diff --git a/Source/Framework/Constants/ItemConst.cs b/Source/Framework/Constants/ItemConst.cs index 61ec259a7..3265112f5 100644 --- a/Source/Framework/Constants/ItemConst.cs +++ b/Source/Framework/Constants/ItemConst.cs @@ -262,17 +262,13 @@ namespace Framework.Constants { OnUse = 0, // use after equip cooldown OnEquip = 1, - ChanceOnHit = 2, - Soulstone = 4, - /* - * ItemSpelltriggerType 5 might have changed on 2.4.3/3.0.3: Such auras - * will be applied on item pickup and removed on item loss - maybe on the - * other hand the item is destroyed if the aura is removed ("removed on - * death" of spell 57348 makes me think so) - */ - OnObtain = 5, - LearnSpellId = 6, // used in itemtemplate.spell2 with spellid with SPELLGENERICLEARN in spell1 - Max = 7 + OnProc = 2, + SummonedBySpell = 3, + OnDeath = 4, + OnPickup = 5, + OnLearn = 6, // used in itemtemplate.spell2 with spellid with SPELLGENERICLEARN in spell1 + OnLooted = 7, + Max } public enum BuyBankSlotResult diff --git a/Source/Game/Entities/Player/Player.Items.cs b/Source/Game/Entities/Player/Player.Items.cs index 695849b03..ae820d874 100644 --- a/Source/Game/Entities/Player/Player.Items.cs +++ b/Source/Game/Entities/Player/Player.Items.cs @@ -3947,6 +3947,21 @@ namespace Game.Entities } } + void ApplyItemLootedSpell(Item item, bool apply) + { + if (item.GetTemplate().HasFlag(ItemFlags.Legacy)) + return; + + var lootedEffect = item.GetEffects().FirstOrDefault(effectData => effectData.TriggerType == ItemSpelltriggerType.OnLooted); + if (lootedEffect != null) + { + if (apply) + CastSpell(this, (uint)lootedEffect.SpellID, item); + else + RemoveAurasDueToItemSpell((uint)lootedEffect.SpellID, item.GetGUID()); + } + } + void _RemoveAllItemMods() { Log.outDebug(LogFilter.Player, "_RemoveAllItemMods start."); @@ -5515,6 +5530,7 @@ namespace Game.Entities RemoveTradeableItem(pItem); ApplyItemObtainSpells(pItem, false); + ApplyItemLootedSpell(pItem, false); Global.ScriptMgr.OnItemRemove(this, pItem); @@ -5896,6 +5912,7 @@ namespace Game.Entities Item pItem = StoreNewItem(dest, lootItem.itemid, true, lootItem.randomBonusListId, null, lootItem.context, lootItem.BonusListIDs); SendNewItem(pItem, lootItem.count, false, createdByPlayer, broadcast); + ApplyItemLootedSpell(pItem, true); } Unit.ProcSkillsAndAuras(this, null, new ProcFlagsInit(ProcFlags.Looted), new ProcFlagsInit(ProcFlags.None), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null); @@ -6044,6 +6061,7 @@ namespace Game.Entities if (!loot.containerID.IsEmpty()) Global.LootItemStorage.RemoveStoredLootItemForContainer(loot.containerID.GetCounter(), item.itemid, item.count, item.itemIndex); + ApplyItemLootedSpell(newitem, true); } else SendEquipError(msg, null, null, item.itemid); diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 580f534cc..e865f6d7c 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -1496,7 +1496,7 @@ namespace Game.Entities foreach (ItemEffectRecord effectData in item.GetEffects()) { // wrong triggering type - if (effectData.TriggerType != ItemSpelltriggerType.OnUse) + if (effectData.TriggerType != ItemSpelltriggerType.OnProc) continue; SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None); @@ -1783,7 +1783,7 @@ namespace Game.Entities foreach (ItemEffectRecord effect in item.GetEffects()) { - if (effect.TriggerType != ItemSpelltriggerType.OnObtain) // On obtain trigger + if (effect.TriggerType != ItemSpelltriggerType.OnPickup) // On obtain trigger continue; int spellId = effect.SpellID; @@ -3295,7 +3295,7 @@ namespace Game.Entities foreach (ItemEffectRecord effectData in item.GetEffects()) { // wrong triggering type - if (effectData.TriggerType != ItemSpelltriggerType.ChanceOnHit) + if (effectData.TriggerType != ItemSpelltriggerType.OnProc) continue; SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None); diff --git a/Source/Game/Handlers/ItemHandler.cs b/Source/Game/Handlers/ItemHandler.cs index 228bbb18e..2d6e6e491 100644 --- a/Source/Game/Handlers/ItemHandler.cs +++ b/Source/Game/Handlers/ItemHandler.cs @@ -1062,7 +1062,7 @@ namespace Game foreach (var itemEffect in item.GetEffects()) { - if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId) + if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn) continue; var speciesEntry = Global.SpellMgr.GetBattlePetSpecies((uint)itemEffect.SpellID); diff --git a/Source/Game/Loot/Loot.cs b/Source/Game/Loot/Loot.cs index 92bba7c9d..e05392b85 100644 --- a/Source/Game/Loot/Loot.cs +++ b/Source/Game/Loot/Loot.cs @@ -72,7 +72,7 @@ namespace Game.Loots foreach (var itemEffect in pProto.Effects) { - if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId) + if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn) continue; if (player.HasSpell((uint)itemEffect.SpellID)) @@ -85,7 +85,7 @@ namespace Game.Loots { foreach (var itemEffect in pProto.Effects) { - if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId) + if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn) continue; if (player.HasSpell((uint)itemEffect.SpellID)) diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 1b7ca82f8..fce0f3378 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -1746,7 +1746,7 @@ namespace Game.Spells { foreach (var itemEffect in m_CastItem.GetEffects()) { - if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId) + if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn) continue; bool dependent = false;