scope blast initializer i
private struct kbDat
unit pushee
real degDirection
integer power
endstruct
globals
private constant integer BLASTID='A004'
private unit tempCaster
private timer time=CreateTimer()
private integer dbIndex=-1
private group grp=CreateGroup()
private kbDat array kbDB
endglobals
private function p takes nothing returns nothing
local integer index=0
local kbDat tempDat
local real x
local real y
loop
exitwhen index>dbIndex
set tempDat=kbDB[index]
set x=GetUnitX(tempDat.pushee)+tempDat.power*Cos(tempDat.degDirection*bj_DEGTORAD)
set y=GetUnitY(tempDat.pushee)+tempDat.power*Sin(tempDat.degDirection*bj_DEGTORAD)
if IsTerrainWalkable(x,y) then
call SetUnitX(tempDat.pushee,x)
call SetUnitY(tempDat.pushee,y)
else
set tempDat.power=1
endif
set tempDat.power=tempDat.power-1
if tempDat.power<1 then
call tempDat.destroy()
set kbDB[index]=kbDB[dbIndex]
set dbIndex=dbIndex-1
if dbIndex==-1 then
call PauseTimer(time)
endif
endif
set index=index+1
endloop
endfunction
private function f takes nothing returns boolean
local kbDat tempDat
if IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(tempCaster)) then
set tempDat=kbDat.create()
set tempDat.pushee=GetFilterUnit()
set tempDat.degDirection=bj_RADTODEG*Atan2(GetUnitY(GetFilterUnit())-GetUnitY(tempCaster),GetUnitX(GetFilterUnit())-GetUnitX(tempCaster))
set tempDat.power=20
set dbIndex=dbIndex+1
set kbDB[dbIndex]=tempDat
if dbIndex==0 then
call TimerStart(time,.03,true,function p)
endif
endif
return false
endfunction
private function c takes nothing returns boolean
if GetSpellAbilityId()==BLASTID then
set tempCaster=GetSpellAbilityUnit()
call GroupEnumUnitsInRange(grp,GetUnitX(GetSpellAbilityUnit()),GetUnitY(GetSpellAbilityUnit()),500,Filter(function f))
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function c))
endfunction
endscope