scope ShieldWall initializer Init
globals
private constant integer Abil_id = 039;----039; // Raw code of the passive ability.
private constant string Sfx = "Your\\effect\\here." // May want an effect to Play
private constant string Point = "chest" // Probably the best place for an attachment point.
endglobals
private function Percent takes integer lvl returns real
return 0.20*lvl // Percentage of damaged healed. So 100 damage dealt would only be 80/60/40.
endfunction
private function Chance takes integer lvl returns integer
return 10+(5*lvl) // Percent chance to absorb damage.
endfunction
private function Heal takes nothing returns boolean
local unit cast = GetTriggerUnit()
local real dam = GetEventDamage()
local integer lvl = GetUnitAbilityLevel(cast,Abil_id)
if (dam > 1) then
if (GetRandomInt(1,100) <= Chance(lvl)) then
call SetWidgetLife(cast,GetWidgetLife(cast)+(dam*Percent(lvl)))
call DestroyEffect(AddSpecialEffectTarget(Sfx,cast,Point))
endif
endif
set cast = null
return false
endfunction
private function Actions takes nothing returns nothing
local unit cast = GetTriggerUnit()
local trigger trig
if GetUnitAbilityLevel(cast,Abil_id) == 1 then
set trig = CreateTrigger()
call TriggerRegisterUnitEvent(trig,cast,EVENT_UNIT_DAMAGED)
call TriggerAddCondition(trig,Condition(function Heal))
endif
set cast = null
endfunction
private function Conditions takes nothing returns boolean
return GetLearnedSkill() == Abil_id and IsUnitIllusion(GetTriggerUnit()) == false
endfunction
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(trig,Condition(function Conditions))
call TriggerAddAction(trig,function Actions)
endfunction
endscope
Mana shield doesn't seam to work. If I change these fields:
Damage Absorbed (%) to 0.60
Mana Per Hit Point to 0.00
The mana shield buff disappears after one hit. =/