• 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.

Automatically train units when a building is constructed

Status
Not open for further replies.
Level 5
Joined
Jul 13, 2010
Messages
84
Barracks Finish
Events
Unit - A unit Finishes construction
Conditions
(Triggering unit) Equal to BarracksVariable
Actions
Unit - Order BuilderVariable to build a Supply Depot at (Center of Supply Depot1 <gen>)
Unit - Order BarracksVariable to train/upgrade to a Marine
Unit - Order BarracksVariable to train/upgrade to a Marine
Trigger - Turn on Marine Variable new <gen>
Trigger - Turn off (This trigger)


Barracks Variable
Events
Unit - A unit Begins construction
Conditions
(Triggering unit) Equal to BuilderVariable
Actions
Set BarracksVariable = (Constructing structure)
Trigger - Turn on Barracks Finish<gen>
Trigger - Turn off (This trigger)
I'm trying to get the barracks to train marines when it finishes, but it doesn't....idk something is apparantly wrong with this trigger? Plz help it's so confusing. Do buildings not constitute as units? Do buildings currently being build not constiture as a Constructing structure??????
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You can use
  • tags to post triggers :)
  • Units are not constructed. Units are "Trained". Buildings are Constructed.
  • [Trigger]
  • Unit - Order BuilderVariable to build a Supply Depot at (Center of Supply Depot1 <gen>)
It leaks Point. ---Fix--->
  • Set Point = Center of Supply Depot 1 <gen>
  • Unit - Order BuilderVariable to build a Supply Depot at Point
  • Custom script: call RemoveLocation(udg_Point)
If you want Barracks to train marines, why don't you just add the Marines into the possible Units to train in the Object Editor, in the Barracks data?

  • Barracks Variable
  • Events
    • Unit - A unit Begins training a unit
  • Conditions
    • (Triggering unit) Equal to BuilderVariable
  • Actions
    • Set BarracksVariable = (Triggering Unit)
    • Trigger - Turn on Barracks Finish<gen>
    • Trigger - Turn off (This trigger)
 
Level 12
Joined
Oct 16, 2010
Messages
680
Unit - A unit Finishes construction
for this , Triggering Unit refers to the builder not the building . Use "Constructed Structure"

buildings counts as units

EDIT: and also you should make it clear to us which variable is a structure and which variable is worker(think builder is a worker,barrack is a structure:D)and explain which trigger what should do exactly
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok... sorry... I got messed with the names. BuilderVariable is the Worker/Builder... Then follow Lender suggest.

  • Events
    • Unit - A unit Finishes construction
  • Conditions
    • (Triggering unit) Equal to BarracksVariable
The unit that "Finishes Construction" is the worker, not the building. =)
 
after the unit is constructed, add it to a looping group...something like this...
  • Build
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • //specify your condition
    • Actions
      • Unit Group - Add (Triggering unit) to StructureGroup
      • Set StructureIndex = (StructureIndex + 1)
      • Trigger - Turn on Train <gen>
  • Train
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in StructureGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • //specify your condition
            • Then - Actions
              • Unit - Order (Picked unit) to train/upgrade to a Footman
              • Unit - Order (Picked unit) to train/upgrade to a Rifleman
            • Else - Actions
              • Unit Group - Remove (Picked unit) from StructureGroup
              • Set StructureIndex = (StructureIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Integers Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Status
Not open for further replies.
Top