Friday, March 2, 2018

FPS Tower Defense Toolkit Basics: Weighted Wave Spawn Controller

The FPS Tower Defense Toolkit comes equipped with two different types of wave spawning models: one centered around user-defined wave patterns, and another geared towards generating waves based on weighted probability distributions. I covered the former of the two in an earlier article. You can read more about it here: FPS Tower Defense Toolkit Basics: Batched Wave Spawn Controller. Today I'm going over the design of the second model: the Weighted Wave Spawning System.

The WeightedWaveSpawnController is intended to provide the designers with a tool capable of generating waves of AI bots in an automated manner. Unlike its contemporary, which requires the designer to explicitly specify each and every aspect of the wave, we have a system here that spawns units based on a weighted probability distribution. This approach essentially allows us to control the spawn probabilities of different AI classes based on the weights associated with them.

Another factor that helps with the automation process is the threat rating attribute, which keeps increasing with each subsequent wave. As the threat rating goes up, it opens the door for spawning high tier enemies. Meanwhile, the number of low tier enemies may go up as well. Both of these factors together increase the overall difficulty of the game over time.

To aid in the functioning of these systems are a host of variables that can be customized directly from the editor. I will go through each of those attributes one by one and briefly explain their individual functionalities:

1. WeightedWaveSpawnData: Controls the shifting dynamics of waves through the following parameters:
  • NumberOfWaves: Determines the total number of waves.
  • TowerBaseResourceAllocation_BaseValue: The number of towers bases to be distributed to the player per wave.
  • TowerBaseResourceAllocation_StartingBonus: Bonus tower bases to be provided to the player at the start of a level.
  • TowerPointResourceAllocation_BaseValue: Tower points to be distributed to the player prior to the first wave.
  • TowerPointAllocation_LinearGrowthMultiplier: The number of tower points to be distributed to the player keeps changing based on a linear function. This parameter controls the growth rate of tower point allocation with each new wave.
  • WaveThreatRating_BaseValue: Threat Rating of the first wave. Determines the starting difficulty of the level.
  • WaveThreatRating_LinearGrowthMultiplier: The wave threat rating increases with each new wave based on a linear function. This parameter controls its growth rate and thus provides an estimate of how fast the difficulty rises up as the player progresses through the level.
  • SpawnInterval_MinValue: Minimum duration between spawning of individual bots.
  • SpawnInterval_MaxValue: Maximum duration between spawning of individual bots.
  • MaxUnitToWaveThreatRatio: Restricts the types of units that can be spawned in a wave based on the ratio of their threat rating to the wave threat rating. Only AI classes with these ratios less than or equal to this parameter will be spawned. As a result, this feature can be used to prevent high tier units from being spawned during the initial waves.
2. AISpawnWeightingDataArray: Enables setting of the spawn weights, with each element of the array used to represent the spawn probability data about an individual AI class. Each element of the array contains the following attributes:
  • AIType: An enum that defines the AI model.
  • BaseWeighting: Controls the spawn weight of this AI class. Higher values relative to other classes increase the spawn chances, while lower values reduce it.
  • CanBeSpawned?: Determines if this AI type can be spawned. Can be used to control/restrict the types of enemies present in different levels.
  • DataTableRowName: Connects the AI class with the associated row in the DT_EnemyAIStats data table. [No need to explicitly specify this as it will be set automatically by the wave spawn controller]
3. NumberOfWaveCycles: Not applicable to this model. Used by Batched Wave Spawn Controllers to repeat wave patterns.

4. TimedWaveStarts?: Determines if new waves will start automatically after a designated amount of time. If turned off, the player will have to manually trigger new waves.

5. WaveTimerInterval: If TimedWaveStarts? is set to true, then this parameter controls the time interval between waves.