From e05f2ca63701b7642b0c71f2f0621f70c0dd124e Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Wed, 18 May 2016 21:19:52 +0100 Subject: [PATCH] Add search nearby building zeus module --- addons/zeus/CfgVehicles.hpp | 5 ++ addons/zeus/XEH_PREP.hpp | 1 + addons/zeus/XEH_postInit.sqf | 2 + addons/zeus/config.cpp | 1 + .../zeus/functions/fnc_moduleSearchNearby.sqf | 50 +++++++++++++++++++ addons/zeus/stringtable.xml | 6 +++ 6 files changed, 65 insertions(+) create mode 100644 addons/zeus/functions/fnc_moduleSearchNearby.sqf diff --git a/addons/zeus/CfgVehicles.hpp b/addons/zeus/CfgVehicles.hpp index ba1f8bfe46..ddf1af6c37 100644 --- a/addons/zeus/CfgVehicles.hpp +++ b/addons/zeus/CfgVehicles.hpp @@ -113,6 +113,11 @@ class CfgVehicles { displayName = CSTRING(ModuleGroupSide_DisplayName); curatorInfoType = QGVAR(RscGroupSide); }; + class GVAR(moduleSearchNearby): GVAR(moduleBase) { + curatorCanAttach = 1; + displayName = CSTRING(ModuleSearchNearby_DisplayName); + function = QFUNC(moduleSearchNearby); + }; class GVAR(moduleSetMedic): GVAR(moduleBase) { curatorCanAttach = 1; displayName = CSTRING(ModuleSetMedic_DisplayName); diff --git a/addons/zeus/XEH_PREP.hpp b/addons/zeus/XEH_PREP.hpp index d171b3679c..cbc04f1c3a 100644 --- a/addons/zeus/XEH_PREP.hpp +++ b/addons/zeus/XEH_PREP.hpp @@ -10,6 +10,7 @@ PREP(moduleAddSpareWheel); PREP(moduleCaptive); PREP(moduleGlobalSetSkill); PREP(moduleGroupSide); +PREP(moduleSearchNearby); PREP(moduleSetMedic); PREP(moduleSetMedicalVehicle); PREP(moduleSetMedicalFacility); diff --git a/addons/zeus/XEH_postInit.sqf b/addons/zeus/XEH_postInit.sqf index c2c7c192eb..b7d09aa3c0 100644 --- a/addons/zeus/XEH_postInit.sqf +++ b/addons/zeus/XEH_postInit.sqf @@ -2,3 +2,5 @@ // Global skill module PVs values for persistence, just listen for the PV QGVAR(GlobalSkillAI) addPublicVariableEventHandler FUNC(moduleGlobalSetSkill); + +[QGVAR(moduleSearchNearby), CBA_fnc_searchNearby] call EFUNC(common,addEventHandler); diff --git a/addons/zeus/config.cpp b/addons/zeus/config.cpp index 1b47046fd9..cbcdef373c 100644 --- a/addons/zeus/config.cpp +++ b/addons/zeus/config.cpp @@ -5,6 +5,7 @@ class CfgPatches { units[] = { QGVAR(moduleGlobalSetSkill), QGVAR(moduleGroupSide), + QGVAR(moduleSearchNearby), QGVAR(moduleTeleportPlayers) }; weapons[] = {}; diff --git a/addons/zeus/functions/fnc_moduleSearchNearby.sqf b/addons/zeus/functions/fnc_moduleSearchNearby.sqf new file mode 100644 index 0000000000..b5be224a84 --- /dev/null +++ b/addons/zeus/functions/fnc_moduleSearchNearby.sqf @@ -0,0 +1,50 @@ +/* + * Author: SilentSpike + * Commands the group the module is placed on to search the nearest building + * + * Arguments: + * 0: The module logic + * 1: Synchronized units + * 2: Activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_logic","_units","_activated"]; + +if !(_activated && local _logic) exitWith {}; + +//Validate the module target: +private _unit = effectiveCommander (attachedTo _logic); +private _building = nearestBuilding (getPosASL _unit); + +scopeName "Main"; +private _fnc_errorAndClose = { + params ["_msg"]; + deleteVehicle _logic; + [_msg] call EFUNC(common,displayTextStructured); + breakOut "Main"; +}; + +switch (false) do { + case !(isNull _unit): { + [LSTRING(NothingSelected)] call _fnc_errorAndClose; + }; + case (_unit isKindOf "CAManBase"): { + [LSTRING(OnlyInfantry)] call _fnc_errorAndClose; + }; + case (alive _unit): { + [LSTRING(OnlyAlive)] call _fnc_errorAndClose; + }; + case (_unit distance _building < 500): { + [LSTRING(BuildingTooFar)] call _fnc_errorAndClose; + }; +}; + +//Perform the module function: +[QGVAR(moduleSearchNearby), _unit, [_unit]] call EFUNC(common,targetEvent); diff --git a/addons/zeus/stringtable.xml b/addons/zeus/stringtable.xml index df209f4426..a972cd6e06 100644 --- a/addons/zeus/stringtable.xml +++ b/addons/zeus/stringtable.xml @@ -262,6 +262,9 @@ Без сознания (вкл./выкл.) Apri Incosciente + + Search Nearby Building + Assign Medic Sanitäter zuweisen. @@ -387,6 +390,9 @@ Unit must belong to an appropriate side + + Nearest building is too far away + Place on a unit Rien sous le curseur