How to build

Level 2
Sep 7, 2014
How do you make a trigger that will force the worker to build a building and after the building is finished, it must produce units every 5 sec. Also if the building will be destroyed the worker stars to build another.
Unit - Issue Build Order.

  • Init
  • Events
    • A unit finishes construction
  • Conditions
    • Unit-type of (Triggering unit) Equal to X
  • Actions
    • Unit Group - Add (Triggering unit) to ProductionGroup
    • Trigger - Turn on Production <gen>
  • Production
  • Events
    • Time - Every 5.00 seconds of game-time
  • Conditions
  • Actions
    • Unit Group - Pick every unit in ProductionGroup and do (Actions)
      • Loop - Actions
        • Set TempU = (Picked unit)
        • Set Point1 = (Position of TempU)
        • Set Point2 = (Point1 offset by 200.00 towards 270.00 degrees)
        • Unit - Create 1 Y for (Owner of TempU) at Point2 facing Default building facing degrees
        • Custom script: call RemoveLocation (udg_Point1)
        • Custom script: call RemoveLocation (udg_Point2)
  • Death
  • Events
    • Unit - A unit dies
  • Conditions
    • ((Triggering unit) is in ProductionGroup) Equal to True
  • Actions
    • Unit Group - Remove (Triggering unit) from ProductionGroup
    • If (All conditions) then (Actions) else (Actions)
      • If - Conditions
        • (ProductionGroup is empty) Equal to True
      • Then - Actions
        • Trigger - Turn off Production <gen>
      • Else - Actions
Integrate the Unit - Issue Build Order in the Death trigger; I am not sure how you manage your builders or how vulnerable they are, so I didn't create that part.

Alternatively, there are abilities that generate a unit every X seconds, but a) they are visible (and some of them not functional, if hidden with a Spell Book) and b) the trigger's more flexible.