HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Time Window help

05-19-2004, 03:16 AM#1
thedevil
I have a trigger create time window when hero die but if many hero die at the same time then after them revive some time window was not destroyed could everyone help me?
05-19-2004, 03:36 AM#2
ELNINO
Sadly i also have the same problem. Its the first time iver used more than one countdown timer at one time, and i know it has to do with using: "destroy last created timer window".

The thing is, i cant be bothered making variables for each hero, is this what i am going to have to do? Or is tehre an easier way?
05-19-2004, 04:34 AM#3
Pyrokinesis
Actually you just need one boolean variable with an array.

When a hero dies and your trigger starts the timer use this action

Set HeroIsDead[(Player number of (Triggering player))] = True

When a hero revives
Set HeroIsDead[(Player number of (Triggering player))] = False

Now have the death timers run Only when-
HeroIsDead[(Player number of (Triggering player))] = True

I think that should work, if it doesn't i blame it on being 4 a.m. and no sleep o_O
05-19-2004, 08:25 AM#4
thedevil
So thanks for reply but i'm not good at using boolean at variable.Could you give me a tutorial map please?
05-19-2004, 01:59 PM#5
weaaddar
thats a terrible way to do it.
if I were to ever need a timer dialog which is a rare and copious thought I'd exploit some bugs to do it.
First you need an array of timers the amount of players you have.
You'll also need an array of the units that are the guys revived.
you'll also need an array of the timer windows.
In my code I call the array Timers[],Heroes[],TimerWindows[] respectively.
Code:
Lets make a reviver trigger
    Events
        Unit - A unit Dies
    Conditions
        ((Dying unit) is A Hero) Equal to True
    Actions
        Custom script:   local timer t=udg_Timers[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))]
        Countdown Timer - Create a timer window for Timers[(Player number of (Owner of (Dying unit)))] with title ((Proper name of (Dying unit)) +  will revive in)
        Set TimerWindows[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
        Custom script:   call TimerStart(t,10,false,function Revive)
        Unit Group - Pick every unit in (Last created unit group) and do (Actions)
            Loop - Actions
                Custom script:   endfunction
                Custom script:   function Revive takes nothing returns nothing
                For each (Integer A) from 1 to 12, do (Actions)
                    Loop - Actions
                        Custom script:   if(GetExpiredTimer()==udg_Timers[ bj_forLoopAIndex])then
                        Hero - Instantly revive Heroes[(Integer A)] at (Center of (Playable map area)), Hide revival graphics
                        Countdown Timer - Destroy TimerWindows[(Integer A)]
                        Custom script:   endif
05-20-2004, 06:37 AM#6
thedevil
Quote:
Originally Posted by weaaddar
thats a terrible way to do it.
if I were to ever need a timer dialog which is a rare and copious thought I'd exploit some bugs to do it.
First you need an array of timers the amount of players you have.
You'll also need an array of the units that are the guys revived.
you'll also need an array of the timer windows.
In my code I call the array Timers[],Heroes[],TimerWindows[] respectively.
Code:
Lets make a reviver trigger
    Events
        Unit - A unit Dies
    Conditions
        ((Dying unit) is A Hero) Equal to True
    Actions
        Custom script:   local timer t=udg_Timers[GetConvertedPlayerId(GetOwningPlayer(GetDyingUnit()))]
        Countdown Timer - Create a timer window for Timers[(Player number of (Owner of (Dying unit)))] with title ((Proper name of (Dying unit)) +  will revive in)
        Set TimerWindows[(Player number of (Owner of (Dying unit)))] = (Last created timer window)
        Custom script:   call TimerStart(t,10,false,function Revive)
        Unit Group - Pick every unit in (Last created unit group) and do (Actions)
            Loop - Actions
                Custom script:   endfunction
                Custom script:   function Revive takes nothing returns nothing
                For each (Integer A) from 1 to 12, do (Actions)
                    Loop - Actions
                        Custom script:   if(GetExpiredTimer()==udg_Timers[ bj_forLoopAIndex])then
                        Hero - Instantly revive Heroes[(Integer A)] at (Center of (Playable map area)), Hide revival graphics
                        Countdown Timer - Destroy TimerWindows[(Integer A)]
                        Custom script:   endif
-Thanks for help but i not understood at all and i dont use unit group :( ,actualy my map is a corridor map so i must create 2 varriable unit group and create 2 action revive hero right :( ?
05-20-2004, 07:03 AM#7
ELNINO
Hmm, i havent got editor running right now.

What if i use:

Actions: -Set Timerwindow - last created timer window
- Destroy alst created timer window.

Would this work? I dont see why it wouldent, ive used if/then/else for each level.. so i could just input it in after the countdown timer...
05-20-2004, 11:42 AM#8
weaaddar
I never said use unit groups. I said use UNIT arrays. The code is pretty self explanatory and can be used for a single hero per player to be revived.
05-20-2004, 02:32 PM#9
ThyFlame
Uhm. I think weaddar was a bit extravagant.

You should be able to just use a timer array when creating the timer, and when the unit is revived you just destroy/hide the timer.

timer - hide timerArray[player number of (owner of (reviving unit))]


Okay I got a little bored and did this psuedo-code. It actually isnt that much extra work and is an avoidance of local variables and multiple triggers on the same thing.


Just an interesting idea to me.

------

Timers instead of Buff
12 Units off the screen one for each player.
Dummy Buff lasts however many sections you want to avoid. These units are off the playable screen, owned by neutral passive, and each 1 of the 12 is assigned a place in the buffRecievers unit array to represent a player.

Unit dies

Unit == hero

create dummy caster for neutral hostile
order last created unit to cast [spell w/ dummy buff] on buffRecievers[Number of Owner of hero]
set boolean isDead[Number of Owner of hero] = true

Every 1 second

For each integer A (1 to 12)
IF
buffReceivers[Integer A] has [dummy buff] = false AND isDead[Integer A] = true
THEN
set isDead[Integer A] = false
[Actions -- In this case reviving]
Revive heroArray[Integer A] at (wherever).
11-19-2004, 01:31 PM#10
Guest
An easier way if each player only is supposed to have 1 hero:

Code:
Variables: 
TimerVar (has array)
TimerwindowVar (has array)

Events:
A unit dies

Conditions:
Boolean - Dying unit is a hero equal to True

Actions:
Create a timerwindow for TimerVar(Player number of owner of (Dying unit))
Set TimerwindowVar(Player number of owner of (Dying unit)) == Last created timerwindow
Start TimerVar(Player number of owner of (Dying unit)) as a One-shot timer that will expire in X seconds
Wait X seconds
Destroy TimerwindowVar
Instantly revive (Dying unit) at (Owner of (Dying unit) start location)


Hope you can use it.