Skip to content

Commit

Permalink
Buildings can now (ideally) only last 2 hours max. If supplies are st…
Browse files Browse the repository at this point in the history
…ill added at the building's max time, it will still consume the supplies.
  • Loading branch information
FightKnight441 committed Sep 9, 2024
1 parent ce364e8 commit f059cff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/functions/basebuilding/fn_resupplybuilding.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ if (_resupplyType == "MULTISANDBAG" && _supplyType == "BuildingSupplies") then {
//No supplies, no point continuing execution.
if (_supplies == 0) exitWith {};

private _currentSupplies = _supplySource getVariable ["para_g_current_supplies", 0];
private _supplyConsumptionRate = _supplySource getVariable ["para_g_supply_consumption_rate", 1];

private _proposedSuppliesSum = _currentSupplies + _supplies;
private _proposedRemainingTimeSeconds = _proposedSuppliesSum / _supplyConsumptionRate;
private _maxTimeLimit = 7200; // max time limit a building can have -2 hours in seconds

// Check if the current lifetime would exceed the time limit
if ( _proposedRemainingTimeSeconds >= _maxTimeLimit) then {
// if the supplies that are being added will exceed 2 hours for the building, trim the supplies so that it only reaches 2 hours max. This will still consume the item!!!
_supplies = (_maxTimeLimit * _supplyConsumptionRate) - _currentSupplies;

hint "Time limit has reached its max, item still consumed.";
//this hint is important, it will notfiy players that the time limit has reached max, and adding any more items will just consume them without adding time
};


[_building, -_supplies, true] call para_s_fnc_building_consume_supplies;

_supplySource getVariable "para_g_current_supplies"

0 comments on commit f059cff

Please sign in to comment.