/ #mechanics 

Units

Odds are every strategy game ever created features units! I assume the term comes from ‘military unit’, which probably means the term has its origin in war games.

In strategy games a unit typically refers to a single soldier or vehicle. These units can usually be invividually controlled. If you see a game where units are not individually controlled you are likely dealing with a one of the derivatives of a pure unit-based system like Unit: Formation or Unit: Stack.

So what makes a unit? Let’s look at this unit details screen from Age of Wonders to get some ideas:

Age of Wonders Cavalry Unit

You can see the unit has a type: Elven Scout. It has several numerical statistics:

  • Attack: 7
  • Damage: 2
  • Defense: 3
  • Magic Resistance: 4
  • Movement Points: 3636
  • Health: 77
  • Upkeep: 6

Then there are also several text abilities:

  • Charge: Extra damage on first attack based on distance moved.
  • Forestry: Cheaper movement through forest tiles.
  • Leadership: Extra attack / damage to other units in the same army.
  • Strike: Ability to melee attack enemy units.
  • Vision: Reveals the map around it as it moves.
  • Walking: Can move around the map on solid ground tiles.

So I’ve listed a bunch of things, but you might still be asking - what is a unit? I would define it is an individually controllable, (usually) easily replacable piece in a game that can be used to defend yourself or attack your enemies. What I hope is clear from the listings above is how nicely a unit fits into an ECS game design - you can compose several systems to build unique units and the flexibility of ECS should allow you to easily build a large variety of units with a wide variety of abilities:

  • Combat System: Attack, Damage, Defense, Strike, Charge, Leadership
  • Movement System: Movement points, Walking, Forestry
  • Exploration System: Vision
  • Magic System: Magic Resistance
  • Health System: Health
  • Economic System: Upkeep

ECS Design

No specific code for this one: a unit is built by combining all of the other systems.

Author

Matt Van Der Westhuizen

Back-end service developer at Ubisoft Blue Byte by day - wannabe game designer & developer by night.