• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Countdown Timer - Periodic Event (ERROR)

Status
Not open for further replies.
Level 8
Joined
Jun 20, 2004
Messages
229
Hi,
I am having a bit of trouble with timers not correctly aligning with my periodic event. Due to the complexity for what the timers are used in my original map I have dubbed down a basic demo example below as well as an image to sort of explain what the problem is.

What the map does is, whenever an ability is cast, Thunderclap from the hero in this case for quick demonstration, is that at any time the ability is cast, a boolean will be set to true. When this happens, a periodic event running every .01 will detect this and in order to keep the periodic and countdown timer from desyncronizing from each other and keeping the same iterations the first condition will run when startTimer is true, and start a 2 second countdown timer as well as set the boolean to false so it wont run until the ability is cast again as well as set the showTimer boolean to true so the periodic knows when to run the trigger showing the time remaining for the current timer in progress. When the timer reaches 0, it will set the boolean to false, causing no more text to be shown announcing the timers remaining time. This works all fine as well as the ability to spam Thunderclap as fast as possible and it will still work correctly and will replace an already running countdown as intended.

The problem however, is after casting an ability many times, basically I urge you to spam the Thunderclap for a good minute or two until you notice a different set of numbers to the left. You will notice that instead of the text ending in 0.020, 0.010, 0.00... you will get 0.021, 0.011, 0.01, 0.00 which completely throws off everything if you were to have any conditions in the Timer trigger set to go off during a specific time frame. I can not figure out what the problem is. If anyone has any idea what might be happening please post, I will appriciate it greatly as this is a very detrimental to my project.

Here is the code:

Code:
Start Timer
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
        Set startTimer[(Player number of (Picked player))] = True

Code:
Check Timer
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        startTimer[(Player number of (Picked player))] Equal to True
                    Then - Actions
                        Countdown Timer - Start timerCountdown[(Player number of (Picked player))] as a One-shot timer that will expire in 2.00 seconds
                        Set startTimer[(Player number of (Picked player))] = False
                        Set showTimer[(Player number of (Picked player))] = True
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        showTimer[(Player number of (Picked player))] Equal to True
                    Then - Actions
                        Trigger - Run Timer <gen> (checking conditions)
                    Else - Actions

Code:
Timer
    Events
    Conditions
    Actions
        Quest - Display to (All players) the Simple Hint message: (String((Remaining time for timerCountdown[(Player number of (Picked player))])))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Remaining time for timerCountdown[(Player number of (Picked player))]) Equal to 0.00
            Then - Actions
                Set showTimer[(Player number of (Picked player))] = False
            Else - Actions

Here is the screen shot

errorxc1.jpg


The map example is attached below,

Thanks
 

Attachments

  • Example.w3x
    17.1 KB · Views: 58
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
First of all: Next time, don't use the [ CODE ] tags, but the [ TRIGGER ] tags.

Second of all: Place all Actions (except the Conditions) from your second trigger to your first. There's no use of dividing the trigger in 2. Change the 'Trigger - Run Timer <gen>' to 'Trigger - Turn On Timer <gen>'. Then delete the second trigger.

Edit the third trigger to:
  • Timer
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Quest - Display to (All players) the Simple Hint message: (String((Remaining time for timerCountdown[(Player number of (Picked player))])))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Remaining time for timerCountdown[(Player number of (Picked player))]) Equal to 0.00
        • Then - Actions
          • Set showTimer[(Player number of (Picked player))] = False
          • Trigger - Turn Off (This Trigger)
        • Else - Actions

If the problem still occurs, change the
  • Quest - Display to (All players) the Simple Hint message: (String((Remaining time for timerCountdown[(Player number of (Picked player))])))
to
  • Quest - Display to (All players) the Simple Hint message: (String((Remaining time for (timerCountdown[(Player number of (Picked player))] - 1))))
 
Level 8
Joined
Jun 20, 2004
Messages
229
ah sorry about the trigger/code thing...

they were dividing into separate triggers due to the original code (not example) has a large amount of conditional actions set to activate on a specific time remaining and is simply more organized and bogs down editor. The periodic trigger unfortunately can not be turned off as it must be running at all times as it is used by multiple players and also runs other things periodically on it on the original map. Nevertheless, I rearranged it to what you have shown just for attempting and it still gave the same problem.

After further investigation of testing I have come to the conclusion it is due to the fact a periodic runs every hundredth of a second while a timer runs at every thousandth of a second causing inaccuracy if there is even a 1/1000th of a second delay it will completely cause the syncronization to be offset. There is probably no precise solution to this so I have decided to abandon timers and go with increasing an real number by .01 every time the periodic is ran so it will never be off.

Thanks though, +rep... one of the only people to reply to this asjde from one other on TH.
 
Status
Not open for further replies.
Top