From b559debd619613cfe4348db073617e8b1c97fe4e Mon Sep 17 00:00:00 2001 From: Skyliegirl33 <44952533+Skyliegirl33@users.noreply.github.com> Date: Thu, 16 Sep 2021 20:47:41 +0200 Subject: [PATCH] Only commit changes for this PR --- .../Network/PacketDef/Zone/ServerZoneDef.h | 5 ++- src/world/Action/ItemAction.cpp | 14 ++++++++ src/world/Action/ItemAction.h | 2 ++ src/world/Actor/Player.h | 9 +++-- src/world/Actor/PlayerInventory.cpp | 35 +++++++++++-------- 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 87ab1c3d..62d372a6 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -1344,7 +1344,10 @@ namespace Sapphire::Network::Packets::Server uint32_t catalogId; uint32_t someActorId; int32_t targetStorageId; - uint32_t padding3[3]; + uint16_t targetSlotId; + uint16_t padding3; + uint32_t targetStackSize; + uint32_t targetCatalogId; }; diff --git a/src/world/Action/ItemAction.cpp b/src/world/Action/ItemAction.cpp index 50b0cccd..3707a5b5 100644 --- a/src/world/Action/ItemAction.cpp +++ b/src/world/Action/ItemAction.cpp @@ -54,6 +54,13 @@ void ItemAction::execute() break; } + + case Common::ItemActionType::ItemActionOrchestrion: + { + handleOrchestrionItem(); + + break; + } } } @@ -69,6 +76,13 @@ void ItemAction::handleMountItem() player->dropInventoryItem ( static_cast< Common::InventoryType >( m_itemSourceContainer ), m_itemSourceSlot, false ); } +void ItemAction::handleOrchestrionItem() +{ + auto player = getSourceChara()->getAsPlayer(); + player->learnSong( m_itemAction->data[ 0 ], m_itemAction->data[ 1 ] ); + player->dropInventoryItem ( static_cast< Common::InventoryType >( m_itemSourceContainer ), m_itemSourceSlot, false ); +} + void ItemAction::handleVFXItem() { Common::EffectEntry effect{}; diff --git a/src/world/Action/ItemAction.h b/src/world/Action/ItemAction.h index 73c78cbb..fdce1464 100644 --- a/src/world/Action/ItemAction.h +++ b/src/world/Action/ItemAction.h @@ -29,6 +29,8 @@ namespace Sapphire::World::Action void handleMountItem(); + void handleOrchestrionItem(); + private: Sapphire::Data::ItemActionPtr m_itemAction; diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index f8db2c96..8a13ef47 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -348,6 +348,9 @@ namespace Sapphire::Entity /*! send player ilvl */ void sendItemLevel(); + /*! set player ilvl */ + void setItemLevel(); + /*! get the current main hand model */ uint64_t getModelMainWeapon() const; @@ -946,12 +949,14 @@ namespace Sapphire::Entity InvSlotPair getFreeBagSlot(); + InvSlotPair getFreeContainerSlot( uint32_t containerId ); + ItemPtr addItem( uint32_t catalogId, uint32_t quantity = 1, bool isHq = false, bool silent = false, bool canMerge = true, bool sendLootMessage = false ); ItemPtr addItem( ItemPtr itemToAdd, bool silent = false, bool canMerge = true, bool sendLootMessage = false ); void moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot, bool sendUpdate = true ); - void swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot ); + void swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot, bool sendUpdate = true ); void discardItem( uint16_t fromInventoryId, uint8_t fromSlotId ); @@ -964,8 +969,6 @@ namespace Sapphire::Entity bool updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem ); - bool updateGearContainer( uint8_t slotId, ItemPtr pItem ); - /*! calculate and return player ilvl based off equipped gear */ uint16_t calculateEquippedGearItemLevel(); diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index caf9dce3..09604aec 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -110,6 +110,11 @@ void Sapphire::Entity::Player::sendItemLevel() queuePacket( makeActorControl( getId(), SetItemLevel, getItemLevel(), 0 ) ); } +void Sapphire::Entity::Player::setItemLevel() +{ + m_itemLevel = calculateEquippedGearItemLevel(); +} + void Sapphire::Entity::Player::equipWeapon( ItemPtr pItem, bool updateClass ) { auto& exdData = Common::Service< Sapphire::Data::ExdDataGenerated >::ref(); @@ -459,6 +464,17 @@ Sapphire::Entity::Player::InvSlotPairVec Sapphire::Entity::Player::getSlotsOfIte return outVec; } +Sapphire::Entity::Player::InvSlotPair Sapphire::Entity::Player::getFreeContainerSlot( uint32_t containerId ) +{ + auto freeSlot = static_cast < int8_t >( m_storageMap[ containerId ]->getFreeSlot() ); + + if( freeSlot != -1 ) + return std::make_pair( containerId, freeSlot ); + + // no room in inventory + return std::make_pair( 0, -1 ); +} + Sapphire::Entity::Player::InvSlotPair Sapphire::Entity::Player::getFreeBagSlot() { for( auto i : { Bag0, Bag1, Bag2, Bag3 } ) @@ -742,20 +758,11 @@ Sapphire::Entity::Player::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId if( static_cast< InventoryType >( fromInventoryId ) == GearSet0 ) unequipItem( static_cast< GearSetSlot >( fromSlotId ), tmpItem, sendUpdate ); - if( static_cast< InventoryType >( toInventoryId ) == GearSet0 || - static_cast< InventoryType >( fromInventoryId ) == GearSet0 ) + if( ( static_cast< InventoryType >( toInventoryId ) == GearSet0 || + static_cast< InventoryType >( fromInventoryId ) == GearSet0 ) && sendUpdate ) sendStatusEffectUpdate(); // send if any equip is changed } -bool Sapphire::Entity::Player::updateGearContainer( uint8_t slotId, ItemPtr pItem ) -{ - m_storageMap[ GearSet0 ]->setItem( slotId, pItem ); - - writeInventory( GearSet0 ); - - return true; -} - bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem ) { auto containerType = World::Manager::ItemMgr::getContainerType( storageId ); @@ -863,7 +870,7 @@ void Sapphire::Entity::Player::mergeItem( uint16_t fromInventoryId, uint8_t from } void Sapphire::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, - uint16_t toInventoryId, uint8_t toSlot ) + uint16_t toInventoryId, uint8_t toSlot, bool sendUpdate ) { auto fromItem = m_storageMap[ fromInventoryId ]->getItem( fromSlotId ); auto toItem = m_storageMap[ toInventoryId ]->getItem( toSlot ); @@ -891,8 +898,8 @@ void Sapphire::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromS updateContainer( toInventoryId, toSlot, fromItem ); updateContainer( fromInventoryId, fromSlotId, toItem ); - if( static_cast< InventoryType >( toInventoryId ) == GearSet0 || - static_cast< InventoryType >( fromInventoryId ) == GearSet0 ) + if( ( static_cast< InventoryType >( toInventoryId ) == GearSet0 || + static_cast< InventoryType >( fromInventoryId ) == GearSet0 ) && sendUpdate ) sendStatusEffectUpdate(); // send if any equip is changed }