ACE3/addons/missileguidance/functions/fnc_checkSeekerAngle.sqf
jonpas 742626ff1a
General - Relative script_component.hpp includes (#9378)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-12 20:58:10 +02:00

35 lines
838 B
Plaintext

#include "..\script_component.hpp"
/*
* Author: jaynus
* Returns whether the target position is within the maximum angle FOV of the provided seeker
* objects current direction.
*
* Arguments:
* 0: Seeker <OBJECT>
* 1: Target PosASL <ARRAY>
* 2: Max Angle (degrees) <NUMBER>
*
* Return Value:
* Can See <BOOL>
*
* Example:
* [player, cursorTarget, 45] call ace_missileguidance_fnc_checkSeekerAngle;
*
* Public: No
*/
params ["_seeker", "_targetPos", "_seekerMaxAngle"];
private _sensorPos = getPosASL _seeker;
private _testPointVector = vectorNormalized (_targetPos vectorDiff _sensorPos);
private _testDotProduct = (vectorNormalized (velocity _seeker)) vectorDotProduct _testPointVector;
TRACE_2("fov",acos _testDotProduct,_seekerMaxAngle);
if (_testDotProduct < (cos _seekerMaxAngle)) exitWith {
false
};
true