Core/Items: Implemented item effect trigger type 7 (On Looted)
Port From (https://github.com/TrinityCore/TrinityCore/commit/372c84e998a090185f822a228c407911cbc821f1)
This commit is contained in:
@@ -262,17 +262,13 @@ namespace Framework.Constants
|
|||||||
{
|
{
|
||||||
OnUse = 0, // use after equip cooldown
|
OnUse = 0, // use after equip cooldown
|
||||||
OnEquip = 1,
|
OnEquip = 1,
|
||||||
ChanceOnHit = 2,
|
OnProc = 2,
|
||||||
Soulstone = 4,
|
SummonedBySpell = 3,
|
||||||
/*
|
OnDeath = 4,
|
||||||
* ItemSpelltriggerType 5 might have changed on 2.4.3/3.0.3: Such auras
|
OnPickup = 5,
|
||||||
* will be applied on item pickup and removed on item loss - maybe on the
|
OnLearn = 6, // used in itemtemplate.spell2 with spellid with SPELLGENERICLEARN in spell1
|
||||||
* other hand the item is destroyed if the aura is removed ("removed on
|
OnLooted = 7,
|
||||||
* death" of spell 57348 makes me think so)
|
Max
|
||||||
*/
|
|
||||||
OnObtain = 5,
|
|
||||||
LearnSpellId = 6, // used in itemtemplate.spell2 with spellid with SPELLGENERICLEARN in spell1
|
|
||||||
Max = 7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BuyBankSlotResult
|
public enum BuyBankSlotResult
|
||||||
|
|||||||
@@ -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()
|
void _RemoveAllItemMods()
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Player, "_RemoveAllItemMods start.");
|
Log.outDebug(LogFilter.Player, "_RemoveAllItemMods start.");
|
||||||
@@ -5515,6 +5530,7 @@ namespace Game.Entities
|
|||||||
RemoveTradeableItem(pItem);
|
RemoveTradeableItem(pItem);
|
||||||
|
|
||||||
ApplyItemObtainSpells(pItem, false);
|
ApplyItemObtainSpells(pItem, false);
|
||||||
|
ApplyItemLootedSpell(pItem, false);
|
||||||
|
|
||||||
Global.ScriptMgr.OnItemRemove(this, pItem);
|
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);
|
Item pItem = StoreNewItem(dest, lootItem.itemid, true, lootItem.randomBonusListId, null, lootItem.context, lootItem.BonusListIDs);
|
||||||
SendNewItem(pItem, lootItem.count, false, createdByPlayer, broadcast);
|
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);
|
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())
|
if (!loot.containerID.IsEmpty())
|
||||||
Global.LootItemStorage.RemoveStoredLootItemForContainer(loot.containerID.GetCounter(), item.itemid, item.count, item.itemIndex);
|
Global.LootItemStorage.RemoveStoredLootItemForContainer(loot.containerID.GetCounter(), item.itemid, item.count, item.itemIndex);
|
||||||
|
|
||||||
|
ApplyItemLootedSpell(newitem, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SendEquipError(msg, null, null, item.itemid);
|
SendEquipError(msg, null, null, item.itemid);
|
||||||
|
|||||||
@@ -1496,7 +1496,7 @@ namespace Game.Entities
|
|||||||
foreach (ItemEffectRecord effectData in item.GetEffects())
|
foreach (ItemEffectRecord effectData in item.GetEffects())
|
||||||
{
|
{
|
||||||
// wrong triggering type
|
// wrong triggering type
|
||||||
if (effectData.TriggerType != ItemSpelltriggerType.OnUse)
|
if (effectData.TriggerType != ItemSpelltriggerType.OnProc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None);
|
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None);
|
||||||
@@ -1783,7 +1783,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
foreach (ItemEffectRecord effect in item.GetEffects())
|
foreach (ItemEffectRecord effect in item.GetEffects())
|
||||||
{
|
{
|
||||||
if (effect.TriggerType != ItemSpelltriggerType.OnObtain) // On obtain trigger
|
if (effect.TriggerType != ItemSpelltriggerType.OnPickup) // On obtain trigger
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int spellId = effect.SpellID;
|
int spellId = effect.SpellID;
|
||||||
@@ -3295,7 +3295,7 @@ namespace Game.Entities
|
|||||||
foreach (ItemEffectRecord effectData in item.GetEffects())
|
foreach (ItemEffectRecord effectData in item.GetEffects())
|
||||||
{
|
{
|
||||||
// wrong triggering type
|
// wrong triggering type
|
||||||
if (effectData.TriggerType != ItemSpelltriggerType.ChanceOnHit)
|
if (effectData.TriggerType != ItemSpelltriggerType.OnProc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None);
|
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None);
|
||||||
|
|||||||
@@ -1062,7 +1062,7 @@ namespace Game
|
|||||||
|
|
||||||
foreach (var itemEffect in item.GetEffects())
|
foreach (var itemEffect in item.GetEffects())
|
||||||
{
|
{
|
||||||
if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
|
if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var speciesEntry = Global.SpellMgr.GetBattlePetSpecies((uint)itemEffect.SpellID);
|
var speciesEntry = Global.SpellMgr.GetBattlePetSpecies((uint)itemEffect.SpellID);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace Game.Loots
|
|||||||
|
|
||||||
foreach (var itemEffect in pProto.Effects)
|
foreach (var itemEffect in pProto.Effects)
|
||||||
{
|
{
|
||||||
if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
|
if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (player.HasSpell((uint)itemEffect.SpellID))
|
if (player.HasSpell((uint)itemEffect.SpellID))
|
||||||
@@ -85,7 +85,7 @@ namespace Game.Loots
|
|||||||
{
|
{
|
||||||
foreach (var itemEffect in pProto.Effects)
|
foreach (var itemEffect in pProto.Effects)
|
||||||
{
|
{
|
||||||
if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
|
if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (player.HasSpell((uint)itemEffect.SpellID))
|
if (player.HasSpell((uint)itemEffect.SpellID))
|
||||||
|
|||||||
@@ -1746,7 +1746,7 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
foreach (var itemEffect in m_CastItem.GetEffects())
|
foreach (var itemEffect in m_CastItem.GetEffects())
|
||||||
{
|
{
|
||||||
if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
|
if (itemEffect.TriggerType != ItemSpelltriggerType.OnLearn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool dependent = false;
|
bool dependent = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user