• 🏆 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!

[Solved] Timers

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
  • Untitled Trigger 001
    • Events
      • Time - Timer_BarrackSpawn[1] expires
      • Time - Timer_BarrackSpawn[2] expires
      • Time - Timer_BarrackSpawn[3] expires
      • Time - Timer_BarrackSpawn[4] expires
      • Time - Timer_BarrackSpawn[5] expires
      • Time - Timer_BarrackSpawn[6] expires
      • Time - Timer_BarrackSpawn[7] expires
      • Time - Timer_BarrackSpawn[8] expires
      • Time - Timer_BarrackSpawn[9] expires
      • Time - Timer_BarrackSpawn[10] expires
      • Time - Timer_BarrackSpawn[11] expires
      • Time - Timer_BarrackSpawn[12] expires
    • Conditions
    • Actions
      • For each (Integer Temp_Int[40]) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Elapsed time for Timer_BarrackSpawn[Temp_Int[40]]) Equal to (Real(Int_BarrackSpawnTime[(Integer A)]))
            • Then - Actions
              • Game - Display to (All players) the text: (Barrack Timer[ + ((String(Temp_Int[40])) + ]))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in (Units in CenterOfMapVision <gen>)) Less than 100
                • Then - Actions
                  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
                • Else - Actions
              • Countdown Timer - Start Timer_BarrackSpawn[Temp_Int[40]] as a One-shot timer that will expire in (Real(Int_BarrackSpawnTime[(Integer A)])) seconds
            • Else - Actions
will execute several times at those occasions or work through them 1 at the time.

Also I did not find a function for expiering timer, which would have been better.

Thanks to Deathismyfriend it's now working, the use of integer A was at fault. + rep
 
Last edited:
Level 12
Joined
Nov 3, 2013
Messages
989
Warcraft 3 runs one thread at a time. So you do not have to worry about the threads executing at the same time since they cannot.

Also never use integer A / B they are less efficient and can cause bugs.

I should use a variable in these loops instead then i presume? Also remaning time did not work so i changed it to 'elapsed' (which was more appropriate anyway) but somehow only one of the timers get registered when it expires (edited OP)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Yes use your own integer for looping.

I suspect the problem is in your variable editor.
You have 12 instances of timers running.

In the variable editor set the timers to 12 instead of 1.

if the above does not work use game messages to display messages to see what happens to the trigger.

You should look at my tutorial things a guier should know. It will help with a lot of optimizing and it will explain more on integer A / B along with many other things.
 
Status
Not open for further replies.
Top