JASS:
constant function CS_RectLimitOffSet takes nothing returns real
return 250.00
endfunction
function CS_MoveUnit takes unit u, real x, real y returns boolean
local rect r=bj_mapInitialPlayableArea
local real t=GetRectMinX(r)+CS_RectLimitOffSet()
local boolean b=true
if (x<t) then
set x=t
set b=false
else
set t=GetRectMaxX(r)-CS_RectLimitOffSet()
if (x>t) then
set b=false
set x=t
endif
endif
set t=GetRectMinY(r)+CS_RectLimitOffSet()
if (y<t) then
set y=t
set b=false
else
set t=GetRectMaxY(r)-CS_RectLimitOffSet()
if (y>t) then
set y=t
set b=false
endif
endif
if (b) then
call SetUnitX(u, x)
call SetUnitY(u, y)
endif
set r=null
return b
endfunction
function UnitMoveToAsProjectileGen takes unit m, real arc, real x2, real y2, unit target, real z2 returns nothing
local real x1=GetUnitX(m)
local real y1=GetUnitY(m)
local real acel=arc*1600
local real speed=GetUnitMoveSpeed(m)
local real z1=GetUnitFlyHeight(m)
local real d
local real d1
local real d2
local real t
local real vel
local real dif=0
local boolean tounit= (target!=null)
local boolean b=false
local boolean mode=false
if tounit then
set x2=GetUnitX(target)
set y2=GetUnitY(target)
set z2=GetUnitFlyHeight(target)+z2
endif
set mode=(z2>z1)
set d=SquareRoot(Pow(x2-x1,2)+Pow(y2-y1,2))
set d1=1000000
set d2=0
set t=d/speed
if t==0 then
set t=0.001
endif
set vel=(z2-z1+0.5*acel*t*t)/t
call SetUnitFacing( m, Atan2BJ(y2 - y1, x2 - x2) )
call IssuePointOrder( m, "move", x2,y2)
set t=0
loop
set d2=d1
if tounit then
if IsUnitDeadBJ(target) then
set tounit=false
else
set x2=GetUnitX(target)
set y2=GetUnitY(target)
endif
endif
set d1=SquareRoot(Pow(x2-GetUnitX(m),2)+Pow(y2-GetUnitY(m),2))
exitwhen b or d1==0
set b=(d1<=speed*(t-dif))
exitwhen (mode and b) or (GetUnitCurrentOrder(m) != OrderId("move"))
if tounit then
call IssuePointOrder( m, "move", x2,y2)
endif
set dif=t
if dif==0.001 then
set t=0.1
else
set t= (d-d1)/speed
endif
set t= 2*t-dif
call SetUnitFlyHeight( m, z1+(vel*t-0.5*acel*t*t), RAbsBJ( vel-acel*(t+dif)/2) )
set t=(t+dif)/2
call TriggerSleepAction(0)
endloop
if tounit then
set x2=GetUnitX(target)
set y2=GetUnitY(target)
endif
call SetUnitFlyHeight( m,z2,0)
call CS_MoveUnit(m,x2,y2)
endfunction
function UnitMoveToAsProjectile takes unit m, real arc, real x2, real y2, real z2 returns nothing
call UnitMoveToAsProjectileGen(m, arc,x2,y2,null,z2)
endfunction
function Trig_MoveAsProjectile_Actions takes nothing returns nothing
local unit stopper = GetTriggerUnit()
local location goalLoc = PolarProjectionBJ(GetUnitLoc(stopper), 500.00, 0)
local real XgoalLoc = GetLocationX(goalLoc)
local real YgoalLoc = GetLocationY(goalLoc)
local real FlyingHeight = GetUnitDefaultFlyHeight(stopper)
call BJDebugMsg("Variables Declared")
call UnitMoveToAsProjectile(stopper, 250.00, XgoalLoc, YgoalLoc, FlyingHeight)
call BJDebugMsg("debug completed")
endfunction
//===========================================================================
function InitTrig_MoveAsProjectile takes nothing returns nothing
set gg_trg_MoveAsProjectile = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_MoveAsProjectile, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( gg_trg_MoveAsProjectile, function Trig_MoveAsProjectile_Actions )
endfunction
Why?