initial files
This commit is contained in:
@@ -0,0 +1,464 @@
|
||||
waitUntil {!isNil "save_is_loaded"};
|
||||
waitUntil {!isNil "KP_liberation_logistics"};
|
||||
waitUntil {save_is_loaded};
|
||||
|
||||
["Logistic management started", "LOGISTIC"] call KPLIB_fnc_log;
|
||||
|
||||
KP_liberation_convoy_ambush_inProgress = false;
|
||||
KP_liberation_convoy_ambush_check = 0;
|
||||
private _start = 0;
|
||||
while {GRLIB_endgame == 0} do {
|
||||
|
||||
if (((count (allPlayers - entities "HeadlessClient_F")) > 0) && ((count KP_liberation_logistics) > 0)) then {
|
||||
_start = diag_tickTime;
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic interval started: %1", diag_tickTime], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
|
||||
private _tempLogistics = +KP_liberation_logistics;
|
||||
|
||||
{
|
||||
private _locPos = -1;
|
||||
private _locRes = -1;
|
||||
switch (_x select 7) do {
|
||||
case 0: {};
|
||||
case 1;
|
||||
case 3: {
|
||||
if ((_x select 8) > 1) then {
|
||||
switch (_x select 7) do {case 1: {_locPos = 2; _locRes = 4;}; case 3: {_locPos = 3; _locRes = 5;};};
|
||||
switch (_x select 9) do {case 2: {_x set [9,0];}; case 3: {_x set [9,1];};};
|
||||
private _storage_areas = nearestObjects [(_x select _locPos), [KP_liberation_small_storage_building, KP_liberation_large_storage_building], 150];
|
||||
|
||||
if (((_x select 9) == 0) && !((_x select 6) isEqualTo [0,0,0])) then {
|
||||
|
||||
if ((count (_storage_areas)) == 0) exitWith {_x set [9,2];};
|
||||
|
||||
private _toProcess = ceil ((ceil (((_x select 6) select 0) / 100)) + (ceil (((_x select 6) select 1) / 100)) + (ceil (((_x select 6) select 2) / 100)));
|
||||
if (_toProcess > 3) then {_toProcess = 3;};
|
||||
private _spaceSum = 0;
|
||||
{
|
||||
if (typeOf _x == KP_liberation_large_storage_building) then {
|
||||
_spaceSum = _spaceSum + (count KP_liberation_large_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
if (typeOf _x == KP_liberation_small_storage_building) then {
|
||||
_spaceSum = _spaceSum + (count KP_liberation_small_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
} forEach _storage_areas;
|
||||
|
||||
if (_spaceSum < _toProcess) exitWith {_x set [9,2];};
|
||||
|
||||
_x set [8,((_x select 8) - 1)];
|
||||
private _currentIndex = _forEachIndex;
|
||||
private _processed = 0;
|
||||
while {_processed < _toProcess} do {
|
||||
{
|
||||
private _space = 0;
|
||||
if (typeOf _x == KP_liberation_large_storage_building) then {
|
||||
_space = (count KP_liberation_large_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
if (typeOf _x == KP_liberation_small_storage_building) then {
|
||||
_space = (count KP_liberation_small_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
|
||||
if ((_space > 0) && ((((_tempLogistics select _currentIndex) select 6) select 0) > 0)) then {
|
||||
private _amount = 100;
|
||||
if (((((_tempLogistics select _currentIndex) select 6) select 0) / 100) < 1) then {
|
||||
_amount = ((_tempLogistics select _currentIndex) select 6) select 0;
|
||||
};
|
||||
(_tempLogistics select _currentIndex) set [6,
|
||||
[(((_tempLogistics select _currentIndex) select 6) select 0) - _amount,
|
||||
(((_tempLogistics select _currentIndex) select 6) select 1),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 2)]
|
||||
];
|
||||
private _crate = [KP_liberation_supply_crate, _amount, getPos _x] call KPLIB_fnc_createCrate;
|
||||
[_crate, _x] call KPLIB_fnc_crateToStorage;
|
||||
_processed = _processed + 1;
|
||||
_space = _space - 1;
|
||||
};
|
||||
if (_processed >= _toProcess) exitWith {};
|
||||
|
||||
if ((_space > 0) && ((((_tempLogistics select _currentIndex) select 6) select 1) > 0)) then {
|
||||
private _amount = 100;
|
||||
if (((((_tempLogistics select _currentIndex) select 6) select 1) / 100) < 1) then {
|
||||
_amount = ((_tempLogistics select _currentIndex) select 6) select 1;
|
||||
};
|
||||
(_tempLogistics select _currentIndex) set [6,
|
||||
[(((_tempLogistics select _currentIndex) select 6) select 0),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 1) - _amount,
|
||||
(((_tempLogistics select _currentIndex) select 6) select 2)]
|
||||
];
|
||||
private _crate = [KP_liberation_ammo_crate, _amount, getPos _x] call KPLIB_fnc_createCrate;
|
||||
[_crate, _x] call KPLIB_fnc_crateToStorage;
|
||||
_processed = _processed + 1;
|
||||
_space = _space - 1;
|
||||
};
|
||||
if (_processed >= _toProcess) exitWith {};
|
||||
|
||||
if ((_space > 0) && ((((_tempLogistics select _currentIndex) select 6) select 2) > 0)) then {
|
||||
private _amount = 100;
|
||||
if (((((_tempLogistics select _currentIndex) select 6) select 2) / 100) < 1) then {
|
||||
_amount = ((_tempLogistics select _currentIndex) select 6) select 2;
|
||||
};
|
||||
(_tempLogistics select _currentIndex) set [6,
|
||||
[(((_tempLogistics select _currentIndex) select 6) select 0),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 1),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 2) - _amount]
|
||||
];
|
||||
private _crate = [KP_liberation_fuel_crate, _amount, getPos _x] call KPLIB_fnc_createCrate;
|
||||
[_crate, _x] call KPLIB_fnc_crateToStorage;
|
||||
_processed = _processed + 1;
|
||||
_space = _space - 1;
|
||||
};
|
||||
if (_processed >= _toProcess) exitWith {};
|
||||
} forEach _storage_areas;
|
||||
};
|
||||
please_recalculate = true;
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
} else {
|
||||
_x set [9,1];
|
||||
};
|
||||
|
||||
if (((_x select 9) == 1) && !((_x select _locRes) isEqualTo [0,0,0])) then {
|
||||
|
||||
if ((count (_storage_areas)) == 0) exitWith {_x set [9,3];};
|
||||
|
||||
private _supplyValue = 0;
|
||||
private _ammoValue = 0;
|
||||
private _fuelValue = 0;
|
||||
|
||||
{
|
||||
{
|
||||
switch ((typeOf _x)) do {
|
||||
case KP_liberation_supply_crate: {_supplyValue = _supplyValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
case KP_liberation_ammo_crate: {_ammoValue = _ammoValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
case KP_liberation_fuel_crate: {_fuelValue = _fuelValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
default {[format ["Invalid object (%1) at storage area", (typeOf _x)], "ERROR"] call KPLIB_fnc_log;};
|
||||
};
|
||||
} forEach (attachedObjects _x);
|
||||
} forEach _storage_areas;
|
||||
|
||||
private _toProcess = ceil ((ceil (((_x select _locRes) select 0) / 100)) + (ceil (((_x select _locRes) select 1) / 100)) + (ceil (((_x select _locRes) select 2) / 100)));
|
||||
if (_toProcess > 3) then {_toProcess = 3;};
|
||||
|
||||
private _maxGetSupply = ((_x select _locRes) select 0);
|
||||
if (_maxGetSupply > 300) then {_maxGetSupply = 300;};
|
||||
private _maxGetAmmo = ((_x select _locRes) select 1);
|
||||
if (_maxGetAmmo > 300) then {_maxGetAmmo = 300;};
|
||||
private _maxGetFuel = ((_x select _locRes) select 2);
|
||||
if (_maxGetFuel > 300) then {_maxGetFuel = 300;};
|
||||
|
||||
private _getSupply = 0;
|
||||
private _getAmmo = 0;
|
||||
private _getFuel = 0;
|
||||
private _i = 0;
|
||||
private _j = 0;
|
||||
|
||||
while {(_i < _toProcess) && (_j < _toProcess)} do {
|
||||
if ((_maxGetSupply - _getSupply) > 0) then {
|
||||
if ((floor ((_maxGetSupply - _getSupply) / 100)) > 0) then {
|
||||
if ((_supplyValue - _getSupply) >= 100) then {
|
||||
_getSupply = _getSupply + 100;
|
||||
_i = _i + 1;
|
||||
};
|
||||
} else {
|
||||
if ((_maxGetSupply - _getSupply) <= (_supplyValue - _getSupply)) then {
|
||||
_getSupply = _maxGetSupply;
|
||||
_i = _i + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (((_maxGetAmmo - _getAmmo) > 0) && (_i < _toProcess)) then {
|
||||
if ((floor ((_maxGetAmmo - _getAmmo) / 100)) > 0) then {
|
||||
if ((_ammoValue - _getAmmo) >= 100) then {
|
||||
_getAmmo = _getAmmo + 100;
|
||||
_i = _i + 1;
|
||||
};
|
||||
} else {
|
||||
if ((_maxGetAmmo - _getAmmo) <= (_ammoValue - _getAmmo)) then {
|
||||
_getAmmo = _maxGetAmmo;
|
||||
_i = _i + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (((_maxGetFuel - _getFuel) > 0) && (_i < _toProcess)) then {
|
||||
if ((floor ((_maxGetFuel - _getFuel) / 100)) > 0) then {
|
||||
if ((_fuelValue - _getFuel) >= 100) then {
|
||||
_getFuel = _getFuel + 100;
|
||||
_i = _i + 1;
|
||||
};
|
||||
} else {
|
||||
if ((_maxGetFuel - _getFuel) <= (_fuelValue - _getFuel)) then {
|
||||
_getFuel = _maxGetFuel;
|
||||
_i = _i + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
_j = _j + 1;
|
||||
};
|
||||
|
||||
if ((_j == _toProcess) && (_i != _toProcess)) exitWith {_x set [9,3];};
|
||||
|
||||
_x set [_locRes,[((_x select _locRes) select 0) - _getSupply,((_x select _locRes) select 1) - _getAmmo,((_x select _locRes) select 2) - _getFuel]];
|
||||
_x set [6,[((_x select 6) select 0) + _getSupply,((_x select 6) select 1) + _getAmmo,((_x select 6) select 2) + _getFuel]];
|
||||
_x set [8,((_x select 8) - 1)];
|
||||
|
||||
{
|
||||
private _storage_positions = [];
|
||||
private _storedCrates = (attachedObjects _x);
|
||||
reverse _storedCrates;
|
||||
|
||||
{
|
||||
private _crateValue = _x getVariable ["KP_liberation_crate_value",0];
|
||||
|
||||
switch ((typeOf _x)) do {
|
||||
case KP_liberation_supply_crate: {
|
||||
if (_getSupply > 0) then {
|
||||
if (_crateValue > _getSupply) then {
|
||||
_crateValue = _crateValue - _getSupply;
|
||||
_x setVariable ["KP_liberation_crate_value", _crateValue, true];
|
||||
_getSupply = 0;
|
||||
} else {
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
_getSupply = _getSupply - _crateValue;
|
||||
};
|
||||
};
|
||||
};
|
||||
case KP_liberation_ammo_crate: {
|
||||
if (_getAmmo > 0) then {
|
||||
if (_crateValue > _getAmmo) then {
|
||||
_crateValue = _crateValue - _getAmmo;
|
||||
_x setVariable ["KP_liberation_crate_value", _crateValue, true];
|
||||
_getAmmo = 0;
|
||||
} else {
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
_getAmmo = _getAmmo - _crateValue;
|
||||
};
|
||||
};
|
||||
};
|
||||
case KP_liberation_fuel_crate: {
|
||||
if (_getFuel > 0) then {
|
||||
if (_crateValue > _getFuel) then {
|
||||
_crateValue = _crateValue - _getFuel;
|
||||
_x setVariable ["KP_liberation_crate_value", _crateValue, true];
|
||||
_getFuel = 0;
|
||||
} else {
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
_getFuel = _getFuel - _crateValue;
|
||||
};
|
||||
};
|
||||
};
|
||||
default {[format ["Invalid object (%1) at storage area", (typeOf _x)], "ERROR"] call KPLIB_fnc_log;};
|
||||
};
|
||||
} forEach _storedCrates;
|
||||
|
||||
([_x] call KPLIB_fnc_getStoragePositions) params ["_storage_positions"];
|
||||
|
||||
private _area = _x;
|
||||
_i = 0;
|
||||
{
|
||||
_height = [typeOf _x] call KPLIB_fnc_getCrateHeight;
|
||||
detach _x;
|
||||
_x attachTo [_area, [(_storage_positions select _i) select 0, (_storage_positions select _i) select 1, _height]];
|
||||
_i = _i + 1;
|
||||
} forEach attachedObjects (_x);
|
||||
|
||||
if ((_getSupply == 0) && (_getAmmo == 0) && (_getFuel == 0)) exitWith {};
|
||||
|
||||
} forEach _storage_areas;
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
};
|
||||
} else {
|
||||
private _nextState = 0;
|
||||
private _time = -1;
|
||||
if (((_x select 4) isEqualTo [0,0,0]) && ((_x select 5) isEqualTo [0,0,0]) && ((_x select 6) isEqualTo [0,0,0])) then {
|
||||
_x set [2, [0,0,0]];
|
||||
_x set [3, [0,0,0]];
|
||||
} else {
|
||||
_nextState = switch (_x select 7) do {case 1: {2}; case 3: {4};};
|
||||
_time = ceil (((_x select 2) distance2D (_x select 3)) / 400);
|
||||
};
|
||||
|
||||
_x set [7,_nextState];
|
||||
_x set [8,_time];
|
||||
_x set [9,0];
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
};
|
||||
};
|
||||
case 2;
|
||||
case 4: {
|
||||
if ((_x select 8) > 1) then {
|
||||
|
||||
if (((_x select 8) <= ((ceil (((_x select 2) distance2D (_x select 3)) / 400)) - 3)) && ((_x select 8) >= 3) && !((_x select 6) isEqualTo [0,0,0]) && !KP_liberation_convoy_ambush_inProgress && (KP_liberation_civ_rep <= -25) && (((_x select 8) % 2) == 0)) then {
|
||||
private _dice = round (random 100);
|
||||
private _chance = KP_liberation_convoy_ambush_chance;
|
||||
if (chance > 0) then {
|
||||
_chance = _chance + ([] call KPLIB_fnc_crGetMulti);
|
||||
};
|
||||
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1: ambush possible - current ETA: %2 - Dice: %3 - Chance: %4", (_x select 0), (_x select 8), _dice, _chance], "ASYMMETRIC"] call KPLIB_fnc_log;};
|
||||
if (_dice <= _chance) then {
|
||||
private _convoy = +_x;
|
||||
sleep 0.1;
|
||||
[_convoy] spawn logistic_convoy_ambush;
|
||||
waitUntil {sleep 0.1; KP_liberation_convoy_ambush_check != 0};
|
||||
if (KP_liberation_convoy_ambush_check == 2) then {
|
||||
_x set [1,0];
|
||||
_x set [2,[0,0,0]];
|
||||
_x set [3,[0,0,0]];
|
||||
_x set [4,[0,0,0]];
|
||||
_x set [5,[0,0,0]];
|
||||
_x set [6,[0,0,0]];
|
||||
_x set [7,0];
|
||||
_x set [8,-1];
|
||||
} else {
|
||||
_x set [8,((_x select 8) - 1)];
|
||||
KP_liberation_convoy_ambush_check = 0;
|
||||
};
|
||||
} else {
|
||||
_x set [8,((_x select 8) - 1)];
|
||||
};
|
||||
} else {
|
||||
_x set [8,((_x select 8) - 1)];
|
||||
};
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
|
||||
} else {
|
||||
private _nextState = -1;
|
||||
private _time = 0;
|
||||
switch (_x select 7) do {
|
||||
case 2: {
|
||||
_nextState = 3;
|
||||
_time = ceil (((ceil (((_x select 5) select 0) / 100)) + (ceil (((_x select 5) select 1) / 100)) + (ceil (((_x select 5) select 2) / 100))) / 3);
|
||||
};
|
||||
case 4: {
|
||||
_nextState = 1;
|
||||
_time = ceil (((ceil (((_x select 4) select 0) / 100)) + (ceil (((_x select 4) select 1) / 100)) + (ceil (((_x select 4) select 2) / 100))) / 3);
|
||||
};
|
||||
};
|
||||
if (_time > (_x select 1)) then {_time = (_x select 1);};
|
||||
|
||||
_time = _time + (ceil (((ceil (((_x select 6) select 0) / 100)) + (ceil (((_x select 6) select 1) / 100)) + (ceil (((_x select 6) select 2) / 100))) / 3));
|
||||
_time = _time + 1;
|
||||
|
||||
_x set [7,_nextState];
|
||||
_x set [8,_time];
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
};
|
||||
};
|
||||
case 5;
|
||||
case 6: {
|
||||
if ((_x select 8) > 1) then {
|
||||
_locPos = switch (_x select 7) do {case 5: {2}; case 6: {3};};
|
||||
_x set [9,0];
|
||||
private _storage_areas = nearestObjects [(_x select _locPos), [KP_liberation_small_storage_building, KP_liberation_large_storage_building], 150];
|
||||
|
||||
if ((count (_storage_areas)) == 0) exitWith {_x set [9,2];};
|
||||
|
||||
private _toProcess = ceil ((ceil (((_x select 6) select 0) / 100)) + (ceil (((_x select 6) select 1) / 100)) + (ceil (((_x select 6) select 2) / 100)));
|
||||
if (_toProcess > 3) then {_toProcess = 3;};
|
||||
private _spaceSum = 0;
|
||||
{
|
||||
if (typeOf _x == KP_liberation_large_storage_building) then {
|
||||
_spaceSum = _spaceSum + (count KP_liberation_large_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
if (typeOf _x == KP_liberation_small_storage_building) then {
|
||||
_spaceSum = _spaceSum + (count KP_liberation_small_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
} forEach _storage_areas;
|
||||
|
||||
if (_spaceSum < _toProcess) exitWith {_x set [9,2];};
|
||||
|
||||
_x set [8,((_x select 8) - 1)];
|
||||
private _currentIndex = _forEachIndex;
|
||||
private _processed = 0;
|
||||
while {_processed < _toProcess} do {
|
||||
{
|
||||
private _space = 0;
|
||||
if (typeOf _x == KP_liberation_large_storage_building) then {
|
||||
_space = (count KP_liberation_large_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
if (typeOf _x == KP_liberation_small_storage_building) then {
|
||||
_space = (count KP_liberation_small_storage_positions) - (count (attachedObjects _x));
|
||||
};
|
||||
|
||||
if ((_space > 0) && ((((_tempLogistics select _currentIndex) select 6) select 0) > 0)) then {
|
||||
private _amount = 100;
|
||||
if (((((_tempLogistics select _currentIndex) select 6) select 0) / 100) < 1) then {
|
||||
_amount = ((_tempLogistics select _currentIndex) select 6) select 0;
|
||||
};
|
||||
(_tempLogistics select _currentIndex) set [6,
|
||||
[(((_tempLogistics select _currentIndex) select 6) select 0) - _amount,
|
||||
(((_tempLogistics select _currentIndex) select 6) select 1),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 2)]
|
||||
];
|
||||
private _crate = [KP_liberation_supply_crate, _amount, getPos _x] call KPLIB_fnc_createCrate;
|
||||
[_crate, _x] call KPLIB_fnc_crateToStorage;
|
||||
_processed = _processed + 1;
|
||||
_space = _space - 1;
|
||||
};
|
||||
if (_processed >= _toProcess) exitWith {};
|
||||
|
||||
if ((_space > 0) && ((((_tempLogistics select _currentIndex) select 6) select 1) > 0)) then {
|
||||
private _amount = 100;
|
||||
if (((((_tempLogistics select _currentIndex) select 6) select 1) / 100) < 1) then {
|
||||
_amount = ((_tempLogistics select _currentIndex) select 6) select 1;
|
||||
};
|
||||
(_tempLogistics select _currentIndex) set [6,
|
||||
[(((_tempLogistics select _currentIndex) select 6) select 0),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 1) - _amount,
|
||||
(((_tempLogistics select _currentIndex) select 6) select 2)]
|
||||
];
|
||||
private _crate = [KP_liberation_ammo_crate, _amount, getPos _x] call KPLIB_fnc_createCrate;
|
||||
[_crate, _x] call KPLIB_fnc_crateToStorage;
|
||||
_processed = _processed + 1;
|
||||
_space = _space - 1;
|
||||
};
|
||||
if (_processed >= _toProcess) exitWith {};
|
||||
|
||||
if ((_space > 0) && ((((_tempLogistics select _currentIndex) select 6) select 2) > 0)) then {
|
||||
private _amount = 100;
|
||||
if (((((_tempLogistics select _currentIndex) select 6) select 2) / 100) < 1) then {
|
||||
_amount = ((_tempLogistics select _currentIndex) select 6) select 2;
|
||||
};
|
||||
(_tempLogistics select _currentIndex) set [6,
|
||||
[(((_tempLogistics select _currentIndex) select 6) select 0),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 1),
|
||||
(((_tempLogistics select _currentIndex) select 6) select 2) - _amount]
|
||||
];
|
||||
private _crate = [KP_liberation_fuel_crate, _amount, getPos _x] call KPLIB_fnc_createCrate;
|
||||
[_crate, _x] call KPLIB_fnc_crateToStorage;
|
||||
_processed = _processed + 1;
|
||||
_space = _space - 1;
|
||||
};
|
||||
if (_processed >= _toProcess) exitWith {};
|
||||
} forEach _storage_areas;
|
||||
};
|
||||
please_recalculate = true;
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
} else {
|
||||
_x set [2,[0,0,0]];
|
||||
_x set [3,[0,0,0]];
|
||||
_x set [4,[0,0,0]];
|
||||
_x set [5,[0,0,0]];
|
||||
_x set [6,[0,0,0]];
|
||||
_x set [7,0];
|
||||
_x set [8,-1];
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic Group Update: %1", _x], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
};
|
||||
};
|
||||
default {};
|
||||
};
|
||||
} forEach _tempLogistics;
|
||||
|
||||
KP_liberation_logistics = +_tempLogistics;
|
||||
|
||||
if (KP_liberation_logistic_debug > 0) then {[format ["Logistic interval finished - Time needed: %1 seconds", diag_tickTime - _start], "LOGISTIC"] call KPLIB_fnc_log;};
|
||||
};
|
||||
uiSleep 60;
|
||||
};
|
||||
@@ -0,0 +1,93 @@
|
||||
waitUntil {!isNil "save_is_loaded"};
|
||||
waitUntil {!isNil "KP_liberation_production"};
|
||||
waitUntil {save_is_loaded};
|
||||
|
||||
sectors_recalculating = false;
|
||||
sectors_timer = false;
|
||||
|
||||
["Production management started", "PRODUCTION"] call KPLIB_fnc_log;
|
||||
private _start = 0;
|
||||
while {GRLIB_endgame == 0} do {
|
||||
|
||||
recalculate_sectors = false;
|
||||
|
||||
if (((count (allPlayers - entities "HeadlessClient_F")) > 0) && ((count KP_liberation_production) > 0)) then {
|
||||
waitUntil {sleep 0.5; !sectors_recalculating};
|
||||
sectors_recalculating = true;
|
||||
|
||||
private _time_update = false;
|
||||
if (sectors_timer) then {_time_update = true; sectors_timer = false;};
|
||||
|
||||
_start = diag_tickTime;
|
||||
if (KP_liberation_production_debug > 0) then {[format ["Production interval started: %1 - _time_update: %2", diag_tickTime, _time_update], "PRODUCTION"] call KPLIB_fnc_log;};
|
||||
|
||||
private _tempProduction = [];
|
||||
{
|
||||
private _storageArray = [];
|
||||
private _supplyValue = 0;
|
||||
private _ammoValue = 0;
|
||||
private _fuelValue = 0;
|
||||
private _time = _x select 8;
|
||||
|
||||
private _storage = nearestObjects [(markerPos (_x select 1)), [KP_liberation_small_storage_building], 100];
|
||||
_storage = _storage select {(_x getVariable ["KP_liberation_storage_type",-1]) == 1};
|
||||
if ((count _storage) > 0) then {
|
||||
_storage = (_storage select 0);
|
||||
_storageArray = [(getPosATL _storage),(getDir _storage),(vectorUpVisual _storage)];
|
||||
|
||||
if (_time_update) then {
|
||||
|
||||
if ((_time - 1) < 1) then {
|
||||
_time = KP_liberation_production_interval;
|
||||
|
||||
if (((count (attachedObjects _storage)) < 12) && !((_x select 7) == 3)) then {
|
||||
private _crateType = KP_liberation_supply_crate;
|
||||
switch (_x select 7) do {
|
||||
case 1: {_crateType = KP_liberation_ammo_crate; stats_ammo_produced = stats_ammo_produced + 100;};
|
||||
case 2: {_crateType = KP_liberation_fuel_crate; stats_fuel_produced = stats_fuel_produced + 100;};
|
||||
default {_crateType = KP_liberation_supply_crate; stats_supplies_produced = stats_supplies_produced + 100;};
|
||||
};
|
||||
|
||||
private _crate = [_crateType, 100, getPosATL _storage] call KPLIB_fnc_createCrate;
|
||||
[_crate, _storage] call KPLIB_fnc_crateToStorage;
|
||||
};
|
||||
} else {
|
||||
_time = _time - 1;
|
||||
};
|
||||
};
|
||||
|
||||
{
|
||||
switch ((typeOf _x)) do {
|
||||
case KP_liberation_supply_crate: {_supplyValue = _supplyValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
case KP_liberation_ammo_crate: {_ammoValue = _ammoValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
case KP_liberation_fuel_crate: {_fuelValue = _fuelValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
default {[format ["Invalid object (%1) at storage area", (typeOf _x)], "ERROR"] call KPLIB_fnc_log;};
|
||||
};
|
||||
} forEach (attachedObjects _storage);
|
||||
};
|
||||
|
||||
_tempProduction pushBack [
|
||||
(markerText (_x select 1)),
|
||||
(_x select 1),
|
||||
(_x select 2),
|
||||
_storageArray,
|
||||
(_x select 4),
|
||||
(_x select 5),
|
||||
(_x select 6),
|
||||
(_x select 7),
|
||||
_time,
|
||||
_supplyValue,
|
||||
_ammoValue,
|
||||
_fuelValue
|
||||
];
|
||||
if (KP_liberation_production_debug > 0) then {[format ["Production Update: %1", _tempProduction select _forEachIndex], "PRODUCTION"] call KPLIB_fnc_log;};
|
||||
} forEach KP_liberation_production;
|
||||
|
||||
_tempProduction sort true;
|
||||
|
||||
KP_liberation_production = +_tempProduction;
|
||||
sectors_recalculating = false;
|
||||
};
|
||||
if (KP_liberation_production_debug > 0) then {[format ["Production interval finished - Time needed: %1 seconds", diag_tickTime - _start], "PRODUCTION"] call KPLIB_fnc_log;};
|
||||
waitUntil {sleep 1; recalculate_sectors};
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
waitUntil {!isNil "save_is_loaded"};
|
||||
waitUntil {save_is_loaded};
|
||||
|
||||
KP_liberation_fob_resources = [];
|
||||
KP_liberation_supplies_global = 0;
|
||||
KP_liberation_ammo_global = 0;
|
||||
KP_liberation_fuel_global = 0;
|
||||
KP_liberation_heli_slots = 0;
|
||||
KP_liberation_plane_slots = 0;
|
||||
infantry_cap = 50 * GRLIB_resources_multiplier;
|
||||
|
||||
please_recalculate = true;
|
||||
|
||||
waitUntil {time > 1};
|
||||
|
||||
while {true} do {
|
||||
waitUntil {sleep 0.5; please_recalculate};
|
||||
please_recalculate = false;
|
||||
|
||||
private _local_fob_resources = [];
|
||||
private _local_supplies_global = 0;
|
||||
private _local_ammo_global = 0;
|
||||
private _local_fuel_global = 0;
|
||||
private _local_heli_slots = 0;
|
||||
private _local_plane_slots = 0;
|
||||
private _local_infantry_cap = 50 * GRLIB_resources_multiplier;
|
||||
|
||||
{
|
||||
private _fob_buildings = _x nearobjects GRLIB_fob_range;
|
||||
private _storage_areas = _fob_buildings select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0};
|
||||
private _heliSlots = {(typeOf _x) == KP_liberation_heli_slot_building;} count _fob_buildings;
|
||||
private _planeSlots = {(typeOf _x) == KP_liberation_plane_slot_building;} count _fob_buildings;
|
||||
private _hasAirBuilding = {(typeOf _x) == KP_liberation_air_vehicle_building;} count _fob_buildings;
|
||||
if (_hasAirBuilding > 0) then {_hasAirBuilding = true;} else {_hasAirBuilding = false;};
|
||||
private _hasRecBuilding = {(typeOf _x) == KP_liberation_recycle_building;} count _fob_buildings;
|
||||
if (_hasRecBuilding > 0) then {_hasRecBuilding = true;} else {_hasRecBuilding = false;};
|
||||
|
||||
private _supplyValue = 0;
|
||||
private _ammoValue = 0;
|
||||
private _fuelValue = 0;
|
||||
|
||||
{
|
||||
{
|
||||
switch ((typeOf _x)) do {
|
||||
case KP_liberation_supply_crate: {_supplyValue = _supplyValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
case KP_liberation_ammo_crate: {_ammoValue = _ammoValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
case KP_liberation_fuel_crate: {_fuelValue = _fuelValue + (_x getVariable ["KP_liberation_crate_value",0]);};
|
||||
default {[format ["Invalid object (%1) at storage area", (typeOf _x)], "ERROR"] call KPLIB_fnc_log;};
|
||||
};
|
||||
} forEach (attachedObjects _x);
|
||||
} forEach _storage_areas;
|
||||
|
||||
_local_fob_resources pushBack [_x, _supplyValue, _ammoValue, _fuelValue, _hasAirBuilding, _hasRecBuilding];
|
||||
_local_supplies_global = _local_supplies_global + _supplyValue;
|
||||
_local_ammo_global = _local_ammo_global + _ammoValue;
|
||||
_local_fuel_global = _local_fuel_global + _fuelValue;
|
||||
_local_heli_slots = _local_heli_slots + _heliSlots;
|
||||
_local_plane_slots = _local_plane_slots + _planeSlots;
|
||||
} forEach GRLIB_all_fobs;
|
||||
|
||||
{
|
||||
if ( _x in sectors_capture ) then {
|
||||
_local_infantry_cap = _local_infantry_cap + (10 * GRLIB_resources_multiplier);
|
||||
};
|
||||
} foreach blufor_sectors;
|
||||
|
||||
KP_liberation_fob_resources = _local_fob_resources;
|
||||
KP_liberation_supplies_global = _local_supplies_global;
|
||||
KP_liberation_ammo_global = _local_ammo_global;
|
||||
KP_liberation_fuel_global = _local_fuel_global;
|
||||
KP_liberation_heli_slots = _local_heli_slots;
|
||||
KP_liberation_plane_slots = _local_plane_slots;
|
||||
infantry_cap = _local_infantry_cap;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
waitUntil { !isNil "save_is_loaded" };
|
||||
waitUntil {save_is_loaded};
|
||||
|
||||
while {true} do {
|
||||
sleep 3;
|
||||
please_recalculate = true;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
waitUntil {!isNil "save_is_loaded"};
|
||||
waitUntil {save_is_loaded};
|
||||
|
||||
while {true} do {
|
||||
uiSleep 60;
|
||||
recalculate_sectors = true;
|
||||
sectors_timer = true;
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
unitcap = 0;
|
||||
KP_liberation_heli_count = 0;
|
||||
KP_liberation_plane_count = 0;
|
||||
|
||||
while {true} do {
|
||||
private _local_unitcap = 0;
|
||||
private _local_heli_count = 0;
|
||||
private _local_plane_count = 0;
|
||||
{
|
||||
if ((side group _x == GRLIB_side_friendly) && (alive _x) && ((_x distance startbase) > 250 || (isPlayer _x))) then {
|
||||
_local_unitcap = _local_unitcap + 1;
|
||||
};
|
||||
} forEach allUnits;
|
||||
{
|
||||
if ((toLower (typeOf _x)) in KPLIB_b_air_classes && !([typeOf _x] call KPLIB_fnc_isClassUAV) && alive _x && !(_x getVariable ["KP_liberation_preplaced", false])) then {
|
||||
if (_x isKindOf "Helicopter") then {
|
||||
_local_heli_count = _local_heli_count + 1;
|
||||
};
|
||||
if (_x isKindOf "Plane") then {
|
||||
_local_plane_count = _local_plane_count + 1;
|
||||
};
|
||||
};
|
||||
} forEach vehicles;
|
||||
unitcap = _local_unitcap;
|
||||
KP_liberation_heli_count = _local_heli_count;
|
||||
KP_liberation_plane_count = _local_plane_count;
|
||||
sleep 1;
|
||||
};
|
||||
Reference in New Issue
Block a user