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

Issue with trigger.

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
  • Death
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • (Unit-type of (Triggering unit)) Equal to Human
        • Then - Actions
          • Unit Group - Pick every unit in (Units in (Entire map) owned by Player 1 (Red)) and do (Actions)
            • Loop - Actions
              • Wait 0.00 seconds
              • Unit - Replace (Picked unit) with a Scout Tower using The old unit's relative life and mana
        • Else - Actions
So I assume picked unit is not used for loops and only the event? How can I make this work then.
 
Level 11
Joined
Jun 2, 2004
Messages
849
Triggering unit is actually local and fine to use after waits, fyi. Though it's correct to not use picked unit since it's a global and can be changed/nulled by another trigger.

I'm not sure why it would crash, but if you're worried about infinite loops then just add a if/then/else check to not replace scout towers. Also since scout towers are buildings there are a few crash possibilities, such as being too close to the map edge.
 
Level 12
Joined
Dec 2, 2016
Messages
733
Triggering unit is actually local and fine to use after waits, fyi. Though it's correct to not use picked unit since it's a global and can be changed/nulled by another trigger.

I'm not sure why it would crash, but if you're worried about infinite loops then just add a if/then/else check to not replace scout towers. Also since scout towers are buildings there are a few crash possibilities, such as being too close to the map edge.

Wait so I can't have multiple triggers using the pick unit and replace action? What should I do then to make it local?
 
Level 11
Joined
Jun 2, 2004
Messages
849
You can have multiple triggers use picked unit/etc, but you just can't have waits between the variable being set and it being used.

So, for the unit response variables like "casting unit", you can't have a wait in the trigger. Otherwise, there's a very good chance "casting unit" will be overwritten during the wait period. ("triggering unit" is an exception to this but is afaik the only one)

For picked unit/matching unit, you can't have a wait within the code block where those variables make sense. So no waits within "pick every unit..." blocks. You CAN have a wait between "pick every unit..." blocks, like so:
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • Game - Display to (All players) the text: (Name of (Picked unit))
  • Wait 2.00 game-time seconds
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • Unit - Explode (Picked unit)
 
Status
Not open for further replies.
Top