Adding Maximum HP

jhnam95

Active Member
Reaction score
12
I'm trying to figure out a way to add maximum HP to a unit. I'm using the +Maximum HP spells that are based on items that give bonus hp. Since those abilities can only have 1 level, I used binaries to add the specific amount. For some reason, the trigger won't add the amount I tell it to.

I just made a simple ability on warstomp to test it out. It's supposed to give 250 HP. Unfortunately, it doesn't give any.

MaxLevel is just however many base abilities I made. I made 13 because I got lazy, but with 13, up to 8095 HP can be added...

HPID are just the list of the abilities. HPID[1] is +1 HP, HPID[2] is +2, HPID[3] is +4 and so on.

Here's the code:

JASS:
function Trig_Add_HP_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00D' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Add_HP_Actions takes nothing returns nothing
    local integer i = 1
    local integer i2
    local integer i3
    local integer CurrentHP
    local unit u = GetTriggerUnit()
    local integer AddingHP = 250
    loop
        exitwhen i > MaxLevel
        if GetUnitAbilityLevel(u, HPID<i>) == 1 then
            call UnitRemoveAbility(u, HPID<i>)
        endif
        set i = i + 1
    endloop
    if (IsUnitInGroup(u, FirstCast[1]) == false) then
        set CurrentHP = 0
    else
        set CurrentHP = LoadInteger(GlobalHashtable, StringHash(&quot;+HP&quot;), GetHandleId(u))
        call GroupAddUnit(FirstCast[1], u)
    endif
    set CurrentHP = AddingHP + CurrentHP
    set i3 = CurrentHP
    set i = MaxLevel
    loop
        exitwhen i &lt; 0
        set i2 = R2I(Pow(I2R(2), I2R(i)))
        if i2 &lt;= CurrentHP then
            call UnitAddAbility(u, HPID<i>)
            set CurrentHP = (CurrentHP - i2)
        endif
        set i = i - 1
    endloop
    call SaveInteger(GlobalHashtable, StringHash(&quot;+HP&quot;), GetHandleId(u), i3)
    set u = null
endfunction

//===========================================================================
function InitTrig_Add_HP takes nothing returns nothing
    set gg_trg_Add_HP = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Add_HP, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Add_HP, Condition( function Trig_Add_HP_Conditions ) )
    call TriggerAddAction( gg_trg_Add_HP, function Trig_Add_HP_Actions )
endfunction

</i></i></i>


I'm really not good at JASS, so if the solution requires some sophisticated JASS or vJASS, I'd appreciate it if you clarified the various functions and steps.
 
I can give you a GUI version on how to passively increase your maximum hp.
The spell gives you 1/2/3/4 Hp for each unit killed and 5/10/15/20 for each hero killed. The spell was originally made by Tom_Kazansky. I'm not taking any credit for this spell. He just helped me so now I would like to help you. Do you want it?
 
Hmm for some strange reason the spell isn't working very well. Wait give me a minute. I think I can fix it up. Sorry for the technical difficulties ;)

Edit: Seems like the spell works only if the hero is on full health. You can get the general idea though. I will upload the map below.
 

Attachments

  • [Spell] Vampiric Touch.w3x
    19.6 KB · Views: 176
So theoretically, if I wanted to add 500 HP, I'd just have to run the loop 500 times, assuming each loop gave 1 bonus HP?

I'm still curious on why my +HP system didn't work.
 
Yes I already got my question answered via the alternative method. My question now is: why didn't my previous trigger work?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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