| 06-04-2004, 02:26 AM | #1 |
I know that I can do the following with 12 separate triggers, but need helping combining them into 1. I have a custom spell that starts a timer when it is cast upon a player's hero, and stores the timer in a timer array (the index of the array is the player's number). Countdown Timer - Start DimensionalAnchorTimer[(Player number of (Owner of (Target unit of ability being cast)))] as a One-shot timer that will expire in (45.00 x (Real(DimensionalAnchorLevel))) seconds The problem is executing the Timer Expires event correctly. While I could easily create 12 triggers and have each trigger set with the Event: Time - DimensionalAnchorTimer[index] expires, I would prefer to have all of the Events in 1 trigger and use If/Then/Else actions. Is there any way to get the index value of the timer that actually set off the trigger? All I have found in the GUI using WEUnlimited is a command for grabbing the "event id", but this only helps when using multiple Events of different types. If this can't be achieved in 1 trigger using the GUI, could JASS accomplish this, and if so, how? |
| 06-04-2004, 05:54 AM | #2 |
did you know that you can put multiple events in one trigger and if any one of them happens it sets the trigger off? so just use your timer[index] event and copypaste it for all 12 and change the number.. then if any of em happen it will run the one trigger. if thsi helped mind hooking me up with some rep points? |
| 06-05-2004, 03:24 PM | #3 |
That wasn't quite what I was asking. I know that I can put all 12 events into one trigger, but if I do that, I need a way to know which of the 12 timers set off the trigger. |
| 06-05-2004, 07:42 PM | #4 | |
Quote:
While I know of no way how to indenitify which Timer has expired, I do know of a way to find when a unit dies. The action Code:
Unit - Add a 60.00 second Generic expiration timer to (Triggering unit) |
| 06-05-2004, 07:46 PM | #5 | |
Quote:
I know of no way telling which Countdown expires, but I do know of a way of finding when a unit dies. Adding a timer to a custom unit with the Unit - Add a 60.00 second Generic expiration timer to (Triggering unit) will allow you to detect when the unit dies, and more. It would void your trigger with little If/Thens because you can easily find the player number of the dying unit and use it as the index. You could even add a custom value to the unit which creates many more possibilities. |
| 06-05-2004, 07:51 PM | #6 |
nah, use a loop and a result integer variable Code:
for each integer a from 0 to Number do actions custom script: if GetExpiredTimer() == udg_TimerArray[bj_forLoopAIndex] then set result=(Integer A) custom script: endif Anyways replace udg_TimerArray with udg_NameOfTimerArray and the Number with the maximum number of timers. I think it should be possible to do in gui if there is a timer comparission, but my memory tells me there isn't |
| 06-06-2004, 01:29 AM | #7 |
Thanks a lot, Lord Vexorian. I can't fully test to make sure this works yet, but if nothing else, I got no compile errors. :D |
| 06-06-2004, 12:30 PM | #8 |
Lord Vexorian has it right on the money. If you know JASS, you dont even need a trigger. Using the native function "TimerStart", you can specify a function to run when it expires. That function can access GetExpiredTimer aswell. It might look something like this: Code:
function expired_func takes nothing returns nothing // Some actions here... call DestroyTimer(GetExpiredTimer()) endfunction function start_timer takes nothing returns nothing set udg_SomeTimerArray[1] = CreateTimer() call TimerStart(udg_SomeTimerArray[1], 3.00, false, function expired_func) endfunction |
