Hi I need help with the following jass script I wrote myself. I wrote this in JassCraft and the syntax checker didn't detect any mistake in my whole map but WorldEdit kept saying I had compile errors. Any ideas on how to fix it? The code is as follows:
JASS:
function ProjectileMotion takes unit p, real speed, real H, real Xi, real Yi, real Zi, real Xf, real Yf, real Zf returns boolean
local location Loc = GetUnitLoc(p)
local location LocF = Location(Xf,Yf)
local location LocI = Location(Xi,Yi)
local location LocN
local real Xn = GetLocationX(Loc)
local real Yn = GetLocationY(Loc)
local real v = ( speed * timerdelay() )
local real angle = AngleBetweenPoints(Loc,LocF)
local boolean reached = false
local real Df = DistanceBetweenPoints(Loc,LocF)
local real Di = DistanceBetweenPoints(Loc,LocI)
local real t = Df / v
local real h = Zf + (v*( (Zi-Zf)- ((4*h*(t-(t*t))) /(Df+Di))))
if Df <= v then
set LocN = LocF
set reached = true
call SetUnitFlyHeight(p,Zf,0)
else
set LocN = PolarProjectionBJ(Loc,v,angle)
call SetUnitFlyHeight(p,h,0)
endif
call SetUnitPositionLoc(p,LocN)
call SetUnitFacing(p,angle)
call RemoveLocation(Loc)
call RemoveLocation(LocF)
call RemoveLocation(LocN)
call RemoveLocation(LocI)
return reached
endfunction
function ProjectileMoment takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit p = GetHandleUnit(t,"ProjectileUnit")
local real speed = GetHandleReal(t,"speed")
local real H = GetHandleReal(t,"H")
local real Xi = GetHandleReal(t,"Xi")
local real Yi = GetHandleReal(t,"Yi")
local real Zi = GetHandleReal(t,"Zi")
local real Xf = GetHandleReal(t,"Xf")
local real Yf = GetHandleReal(t,"Yf")
local real Zf = GetHandleReal(t,"Zf")
local boolean reached = ProjectileMotion(p,speed,H,Xi,Yi,Zi,Xf,Yf,Zf)
if reached == true then
call ExecuteFunc(GetHandleString(t,"OnResolve"))
endif
endfunction
function LaunchProjectileNoTrack takes unit p, real speed, real arc, location LocI, real Zi, location LocF, real Zf, string OnResolve returns nothing
local real H = arc* DistanceBetweenPoints(LocF,LocI)
local real Xf = GetLocationX(LocF)
local real Yf = GetLocationY(LocF)
local real Xi = GetLocationX(LocI)
local real Yi = GetLocationY(LocI)
local timer t = CreateTimer()
call SetHandleString(p,"OnResolve",OnResolve)
call SetHandleString(t, "Type", "ProjectileTimer")
call SetHandleHandle(t,"ProjectileUnit",p)
call SetHandleReal(t,"speed",speed)
call SetHandleReal(t,"H",H)
call SetHandleReal(t,"Xi",Xi)
call SetHandleReal(t,"Yi",Yi)
call SetHandleReal(t,"Zi",Zi)
call SetHandleReal(t,"Xf",Xf)
call SetHandleReal(t,"Yf",Yf)
call SetHandleReal(t,"Zf",Zf)
call TimerStart( t, timerdelay(), false, function ProjectileMoment )
call RemoveLocation(LocI)
call RemoveLocation(LocF)
endfunction