Fill storage function

This commit is contained in:
Wyqer 2019-06-18 22:49:50 +02:00
parent fcc5b49a7f
commit baf3871440
No known key found for this signature in database
GPG Key ID: D7E2F8BD7F1E48FA
3 changed files with 33 additions and 32 deletions

View File

@ -0,0 +1,31 @@
params [
["_supply", 0, [0]],
["_ammo", 0 [0]],
["_fuel", 0, [0]],
["_storage", objNull, [objNull]],
["_delay", false, [false]]
];
if (isNull _storage) exitWith {false};
private _crateType = KP_liberation_supply_crate;
private _amount = 0;
private _crate = objNull;
private _pos = getPos _storage;
{
_crateType = [KP_liberation_supply_crate, KP_liberation_ammo_crate, KP_liberation_fuel_crate] select _forEachIndex;
while {_x > 0} do {
_amount = 100;
if (_x / 100) < 1) then {
_amount = _x;
};
_x = _x - _amount;
_crate = [_crateType, _amount, _pos] call F_createCrate;
if (_delay) then {sleep 0.1;};
[_crate, _storage] call F_crateToStorage;
};
} forEach [_supply, _ammo, _fuel];
true

View File

@ -32,35 +32,4 @@ private _fuel = 0;
sleep 0.5;
while {_supply > 0} do {
private _amount = 100;
if ((_supply / 100) < 1) then {
_amount = _supply;
};
_supply = _supply - _amount;
private _crate = [KP_liberation_supply_crate, _amount, _pos] call F_createCrate;
sleep 0.1;
[_crate, _storage] call F_crateToStorage;
};
while {_ammo > 0} do {
private _amount = 100;
if ((_ammo / 100) < 1) then {
_amount = _ammo;
};
_ammo = _ammo - _amount;
private _crate = [KP_liberation_ammo_crate, _amount, _pos] call F_createCrate;
sleep 0.1;
[_crate, _storage] call F_crateToStorage;
};
while {_fuel > 0} do {
private _amount = 100;
if ((_fuel / 100) < 1) then {
_amount = _fuel;
};
_fuel = _fuel - _amount;
private _crate = [KP_liberation_fuel_crate, _amount, _pos] call F_createCrate;
sleep 0.1;
[_crate, _storage] call F_crateToStorage;
};
[_supply, _ammo, _fuel, _storage, true] spawn F_fillStorage;

View File

@ -46,6 +46,7 @@ F_getCorrectedSectorRange = compileFinal preprocessFileLineNumbers "scripts\shar
F_getLocationName = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_getLocationName.sqf";
F_correctLaserBatteries = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_correctLaserBatteries.sqf";
F_crateToStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_crate_to_storage.sqf";
F_fillStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_fillStorage.sqf";
F_crateFromStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_crate_from_storage.sqf";
F_crateCheckValue = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_crate_checkValue.sqf";
F_sortStorage = compileFinal preprocessFileLineNumbers "scripts\shared\functions\F_kp_sort_storage.sqf";