Home   Help Search Login Register  

Author Topic: Mando Angles (ACCEPTED)  (Read 1739 times)

0 Members and 1 Guest are viewing this topic.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Mando Angles (ACCEPTED)
« 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
« Last Edit: 04 Nov 2007, 13:33:38 by LeeHunt »

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: Mando Angles
« Reply #1 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.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Mando Angles (TESTING)
« Reply #2 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.

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: Mando Angles (TESTING)
« Reply #3 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