From 2238844f567b63de1edd394b654b62ac4ddeb666 Mon Sep 17 00:00:00 2001 From: Meji Date: Fri, 3 May 2024 15:58:05 +0200 Subject: Core/Creatures: Allow profession tools to be used as equipment (#29915) --- src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/server/game/AI/SmartScripts') diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index fed55249eba..c9e1cb072fe 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -2054,6 +2054,33 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) return false; } } + + auto isValidEquipmentSlot = [&](uint32 itemEntry, uint8 slot) + { + ItemEntry const* dbcItem = sItemStore.LookupEntry(itemEntry); + if (!dbcItem) + { + TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses unknown item {} (slot {}) for creature {}, skipped.", itemEntry, slot, e.entryOrGuid); + return false; + } + + if (std::ranges::none_of(InventoryTypesEquipable, [dbcItem](InventoryType inventoryType) { return inventoryType == dbcItem->InventoryType; })) + { + TC_LOG_ERROR("sql.sql", "SmartScript: SMART_ACTION_EQUIP uses item {} (slot {}) not equipable in a hand for creature {}, skipped.", itemEntry, slot, e.entryOrGuid); + return false; + } + + return true; + }; + + if (e.action.equip.slot1 && !isValidEquipmentSlot(e.action.equip.slot1, 0)) + return false; + + if (e.action.equip.slot2 && !isValidEquipmentSlot(e.action.equip.slot2, 1)) + return false; + + if (e.action.equip.slot3 && !isValidEquipmentSlot(e.action.equip.slot3, 2)) + return false; } break; } -- cgit v1.2.3