diff --git a/GameServer/craft/CraftingMgr.cs b/GameServer/craft/CraftingMgr.cs index 2b02d5d33a..2499e7668f 100644 --- a/GameServer/craft/CraftingMgr.cs +++ b/GameServer/craft/CraftingMgr.cs @@ -102,6 +102,77 @@ public static bool Init() #region Global craft functions + /// + /// Return the crafting skill which created the item + /// + public static eCraftingSkill GetCraftingSkill(InventoryItem item) + { + if (!item.IsCrafted) + return eCraftingSkill.NoCrafting; + + switch (item.Object_Type) + { + case (int)eObjectType.Cloth: + case (int)eObjectType.Leather: + return eCraftingSkill.Tailoring; + + case (int)eObjectType.Studded: + case (int)eObjectType.Reinforced: + case (int)eObjectType.Chain: + case (int)eObjectType.Scale: + case (int)eObjectType.Plate: + return eCraftingSkill.ArmorCrafting; + + // all weapon + case (int)eObjectType.Axe: + case (int)eObjectType.Blades: + case (int)eObjectType.Blunt: + case (int)eObjectType.CelticSpear: + case (int)eObjectType.CrushingWeapon: + case (int)eObjectType.Flexible: + case (int)eObjectType.Hammer: + case (int)eObjectType.HandToHand: + case (int)eObjectType.LargeWeapons: + case (int)eObjectType.LeftAxe: + case (int)eObjectType.Piercing: + case (int)eObjectType.PolearmWeapon: + case (int)eObjectType.Scythe: + case (int)eObjectType.Shield: + case (int)eObjectType.SlashingWeapon: + case (int)eObjectType.Spear: + case (int)eObjectType.Sword: + case (int)eObjectType.ThrustWeapon: + case (int)eObjectType.TwoHandedWeapon: + return eCraftingSkill.WeaponCrafting; + + case (int)eObjectType.CompositeBow: + case (int)eObjectType.Crossbow: + case (int)eObjectType.Fired: + case (int)eObjectType.Instrument: + case (int)eObjectType.Longbow: + case (int)eObjectType.RecurvedBow: + case (int)eObjectType.Staff: + return eCraftingSkill.Fletching; + + case (int)eObjectType.AlchemyTincture: + case (int)eObjectType.Poison: + return eCraftingSkill.Alchemy; + + case (int)eObjectType.SpellcraftGem: + return eCraftingSkill.SpellCrafting; + + case (int)eObjectType.SiegeBalista: + case (int)eObjectType.SiegeCatapult: + case (int)eObjectType.SiegeCauldron: + case (int)eObjectType.SiegeRam: + case (int)eObjectType.SiegeTrebuchet: + return eCraftingSkill.SiegeCrafting; + + default: + return eCraftingSkill.NoCrafting; + } + } + /// /// Return the crafting skill needed to work on the item /// diff --git a/GameServer/packets/Server/PacketLib1109.cs b/GameServer/packets/Server/PacketLib1109.cs index 50d077d3ee..5f57a31242 100644 --- a/GameServer/packets/Server/PacketLib1109.cs +++ b/GameServer/packets/Server/PacketLib1109.cs @@ -201,9 +201,24 @@ protected override void WriteItemData(GSTCPPacketOut pak, InventoryItem item) pak.WriteShort((ushort)item.Color); // flag |= 0x01; // newGuildEmblem flag |= 0x02; // enable salvage button - AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(m_gameClient.Player.CraftingPrimarySkill); - if (skill != null && skill is AdvancedCraftingSkill/* && ((AdvancedCraftingSkill)skill).IsAllowedToCombine(m_gameClient.Player, item)*/) - flag |= 0x04; // enable craft button + + // Enable craft button if the item can be modified and the player has alchemy or spellcrafting + eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item); + switch (skill) + { + case eCraftingSkill.ArmorCrafting: + case eCraftingSkill.Fletching: + case eCraftingSkill.Tailoring: + case eCraftingSkill.WeaponCrafting: + if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) + || m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting)) + flag |= 0x04; // enable craft button + break; + + default: + break; + } + ushort icon1 = 0; ushort icon2 = 0; string spell_name1 = ""; diff --git a/GameServer/packets/Server/PacketLib1112.cs b/GameServer/packets/Server/PacketLib1112.cs index ecb0cef84e..d9003020c2 100644 --- a/GameServer/packets/Server/PacketLib1112.cs +++ b/GameServer/packets/Server/PacketLib1112.cs @@ -468,10 +468,24 @@ protected override void WriteItemData(GSTCPPacketOut pak, InventoryItem item) pak.WriteShort((ushort)color); } // flag |= 0x01; // newGuildEmblem - flag |= 0x02; // enable salvage button - AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(m_gameClient.Player.CraftingPrimarySkill); - if (skill != null && skill is AdvancedCraftingSkill/* && ((AdvancedCraftingSkill)skill).IsAllowedToCombine(m_gameClient.Player, item)*/) - flag |= 0x04; // enable craft button + + // Enable craft button if the item can be modified and the player has alchemy or spellcrafting + eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item); + switch (skill) + { + case eCraftingSkill.ArmorCrafting: + case eCraftingSkill.Fletching: + case eCraftingSkill.Tailoring: + case eCraftingSkill.WeaponCrafting: + if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) + || m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting)) + flag |= 0x04; // enable craft button + break; + + default: + break; + } + ushort icon1 = 0; ushort icon2 = 0; string spell_name1 = ""; diff --git a/GameServer/packets/Server/PacketLib1119.cs b/GameServer/packets/Server/PacketLib1119.cs index 8a6780c67a..e038efa1c1 100644 --- a/GameServer/packets/Server/PacketLib1119.cs +++ b/GameServer/packets/Server/PacketLib1119.cs @@ -132,9 +132,24 @@ protected override void WriteItemData(GSTCPPacketOut pak, InventoryItem item) } // flag |= 0x01; // newGuildEmblem flag |= 0x02; // enable salvage button - AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(m_gameClient.Player.CraftingPrimarySkill); - if (skill != null && skill is AdvancedCraftingSkill/* && ((AdvancedCraftingSkill)skill).IsAllowedToCombine(m_gameClient.Player, item)*/) - flag |= 0x04; // enable craft button + + // Enable craft button if the item can be modified and the player has alchemy or spellcrafting + eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item); + switch (skill) + { + case eCraftingSkill.ArmorCrafting: + case eCraftingSkill.Fletching: + case eCraftingSkill.Tailoring: + case eCraftingSkill.WeaponCrafting: + if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) + || m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting)) + flag |= 0x04; // enable craft button + break; + + default: + break; + } + ushort icon1 = 0; ushort icon2 = 0; string spell_name1 = ""; diff --git a/GameServer/packets/Server/PacketLib1124.cs b/GameServer/packets/Server/PacketLib1124.cs index e6bde2c4ac..d0809d9302 100644 --- a/GameServer/packets/Server/PacketLib1124.cs +++ b/GameServer/packets/Server/PacketLib1124.cs @@ -5109,9 +5109,24 @@ protected virtual void WriteItemData(GSTCPPacketOut pak, InventoryItem item, int } //flag |= 0x01; // newGuildEmblem flag |= 0x02; // enable salvage button - AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(m_gameClient.Player.CraftingPrimarySkill); - if (skill != null && skill is AdvancedCraftingSkill/* && ((AdvancedCraftingSkill)skill).IsAllowedToCombine(_gameClient.Player, item)*/) - flag |= 0x04; // enable craft button + + // Enable craft button if the item can be modified and the player has alchemy or spellcrafting + eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item); + switch (skill) + { + case eCraftingSkill.ArmorCrafting: + case eCraftingSkill.Fletching: + case eCraftingSkill.Tailoring: + case eCraftingSkill.WeaponCrafting: + if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) + || m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting)) + flag |= 0x04; // enable craft button + break; + + default: + break; + } + ushort icon1 = 0; ushort icon2 = 0; string spell_name1 = ""; diff --git a/GameServer/packets/Server/PacketLib182.cs b/GameServer/packets/Server/PacketLib182.cs index 477d911c1e..7edf7c44b2 100644 --- a/GameServer/packets/Server/PacketLib182.cs +++ b/GameServer/packets/Server/PacketLib182.cs @@ -143,10 +143,25 @@ protected override void SendInventorySlotsUpdateRange(ICollection slots, eI else pak.WriteShort((ushort)item.Color); // flag |= 0x01; // newGuildEmblem - flag |= 0x02; // enable salvage button - AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(m_gameClient.Player.CraftingPrimarySkill); - if (skill != null && skill is AdvancedCraftingSkill/* && ((AdvancedCraftingSkill)skill).IsAllowedToCombine(m_gameClient.Player, item)*/) - flag |= 0x04; // enable craft button + flag |= 0x02; // enable salvage button + + // Enable craft button if the item can be modified and the player has alchemy or spellcrafting + eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item); + switch (skill) + { + case eCraftingSkill.ArmorCrafting: + case eCraftingSkill.Fletching: + case eCraftingSkill.Tailoring: + case eCraftingSkill.WeaponCrafting: + if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) + || m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting)) + flag |= 0x04; // enable craft button + break; + + default: + break; + } + ushort icon1 = 0; ushort icon2 = 0; string spell_name1 = ""; diff --git a/GameServer/packets/Server/PacketLib189.cs b/GameServer/packets/Server/PacketLib189.cs index 7bafa6ade0..c35bca84b7 100644 --- a/GameServer/packets/Server/PacketLib189.cs +++ b/GameServer/packets/Server/PacketLib189.cs @@ -325,10 +325,21 @@ protected virtual void WriteItemData(GSTCPPacketOut pak, InventoryItem item) flag |= 0x02; // enable salvage button - AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(m_gameClient.Player.CraftingPrimarySkill); - if (skill != null && skill is AdvancedCraftingSkill/* && ((AdvancedCraftingSkill)skill).IsAllowedToCombine(m_gameClient.Player, item)*/) + // Enable craft button if the item can be modified and the player has alchemy or spellcrafting + eCraftingSkill skill = CraftingMgr.GetCraftingSkill(item); + switch (skill) { - flag |= 0x04; // enable craft button + case eCraftingSkill.ArmorCrafting: + case eCraftingSkill.Fletching: + case eCraftingSkill.Tailoring: + case eCraftingSkill.WeaponCrafting: + if (m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.Alchemy) + || m_gameClient.Player.CraftingSkills.ContainsKey(eCraftingSkill.SpellCrafting)) + flag |= 0x04; // enable craft button + break; + + default: + break; } ushort icon1 = 0;