ACE3/addons/microdagr/functions/fnc_recieveRangefinderData.sqf
PabstMirror 95d59a1b3a Headers
2015-03-11 02:06:07 -05:00

35 lines
1.1 KiB
Plaintext

/*
* Author: PabstMirror
* Recieves the data packet from the vector rangefinder
*
* Arguments:
* 0: Slope distance (Meters) <NUMBER>
* 1: Azimuth (Degrees) <NUMBER>
* 2: Inclination (Degrees) <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [1000, 45, 1] call ace_microdagr_fnc_recieveRangefinderData
*
* Public: No
*/
#include "script_component.hpp"
private ["_horizontalDistance", "_verticleDistance", "_targetOffset", "_targetPosASL"];
PARAMS_3(_slopeDistance,_azimuth,_inclination);
if (GVAR(currentWaypoint) != -2) exitWith {}; //Only take waypoint when "connected"
if (_slopeDistance < 0) exitWith {}; //Bad Data
_horizontalDistance = (cos _inclination) * _slopeDistance;
_verticleDistance = (sin _inclination) * _slopeDistance;
_targetOffset = [((sin _azimuth) * _horizontalDistance), ((cos _azimuth) * _horizontalDistance), _verticleDistance];
//This assumes the "rangefinder view" pos is very close to player, at worst the turret should only be a few meters different
_targetPosASL = (getPosASL ace_player) vectorAdd _targetOffset;
GVAR(rangeFinderPositionASL) = _targetPosASL;