Warcraft III resources & community, 2003–2006 · archived

Increasing a unit's max hp

16 posts
#16
Aaah yes those rawcodes! Completely forgot about them :oops: . Thanks a lot! It really works now, just not perfectly, it doesn't stack yet because it keeps setting the hp back to the real local I saved, so I changed it to this now:

function Trig_White_MageHealthShield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02O'
endfunction


function Trig_White_MageHealthShield_Actions takes nothing returns nothing
    local unit Targ = GetSpellTargetUnit()
    local unit Cast = GetSpellAbilityUnit()
    local real PercHP = GetUnitLifePercent(Targ)
    local real NewHP = GetUnitState(Targ, UNIT_STATE_MAX_LIFE) + 30 * GetUnitAbilityLevel(Cast, 'A02O')
    local real HPdif = NewHP - GetUnitState(Targ, UNIT_STATE_MAX_LIFE)
    set Cast = null
    call SetUnitMaxState(Targ, UNIT_STATE_MAX_LIFE, R2I(NewHP))
    call SetUnitLifePercentBJ( Targ, PercHP )
    call TriggerSleepAction( 30.00 )
    set PercHP = GetUnitLifePercent(Targ)
    call SetUnitMaxState(Targ, UNIT_STATE_MAX_LIFE, R2I(GetUnitState(Targ, UNIT_STATE_MAX_LIFE) - HPdif))
    call SetUnitLifePercentBJ( Targ, PercHP )
    set Targ = null
endfunction


//===========================================================================
function InitTrig_White_MageHealthShield takes nothing returns nothing
    set gg_trg_White_MageHealthShield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_White_MageHealthShield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_White_MageHealthShield, Condition( function Trig_White_MageHealthShield_Conditions ) )
    call TriggerAddAction( gg_trg_White_MageHealthShield, function Trig_White_MageHealthShield_Actions )
endfunction


But haven't tested it yet, but really thanks a lot all ^^.