Game Development Reference
In-Depth Information
FIGURe 6.47
rTs building
mechanics
RTS Fighting
An efficient way of modeling mechanics for combat between units is to give every
unit a chance to destroy one unit of the opposition in each time step. This is best
implemented with a multiplier. Figure 6.48 illustrates this mechanism. It features
generic units from two armies (red versus blue), each in a pool; blue has 20 units,
and red has 30. Every unit has a 50% chance of destroying an enemy unit in each
time step. This is implemented with a state connection from the pool (the dot-
ted line marked +1m) that controls how many units the blue army will try to drain
from the red army, and vice versa. As blue has 20 units at the beginning of the run,
the resource connection between the red pool, and its drain reads 20*50%—that is,
the 20 blue units each have a 50% chance of killing (draining) a red unit. Similarly,
the 30 red units each have a 50% chance of killing a blue unit. In the first time step,
the calculation will run, and some number of each armies units will be drained. The
state connection will then update the flow rate of the resource connection to reflect
the new number of units in each pool.
NOTE remember
that a state connec-
tion always tracks
changes in the node
that is its origin. in
Figure 6.48, the state
connections reduce the
multipliers that they
point to because their
origin pools are being
drained.
 
Search WWH ::




Custom Search