• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to make trigger that count units

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
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: 17
Last edited:
Status
Not open for further replies.
Top