Core/Players: Added support for profession equipment slots
Port From (https://github.com/TrinityCore/TrinityCore/commit/aaa0db28801784e64a845d2df90a0e285062d3a8)
This commit is contained in:
@@ -4829,6 +4829,65 @@ namespace Game.Entities
|
||||
slots[2] = InventorySlots.BagStart + 2;
|
||||
slots[3] = InventorySlots.BagStart + 3;
|
||||
break;
|
||||
case InventoryType.ProfessionTool:
|
||||
case InventoryType.ProfessionGear:
|
||||
{
|
||||
bool isProfessionTool = item.GetTemplate().GetInventoryType() == InventoryType.ProfessionTool;
|
||||
|
||||
// Validate item class
|
||||
if (!(item.GetTemplate().GetClass() == ItemClass.Profession))
|
||||
return ItemConst.NullSlot;
|
||||
|
||||
// Check if player has profession skill
|
||||
uint itemSkill = (uint)item.GetTemplate().GetSkill();
|
||||
if (!HasSkill(itemSkill))
|
||||
return ItemConst.NullSlot;
|
||||
|
||||
switch ((ItemSubclassProfession)item.GetTemplate().GetSubClass())
|
||||
{
|
||||
case ItemSubclassProfession.Cooking:
|
||||
slots[0] = isProfessionTool ? ProfessionSlots.CookingTool : ProfessionSlots.CookingGear1;
|
||||
break;
|
||||
case ItemSubclassProfession.Fishing:
|
||||
{
|
||||
// Fishing doesn't make use of gear slots (clientside)
|
||||
if (!isProfessionTool)
|
||||
return ItemConst.NullSlot;
|
||||
|
||||
slots[0] = ProfessionSlots.FishingTool;
|
||||
break;
|
||||
}
|
||||
case ItemSubclassProfession.Blacksmithing :
|
||||
case ItemSubclassProfession.Leatherworking :
|
||||
case ItemSubclassProfession.Alchemy :
|
||||
case ItemSubclassProfession.Herbalism :
|
||||
case ItemSubclassProfession.Mining :
|
||||
case ItemSubclassProfession.Tailoring :
|
||||
case ItemSubclassProfession.Engineering :
|
||||
case ItemSubclassProfession.Enchanting :
|
||||
case ItemSubclassProfession.Skinning :
|
||||
case ItemSubclassProfession.Jewelcrafting :
|
||||
case ItemSubclassProfession.Inscription :
|
||||
{
|
||||
int professionSlot = GetProfessionSlotFor(itemSkill);
|
||||
if (professionSlot == -1)
|
||||
return ItemConst.NullSlot;
|
||||
|
||||
if (isProfessionTool)
|
||||
slots[0] = (byte)(ProfessionSlots.Profession1Tool + professionSlot * ProfessionSlots.MaxCount);
|
||||
else
|
||||
{
|
||||
slots[0] = (byte)(ProfessionSlots.Profession1Gear1 + professionSlot * ProfessionSlots.MaxCount);
|
||||
slots[0] = (byte)(ProfessionSlots.Profession1Gear2 + professionSlot * ProfessionSlots.MaxCount);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return ItemConst.NullSlot;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return ItemConst.NullSlot;
|
||||
}
|
||||
@@ -4970,8 +5029,50 @@ namespace Game.Entities
|
||||
if (!swap && GetItemByPos(InventorySlots.Bag0, eslot) != null)
|
||||
return InventoryResult.NoSlotAvailable;
|
||||
|
||||
// if we are swapping 2 equiped items, CanEquipUniqueItem check
|
||||
// should ignore the item we are trying to swap, and not the
|
||||
// destination item. CanEquipUniqueItem should ignore destination
|
||||
// item only when we are swapping weapon from bag
|
||||
byte ignore = ItemConst.NullSlot;
|
||||
switch (eslot)
|
||||
{
|
||||
case EquipmentSlot.MainHand:
|
||||
ignore = EquipmentSlot.OffHand;
|
||||
break;
|
||||
case EquipmentSlot.OffHand:
|
||||
ignore = EquipmentSlot.MainHand;
|
||||
break;
|
||||
case EquipmentSlot.Finger1:
|
||||
ignore = EquipmentSlot.Finger2;
|
||||
break;
|
||||
case EquipmentSlot.Finger2:
|
||||
ignore = EquipmentSlot.Finger1;
|
||||
break;
|
||||
case EquipmentSlot.Trinket1:
|
||||
ignore = EquipmentSlot.Trinket2;
|
||||
break;
|
||||
case EquipmentSlot.Trinket2:
|
||||
ignore = EquipmentSlot.Trinket1;
|
||||
break;
|
||||
case ProfessionSlots.Profession1Gear1:
|
||||
ignore = ProfessionSlots.Profession1Gear2;
|
||||
break;
|
||||
case ProfessionSlots.Profession1Gear2:
|
||||
ignore = ProfessionSlots.Profession1Gear1;
|
||||
break;
|
||||
case ProfessionSlots.Profession2Gear1:
|
||||
ignore = ProfessionSlots.Profession2Gear2;
|
||||
break;
|
||||
case ProfessionSlots.Profession2Gear2:
|
||||
ignore = ProfessionSlots.Profession2Gear1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ignore == ItemConst.NullSlot || pItem != GetItemByPos(InventorySlots.Bag0, ignore))
|
||||
ignore = eslot;
|
||||
|
||||
// if swap ignore item (equipped also)
|
||||
InventoryResult res2 = CanEquipUniqueItem(pItem, swap ? eslot : ItemConst.NullSlot);
|
||||
InventoryResult res2 = CanEquipUniqueItem(pItem, swap ? ignore : ItemConst.NullSlot);
|
||||
if (res2 != InventoryResult.Ok)
|
||||
return res2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user