Initial upload. Not currently functional as a mod. Includes some slightly refactored source code as well as the original mission this was debuted in zipped up as reference + example of usage.

This commit is contained in:
Clarky committed 2026-08-08 17:42:15 +10:00
commit 75b737230e
32 files changed
+2049

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
/*
* Author: Clarky
*
*
*
*
*/
params ["_hq", "_amount", "_player"];
// Grab all Depots at the HQ
private _baseDetails = _hq getVariable "baseDetails";
private _depots = _baseDetails get "depots";
if (_depots isEqualTo []) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"No connected supply depots found."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
// Check current materiel available at this base
private _currentMateriel = 0;
{
_currentMateriel = _currentMateriel + (_x getVariable ["currentMateriel", 0]);
} forEach _depots;
if (_currentMateriel < _amount) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"Not enough materiel."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
// Loop through and subtract materiel from the depots
// Might work on a better way to do this eventually (i.e prioritising specific depots depending on reasons)
// By this point we have 100% checked and confirmed there is enough materiel to proceed with the requested supply consumption, so this SHOULD BE SAFE AND NOT ALLOW OVERCONSUMPTION :)
{
// If the _amount is now at 0, exit the loop early
if (_amount <= 0) exitWith {};
// Get currently looped depot's materiel and draw down from it
private _depotMateriel = _x getVariable "currentMateriel";
private _reduceAmount = _depotMateriel min _amount;
_x setVariable ["currentMateriel", _depotMateriel - _reduceAmount, true];
// Update remaining amount to reduce
_amount = _amount - _reduceAmount;
} forEach _depots;
// Return true
true;