scope buffsToSector initializer i //we define a scope and a function to run on initialization
globals
private group grp=CreateGroup()
private real angBetween
private real tempFacing
private unit tempOwner
private constant integer ABILCODE='A000' //Set this to the proper code!
private constant real ENUMRANGE=500 //Set your max range here, in game units
private constant real SECTORSIZE=bj_PI/2 //Set the size of the sector you want to apply the effect to, in radians
endglobals
private function f takes nothing returns boolean
local real theta=Acos(Cos(tempFacing-angBetween))
if IsUnitEnemy(GetFilterUnit(),tempOwner) and theta<.5*SECTORSIZE then //if the enumerated unit is in the proper sector:
//Apply some buffs!
endif
return false
endfunction
private function c takes nothing returns boolean
local unit tU
local unit targ
if GetSpellAbilityId()==ABILCODE then //if casted abil is the right one:
set tU=GetTriggerUnit()
set targ=GetSpellTargetUnit()
set tempOwner=GetOwningPlayer(tU)
set tempFacing=GetUnitFacing(tU)*bj_DEGTORAD
set angBetween=Atan2(GetUnitY(targ)-GetUnitY(tU),GetUnitX(targ)-GetUnitX(tU))
call GroupEnumUnitsInRange(grp,GetUnitX(tU),GetUnitY(tU),ENUMRANGE,Filter(function f)) //Enumerate all the units within the proper range of the caster (and see function f)
set tU=null
set targ=null
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger() //create a trigger
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT) //register ability effect
call TriggerAddCondition(t,Condition(function c)) //define a conndition/action function
set t=null
endfunction
endscope