ACE3/addons/microdagr/functions/fnc_recieveRangefinderData.sqf

32 lines
1.0 KiB
Plaintext
Raw Normal View History

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