mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[11645] Fixed work EffectSummonChangeItem, for example, for item. 17223
Also * Move item comvert code from spell effect to new function. * Some code style cleanups.
This commit is contained in:
parent
92e0b5941f
commit
a97370a7f0
6 changed files with 113 additions and 108 deletions
|
|
@ -493,7 +493,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
|
|||
Item *it = pl->GetMItem(itemId);
|
||||
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false );
|
||||
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false );
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
m->RemoveItem(itemId);
|
||||
|
|
@ -771,7 +771,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
|
|||
DETAIL_LOG("HandleMailCreateTextItem mailid=%u", mailId);
|
||||
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, bodyItem, false );
|
||||
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, bodyItem, false );
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
m->checked = m->checked | MAIL_CHECK_MASK_COPIED;
|
||||
|
|
|
|||
|
|
@ -828,7 +828,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
{
|
||||
uint16 eDest;
|
||||
// equip offhand weapon/shield if it attempt equipped before main-hand weapon
|
||||
uint8 msg = CanEquipItem( NULL_SLOT, eDest, pItem, false );
|
||||
InventoryResult msg = CanEquipItem(NULL_SLOT, eDest, pItem, false);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
|
||||
|
|
@ -10496,7 +10496,7 @@ InventoryResult Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item,
|
|||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
||||
}
|
||||
|
||||
InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading ) const
|
||||
InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool direct_action ) const
|
||||
{
|
||||
dest = 0;
|
||||
if (pItem)
|
||||
|
|
@ -10518,7 +10518,7 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo
|
|||
return res;
|
||||
|
||||
// check this only in game
|
||||
if (not_loading)
|
||||
if (direct_action)
|
||||
{
|
||||
// May be here should be more stronger checks; STUNNED checked
|
||||
// ROOT, CONFUSED, DISTRACTED, FLEEING this needs to be checked.
|
||||
|
|
@ -10558,7 +10558,7 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo
|
|||
if (eslot == NULL_SLOT)
|
||||
return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
|
||||
|
||||
InventoryResult msg = CanUseItem(pItem , not_loading);
|
||||
InventoryResult msg = CanUseItem(pItem , direct_action);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
return msg;
|
||||
if (!swap && GetItemByPos(INVENTORY_SLOT_BAG_0, eslot))
|
||||
|
|
@ -10624,7 +10624,7 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo
|
|||
// offhand item must can be stored in inventory for offhand item and it also must be unequipped
|
||||
Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND );
|
||||
ItemPosCountVec off_dest;
|
||||
if (offItem && (!not_loading ||
|
||||
if (offItem && (!direct_action ||
|
||||
CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK ||
|
||||
CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ) != EQUIP_ERR_OK ))
|
||||
return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL;
|
||||
|
|
@ -10865,13 +10865,13 @@ InventoryResult Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &des
|
|||
return EQUIP_ERR_BANK_FULL;
|
||||
}
|
||||
|
||||
InventoryResult Player::CanUseItem( Item *pItem, bool not_loading ) const
|
||||
InventoryResult Player::CanUseItem(Item *pItem, bool direct_action) const
|
||||
{
|
||||
if (pItem)
|
||||
{
|
||||
DEBUG_LOG( "STORAGE: CanUseItem item = %u", pItem->GetEntry());
|
||||
|
||||
if (!isAlive() && not_loading)
|
||||
if (!isAlive() && direct_action)
|
||||
return EQUIP_ERR_YOU_ARE_DEAD;
|
||||
|
||||
//if (isStunned())
|
||||
|
|
@ -21631,6 +21631,70 @@ void Player::AutoStoreLoot(Loot& loot, bool broadcast, uint8 bag, uint8 slot)
|
|||
}
|
||||
}
|
||||
|
||||
Item* Player::ConvertItem(Item* item, uint32 newItemId)
|
||||
{
|
||||
uint16 pos = item->GetPos();
|
||||
|
||||
Item *pNewItem = Item::CreateItem(newItemId, 1, this);
|
||||
if (!pNewItem)
|
||||
return NULL;
|
||||
|
||||
// copy enchantments
|
||||
for (uint8 j= PERM_ENCHANTMENT_SLOT; j<=TEMP_ENCHANTMENT_SLOT; ++j)
|
||||
{
|
||||
if (item->GetEnchantmentId(EnchantmentSlot(j)))
|
||||
pNewItem->SetEnchantment(EnchantmentSlot(j), item->GetEnchantmentId(EnchantmentSlot(j)),
|
||||
item->GetEnchantmentDuration(EnchantmentSlot(j)), item->GetEnchantmentCharges(EnchantmentSlot(j)));
|
||||
}
|
||||
|
||||
// copy durability
|
||||
if (item->GetUInt32Value(ITEM_FIELD_DURABILITY) < item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
|
||||
{
|
||||
double loosePercent = 1 - item->GetUInt32Value(ITEM_FIELD_DURABILITY) / double(item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY));
|
||||
DurabilityLoss(pNewItem, loosePercent);
|
||||
}
|
||||
|
||||
if (IsInventoryPos(pos))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
InventoryResult msg = CanStoreItem(item->GetBagSlot(), item->GetSlot(), dest, pNewItem, true);
|
||||
// ignore cast/combat time restriction
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||
return StoreItem( dest, pNewItem, true);
|
||||
}
|
||||
}
|
||||
else if (IsBankPos(pos))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
InventoryResult msg = CanBankItem(item->GetBagSlot(), item->GetSlot(), dest, pNewItem, true);
|
||||
// ignore cast/combat time restriction
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||
return BankItem(dest, pNewItem, true);
|
||||
}
|
||||
}
|
||||
else if (IsEquipmentPos (pos))
|
||||
{
|
||||
uint16 dest;
|
||||
InventoryResult msg = CanEquipItem(item->GetSlot(), dest, pNewItem, true, false);
|
||||
// ignore cast/combat time restriction
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||
pNewItem = EquipItem(dest, pNewItem, true);
|
||||
AutoUnequipOffhandIfNeed();
|
||||
return pNewItem;
|
||||
}
|
||||
}
|
||||
|
||||
// fail
|
||||
delete pNewItem;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32 Player::CalculateTalentsPoints() const
|
||||
{
|
||||
uint32 base_level = getClass() == CLASS_DEATH_KNIGHT ? 55 : 9;
|
||||
|
|
|
|||
|
|
@ -1220,14 +1220,14 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
}
|
||||
InventoryResult CanStoreItems(Item **pItem,int count) const;
|
||||
InventoryResult CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, bool swap) const;
|
||||
InventoryResult CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const;
|
||||
InventoryResult CanEquipItem(uint8 slot, uint16 &dest, Item *pItem, bool swap, bool direct_action = true) const;
|
||||
|
||||
InventoryResult CanEquipUniqueItem( Item * pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
|
||||
InventoryResult CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1 ) const;
|
||||
InventoryResult CanUnequipItems( uint32 item, uint32 count ) const;
|
||||
InventoryResult CanUnequipItem( uint16 src, bool swap ) const;
|
||||
InventoryResult CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const;
|
||||
InventoryResult CanUseItem( Item *pItem, bool not_loading = true ) const;
|
||||
InventoryResult CanUseItem(Item *pItem, bool direct_action = true) const;
|
||||
bool HasItemTotemCategory(uint32 TotemCategory) const;
|
||||
InventoryResult CanUseItem(ItemPrototype const *pItem) const;
|
||||
InventoryResult CanUseAmmo( uint32 item ) const;
|
||||
|
|
@ -1242,6 +1242,8 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false, uint8 bag = NULL_BAG, uint8 slot = NULL_SLOT);
|
||||
void AutoStoreLoot(Loot& loot, bool broadcast = false, uint8 bag = NULL_BAG, uint8 slot = NULL_SLOT);
|
||||
|
||||
Item* ConvertItem(Item* item, uint32 newItemId);
|
||||
|
||||
InventoryResult _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const;
|
||||
InventoryResult _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -4478,73 +4478,12 @@ void Spell::EffectSummonChangeItem(SpellEffectIndex eff_idx)
|
|||
if (!newitemid)
|
||||
return;
|
||||
|
||||
uint16 pos = m_CastItem->GetPos();
|
||||
|
||||
Item *pNewItem = Item::CreateItem( newitemid, 1, player);
|
||||
if (!pNewItem)
|
||||
return;
|
||||
|
||||
for(uint8 j= PERM_ENCHANTMENT_SLOT; j<=TEMP_ENCHANTMENT_SLOT; ++j)
|
||||
{
|
||||
if (m_CastItem->GetEnchantmentId(EnchantmentSlot(j)))
|
||||
pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j)));
|
||||
}
|
||||
|
||||
if (m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
|
||||
{
|
||||
double loosePercent = 1 - m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) / double(m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY));
|
||||
player->DurabilityLoss(pNewItem, loosePercent);
|
||||
}
|
||||
|
||||
if (player->IsInventoryPos(pos))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = player->CanStoreItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true );
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
|
||||
Item* oldItem = m_CastItem;
|
||||
|
||||
// prevent crash at access and unexpected charges counting with item update queue corrupt
|
||||
ClearCastItem();
|
||||
|
||||
player->StoreItem( dest, pNewItem, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (player->IsBankPos (pos))
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = player->CanBankItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true );
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
|
||||
|
||||
// prevent crash at access and unexpected charges counting with item update queue corrupt
|
||||
ClearCastItem();
|
||||
|
||||
player->BankItem( dest, pNewItem, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (player->IsEquipmentPos (pos))
|
||||
{
|
||||
uint16 dest;
|
||||
uint8 msg = player->CanEquipItem( m_CastItem->GetSlot(), dest, pNewItem, true );
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), true);
|
||||
|
||||
// prevent crash at access and unexpected charges counting with item update queue corrupt
|
||||
ClearCastItem();
|
||||
|
||||
player->EquipItem( dest, pNewItem, true);
|
||||
player->AutoUnequipOffhandIfNeed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// fail
|
||||
delete pNewItem;
|
||||
player->ConvertItem(oldItem, newitemid);
|
||||
}
|
||||
|
||||
void Spell::EffectProficiency(SpellEffectIndex /*eff_idx*/)
|
||||
|
|
|
|||
|
|
@ -3698,18 +3698,18 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip
|
|||
if (m_currentSpells[CURRENT_GENERIC_SPELL] &&
|
||||
(m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) &&
|
||||
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED))
|
||||
return(true);
|
||||
return true;
|
||||
|
||||
// channeled spells may be delayed, but they are still considered casted
|
||||
else if (!skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] &&
|
||||
(m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED))
|
||||
return(true);
|
||||
return true;
|
||||
|
||||
// autorepeat spells may be finished or delayed, but they are still considered casted
|
||||
else if (!skipAutorepeat && m_currentSpells[CURRENT_AUTOREPEAT_SPELL])
|
||||
return(true);
|
||||
return true;
|
||||
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11644"
|
||||
#define REVISION_NR "11645"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue