Skip to content

Commit

Permalink
Added a unified resupply module (#1143)
Browse files Browse the repository at this point in the history
Co-authored-by: Broström.A | Evul <[email protected]>
  • Loading branch information
pool011 and AndreasBrostrom authored Mar 2, 2024
1 parent bd0f9c4 commit fd8d172
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 209 deletions.
4 changes: 1 addition & 3 deletions cScripts/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class cScripts {

class doStarterCrateSupplies {};
class doFieldHospital {};
class doSupplyCrate {};

class doEmptyCrate {};

Expand Down Expand Up @@ -102,7 +103,6 @@ class cScripts {
class addStagingZone {};

class doStarterCrate {};
class doSupplyCrate {};

class makeAgent {};
};
Expand Down Expand Up @@ -202,8 +202,6 @@ class cScripts {
file = "cScripts\functions\modules";
class zenModule_EnableUnitSimulation {};

class zenModule_CreateFieldHospital {};
class zenModule_CreateMedicalCrate {};
class zenModule_CreateStarterCrate {};
class zenModule_CreateSupplyCrate {};

Expand Down
7 changes: 0 additions & 7 deletions cScripts/functions/init/fn_init_zenModuels.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ INFO("init", "Initializing custom Zen Modules.");
"\A3\ui_f\data\map\vehicleicons\iconCrate_ca.paa"
] call zen_custom_modules_fnc_register;

["7Cav Logistics", "Spawn Medical Crate",
{
params ["_modulePos", "_objectPos"];
[_modulePos, _objectPos] call EFUNC(zenModule,CreateMedicalCrate);
},
"\z\ACE\addons\medical_gui\ui\cross.paa"
] call zen_custom_modules_fnc_register;

["7Cav Utilities", "Apply Loadout",
{
Expand Down
10 changes: 5 additions & 5 deletions cScripts/functions/logistics/fn_doStarterCrateSupplies.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ private _container = switch (_companySelector) do {
case "TITAN";
case "RAIDER";
case "SPARROW";
case "ALPHA": {GET_CONTAINER(alpha_company);};
case "ALPHA": {GET_CONTAINER("alpha_company");};

case "ATLAS": {GET_CONTAINER(bravo_company_atlas);};
case "ATLAS": {GET_CONTAINER("bravo_company_atlas");};
case "SABER";
case "VIKING";
case "BRAVO": {GET_CONTAINER(bravo_company_viking);};
case "BRAVO": {GET_CONTAINER("bravo_company_viking");};

case "BANDIT";
case "MISFIT";
case "CHARLIE": {GET_CONTAINER(charlie_company);};
case "CHARLIE": {GET_CONTAINER("charlie_company");};

case "FULL";
case "ALL": {
private _fullContainer = [];
{
private _items = _x call EFUNC(logistics,getContainer);
private _items = GET_CONTAINER(_x);
_fullContainer append _items;
} forEach ["alpha_company", "bravo_company_atlas", "bravo_company_viking", "charlie_company"];
};
Expand Down
55 changes: 38 additions & 17 deletions cScripts/functions/logistics/fn_doSupplyCrate.sqf
Original file line number Diff line number Diff line change
@@ -1,40 +1,58 @@
#include "..\script_component.hpp";
/*
* Author: CPL.Brostrom.A
* Author: CPL.Brostrom.A, J.Turn
* This populats a given object with items.
* Use for mission resupplies.
*
* Arguments:
* 0: Crate <OBJECT>
* 1: Scale cargo ammount <NUMBER> (Default: 1)
* 0: Module Position <ARRAY> (Default: [0.0,0.0,0.0])
* 1: Crate Type <STRING> (Default: "crate_resupply_general")
*
* Example:
* [this,0.5] call cScripts_fnc_doSupplyCrate;
* [this,1] call cScripts_fnc_doSupplyCrate;
* [[0.0,0.0,0.0],"crate_resupply_general"] call cScripts_fnc_doSupplyCrate;
* [[0.0,0.0,0.0],"crate_medicalAtlas"] call cScripts_fnc_doSupplyCrate;
*/

if (!isServer) exitWith {};

params [["_crate", objNull, [objNull]]];
params [
["_modulePos", [0.0,0.0,0.0], [[0.0,0.0,0.0]]],
["_crateType","crate_resupply_general",[""]]
];

// Crate model changes based on container of the crate
private _crateModel = "";

clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;
clearItemCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
switch (_crateType) do {
case "crate_medicalAtlas";
case "crate_medicalInfantry": {
_crateModel = "ace_medicalSupplyCrate";
};
case "crate_stinger": {
_crateModel = "Box_NATO_WpsLaunch_F";
};
default {
_crateModel = "Box_NATO_Equip_F";
};
};

// Create crate at module position
INFO_2("Logistics", "Spawning %1 on %2", _crateType, _modulePos);
private _crate = _crateModel createVehicle _modulePos;

// Add items from logistics database entry
if (isServer) then {
[{!isNil{EGVAR(DATABASE,DONE)} && EGVAR(DATABASE,DONE);}, {
_this params ["_crate"];
private _container = GET_CONTAINER(crate_resupply_general);
_this params ["_crate","_crateType"];
private _container = GET_CONTAINER(_crateType);
[_crate, _container] call FUNC(addCargo);
}, [_crate, _quickSelectScale]] call CBA_fnc_waitUntilAndExecute;
}, [_crate, _crateType]] call CBA_fnc_waitUntilAndExecute;
};

// Change ace logistics size of crate
[_crate, 1] remoteExec ["ace_cargo_fnc_setSize",0,true];
[_crate, true] remoteExec ["ace_dragging_fnc_setDraggable",0,true];
[_crate, true] remoteExec ["ace_dragging_fnc_setCarryable",0,true];
// Change ace characteristics of crate
[_crate, 1] call ace_cargo_fnc_setSize;
[_crate, true] call ace_dragging_fnc_setDraggable;
[_crate, true] call ace_dragging_fnc_setCarryable;

// If a correct classname add texture
private _smallBox = [
Expand Down Expand Up @@ -70,3 +88,6 @@ if (typeOf _crate in _smallBox) then {
if (typeOf _crate in _largeBox) then {
_crate setObjectTextureGlobal [1, "\z\cav\addons\supplies\data\Ammobox_7CAV_co.paa"];
};

// Add object to the curator for all Zeuses
_crate call ace_zeus_fnc_addObjectToCurator;
128 changes: 0 additions & 128 deletions cScripts/functions/mission/fn_doSupplyCrate.sqf

This file was deleted.

44 changes: 26 additions & 18 deletions cScripts/functions/modules/fn_zenModule_createSupplyCrate.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\script_component.hpp";
/*
* Author: CPL.Brostrom.A
* Author: CPL.Brostrom.A, J.Turn
* This module function spawn a supply crate.
*
* Arguments:
Expand All @@ -14,31 +14,39 @@
*/

params ["_modulePos", "_objectPos"];
// The crate type that will be passed to the supply crate spawner.
private _crateTypeList = [
'crate_resupply_general',
'crate_medicalAtlas',
'crate_medicalInfantry',
'crate_stinger'
];

// Display text for the crate list selection. This is what the zeus sees.
private _displayTextList =
[
"7th Cavalry Supply Crate",
['Infantry Resupply', "Contains weapons, ammo, and supplies for one infantry platoon"],
['Atlas Team', "Contains enough supplies to sustain two Atlas teams as well supplementing one infantry platoon."],
['Infantry Medical', "Contains enough medical supplies for one infantry platoon."],
['Stinger MANPAD', "Contains 1 launcher and 2 missiles."]
];
[
"7th Cavalry Supply Crates",
[
["SLIDER:PERCENT", ["Supply size", "Regulate the total amount of supplies in the crate"], [0, 1, 1], false]
["LIST", ["Crate Type", "Select the type of unit you are supplying with this crate"],
[
_crateTypeList,
_displayTextList,
0,
4
], false]
],
{
params ["_arg", "_pos"];
_arg params ["_size"];
_arg params ["_crateType"];
_pos params ["_modulePos"];

private _crate = "Box_NATO_Equip_F" createVehicle _modulePos;

[_crate, _size] remoteExec [QFUNC(doSupplyCrate), 0, true];


// Change ace characteristics of crate
[_crate, 1] call ace_cargo_fnc_setSize;
[_crate, true] call ace_dragging_fnc_setDraggable;
[_crate, true] call ace_dragging_fnc_setCarryable;

// Add object to Zeus
[{
_this call ace_zeus_fnc_addObjectToCurator;
}, _crate] call CBA_fnc_execNextFrame;
[_modulePos, _crateType] remoteExec [QFUNC(doSupplyCrate), 2, false];
},
{},
[_modulePos]
Expand Down
Loading

0 comments on commit fd8d172

Please sign in to comment.