its supposed to make a parabola.. starting with height 50, and ending in 0 with max height of 400.

The problem is when hills/cliffs are involved.. it quite messes up.

Is there any problem with the formula?

JASS:

```
scope Grenade
globals
private constant integer ABCD = 'A072'
private constant string FX = "Grenade.mdx"
private constant real MAX_HEIGHT = 400
private constant real MAX_RANGE = 1200
private constant real SPEED = 700*T32_PERIOD
endglobals
function GetParabolaZ2 takes real x, real d, real h, real b returns real
local real r=b-h
local real p
local real q
set q=2*r*(-1-SquareRoot(1-b/r))/d
set p=.25*q*q/r
return p*x*x+q*x+b
endfunction
private function GetSpeed takes real range returns real
return (range/MAX_RANGE)*SPEED*2
endfunction
private struct Data
xefx fx
unit caster
real x
real y
real distCur
real distMax
real heightBase
real speed
real cos
real sin
integer bounce
private method Destroy takes nothing returns nothing
call .stopPeriodic()
call .fx.hiddenDestroy()
set .caster = null
call .deallocate()
endmethod
private method Explode takes nothing returns nothing
call DestroyEffect(AddSpecialEffect("PlasmaGrenade.mdx",.fx.x,.fx.y))
call .Destroy()
endmethod
private method periodic takes nothing returns nothing
local real i
if .distCur+.speed > .distMax then
set i = .distMax-.distCur
else
set i = .speed
endif
set .distCur = .distCur+i
set .x = .x+i*.cos
set .y = .y+i*.sin
set .fx.x = .x
set .fx.y = .y
set .fx.z = .heightBase+GetParabolaZ2(.distCur,.distMax,MAX_HEIGHT,50)+GetHeight(.x,.y)
//if R2I(.fx.z) == 0 then
if .distMax == .distCur then
call BJDebugMsg(I2S(R2I(.fx.z)))
call .Explode()
endif
endmethod
implement T32x
private static method onCast takes nothing returns boolean
local thistype this = thistype.allocate()
local real dx
local real dy
local real angle
set .caster = GetTriggerUnit()
set .x = GetUnitX(.caster)
set .y = GetUnitY(.caster)
set .bounce = 0
set dx = GetSpellTargetX()-.x
set dy = GetSpellTargetY()-.y
set angle = Atan2(dy,dx)
set .sin = Sin(angle)
set .cos = Cos(angle)
set .distMax = MinMax(SquareRoot(dx*dx+dy*dy),400,MAX_RANGE)
set .distCur = 0
set .heightBase = GetHeight(.x,.y)
set .speed = GetSpeed(.distMax)
set .fx = xefx.create(.x,.y,angle)
set .fx.fxpath = FX
call .startPeriodic()
return false
endmethod
private static method onInit takes nothing returns nothing
call GT_AddStartsEffectAction(function thistype.onCast,ABCD)
endmethod
endstruct
endscope
```