How to make trigger that count units

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 57
Joined
Aug 10, 2018
Messages
5,600
Create a Unit Group variable or Integer variable, both are viable choices.

Integer example:
  • Integer Example
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • UnitCount Less than 10
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set VariableSet UnitCount = (UnitCount + 1)

A Unit Group is used to contain units.
You can Pick through a Unit Group to reference the units contained inside and even get information about it like how many units are inside of it, like so:
  • UG Example
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (Number of units in YourUnitGroup) Less than 10
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to YourUnitGroup

Next you'll want to manage your Unit Group or Integer if one of the related units dies.
  • UG Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in YourUnitGroup.) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from YourUnitGroup.
OR
  • Integer Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set VariableSet UnitCount = (UnitCount - 1)
 

Attachments

  • Variable Examples.w3m
    16.8 KB · Views: 10
Last edited:
Status
Not open for further replies.
Top