Hello, I haven't coded JASS in about a year and I recently read a VJASS tutorial, but the spell I made (not based on the tutorial) doesn't work. I am not looking to optimize my spell yet, I am just trying to find out what the problem is, its supposed to shoot out a missile toward a point. The problem is that it only creates the dummy unit though and doesn't move :
JASS:
scope Projectile initializer Init
globals
private constant integer SPELL_ID = 039;A000039;
private constant integer SPEED = 900
private constant real RANGE = 600.00
real CRANGE = 0.00
projectiledata array Projectile_Ar
timer Projectile_timer = CreateTimer()
endglobals
constant function Projectile_Dummy takes nothing returns integer
return 039;h001039;
endfunction
struct projectiledata
unit d
location l
real x
real y
endstruct
function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
function Timer takes nothing returns nothing
local projectiledata dat
local real angle
local real nx
local real ny
if (CRANGE == 600.00) then
call dat.destroy()
call RemoveUnit(dat.d)
call PauseTimer(Projectile_timer)
else
set angle = bj_RADTODEG * Atan2(GetLocationY(dat.l) - GetUnitY(dat.d), GetLocationX(dat.l) - GetUnitX(dat.d))
set nx = GetUnitX(dat.d) + 10.00 * Cos(angle * bj_DEGTORAD)
set ny = GetUnitY(dat.d) + 10.00 * Sin(angle * bj_DEGTORAD)
call SetUnitPosition(dat.d, nx, ny )
set CRANGE = CRANGE + 10.00
endif
endfunction
function Actions takes nothing returns nothing
local unit b = GetTriggerUnit()
local unit d = CreateUnit(GetOwningPlayer(b), Projectile_Dummy(), GetUnitX(b), GetUnitY(b), 90.00)
local location l = GetSpellTargetLoc()
local projectiledata dat = projectiledata.create()
set dat.x = 0.00
set dat.y = 0.00
set dat.d = d
set dat.l = l
call TimerStart(Projectile_timer, 0.01, true, function Timer)
endfunction
private function Init takes nothing returns nothing
local trigger ProjectileTrg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(ProjectileTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( ProjectileTrg, Condition(function Conditions) )
call TriggerAddAction( ProjectileTrg, function Actions )
endfunction
endscope