1. The Hand of Merlin
  2. News
  3. Dev blog 46 - Waves of enemies

Dev blog 46 - Waves of enemies

Hi!

Some time ago, our designer boi Mat asked me if we can do something different for a couple of skirmish maps regarding how the fights progress. He wanted to have enemies spawn during fights and have it controlled externally through some sort of wave spawning system. While we can spawn new units during fights through abilities, I didn’t want to hack this functionality using invisible units that use hidden abilities to spawn new units.

We’re making the game in Serious Engine which has support for spawners, but a lot of our code is not really compatible with that method. We have custom needs for spawning units anyway, so we had to approach it differently. Luckily, the scripting side of the engine is flexible enough and made this possible with relative ease. A bit of tech background:
When any skirmish fight starts, there is a single script in that world that spawns the starting enemies. The script takes into account any decisions made during the encounter that lead to the fight in order to spawn units and players at different locations and configurations. Until now, this script was only ever executed once.
To make the spawn system, we needed to make this script wait for specific events from our game code in order to do more things. Currently, we have a “round started” event that gets picked up by the script, and spawns new units based on any internal decision making, like whether the enemy warband has less than 2 units, and whether all reinforcement units have already spawned. For now, this is the only event we need.



The biggest difference between the wave spawning and initial unit spawning is in tile occupancy and spawning animation.
When we spawn units for the start of the fight, we don’t have to check for multiple units occupying the same tile. This is very obvious to the designer when making the initial spawn setup, and is very easy to test if it all works. We also don’t have to play special animations on those units, because we’re assuming they were already there when the player characters arrive there. So they all just appear in their Idle animation.
When spawning units for the wave system, this happens in the middle of a fight. Units have likely already moved around and might be occupying tiles where we wanted to spawn wave units. Thus, we have to find an unoccupied spawn point within a named group to use for the new unit position, and we have to play an animation on that unit unless we want it to look pretty horrible.



The plan is to use this system primarily for boss fight maps (especially the final boss of the game), but it’s not a stretch it will be used in regular fights as well. This mostly means we’ll have to add a new animation to some, if not all, abomination units so we can use them for this system. Human enemies will likely not be dynamically spawned, because we can’t make them unburrow like the Mandrake above (tho that would be funny as hell), but we might find a way to let them walk in from off-screen or something. This does have some unrelated issues, but if we manage to sort them out, we might use it.
Personally, I can't wait to see how the rest of the abominations look like when they spawn through this.

Thanks for reading about some of the stuff we’re working on. If you’d like to say hi to us, ask questions, or tell us how much our game sucks, come join our Discord server, all the devs are there and are very friendly and receptive to all feedback.

MarkoP

https://store.steampowered.com/app/600610/The_Hand_of_Merlin/