Gain 3% of maximum hp on killing a unit

LassePihl

New Member
Reaction score
0
Hello out there :) I am trying to create a hero for my game, who I have granted a passive ability that should be regaining 3% of the heros max hp each time he kills a creep. Can anyone help me how to do that? :)

Each time he kills a unit he must regain 3% of his maximum hp :)
 

Bogrim

y hello thar
Reaction score
154
Open the trigger editor. Create a new trigger. For event, you'll want a generic unit event - a unit dies. For your condition, you need an integer comparison checking the level of your ability for the killing unit. For the action, you should just make a unit action and set the killing unit's percentage health to (current percentage + 3%).
 

felnix

New Member
Reaction score
4
Sample:

Trigger:
  • Gain hp Skill
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Killing unit) Equal to Your_Unit
    • Actions
      • Unit - Set life of Your_Unit to ((Life of Your_Unit) + ((Max life of Your_Unit) x 0.03))


Your_Unit refer to your hero

Well you can add more condition in it. Hope this help you :)
 

Carnerox

The one and only.
Reaction score
84
JASS:
function Trig_Heal_Conditions takes nothing returns boolean
    return (UnitHasBuffBJ(GetKillingUnit(), 'BNab') == true) //'BNab' = The buff for the spell.
endfunction

function Trig_Heal_Actions takes nothing returns nothing
    local unit triggerunit = GetTriggerUnit() //If GetTriggerUnit() doesn't work try GetAttacker().
    local unit dyingunit = GetDyingUnit()
    local real heal = (GetUnitStateSwap (UNIT_STATE_LIFE, triggerunit) + (GetUnitStateSwap(UNIT_STATE_MAX_LIFE, triggerunit) * 0.03))
    call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", triggerunit, "chest"))
    call SetUnitLifeBJ (triggerunit, heal)
    set triggerunit = null
    set dyingunit = null
endfunction

//===========================================================================
function InitTrig_Heal takes nothing returns nothing
    local trigger heal = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (heal, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition (heal, Condition( function Trig_Heal_Conditions))
    call TriggerAddAction (heal, function Trig_Heal_Actions)
endfunction
 

IronTrout

New Member
Reaction score
20
I'm gunna base my answer off felnix, do the same thing, but I've found if you use the Condition

Trigger:
  • ((Killing Unit) has buff PassiveBuff) Equal to True


Works much better and is MUI friendly :)

Edit: Typo, And to regain my pride;
Trigger:
  • Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) has buff Devotion Aura) Equal to (==) True
    • Actions
      • Unit - Set life of (Killing unit) to ((Percentage life of (Killing unit)) + 3.00)%


Works fine. But yes i realise that you can't modify total hp without adding abilities to units, so go with jass :p
 

jig7c

Stop reading me...-statement
Reaction score
123
need to change this:
JASS:
local real heal = (GetUnitStateSwap (UNIT_STATE_LIFE, triggerunit) + (GetUnitStateSwap(UNIT_STATE_MAX_LIFE, dyingunit) * 0.03))


to:
JASS:
local real heal = (GetUnitStateSwap (UNIT_STATE_LIFE, triggerunit) + (GetUnitStateSwap(UNIT_STATE_MAX_LIFE, triggerunit) * 0.03))


he wants 3% of the hero's hp, not the dying unit's hp...

this:
JASS:
call AddSpecialEffectTarget ("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", triggerunit, "chest")
call DestroyEffect (GetLastCreatedEffectBJ())


can be simplified to:
JASS:
call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", triggerunit, "chest"))
 

Carnerox

The one and only.
Reaction score
84
need to change this:
JASS:
local real heal = (GetUnitStateSwap (UNIT_STATE_LIFE, triggerunit) + (GetUnitStateSwap(UNIT_STATE_MAX_LIFE, dyingunit) * 0.03))


to:
JASS:
local real heal = (GetUnitStateSwap (UNIT_STATE_LIFE, triggerunit) + (GetUnitStateSwap(UNIT_STATE_MAX_LIFE, triggerunit) * 0.03))


he wants 3% of the hero's hp, not the dying unit's hp...

this:
JASS:
call AddSpecialEffectTarget ("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", triggerunit, "chest")
call DestroyEffect (GetLastCreatedEffectBJ())


can be simplified to:
JASS:
call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", triggerunit, "chest"))

my bad on the heal part, but besides that i just typed it up quickly.:rolleyes:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top