Combo Point System; Was Working, Now Fails

WolfieeifloW

WEHZ Helper
Reaction score
372
I have no idea what changed that could have wrecked this system.
It was working completely fine, and now it doesn't.

What's supposed to happen:
A unit uses a certain spell (Mangle or Claw) and gets a 'combo point'.
Combo points range from 0-5.
So, I made 6 spells with different icons/descriptions/models to represent these combo points.

When the hero uses Mangle/Claw, it's combo points get increased by 1 up to a maximum of 5.
The system removes the current combo point ability, and gives it the next rank (Again, up to 5).

The problem?
On the first attack, it just stays with the 0 ability.
On the second attack, it keeps the 0 ability, AND gives the hero the 1 ability.
On the third, it keeps 0, 1, and gives the hero the 2 ability.

However, according to the BJDebug's, it should be working perfectly:
JASS:
scope ComboPoints initializer CPInit

    globals
        integer array combo
    endglobals    

    private function Conditions takes nothing returns boolean
        local unit u
        local integer ud
        
        call BJDebugMsg("Running")        
        if (GetUnitTypeId(GetTriggerUnit()) == feralDruid and GetSpellAbilityId() == mangle or GetSpellAbilityId() == claw) then
            call BJDebugMsg("Passed")
            set u = GetTriggerUnit()
            set ud = GetUnitUserData(u)
            call BJDebugMsg("Before UD- " + I2S(ud))
            if (ud != 5) then
                call BJDebugMsg("Passed2")
                call UnitRemoveAbility(u, combo[ud])
                call SetUnitUserData(u, ud + 1)
                call BJDebugMsg("After UD- " + I2S(GetUnitUserData(u)))
                call UnitAddAbility(u, combo[ud])
            endif
        endif
        set u = null
        return false
    endfunction

    private function CPInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer index = 0
        
        loop
            call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope

The outcome of the debugs for the first cast are:
Running
Passed
Before UD- 0
Passed2
After UD- 1
And for the second cast:
Running
Passed
Before UD- 1
Passed2
After UD- 2
And so on.
According to these, it should be removing the current ability, and replacing it with the next one up, which it's not.
 

Solmyr

Ultra Cool Member
Reaction score
30
And where is your array filled?
JASS:
set combo[1] = 'A000'
set combo[2] = 'A001'
set combo[3] = 'A002'
set combo[4] = 'A003'
set combo[5] = 'A005'

or anything similar to that?
 

luorax

Invasion in Duskwood
Reaction score
67
JASS:
if (ud != 5) then
    call BJDebugMsg("Passed2")
    call UnitRemoveAbility(u, combo[ud])
    call SetUnitUserData(u, ud + 1)
    call BJDebugMsg("After UD- " + I2S(GetUnitUserData(u)))
    call UnitAddAbility(u, combo[ud])
endif


should be:
JASS:
if (ud != 5) then
    call BJDebugMsg("Passed2")
    call UnitRemoveAbility(u, combo[ud])
    call SetUnitUserData(u, ud + 1)
    call BJDebugMsg("After UD- " + I2S(GetUnitUserData(u)))
    call UnitAddAbility(u, combo[ud+1])
endif


What happened? You changed the unit's user data. It's good, but as array index, you used a local variable (ud) which remained the same.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Ah, yes..
JASS:
scope ComboPoints initializer CPInit

    globals
        integer array combo
    endglobals    

    private function Conditions takes nothing returns boolean
        local unit u
        local integer ud
        
        call BJDebugMsg("Running")        
        if (GetUnitTypeId(GetTriggerUnit()) == feralDruid and GetSpellAbilityId() == mangle or GetSpellAbilityId() == claw) then
            call BJDebugMsg("Passed")
            set u = GetTriggerUnit()
            set ud = GetUnitUserData(u)
            call BJDebugMsg("Before UD- " + I2S(ud))
            if (ud != 5) then
                call BJDebugMsg("Passed2")
                call UnitRemoveAbility(u, combo[ud])
                call SetUnitUserData(u, ud + 1)
                call BJDebugMsg("After UD- " + I2S(GetUnitUserData(u)))
                call UnitAddAbility(u, combo[GetUnitUserData(u)])
            endif
        endif
        set u = null
        return false
    endfunction

    private function CPInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer index = 0
        
        loop
            call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope

That works fine now :)

My damage trigger for the combo point user spell doesn't work either though..
I've looked over it and can't find why..
JASS:
scope FerociousBite initializer FBnit

    private function Chance takes integer level returns integer
        return level * 2
    endfunction

    private function Damage takes integer level returns real
        return (level * 0.5) + 0.5
    endfunction
    
    private function Conditions takes nothing returns boolean
        local real fbDamage
        local unit u
        local integer ud
        
        if (GetSpellAbilityId() == ferociousBite and GetUnitUserData(u) > 0) then
            set u = GetTriggerUnit()
            set ud = GetUnitUserData(u)
            set fbDamage = (GetHeroAgi(u, true) * Damage(ud))
            call UnitDamageTarget(u, GetSpellTargetUnit(), fbDamage, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            call UnitRemoveAbility(u, combo[ud])
            if (GetRandomInt(1, 100) <= Chance(GetUnitAbilityLevel(u, ferociousBite)) and ud >= 4) then
                call SetUnitUserData(u, ud - 3)
            else
                call SetUnitUserData(u, 0)
            endif
            call UnitAddAbility(u, combo[GetUnitUserData(u)])
        elseif (GetSpellAbilityId() == ferociousBite and ud <= 0) then
            call IssueImmediateOrder(u, "stop")
            call SimError(GetOwningPlayer(u), "You need at least one combo point!")
        endif
        set u = null
        return false
    endfunction

    private function FBnit takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer index = 0
        
        loop    
            call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope

It's based off 'Channel', but again, it worked before and now it doesn't.
 

Magthridon96

Member
Reaction score
2
Don't use SetUnitUserData, only GetUnitUserData.
Using SetUnitUserData would break a lot of systems like AIDS, UnitIndexer, UnitIndexer GUI, etc...
 

Romek

Super Moderator
Reaction score
964
You'll almost certainly end up using some sort of indexing system, or a resource which uses some sort of indexing.
I too, would strongly recommend using AIDS and an array instead of UnitUserData, and saving yourself the trouble of converting everything later. ;)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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

      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