[System] Smooth Timers

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Okay first of: This patch tool is awesome and works.

Second: I tested waits now on Bnet (with only me as a player, though ... couldnt make other people to join >_>), and they worked the same as in single player.

I tested it via the following trigger:
Code:
Nahkampfinitialisierung
    Ereignisse
        TriggerAddEventMapInit()
    Lokale Variablen
        t = (TimerCreate()) <timer>
        i = 0 <int>
    Bedingungen
    Aktionen
        TimerStart(t,9.0,false,c_timeGame)
        While()
            Conditions
                Comparison(i,<=,256)
            Actions
                Wait(0.0,c_timeGame)
                IncrementInteger(i,+,1)
        TriggerDebugOutput(1,"This should show 1:",true)
        TriggerDebugOutput(1,(FixedToText((TimerGetRemaining(t)),c_fixedPrecisionAny)),true)
It returned "1" in both singleplayer and singleplayer-bnet games.

However, something is really odd about that: When I changed the code to this, it returned "0" for some reason: Any idea why?
Code:
Nahkampfinitialisierung
    Ereignisse
        TriggerAddEventMapInit()
    Lokale Variablen
        t = (TimerCreate()) <timer>
        i = 0 <int>
    Bedingungen
    Aktionen
        TimerStart(t,9.0,false,c_timeGame)
        While()
            Conditions
                Comparison(i,<=,256)
            Actions
                Wait(0.0312,c_timeGame)
                IncrementInteger(i,+,1)
        TriggerDebugOutput(1,"This should show 1:",true)
        TriggerDebugOutput(1,(FixedToText((TimerGetRemaining(t)),c_fixedPrecisionAny)),true)

PS: Sorry for this gui trigger stuff, but I didnt find out how to convert triggers to galaxy yet.
 

Saldu

New Member
Reaction score
1
My only guess would be that since you can't have 0.03125 as a real entered there since the real input is limited to 4 digits after comma, it can't display 7.9872 as a result for some reason, but I'm at a loss for that reason too.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
The reason for that problem was already found; I posted everything I found out about waits in the other thread. But thanks for your comment.
 

Marsunpaisti

New Member
Reaction score
0
Im having problems getting this to work. I tried to experiment around with these timers, and I'm not really sure if I used them properly. First of all I tried to copy the example you had in the original post but when im saving the map, galaxy editor tells me there is a syntax error on the line where there is the "newsmoothtimer(test,5)" thing.
 

Steel

Software Engineer
Reaction score
109
Steel said:
I was going to try this but got side tracked with my latest tutorial so someone in their spare time can try running this. The minimum time you can wait is 0.03125s, this is tested and proven, we know this. But that is just a minimum, the fastest. This means you can have something wait 0.03126s. So you could potentially have triggers running at the intervals of:

  • 0.03125
  • 0.03126
  • 0.03127
  • 0.03128
    ....

With careful coding and tweaking some numbers you could have several triggers running in parallel to execute code at a much faster rate.

If you have one trigger starting at the fastest delay possible 0.03125s and the next starting at 0.04678s (rounded up) you effectively double the number of waits you get to execute with your data¹. If you create another split you can end up with these figures: 0.03125, 0.03907, 0.04689, 0.05471¹. This now breaks the limitation of 1/32 executions per second and effectively increases it to 1/128 executions per second.

Now remember I'm just speculating here. I don't know if parallel time triggers will work or what their effect on the game they would have. The thing people seem to be focused on is interval clicks. Like everything executes in batches of 0.03125, I don't know if that is true or not. If you can actually have a wait time between 0.03125 and 0.0625, the next minimum wait time, you can execute more than this mysterious minimum value.

[Note: If the numbers get cut off to rounding, then round all of the minimum waits to a linear progression so they all are going in unison.]

¹ With proper rounding lets say we run two triggers in parallel starting at 0.03126, 0.04689. The interval difference here is 0.01563s. The starting point for our thread can be 0 seconds since we can execute a command upon initialization since these would be two actively running triggers. If you're going to nitpick and say what if this is at map initialization? The first instance of thread 2 would not execute, everything else though would be the same.

Thread 1 - 0.00000
Thread 2 - 0.01563
Thread 1 - 0.03126
Thread 2 - 0.04689
Thread 1 - 0.06252
Thread 2 - 0.07815
Thread 1 - 0.09378
Thread 2 - 0.10941
Thread 1 - 0.12504
Thread 2 - 0.14067
Thread 1 - 0.15630
Thread 2 - 0.17193
Thread 1 - 0.18756
Thread 2 - 0.20319
Thread 1 - 0.21882
Thread 2 - 0.23445
Thread 1 - 0.25008
Thread 2 - 0.26571
Thread 1 - 0.28134
Thread 2 - 0.29697
Thread 1 - 0.31260
Thread 2 - 0.32823
Thread 1 - 0.34386
Thread 2 - 0.35949
Thread 1 - 0.37512
Thread 2 - 0.39075
Thread 1 - 0.40638
Thread 2 - 0.42201
Thread 1 - 0.43764
Thread 2 - 0.45327
Thread 1 - 0.46890
Thread 2 - 0.48453 (32 executions here)
Thread 1 - 0.50016

33 executions in 0.050016 seconds

Originally posted on TDG's forum.

Have fun.
 

Marsunpaisti

New Member
Reaction score
0
Here is the map I was trying to import the smooth timer into.
 

Attachments

  • Galaxy racing 0.1a.zip
    73.9 KB · Views: 245

Builder Bob

Live free or don't
Reaction score
249
Does this system actually work as intended? I'm trying to create a smooth sliding motion for a unit, but it appears just as choppy with this system as with a .0625 timer.

Adding a line to display the game time every time the smooth timer starts a new tick shows it constantly expires twice with the same game time.

Example:
0
0
0.0625
0.0625
0.125
0.125
0.1875
0.1875
etc.

Can anyone confirm this system works and that I'm just doing something wrong? If not, can you point me in the right direction on how to achieve smooth sliding?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top