• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Failed in MUI Situation - Why?

Status
Not open for further replies.
Level 18
Joined
Mar 16, 2008
Messages
721
So this runs when players are defeated and moves their heroes to 'heaven' - more of a cosmetic thing. However seems "Rezing_Hero_Hev_Var" got rewrote half way through the trigger. I thought only 1 trigger could run at a time? Is the solution to just make more variables? thanks for any feedback.

  • Heroes Hev Rez Red
    • Events
      • Time - Royal_Hev_Rez_Timer[1] expires
    • Conditions
    • Actions
      • Trigger - Turn off Red King Stay in <gen>
      • Trigger - Turn off AI Hero Dies Red <gen>
      • Set VariableSet Ran_Num_Rez_Var = (Random integer number between 1 and Rez_Pt_Count)
      • Set VariableSet Rezing_Hero_Hev_Var = Red_King
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot (Integer A) of Rezing_Hero_Hev_Var.
      • Hero - Instantly revive Rezing_Hero_Hev_Var at Rez_Pt_Var[Ran_Num_Rez_Var], Show revival graphics
      • Unit - Move Rezing_Hero_Hev_Var instantly to Rez_Pt_Var[Ran_Num_Rez_Var]
      • Custom script: call RemoveLocation(udg_Rez_Pt_Var[udg_Ran_Num_Rez_Var])
      • Unit - Make Rezing_Hero_Hev_Var Invulnerable
      • Unit - Change ownership of Rezing_Hero_Hev_Var to Neutral Passive and Retain color
      • Unit - Change color of Rezing_Hero_Hev_Var to Snow
      • Custom script: call SetUnitPropWindow(udg_Rezing_Hero_Hev_Var, 0.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ran_Num_Rez_Var Not equal to Rez_Pt_Count
        • Then - Actions
          • Set VariableSet Rez_Pt_Var[Ran_Num_Rez_Var] = Rez_Pt_Var[Rez_Pt_Count]
        • Else - Actions
      • Set VariableSet Rez_Pt_Count = (Rez_Pt_Count - 1)
      • Set VariableSet Ran_Num_Rez_Var = (Random integer number between 1 and Rez_Pt_Count)
      • Set VariableSet Rezing_Hero_Hev_Var = Red_Prince
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot (Integer A) of Rezing_Hero_Hev_Var.
      • Hero - Instantly revive Rezing_Hero_Hev_Var at Rez_Pt_Var[Ran_Num_Rez_Var], Show revival graphics
      • Unit - Move Rezing_Hero_Hev_Var instantly to Rez_Pt_Var[Ran_Num_Rez_Var]
      • Custom script: call RemoveLocation(udg_Rez_Pt_Var[udg_Ran_Num_Rez_Var])
      • Unit - Make Rezing_Hero_Hev_Var Invulnerable
      • Unit - Change ownership of Rezing_Hero_Hev_Var to Neutral Passive and Retain color
      • Unit - Change color of Rezing_Hero_Hev_Var to Snow
      • Custom script: call SetUnitPropWindow(udg_Rezing_Hero_Hev_Var, 0.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ran_Num_Rez_Var Not equal to Rez_Pt_Count
        • Then - Actions
          • Set VariableSet Rez_Pt_Var[Ran_Num_Rez_Var] = Rez_Pt_Var[Rez_Pt_Count]
        • Else - Actions
      • Set VariableSet Rez_Pt_Count = (Rez_Pt_Count - 1)
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
I thought only 1 trigger could run at a time?
Yes, but if something in trigger A causes trigger B to fire, B interrupts A and A will only resume once B has finished (or hit a wait). This also applies to a trigger C being fired because of something B did, and so on ad infinitum. If A sets a variable to x, but then B sets it to y... in the part of A that runs after B, the variable will be y not x.

Something in this trigger is causing another trigger to fire which is overwriting that variable. However, there's also this line that explicitly changes the variable halfway through:
  • Set Rezing_Hero_Hev_Var = Red_Prince
 
Level 18
Joined
Mar 16, 2008
Messages
721
well what happened was two players got eliminated at nearly the exact same moment, which is rare but i still want it to work in those situations. it seems like one of the heroes got moved to 'heaven' but the ownership action didn't seem to fire. for the other 3 heroes it seemed to work fine.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
Simultaneity doesn't exist, it's always an order of operations.
I think this mostly can be solved by the technique of shadowing global variables.
  • Actions
    • Custom script: local udg_SomeVariable
    • Set VariableSet SomeVariable = (Random integer number between 1 and 10)
This sort of thing. Now, I don't know which variables are been overwritten, so I would just do this logic to every variable you're using there, unless you find out the culprit.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,541
Simultaneity doesn't exist, it's always an order of operations.
I think this mostly can be solved by the technique of shadowing global variables.
  • Actions
    • Custom script: local udg_SomeVariable
    • Set VariableSet SomeVariable = (Random integer number between 1 and 10)
This sort of thing. Now, I don't know which variables are been overwritten, so I would just do this logic to every variable you're using there, unless you find out the culprit.
Keep in mind that shadowed variables are inaccessible in Condition blocks so lines like these won't work with them:
  • If - Conditions
    • Ran_Num_Rez_Var Not equal to Rez_Pt_Count
 
Status
Not open for further replies.
Top