Wednesday, April 4, 2018

FPS Tower Defense Toolkit v3.1 Dev Log #1: The Introduction of Multiple Power Cores

[Minor Spoilers ahead: The opening paragraph goes into minor spoiler territory on the story of Sanctum 2]

The ending of the third act of Sanctum 2 marks a pivotal point in its story-driven campaign. Players are finally presented with the reason behind recent waves of coordinated attacks against human settlements and outposts by the planet's native life forms. However, that's not the only thing that makes it interesting. The final mission of the chapter, titled Abandoned Lab is one of the only two maps from the base game where players are tasked with defending multiple cores. The inclusion of an extra core in these maps added a completely new layer of challenge as tower placement needed to be balanced along two paths that couldn't be merged. Having two cores to protect also presented a situation that required the players to split up their team in order to defend multiple paths to the cores, especially during later waves when powerful enemies start advancing against both cores simultaneously. I've found myself returning to this map quite a few times even after I finished the main campaign. Since the FPS Tower Defense Toolkit was inspired by Sanctum 2, adding support for multiple cores was among the features planned for the first round of post-release updates. But due to more pressing feature requests, it got sidelined. And that remained the case for quite some time, until recently, when a customer brought up the idea again.


So that got me thinking again about integrating support for multiple cores into the toolkit. To give people the power to design their own versions of the iconic Abandoned Lab. After going over the rough design plan, I realized that it would barely require any changes at all. The core idea would be centered around creating a link between enemy spawn points and power cores. All AI bots spawned from a specific enemy spawn point will receive directives to set the linked power core as their prime target.

To start with the implementation, I added a new variable to the BP_EnemySpawnPoint class for storing a reference to its linked Power Core. The variable was then publicly exposed so that this link could be easily set up by the designer directly from the editor.


The next thing to consider was to give the AI bots access to this information. This is necessary because the player can pull enemy units from their standard paths. If the bots later lose interest in the player, they should be able to return to the core assigned to them. And that required making some modifications to the Enemy AI Manager class.

The Enemy AI Manager class keeps a dynamically updated list of all entities that can be targeted by the enemy AI bots. Until now, this list included only the power core and the player character. So I made some slight alterations to ensure that references to all the power cores get placed at the top of the array. The underlying reason behind doing so is to have static references to the cores within the list. While the player character can get destroyed during a wave, the indices of the core will remain constant irrespective of changes made to the list at runtime. Due to the static nature of these indices, individual AI units can use the index of their assigned core to fall back to their primary objective whenever required. After making a few more minor changes within the AI blueprints to reflect the aforementioned design alterations, the AI was completely capable of functioning within the updated feature set.



With that, we've come to the end of this dev log. Stay tuned for the next update where I'll go through the process of making improvements to the weighted wave spawning system.