JASS:
library APEX
//The Struct.
struct APEX
private static unit proj
private static real x1
private static real y1
private static real x2
private static real y2
private static real z1
private static real z2
private static real arcspeed
private static real arc
private static real face
private static effect fx
private static real A // from emjlr's Wild Axes spell
private static real outx
private static real outy
private static real s2
private static timer T
static method move takes nothing returns nothing
local real nx
local real ny
//Calculations from Vexorian's Projectile System.
// calculates the vertical arc.
local real d = .arcspeed*0.035
local real od = SquareRoot(Pow(GetUnitX(.proj)-.x2,2) + Pow(GetUnitY(.proj)-.y2,2))
local real time = od / .arcspeed
local real zspeed = (.z2-GetUnitFlyHeight(.proj)+0.5*.arc*time*time)/time
//Calculataions from emjlr's Wild Axes spell.
// calculates the horizontal arc.
local real b = 1.-.A
//VERTICAL ARC, from Vexorian
call SetUnitFlyHeight(.proj,GetUnitFlyHeight(.proj)+zspeed*.035,0)
call SetUnitAnimationByIndex(.proj,R2I(Atan2(zspeed,.arcspeed)* bj_RADTODEG)+90) //Thanks infrane!
//Corrective Facing >by me, 13lade619<
set nx = .x1*.A*.A+.outx*2*.A*b+.x2*b*b
set ny = .y1*.A*.A+.outy*2*.A*b+.y2*b*b
call SetUnitFacingTimed(.proj, bj_RADTODEG*Atan2(ny - GetUnitY(.proj), nx - GetUnitX(.proj)), 0)
//HORIZONTAL ARC, from emjlr.
call SetUnitX(.proj,nx)
call SetUnitY(.proj,ny)
set .A = .A-.s2
if (.A <= 0) then
call DestroyEffect(.fx)
call SetUnitExploded(.proj, true)
call KillUnit(.proj)
set .proj = null
call PauseTimer(.T)
call DestroyTimer(.T)
call .destroy() // <<<<======= undeclared variable 'this' ???
endif
endmethod
//===================================================================================
static method create takes unit caster, real x1, real y1, real z1, real x2, real y2, real z2, real varc, real width, real angle, real speed, string model returns thistype
local thistype this = thistype.allocate()
local code callback = function thistype.move
set.T = CreateTimer()
set .x1 = x1
set .y1 = y1
set .x2 = x2
set .y2 = y2
set .z1 = z1
set .z2 = z2
set .face = Atan2(.y2-.y1,.x2-.x1)*bj_RADTODEG
// VERTICALS / Vex
set .arcspeed = 1000 // affects the rate where the arc changes, lower generates bigger arc. calc by Vexorian.
set .arc = (varc) * 8000 // vertical arc. change only within the (). calculation by Vexorian.
set .A = 1 // variable from emjlr.. dont change.
// HORIZONTALS / emjlr3
set .outx = .x1+ width *Cos(Atan2(.y2-.y1,.x2-.x1)+(angle))
set .outy = .y1+ width *Sin(Atan2(.y2-.y1,.x2-.x1)+(angle))
// Affects the REAL SPEED of the projectile, lower is slower. always<1
set .s2 = speed
//Starting movement, move to the PMove Function.
set .proj = CreateUnit(GetOwningPlayer(caster),'e001',.x1,.y1,.face)
set .fx = AddSpecialEffectTarget(model,.proj,"origin")
call SetUnitFlyHeight(.proj,.z1,0)
call TimerStart(.T, .03125, true, callback)
return this
endmethod
//===================================================================================
endstruct
endlibrary
JassHelper is having "undeclared variable 'this' "
on the .ondestroy line on the move method... i dont know why.
please help. thanks.