OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Garcia on 05 Jul 2005, 03:11:29

Title: Find the angle of CoC arty
Post 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.
Title: Re:Find the angle of CoC arty
Post by: UNN on 05 Jul 2005, 11:06:34
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:

Code: [Select]
This AddEventHandler ["Fired",{_Shell=NearestObject [_This Select 0,_This Select 4] ; [_This Select 0,_Shell] Exec {Script.sqs}}]"
Script.sqs:
Code: [Select]
_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:
Code: [Select]
_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)]
Title: Re:Find the angle of CoC arty
Post by: Garcia on 05 Jul 2005, 22:44:10
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 ;)
Title: Re:Find the angle of CoC arty
Post by: UNN on 06 Jul 2005, 01:32:31
Yeah,

It should have been ATan2, and I got the parameters the wrong way round:

Code: [Select]
Hint Format ["Pitch %1",(_Vel Select 2) ATan2 Sqrt(((_Vel Select 0)^2) + ((_Vel Select 1)^2))]
Doh
Title: Re:Find the angle of CoC arty
Post by: Garcia on 06 Jul 2005, 01:43:35
heh, well, shit happens ;) I guess I can press that solved button now ;D