mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +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
|
|
@ -822,33 +822,33 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
// bags and main-hand weapon must equipped at this moment
|
||||
// now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon)
|
||||
// or ammo not equipped in special bag
|
||||
for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
if(Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
uint16 eDest;
|
||||
// equip offhand weapon/shield if it attempt equipped before main-hand weapon
|
||||
uint8 msg = CanEquipItem( NULL_SLOT, eDest, pItem, false );
|
||||
if( msg == EQUIP_ERR_OK )
|
||||
InventoryResult msg = CanEquipItem(NULL_SLOT, eDest, pItem, false);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
RemoveItem(INVENTORY_SLOT_BAG_0, i,true);
|
||||
EquipItem( eDest, pItem, true);
|
||||
RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
|
||||
EquipItem(eDest, pItem, true);
|
||||
}
|
||||
// move other items to more appropriate slots (ammo not equipped in special bag)
|
||||
else
|
||||
{
|
||||
ItemPosCountVec sDest;
|
||||
msg = CanStoreItem( NULL_BAG, NULL_SLOT, sDest, pItem, false );
|
||||
if( msg == EQUIP_ERR_OK )
|
||||
msg = CanStoreItem(NULL_BAG, NULL_SLOT, sDest, pItem, false);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
RemoveItem(INVENTORY_SLOT_BAG_0, i,true);
|
||||
pItem = StoreItem( sDest, pItem, true);
|
||||
}
|
||||
|
||||
// if this is ammo then use it
|
||||
msg = CanUseAmmo( pItem->GetEntry() );
|
||||
if( msg == EQUIP_ERR_OK )
|
||||
SetAmmo( pItem->GetEntry() );
|
||||
msg = CanUseAmmo(pItem->GetEntry());
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
SetAmmo(pItem->GetEntry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
|
@ -10530,7 +10530,7 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo
|
|||
// - in-progress arenas
|
||||
if (!pProto->CanChangeEquipStateInCombat())
|
||||
{
|
||||
if( isInCombat() )
|
||||
if (isInCombat())
|
||||
return EQUIP_ERR_NOT_IN_COMBAT;
|
||||
|
||||
if (BattleGround* bg = GetBattleGround())
|
||||
|
|
@ -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))
|
||||
|
|
@ -10571,7 +10571,7 @@ InventoryResult Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, boo
|
|||
// check unique-equipped special item classes
|
||||
if (pProto->Class == ITEM_CLASS_QUIVER)
|
||||
{
|
||||
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
|
||||
{
|
||||
if (Item* pBag = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
|
||||
{
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue