System Key Timers 2

Question: Vexorian told me that if I do something like:

call KT_Add(function myFunc, myData, 0.06) <-- 54 seconds elapsed in game
call KT_Add(function myOtherFunc, myOtherData, 0.06) <-- 56 seconds elasped in game

Then when the first one expired, at 60 seconds elapsed, it would run the other one too because it has the same period and therefore not being very multi instanceable. Is that true?
 
>Is that true?
Thanks for asking. The answer is no, if I understood you right.

But let me get this straight...
>call KT_Add(function myFunc, myData, 0.06) <-- 54 seconds elapsed in game
>call KT_Add(function myOtherFunc, myOtherData, 0.06) <-- 56 seconds elasped in game
>Then when the first one expired, at 60 seconds elapsed

The first one will expire at 54.06, not 60...

If you mean 6.0 seconds instead of 0.06, the answer is still no. They will fire 2 seconds apart as they should.

If you did indeed mean 0.06 and you meant when the game finally hits 60 seconds, then yes they will fire at the same time, but that shouldn't effect multi instanceability.

Feel free to ask further questions.
 
You have removed the cons which made me prefer TimerUtils for long periods and accurate not periodic timers.
Just to be sure, we can use it for a Timer(0), right ?

But you should display a message in debug mode if TAZO_INSTANCEMAX is reached.
Also what about comment better the constants ?
Or do you consider you need to look all the code to know what you are doing if you edit them ?
At least the names are not obvious.
 
Hey, thanks for the response.

>removed the cons which made me prefer TimerUtils for long periods
Cool. :)

>Just to be sure, we can use it for a Timer(0), right ?
Yep.

>But you should display a message in debug mode if TAZO_INSTANCEMAX is reached.
Yes I should. I'll stack on some debug messages next version, probably. Or just get rid of the need for them.

>Also what about comment better the constants ?
Good point. Done (1.7.1).
 
I found nasty thing. period * 800. :D Then the periods need to multipliable by 8 and it must an integer.
 
Jesus4Lyf said:
Yes I should. I'll stack on some debug messages next version, probably. Or just get rid of the need for them.
Oh yes i've forgotten this last con, which why i prefer TimerUtils purple favor against TimerUtils red favor.
If you can get rid of the need of them it would be definitely cool.
But i'm just wondering if you can do that without H2I, or let's say GetHandleId :D
 
So.. What exactly is Tazo? :rolleyes:
You mention it a few times, but you don't say what it is.
 
I found nasty thing. period * 800. :D Then the periods need to multipliable by 8 and it must an integer.
Add logic to your comments. *800 and *8 are not the same. Next time please find the documentation instead. :) (You are referring to the 0.00125 thing which is clearly stated.)
JASS:
//    =Cons=
//         - The code passed into KT2 must call KT_GetData exactly once.
//         - Periods must be a multiple of 0.00125 seconds. Not 0.007, for example.

Oh, and that 0.00125 second thing only applies to periods under the threshold. Above its actually fully accurate.

If you can get rid of the need of them it would be definitely cool.
But i'm just wondering if you can do that without H2I, or let's say GetHandleId :D
Yeah. I can probably do that for ya. It's actually easier because I'm not using H2I. I'll do this when I get some time and its not 2:00 am (coding at 2 am ain't quality ;)).

So.. What exactly is Tazo? :rolleyes:
You mention it a few times, but you don't say what it is.
It's a Tazo!
tazo_1996_daffy-Verne.jpg

See? :D

Ok, fine... Firstly, from the doc.
JASS:
    //////////
    // TAZO //
    ////////////////////////////////////////////////////////////////////////////
    // KT2 implementation for higher periods (low frequency).

JASS:
        // Period Threshold is the point at which Key Timers 2 will switch from
        // using the single timer per period mechanism to using TAZO, which is
        // better for higher periods due to the first tick being accurate.

Did you want to know anything more?
 
Good enough.
So how does it work this time? I can't be bothered to look through that nightmare code. :p
A timer per period? A list? I'm curious. :)
 
I didn't take more than 5 min to understand the code, it's not that big or complicated, but the variables and function name are not obvious, i'm agree.
 
Good enough.
So how does it work this time? I can't be bothered to look through that nightmare code. :p
A timer per period? A list? I'm curious. :)
Well. The classic stuff (below threshold) works the classic way. The other stuff (Tazo, >= Threshold) works by a trigger per instance with exec count attachment and a timed event. It builds up the exec count triggers over time, then pops one off the stack when it comes time to use one. It uses the classic KT2 stuff to rebuild the triggers over time after the instance is done and the trigger is destroyed. It's slower than TU red, but doesn't matter for high periods anyway (and it's not significantly slower, still all O(1) complexity for adding, removing and ticking instances).

What to do next:...
I can remove the background reconstruction by using a "timer expires" event and having a timer along with each trigger (much like vTimer which Azlier and myself wrote). (Removes Tazo's internal reconstruction period constant.)

I can remove the instance limit by constructing more triggers when a low number is left. (Removes Tazo's max instances constant, but puts the internal construction period back.)

So I can remove one constant. I'll probably do both of the above in the near future. They will allow Tazo to automatically extend itself and remove the max instance constant, which I think is good. Still backwards compatible to the first version of KT2. :thup:
 
As said, done. No longer a maximum number of instances for TAZO, no longer reconstructs triggers.

I made a precache constant for TAZO, which is kind of nice. You can actually set it to 0 and it all still runs fine. The construction period is only used when approaching the PRECACHE limit (to slowly start precaching more in the background). If you happen to suddenly go over the precached limit, KT2 won't break, it'll just suddenly prepare a new instance for you, which might spike slightly (processing time varies with number of instances already in existance). The idea is that this doesn't happen (it's just a failsafe), so if you're particularly concerned about it, you bump up the precache limit.

... In my maps, I'd probably put the precache on around 32. But that's me. :D

So, yeah. Happy 1.7.2. ;)

Hopefully the last release for a little while. Yet again. :)

So KT2 is now limitless on higher periods (>= 0.3), exact for them, still hasn't changed interface and still won't break over the return bug being removed.
 
Awesome system. I consider it better than TimerUtils because of the backwards compatibility.
 
>Awesome system. I consider it better than TimerUtils because of the backwards compatibility.

lol, dumbest reason ever. its not like TimerUtils isnt already compatible...
 
>lol, dumbest reason ever. its not like TimerUtils isnt already compatible...

the updated timerutils would not work for 1.23 and the old timerutils wouldn't work for 1.24 so whys that a dumb reason?

its completely valid
 
Trying the system out and the timer's working, but I'm having trouble getting it to stop for some reason. First time working with structs, too.

Basically, the problem is that even after the sliding stops, everything under the "else" statement keeps running.

JASS:
function WW_Slide_Effect takes nothing returns boolean
    local projectile ww = KT_GetData()
    local real speed = (GetUnitMoveSpeed(ww.slider) * WW_SPEEDMULT) / 20
    local group effectgroup
    local unit effectunit
    local location castpoint
    local location movepoint

    if (ww.N &lt;= ww.distance) and (GetUnitState(ww.slider, UNIT_STATE_LIFE) &gt; 0) then
        //sliding stuff
        return false
    else        
        call PauseUnit(ww.slider, false)               
        call SetUnitPathing(ww.slider, true)
        call SetUnitAnimation(ww.slider, &quot;stand&quot;)
        call RemoveLocation(movepoint)
        call RemoveLocation(castpoint)
        call ww.destroy()
        return true
    endif
endfunction

function WW_Point_Slide takes unit slider, real direction, real distance, real damage returns nothing
    local projectile ww = projectile.create()

    call PauseUnit(slider, true)
    call SetUnitPathing(slider, false)
    call SetUnitAnimation(slider, &quot;Attack Walk Stand Spin&quot;)
    
    set ww.slider = slider
    set ww.angle = direction
    set ww.damage = damage
    set ww.distance = distance
    set ww.N = 0
    set ww.O = 0

    call KT_Add(function WW_Slide_Effect, ww, 0.05)
endfunction
 
It is hard to know the exact cause without more code.

Personally I would change the structure a little:
JASS:
    if (ww.N &lt;= ww.distance) and (GetUnitState(ww.slider, UNIT_STATE_LIFE) &gt; 0) then
        //sliding stuff
        return false
    else        
        call PauseUnit(ww.slider, false)               
        call SetUnitPathing(ww.slider, true)
        call SetUnitAnimation(ww.slider, &quot;stand&quot;)
        call RemoveLocation(movepoint)
        call RemoveLocation(castpoint)
        call ww.destroy()
        return true
    endif

-->
JASS:
    if not ((ww.N &lt;= ww.distance) and (GetUnitState(ww.slider, UNIT_STATE_LIFE) &gt; 0)) then
        call PauseUnit(ww.slider, false)               
        call SetUnitPathing(ww.slider, true)
        call SetUnitAnimation(ww.slider, &quot;stand&quot;)
        call RemoveLocation(movepoint)
        call RemoveLocation(castpoint)
        call ww.destroy()
        return true
    endif
    //sliding stuff
    return false


My best guess would be that you have a thread termination issue. Perhaps try using debug messages to figure out what's going on. From what you've shown me there, you're removing locations "movepoint" and "castpoint" which are local variables, but don't actually hold values. That will cause the thread to terminate (without returning a value, but probably translated as "false").
 
From what you've shown me there, you're removing locations "movepoint" and "castpoint" which are local variables, but don't actually hold values. That will cause the thread to terminate (without returning a value, but probably translated as "false").
Didn't realize it'd spazz out when trying to destroy non-existent variables. Nice to know. Was just trying to cover all bases as far as leaks were concerned.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    alternatively if you not making at least 23 an hour you could work in an Aldi warehouse
  • Varine Varine:
    Yeah I've been thinking about using AI for shit. I'm on vacation next week so I'm going to spend some time reorganizing everything and getting all my shit back in order
  • Varine Varine:
    lol I technically make less than 23 right now because I'm on salary and am there all the time, but it's a lot more than a normal wage still. I also have a meeting soon to renegotiate my pay because I want about a 25% increase to account for what I'm actually doing or a re-evaluation of our duties so that that my responsibilities are more in line with my pay. Depending on how that goes I'm prepared to give notice and move on, I don't mind taking less money so I'd have time for the rest of my life, but I'd rather they just fucking pay me enough to justify the commitment on my end. Plus right now I hold pretty much all the cards since I'm the only one actually qualified for my position.
    +1
  • Varine Varine:
    The other chef was there before me and got his position by virtue of being the only adult when the old general manager got married and didn't want to deal with the kitchen all the time, and happened to be in the position when the GM quit. New GM is fine with front of house but doesn't know enough about the kitchen side to really do anything or notice that I'm the one primarily maintaining it. Last time I left they hired like 3 people to replace me and there was still a noticeable drop in quality, so I got offered like 6 dollars an hour more and a pretty significant summer bonus to come back
  • Varine Varine:
    So honestly even if I leave I think it would last a couple of months until it's obvious that I am not exactly replaceable and then I would be in an even better position.
  • Varine Varine:
    But as of right now I have two other job offers that are reasonably close to what my hourly equivalency would be, and I would probably have more time for my other projects. The gap would be pretty easy to fill up if I had time to do my side jobs. I use to do some catering and private events, personal lessons, consultations, ect, and I charge like 120 an hour for those. But they aren't consistent enough for a full time job, too small of a town. And I'm not allowed to move for another year until my probation is over
  • Varine Varine:
    I guess I could get it transferred, but that seems like a hassle.
  • Varine Varine:
    Plus I have a storage room full of broken consoles I need to fix. I need to build a little reflow oven so I can manufacture some mod chips still, but it'll get there.
    +1
  • Varine Varine:
    I would like to get out of cooking in general at some point in the next ten years, but for the time being I can make decent money and pump that into savings. I've been taking some engineering classes online, but those aren't exactly career oriented at the moment, but I think getting into electronic or computer engineering of some sort would be ideal. I'm just going to keep taking some classes here and there until there's one that I am really into.
    +2
  • The Helper The Helper:
    There is money in fixing and reselling consoles. Problem is people know that so they are doing it
  • The Helper The Helper:
    If you can find a source of broken consoles though you can make money fixing them - sometimes some big money
  • Varine Varine:
    I was buying them on Ebay, but it's pretty competitive, so more recently I've just been telling the thrift stores to call me and I will come take all their electronics they can't sell. I've volunteered there before and people use them like a dump sometimes, and so they just have a massive amount of broken shit they throw away
  • Varine Varine:
    The local GoodWill was pretty into it, surprisingly the animal shelter store was not. The lady I talked to there seemed to think I was trying to steal stuff or something, she wasn't very nice about it. Like I'm just trying to stop you having to throw a bunch of electronics away, if you can sell it great. I'd probably pay you for the broken shit too if you wanted
  • Varine Varine:
    Then I make posts on Facebook yard sale pages sometimes saying I want your old electronics, but Facebook being Facebook people on there are also wary about why I want it, then want a bunch of money like it's going to be very worth it
  • Varine Varine:
    Sooner than later I'm going to get my archives business going a little more. I need some office space that is kind of hard to get at the moment, but without it, I have to be like "Yeah so go ahead and just leave your family heirlooms and hundred year old photographs here at my shitty apartment and give me a thousand dollars, and next month I'll give you a thumb drive. I promise I'll take care of them!"
    +1
  • Varine Varine:
    I can do some things with them at their home, but when people have thousands of slides and very delicate newspaper clippings and things, not really practical. I
  • Varine Varine:
    I would be there for days, even with my camera set up slides can take a long time, and if they want perfect captures I really need to use my scanners that are professionally made for that. My camera rig works well for what it is, but for enlargements and things it's not as good.
  • Varine Varine:
    I've only had a couple clients with that so far, though. I don't have a website or anything yet though.
  • Varine Varine:
    Console repair can be worthwhile, but it's also not a thing I can do at scale in my house. I just don't have room for the equipment. I need an office that I can segregate out for archival and then electronic restoration.
  • Varine Varine:
    But in order for that to be real, I need more time, and for more time I need to work less, and to work less I need a different job, and for a different job I need more money to fall back on so that I can make enough to just pay like, rent and utilities and use my savings to find these projects
    +1
  • Varine Varine:
    Another couple years. I just need to take it slow and it'll get there.
  • jonas jonas:
    any chance to get that stolen money back?
  • jonas jonas:
    Maybe you can do console repair just as a side thing, especially if there's so much competition business might be slow. Or do you need a lot of special equipment for that?
  • jonas jonas:
    I recently bought a used sauna and the preowner told me some component is broken, I took a look and it was just a burnt fuse, really cheap to fix. I was real proud of my self since I usually have two left hands for this kinda stuff :p
  • tom_mai78101 tom_mai78101:
    I am still playing Shapez 2. What an awful thing to happen, Varine, and hopefully everything has been sorted out soon. Always use multi-factor authentication whenever you have the opportunity to do so.

      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