Vision Field Improvement

I had a bit of inspiration for how to dramatically simplify vision checks in the game.

Vision checks are used in two situations:

  1. Ranged summons (archer and bomber) look for a suitable target
  2. Monsters check if a hero is directly walkable, so they switch from pathing to Gauntlet style movement

These checks are very expensive for the CPU, because they have to iterate to check for obstruction with the world and other actors in the scene.  I realized that we don’t need this level of precision for monster hunting behavior–tile-based granularity is fine, and since there are few targets (summoner and summons), it’s best to broadcast vision from these sources rather than do constant checks.

Pillars obstruct sight. Monsters on blue tinted tiles will move towards player instead of using pathfinding.
Pillars obstruct sight. Monsters on blue tinted tiles will move towards player instead of using pathfinding.

In this new system, every time the summoner moves to a new tile, it calculates which tiles are visible from that position. Monsters only need to check if they step into one of these zones, and this check is only done when they move from tile to tile. Even with the brute force evaluation of visibility, this is probably 50x faster than the old system. (If it needs to be optimized, there is no shortage of methods for calculating vision).

As a side bonus, the monsters don’t need to be on an interval timer for sight checks. It always checks just when it needs to (on a tile change). There were problems before with monsters stepping too far away from the player because their vision timer hadn’t reset yet, and they were still pathing to a stale position. Now they are way less likely to be confused and aimless at close range.

Feature restored: Aeox and Shaedu Attacking

As is usually the case with a major code overhaul, I disabled many features so I could test stuff out and get it working with each existing system, one at a time. One of the final things I need to restore is the summon AI for targeting and attacking enemies. Their behavior is slightly different from monsters, because they never move to reach another target, but it uses the same code at least.

attacks1

So far, Aeox attacks properly (now with 8-way attacking!) and Shaedu also aims and hits properly. There’s still an issue with her firing trick shots at moving targets between obstacles (like through a doorway if the monster walks past it), which probably has to do with her search interval and vision check code. Something to fix tomorrow, along with the Bloodfire attacks.