change root level folder name to framework, update resupply+vehicleflags
tested locally
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
// adds a scroll wheel action to all arsenal boxes to spawn different supply crate types
|
||||
|
||||
private _arsenalBoxClassName = "Land_PaperBox_open_full_F";
|
||||
|
||||
// get all instances of the arsenal item
|
||||
private _arsenalBoxes = (allMissionObjects _arsenalBoxClassName) select {
|
||||
// only select the ones that already have user actions attached
|
||||
count (actionIDs _x) > 0;
|
||||
};
|
||||
|
||||
private _supplyCratesCfg = call FUNC(getSupplyCratesCfg);
|
||||
private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren;
|
||||
|
||||
{
|
||||
// add scroll wheel action to spawn different supply box types
|
||||
private _arsenalBox = _x;
|
||||
{
|
||||
private _cfg = _x;
|
||||
private _supplyCrateDisplayName = (_cfg >> "displayName") call BIS_fnc_getCfgData;
|
||||
|
||||
_arsenalBox addAction [format ["<t color='#ffffff'>Spawn %1</t>", _supplyCrateDisplayName], {
|
||||
params ["_target", "_caller", "_actionId", "_arguments"];
|
||||
_arguments params ["_supplyCrateCfg"];
|
||||
[
|
||||
objNull,
|
||||
configName _supplyCrateCfg,
|
||||
getPos _target
|
||||
] call FUNC(createBox);
|
||||
}, [_cfg], 0, false, true, "", ""];
|
||||
} forEach _supplyCrateTypesCfgs;
|
||||
} forEach _arsenalBoxes;
|
||||
25
framework/resupply/functions/fn_addCBASettings.sqf
Normal file
25
framework/resupply/functions/fn_addCBASettings.sqf
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
[
|
||||
QGVAR(setting_allowSupplyBoxScrollWheelSpawning), // variable
|
||||
"CHECKBOX", // type
|
||||
["Allow Spawning Boxes from Arsenal Box", "If true, adds scroll wheel options to arsenal boxes to spawn supply boxes"], // title
|
||||
[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category
|
||||
false, // default value
|
||||
true, // global setting
|
||||
{
|
||||
params ["_value"];
|
||||
[
|
||||
QUOTE(COMPONENT),
|
||||
"SETTING CHANGED",
|
||||
[
|
||||
[
|
||||
"setting",
|
||||
QGVAR(setting_allowSupplyBoxScrollWheelSpawning)
|
||||
],
|
||||
["newValue", _value]
|
||||
]
|
||||
] call EFUNC(util,log);
|
||||
},
|
||||
true // requires mission restart
|
||||
] call CBA_fnc_addSetting;
|
||||
168
framework/resupply/functions/fn_createBox.sqf
Normal file
168
framework/resupply/functions/fn_createBox.sqf
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Author: Hizumi & IndigoFox
|
||||
*
|
||||
* Create Mortar resupply box for the 17th Battalion. Primarily called from milsim_fnc_addZenModules
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle - <OBJECT>
|
||||
* 1: Type - <STRING>
|
||||
* 2: Position - <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Function executed <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [box, "AmmoSquad"] call milsim_fnc_createBox; // create mortar ammo box via init line of editor object
|
||||
* [objNull, "AmmoHeavy", pos] call milsim_fnc_createBox; // create mortar ammo box via zeus module
|
||||
*
|
||||
* Public: Yes
|
||||
*
|
||||
* Note: For gathering:
|
||||
formatText ["%1", [
|
||||
["containerClassname", typeOf cursorObject],
|
||||
["backpack", (backpackCargo cursorObject) call BIS_fnc_consolidateArray],
|
||||
["item", (itemCargo cursorObject) call BIS_fnc_consolidateArray],
|
||||
["magazine", (magazineCargo cursorObject) call BIS_fnc_consolidateArray],
|
||||
["magazineAmmo", magazinesAmmoCargo cursorObject],
|
||||
["weapon", (weaponCargo cursorObject) call BIS_fnc_consolidateArray]
|
||||
]];
|
||||
*/
|
||||
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
params [
|
||||
["_box", objNull, [objNull]],
|
||||
["_type", "", [""]],
|
||||
["_pos", [0,0,0], [[]], 3]
|
||||
];
|
||||
|
||||
// get defs class
|
||||
private _supplyCratesCfg = call FUNC(getSupplyCratesCfg);
|
||||
if (!isClass _supplyCratesCfg) exitWith {
|
||||
["Resupply Boxes: Failed to load crate definitions, possibly a bad edit?"] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
// get the subclass names
|
||||
private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses;
|
||||
|
||||
// if no type is provided, show the available types
|
||||
if (_type isEqualTo "") exitWith {
|
||||
[
|
||||
"%1 | %2 %3",
|
||||
"Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox",
|
||||
"No type provided. Please use one of the following types for _type:",
|
||||
_boxTypesAvailable joinString ", "
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// get the box definition class
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
private _boxDef = (_supplyCratesCfg >> _type);
|
||||
// validate it exists
|
||||
if (!isClass _boxDef) exitWith {
|
||||
[
|
||||
"%1 | %2 %3",
|
||||
"Resupply Boxes: [_boxObject, _type, _pos] call milsim_fnc_createBox",
|
||||
"Invalid type provided. Please use one of the following types for _type:",
|
||||
_boxTypesAvailable joinString ", "
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Create box if one wasn't provided in parameters
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (isNull _box) then {
|
||||
private _neededBoxType = getText(_boxDef >> "boxClass");
|
||||
if (_neededBoxType isEqualTo "") exitWith {
|
||||
[
|
||||
"Resupply Boxes: Failed to create box. No boxClass defined in the box definition."
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
_box = _neededBoxType createVehicle _pos;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Clear box
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
clearBackpackCargoGlobal _box;
|
||||
clearItemCargoGlobal _box;
|
||||
clearMagazineCargoGlobal _box;
|
||||
clearWeaponCargoGlobal _box;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Get [item, quantity] arrays from definition
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
private _backpacks = ([_boxDef >> "backpacks"] call BIS_fnc_getCfgDataArray);
|
||||
if (isNil "_backpacks") exitWith {
|
||||
[
|
||||
"Resupply Boxes: Failed to create box. No backpacks defined in the box definition."
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
private _weapons = ([_boxDef >> "weapons"] call BIS_fnc_getCfgDataArray);
|
||||
if (isNil "_weapons") exitWith {
|
||||
[
|
||||
"Resupply Boxes: Failed to create box. No weapons defined in the box definition."
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
private _magazines = ([_boxDef >> "magazines"] call BIS_fnc_getCfgDataArray);
|
||||
if (isNil "_magazines") exitWith {
|
||||
[
|
||||
"Resupply Boxes: Failed to create box. No magazines defined in the box definition."
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
private _items = ([_boxDef >> "items"] call BIS_fnc_getCfgDataArray);
|
||||
if (isNil "_items") exitWith {
|
||||
[
|
||||
"Resupply Boxes: Failed to create box. No items defined in the box definition."
|
||||
] call BIS_fnc_error;
|
||||
objNull;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Add stuff to box
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
_x params ["_class", "_qty"];
|
||||
_box addBackpackCargoGlobal [_class, _qty]
|
||||
} foreach _backpacks;
|
||||
|
||||
{
|
||||
_x params ["_class", "_qty"];
|
||||
_box addItemCargoGlobal [_class, _qty]
|
||||
} foreach _items;
|
||||
|
||||
{
|
||||
_x params ["_class", "_qty"];
|
||||
_box addMagazineCargoGlobal [_class, _qty]
|
||||
} foreach _magazines;
|
||||
|
||||
{
|
||||
_x params ["_class", "_qty"];
|
||||
_box addWeaponCargoGlobal [_class, _qty]
|
||||
} foreach _weapons;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Adjust ACE settings
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// set box size
|
||||
[_box,1] call ace_cargo_fnc_setSize;
|
||||
|
||||
// ignore weight restrictions for carry/drag
|
||||
_box setVariable ["ace_ignoreWeightCarry", true, true];
|
||||
|
||||
// Return the box
|
||||
_box;
|
||||
2
framework/resupply/functions/fn_getSupplyCratesCfg.sqf
Normal file
2
framework/resupply/functions/fn_getSupplyCratesCfg.sqf
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "..\script_component.hpp"
|
||||
(missionConfigFile >> "SupplyCrates");
|
||||
12
framework/resupply/functions/fn_init.sqf
Normal file
12
framework/resupply/functions/fn_init.sqf
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes
|
||||
[
|
||||
{time > 5},
|
||||
{
|
||||
if (missionNamespace getVariable [
|
||||
QGVAR(setting_allowSupplyBoxScrollWheelSpawning),
|
||||
false
|
||||
]) then {call FUNC(addSpawnBoxActions)}
|
||||
}
|
||||
] call CBA_fnc_waitUntilAndExecute;
|
||||
3
framework/resupply/script_component.hpp
Normal file
3
framework/resupply/script_component.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#define COMPONENT resupply
|
||||
#define COMPONENT_BEAUTIFIED Resupply
|
||||
#include "../script_mod.hpp"
|
||||
Reference in New Issue
Block a user