From 8cdde53bf789e6232283f4f8097b6ec729aca0b9 Mon Sep 17 00:00:00 2001 From: SilenceIsFatto <78276788+SilenceIsFatto@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:16:20 +0100 Subject: [PATCH 1/4] Add forbiddenItems checks --- .../Addons/store/functions/server/fn_sell.sqf | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf b/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf index ffa00c20c7..698a0c7bc9 100644 --- a/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf +++ b/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf @@ -39,9 +39,19 @@ try { private _trader = _unit getVariable ["HALs_store_trader_current", objNull]; if (isNull _trader) then {throw [""]}; + private _forbiddenItem_is_unlimited = false; + + if (_classname in A3U_forbiddenItems) then { + private _is_forbiddenItem = isClass (configFile >> "A3U" >> "forbiddenItems" >> _classname); + + if (_is_forbiddenItem) then { + _forbiddenItem_is_unlimited = (getNumber (configFile >> "A3U" >> "forbiddenItems" >> _classname >> "unlimited")); + }; + }; + // Check if the trader will buy this item private _stock = [_trader, _classname] call HALs_store_fnc_getTraderStock; - if (_stock isEqualTo -1) then { + if (_stock isEqualTo -1 && {!(_is_forbidden)}) then { // Try parent _parent = _classname call HALs_store_fnc_getParentClassname; _stock = [_trader, _parent] call HALs_store_fnc_getTraderStock; @@ -79,7 +89,10 @@ try { ) select {(_x select 1) == -1 || {(_x select 1) >= minWeaps}}) apply {_x select 0}; if (_classname in _unlockedItems) then { - throw ["The trader is not interested in this item, no deal."] + // If classname is "unlocked" but is also a forbidden item (that can't be unlimited), we want it to sell as usual + if (_is_forbiddenItem && {!(_forbiddenItem_is_unlimited)}) then {} else { + throw ["The trader is not interested in this item, no deal."] + }; }; _unlockedItems = nil; From dd4011a685a77bc804f88aef7efa767ba2b52e6b Mon Sep 17 00:00:00 2001 From: SilenceIsFatto <78276788+SilenceIsFatto@users.noreply.github.com> Date: Sat, 29 Jun 2024 13:48:24 +0100 Subject: [PATCH 2/4] Update cfgForbiddenItems.hpp --- A3A/addons/ultimate/config/cfgForbiddenItems.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/A3A/addons/ultimate/config/cfgForbiddenItems.hpp b/A3A/addons/ultimate/config/cfgForbiddenItems.hpp index 04692ec5a3..e7a50b5147 100644 --- a/A3A/addons/ultimate/config/cfgForbiddenItems.hpp +++ b/A3A/addons/ultimate/config/cfgForbiddenItems.hpp @@ -11,6 +11,8 @@ class forbiddenItems unlimited = 0; }; + class LMG_Mk200_F : forbidden_unlimited_base {}; // here for testing purposes + #include "cfgForbiddenItemsAndroid.hpp" #include "cfgForbiddenItemsCW.hpp" #include "cfgForbiddenItemsFWA.hpp" From a546ad6f2cbb5ca6d22e1d622ad79ae45304e33b Mon Sep 17 00:00:00 2001 From: SilenceIsFatto <78276788+SilenceIsFatto@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:11:36 +0100 Subject: [PATCH 3/4] Allow forbidden items to be sold correctly --- .../Addons/store/functions/server/fn_sell.sqf | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf b/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf index 698a0c7bc9..c80b6865dc 100644 --- a/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf +++ b/A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf @@ -39,19 +39,21 @@ try { private _trader = _unit getVariable ["HALs_store_trader_current", objNull]; if (isNull _trader) then {throw [""]}; - private _forbiddenItem_is_unlimited = false; + private _forbiddenItem_is_unlimited = 0; if (_classname in A3U_forbiddenItems) then { private _is_forbiddenItem = isClass (configFile >> "A3U" >> "forbiddenItems" >> _classname); + diag_log format["%1 is a forbidden item.", _classname]; + if (_is_forbiddenItem) then { - _forbiddenItem_is_unlimited = (getNumber (configFile >> "A3U" >> "forbiddenItems" >> _classname >> "unlimited")); + _is_forbiddenItemUnlimited = (getNumber (configFile >> "A3U" >> "forbiddenItems" >> _classname >> "unlimited")); }; }; // Check if the trader will buy this item private _stock = [_trader, _classname] call HALs_store_fnc_getTraderStock; - if (_stock isEqualTo -1 && {!(_is_forbidden)}) then { + if (_stock isEqualTo -1) then { // && {_is_forbiddenItem isEqualTo false} // Try parent _parent = _classname call HALs_store_fnc_getParentClassname; _stock = [_trader, _parent] call HALs_store_fnc_getTraderStock; @@ -86,13 +88,12 @@ try { (jna_dataList select IDC_RSCDISPLAYARSENAL_TAB_NVGS) + (jna_dataList select IDC_RSCDISPLAYARSENAL_TAB_HEADGEAR) + (jna_dataList select IDC_RSCDISPLAYARSENAL_TAB_VEST) - ) select {(_x select 1) == -1 || {(_x select 1) >= minWeaps}}) apply {_x select 0}; + ) select {(_x select 1) == -1 || {(_x select 1) >= minWeaps && {_is_forbiddenItemUnlimited isEqualTo 0}}}) apply {_x select 0}; + + diag_log (format["%1 unlock state: %2", _classname, (_classname in _unlockedItems)]); if (_classname in _unlockedItems) then { - // If classname is "unlocked" but is also a forbidden item (that can't be unlimited), we want it to sell as usual - if (_is_forbiddenItem && {!(_forbiddenItem_is_unlimited)}) then {} else { - throw ["The trader is not interested in this item, no deal."] - }; + throw ["The trader is not interested in this item, no deal."] }; _unlockedItems = nil; From 73efab654ade69e3f9642a76ea55f2a57c80c296 Mon Sep 17 00:00:00 2001 From: Silence <78276788+SilenceIsFatto@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:31:25 +0100 Subject: [PATCH 4/4] Remove testing forbiddenItem --- A3A/addons/ultimate/config/cfgForbiddenItems.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/A3A/addons/ultimate/config/cfgForbiddenItems.hpp b/A3A/addons/ultimate/config/cfgForbiddenItems.hpp index e7a50b5147..1a9acb3d03 100644 --- a/A3A/addons/ultimate/config/cfgForbiddenItems.hpp +++ b/A3A/addons/ultimate/config/cfgForbiddenItems.hpp @@ -11,8 +11,6 @@ class forbiddenItems unlimited = 0; }; - class LMG_Mk200_F : forbidden_unlimited_base {}; // here for testing purposes - #include "cfgForbiddenItemsAndroid.hpp" #include "cfgForbiddenItemsCW.hpp" #include "cfgForbiddenItemsFWA.hpp" @@ -23,4 +21,4 @@ class forbiddenItems #include "cfgForbiddenItemsSMA.hpp" #include "cfgForbiddenItemsTOW.hpp" #include "cfgForbiddenItemsUns.hpp" -}; \ No newline at end of file +};