Item Life Bonus not Working

ZiggyMcjoney

Data editor?! AAAHHHHH!
Reaction score
95
So I have an ability based off of Item Life Bonus. It has 51 levels, level 1 gives 0 hp, 2 gives 15, 3 30 etc. It goes up by 15 each time basically.

Now my problem is, this ability is leveled through a trigger, and while the ability is definitely leveling up (I can tell because I have a hp regen trigger that does trigger health regeneration based on the level of this ability, and the health regenerated is increasing), the health it gives is not. The same is happening with the mana ability.

I'll post the trigger anyways but I don't think it's related, and it's also in JASS:

JASS:
private function Actions takes nothing returns nothing
    if udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] >= 1 then
        set udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] - 1
        call SetItemCharges(UnitItemInSlot(GetTriggerUnit(), 4), udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))])
        set udg_Toughness[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = udg_Toughness[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] + 1
        if GetUnitAbilityLevel(GetTriggerUnit(), 'A003') < 51 then
            call SetUnitAbilityLevel(GetTriggerUnit(), 'A003', GetUnitAbilityLevel(GetTriggerUnit(), 'A003') + 1)
        else
            call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0, "You cannot add any more levels to this stat, as it has maxed out!")
        endif
    else
        call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0, "Not enough attribute points!")
    endif
    call SetItemCharges(GetManipulatedItem(), udg_Toughness[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))])
endfunction


Is there a problem with item life bonus that I'm missing? Thanks in advance for any help.
 

jonadrian619

-___-
Reaction score
242
I don't get the JASS code clearly, but from what I can see it sets the charges of a particular item and it sets the level of an ability, might be Item Life Bonus. It doesn't contain any code w/c gives it an HP/Mana bonus. Maybe I missed something?

Leveling Item Life Bonus won't work I think, the best way to achieve the bonus is to add an Item Life Bonus ability (only has 1 level) to that unit everytime he levels up. :thup:

It is cumulative and it stacks, for example if I use Unit - Add Ability to a Hero and it's an Item Life Bonus (15) for 3 times then he gets 45 HP. I tried this one before on a map. Please try this first by adding Item Life Bonus on a unit 100 times and if this causes your map to lag, then forget about it.

-- Umaku iku yō ni -|- jonadrian619 --​
 

Tom Jones

N/A
Reaction score
437
Yea, that ability acts funny. When you remove the ability from a unit, the actual hp/mana the ability was supposed to add is added. Here's an example on how it works in GUI:
Link.
 

vypur85

Hibernate
Reaction score
803
If you're player 1, and if GetPlayerId is used, it will return as Player 0. Probably what you want is 'GetConvertedPlayerId'? Or you could just add the +1 everytime you call for the player ID:

Code:
udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))[B] + 1[/B]]

Not sure if this is the main problem though.

Edit:
Guess I suck in JASS pretty badly...
 

ZiggyMcjoney

Data editor?! AAAHHHHH!
Reaction score
95
Yea, that ability acts funny. When you remove the ability from a unit, the actual hp/mana the ability was supposed to add is added. Here's an example on how it works in GUI:
Link.

Hrm, I tried to use that by adding the ability (which gave +15hp) and then immediately removing it, but nothing happened.

When I gave the unit the ability permenantly, by the way, it worked on the first addition of the ability but every subsequent one the units health did not increase.

Any other ideas?

JASS:
private function Actions takes nothing returns nothing
    if udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] >= 1 then
        if udg_Intelligence[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] < 51 then
            set udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] - 1
            call SetItemCharges(UnitItemInSlot(GetTriggerUnit(), 4), udg_AttributePoints[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))])
            call UnitAddAbility(GetTriggerUnit(), 'A004')
            call UnitRemoveAbility(GetTriggerUnit(), 'A004')
            set udg_Intelligence[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = udg_Intelligence[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] + 1
        else
            call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0, "You cannot add any more levels to this stat, as it has maxed out!")
        endif
    else
        call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0, "Not enough attribute points!")
    endif
    call SetItemCharges(GetManipulatedItem(), udg_Intelligence[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))])
endfunction


That's what the function looks like right now.

EDIT: I used Blade.dk's function and managed to get it working. Thanks anyway guys :p
 

Tom Jones

N/A
Reaction score
437
My memory didn't serve me well in this case. When you add the ability to a unit nothing happens. When you remove the ability from the unit, the engine removes the hp that the ability was supposed to have gained, thus your unit will lose x max hp when you remove the ability. Luckily the engine treats negative values in the same way, thus if a unit was supposed to lost -x max hp from the ability, the engine will add x max hp when the ability is used. To sum up, try changing your A004 ability to -1000 for example, and see if that doesn't work.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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