constant function MassHeal_AbilityID takes nothing returns integer
// The rawcode of the ability being casted, probably just a dummy ability
return 'Ahea'
endfunction
constant function MassHeal_CasterFX takes nothing returns string
// The effect created on a casting unit
// NOTE: Effect strings MUST double slash:
// "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl" = GOOD
// "Abilities\Spells\Human\Heal\HealTarget.mdl" = EDITOR WILL CRASH ON SAVE!
return "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
endfunction
constant function MassHeal_EffectFX takes nothing returns string
// The effect created on a healed unit
// NOTE: Effect strings MUST double slash:
// "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl" = GOOD
// "Abilities\Spells\Human\Heal\HealTarget.mdl" = EDITOR WILL CRASH ON SAVE!
return "Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl"
endfunction
constant function MassHeal_Caster_Bonus takes nothing returns real
// The fraction of healing that the caster gets 0-1
// More than 1 means that the caster gets bonus heal
// Less than 1 means that the caster gets less healing than everyone else
return 2.0
endfunction
constant function MassHeal_HealAmount takes nothing returns integer
// The beginning amount healed irrelevant of intelligence
return 100
endfunction
constant function MassHeal_HealAmount_Increment takes nothing returns integer
// The amount healed gained per level
return 100
endfunction
constant function MassHeal_HealAmount_Intelligence takes nothing returns integer
// The beginning amount healed per point of intelligence
return 3
endfunction
constant function MassHeal_HealAmount_Intelligence_Increment takes nothing returns integer
// The amount healed gained per level
return 1
endfunction
constant function MassHeal_Radius takes nothing returns integer
// The beginning radius of effect
return 500
endfunction
constant function MassHeal_Radius_Increment takes nothing returns integer
// The radius of effect gained per level
return 0
endfunction
function Trig_Mass_Heal_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == MassHeal_AbilityID())
endfunction
function Trig_Mass_Heal_Actions takes nothing returns nothing
// Get the caster
local unit caster = GetSpellAbilityUnit()
// Get the caster's intellegence
local integer intelligence = GetHeroInt(caster, true)
// The Ability being casted
local integer abil_id = GetSpellAbilityId()
// The Level of THAT ability
local integer abil_lvl = GetUnitAbilityLevel(caster, abil_id) - 1
// The player that owns the caster (for filtering friendly units)
local player player_caster = GetOwningPlayer(caster)
// Group var, contain ALL units possibly effected
local group unitgroup = CreateGroup()
// The current unit selected from the group
local unit iterator
// Caster's position in world co-ordinates
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
// The AoE of the spell
local real radius = MassHeal_Radius() + (MassHeal_Radius_Increment() * abil_lvl)
// Current HP of the iterator
local real life
// Maximum HP of the iterator
local real max_life
// Special Effect Variable
local effect sfx
// The maximum amount healed (broken up onto 3 lines for readability)
local real heal_amount = MassHeal_HealAmount_Intelligence()
set heal_amount = heal_amount + (MassHeal_HealAmount_Intelligence_Increment() * abil_lvl)
set heal_amount = heal_amount * intelligence
set heal_amount = heal_amount + MassHeal_HealAmount()
set heal_amount = heal_amount + (MassHeal_HealAmount_Increment() * abil_lvl)
// The actual healing part (caster only)
set life = GetUnitState(caster, UNIT_STATE_LIFE)
set max_life = GetUnitState(caster, UNIT_STATE_MAX_LIFE)
set life = life + (heal_amount * MassHeal_Caster_Bonus())
call SetUnitState(caster, UNIT_STATE_LIFE, life)
// Create SFX where the target is
set sfx = AddSpecialEffectTarget(MassHeal_CasterFX(), caster, "origin")
call DestroyEffect(sfx)
set sfx = null
call GroupEnumUnitsInRange(unitgroup, x,y, radius, null)
loop
set iterator = FirstOfGroup(unitgroup)
exitwhen (iterator == null)
if (IsUnitAlly(iterator, player_caster) and iterator != caster) then
// The actual healing part
set life = GetUnitState(iterator, UNIT_STATE_LIFE)
set max_life = GetUnitState(iterator, UNIT_STATE_MAX_LIFE)
if (life > 0 and life < max_life) then
set life = life + heal_amount
call SetUnitState(iterator, UNIT_STATE_LIFE, life)
// Create SFX where the target is
set sfx = AddSpecialEffectTarget(MassHeal_EffectFX(), iterator, "origin")
call DestroyEffect(sfx)
set sfx = null
endif
endif
call GroupRemoveUnit(unitgroup, iterator)
set iterator = null
endloop
// Var cleanup
call DestroyGroup(unitgroup)
set unitgroup = null
set player_caster = null
set caster = null
endfunction
//===========================================================================
function InitTrig_Mass_Heal takes nothing returns nothing
set gg_trg_Mass_Heal = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Mass_Heal, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Mass_Heal, Condition(function Trig_Mass_Heal_Conditions))
call TriggerAddAction(gg_trg_Mass_Heal, function Trig_Mass_Heal_Actions)
endfunction