Skip to content

Commit

Permalink
Core/Items: correctly cast spells on item store. Closes TrinityCore#4208
Browse files Browse the repository at this point in the history
  • Loading branch information
Star-lion committed May 22, 2012
1 parent 4943eb4 commit 9904023
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -12180,11 +12180,6 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update
pItem->SetItemRandomProperties(randomPropertyId);
pItem = StoreItem(dest, pItem, update);

const ItemTemplate* proto = pItem->GetTemplate();
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger
CastSpell(this, proto->Spells[i].SpellId, true, pItem);

if (allowedLooters.size() > 1 && pItem->GetTemplate()->GetMaxStackSize() == 1 && pItem->IsSoulBound())
{
pItem->SetSoulboundTradeable(allowedLooters);
Expand Down Expand Up @@ -12290,6 +12285,14 @@ 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 < MAX_ITEM_PROTO_SPELLS; ++i)
if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
if (HasAura(proto->Spells[i].SpellId))
CastSpell(this, proto->Spells[i].SpellId, true, pItem);

return pItem;
}
else
Expand Down Expand Up @@ -12326,6 +12329,13 @@ 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 < MAX_ITEM_PROTO_SPELLS; ++i)
if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
if (HasAura(proto->Spells[i].SpellId))
CastSpell(this, proto->Spells[i].SpellId, true, pItem2);

return pItem2;
}
}
Expand Down

0 comments on commit 9904023

Please sign in to comment.