• 🏆 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] Two Timer

Status
Not open for further replies.
Level 13
Joined
Jun 20, 2014
Messages
479
I am working on a spell. It consists of a cast then some effects then a delay then create some projectiles then move the projectiles. Something like that. I was thinking of having two different periodic timers to make it work. But browsing on the spell section i haven't seen a spell that has two periodic timer. Can someone tell me if having two periodic timers in one spell is a good thing? Thank you in advance.
 
Level 10
Joined
Apr 4, 2010
Messages
509
Have two groups.
Periodic Trigger 1: If caster is in Group 1, then do actions, when actions done, remove caster from group 1, if group 1 is empty, then turn off Periodic Trigger 1

Periodic Trigger 2: If caster is in Group 2 and not in group 1, then do actions, when actions done, remove caster from group 2, if group 2 is empty, then turn off Periodic Trigger 2.
 
Level 13
Joined
Jun 20, 2014
Messages
479
ya, that's almost the case DEE-BOO. I used indexed the caster then the first timer runs and within the first timer i will create 50 units that will be indexed as well then run the second timer to make the created units move.

Edit: So, does it mean that it is not a bad practice?
 
Last edited:
Level 5
Joined
Jan 17, 2014
Messages
131
Edit: So, does it mean that it is not a bad practice?

It is unnecessary. You can just use one periodic event and switch between variables according to which one it should be counting.

Example:
  • Periodic Trigger
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • timer1 Less than 10.00
        • Then - Actions
          • Set timer1 = (timer1 + 1.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • timer1 Equal to 10.00
            • Then - Actions
              • Set timer1 = (timer1 + 1.00)
              • -------- Your actions, after the first timer expires. --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • timer1 Greater than 10.00
                  • timer2 Less than 10.00
                • Then - Actions
                  • Set timer2 = (timer2 + 1.00)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • timer1 Greater than 10.00
                      • timer2 Equal to 10.00
                    • Then - Actions
                      • -------- Your action, after the second timer expires. --------
                    • Else - Actions
 
Level 13
Joined
Jun 20, 2014
Messages
479
Thank you for the response. I should use flag variables to avoid two timers. What if i used indexing on the first loop and theres another loop where there are indexed unit. This means that i should deindex after the first loop the wait for the second loop to get deindex before turning off the timer correct?
 
Level 5
Joined
Jan 17, 2014
Messages
131
How about tracking thetime elapsed? Example
if Time_Elapsed <= 10 then
do first action
Elseif Time_Elapsed > 10 and Time_Elapsed <= 25 then
do second action
End.
In periodic trigger
Time_Elapsed = Time_Elapsed + 0.03

This will do the action every 0.03 seconds and I think that he/she wants the action to occur only once when the timers expire.
 
Level 13
Joined
Jun 20, 2014
Messages
479
Well i was planning to make it happen at the same time. The first timer will create the units and the second timer will move the unit. Note: on the first timer loop is indexed and thats goes the same for the second timer.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Thank you for the response. I should use flag variables to avoid two timers. What if i used indexing on the first loop and theres another loop where there are indexed unit. This means that i should deindex after the first loop the wait for the second loop to get deindex before turning off the timer correct?

If you use my example, the deindexing should be where it belongs... at the bottom, after the second timer expires.
 
Level 13
Joined
Jun 20, 2014
Messages
479
The thing is
on first action -> one object has been indexed. Ok
->timer runs and create object for 50 iterations.
-> as soon as the object is created, it is indexed
-> there must be a timer of some sort to move the newly indexed object (50)
-> now if the indexing is done after the 2nd loop then i guess its fine but the indexing on the first loop is not needed anymore and can be freed. What am i doing?
 
Level 5
Joined
Jan 17, 2014
Messages
131
The thing is
on first action -> one object has been indexed. Ok
->timer runs and create object for 50 iterations.
-> as soon as the object is created, it is indexed
-> there must be a timer of some sort to move the newly indexed object (50)
-> now if the indexing is done after the 2nd loop then i guess its fine but the indexing on the first loop is not needed anymore and can be freed. What am i doing?

Ok, I'm confused now. I don't exactly understand what is it you want.

Right, that should not be an inequality. My bad

Yup. :)

if Time_Elapsed <= 10 then
do first action
Elseif Time_Elapsed > 10 and Time_Elapsed <= 25 then
do second action
End.
In periodic trigger
Time_Elapsed = Time_Elapsed + 0.03
 
Level 13
Joined
Jun 20, 2014
Messages
479
ya sorry i forgot what i was writing back there.

i was planning to index the caster then create 50 throught each interval of the timer. upon creation i want the created objects to move. Thus, first timer is for creation and the second one is for moving the created objects. also before creation there are 2 events one is it will raise a created object upon cast and a delay checker. There i didnt forget what i was typing this time. I hope u can help. hehe thanks
 
Level 5
Joined
Jan 17, 2014
Messages
131
ya sorry i forgot what i was writing back there.

i was planning to index the caster then create 50 throught each interval of the timer. upon creation i want the created objects to move. Thus, first timer is for creation and the second one is for moving the created objects. also before creation there are 2 events one is it will raise a created object upon cast and a delay checker. There i didnt forget what i was typing this time. I hope u can help. hehe thanks

You are still typing confused. If there is 1 timer for creation and 1 timer for move, then why would you type "UPON CREATION i want the created objects to move" - that means the object move instantly when they are created (no need for timer).

Let me try to understand :

Spell is cast > Timer starts > Objects are created 1 by 1 for each interval of the timer > Timer finishes > Objects move...

(If I'm not getting it right, make a change and share)
 
Level 5
Joined
Jan 17, 2014
Messages
131
So, is my schematic correct?

Spell is cast > Timer starts > Objects are created 1 by 1 for each interval of the timer > Timer finishes > Objects move...
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
I'd use JASS for that.

JASS:
function Create50Units takes nothing returns nothing
    //create your units here.
endfunction


function Tast takes nothing returns nothing
 local timer t = CreateTimer()
    call TimerStart(t, 8.00, false, function Create50Units())
    // note that the function ran should take nothing return nothing
 set t = null
endfunction

I might be wrong tho. Been a while since I haven't been using timers.

This is an example to find out what a JASS timer is capable of.
 
Status
Not open for further replies.
Top