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.
 
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 )
 
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
 
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.
 
Thank you, again. The spell works great now, and I learned more than I thought I would. :p
 
General chit-chat
Help Users
  • The Helper The Helper:
    It is weird seeing a way more realistic users online number
  • The Helper The Helper:
    Happy Tuesday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:

      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