aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-04-22 20:57:05 +0200
committerShauren <shauren.trinity@gmail.com>2022-04-22 20:57:05 +0200
commit372c84e998a090185f822a228c407911cbc821f1 (patch)
treec7327a930be730d986cf12246dbfcafcdb8f3a4c /src
parent8ecb16fde4cf71851c46d78471b667b56f55bd17 (diff)
Core/Items: Implemented item effect trigger type 7 (On Looted)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Item/ItemTemplate.h24
-rw-r--r--src/server/game/Entities/Player/Player.cpp27
-rw-r--r--src/server/game/Entities/Player/Player.h1
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp2
-rw-r--r--src/server/game/Loot/Loot.cpp4
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
6 files changed, 39 insertions, 21 deletions
diff --git a/src/server/game/Entities/Item/ItemTemplate.h b/src/server/game/Entities/Item/ItemTemplate.h
index 8ae68284dec..70974649bdf 100644
--- a/src/server/game/Entities/Item/ItemTemplate.h
+++ b/src/server/game/Entities/Item/ItemTemplate.h
@@ -101,21 +101,15 @@ enum ItemModType
enum ItemSpelltriggerType
{
- ITEM_SPELLTRIGGER_ON_USE = 0, // use after equip cooldown
- ITEM_SPELLTRIGGER_ON_EQUIP = 1,
- ITEM_SPELLTRIGGER_CHANCE_ON_HIT = 2,
- ITEM_SPELLTRIGGER_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)
- */
- ITEM_SPELLTRIGGER_ON_OBTAIN = 5,
- ITEM_SPELLTRIGGER_LEARN_SPELL_ID = 6 // used in ItemEffect in second slot with spell_id with SPELL_GENERIC_LEARN in spell_1
-};
-
-#define MAX_ITEM_SPELLTRIGGER 7
+ ITEM_SPELLTRIGGER_ON_USE = 0, // use after equip cooldown
+ ITEM_SPELLTRIGGER_ON_EQUIP = 1,
+ ITEM_SPELLTRIGGER_ON_PROC = 2,
+ ITEM_SPELLTRIGGER_SUMMONED_BY_SPELL = 3,
+ ITEM_SPELLTRIGGER_ON_DEATH = 4,
+ ITEM_SPELLTRIGGER_ON_PICKUP = 5,
+ ITEM_SPELLTRIGGER_ON_LEARN = 6, // used in ItemEffect in second slot with spell_id with SPELL_GENERIC_LEARN in spell_1
+ ITEM_SPELLTRIGGER_ON_LOOTED = 7,
+};
enum ItemBondingType
{
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 10d29ceb629..74c9308f915 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7892,7 +7892,7 @@ void Player::ApplyItemObtainSpells(Item* item, bool apply)
for (ItemEffectEntry const* effect : item->GetEffects())
{
- if (effect->TriggerType != ITEM_SPELLTRIGGER_ON_OBTAIN) // On obtain trigger
+ if (effect->TriggerType != ITEM_SPELLTRIGGER_ON_PICKUP) // On obtain trigger
continue;
int32 const spellId = effect->SpellID;
@@ -8336,7 +8336,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
for (ItemEffectEntry const* effectData : item->GetEffects())
{
// wrong triggering type
- if (effectData->TriggerType != ITEM_SPELLTRIGGER_CHANCE_ON_HIT)
+ if (effectData->TriggerType != ITEM_SPELLTRIGGER_ON_PROC)
continue;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(effectData->SpellID, DIFFICULTY_NONE);
@@ -8521,6 +8521,25 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, Objec
}
}
+void Player::ApplyItemLootedSpell(Item* item, bool apply)
+{
+ if (item->GetTemplate()->HasFlag(ITEM_FLAG_LEGACY))
+ return;
+
+ auto lootedEffectItr = std::find_if(item->GetEffects().begin(), item->GetEffects().end(), [](ItemEffectEntry const* effectData)
+ {
+ return effectData->TriggerType == ITEM_SPELLTRIGGER_ON_LOOTED;
+ });
+
+ if (lootedEffectItr != item->GetEffects().end())
+ {
+ if (apply)
+ CastSpell(this, (*lootedEffectItr)->SpellID, item);
+ else
+ RemoveAurasDueToItemSpell((*lootedEffectItr)->SpellID, item->GetGUID());
+ }
+}
+
void Player::_RemoveAllItemMods()
{
TC_LOG_DEBUG("entities.player.items", "_RemoveAllItemMods start.");
@@ -12731,6 +12750,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
RemoveTradeableItem(pItem);
ApplyItemObtainSpells(pItem, false);
+ ApplyItemLootedSpell(pItem, false);
sScriptMgr->OnItemRemove(this, pItem);
@@ -26546,6 +26566,7 @@ void Player::AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore cons
Item* pItem = StoreNewItem(dest, lootItem->itemid, true, lootItem->randomBonusListId, GuidSet(), lootItem->context, lootItem->BonusListIDs);
SendNewItem(pItem, lootItem->count, false, createdByPlayer, broadcast);
+ ApplyItemLootedSpell(pItem, true);
}
Unit::ProcSkillsAndAuras(this, nullptr, PROC_FLAG_LOOTED, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr);
@@ -26642,6 +26663,8 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot, AELootResult* aeResult/*
// LootItem is being removed (looted) from the container, delete it from the DB.
if (!loot->containerID.IsEmpty())
sLootItemStorage->RemoveStoredLootItemForContainer(loot->containerID.GetCounter(), item->itemid, item->count, item->itemIndex);
+
+ ApplyItemLootedSpell(newitem, true);
}
else
SendEquipError(msg, nullptr, nullptr, item->itemid);
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index a013473c3ec..40816c70cd6 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -2342,6 +2342,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void CastItemCombatSpell(DamageInfo const& damageInfo);
void CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto);
void CastItemUseSpell(Item* item, SpellCastTargets const& targets, ObjectGuid castCount, int32* misc);
+ void ApplyItemLootedSpell(Item* item, bool apply);
void SendEquipmentSetList();
void SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& newEqSet);
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index 753dedeff21..03b42479a62 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -1204,7 +1204,7 @@ void WorldSession::HandleUseCritterItem(WorldPackets::Item::UseCritterItem& useC
for (ItemEffectEntry const* itemEffect : item->GetEffects())
{
- if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
+ if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_ON_LEARN)
continue;
if (BattlePetSpeciesEntry const* speciesEntry = sSpellMgr->GetBattlePetSpecies(uint32(itemEffect->SpellID)))
diff --git a/src/server/game/Loot/Loot.cpp b/src/server/game/Loot/Loot.cpp
index e4784f37650..71704029fb6 100644
--- a/src/server/game/Loot/Loot.cpp
+++ b/src/server/game/Loot/Loot.cpp
@@ -88,7 +88,7 @@ bool LootItem::AllowedForPlayer(Player const* player, bool isGivenByMasterLooter
for (ItemEffectEntry const* itemEffect : pProto->Effects)
{
- if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
+ if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_ON_LEARN)
continue;
if (player->HasSpell(itemEffect->SpellID))
@@ -101,7 +101,7 @@ bool LootItem::AllowedForPlayer(Player const* player, bool isGivenByMasterLooter
{
for (ItemEffectEntry const* itemEffect : pProto->Effects)
{
- if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
+ if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_ON_LEARN)
continue;
if (player->HasSpell(itemEffect->SpellID))
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index bba8045dd82..41dbd3f3caa 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -2066,7 +2066,7 @@ void Spell::EffectLearnSpell()
{
for (ItemEffectEntry const* itemEffect : m_CastItem->GetEffects())
{
- if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
+ if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_ON_LEARN)
continue;
bool dependent = false;