OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Mandoble on 03 Nov 2007, 13:24:49

Title: Mando Angles (ACCEPTED)
Post by: Mandoble on 03 Nov 2007, 13:24:49
Function mando_angles.sqf v1.0

Returns the angle between obj1 and obj2, the degrees that obj1 needs to turn to have obj2 centered horizontally and checks whether obj2 is inside field of view of obj1
Negative means turning left, positive means turning right
The returned value is in the form [angle, angle to turn, inside FOV true/false]

Load and compile the function first in your init.sqs or init.sqf
mando_angles = compile (preprocessFileLineNumbers "mando_angles.sqf");

Then to call it:
   _angles = [firstobject, secondobject] call mando_angles;
   _angles select 0 = angle between firstobject and secondobject
   _angles select 1 = angle that firstobject needs to turn to have secondobject centered horizontally
   _angles select 2 = true if secondobject is inside field of view of firstobject
Title: Re: Mando Angles
Post by: LeeHunt on 03 Nov 2007, 13:47:54
Works great!!!   

One obvious of many uses would be to guide the player back to an objective or zone.  Knowing whether or not this objective is in the player's field of view is also useful. 
This function would be useful in resources like Norrin's Out of Bounds (i'll pass on the info to Norrin) http://www.ofpec.com/forum/index.php?topic=30324.0.
Title: Re: Mando Angles (TESTING)
Post by: Mandoble on 03 Nov 2007, 16:26:33
Well, not sure about that. Norrin is using bounds, and bounds are basically defined by rects or segments, not just objects.
Title: Re: Mando Angles (TESTING)
Post by: LeeHunt on 03 Nov 2007, 17:13:32
Yes that's true, if the trigger defining the rectangle etc had a name he could use that as the object in view etc.  But no worries either way