diff --git a/addons/loadout/$PBOPREFIX$ b/addons/loadout/$PBOPREFIX$ new file mode 100644 index 000000000..4716d0880 --- /dev/null +++ b/addons/loadout/$PBOPREFIX$ @@ -0,0 +1 @@ +x\cba\addons\loadout diff --git a/addons/loadout/CfgEventHandlers.hpp b/addons/loadout/CfgEventHandlers.hpp new file mode 100644 index 000000000..9b160c160 --- /dev/null +++ b/addons/loadout/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; diff --git a/addons/loadout/CfgFunctions.hpp b/addons/loadout/CfgFunctions.hpp new file mode 100644 index 000000000..e46a149c0 --- /dev/null +++ b/addons/loadout/CfgFunctions.hpp @@ -0,0 +1,8 @@ +class CfgFunctions { + class CBA { + class Loadout { + PATHTO_FNC(getLoadout); + PATHTO_FNC(setLoadout); + }; + }; +}; diff --git a/addons/loadout/XEH_preInit.sqf b/addons/loadout/XEH_preInit.sqf new file mode 100644 index 000000000..19f1494f2 --- /dev/null +++ b/addons/loadout/XEH_preInit.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +ADDON = true; diff --git a/addons/loadout/config.cpp b/addons/loadout/config.cpp new file mode 100644 index 000000000..10af0c1d2 --- /dev/null +++ b/addons/loadout/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = "Community Base Addons - Loadout Framework"; + units[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"cba_common", "cba_events"}; + author = "$STR_CBA_Author"; + authors[] = {"Brett Mayson"}; + url = "$STR_CBA_URL"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgFunctions.hpp" diff --git a/addons/loadout/fnc_getLoadout.sqf b/addons/loadout/fnc_getLoadout.sqf new file mode 100644 index 000000000..431407d20 --- /dev/null +++ b/addons/loadout/fnc_getLoadout.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_getLoadout +Description: + Get a unit's extended loadout +Parameters: + _unit - The unit to set the loadout on. +Returns: + Extended Loadout +Examples: + (begin example) + [player] call CBA_fnc_getLoadout + (end) +Author: + Brett Mayson +---------------------------------------------------------------------------- */ + +params [ + ["_unit", objNull, [objNull]] +]; + +if (_unit isEqualTo objNull) exitWith {[]}; + +private _loadout = getUnitLoadout _unit; +private _extendedInfo = createHashMap; + +["CBA_loadoutGet", [_unit, _loadout, _extendedInfo]] call CBA_fnc_localEvent; + +[ + _loadout, + _extendedInfo +] diff --git a/addons/loadout/fnc_setLoadout.sqf b/addons/loadout/fnc_setLoadout.sqf new file mode 100644 index 000000000..1d61a4450 --- /dev/null +++ b/addons/loadout/fnc_setLoadout.sqf @@ -0,0 +1,39 @@ +#include "script_component.hpp" +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_setLoadout +Description: + Set a unit's extended loadout +Parameters: + _unit - The unit to set the loadout on. + _loadout - The extended loadout to set. + _fullMagazines - Partially emptied magazines will be refilled when the loadout is applied. +Returns: + Nothing +Examples: + (begin example) + [player] call CBA_fnc_setLoadout + (end) +Author: + Brett Mayson +---------------------------------------------------------------------------- */ + +params [ + ["_unit", objNull, [objNull]], + ["_loadout", [], [[]]], + ["_fullMagazines", false, [false]] +]; + +if (isNull _unit) exitWith {}; + +// A regular loadout array was passed in +if (count _loadout == 10) exitWith { + _unit setUnitLoadout [_loadout, _fullMagazines]; +}; + +_loadout params ["_loadoutArray", "_extendedInfo"]; + +_unit setUnitLoadout [_loadoutArray, _fullMagazines]; + +if (_extendedInfo isEqualType []) then { _extendedInfo = createHashMapFromArray _extendedInfo; }; + +["CBA_loadoutSet", [_unit, _loadout, _extendedInfo]] call CBA_fnc_localEvent; diff --git a/addons/loadout/script_component.hpp b/addons/loadout/script_component.hpp new file mode 100644 index 000000000..d1b041eb8 --- /dev/null +++ b/addons/loadout/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT loadout +#include "\x\cba\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_LOADOUT + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_LOADOUT + #define DEBUG_SETTINGS DEBUG_SETTINGS_LOADOUT +#endif + +#include "\x\cba\addons\main\script_macros.hpp"