-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1503 from BrettMayson/extended_loadout
Extended Loadout Framework
- Loading branch information
Showing
8 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x\cba\addons\loadout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CfgFunctions { | ||
class CBA { | ||
class Loadout { | ||
PATHTO_FNC(getLoadout); | ||
PATHTO_FNC(setLoadout); | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. <UNIT> | ||
Returns: | ||
Extended Loadout <ARRAY> | ||
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 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. <UNIT> | ||
_loadout - The extended loadout to set. <ARRAY> | ||
_fullMagazines - Partially emptied magazines will be refilled when the loadout is applied. <BOOL> | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |