Cooldown system issues

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Updated my post. Now it can handle multiple level.

Usage :
JASS:
set Slot['TEST'] = 1
set Cooldown['TEST'][<level>] = 10.
set HeroAbilities['HERO'][<slot number>] = 'TEST'
 

Nexor

...
Reaction score
74
Kingkingyyk3: Your updated post has some compile errors, and I don't know your code, so I can't repair it.

Viikuna: The compiler says at this line

JASS:
private static method hook_ReplaceUnitBJ takes unit whichUnit, integer newUnitId, integer unitStateMethod returns nothing


the following: Unable to find textmacro : "optional"
This has never happened to me.

And yes, I have the latest NewGen I dl'ed it yesterday.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Kingkingyyk3: Your updated post has some compile errors, and I don't know your code, so I can't repair it.

Updated again. 100% compilable now.
 

Nexor

...
Reaction score
74
yeah, it compiles now, but it won't give any fake ability to the caster and will not give the ability back.

other issue: using mirror image caused critical error
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Sorry, my bad. >< Nevermind, it should works now. Newer version is in my previous post.

Here's an example for implementing cooldown system for normal Archmage :
JASS:
library CooldownInit initializer Init requires Cooldown

    private function Init takes nothing returns nothing
        set Slot[&#039;AHbz&#039;] = 1
        set Cooldown[&#039;AHbz&#039;][1] = 6.
        set Cooldown[&#039;AHbz&#039;][2] = 6.
        set Cooldown[&#039;AHbz&#039;][3] = 6.
        
        set Slot[&#039;AHwe&#039;] = 2
        set Cooldown[&#039;AHwe&#039;][1] = 20.
        set Cooldown[&#039;AHwe&#039;][2] = 20.
        set Cooldown[&#039;AHwe&#039;][3] = 20.
        
        set HeroAbilities[&#039;Hamg&#039;][1] = &#039;AHbz&#039;
        set HeroAbilities[&#039;Hamg&#039;][2] = &#039;AHwe&#039;
        
    endfunction
    
endlibrary

Or you can do it in spell's init if the spell is triggered.
 

Nexor

...
Reaction score
74
Thank you for a demo setup.

I tried it out and it isn't working :S:S

The other thing, with the mirror image ability: it just exits with a critical error.
I don't think the END_CAST event is the best for this system :S

EDIT: sorry, I didn't see you updated the system code.
It's working woohooo :D:D thank you very much.

Some questions though:
-how do I implent some functions, like:
*the remaining time of an ability
*name of the ability and such
-how do I implent functions that will manipulate with the ability cooldown:
*increase/decrease
*set it to a number
*pause it !!!
*reset
*restart
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
I will implement them. Just wait for the update. :)

JASS:
library Cooldown initializer Init requires PUI, ABC
    
    globals
        private constant integer MAX_ABILITY = 4
        private integer array DisabledAbilities
        private constant integer MaxAbilityPlusOne = MAX_ABILITY + 1
    endglobals
    
    struct Slot extends array
        private static integer array Data
        
        static method operator []= takes integer id, integer value returns nothing
            set thistype.Data[id-(id/8191)*8191] = value
        endmethod
        
        static method operator[] takes integer id returns integer
            return thistype.Data[id-(id/8191)*8191]
        endmethod
        
    endstruct

    struct Cooldown extends array
        private static hashtable ht = InitHashtable()
        
        static method operator [] takes integer id returns thistype
            return id
        endmethod
                
        method operator [] takes integer level returns real
            return LoadReal(thistype.ht,this,level)
        endmethod
                
        method operator []= takes integer level, real value returns nothing
            call SaveReal(thistype.ht,this,level,value)
        endmethod
    endstruct
    
    struct HeroAbilities extends array
        private static hashtable ht = InitHashtable()
        
        static method operator [] takes integer pos returns thistype
            return pos
        endmethod
        
        method operator [] takes integer pos returns integer
            return LoadInteger(thistype.ht,this,pos)
        endmethod
        
        method operator []= takes integer pos, integer value returns nothing
            call SaveInteger(thistype.ht,this,pos,value)
        endmethod
    endstruct
    
    public struct Data
        unit hero
        timer array t [MaxAbilityPlusOne]
        boolean array ready [MaxAbilityPlusOne]
        
        method reset takes integer pos returns nothing
            set .ready[pos] = true
            call PauseTimer(.t[pos])
            call UnitRemoveAbility(.hero,DisabledAbilities[pos])
            call UnitAddAbility(.hero,HeroAbilities[GetUnitTypeId(.hero)][pos])
        endmethod
        
        static method removeCooldown takes nothing returns nothing
            call thistype(GetTimerStructA(GetExpiredTimer())).reset(GetTimerStructB(GetExpiredTimer()))
        endmethod
        
        method add takes integer id returns nothing
            local integer abil_id = id
            local integer pos = Slot[abil_id]
            local integer lv = 0
            if .t[pos] == null then
                set .t[pos] = CreateTimer()
                call SetTimerStructA(.t[pos],this)
                call SetTimerStructB(.t[pos],pos)
            endif
            set .ready[pos] = false
            set lv = GetUnitAbilityLevel(.hero,abil_id)
            call UnitRemoveAbility(.hero,abil_id)
            call UnitAddAbility(.hero,DisabledAbilities[pos])
            call TimerStart(.t[pos],Cooldown[abil_id][lv],false,function thistype.removeCooldown)
            //call BJDebugMsg(&quot;Slot : &quot; + I2S(pos))
            //call BJDebugMsg(&quot;Cooldown : &quot; + R2S(Cooldown[abil_id][lv]))
        endmethod
        
        method resetall takes nothing returns nothing
            local integer i = 1
            loop
                call .reset(i)
            exitwhen i == MAX_ABILITY
            endloop
        endmethod
        
        method remaining takes integer abil_id returns real
            return TimerGetRemaining(.t[Slot[abil_id]])
        endmethod
        
        method pause takes integer abil_id returns nothing
            call PauseTimer(.t[Slot[abil_id]])
        endmethod
        
        method restart takes integer abil_id returns nothing
            local integer i = Slot[abil_id]
            call .reset(i)
            call .add(abil_id)
        endmethod
        
        method isReady takes integer abil_id returns boolean
            return .ready[Slot[abil_id]]
        endmethod
        
        static method create takes unit hero returns thistype
            local thistype this = thistype.allocate()
            set .hero = hero
            return this
        endmethod
        //! runtextmacro PUI()
    endstruct
    
    private function Cond takes nothing returns boolean
        if Data[GetTriggerUnit()] == 0 then
            set Data[GetTriggerUnit()] = Data.create(GetTriggerUnit())
        endif
        call Data(Data[GetTriggerUnit()]).add(GetSpellAbilityId())
        return false
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_ENDCAST)
        call TriggerAddCondition(trig,Condition(function Cond))
        
        set DisabledAbilities[1] = &#039;A001&#039;
        set DisabledAbilities[2] = &#039;A002&#039;
        set DisabledAbilities[3] = &#039;A003&#039;
        set DisabledAbilities[4] = &#039;A004&#039;
    endfunction
    
endlibrary


JASS:
call Cooldown_Data(hero).reset(ability&#039;s id)
call Cooldown_Data(hero).resetAll()
Cooldown_Data(hero).remaining(ability&#039;s id) -&gt; remaining cooldown
call Cooldown_Data(hero).pause(ability&#039;s id)
call Cooldown_Data(hero).resume(ability&#039;s id)
call Cooldown_Data(hero).restart(ability&#039;s id)
Cooldown_Data(hero).isReady(ability&#039;s id) -&gt; Is the ability ready?
//For abilities&#039; name, just use
GetObjectName(ability&#039;s id) -&gt; string
 

Nexor

...
Reaction score
74
Hmm it looks nice :) Thank you !

Q: Is it possible to write in the argument the skill position and not the ability id ?
 

Nexor

...
Reaction score
74
Okay, I got the position part I asked for in my previous post.

Now I want to write out the cooldowns locally for each player in a multiboard.
But it seems the values got overwritten and I don't know the reason.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Is it possible to write in the argument the skill position and not the ability id
Just use Slot[ability] to convert ability into slot.

Now I want to write out the cooldowns locally for each player in a multiboard.
Mind to post the map? :)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
You have messed up your multiboard.
Just use 0 as array value, it works flawlessly. It can reduce some calculating.
 

Nexor

...
Reaction score
74
I don't get it where should I use 0 as array value, in the multiboard update trigger?
 

Nexor

...
Reaction score
74
I changed it, and now it shows for me (player 0) the values of player 1

Could you change it in the posted map and send it back?
 

Nexor

...
Reaction score
74
For me, the PUI writes out some error ALOT of times (because the periodic trigger)
And if I don't cast the spell first (I wait until comp player casts it) then I can see his cooldown
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      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