Core/Creatures: Allow profession tools to be used as equipment (#29915)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -415,6 +415,20 @@ enum InventoryType : uint8
|
||||
|
||||
#define MAX_INVTYPE 35
|
||||
|
||||
constexpr std::array<InventoryType, 10> InventoryTypesEquipable =
|
||||
{
|
||||
INVTYPE_WEAPON,
|
||||
INVTYPE_SHIELD,
|
||||
INVTYPE_RANGED,
|
||||
INVTYPE_2HWEAPON,
|
||||
INVTYPE_WEAPONMAINHAND,
|
||||
INVTYPE_WEAPONOFFHAND,
|
||||
INVTYPE_HOLDABLE,
|
||||
INVTYPE_THROWN,
|
||||
INVTYPE_RANGEDRIGHT,
|
||||
INVTYPE_PROFESSION_TOOL
|
||||
};
|
||||
|
||||
enum ItemClass : uint8
|
||||
{
|
||||
ITEM_CLASS_CONSUMABLE = 0,
|
||||
|
||||
@@ -1526,15 +1526,7 @@ void ObjectMgr::LoadEquipmentTemplates()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dbcItem->InventoryType != INVTYPE_WEAPON &&
|
||||
dbcItem->InventoryType != INVTYPE_SHIELD &&
|
||||
dbcItem->InventoryType != INVTYPE_RANGED &&
|
||||
dbcItem->InventoryType != INVTYPE_2HWEAPON &&
|
||||
dbcItem->InventoryType != INVTYPE_WEAPONMAINHAND &&
|
||||
dbcItem->InventoryType != INVTYPE_WEAPONOFFHAND &&
|
||||
dbcItem->InventoryType != INVTYPE_HOLDABLE &&
|
||||
dbcItem->InventoryType != INVTYPE_THROWN &&
|
||||
dbcItem->InventoryType != INVTYPE_RANGEDRIGHT)
|
||||
if (std::ranges::none_of(InventoryTypesEquipable, [dbcItem](InventoryType inventoryType) { return inventoryType == dbcItem->InventoryType; }))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Item (ID={}) in creature_equip_template.ItemID{} for CreatureID = {} and ID = {} is not equipable in a hand, forced to 0.",
|
||||
equipmentInfo.Items[i].ItemId, i + 1, entry, id);
|
||||
|
||||
Reference in New Issue
Block a user