I can't recall where from, but I found this as a tutorial method for respawn of creeps (RPG style). I've really enjoyed the concept and have used it quite creatively in many of the triggers for this game (using the CV for stuff.. etc.) I only just recently learned that Wait Game-Time second causes a leak due to a bug. I'd replaced its overuse in all of my triggers, never thinking to check this one...
Thus, here we are. I need to replace the 'wait game-time seconds' with a new method of waiting the duration of that variable before performing those actions without losing the information.
Countdown timers make no sense to me. I don't understand how they work at all. If they are the solution, please also answer the following questions for me:
Respawn
Events
Unit - A unit Dies
Conditions
(Owner of (Triggering unit)) Equal to Neutral Hostile
(Custom value of (Triggering unit)) Greater than 0
Actions
Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
Wait Respawn_Time game-time seconds
Custom script: call SetUnitUserData(CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE),i,GetLocationX(udg_Creep_Point[ii]),GetLocationY(udg_Creep_Point[ii]),udg_Creep_Facing[ii]),ii)
Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
Thus, here we are. I need to replace the 'wait game-time seconds' with a new method of waiting the duration of that variable before performing those actions without losing the information.
Countdown timers make no sense to me. I don't understand how they work at all. If they are the solution, please also answer the following questions for me:
- I've read that they must be 'destroyed after use' and that you must pause them first in order to do so. Is this true, and if so, how do I destroy it? Is this done in custom script?
- Does that mean that setting a variable for a timer is sort of like opening up a vacancy for a timer that can then be set/started via "start timer as a one-shot timer?" If that is the case, would that action be unavailable until the first timer started finishes?
- An extension of question 2, is this where I've read that timers need their array sizes changed so additional values can be initialized?
- Do I 'have' to interact with a timer window when making a timer or is that only when I want the timer to be visible in the top right corner, in-game?
- If I end up using timers, wouldn't that also require me to add the event, "timer (the one started in the respawn trigger) expires" each time a unit dies & needs to be respawned?
Respawn
Events
Unit - A unit Dies
Conditions
(Owner of (Triggering unit)) Equal to Neutral Hostile
(Custom value of (Triggering unit)) Greater than 0
Actions
Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
Wait Respawn_Time game-time seconds
Custom script: call SetUnitUserData(CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE),i,GetLocationX(udg_Creep_Point[ii]),GetLocationY(udg_Creep_Point[ii]),udg_Creep_Facing[ii]),ii)
Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))