diff --git a/addons/friendly_tracker/XEH_PREP.hpp b/addons/friendly_tracker/XEH_PREP.hpp index e02ca0b..3ac5e88 100644 --- a/addons/friendly_tracker/XEH_PREP.hpp +++ b/addons/friendly_tracker/XEH_PREP.hpp @@ -12,4 +12,5 @@ PREP(getVehicleMarkerType); PREP(canTrack); PREP(getTrackedSides); PREP(hasTracker); +PREP(hasTrackerVehicle); PREP(isTrackable); diff --git a/addons/friendly_tracker/XEH_preInit.sqf b/addons/friendly_tracker/XEH_preInit.sqf index a9d2a2b..a7b4632 100644 --- a/addons/friendly_tracker/XEH_preInit.sqf +++ b/addons/friendly_tracker/XEH_preInit.sqf @@ -11,4 +11,6 @@ GVAR(running) = false; GVAR(markers) = []; GVAR(trackedVehicles) = []; +GVAR(vehicleGpsCache) = call CBA_fnc_hashCreate; + ADDON = true; diff --git a/addons/friendly_tracker/functions/fnc_canTrack.sqf b/addons/friendly_tracker/functions/fnc_canTrack.sqf index 4639e00..5277fc5 100644 --- a/addons/friendly_tracker/functions/fnc_canTrack.sqf +++ b/addons/friendly_tracker/functions/fnc_canTrack.sqf @@ -20,4 +20,4 @@ params ["_object"]; // If GPS mode is disabled all units can track. if (!GVAR(GPS)) exitWith {true}; -[_object] call FUNC(hasTracker) +_object call FUNC(hasTracker) || {vehicle _object call FUNC(hasTrackerVehicle)} diff --git a/addons/friendly_tracker/functions/fnc_hasTracker.sqf b/addons/friendly_tracker/functions/fnc_hasTracker.sqf index c14d4d6..15b62fa 100644 --- a/addons/friendly_tracker/functions/fnc_hasTracker.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTracker.sqf @@ -17,4 +17,4 @@ params ["_unit"]; -((assignedItems _unit findIf {_x isEqualTo "ItemGPS" || {["UavTerminal", _x] call BIS_fnc_inString}}) != -1) +((assignedItems _unit findIf {_x isEqualTo "ItemGPS" || {"uavterminal" in toLower _x}}) != -1) // return diff --git a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf new file mode 100644 index 0000000..d4a3a16 --- /dev/null +++ b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf @@ -0,0 +1,37 @@ +#include "script_component.hpp" +/* + * Author: veteran29 + * Function checks if vehicle has tracking capabilities + * + * Arguments: + * 0: The vehicle that will be checked if it has a tracking capabilities + * + * Return Value: + * 0: Has tracker + * + * Example: + * [bob] call afft_friendly_tracker_fnc_hasTrackerVehicle + * + * Public: No + */ + +params ["_vehicle"]; + +if (!GVAR(GPSVehicle)) exitWith {false}; + +private _enabledGps = _vehicle getVariable [QGVAR(enabledGps), ""]; + +if (_enabledGps isEqualType true) exitWith {_enabledGps}; + +private _vehicleConfig = configOf _vehicle; +private _vehicleConfigName = configName _vehicleConfig; + +_enabledGps = [GVAR(vehicleGpsCache), _vehicleConfigName, ""] call CBA_fnc_hashGet; + +if (_enabledGps isEqualTo "") then { + _enabledGps = getNumber (_vehicleConfig >> "enableGPS") == 1; + [GVAR(vehicleGpsCache), _vehicleConfigName, _enabledGps] call CBA_fnc_hashSet; +}; + +// Return +_enabledGps diff --git a/addons/friendly_tracker/functions/fnc_isTrackable.sqf b/addons/friendly_tracker/functions/fnc_isTrackable.sqf index e54cfd3..8264125 100644 --- a/addons/friendly_tracker/functions/fnc_isTrackable.sqf +++ b/addons/friendly_tracker/functions/fnc_isTrackable.sqf @@ -29,9 +29,10 @@ if (!GVAR(showInvisible) && {isObjectHidden _object}) exitWith {false}; // If GPS mode is disabled all object are trackable. if (!GVAR(GPS)) exitWith {true}; -// If object is vehicle check if anyone inside has tracker -if (_object isKindOf "AllVehicles") exitWith { - (crew _object) findIf {[_x] call FUNC(hasTracker)} != -1 +// If object is Human check if has tracker or is in vehicle with tracker +if (_object isKindOf "CAManBase") exitWith { + _object call FUNC(hasTracker) || {vehicle _object call FUNC(hasTrackerVehicle)} // return }; -[_object] call FUNC(hasTracker); +// If object is vehicle check if it has tracker or its crew has tracker +_object call FUNC(hasTrackerVehicle) || (crew _object) findIf {_x call FUNC(hasTracker)} != -1 // return diff --git a/addons/friendly_tracker/initSettings.sqf b/addons/friendly_tracker/initSettings.sqf index fbc3d4a..7a5bcb8 100644 --- a/addons/friendly_tracker/initSettings.sqf +++ b/addons/friendly_tracker/initSettings.sqf @@ -92,3 +92,12 @@ false, true ] call CBA_fnc_addSetting; + +[ + QGVAR(GPSVehicle), + "CHECKBOX", + [LSTRING(GPSVehicle), LSTRING(GPSVehicle_Description)], + LSTRING(DisplayName), + true, + true +] call CBA_fnc_addSetting; diff --git a/addons/friendly_tracker/stringtable.xml b/addons/friendly_tracker/stringtable.xml index 4fe7680..3234680 100644 --- a/addons/friendly_tracker/stringtable.xml +++ b/addons/friendly_tracker/stringtable.xml @@ -109,5 +109,13 @@ When enabled only units with tracker in equipment will be visible on the map. To see other players you also need a tracker. Wymagaj trackera by pokazać jednostkę na mapie. By widzieć markery innych graczy również musisz mieć tracker. + + Use vehicle GPS as tracker + Używaj GPS pojazdu jako tracker + + + When enabled vehicles with GPS will provide tracking capabilities to its crew. + Gdy włączone pojazdy z GPS będą dostarczać funkcjonalność trackera swojej załodze. +