This commit is contained in:
Brett Mayson 2021-06-27 16:00:37 -06:00
parent a417ea87d3
commit a849f04f75
13 changed files with 211 additions and 0 deletions

1
addons/gps/$PBOPREFIX$ Normal file
View File

@ -0,0 +1 @@
z\ace\addons\gps

View File

@ -0,0 +1,17 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

4
addons/gps/XEH_PREP.hpp Normal file
View File

@ -0,0 +1,4 @@
PREP(getError);
PREP(getOffset);
PREP(getPos);
PREP(getSatLocations);

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
if (!hasInterface) exitWith {};

View File

@ -0,0 +1,11 @@
#include "script_component.hpp"
ADDON = false;
PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
// #include "initSettings.sqf"
ADDON = true;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

18
addons/gps/config.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "script_component.hpp"
#define COLOUR 8.0
class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam);
authors[] = {"Brett Mayson"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"

View File

@ -0,0 +1,40 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Get GPS error level
*
* This number does not have any real world correlation
*
* Arguments:
* Object with GPS <OBJECT>
*
* Return Value:
* Error <NUMBER>
*
* Example:
* [_unit] call ace_gps_fnc_getError
*
* Public: Yes
*/
params [
["_object", ACE_player, [objNull]]
];
if (time < (_object getVariable [QGVAR(errorCacheExpire), -1])) exitWith {
_object getVariable [QGVAR(errorCache), 0];
};
private _points = [_object] call FUNC(getSatLocations);
private _src = getPos _object;
_src set [2, 1.3];
_src = AGLtoASL _src;
private _error = 0;
{
_error = _error + count lineIntersectsSurfaces [_src, AGLtoASL _x, _object, objNull, true, 3];
} forEach _points;
_object setVariable [QGVAR(errorCache), _error];
_object setVariable [QGVAR(errorCacheExpire), time + 0.5];
_error

View File

@ -0,0 +1,44 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Get GPS position with random error
*
* This number does not have any real world correlation
*
* Arguments:
* Object with GPS <OBJECT>
*
* Return Value:
* Error <NUMBER>
*
* Example:
* [_unit] call ace_gps_fnc_getPos
*
* Public: Yes
*/
params [
["_object", ACE_player, [objNull]]
];
if (time < (_object getVariable [QGVAR(offsetCacheExpire), -1])) exitWith {
_object getVariable [QGVAR(offsetCache), [0, 0]];
};
private _error = [_object] call FUNC(getError);
if (_error == 0) exitWith { [0,0] };
private _seed = floor (dayTime * 10);
private _pos = getPos _object;
_pos deleteAt 2;
_pos set [0, floor (_pos#0 / 100)];
_pos set [1, floor (_pos#1 / 100)];
private _distance = (_seed random _pos) * _error;
private _direction = (_error random _pos) * 360;
_object setVariable [QGVAR(offsetCache), [_distance, _direction]];
_object setVariable [QGVAR(offsetCacheExpire), time + 3];
[_distance, _direction]

View File

@ -0,0 +1,24 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Get GPS position with random error
*
* This number does not have any real world correlation
*
* Arguments:
* Object with GPS <OBJECT>
*
* Return Value:
* Error <NUMBER>
*
* Example:
* [_unit] call ace_gps_fnc_getPos
*
* Public: Yes
*/
params [
["_object", ACE_player, [objNull]]
];
_object getPos ([_object] call FUNC(getOffset));

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: Brett Mayson
* Get "satellite" locations for simulating gps inaccuracy
*
* Arguments:
* Object with GPS <OBJECT>
*
* Return Value:
* Locations <ARRAY>
*
* Example:
* [_unit] call ace_gps_fnc_getSatLocations
*
* Public: Yes
*/
params [
["_object", ACE_player, [objNull]]
];
private _points = [];
for "_i" from 0 to 5 do {
private _point = _object getPos [800, _i * 60];
_point set [2, 500];
_points pushBack _point;
};
_points

View File

@ -0,0 +1 @@
#include "\z\ace\addons\gps\script_component.hpp"

View File

@ -0,0 +1,17 @@
#define COMPONENT gps
#define COMPONENT_BEAUTIFIED GPS
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_GPS
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_GPS
#define DEBUG_SETTINGS DEBUG_SETTINGS_GPS
#endif
#include "\z\ace\addons\main\script_macros.hpp"