System Key Timers 2

Troll-Brain

You can change this now in User CP.
Meh nevermind, i will still be stuck with Timers Utils Blue for longs or accurate timers, and my own personal ugly system for low periods.
 

Troll-Brain

You can change this now in User CP.
Because i've made my own timer system, and tested it, i've found a lame thing.
If you don't set to null the boolexpr variable after destroying the boolexpr, it leaks.

JASS:
library Test initializer init

globals
    private boolexpr B1
    private boolexpr B2
    private trigger Trig
endglobals

private function F1 takes nothing returns boolean
    return true
endfunction

private function F2 takes nothing returns boolean
    return true
endfunction

private function F3 takes nothing returns boolean
    return true
endfunction

private function Actions takes nothing returns nothing
    call EnableTrigger(Trig)
    call TriggerSleepAction(20.)
    //call BJDebugMsg("end")
    call DisableTrigger(Trig)
endfunction

private function DoTheTest takes nothing returns nothing
    //call BJDebugMsg("run")
    set B1 = And(Condition(function F1),Condition(function F2))
    set B2 = And(B1,Condition(function F3))
    call DestroyBoolExpr(B1)
    call DestroyBoolExpr(B2)
    //set B1 = null
    //set B2 = null
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.01,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary


- i've tested on window mode.
- i've waited the stability of the process war3 before press escape
- and you can wait as you want the memory won't be freed after the trigger disabling, but if you set to null the variables there are no leaks.
 

Troll-Brain

You can change this now in User CP.
No, if the variable set to another value, original value will be removed, I think.
Test it ?
That was i assumed, but it's wrong with boolexprs at least.

Btw it's a minor leak.

EDIT :
To be more accurate it doesn't leak handle references but just take some memory.
And the epic thing, it seems to be true for all handles (at least for triggers and locations).

Meh i wouldn't assume anything more without a personal test now ...
 

BlackRose

Forum User
? You don't in detail how WC3 handles memory? WUT? That doesn't make sense. You dont in detail how? I don't in detail how....


< INSERT GIANT SMILEY FACE HERE >
< YEP, BLACKROSE HAS LOST IT, HE GONE INSANE >
Has anyone really been far even as decided to use even go want to do look more like?
lolwut?
 

Troll-Brain

You can change this now in User CP.
But it's not the same effect, i know it's unbelievable, but you can test the code and you will see it leaks, even if it's minor like i've said.
The reason why i posted here because i thought it was a particular case for boolexpr, but it seems it's true for handle type in general.
 

Troll-Brain

You can change this now in User CP.
What, setting the value to something else instead of null?
It leaks, it's minor but it's still a leak.
I know it's unbelievable, but you can test it yourself, just test my code with the comments for the setting nulls, and then with theses comments removed.
 

GetTriggerUnit-

DogEntrepreneur
:) This is like the only system from you that does not have an ASCII

Well, there you go.
JASS:

//  _  __       _______ _                         ___  
// | |/ /      |__   __(_)                       |__ \ 
// | ' / ___ _   _| |   _ _ __ ___   ___ _ __ ___   ) |
// |  &lt; / _ \ | | | |  | | '_ ` _ \ / _ \ '__/ __| / / 
// | . \  __/ |_| | |  | | | | | | |  __/ |  \__ \/ /_ 
// |_|\_\___|\__, |_|  |_|_| |_| |_|\___|_|  |___/____|
//            __/ |                                    
//           |___/          

// This one is nice too

//  _   __         _____ _                          _____ 
// | | / /        |_   _(_)                        / __  \
// | |/ /  ___ _   _| |  _ _ __ ___   ___ _ __ ___ `' / /'
// |    \ / _ \ | | | | | | '_ ` _ \ / _ \ '__/ __|  / /  
// | |\  \  __/ |_| | | | | | | | | |  __/ |  \__ \./ /___
// \_| \_/\___|\__, \_/ |_|_| |_| |_|\___|_|  |___/\_____/
//              __/ |                                     
//            |____/
 

Jesus4Lyf

Good Idea™
>What, setting the value to something else instead of null?
It leaks, it's minor but it's still a leak.
I know it's unbelievable, but you can test it yourself, just test my code with the comments for the setting nulls, and then with theses comments removed.
He's right. But this has nothing to do with KT2 anymore at all. This is a new leak altogether. Shift discussion here.

Aaaannd I'm not in a rush to ASCII Key Timers 2. :p
 

GoGo-Boy

You can change this now in User CP
Yummy!
Compared to HSAS by PandaMine this is easy as **** to use (although his system attaches to other handles as well).

One last question. I don't need to null struct variables actually do I?
I did that til now because it was necessary in HSAS. But normally I don't need to or?
 

uberfoop

~=Admiral Stukov=~
Yummy!
Compared to HSAS by PandaMine this is easy as **** to use (although his system attaches to other handles as well).
That's because HSAS is a general struct attachment system and this is a timer system. Two completely different things with two completely different purposes.

If you like J4L's systems and you want to attach to, say, units, use this.

One last question. I don't need to null struct variables actually do I?
I did that til now because it was necessary in HSAS. But normally I don't need to or?
You never need to null struct variables even if you are using HSAS. Struct variables themselves are just integers. HSAS refers to nulling the local handle variables, which is something that you should be doing anyway regardless of what system you're using.
 

GoGo-Boy

You can change this now in User CP
Okay thanks, didn't really take a look at AIDS although I implanted it for 'Damage' already. Looks neat^^
I'll un-null my struct members then. Seems like I misunderstood PandaMine:

"The system just uses conventional arrays to store data. The maximum possible number of handles that can be used by the system is specified by a limit per database, however the actual maximum value can be lower, and it decreases as the map time increases (the bigger the gap between the handle indexes the lower the amount of structs you can store). It is however almost IMPOSSIBLE to go through all 3 arrays as long as
1. You are not being stupid
2. MOST CRUCIALLY remember to set your handles to null when you are finished with them. This recycles the index which makes a huge differences in the amount of data the system an store. If you set your handles to null most of the time then you will most likely never reach the limit
3. Someone enjoys playing your map for over a day straight "

Thought he meant struct members because nulling handles is... kinda obvious anyway oO
 

Viikuna

No Marlo no game.
I tried to read that TAZO shit, but I just cant force myself to concentrate on it, because it just seems to be too damn complicated for such an simple thing, so I think I just ask you about this stuff.


Would it be possible to add some functions for pausing this TAZO timer outside of callback, as well as some TimerGetRemaining and TimerGetElapsed functions, or just some way to get the timer that runs some specific instance?
 

SanKakU

Member
ok, i want to learn to use this system that you wrote.
please help me with it.

you said for typical waiting KT2 should be used
also another system should be used for graphics
or whatever. i don't remember what that one was,
but for now i just want to at least tackle this one.

here is a hero revival trigger, for an example


JASS:

scope revivehero initializer I
private function C takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and IsUnitIllusion(GetTriggerUnit()) == false
endfunction
//the following comments are just notes considering you cannot
//view the unit id in the terrain editor
    //call KillUnit( gg_unit_nhmc_0117 )
    //call KillUnit( gg_unit_nder_0195 )
    //call KillUnit( gg_unit_nshe_0196 )
    //call KillUnit( gg_unit_nrac_0197 )
    //call KillUnit( gg_unit_ndog_0190 )
    //call KillUnit( gg_unit_necr_0199 )
    //call KillUnit( gg_unit_nfro_0201 )
    //call KillUnit( gg_unit_npng_0189 )
    //call KillUnit( gg_unit_nfbr_0162 )
    //call KillUnit( gg_unit_ncrb_0148 )
private function A takes nothing returns nothing
local real x
local real y
call TriggerSleepAction(I2R(GetUnitLevel(GetTriggerUnit())) * 1.75 + 10.00)
if GetOwningPlayer(GetTriggerUnit()) == Player(2) then
set x = GetUnitX(gg_unit_nshe_0196)
set y = GetUnitY(gg_unit_nshe_0196)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(3) then
set x = GetUnitX(gg_unit_npng_0189)
set y = GetUnitY(gg_unit_npng_0189)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(4) then
set x = GetUnitX(gg_unit_necr_0199)
set y = GetUnitY(gg_unit_necr_0199)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(5) then
set x = GetUnitX(gg_unit_nfbr_0162)
set y = GetUnitY(gg_unit_nfbr_0162)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(6) then
set x = GetUnitX(gg_unit_nder_0195)
set y = GetUnitY(gg_unit_nder_0195)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(8) then
set x = GetUnitX(gg_unit_nrac_0197)
set y = GetUnitY(gg_unit_nrac_0197)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(7) then
set x = GetUnitX(gg_unit_nfro_0201)
set y = GetUnitY(gg_unit_nfro_0201)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(10) then
set x = GetUnitX(gg_unit_ndog_0190)
set y = GetUnitY(gg_unit_ndog_0190)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(11) then
set x = GetUnitX(gg_unit_ncrb_0148)
set y = GetUnitY(gg_unit_ncrb_0148)
if GetOwningPlayer(GetTriggerUnit()) == Player(9) then
set x = GetUnitX(gg_unit_nhmc_0117)
set y = GetUnitY(gg_unit_nhmc_0117)
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
call ReviveHero(GetTriggerUnit(), x,y,true)
endfunction

//===========================================================================
private function I takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TAF_PUE( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function C ) )
    call TriggerAddAction( t, function A )
endfunction

endscope

now, how do you swap out the TriggerSleepAction function call?
 

Jesus4Lyf

Good Idea™
>now, how do you swap out the TriggerSleepAction function call?
To do that, try this:
JASS:
scope revivehero initializer I
private struct Data
    real x
    real y
    unit hero
endstruct
private function AfterWait takes nothing returns boolean
    local Data d=Data(KT_GetData())
    call ReviveHero(d.hero,d.x,d.y,true)
    call d.destroy()
    return true
endfunction
private function C takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and IsUnitIllusion(GetTriggerUnit()) == false
endfunction
//the following comments are just notes considering you cannot
//view the unit id in the terrain editor
    //call KillUnit( gg_unit_nhmc_0117 )
    //call KillUnit( gg_unit_nder_0195 )
    //call KillUnit( gg_unit_nshe_0196 )
    //call KillUnit( gg_unit_nrac_0197 )
    //call KillUnit( gg_unit_ndog_0190 )
    //call KillUnit( gg_unit_necr_0199 )
    //call KillUnit( gg_unit_nfro_0201 )
    //call KillUnit( gg_unit_npng_0189 )
    //call KillUnit( gg_unit_nfbr_0162 )
    //call KillUnit( gg_unit_ncrb_0148 )
private function A takes nothing returns nothing
local Data d=Data.create()
local real x
local real y
if GetOwningPlayer(GetTriggerUnit()) == Player(2) then
set x = GetUnitX(gg_unit_nshe_0196)
set y = GetUnitY(gg_unit_nshe_0196)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(3) then
set x = GetUnitX(gg_unit_npng_0189)
set y = GetUnitY(gg_unit_npng_0189)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(4) then
set x = GetUnitX(gg_unit_necr_0199)
set y = GetUnitY(gg_unit_necr_0199)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(5) then
set x = GetUnitX(gg_unit_nfbr_0162)
set y = GetUnitY(gg_unit_nfbr_0162)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(6) then
set x = GetUnitX(gg_unit_nder_0195)
set y = GetUnitY(gg_unit_nder_0195)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(8) then
set x = GetUnitX(gg_unit_nrac_0197)
set y = GetUnitY(gg_unit_nrac_0197)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(7) then
set x = GetUnitX(gg_unit_nfro_0201)
set y = GetUnitY(gg_unit_nfro_0201)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(10) then
set x = GetUnitX(gg_unit_ndog_0190)
set y = GetUnitY(gg_unit_ndog_0190)
else
if GetOwningPlayer(GetTriggerUnit()) == Player(11) then
set x = GetUnitX(gg_unit_ncrb_0148)
set y = GetUnitY(gg_unit_ncrb_0148)
if GetOwningPlayer(GetTriggerUnit()) == Player(9) then
set x = GetUnitX(gg_unit_nhmc_0117)
set y = GetUnitY(gg_unit_nhmc_0117)
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
set d.x=x
set d.y=y
set d.hero=GetTriggerUnit()
call KT_Add(function AfterWait,d,I2R(GetUnitLevel(GetTriggerUnit())) * 1.75 + 10.00)
endfunction

//===========================================================================
private function I takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TAF_PUE( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function C ) )
    call TriggerAddAction( t, function A )
endfunction

endscope

I can't syntax check it right now, but that should work. :thup:

However, this will revive the hero at the location of the unit when the hero died. Is the unit mobile? You could store the unit in the struct, and get its x/y when it revives or something. :thup:

Edit: Done that also.
JASS:
scope revivehero initializer I
private struct Data
    unit hero
endstruct
private function AfterWait takes nothing returns boolean
    local Data d=KT_GetData()
    local real x
    local real y
    if GetOwningPlayer(d.hero) == Player(2) then
    set x = GetUnitX(gg_unit_nshe_0196)
    set y = GetUnitY(gg_unit_nshe_0196)
    else
    if GetOwningPlayer(d.hero) == Player(3) then
    set x = GetUnitX(gg_unit_npng_0189)
    set y = GetUnitY(gg_unit_npng_0189)
    else
    if GetOwningPlayer(d.hero) == Player(4) then
    set x = GetUnitX(gg_unit_necr_0199)
    set y = GetUnitY(gg_unit_necr_0199)
    else
    if GetOwningPlayer(d.hero) == Player(5) then
    set x = GetUnitX(gg_unit_nfbr_0162)
    set y = GetUnitY(gg_unit_nfbr_0162)
    else
    if GetOwningPlayer(d.hero) == Player(6) then
    set x = GetUnitX(gg_unit_nder_0195)
    set y = GetUnitY(gg_unit_nder_0195)
    else
    if GetOwningPlayer(d.hero) == Player(8) then
    set x = GetUnitX(gg_unit_nrac_0197)
    set y = GetUnitY(gg_unit_nrac_0197)
    else
    if GetOwningPlayer(d.hero) == Player(7) then
    set x = GetUnitX(gg_unit_nfro_0201)
    set y = GetUnitY(gg_unit_nfro_0201)
    else
    if GetOwningPlayer(d.hero) == Player(10) then
    set x = GetUnitX(gg_unit_ndog_0190)
    set y = GetUnitY(gg_unit_ndog_0190)
    else
    if GetOwningPlayer(d.hero) == Player(11) then
    set x = GetUnitX(gg_unit_ncrb_0148)
    set y = GetUnitY(gg_unit_ncrb_0148)
    if GetOwningPlayer(d.hero) == Player(9) then
    set x = GetUnitX(gg_unit_nhmc_0117)
    set y = GetUnitY(gg_unit_nhmc_0117)
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    call ReviveHero(d.hero, x,y,true)
    call d.destroy()
    return true
endfunction
private function C takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and IsUnitIllusion(GetTriggerUnit()) == false
endfunction
//the following comments are just notes considering you cannot
//view the unit id in the terrain editor
    //call KillUnit( gg_unit_nhmc_0117 )
    //call KillUnit( gg_unit_nder_0195 )
    //call KillUnit( gg_unit_nshe_0196 )
    //call KillUnit( gg_unit_nrac_0197 )
    //call KillUnit( gg_unit_ndog_0190 )
    //call KillUnit( gg_unit_necr_0199 )
    //call KillUnit( gg_unit_nfro_0201 )
    //call KillUnit( gg_unit_npng_0189 )
    //call KillUnit( gg_unit_nfbr_0162 )
    //call KillUnit( gg_unit_ncrb_0148 )
private function A takes nothing returns nothing
    local Data d=Data.create()
    set d.hero=GetTriggerUnit()
    call KT_Add(function AfterWait,d,I2R(GetUnitLevel(d.hero)) * 1.75 + 10.00)
endfunction

//===========================================================================
private function I takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TAF_PUE( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function C ) )
    call TriggerAddAction( t, function A )
endfunction

endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Seeing J4L is definitely a blast from the past.
  • Jesus4Lyf Jesus4Lyf:
    Oh hey Ghan! Long time. :)
    +1
  • jonas jonas:
    J4L! What has happened in your life
  • Jesus4Lyf Jesus4Lyf:
    Hmm, how to summarize... Moved to the USA and got married. Became a professional software engineer and solution lead. Learning Godot for game dev. :)
  • jonas jonas:
    So you are pursuing game dev as a hobby? What industry is your dayjob in?
  • jonas jonas:
    FAANG?
  • Jesus4Lyf Jesus4Lyf:
    Not quite FAANG, less pay for a less hours/stress. Yeah, game dev as a hobby.
  • jonas jonas:
    makes sense. Do we have a hobby game dev subforum to showcase some work?
  • Blackveiled Blackveiled:
    Happy Thursday
    +1
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    TGIF!
  • The Helper The Helper:
    hey tom_mai please do not archive anymore news
  • Ghan Ghan:
    AMD Ryzen 7000 next week :D
    +1
  • The Helper The Helper:
    noice!
  • tom_mai78101 tom_mai78101:
    "hey tom_mai please do not archive anymore news" ----> Got it. What should we do with the "News Archive" subforum?
  • The Helper The Helper:
    I think leave it for real old news that cannot be sorted the reason we had it in the first place was a server issue that we do not have anymore. I don't want to get rid of the archive just not put anything in it for now until we figure it out more
  • The Helper The Helper:
    The side chat has nothing on the discord. it is not possible but the biggest thing on my wish list right now is a sidechat channel on the disord that hooks up to this...
  • Ghan Ghan:
    I've been selected for the Diablo IV beta.
    +1
  • Ghan Ghan:
    Woo!
    +1
  • The Helper The Helper:
    that is so cool
  • V-SNES V-SNES:
    Eh just noticed the new discord section on the side. Looks great!
    +1
  • Blackveiled Blackveiled:
    :( feels bad I can't ever get selected for any beta I sign up for. It's annoying as heck.
    +1
  • The Helper The Helper:
    Hello mgarcia! Happy Monday everyone!

    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