I've noticed a strange thing when trying to get the "Triggering unit, or "Owner of Triggering unit with the event, "Unit Dies" when using a wait action.
The trigger is for a hero respawn and has some typical things like modifying the minerals, letting the player know how much they lost etc. Here is what it looks like.
Unit-AnyUnitdiesLocalVariablestimer=(Newtimer)<Timer>Conditions(Triggeringunit)==DestroyerHeroPlayer1ActionsUI-Display((Text(Nameofplayer(Ownerof(Killingunit)))withcolor(Color((Currentplayer(Ownerof(Killingunit))color))))+(" has killed "+(Text(Nameofplayer(Ownerof(Triggeringunit)))withcolor(Color((Currentplayer(Ownerof(Triggeringunit))color))))))for(Allplayers)toChatareaUI-Display("You have been killed! You have lost..."+((Text(((Player(Ownerof(Triggeringunit))Minerals)/6)))+(" minerals and…"+((Text(((Player(Ownerof(Triggeringunit))Vespene)/6)))+" gas."))))for(Playergroup((Ownerof(Triggeringunit))))toSubtitleareaPlayer-Modifyplayer(Ownerof(Triggeringunit))Minerals:Subtract((Player(Ownerof(Triggeringunit))Minerals)/6)Player-Modifyplayer(Ownerof(Triggeringunit))Vespene:Subtract((Player(Ownerof(Triggeringunit))Minerals)/6)Variable-ModifyDeathcounterplayer1:+2Timer-Createatimerwindowfortimer,withthetitle((Nameofplayer(Ownerof(Triggeringunit)))+" Destroyer respawning in…"),usingRemainingtime(initiallyVisible)Timer-StarttimerasaOneShottimerthatwillexpireinDeathcounterplayer1RealTimesecondsTimer-Anchor(Lastcreatedtimerwindow)totheBottomLeftofthescreen,offsetby(0,0)General-WaitDeathcounterplayer1RealTimesecondsUnit-Create1Destroyer(Hero)forplayer(Ownerof(Triggeringunit))atLeftsideusingdefaultfacing(NoOptions)
Here is the problem. The hero won't respawn. And here is why. The Trigger loses what was the triggering unit when you use the Wait action. I've done it a million times. If I remove the wait action, which in this case, is simply a variable which is being modified each time the player's hero dies, if I remove that wait, then it will work.
Consequentially, this problem has forced me to do some really annoying things on my map. Such as having an individual trigger for every single player # and their hero respawn. That is super annoying and it limits me.
I don't understand why the "Wait" action causes the editor to lose that information on what is the triggering unit.
Your topic is a statement. Any time you use a wait, you stand a strong chance of losing your references. Here is a way to understand it:
A trigger can only fire once at a time.
This trigger is being executed from top to bottom,
During a wait nothing is happening
the event happens again during the wait
The "triggering unit" in the event, is now a new unit, while the trigger is running
Bad stuff happens
If you really want to use waits, you can create action definitions with their own thread. I assume you dont know what that means, so your best bet is just to do what ducky suggests
if you have consumable items and you are using "any unit uses item" on the last charge not even a wait is required to loose reference to the triggering item. triggering unit is just a variable that is set on certain occasions and therefore overwritten whenever one of these occasions happens (in this case the unit got removed from the game and cannot be referenced anymore)
So this helps for the unit, but what about the player #? We want 1 single trigger for all player respawns, regardless of the hero type. If you store the dying unit in a local variable, how would you also store the owner of that unit? Local Variable as integer = to owner of dying unit?
I've noticed a strange thing when trying to get the "Triggering unit, or "Owner of Triggering unit with the event, "Unit Dies" when using a wait action.
The trigger is for a hero respawn and has some typical things like modifying the minerals, letting the player know how much they lost etc. Here is what it looks like.
Here is the problem. The hero won't respawn. And here is why. The Trigger loses what was the triggering unit when you use the Wait action. I've done it a million times. If I remove the wait action, which in this case, is simply a variable which is being modified each time the player's hero dies, if I remove that wait, then it will work.
Consequentially, this problem has forced me to do some really annoying things on my map. Such as having an individual trigger for every single player # and their hero respawn. That is super annoying and it limits me.
I don't understand why the "Wait" action causes the editor to lose that information on what is the triggering unit.
I think the common practice is saving triggering unit into local variable and then using that instead.
If you have waits - it's always best to save event variables that into local variables.
Your topic is a statement. Any time you use a wait, you stand a strong chance of losing your references. Here is a way to understand it:
A trigger can only fire once at a time.
This trigger is being executed from top to bottom,
During a wait nothing is happening
the event happens again during the wait
The "triggering unit" in the event, is now a new unit, while the trigger is running
Bad stuff happens
If you really want to use waits, you can create action definitions with their own thread. I assume you dont know what that means, so your best bet is just to do what ducky suggests
Skype: [email protected] Current Project: Custom Hero Arena! US: battlenet:://starcraft/map/1/263274 EU: battlenet:://starcraft/map/2/186418
if you have consumable items and you are using "any unit uses item" on the last charge not even a wait is required to loose reference to the triggering item. triggering unit is just a variable that is set on certain occasions and therefore overwritten whenever one of these occasions happens (in this case the unit got removed from the game and cannot be referenced anymore)
@FunkyUserName: Go
Thanks for the info!
@onlyleviathan: Go
So this helps for the unit, but what about the player #? We want 1 single trigger for all player respawns, regardless of the hero type. If you store the dying unit in a local variable, how would you also store the owner of that unit? Local Variable as integer = to owner of dying unit?
@onlyleviathan: Go
Yes
@BigDonRob: Go
Cool! Thanks for the help guys!
@BigDonRob: Go
Cool! Thanks for the help guys!