2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-05-30 16:37:03 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus
|
|
|
|
* Get the absolute turret direction for FOV/PIP turret.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Vehicle <OBJECT>
|
|
|
|
* 1: Turret Position <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* 0: Position ASL <ARRAY>
|
|
|
|
* 1: Direction <ARRAY>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [car, [5,6,5]] call ace_common_fnc_getTurretDirection
|
|
|
|
*
|
2016-05-30 16:37:03 +00:00
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_vehicle", "_position"];
|
|
|
|
|
|
|
|
private _turret = [_vehicle, _position] call CBA_fnc_getTurret;
|
|
|
|
|
|
|
|
private _pov = getText (_turret >> "memoryPointGunnerOptics");
|
|
|
|
private _gunBeg = getText (_turret >> "gunBeg");
|
|
|
|
private _gunEnd = getText (_turret >> "gunEnd");
|
|
|
|
|
2024-02-05 17:04:24 +00:00
|
|
|
TRACE_3("",_pov,_gunBeg,_gunEnd);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
// Pull the PIP pov or barrel direction, depending on how the model is set up
|
2021-10-10 13:37:05 +00:00
|
|
|
private _povPos = _vehicle modelToWorldVisualWorld (_vehicle selectionPosition _pov);
|
2016-05-30 16:37:03 +00:00
|
|
|
private _povDir = [0,0,0];
|
|
|
|
|
|
|
|
if (_pov == "pip0_pos") then {
|
2021-10-10 13:37:05 +00:00
|
|
|
private _pipDir = _vehicle modelToWorldVisualWorld (_vehicle selectionPosition "pip0_dir");
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
_povDir = _pipDir vectorDiff _povPos;
|
|
|
|
} else {
|
2021-10-10 13:37:05 +00:00
|
|
|
private _gunBeginPos = _vehicle modelToWorldVisualWorld (_vehicle selectionPosition _gunBeg);
|
|
|
|
private _gunEndPos = _vehicle modelToWorldVisualWorld (_vehicle selectionPosition _gunEnd);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
_povDir = _gunBeginPos vectorDiff _gunEndPos;
|
|
|
|
};
|
2016-10-08 10:55:30 +00:00
|
|
|
_povDir = vectorNormalized _povDir;
|
2016-05-30 16:37:03 +00:00
|
|
|
[_povPos, _povDir]
|