• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Need help with "Timer Expires" Event

Status
Not open for further replies.
Level 10
Joined
Feb 18, 2008
Messages
262
Hope I can explain my problem in English.

I have a timer variable (with array) for a trigger-based MUI spell. Everytime the timer expires, something's gonna happen, in order to make this MUI i made it with Array so each player have it's own timer.

The problem is; do i have to make a trigger for each Player? Like;

Event- Timer[1] Expires
Action- Blah blah Hero[1] Blah blah

Event- Timer[2] Expires
Action- Blah blah Hero[2] Blah blah

and so on... I have found no other way, can't i just simply make one trigger like this:

Event- Timer[X] Expires
Action- Blah blah Hero[X] Blah blah

Can anyone help me. Note that I only use GUI.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You can probably do something like this:


  • timer
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to [# Players], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Remaining time for Timer[Integer A]) Equal to 0.00
            • Then - Actions
              • [Your Actions]
            • Else - Actions
              • [Your Actions]
 
MUI means Multi Unit Instanceability; you already know that. The "Each player could have his own timer" makes no sense at all, since a unit of the same player might cast the spell twice before the timer actually expires, so you would need 2 timers for one player.
Since Timer[1] won't do the job, cause it is simply as of making a non-array variable (cause index is yet specified with values: 1/2/3/...), i really have either no clue on how to even add array of a non specified value.
This post gave you no solution, but a word of caution to consider.

ap0calypse, i have tried that, it wouldn't work for me. I really don't know if it is a matter of a periodic event though.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
MUI means Multi Unit Instanceability; you already know that. The "Each player could have his own timer" makes no sense at all, since a unit of the same player might cast the spell twice before the timer actually expires, so you would need 2 timers for one player.
Since Timer[1] won't do the job, cause it is simply as of making a non-array variable (cause index is yet specified with values: 1/2/3/...), i really have either no clue on how to even add array of a non specified value.
This post gave you no solution, but a word of caution to consider.

ap0calypse, i have tried that, it wouldn't work for me. I really don't know if it is a matter of a periodic event though.

Well, it also depends on how long the cooldown is in comparison with the spell duration.
If the cooldown is longer, there can be maximum 1 timer for each player, otherwise you are indeed right.

It's strange that it doesn't work, since it should detect when the timer reaches 0.
I always thought that a timer would still exist after it expires (and if it does exist, it remains 0 after it expires... which should be logical).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
It's strange that it doesn't work, since it should detect when the timer reaches 0.
I always thought that a timer would still exist after it expires (and if it does exist, it remains 0 after it expires... which should be logical).

Since the trigger runs every 0.05 seconds, the timer is probably already running the next iteration.

As to an easy and fast way to make things multi-instance-able, you create a timer, an integer counter, and an array for each attribute to save (you will understand what this means in a second).

Now, whenever a unit casts your spell, you do three things:
1) Check if the counter is equal to 0, if it is - start your timer.
2) You fill in your attribute arrays.
3) Add 1 to the counter.

Now, by arrays I mean that, if for example your spell uses the position of the caster, then you'll have an array of positions, each of them represents an "instance" of your spell being run together with all the others.

The next part is the actual timer call back.
Here you will have two steps to go through:
1) Run over (with a loop) all the instances (remember the counter?), for each of them do your actions.
2) If an instance should be removed (the effects of the spell have finished, for example), you need to
A) "Remove" it from the arrays.
If we go back to the caster's position example, you will do it by setting the current instance (in the running loop) to the last instance, and then you delete the last instance, this way you "over write" the current one with the last one and delete the last one.
B) Decrease the value of the counter, indicating that an instance was removed.
C) If the counter is equal to zero, pause the timer.


The only draw back of this way of view, is the limit of 8192 instances, but you'll never get to it anyway.

If you don't understand what I mean here, perhaps I will make an example if I'm not too annoyed.
 
Level 10
Joined
Feb 18, 2008
Messages
262
Thanks for your time. I'm gonna try out ap0calypse's way first. I don't understand what you said Ghostwolf sorry :(

Edit: It didn't worked properly. (ap0calypse's)
I choosed For each integer from 1 to 8, and it worked for every integer like it don't have a condition :S.
Note: I also tried "elapsed time" condition as well as "remaining time" condition
 
Last edited:
Status
Not open for further replies.
Top