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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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