wraithseeker
Tired.
- Reaction score
- 122
What's wrong with my spell
This code isn't pushing enemys back..
Actions , Check , Create , Conditions work fine but the loop just never works.
JASS:
scope Warstomp initializer Init
globals
private constant integer SPELL = 039;AOws039;
private boolexpr b
endglobals
struct data
real x
real y
group g
unit caster
integer i
timer t
real duration
static method create takes nothing returns data
local data d = data.allocate()
set d.g = CreateGroup()
set d.caster = GetTriggerUnit()
set d.x = GetUnitX(d.caster)
set d.y = GetUnitY(d.caster)
set d.i = GetUnitAbilityLevel(d.caster,SPELL)
call GroupEnumUnitsInRange(d.g,d.x,d.y,100+50*d.i,b)
call BJDebugMsg("Creating Struct.....")
return d
endmethod
method OnDestroy takes nothing returns nothing
call ReleaseTimer(.t)
call DestroyGroup(.g)
set .g = null
endmethod
endstruct
private function Conditions takes nothing returns boolean
call BJDebugMsg("Conditions Worked!")
return GetSpellAbilityId() == SPELL
endfunction
private function Check takes nothing returns boolean
call BJDebugMsg("Checking work")
return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)
endfunction
private function Loop takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real ux
local real uy
local real a
local unit f
call BJDebugMsg("Time To Loop!")
set d.duration = d.i + 0.05
if d.duration < 1+0.5*d.i then
loop
call BJDebugMsg("looping")
set f = FirstOfGroup(d.g)
exitwhen f == null
set ux = GetUnitY(f)
set uy = GetUnitY(f)
set a = Atan2(uy-d.y,ux-d.x)
call SetUnitPosition(f,ux + 40*Cos(a),uy+40*Sin(a))
call GroupRemoveUnit(d.g,f)
endloop
else
call d.destroy()
endif
endfunction
private function Actions takes nothing returns nothing
local data d = data.create()
call SetTimerData(d.t,integer(d))
call TimerStart(d.t,0.05,true,function Loop)
call BJDebugMsg("actions worked")
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
set b = Condition(function Check)
endfunction
endscope
This code isn't pushing enemys back..
Actions , Check , Create , Conditions work fine but the loop just never works.