Stacking buffs with Jass not possible?

DubDub

New Member
Reaction score
0
After a days worth of searching I've yet to come across anything up to date about stacking buffs. The most interesting thread I could find came from this site but the process itself seems broken with the newest patch.
http://www.thehelper.net/forums/showthread.php?t=44499&highlight=buffs

Is anything like this possible anymore, and is there any way to update this code to work? The spell itself is great and I was hoping to tweak it to make a variety of buffs. I think I understand what's wrong with it but I'm looking for an expert opinion first. :)

My knowledge of Jass is minimal but I'd really like to understand how to fix the majority of out-dated spells I come across that all seem to have broken with the latest patch. :p It's awful finding a neat spell only to find out it's not use-able anymore.

I'd really appreciate any help with this one.
 

Viikuna

No Marlo no game.
Reaction score
265
You can probably make that working by making it use some other data storage system instead of CScache.

If your Jass knowledge aint good enough to find CScache calls and replacing them with hashtables for example, you have to either learn more or get someone to do it for you.

You can also use some of the existing buff systems such as: ABuff ( really cool and hideously complicated ) or Inuitive Buff System ( More simple and pretty cool too )

The reason why old spells wont work anymore, is that Blizzard is trying to kill return bug, which was used by many data storage thingies in the past.
Gamecache based systems are now gone, but they can be replaced with native hashtables.
Systems that used H2I function can be made to work by replacing H2I with new native GetHandleId

JASS:


// this is H2I function:

function H2I takes handle h returns integer
    return h
    return 0
endfunction

// for example this:

set x=H2I( something )

// can be replaced with this:

set x=GetHandleId( something )
 

DubDub

New Member
Reaction score
0
That's a great tutorial! It's a shame the tutorials only for GUI, but I'm sure I'll find a use for it when I work on another spell. What I don't understand is executing a code that uses hashtables on Jass. :(

*edit*

Almost Solved!

I finally got the spell to work after some trial and error messing around and learning about hashtables on Jass. :p
The only issues I have is that it lags when it's first activated, and I have no idea if it's even MUI or leakless.
Can someone confirm,please? I'm still wondering if I even did it the right way, hehe.


JASS:
//===========================================================================
//Every kill the unit makes grants it +1 damage buff to a maximum of 5.
//Each level of the spell raises the cap by +5. If the unit does not kill
//again within the minute he will begin to lose the bonus damage by
// 1-3 per minute, depending on level.
//
//
//@ Original author emjlr3 
//@ Minor Edit by DubDub (changed CScache calls to Hashtables)
//http://www.thehelper.net/forums/showthread.php?t=44499&highlight=buffs
//
//===========================================================================
scope Stackbuff initializer TriggBuff

globals
    private hashtable Buff = InitHashtable() 
endglobals

function Buff_Detect takes nothing returns boolean
    return GetUnitAbilityLevel(GetKillingUnit(),'A024')>0    
endfunction

function Buff_Remove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer s = (GetHandleId(t))
    local unit u = LoadUnitHandle(Buff,s, StringHash("hero"))
    local integer lvl = LoadInteger(Buff,s,StringHash("lvl"))
    local integer bonus = GetUnitAbilityLevel(u,'A025')
    
    call PauseTimer(t)
    if bonus==lvl then        
        call UnitRemoveAbility(u,'A025')
    else
        call SetUnitAbilityLevel(u,'A025',bonus-lvl)
    endif
    call RemoveSavedHandle(Buff,s, StringHash("hero"))
    call RemoveSavedInteger(Buff,s, StringHash("lvl"))
    call DestroyTimer(t)
       
    set u = null
endfunction

function Buff_Actions takes nothing returns nothing
    local unit u = GetKillingUnit()
    local integer lvl = GetUnitAbilityLevel(u,'A024')
    local integer bonus = GetUnitAbilityLevel(u,'A025')
    local timer t
    local integer s
    
    if bonus<lvl*5 then
        if bonus==0 then
            call UnitAddAbility(u,'A025')
        endif
        if bonus<=(lvl*5)-lvl then
            call SetUnitAbilityLevel(u,'A025',bonus+lvl)
        else
            call SetUnitAbilityLevel(u,'A025',lvl*5)
        endif
        
        set t = CreateTimer()
        set s = (GetHandleId(t))
        call SaveUnitHandle(Buff, s, StringHash("hero"),u)
        call SaveInteger(Buff,s,StringHash("lvl"),lvl)
        call TimerStart(t,60.,false,function Buff_Remove)
    endif

    
    set u = null
endfunction

function TriggBuff takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(trig, Condition(function Buff_Detect))
    call TriggerAddAction(trig, function Buff_Actions)
    set trig = null
    
    
endfunction


endscope
 

Viikuna

No Marlo no game.
Reaction score
265
It looks good to me. First time lagg might be because you havent preloaded that bonus ability/abilities. ( One ability with 10 levels is exactly same as 10 abilities with one level ) You can do this by adding an ability to some dummy unit when game starts. There is also a nice system called UnitProperties, for handling all these bonus ability thingies.

Hashtable stuff looks good. You can also skip that string hash thing, by using keys. Its a nice vJass feature, and works like this:

JASS:
globals
    private hashtable Buff = InitHashtable() 
    private key Hero // keys are declared here
    private key Level
endglobals

// ...

    local unit u = LoadUnitHandle(Buff,s,Hero) // keys are used here
    local integer lvl = LoadInteger(Buff,s,Level)


Also, it is better to recycle timers, instead of creating&destroying them all the time. TimerUtils is probably the most comon system for that stuff. It also does that attaching thingy for you, so you dont have to type that hashtable stuff by yourself.

Anyways, it looks pretty good.
 

DubDub

New Member
Reaction score
0
Thank you, again. The spell works great now, and I learned more than I thought I would. :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top