Compile Errors

Togrias

New Member
Reaction score
0
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
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Well, make sure you have the "timerdelay" function somewhere in your map header. Preferably above function "ProjectileMotion".

And Kattana's Handle Variables is also a must, having seen them being used by your functions.
 

Togrias

New Member
Reaction score
0
Too add on, nothing uses these functions yet and I haven't gotten the chance to test them. From my own workings these functions *should* generate, as you may have guessed, a projectile motion for unit p. More importantly WorldEdit refuses to compile these functions. I'm new to jass and haven't spotted any syntax mistake in my script.
 

Togrias

New Member
Reaction score
0
ya I have this right on top of my script. Whoa what a speedy reply thanks!
JASS:

constant function timerdelay takes nothing returns real
    return 0.035
    endfunction
 

Togrias

New Member
Reaction score
0
Yep I have all those functions above them. It's the Handle system by Kattana.

I have also removed the following as it's been redundant.
JASS:
    local real Xn = GetLocationX(Loc)
    local real Yn = GetLocationY(Loc)


Given the nature of JassCraft I don't think its syntax checker would miss anything of the sort. Every time I make one of those silly mistakes it would surely prompt me way before WorldEdit would... I ran the entire war3map.j through JassCraft's syntax checker.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
"local real h = Zf + (v*( (Zi-Zf)- ((4*h*(t-(t*t))) /(Df+Di))))"

Variable "h" is in use before it's declared.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top