From 835a62da7ee1f99ac847a2a941fe3d9dce00b55b Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 2 May 2026 18:58:07 +0200 Subject: [PATCH 1/4] Update EEex_Fix.lua --- EEex/copy/EEex_scripts/EEex_Fix.lua | 70 +++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/EEex/copy/EEex_scripts/EEex_Fix.lua b/EEex/copy/EEex_scripts/EEex_Fix.lua index 81797c8..32ecb1b 100644 --- a/EEex/copy/EEex_scripts/EEex_Fix.lua +++ b/EEex/copy/EEex_scripts/EEex_Fix.lua @@ -295,3 +295,73 @@ EEex_Fix_Private_IgnoreLButtonUp = false function EEex_Fix_LuaHook_OnLocalMapDoubleClick() EEex_Fix_Private_IgnoreLButtonUp = true end + +------------------------------------------------------------------------------------------- +-- Make sure switching weapons from the actionbar doesn't bypass the weapon requirements -- +------------------------------------------------------------------------------------------- + +EEex_Actionbar_AddButtonsUpdatedListener(function() + + local sprite = EEex_Sprite_GetSelected() + if not sprite then + return + end + + local array = EEex_Actionbar_GetArray() -- CInfButtonArray + local selectedWeapon = EEex_Sprite_GetSelectedWeapon(sprite).weapon -- CItem + local selectedLauncher = EEex_Sprite_GetSelectedWeapon(sprite).launcher or nil -- CItem + local activeStats = EEex_Sprite_GetActiveStats(sprite) -- CDerivedStats + + local func = function() + local weaponHeader = selectedWeapon.pRes.pHeader -- Item_Header_st + local launcherHeader = selectedLauncher and selectedLauncher.pRes.pHeader or nil -- Item_Header_st + local toCheck = {weaponHeader, launcherHeader} + local cnt = 0 + -- + for _, v in ipairs(toCheck) do + -- Check the weapon requirements and if they aren't met, unequip the weapon + if EEex_Sprite_GetLevels(sprite).active.average >= v.minLevelRequired then + if activeStats.m_nSTR >= v.minSTRRequired then + if activeStats.m_nSTRExtra >= v.minSTRBonusRequired then + if activeStats.m_nINT >= v.minINTRequired then + if activeStats.m_nWIS >= v.minWISRequired then + if activeStats.m_nDEX >= v.minDEXRequired then + if activeStats.m_nCON >= v.minCONRequired then + if activeStats.m_nCHR >= v.minCHRRequired then + cnt = cnt + 1 + end + end + end + end + end + end + end + end + end + -- + if not (cnt == #toCheck and cnt > 0) then + -- actually unequip the weapon (or, if you prefer, equip fists) + local unequip = EEex_Action_ParseResponseString('SelectWeaponAbility(SLOT_FIST,0)') + unequip:executeResponseAsAIBaseInstantly(sprite) + unequip:free() + end + end + + for i = 0, 11 do -- Valid values are [0-11] + + if array.m_buttonArray:getReference(i).m_bHighlighted == 1 then -- CInfButtonSettings + + EEex_Utility_Switch(array.m_buttonTypes:get(i), { + + [EEex_Actionbar_ButtonType.QUICK_WEAPON_1] = func, + [EEex_Actionbar_ButtonType.QUICK_WEAPON_2] = func, + [EEex_Actionbar_ButtonType.QUICK_WEAPON_3] = func, + [EEex_Actionbar_ButtonType.QUICK_WEAPON_4] = func, + + }) -- no defaultCase needed: just do nothing if the button type isn't one of the quick weapon slots + + end + + end + +end) From 418330eb95f2bfc03e0e02c841ca9fcc14cc4ce1 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 2 May 2026 19:22:57 +0200 Subject: [PATCH 2/4] Update EEex_Fix.lua --- EEex/copy/EEex_scripts/EEex_Fix.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/EEex/copy/EEex_scripts/EEex_Fix.lua b/EEex/copy/EEex_scripts/EEex_Fix.lua index 32ecb1b..9ef77b7 100644 --- a/EEex/copy/EEex_scripts/EEex_Fix.lua +++ b/EEex/copy/EEex_scripts/EEex_Fix.lua @@ -317,6 +317,7 @@ EEex_Actionbar_AddButtonsUpdatedListener(function() local launcherHeader = selectedLauncher and selectedLauncher.pRes.pHeader or nil -- Item_Header_st local toCheck = {weaponHeader, launcherHeader} local cnt = 0 + local strref = {} -- for _, v in ipairs(toCheck) do -- Check the weapon requirements and if they aren't met, unequip the weapon @@ -329,17 +330,39 @@ EEex_Actionbar_AddButtonsUpdatedListener(function() if activeStats.m_nCON >= v.minCONRequired then if activeStats.m_nCHR >= v.minCHRRequired then cnt = cnt + 1 + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_CHR", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_CON", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_DEX", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_WIS", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_INT", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_STR", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_STR", "StrRef") end + else + strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_LEVEL", "StrRef") end end -- - if not (cnt == #toCheck and cnt > 0) then + if not (cnt == #toCheck and cnt > 0 and #strref == 0) then + -- play a sound to indicate the weapon can't be equipped + Infinity_PlaySound("ERROR27") + -- display the error message(s) + for _, v in ipairs(strref) do + EEex_Sprite_DisplayTextRef(sprite, tonumber(v)) + end -- actually unequip the weapon (or, if you prefer, equip fists) local unequip = EEex_Action_ParseResponseString('SelectWeaponAbility(SLOT_FIST,0)') unequip:executeResponseAsAIBaseInstantly(sprite) From f2ea027f092c47aeda374bbff28f5427217a1c50 Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 2 May 2026 19:43:06 +0200 Subject: [PATCH 3/4] Update EEex_Fix.lua --- EEex/copy/EEex_scripts/EEex_Fix.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/EEex/copy/EEex_scripts/EEex_Fix.lua b/EEex/copy/EEex_scripts/EEex_Fix.lua index 9ef77b7..789877a 100644 --- a/EEex/copy/EEex_scripts/EEex_Fix.lua +++ b/EEex/copy/EEex_scripts/EEex_Fix.lua @@ -316,7 +316,6 @@ EEex_Actionbar_AddButtonsUpdatedListener(function() local weaponHeader = selectedWeapon.pRes.pHeader -- Item_Header_st local launcherHeader = selectedLauncher and selectedLauncher.pRes.pHeader or nil -- Item_Header_st local toCheck = {weaponHeader, launcherHeader} - local cnt = 0 local strref = {} -- for _, v in ipairs(toCheck) do @@ -329,7 +328,7 @@ EEex_Actionbar_AddButtonsUpdatedListener(function() if activeStats.m_nDEX >= v.minDEXRequired then if activeStats.m_nCON >= v.minCONRequired then if activeStats.m_nCHR >= v.minCHRRequired then - cnt = cnt + 1 + -- cnt = cnt + 1 else strref[#strref + 1] = EEex_Resource_2DA("ENGINEST", "STRREF_ERROR_INADEQUATE_CHR", "StrRef") end @@ -356,7 +355,7 @@ EEex_Actionbar_AddButtonsUpdatedListener(function() end end -- - if not (cnt == #toCheck and cnt > 0 and #strref == 0) then + if #strref > 0 then -- play a sound to indicate the weapon can't be equipped Infinity_PlaySound("ERROR27") -- display the error message(s) From 98827081069e78e90a6f97a7548410b15679b45e Mon Sep 17 00:00:00 2001 From: 4Luke4 Date: Sat, 9 May 2026 18:39:52 +0200 Subject: [PATCH 4/4] Update EEex_Fix.lua --- EEex/copy/EEex_scripts/EEex_Fix.lua | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/EEex/copy/EEex_scripts/EEex_Fix.lua b/EEex/copy/EEex_scripts/EEex_Fix.lua index 789877a..0a60c0a 100644 --- a/EEex/copy/EEex_scripts/EEex_Fix.lua +++ b/EEex/copy/EEex_scripts/EEex_Fix.lua @@ -302,20 +302,25 @@ end EEex_Actionbar_AddButtonsUpdatedListener(function() - local sprite = EEex_Sprite_GetSelected() + local sprite = EEex_Sprite_GetSelected() -- CGameSprite if not sprite then return end local array = EEex_Actionbar_GetArray() -- CInfButtonArray + local selectedWeapon = EEex_Sprite_GetSelectedWeapon(sprite).weapon -- CItem local selectedLauncher = EEex_Sprite_GetSelectedWeapon(sprite).launcher or nil -- CItem + + local weaponHeader = selectedWeapon.pRes.pHeader -- Item_Header_st + local launcherHeader = selectedLauncher and selectedLauncher.pRes.pHeader or nil -- Item_Header_st + local activeStats = EEex_Sprite_GetActiveStats(sprite) -- CDerivedStats + local immunitiesItemEquip = activeStats.m_cImmunitiesItemEquip -- CImmunitiesItemEquipList (op180) + local immunitiesItemTypeEquip = activeStats.m_cImmunitiesItemTypeEquip -- CImmunitiesItemTypeEquipList (op181) local func = function() - local weaponHeader = selectedWeapon.pRes.pHeader -- Item_Header_st - local launcherHeader = selectedLauncher and selectedLauncher.pRes.pHeader or nil -- Item_Header_st - local toCheck = {weaponHeader, launcherHeader} + local toCheck = {weaponHeader, launcherHeader or nil} local strref = {} -- for _, v in ipairs(toCheck) do @@ -355,6 +360,22 @@ EEex_Actionbar_AddButtonsUpdatedListener(function() end end -- + local weaponResRef = selectedWeapon.pRes.resref:get() + local launcherResRef = selectedLauncher and selectedLauncher.pRes.resref:get() or "" + EEex_Utility_IterateCPtrList(immunitiesItemEquip, function(data) + if string.upper(data.m_res:get()) == string.upper(weaponResRef) or string.upper(data.m_res:get()) == string.upper(launcherResRef) then + strref[#strref + 1] = data.m_error + end + end) + -- + local weaponItemType = weaponHeader.itemType + local launcherItemType = launcherHeader and launcherHeader.itemType or -1 + EEex_Utility_IterateCPtrList(immunitiesItemTypeEquip, function(data) + if data.m_type == weaponItemType or data.m_type == launcherItemType then + strref[#strref + 1] = data.m_error + end + end) + -- if #strref > 0 then -- play a sound to indicate the weapon can't be equipped Infinity_PlaySound("ERROR27")