//////////////////////////////////////////////////////////////////////////////
// _ _ __ _ //
// | |_| || _\ /_\ //
// | _ |||_))/ _ \ //
// |_| |_||__//_/ \_\ //
// //
// Holy Deliverance Aura v 1.4 //
// by CakeMaster //
// //
//////////////////////////////////////////////////////////////////////////////
function HD_RadarCondition takes nothing returns boolean
return GetWidgetLife(GetFilterUnit()) > 0.405 and GetWidgetLife(GetFilterUnit()) != GetUnitState(GetFilterUnit(), UNIT_STATE_MAX_LIFE) and IsUnitAlly(GetFilterUnit(), udg_HD_Player[udg_A]) == true
endfunction
function HD_Setup takes nothing returns boolean
//On init
local integer i = -1
loop
set i = i + 1
exitwhen i == 15
call SetPlayerAbilityAvailable(Player(i), udg_Config_HD_SpellBook, false)
endloop
set udg_HD_Dummy = CreateUnit(Player(0), udg_Config_HD_DummyID, 0., 0., 0.)
call UnitAddAbility(udg_HD_Dummy, udg_Config_HD_SalvationDummy)
return false
endfunction
function HD_LearnedCache takes nothing returns boolean
local integer i = 0
local integer c = 0
local unit u = GetTriggerUnit()
//After a hero learns, cache his data
if GetLearnedSkill() == udg_Config_HD_Ability then
loop
set i = i + 1
exitwhen i > udg_HD_Index
if udg_HD_Caster[udg_A] == u then
set udg_HD_Level[udg_A] = udg_HD_Level[udg_A] + 1
else
set c = c + 1
endif
endloop
if c == udg_HD_Index then
set udg_HD_Index = (udg_HD_Index + 1)
set udg_HD_Caster[udg_HD_Index] = u
set udg_HD_Group[udg_HD_Index] = CreateGroup()
set udg_HD_HealCD[udg_HD_Index] = 0.
set udg_HD_HealCounter[udg_HD_Index] = 0
set udg_HD_Player[udg_HD_Index] = GetOwningPlayer(udg_HD_Caster[udg_HD_Index])
set udg_HD_Level[udg_HD_Index] = 1
//Adds the buffer aura
call UnitAddAbility(udg_HD_Caster[udg_HD_Index], udg_Config_HD_SpellBook)
if udg_HD_Index == 1 then
call EnableTrigger(gg_trg_Deliverance_Aura)
endif
endif
endif
set u = null
return false
endfunction
function HD_Detect takes nothing returns boolean
local integer a = 0
//Buff check for Salvation (invul + deflect)
//If a unit already has the buff, it does not prevent from further dummy casts
if GetUnitAbilityLevel(udg_target, udg_Config_HD_SalvationBuff) > 0 then
call DestroyEffect(AddSpecialEffect(udg_Config_HD_SalvationReverseFx, GetUnitX(udg_target), GetUnitY(udg_target)))
call SetWidgetLife(udg_target, (GetWidgetLife(udg_target) + udg_amount))
set udg_amount = 0.
endif
//Buff Application
loop
set a = a + 1
exitwhen a > udg_HD_Index
//Heal CD Reduction
if IsUnitInGroup(udg_target, udg_HD_Group[a]) == true or IsUnitInGroup(udg_source, udg_HD_Group[a]) == true then
set udg_HD_HealCD[a] = udg_HD_HealCD[a] - udg_Config_HD_HealCDRed[udg_HD_Level[udg_A]]
endif
endloop
return false
endfunction
function HD_OnCast takes nothing returns boolean
local group g
local real real1 = 0
local real x
local real y
local unit u = GetTriggerUnit()
local unit u2
if GetSpellAbilityId() == udg_Config_HD_Ability then
set udg_A = 0
loop
set udg_A = udg_A + 1
exitwhen udg_A > udg_HD_Index
if udg_HD_Caster[udg_A] == u then
set u2 = GetSpellTargetUnit()
set x = GetUnitX(u2)
set y = GetUnitY(u2)
set real1 = udg_Config_HD_HealBase[udg_HD_Level[udg_A]] + (I2R(GetHeroInt(u, true)) * udg_Config_HD_HealScale[udg_HD_Level[udg_A]])
//Salvation
if udg_HD_HealCounter[udg_A] < udg_Config_HD_SalvationCounter[udg_HD_Level[udg_A]] then
set udg_HD_HealCounter[udg_A] = udg_HD_HealCounter[udg_A] + 1
call DestroyEffect(AddSpecialEffect(udg_Config_HD_HealFx, x, y))
else
set udg_HD_HealCounter[udg_A] = 0
set real1 = real1 * (1. + udg_Config_HD_SalvationBonus[udg_HD_Level[udg_A]])
call SetUnitOwner(udg_HD_Dummy, GetOwningPlayer(udg_HD_Caster[udg_A]), false)
call IssueTargetOrder(udg_HD_Dummy, "bloodlust", u2)
endif
//Heal
call SetWidgetLife(u2, (GetWidgetLife(u2) + real1))
set real1 = real1 * udg_Config_HD_HealSplash[udg_HD_Level[udg_A]]
set g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, udg_Config_HD_HealArea[udg_HD_Level[udg_A]], Condition(function HD_RadarCondition))
//Area Heal
loop
set u2 = FirstOfGroup(g)
exitwhen u2 == null
call SetWidgetLife(u2, (GetWidgetLife(u2) + real1))
call GroupRemoveUnit(g, u2)
endloop
call DestroyGroup(g)
endif
endloop
endif
set g = null
set u = null
return false
endfunction
function Holy_Deliverance takes nothing returns boolean
local real x
local real y
local group g
local unit u
local real real1
local real real2
local real real3 = 0.
local unit u2
set udg_A = 0
loop
set udg_A = udg_A + 1
exitwhen udg_A > udg_HD_Index
if GetWidgetLife(udg_HD_Caster[udg_A]) > 0.405 then
set x = GetUnitX(udg_HD_Caster[udg_A])
set y = GetUnitY(udg_HD_Caster[udg_A])
//Reduce Cooldown
if udg_HD_HealCD[udg_A] > 0. then
set udg_HD_HealCD[udg_A] = udg_HD_HealCD[udg_A] - udg_Config_HD_Rate
else
set udg_HD_HealCD[udg_A] = 0.
endif
//Group Enumeration
call GroupClear(udg_HD_Group[udg_A])
call GroupEnumUnitsInRange(udg_HD_Group[udg_A], x, y, udg_Config_HD_Range[udg_HD_Level[udg_A]], Condition(function HD_RadarCondition))
set g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, udg_Config_HD_Range[udg_HD_Level[udg_A]], Condition(function HD_RadarCondition))
set u2 = null
set real1 = 0. //Lowest Percentage Checker
set real2 = 100. //Record Tracker
//Check for units to heal
loop
set u = FirstOfGroup(g)
exitwhen u == null
//====================
//Regen
set real3 = GetWidgetLife(u)
set x = GetUnitState(u, UNIT_STATE_MAX_LIFE)
set y = ((((x - real3) / x) * 100.) * udg_Config_HD_Regeneration[udg_HD_Level[udg_A]]) + udg_Config_HD_RegenBase[udg_HD_Level[udg_A]]
call SetWidgetLife(u, (GetWidgetLife(u) + y))
//====================
//Lowest health% unit
set real1 = (real3 / x) * 100.0
//Hero priority
if IsUnitType(u, UNIT_TYPE_HERO) then
//Makes it appear that the hero has 5% less
set real1 = real1 - 5.
endif
if real1 < real2 then
set real2 = real1
set real1 = real2
set u2 = u
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
//Radar Checks
if u2 == null then
call GroupClear(udg_HD_Group[udg_A])
//Group is only used for CD Reduction
else
if udg_HD_HealCD[udg_A] == 0. then
set udg_HD_HealCD[udg_A] = udg_Config_HD_HealCD[udg_HD_Level[udg_A]]
set x = GetUnitX(u2)
set y = GetUnitY(u2)
set real1 = udg_Config_HD_HealBase[udg_HD_Level[udg_A]] + (I2R(GetHeroInt(udg_HD_Caster[udg_A], true)) * udg_Config_HD_HealScale[udg_HD_Level[udg_A]])
//Salvation
if udg_HD_HealCounter[udg_A] < udg_Config_HD_SalvationCounter[udg_HD_Level[udg_A]] then
set udg_HD_HealCounter[udg_A] = udg_HD_HealCounter[udg_A] + 1
call DestroyEffect(AddSpecialEffect(udg_Config_HD_HealFx, x, y))
else
set udg_HD_HealCounter[udg_A] = 0
set real1 = real1 * (1. + udg_Config_HD_SalvationBonus[udg_HD_Level[udg_A]])
call SetUnitOwner(udg_HD_Dummy, GetOwningPlayer(udg_HD_Caster[udg_A]), false)
call IssueTargetOrder(udg_HD_Dummy, "bloodlust", u2)
endif
//Heal
call SetWidgetLife(u2, (GetWidgetLife(u2) + real1))
set real1 = real1 * udg_Config_HD_HealSplash[udg_HD_Level[udg_A]]
set g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, udg_Config_HD_HealArea[udg_HD_Level[udg_A]], Condition(function HD_RadarCondition))
//Area Heal
loop
set u = FirstOfGroup(g)
exitwhen u == null
call SetWidgetLife(u, (GetWidgetLife(u) + real1))
call GroupRemoveUnit(g, u)
endloop
endif
endif
call DestroyGroup(g)
else
call GroupClear(udg_HD_Group[udg_A])
endif
endloop
set g = null
return false
endfunction
//===========================================================================
function InitTrig_Deliverance_Aura takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t, Condition(function HD_LearnedCache))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function HD_OnCast))
call TimerStart(CreateTimer(),0.0,false,function HD_Setup)
set t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_damageEventTrigger", EQUAL, 1.)
call TriggerAddCondition(t, Condition(function HD_Detect))
set t = null
set gg_trg_Deliverance_Aura = CreateTrigger()
call DisableTrigger(gg_trg_Deliverance_Aura)
call TriggerAddCondition(gg_trg_Deliverance_Aura, Condition(function Holy_Deliverance))
endfunction