From f059cff470ff560ed037cbb3b2c94a3cba17fdc7 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 9 Sep 2024 02:15:31 -0400 Subject: [PATCH 1/6] Buildings can now (ideally) only last 2 hours max. If supplies are still added at the building's max time, it will still consume the supplies. --- .../basebuilding/fn_resupplybuilding.sqf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/functions/basebuilding/fn_resupplybuilding.sqf b/server/functions/basebuilding/fn_resupplybuilding.sqf index 7c576f7..be054ad 100644 --- a/server/functions/basebuilding/fn_resupplybuilding.sqf +++ b/server/functions/basebuilding/fn_resupplybuilding.sqf @@ -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" From d01e5916963bc02909ff99156344639141bf126b Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 9 Sep 2024 22:21:18 -0400 Subject: [PATCH 2/6] Adjusted the notification for reaching the time limit to use paradigm notification --- server/functions/basebuilding/fn_resupplybuilding.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/functions/basebuilding/fn_resupplybuilding.sqf b/server/functions/basebuilding/fn_resupplybuilding.sqf index be054ad..f63707e 100644 --- a/server/functions/basebuilding/fn_resupplybuilding.sqf +++ b/server/functions/basebuilding/fn_resupplybuilding.sqf @@ -100,15 +100,15 @@ private _supplyConsumptionRate = _supplySource getVariable ["para_g_supply_consu private _proposedSuppliesSum = _currentSupplies + _supplies; private _proposedRemainingTimeSeconds = _proposedSuppliesSum / _supplyConsumptionRate; -private _maxTimeLimit = 7200; // max time limit a building can have -2 hours in seconds +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 + // notify players that time limit has been reached and item was still consumed + ["TaskFailed",["",localize "STR_para_build_maxtimereached"]] call para_c_fnc_show_notification; }; From 1951bb450e04106a73dffc13ca3f26209c09c1c9 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 9 Sep 2024 22:23:58 -0400 Subject: [PATCH 3/6] Building time limit notification is now Paradigm based --- .../basebuilding/fn_abort_building.sqf | 5 +++ .../basebuilding/fn_place_object.sqf | 31 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/client/functions/basebuilding/fn_abort_building.sqf b/client/functions/basebuilding/fn_abort_building.sqf index 91e97cd..80466c5 100644 --- a/client/functions/basebuilding/fn_abort_building.sqf +++ b/client/functions/basebuilding/fn_abort_building.sqf @@ -39,4 +39,9 @@ if (!isNil "para_l_placing_keyrotate_handler") then { para_l_placing_keyrotate_handler = nil; }; +if (!(isNil "para_l_placing_scroll_handler")) then { + (findDisplay 46) displayRemoveEventHandler ["MouseZChanged", para_l_placing_scroll_handler]; + para_l_placing_keyrotate_handler = nil; +}; + false; diff --git a/client/functions/basebuilding/fn_place_object.sqf b/client/functions/basebuilding/fn_place_object.sqf index 663f385..6585412 100644 --- a/client/functions/basebuilding/fn_place_object.sqf +++ b/client/functions/basebuilding/fn_place_object.sqf @@ -185,7 +185,7 @@ para_l_placing_click_handler = (findDisplay 46) displayAddEventHandler ["MouseBu }; }]; -// Adding key handler for rotation by 45 degrees (R key) +// Adding key handler for rotation by 45 degrees (R key) -Legend para_l_placing_keyrotate_handler = (findDisplay 46) displayAddEventHandler ["KeyDown", { params ["_displayorcontrol", "_keyCode"]; if (!scriptDone para_l_placing_script && _keyCode in [0x13]) then { // 0x13 is the 'R' key @@ -193,6 +193,35 @@ para_l_placing_keyrotate_handler = (findDisplay 46) displayAddEventHandler ["Key }; }]; +// Update the event handler for the mouse scroll wheel, only works whilst holding ALT, probably due to "if (freeLook) exitWith {};" -FightKnight +para_l_placing_scroll_handler = (findDisplay 46) displayAddEventHandler ["MouseZChanged", { + params ["_displayorcontrol", "_scroll_sign"]; + + if (!scriptDone para_l_placing_script) then { + switch (para_l_placing_mode) do { + // Mode 0 - Adjust object position distance + // need to find out how to add distance that you are facing + case 0: { + private _increment_position = _scroll_sign * 1; // Adjust distance by +- 1/2 meter + para_l_placing_center_pos = para_l_placing_center_pos vectorAdd [0, _increment_position, 0]; + }; + + // Mode 1 - Adjust object rotation + case 1: { + private _increment_rotation = _scroll_sign * 2; // Adjust rotation by +- 1 degrees + para_l_placing_final_rotation = para_l_placing_final_rotation + _increment_rotation; + }; + + // Mode 2 - Adjust object height + case 2: { + private _increment_height = _scroll_sign * .25; // Adjust height increment by +- 1/4 meter + para_l_placing_height = para_l_placing_height + _increment_height; + para_l_placing_center_pos set [2, para_l_placing_height]; + }; + }; + }; +}]; + para_l_placing_mode = 0; para_l_placing_center_pos = [0,0,0]; para_l_placing_last_player_dir = getDir player; From faf07b278d7295112299456c691ee6e2666d8d2d Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 9 Sep 2024 22:30:50 -0400 Subject: [PATCH 4/6] Revert "Building time limit notification is now Paradigm based" This reverts commit 1951bb450e04106a73dffc13ca3f26209c09c1c9. --- .../basebuilding/fn_abort_building.sqf | 5 --- .../basebuilding/fn_place_object.sqf | 31 +------------------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/client/functions/basebuilding/fn_abort_building.sqf b/client/functions/basebuilding/fn_abort_building.sqf index 80466c5..91e97cd 100644 --- a/client/functions/basebuilding/fn_abort_building.sqf +++ b/client/functions/basebuilding/fn_abort_building.sqf @@ -39,9 +39,4 @@ if (!isNil "para_l_placing_keyrotate_handler") then { para_l_placing_keyrotate_handler = nil; }; -if (!(isNil "para_l_placing_scroll_handler")) then { - (findDisplay 46) displayRemoveEventHandler ["MouseZChanged", para_l_placing_scroll_handler]; - para_l_placing_keyrotate_handler = nil; -}; - false; diff --git a/client/functions/basebuilding/fn_place_object.sqf b/client/functions/basebuilding/fn_place_object.sqf index 6585412..663f385 100644 --- a/client/functions/basebuilding/fn_place_object.sqf +++ b/client/functions/basebuilding/fn_place_object.sqf @@ -185,7 +185,7 @@ para_l_placing_click_handler = (findDisplay 46) displayAddEventHandler ["MouseBu }; }]; -// Adding key handler for rotation by 45 degrees (R key) -Legend +// Adding key handler for rotation by 45 degrees (R key) para_l_placing_keyrotate_handler = (findDisplay 46) displayAddEventHandler ["KeyDown", { params ["_displayorcontrol", "_keyCode"]; if (!scriptDone para_l_placing_script && _keyCode in [0x13]) then { // 0x13 is the 'R' key @@ -193,35 +193,6 @@ para_l_placing_keyrotate_handler = (findDisplay 46) displayAddEventHandler ["Key }; }]; -// Update the event handler for the mouse scroll wheel, only works whilst holding ALT, probably due to "if (freeLook) exitWith {};" -FightKnight -para_l_placing_scroll_handler = (findDisplay 46) displayAddEventHandler ["MouseZChanged", { - params ["_displayorcontrol", "_scroll_sign"]; - - if (!scriptDone para_l_placing_script) then { - switch (para_l_placing_mode) do { - // Mode 0 - Adjust object position distance - // need to find out how to add distance that you are facing - case 0: { - private _increment_position = _scroll_sign * 1; // Adjust distance by +- 1/2 meter - para_l_placing_center_pos = para_l_placing_center_pos vectorAdd [0, _increment_position, 0]; - }; - - // Mode 1 - Adjust object rotation - case 1: { - private _increment_rotation = _scroll_sign * 2; // Adjust rotation by +- 1 degrees - para_l_placing_final_rotation = para_l_placing_final_rotation + _increment_rotation; - }; - - // Mode 2 - Adjust object height - case 2: { - private _increment_height = _scroll_sign * .25; // Adjust height increment by +- 1/4 meter - para_l_placing_height = para_l_placing_height + _increment_height; - para_l_placing_center_pos set [2, para_l_placing_height]; - }; - }; - }; -}]; - para_l_placing_mode = 0; para_l_placing_center_pos = [0,0,0]; para_l_placing_last_player_dir = getDir player; From 121a28919696be73c0e266c624686f6e14dc0600 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 12 Sep 2024 19:57:48 -0400 Subject: [PATCH 5/6] Updated the notification function to have remoteExecCall on players --- server/functions/basebuilding/fn_resupplybuilding.sqf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/functions/basebuilding/fn_resupplybuilding.sqf b/server/functions/basebuilding/fn_resupplybuilding.sqf index f63707e..400d13d 100644 --- a/server/functions/basebuilding/fn_resupplybuilding.sqf +++ b/server/functions/basebuilding/fn_resupplybuilding.sqf @@ -103,12 +103,16 @@ private _proposedRemainingTimeSeconds = _proposedSuppliesSum / _supplyConsumptio 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!!! + // 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; // notify players that time limit has been reached and item was still consumed - ["TaskFailed",["",localize "STR_para_build_maxtimereached"]] call para_c_fnc_show_notification; + // executes the notification on the client of the specific player who has done the resupply + [["TaskFailed",["",localize "STR_para_build_maxtimereached"]]] remoteExecCall ["para_c_fnc_show_notification", _player]; }; From c20cd5c8f996fb1c106f8fffb104f2aa266808b8 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 15 Sep 2024 01:51:04 -0400 Subject: [PATCH 6/6] updated notification again, previous statement caused error --- server/functions/basebuilding/fn_resupplybuilding.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/functions/basebuilding/fn_resupplybuilding.sqf b/server/functions/basebuilding/fn_resupplybuilding.sqf index 400d13d..c634149 100644 --- a/server/functions/basebuilding/fn_resupplybuilding.sqf +++ b/server/functions/basebuilding/fn_resupplybuilding.sqf @@ -112,7 +112,7 @@ if ( _proposedRemainingTimeSeconds >= _maxTimeLimit) then { // notify players that time limit has been reached and item was still consumed // executes the notification on the client of the specific player who has done the resupply - [["TaskFailed",["",localize "STR_para_build_maxtimereached"]]] remoteExecCall ["para_c_fnc_show_notification", _player]; + ["TaskFailed",["",localize "STR_para_build_maxtimereached"]] remoteExecCall ["para_c_fnc_show_notification", _player]; };