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

[Trigger] Can I avoid a temp variable?

Status
Not open for further replies.
Level 4
Joined
Jun 10, 2007
Messages
46
Okay, consider these two segments of code:

  • Unit - A unit Dies
  • WARP FIELDS Lightning Strike
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set Loc = (Random point in WARP FIELDS <gen>)
      • Special Effect - Create a special effect at Loc using Abilities\Spells\Other\Monsoon\MonsoonBoltTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Set Ugroup = (Units within 250.00 of Loc matching ((((Matching unit) is A Hero) Equal to False) and (((Matching unit) is A structure) Equal to False)))
      • Unit Group - Pick every unit in Ugroup and do (Actions)
        • Loop - Actions
          • Set Loc2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (500.00 x ((250.00 - (Distance between Loc and Loc2)) / 250.00)) Greater than or equal to 0.00
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (500.00 x ((250.00 - (Distance between Loc and Loc2)) / 250.00)))
            • Else - Actions
              • Game - Display to (All players) the text: (This is firing incorrectly. + (( + ((String((X of Loc))) + ( + (String((Y of Loc)))))) + (String((Distance between Loc and Loc2), 5, 5))))
          • Custom script: call RemoveLocation(udg_Loc2)
      • Custom script: call DestroyGroup(udg_Ugroup)
      • Custom script: call RemoveLocation(udg_Loc)
This is my question........

If...
  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (500.00 x ((250.00 - (Distance between Loc and Loc2)) / 250.00)))
...... kills the unit in question, which happens first: the rest of the trigger, or the

  • Unit - A unit Dies
event? Because when I run it, it seems that the event runs first.

So basically, is there a way to do this without defining a temporary variable?
 
Level 4
Joined
May 16, 2004
Messages
76
Perhaps, you could nest another if/then/else statement inside your then clause to check the life of the unit that it is more then the damage being recieved and if it is not, you could set it to run that other trigger where a unit dies?

Taking into account that the unit- a unit dies trigger would be intially off
 
Level 4
Joined
Jun 10, 2007
Messages
46
That's not exactly the problem........

Perhaps, you could nest another if/then/else statement inside your then clause to check the life of the unit that it is more then the damage being recieved and if it is not, you could set it to run that other trigger where a unit dies?

Taking into account that the unit- a unit dies trigger would be intially off

The variable Loc is the problem. It's my all-purpose variable and is used in at least one of the death triggers. If it runs then the variable gets deleted.

I AM using a temp variable now and it works fine, but I don't like the style, so if you know any other means to do it, I'd like the advice.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I think the way you did it will cause you no problems with variables.
But:
  • (500.00 x ((250.00 - (Distance between Loc and Loc2)) / 250.00)) Greater than or equal to 0.00
Is a shitty condition.
I think you just want to check if (250 - (distance between loc and loc2)) is more than 0.
Also:
  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (500.00 x ((250.00 - (Distance between Loc and Loc2)) / 250.00)))
(500.00 x ((250.00 - (Distance between Loc and Loc2)) / 250.00))
That is equal to 2x (250 - (distance between loc and loc 2)).
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
The rest of the trigger will run first. Functions are only interrupted by calling other functions, ExecuteFunc, Evaluate/ExecuteTrigger, ForGroup, ForForce, TriggerSleepAction and probably a few others like them that have slipped my mind, but that's about it.

GUI wise, events in other triggers NEVER interrupt other triggers, unless that trigger has a wait in it.
 
Status
Not open for further replies.
Top