JASS:
function FilterIsEnemyAlive takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Caster)) and GetWidgetLife(GetFilterUnit())>0.405
endfunction
I think thats your problem. If that is in the custom functions library you have, then Caster is probably not refering to anything.
In these situations it is best to make a custom filter for your new library, so it does not have to rely on your other one.
So, basically make a new filter in the CAS library. Just copy and paste the one you have posted, make it private, and then you will need to make a global unit that is set to the casting in the create method.
JASS:
library CAS requires CSData,CSSafety
globals
private constant real Start = 30.00
private constant real Radius = 50
private constant real Scale = 0.6
private constant real Fly_height = 60.00
private constant attacktype A = ATTACK_TYPE_CHAOS
private constant damagetype D = DAMAGE_TYPE_UNIVERSAL
private unit Caster = null // The global unit
endglobals
private function FilterIsEnemyAlive takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Caster)) and GetWidgetLife(GetFilterUnit())>0.405
endfunction // New filter
//=======================================================================
private struct Data
unit u
unit d
real moved
real cd
real maxd
real dmg
real angle
group g1 = CreateGroup()
group g2 = CreateGroup()
timer t
static method create takes integer ut, unit u, real cx, real cy, real tx, real ty, real period, real moved, real maxd, real dmg returns Data
local Data d = Data.allocate()
set d.t = NewTimer()
set d.u = u
set d.cd = Start
set d.maxd = maxd
set d.angle = AngleXY(cx,cy,tx,ty)
set d.dmg = dmg
set d.d = CreateUnit(GetOwningPlayer(u),ut, PolarProjectionX (cx, Start, d.angle), PolarProjectionY (cy, Start, d.angle) , Rad2Deg(d.angle))
call SetUnitMoveSpeed(d.d, moved)
set d.moved = moved
set Caster = u // Setting global unit to caster
call SetUnitPathing(d.d,false)
call SetUnitScale(d.d,Scale,Scale,Scale)
call SetUnitFlyHeight(d.d,Fly_height,0.00)
call TimerStart(d.t,period,true,function Data.Execute)
call SetCSData(d.t,d)
return d
endmethod
static method Execute takes nothing returns nothing
local real x
local real y
local unit u
local Data d = GetCSData(GetExpiredTimer())
set d.moved = GetUnitMoveSpeed(d.d)
set d.cd = d.cd + d.moved
if d.cd >= d.maxd then
call d.destroy()
return
endif
if d.d == null then
call d.destroy()
return
endif
set x = GetUnitX(d.d)
set y = GetUnitY(d.d)
set x = SafeX(PolarProjectionX(x, d.moved, d.angle))
set y = SafeY(PolarProjectionY(y, d.moved, d.angle))
call SetUnitX(d.d, x)
call SetUnitY(d.d, y)
call GroupClear(d.g2)
call GroupEnumUnitsInRange(d.g2,x,y,Radius,Condition(function FilterIsEnemyAlive))
loop
set u = FirstOfGroup(d.g2)
exitwhen u == null
if not(IsUnitInGroup(u,d.g1)) then
call GroupAddUnit(d.g1,u)
call UnitDamageTarget(d.u,u,d.dmg,false,false,A,D,null)
call GroupRemoveUnit(d.g2,u)
endif
call GroupRemoveUnit(d.g2,u)
endloop
endmethod
private method onDestroy takes nothing returns nothing
call RemoveUnit(.d)
call GroupClear(.g1)
call DestroyGroup(.g1)
call GroupClear(.g2)
call DestroyGroup(.g2)
call ReleaseTimer(.t)
endmethod
endstruct
public function SA takes integer ut, unit u, real cx, real cy, real tx, real ty, real period, real moved, real maxd, real dmg returns nothing
call Data.create(ut,u,cx,cy,tx,ty,period,moved,maxd,dmg)
endfunction
endlibrary