mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/Player: Recast lost by death item obtain spells of any items held in the inventory when resurrecting
I HAS BUKKIT
Closes #5184
(cherry picked from commit e1354c72e8)
This commit is contained in:
@@ -4244,6 +4244,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
|
||||
// update visibility
|
||||
UpdateObjectVisibility();
|
||||
|
||||
// recast lost by death auras of any items held in the inventory
|
||||
CastAllObtainSpells();
|
||||
|
||||
if (!applySickness)
|
||||
return;
|
||||
|
||||
@@ -7631,6 +7634,46 @@ void Player::_ApplyWeaponDamage(uint8 slot, Item* item, bool apply)
|
||||
UpdateDamagePhysical(attType);
|
||||
}
|
||||
|
||||
void Player::CastAllObtainSpells()
|
||||
{
|
||||
for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; ++slot)
|
||||
if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
|
||||
ApplyItemObtainSpells(item, true);
|
||||
|
||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
Bag* bag = GetBagByPos(i);
|
||||
if (!bag)
|
||||
continue;
|
||||
|
||||
for (uint32 slot = 0; slot < bag->GetBagSize(); ++slot)
|
||||
if (Item* item = bag->GetItemByPos(slot))
|
||||
ApplyItemObtainSpells(item, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ApplyItemObtainSpells(Item* item, bool apply)
|
||||
{
|
||||
ItemTemplate const* itemTemplate = item->GetTemplate();
|
||||
for (uint8 i = 0; i < itemTemplate->Effects.size(); ++i)
|
||||
{
|
||||
if (itemTemplate->Effects[i]->TriggerType != ITEM_SPELLTRIGGER_ON_OBTAIN) // On obtain trigger
|
||||
continue;
|
||||
|
||||
int32 const spellId = itemTemplate->Effects[i]->SpellID;
|
||||
if (spellId <= 0)
|
||||
continue;
|
||||
|
||||
if (apply)
|
||||
{
|
||||
if (!HasAura(spellId))
|
||||
CastSpell(this, spellId, true, item);
|
||||
}
|
||||
else
|
||||
RemoveAurasDueToSpell(spellId);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::ApplyItemDependentAuras(Item* item, bool apply)
|
||||
{
|
||||
if (apply)
|
||||
@@ -11820,12 +11863,8 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
|
||||
AddEnchantmentDurations(pItem);
|
||||
AddItemDurations(pItem);
|
||||
|
||||
const ItemTemplate* proto = pItem->GetTemplate();
|
||||
for (uint8 i = 0; i < proto->Effects.size(); ++i)
|
||||
if (proto->Effects[i]->TriggerType == ITEM_SPELLTRIGGER_ON_OBTAIN) // On obtain trigger
|
||||
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
if (!HasAura(proto->Effects[i]->SpellID))
|
||||
CastSpell(this, proto->Effects[i]->SpellID, true, pItem);
|
||||
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
ApplyItemObtainSpells(pItem, true);
|
||||
|
||||
return pItem;
|
||||
}
|
||||
@@ -11863,12 +11902,8 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
|
||||
|
||||
pItem2->SetState(ITEM_CHANGED, this);
|
||||
|
||||
const ItemTemplate* proto = pItem2->GetTemplate();
|
||||
for (uint8 i = 0; i < proto->Effects.size(); ++i)
|
||||
if (proto->Effects[i]->TriggerType == ITEM_SPELLTRIGGER_ON_OBTAIN) // On obtain trigger
|
||||
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
if (!HasAura(proto->Effects[i]->SpellID))
|
||||
CastSpell(this, proto->Effects[i]->SpellID, true, pItem2);
|
||||
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
ApplyItemObtainSpells(pItem2, true);
|
||||
|
||||
return pItem2;
|
||||
}
|
||||
@@ -12327,10 +12362,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
|
||||
pItem->ClearSoulboundTradeable(this);
|
||||
RemoveTradeableItem(pItem);
|
||||
|
||||
const ItemTemplate* proto = pItem->GetTemplate();
|
||||
for (uint8 i = 0; i < proto->Effects.size(); ++i)
|
||||
if (proto->Effects[i]->TriggerType == ITEM_SPELLTRIGGER_ON_OBTAIN) // On obtain trigger
|
||||
RemoveAurasDueToSpell(proto->Effects[i]->SpellID);
|
||||
ApplyItemObtainSpells(pItem, false);
|
||||
|
||||
ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
|
||||
sScriptMgr->OnItemRemove(this, pItem);
|
||||
|
||||
@@ -2030,6 +2030,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
|
||||
void ResetAllPowers();
|
||||
|
||||
void CastAllObtainSpells();
|
||||
void ApplyItemObtainSpells(Item* item, bool apply);
|
||||
void ApplyItemDependentAuras(Item* item, bool apply);
|
||||
|
||||
void _ApplyItemMods(Item* item, uint8 slot, bool apply, bool updateItemAuras = true);
|
||||
|
||||
Reference in New Issue
Block a user