Core/Creatures: Allow profession tools to be used as equipment
Port From (https://github.com/TrinityCore/TrinityCore/commit/2238844f567b63de1edd394b654b62ac4ddeb666)
This commit is contained in:
@@ -94,6 +94,20 @@ namespace Framework.Constants
|
||||
ItemModifier.TransmogSecondaryAppearanceSpec4,
|
||||
ItemModifier.TransmogSecondaryAppearanceSpec5
|
||||
};
|
||||
|
||||
public static InventoryType[] InventoryTypesEquipable =
|
||||
{
|
||||
InventoryType.Weapon,
|
||||
InventoryType.Shield,
|
||||
InventoryType.Ranged,
|
||||
InventoryType.Weapon2Hand,
|
||||
InventoryType.WeaponMainhand,
|
||||
InventoryType.WeaponOffhand,
|
||||
InventoryType.Holdable,
|
||||
InventoryType.Thrown,
|
||||
InventoryType.RangedRight,
|
||||
InventoryType.ProfessionTool
|
||||
};
|
||||
}
|
||||
|
||||
public struct ProfessionSlots
|
||||
|
||||
@@ -9,6 +9,7 @@ using Game.Movement;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -1805,6 +1806,33 @@ namespace Game.AI
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isValidEquipmentSlot(uint itemEntry, byte slot)
|
||||
{
|
||||
ItemRecord dbcItem = CliDB.ItemStorage.LookupByKey(itemEntry);
|
||||
if (dbcItem == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartScript: SMART_ACTION_EQUIP uses unknown item {itemEntry} (slot {slot}) for creature {e.EntryOrGuid}, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ItemConst.InventoryTypesEquipable.All(inventoryType => inventoryType != dbcItem.inventoryType))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartScript: SMART_ACTION_EQUIP uses item {itemEntry} (slot {slot}) not equipable in a hand for creature {e.EntryOrGuid}, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (e.Action.equip.slot1 != 0 && !isValidEquipmentSlot(e.Action.equip.slot1, 0))
|
||||
return false;
|
||||
|
||||
if (e.Action.equip.slot2 != 0 && !isValidEquipmentSlot(e.Action.equip.slot2, 1))
|
||||
return false;
|
||||
|
||||
if (e.Action.equip.slot3 != 0 && !isValidEquipmentSlot(e.Action.equip.slot3, 2))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case SmartActions.SetInstData:
|
||||
|
||||
@@ -2481,18 +2481,9 @@ namespace Game
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dbcItem.inventoryType != InventoryType.Weapon &&
|
||||
dbcItem.inventoryType != InventoryType.Shield &&
|
||||
dbcItem.inventoryType != InventoryType.Ranged &&
|
||||
dbcItem.inventoryType != InventoryType.Weapon2Hand &&
|
||||
dbcItem.inventoryType != InventoryType.WeaponMainhand &&
|
||||
dbcItem.inventoryType != InventoryType.WeaponOffhand &&
|
||||
dbcItem.inventoryType != InventoryType.Holdable &&
|
||||
dbcItem.inventoryType != InventoryType.Thrown &&
|
||||
dbcItem.inventoryType != InventoryType.RangedRight)
|
||||
if (ItemConst.InventoryTypesEquipable.All(inventoryType => inventoryType != dbcItem.inventoryType))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Item (ID {0}) in creature_equip_template.ItemID{1} for CreatureID = {2} is not equipable in a hand, forced to 0.",
|
||||
equipmentInfo.Items[i].ItemId, i + 1, entry);
|
||||
Log.outError(LogFilter.Sql, $"Item (ID {equipmentInfo.Items[i].ItemId}) in creature_equip_template.ItemID{i + 1} for CreatureID = {entry} is not equipable in a hand, forced to 0.");
|
||||
equipmentInfo.Items[i].ItemId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user