[2] Mr. Grubba, Combat Progress
06/19/2019, 10:03am
As much as I wanted to dedicate this entire week to dev, I ended up getting a cat. His name is Mr. Grubba and I love him.
But, I have somehow managed to get a bit done on the game. Health is now synced between clients, and attacks actually do damage. When a character reaches 0 HP, they just kinda glitch out and walk around like a zombie. Fun!
Now that characters can trade basic hits, The goal now is to tie combat and movement together so that characters attempt to stay within attack range of their target. This is a little tricky because this is a coupling between the two systems, but I have been trying to avoid such dependencies. Luckily, as I mentioned in the last post, I have a cool EventChannel implementation that is working working well enough. So, when a character begins combat, the combat system sends a FollowEvent to the movement system, telling that character to start "following" the target. Typically, characters just move to a static "destination", mark themselves as arrived, and stop. When following, however, characters need to get in range of another character, and continue to stay in range even if the target has moved since the follow started. When the character is following, I can probably achieve this behavior by updating the characters destination every tick and never "arriving". If the character is within range, they will stand still and combat can proceed.
The big takeaway from this design is that my current way of syncing movement across clients doesn't quite work. When characters simply move from A to B with a set speed, I can send one MovePacket to each client, they can perform the movement on their end, and everyone will stay pretty much synced up. Of course, I'm not accounting for lag, but prematurely optimizing away issues that don't exist yet is an non-goal of this project. Anyway, since character destinations can change on the fly now due to their follow target being able to move, I need a more consistent way to sync movement state.
For now, I'm gonna make a modification to the movement system so that if a character is following another one (and thus has a more volatile movement state), MovePackets will be sent once per second (at the moment, every other tick), containing the most up-to-date state info. In the end, the actual update frequency I roll with is gonna be dependent on how it feels and what level of network activity the game ends up supporting. My next post will contain the results of this experiment.