From 296f945ea3ba38d7034a96d8e0cedf45ca94d6f1 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Mon, 12 Feb 2024 23:51:07 -0800 Subject: [PATCH] adds default bases + allows mms to set custom waypoints for microdagr --- framework/CfgFunctions.hpp | 10 ++-- .../functions/fn_addMicroDAGRWaypoints.sqf | 59 +++++++++++++++++++ framework/client/functions/fn_initClient.sqf | 21 +++++++ framework/init/functions/fn_initClient.sqf | 1 + mission_settings.hpp | 15 ++++- 5 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 framework/client/functions/fn_addMicroDAGRWaypoints.sqf create mode 100644 framework/client/functions/fn_initClient.sqf diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index 2a3c4a0..2146dc0 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -22,10 +22,12 @@ class PREFIX { class DOUBLES(PREFIX,client) { class functions { file = "framework\client\functions"; - class bindEmptyGroupGarbageCleanup { postInit = 1; }; - class bindEventHandlers { postInit = 1; }; - class bindVehicleActions { postInit = 1; }; - class addZenModules {postInit = 1;}; + class initClient {}; + class addMicroDAGRWaypoints {}; + class addZenModules {}; + class bindEmptyGroupGarbageCleanup {}; + class bindEventHandlers {}; + class bindVehicleActions {}; }; }; diff --git a/framework/client/functions/fn_addMicroDAGRWaypoints.sqf b/framework/client/functions/fn_addMicroDAGRWaypoints.sqf new file mode 100644 index 0000000..f72e858 --- /dev/null +++ b/framework/client/functions/fn_addMicroDAGRWaypoints.sqf @@ -0,0 +1,59 @@ +#include "..\script_component.hpp" + +// adds default base locations to players' microDAGR as waypoints + +if (!hasInterface) exitWith {}; + +[{!isNull player}, { + + // add base locations (respawn modules) + { + private _wpName = [_x] call EFUNC(common,getNameOfBase); + private _posASL = getPosASL _x; + [_wpName, _posASL] call ace_microdagr_fnc_deviceAddWaypoint; + } forEach GVARMAIN(baseObjects); + + // add custom waypoints from mission_settings.hpp + private _customWaypoints = [missionConfigFile >> "custom_microdagr_waypoints", "ARRAY", []] call CBA_fnc_getConfigEntry; + { + _x params [ + ["_wpName", ""], + ["_pos", [0, 0, 0], [[], ""]], + ["_object", "", [""]] + ]; + private _realPos = nil; + // if pos was provided, process + if (count _pos > 0) then { + if (typeName _pos == "STRING") then { + _realPos = [_pos, true] call ACE_common_fnc_getMapPosFromGrid; + _realPos set [2, getTerrainHeightASL _realPos]; + } else {_realPos = _pos;}; + }; + // if object was provided, process and override any pos + if (count _object > 0) then { + // object is provided as a string variable name + private _realObject = missionNamespace getVariable _object; + if (isNull _realObject) then { + [ + LEVEL_WARNING, + QUOTE(COMPONENT), + format["Invalid object for custom microDAGR waypoint: %1", _wpName], + [["name", _wpName], ["pos", _pos], ["object", _object]]] call EFUNC(common,log); + continue; + }; + _realPos = getPosASL (missionNamespace getVariable _object); + }; + if (isNil "_realPos") then { + [ + LEVEL_WARNING, + QUOTE(COMPONENT), + format["Invalid waypoint position for custom microDAGR waypoint: %1", _wpName], + [["name", _wpName], ["pos", _pos], ["object", _object]]] call EFUNC(common,log); + continue; + }; + + [_wpName, _realPos] call ace_microdagr_fnc_deviceAddWaypoint; + } forEach _customWaypoints; +}] call CBA_fnc_waitUntilAndExecute; + +nil; \ No newline at end of file diff --git a/framework/client/functions/fn_initClient.sqf b/framework/client/functions/fn_initClient.sqf new file mode 100644 index 0000000..f3d8fac --- /dev/null +++ b/framework/client/functions/fn_initClient.sqf @@ -0,0 +1,21 @@ +#include "..\script_component.hpp" + + +if (!hasInterface) exitWith {}; + +call FUNC(addMicroDAGRWaypoints); +call FUNC(addZenModules); +call FUNC(bindEmptyGroupGarbageCleanup); +call FUNC(bindEventHandlers); +call FUNC(bindVehicleActions); + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "initClient complete", + [] +] call EFUNC(common,log); + +localNamespace setVariable [QGVAR(complete), true]; + +nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initClient.sqf b/framework/init/functions/fn_initClient.sqf index 6e82106..81eef3a 100644 --- a/framework/init/functions/fn_initClient.sqf +++ b/framework/init/functions/fn_initClient.sqf @@ -23,6 +23,7 @@ EGVAR(common,diaryRecords) = createHashMap; // initialize other modules +call EFUNC(client,initClient); call EFUNC(mapcopy,initClient); call EFUNC(reinsert,initClient); call EFUNC(resupply,initClient); diff --git a/mission_settings.hpp b/mission_settings.hpp index 224ef78..fcc6810 100644 --- a/mission_settings.hpp +++ b/mission_settings.hpp @@ -9,8 +9,21 @@ overviewText = "THIS IS WHERE YOU DESCRIBE THE MISSION IN THE #MISSION LIST"; // The name for the series of missions of your campaign. Used for organizational and search purposes missionSeries = "MY SERIES NAME"; -// activate via #ace-fortify west base 2000 +// Add waypoints to players' MicroDAGR devices +// respawn locations (bases) are added by default, don't put them here +custom_microdagr_waypoints[] = { + // the first element is the waypoint name + // the second element is the position of the waypoint - you may use a string for map grid (up to 10 digit) or an array for {X, Y} coordinates + // the third element is optional - provide the variable name of an object if you want to use its initial position instead + // {"WAYPOINT NAME", {POSITION <[x,y]>}, OBJECT }, + // EXAMPLES: + // {"KAVALA HOSPITAL", {1234.56, 7890.12}, ""}, + // {"CAMP TEMPEST", "03421460, ""}, + // {"MY CUSTOM OBJECT", {}, "myCustomObject"} +}; + +// activate via #ace-fortify west base 2000 class ACEX_Fortify_Presets { class base { displayName = "Ken Custom";