I got this two triggers in my (test-)map, but the spell, which should save the target untouched and transfer all damage to the caster, doesn't work.
The spell is actually based on Holy Light (I didn't found any good baseskill, because I play just DotA, not any melee maps) and gives the target a buff, which is based on anti-magicshield (magic immun!).
JASS:
scope HGB4 initializer HGBe4
globals
private constant integer ID = 039;HoGu039;
public real HP = 0.0
endglobals
private function Cons takes nothing returns boolean
return (GetSpellAbilityId() == ID)
endfunction
private function HoGuBe4 takes nothing returns nothing HolyGuardBe4
local unit u
loop
exitwhen UnitHasBuffBJ(u, MyScope_BC)
set u = GroupPickRandomUnit (GetUnitsInRectAll(GetPlayableMapRect()))
endloop
set HP = GetUnitState (u, UNIT_STATE_LIFE)
endfunction
private function HGBe4 takes nothing returns nothing
local trigger t = CreateTrigger()
local unit u
loop
exitwhen GetUnitAbilityLevel(u, ID) > 0
set u = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
if GetUnitAbilityLevel(u, ID) > 0 then
call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_SPELL_CAST)
endif
endloop
call TriggerAddAction (t, function HoGuBe4)
call TriggerAddCondition (t, Filter(function Cons))
endfunction
endscope
scope MyScope initializer HG
globals
public constant integer BC = 039;X001039;
endglobals
private function Cons takes nothing returns boolean
return (UnitHasBuffBJ(GetTriggerUnit(), BC))
endfunction
private function HolyGuard takes nothing returns nothing
local unit u
local real r = GetUnitState(u, UNIT_STATE_LIFE)
local real r2 = GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE)
local real HPT = HGB4_HP
loop
exitwhen GetUnitAbilityLevel(u, 039;HoGu039;) > 0
set u = GroupPickRandomUnit (GetUnitsInRectAll(GetPlayableMapRect()))
endloop
set r2 = HGB4_HP - r2
set r = r - r2
call SetUnitState (u, UNIT_STATE_LIFE, r)
call SetUnitState (GetTriggerUnit(), UNIT_STATE_LIFE, HGB4_HP)
endfunction
private function HG takes nothing returns nothing
local trigger t = CreateTrigger()
local unit u
loop
exitwhen UnitHasBuffBJ(u, BC)
set u = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
if UnitHasBuffBJ(u, BC) then
call TriggerRegisterUnitEvent (t,u, EVENT_UNIT_DAMAGED)
endif
endloop
call TriggerAddAction (t, function HolyGuard)
call TriggerAddCondition(t, Filter(function Cons))
endfunction
endscope
JASS:
scope MyScope initializer HG
globals
public constant integer BC = 039;X001039;
endglobals
private function Cons takes nothing returns boolean
return (UnitHasBuffBJ(GetTriggerUnit(), BC))
endfunction
private function HolyGuard takes nothing returns nothing
local unit u
local real r = GetUnitState(u, UNIT_STATE_LIFE)
local real r2 = GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE)
local real HPT = HGB4_HP
loop
exitwhen GetUnitAbilityLevel(u, 039;HoGu039;) > 0
set u = GroupPickRandomUnit (GetUnitsInRectAll(GetPlayableMapRect()))
endloop
set r2 = HGB4_HP - r2
set r = r - r2
call SetUnitState (u, UNIT_STATE_LIFE, r)
call SetUnitState (GetTriggerUnit(), UNIT_STATE_LIFE, HGB4_HP)
endfunction
private function HG takes nothing returns nothing
local trigger t = CreateTrigger()
local unit u
loop
exitwhen UnitHasBuffBJ(u, BC)
set u = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
if UnitHasBuffBJ(u, BC) then
call TriggerRegisterUnitEvent (t,u, EVENT_UNIT_DAMAGED)
endif
endloop
call TriggerAddAction (t, function HolyGuard)
call TriggerAddCondition(t, Filter(function Cons))
endfunction
endscope
The spell is actually based on Holy Light (I didn't found any good baseskill, because I play just DotA, not any melee maps) and gives the target a buff, which is based on anti-magicshield (magic immun!).