OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Garcia on 05 Jul 2005, 03:11:29
-
Errrm, is it possible to find the angle of the CoC mortars just after they've fired. The angle being the angle of the barrel, not the direction of the cannon.
-
There is probably a function with CoC's UA to return that? But you can always try this.
Add this the the lead Mortars init:
This AddEventHandler ["Fired",{_Shell=NearestObject [_This Select 0,_This Select 4] ; [_This Select 0,_Shell] Exec {Script.sqs}}]"
Script.sqs:
_Vehicle=_This Select 0
_Shell=_This Select 1
Hint Format ["Shell %1",Velocity _Shell]
Sorry I can't remember the Trigonemtry off hand, thats required to calculate the shells angle :( And if I did, it would be over the top. Perhaps someone else could add an efficent way of getting the shells pitch?
Edit:
Ok, I think it's this?
Script.sqs:
_Vehicle=_This Select 0
_Shell=_This Select 1
_Vel=Velocity _Shell
Hint Format ["Pitch %1",Sqrt(((_Vel Select 0)^2) + ((_Vel Select 1)^2)) Atan (_Vel Select 2)]
-
hmm, didn't work...first I got an error about the Atan, so I tried changing it to * atan, but then I got a very high pitch, tried changing it to /,- and +, but didn't get a pitch that seemed ok...and besides, OFP used to long to find it anyway :-\
Anyway, your script gave me and idea, which actually works perfect for what I need :-*
So, thank you ;)
-
Yeah,
It should have been ATan2, and I got the parameters the wrong way round:
Hint Format ["Pitch %1",(_Vel Select 2) ATan2 Sqrt(((_Vel Select 0)^2) + ((_Vel Select 1)^2))]
Doh
-
heh, well, shit happens ;) I guess I can press that solved button now ;D