- Joined
- Mar 10, 2009
- Messages
- 5,016
I really dont know what to call this and IDK how to explain well but let me just draw and give a code sample...
I want a missile from up above to target the ground like the drawing below, it's like an aircraft shoots a missile to a building...
Below is the code/formula I use, my test shows that it's accurate, I wanna know if the calculations are correct or is there any snippet available somewhere?...
If it's correct, how to call it?...
I want a missile from up above to target the ground like the drawing below, it's like an aircraft shoots a missile to a building...
Below is the code/formula I use, my test shows that it's accurate, I wanna know if the calculations are correct or is there any snippet available somewhere?...
If it's correct, how to call it?...
JASS:
function GetDown takes real h, real d, real s returns real
return h-((s/d)*h)
endfunction
struct TestH
real d //distance
real h //height
real s //speed
implement CTLExpire
if .d > 0 then
set .d = .d - .s
set .h = GetDown(.h, .d, .s)
call BJDebugMsg("distance=="+R2S(.d))
call BJDebugMsg("height=="+R2S(.h))
else
call .destroy()
endif
implement CTLEnd
static method run takes nothing returns nothing
local thistype this = create()
set .d = GetRandomReal(600, 1000)
set .h = GetRandomReal(200, 500)
set .s = GetRandomReal(5, 15)
call BJDebugMsg("DISTANCE==============="+R2S(.d))
call BJDebugMsg("HEIGHT==============="+R2S(.h))
call BJDebugMsg("SPEED==============="+R2S(.s))
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function TestH.run)
endmethod
endstruct