NeoMecha v0.3.0 Line of Sight devlog

The goal for v0.3.0 was to implement line of sight working and get replays working

To implement line of sight I started with Path Blocker, Path Blockers being an object on the Game Board that requires the player to go around it. Getting one on the Game Board was easy enough but because I implemented the Path Blocker as another Game Piece, the AI started repeatedly attacking because it spawned closer to the Blocker then to the player. 

AI continuously attacks an object instead of the player

That was a fairly easy thing to fix by ensuring when the AI picked a target it didn’t pick any Path Blockers.

Path Blockers ☑

AI routing around a block to attack the player

Next up was the replay system. I had to create a Game Repository that saved game data and actions. As well as a new scene with a separate game setup code that loaded the new save data. While this took longer then expected, I had to change my command objects so they would serialize correctly, the code flow shaped up as expected.


Replay System ☑

The player and AI moving without input. Replaying a previous game.

Back to line of sight. To implement light of sight I added the concept of a Visibility Map. The Visibility Map encapsulates all the logic for figuring out what tiles are visible from a given Position. Then I made the map available from the game board so that Tiles and Game Pieces could get their visibility from the Gameboard. It is up to the individual Tiles/Game Piece to decided how to render given their visibility. Their is room for improvement. I don’t like how dark the tiles become when they are not visible and sometimes a tiles should be less visible. Moving is also a problem, the Visibility Map for your destination tile becomes active as soon as you start moving. I’d like the Visibility Map to change as you move, so you

have a better sense of movement. I’ll save fixes these issues for a polish sprint.

Line of Sight

The Player moving around a Block. The tiles on the other side of the block are black. Showing that they are not visible

The last piece of line of sight was smoke. I plan to use smoke as both an environmental hazard and as a way to let player disengage from an enemy during combat. This sprint was focused on feature development, so I didn’t add any animation to the smoke grenade throw and focused on how smoke affects line of sight. I added a Smoke list to each tile. Then because the tile is responsible for calculating its own visibility, only the Tile needed to be aware of the smoke. I made a small change to how line of sight was calculated in the visibility map, I changed the starting value from 0 to the visibility index of your tile. That way the smoke on your tile affects your line of sight.

The player uses a smoke gernade on the AI player causing the tiles outside of the smoke to become not visible.

I made sure I tested this with the replay system. Initially the smoke didn’t render because I was not updating the logical game board during the replay. So, I refactored the replay to ensure it updated the logical game board as well as the visual game board.

Smoke ☑

Replayed gameplay with smoke blocking player vision but everything is visible during the replay.