mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 16:37:45 +00:00
Fix and optimize itemlevel; IsWeapon Item Property;
This commit is contained in:
parent
f8b7acc8c4
commit
ed23ff9a60
4 changed files with 25 additions and 11 deletions
|
@ -86,7 +86,7 @@ void Core::Entity::Player::equipWeapon( Core::ItemPtr pItem )
|
|||
}
|
||||
|
||||
// equip an item
|
||||
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, Core::ItemPtr pItem, bool sendModel )
|
||||
void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, Core::ItemPtr pItem, bool sendUpdate )
|
||||
{
|
||||
|
||||
//g_log.debug( "Equipping into slot " + std::to_string( equipSlotId ) );
|
||||
|
@ -118,11 +118,12 @@ void Core::Entity::Player::equipItem( Inventory::EquipSlot equipSlotId, Core::It
|
|||
|
||||
}
|
||||
|
||||
if( sendModel )
|
||||
if( sendUpdate )
|
||||
{
|
||||
this->sendModel();
|
||||
|
||||
m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
|
||||
sendItemLevel();
|
||||
m_itemLevel = getInventory()->calculateEquippedGearItemLevel();
|
||||
sendItemLevel();
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Entity::Player::unequipItem( Inventory::EquipSlot equipSlotId, ItemPtr pItem )
|
||||
|
|
|
@ -833,20 +833,26 @@ uint16_t Core::Inventory::calculateEquippedGearItemLevel()
|
|||
{
|
||||
uint32_t iLvlResult = 0;
|
||||
|
||||
for ( uint16_t i = 0; i < sizeof( m_inventoryMap[GearSet0] ); i++ )
|
||||
auto gearSetMap = m_inventoryMap[GearSet0]->getItemMap();
|
||||
|
||||
auto it = gearSetMap.begin();
|
||||
|
||||
while ( it != gearSetMap.end() )
|
||||
{
|
||||
auto currItem = m_inventoryMap[GearSet0]->getItem( i );
|
||||
auto currItem = it->second;
|
||||
|
||||
if ( currItem )
|
||||
{
|
||||
g_log.debug( std::to_string( currItem->getId() ) + " ilvl: " + std::to_string( currItem->getItemLevel() ) );
|
||||
iLvlResult += currItem->getItemLevel();
|
||||
|
||||
// If weapon isn't one-handed
|
||||
if ( currItem->getCategory() != ItemCategory::CnjWep ||
|
||||
currItem->getCategory() != ItemCategory::ThmWep )
|
||||
// If item is weapon and isn't one-handed
|
||||
if ( currItem->isWeapon() &&
|
||||
( currItem->getCategory() != ItemCategory::CnjWep ||
|
||||
currItem->getCategory() != ItemCategory::ThmWep ) )
|
||||
iLvlResult += currItem->getItemLevel();
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
return boost::algorithm::clamp( iLvlResult / 12, 0, 9999 );
|
||||
|
|
|
@ -68,6 +68,11 @@ uint16_t Core::Item::getWeaponDmg() const
|
|||
return m_weaponDmg;
|
||||
}
|
||||
|
||||
bool Core::Item::isWeapon() const
|
||||
{
|
||||
return (m_weaponDmg != 0);
|
||||
}
|
||||
|
||||
uint32_t Core::Item::getId() const
|
||||
{
|
||||
return m_id;
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
|
||||
uint16_t getWeaponDmg() const;
|
||||
|
||||
bool isWeapon() const;
|
||||
|
||||
float getAutoAttackDmg() const;
|
||||
|
||||
uint16_t getItemLevel() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue