Today was focused on getting the monsters to behave as intelligently as they did back when movement was tile-based.
- Monsters uncrowd when they are overlapping (should pretty much never happen in general, but sometimes they spawn in the hitbox of another creature). If an intersection is detected between two creatures, they get an override that compels them to move away from each other for a few frames.
- Cardinal directional movement replaced with simple vectors, to allow for diagonal movement.
- When monsters have a line of sight and can walk directly to a hero, they use 8-way movement to get there. I added a bit of tolerance to the check to prevent the monster from zigzagging when on the same X or Y coordinate.
- Without line of sight, the monsters fall back on pathfinding (that is, if the monster is intelligent enough.. more on AI changes in another post). Just like with direct walking (which I call Gauntlet Movement in the code), it uses 8-way movement. This was really easy to do with my existing path mapping: it just checks the 8 adjacent tiles by including directions, rather than only the 4 adjacent tiles in cardinal directions.
- When monsters are in melee range, they can attack in 8 directions.
A quick word on diagonal movement. In many games with two-dimensional movement, the X and Y movement vectors simply get combined, and not adjusted for the trigonometry. Bishop movement becomes unnaturally faster than rook movement in this case. Think Doom II or Secret of Mana.
After spending so long with these games, my adjustment to trim diagonal speed actually feels like a real debuff. It seems slower even though it’s the same speed. For now it’s still in there, but I’m not sure what I’ll do later. A friend suggested the fast diagonal movement be a powerup.
Recently I’ve encountered that diagonal problem as well when testing out movement. Basically what I did was normalizing the vector and multiplying it with movement speed… Which makes sense logically, you don’t magically speed up in RL because you suddenly walk diagonally. But because it was also only 8-directional movement and not analog, it felt like a weird slowdown whenever I moved diagonally.
It feels much slower normalizing the vector than it feels faster in comparison to simply adding both vectors. You say “After spending so long with these games….” – Do you think that’s simply because you (well, and me too) are perceiving this as a debuff because you played other games where it’s simply faster? Or is that a general thing?
Exactly, after playing so many games with “diagonal magic” it’s just an expectation at this point. As a quick update, I’ve currently got all creatures using diagonal magic for walking, and it feels great. It’s not so much of a powerup if the monsters can do it when they chase you. One place I do normalize the vectors is vision range and projectile attacks.