function GroupCast_Ability takes nothing returns integer
return 'A000'
endfunction
function GroupCast_IsPriest takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == 'hmpr'
endfunction
function GroupCast_Range takes nothing returns real
return 500.00
endfunction
function GroupCast_Count takes nothing returns integer
return 3
endfunction
function GroupCast_SpellId takes nothing returns integer
return OrderId("channel")
endfunction
function GroupCast_Filter takes nothing returns boolean
if GetWidgetLife(GetFilterUnit()) > 0.405 and GroupCast_IsPriest() and GetOwningPlayer(udg_u) == GetOwningPlayer(GetFilterUnit()) and IsUnitSelected(GetFilterUnit(), GetOwningPlayer(udg_u)) then
set udg_i = udg_i + 1
return true
endif
return false
endfunction
function GroupCast_LoopActions takes nothing returns nothing
set udg_u = GetEnumUnit()
if GetUnitCurrentOrder(udg_u) != GroupCast_SpellId() then
set udg_i = 0
call GroupEnumUnitsInRange(udg_g, GetUnitX(udg_u), GetUnitY(udg_u), GroupCast_Range(), Condition(function GroupCast_Filter))
if udg_i == GroupCast_Count() then
call UnitAddAbility (udg_u, GroupCast_Ability())
else
call UnitRemoveAbility(udg_u, GroupCast_Ability())
endif
endif
endfunction
function GroupCast_Check takes nothing returns nothing
call ForGroup(udg_GroupCast_Check, function GroupCast_LoopActions)
endfunction
function GoupCast_Select takes nothing returns nothing
call GroupAddUnit(udg_GroupCast_Check, GetTriggerUnit())
call EnableTrigger(gg_trg_GroupCast)
endfunction
function GroupCast_Deselect takes nothing returns nothing
call GroupRemoveUnit(udg_GroupCast_Check, GetTriggerUnit())
if FirstOfGroup(udg_GroupCast_Check) == null then
call DisableTrigger(gg_trg_GroupCast)
endif
endfunction
function InitTrig_GroupCast takes nothing returns nothing
local trigger select = CreateTrigger()
local trigger deselect = CreateTrigger()
set gg_trg_GroupCast = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_GroupCast, 0.1, true)
call TriggerAddAction(gg_trg_GroupCast, function GroupCast_Check)
call TriggerAddAction( select, function GoupCast_Select)
call TriggerAddAction(deselect, function GroupCast_Deselect)
set udg_i = 0
loop
call TriggerRegisterPlayerUnitEvent( select, Player(udg_i), EVENT_PLAYER_UNIT_SELECTED, Condition(function GroupCast_IsPriest))
call TriggerRegisterPlayerUnitEvent(deselect, Player(udg_i), EVENT_PLAYER_UNIT_DESELECTED, Condition(function GroupCast_IsPriest))
call TriggerRegisterPlayerUnitEvent(deselect, Player(udg_i), EVENT_PLAYER_UNIT_DEATH, Condition(function GroupCast_IsPriest))
set udg_i = udg_i + 1
exitwhen udg_i >= bj_MAX_PLAYER_SLOTS
endloop
endfunction