HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need help on a timer array

08-25-2003, 12:01 PM#1
Franky_oe
Is there a way to get the index integer of an array in the events, so I know which event is used? Here is an example trigger for one player:
Code:
Revive Hero Player 1

    Events

        Time - hero_time[1] expires

    Conditions

    Actions

        Camera - Pan camera for (Player(1)) to (Center of Night Elf Spawn <gen>) over 0.00 seconds

        Hero - Instantly revive heros[1] at (Center of Night Elf Spawn <gen>), Show revival graphics


Doing this for each player sucks, so i need to know which timer expires. Then i can replace the Player(1) and heros[1] with Player(X) and heros[X]. X is the index of the hero_time[] array in the events. Thx for any help.
08-25-2003, 01:18 PM#2
Reaper359
If you're using that for an event, sorry, impossible. You should make another trigger that branches off to those if you want it the easy way. Otherwise, keep at what you're doing.
08-25-2003, 06:04 PM#3
Raptor--
solution--

just here for the heck of it:
for int A = 0 to 7
+loop
++add event [int A]timer expires to (trig)

(trig)
event:
conditions:
actions:
for int A = 0 to 7
+loop
++if expiring timer = [int A]timer then
+++set OTHER_var = int A
continue with trig using OTHER_var
08-25-2003, 08:21 PM#4
Franky_oe
Thanks for reply.

I can't find a possibility getting "if expiring timer = [int A]timer then"
work. I can only check the time on a timer not it's name. Maybe you can help me?
08-25-2003, 10:54 PM#5
Raptor--
hmm, actually you're right, i didn't notice that they didn't put that condition in -- you'll have to convert it to custom text and do something like the following

Code:
01: function Trig_Timer_Expires_Func002Func001C takes nothing 02: returns boolean
03:     if ( not ( GetExpiredTimer() == udg_OTHER_timerEvent_A[GetForLoopIndexA()] ) ) then
04:         return false
05:     endif
06:     return true
07: endfunction
08: 
09: function Trig_Timer_Expires_Actions takes nothing returns nothing
10:     set udg_OTHER_timerTemp = GetExpiredTimer()
11:     set bj_forLoopAIndex = 1
12:     set bj_forLoopAIndexEnd = 10
13:     loop
14:         exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
15:         if ( Trig_Timer_Expires_Func002Func001C() ) then
16:             set udg_OTHER_nTemp = GetForLoopIndexA()
17:         else
18:             call DoNothing(  )
19:         endif
20:         set bj_forLoopAIndex = bj_forLoopAIndex + 1
21:     endloop
22:     call DisplayTextToForce( GetPlayersAll(), I2S(udg_OTHER_nTemp) )
23: endfunction

line 3 is basically what i wrote in myself, it just goes and compares it the Expiring timer is = to the timer array[intA]

you can also ignore line 10, i was just figuring out what the expiring timer function was called, and line 22 was just to test to make sure it worked
08-26-2003, 11:20 AM#6
Franky_oe
Converting is a nice idea, THANKS :D. It works and I'm happy.
08-26-2003, 12:08 PM#7
Eternal-Agony
Ok, from what I get from this you're trying to make an AoS map with a revival wait time based on hero level upon death. A lot of people on B.Net have whispered me on this subject so I made a small map showing how to do this all in one trigger with no timers. Check it out.

(The guy in the map preview is not me by the way.)
08-26-2003, 05:20 PM#8
Franky_oe
I use 2 triggers to show in a timer window the name of the hero and time remaining until revive. I will check out yours some later, thanks.
08-26-2003, 06:42 PM#9
Raptor--
besides, its not how few triggers you use that counts, its how functional it is...
08-26-2003, 07:17 PM#10
Eternal-Agony
I take pride in my optimized triggers.

A couple functional complex triggers are more fun to write than 12 triggers.
08-26-2003, 07:19 PM#11
Raptor--
and less fun to debug
08-27-2003, 06:53 PM#12
RodOfNOD
Actually we now have a way to do this in gui.

You now have the ability to set up unit death timers.

basically you use the custom value field and assign a unique # every time a hero is created. just increment a global value to do this. then using this unique # as an index assign the hero unit to an array of units.

then when the hero dies you run a trigger that does the following: (HeroTimer is a dummy unit)


Unit - Create 1 HeroTimer for Neutral Passive at (Center of (Playable map area)) facing Default building facing degrees

Unit Hide Last Created

Unit - Set the custom value of (Last created unit) to (Custom value of (Dying unit))

Unit - Add a 5 second Generic expiration timer to (Last created unit)


Then do another event that detects the death of this Fake death unit. Note you will need to do some conditions here.

then revive the hero based on the custom value of the dying unit and its reference into that array we initially created.

Good luck and if this is confusing then let me know.