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.
  • 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
    +2
  • 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