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:
commit
75b737230e
32 files changed
+2049
No files matched your search
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author: Clarky
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
params ["_hq", "_amount", "_player"];
|
||||
|
||||
// Grab all HQ/Base/Depots
|
||||
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;
|
||||
};
|
||||
|
||||
// Loop through and add materiel to the depots
|
||||
// Might work on a better way to do this eventually (i.e prioritising specific depots depending on reasons)
|
||||
{
|
||||
// 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 _depotMax = _x getVariable "maxMateriel";
|
||||
private _freeSpace = _depotMax - _depotMateriel;
|
||||
private _addAmount = _amount min _freeSpace;
|
||||
|
||||
_x setVariable ["currentMateriel", _depotMateriel + _addAmount, true];
|
||||
|
||||
// Update remaining amount to reduce
|
||||
_amount = _amount - _addAmount;
|
||||
} forEach _depots;
|
||||
|
||||
// Return true
|
||||
true;
|
||||
Reference in new issue
Block a user