This post is mainly about our Fog of War system and how it works. Furthermore, we also presented our project in our first-ever Pitch!
In the last research log, we’ve mentioned that we were in the process of completely revamping both our Load/Save and Team system.
We merged the changes right before writing this post, and just the fact that we changed over 120 files and reworked about 3k lines of code shows how deeply integrated these systems are.
Also, the Fog of War system is part of these changes as well.
Fog of War
The Fog of War (Wikipedia) hides parts of the map and action from players to give them an incentive to explore the environment and make strategic decisions.
We wanted to achieve a system similar to what Age of Empires II has:
This has been the standard in most RTS games over the past years.
Breaking it down, we have three states:
Initially, every team sees nothing but the immediate area around its mother cell, increasing in size with the player’s base. Visited Areas, that are now out of range of any entity, enter the Foggy state. If an entity visits a Foggy area, it will become visible again!
We should also mention that the Fog of War map is 2D-only, and exploring a new area also uncovers the depths below and the skies above.
Every entity-type defines a modifiable Range of Sight, which describes how many tiles around the entity will become Visible.
In a recent Research Log, we explained how our Map system works, and why we are limited to 2^16 – 1 (65,535) entities on the whole Map.
Now, every Tile (remember, the Fog of War map is in 2d-space only) consists of a 16-bit Integer and a Boolean. Every entity now tells the map when it has moved, spawned or died, to update its Range of Sight. The entity just increases the integer by 1 if it can see the tile, and decreases it when it has moved and the tile is not visible anymore.
Once our value is greater than 0, the map is visible. In this case, we set the Boolean to true, indicating that the value has been greater than 0.
This now translates to the following states:
- Hidden: The integer is equal to 0 and the Boolean is still false
- Visible: The integer is greater than 0. Also, the Boolean is now true.
- Foggy: The integer is equal to 0 but the Boolean is still true!
This is actually how simple it is to implement a Fog of War system. Keep in mind that we can have up to 8 teams, and the Fog of War is calculated per team. We just save the tiles in a 3-dimensional array (with 8 as the height) and can now easily differentiate between the teams’ Fog of Wars.
The only thing that’s left to do as of now is the actual rendering, as everything so far is data-only. It will be possible to override the Fog of War per team (setting a flag in the core), but it’s still the Rendering’s task to do the right thing with the data!
We have been invited to pitch our project as part of the final event of the build! Accelerator. For us, or especially for me, it was the first time I’ve ever pitched something, and it turned out to be a very nice experience. We had some pitching-sessions before (as part of the accelerator program), and the skills learned there will definitely help us in the long run.
In the next week, we’ll finish transferring the last two remaining systems into 3d and continue with the rendering tasks.
Make sure to follow us on Twitter for our latest updates!
See ya next week!