Core/Items: Implemented item effect trigger type 7 (On Looted)

Port From (https://github.com/TrinityCore/TrinityCore/commit/372c84e998a090185f822a228c407911cbc821f1)
This commit is contained in:
hondacrx
2022-05-31 16:00:10 -04:00
parent a47ecd34e9
commit 108abf92cd
6 changed files with 32 additions and 18 deletions
+7 -11
View File
@@ -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
@@ -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);
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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))
+1 -1
View File
@@ -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;