From 575fb3785440b37627c7e19004676c15fc5e63d0 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sun, 16 Jan 2022 22:48:55 +0100 Subject: [PATCH] Implement mount unlocking --- src/common/Common.h | 1 + src/common/Network/CommonActorControl.h | 6 ++++++ src/world/Action/ItemAction.cpp | 15 +++++++++++++++ src/world/Action/ItemAction.h | 2 ++ src/world/Actor/Player.cpp | 19 +++++++++++++++++++ src/world/Actor/Player.h | 3 +++ 6 files changed, 46 insertions(+) diff --git a/src/common/Common.h b/src/common/Common.h index 64f66173..5375c46c 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -899,6 +899,7 @@ namespace Sapphire::Common KeyItemAction = 1, ItemActionVFX = 852, ItemActionVFX2 = 944, + ItemActionMount = 1322, }; enum ActionEffectDisplayType : uint8_t diff --git a/src/common/Network/CommonActorControl.h b/src/common/Network/CommonActorControl.h index dd40b518..1b0629c9 100644 --- a/src/common/Network/CommonActorControl.h +++ b/src/common/Network/CommonActorControl.h @@ -278,6 +278,12 @@ namespace Sapphire::Network::ActorControl */ SetMountSpeed = 0x39F, + /*! + * param1 = mount ID + * param2 = unlock/lock (1/0) + */ + SetMountBitmask = 0x387, + Dismount = 0x3A1, // updated 4.5 // Duty Recorder diff --git a/src/world/Action/ItemAction.cpp b/src/world/Action/ItemAction.cpp index 89d57a26..15edc483 100644 --- a/src/world/Action/ItemAction.cpp +++ b/src/world/Action/ItemAction.cpp @@ -51,6 +51,13 @@ void ItemAction::execute() break; } + + case Common::ItemActionType::ItemActionMount: + { + handleMountItem(); + + break; + } } } @@ -72,4 +79,12 @@ void ItemAction::handleVFXItem() effectPacket->addTargetEffect( effect, static_cast< uint64_t >( getSourceChara()->getId() ) ); m_pSource->sendToInRangeSet( effectPacket, true ); +} + +void ItemAction::handleMountItem() +{ + auto player = getSourceChara()->getAsPlayer(); + + player->unlockMount( m_itemAction->data().Calcu0Arg[ 0 ] ); + player->dropInventoryItem ( static_cast< Common::InventoryType >( m_itemSourceContainer ), m_itemSourceSlot ); } \ No newline at end of file diff --git a/src/world/Action/ItemAction.h b/src/world/Action/ItemAction.h index a3b60faa..d4a3d394 100644 --- a/src/world/Action/ItemAction.h +++ b/src/world/Action/ItemAction.h @@ -27,6 +27,8 @@ namespace Sapphire::World::Action private: void handleVFXItem(); + void handleMountItem(); + private: std::shared_ptr< Component::Excel::ExcelStruct< Component::Excel::ItemAction > > m_itemAction; diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index ceab1ebc..9aba9187 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1158,6 +1158,22 @@ const Sapphire::Entity::Player::UnlockList& Sapphire::Entity::Player::getUnlockB const Sapphire::Entity::Player::OrchestrionList& Sapphire::Entity::Player::getOrchestrionBitmask() const { return m_orchestrion; + +} + +void Sapphire::Entity::Player::unlockMount( uint32_t mountId ) +{ + auto& exdData = Common::Service< Data::ExdData >::ref(); + auto mount = exdData.getRow< Component::Excel::Mount >( mountId ); + + Logger::debug("Order: {0}", mount->data().MountOrder); + + if ( mount->data().MountOrder == -1 ) + return; + + m_mountGuide[ mount->data().MountOrder / 8 ] |= ( 1 << ( mount->data().MountOrder % 8 ) ); + + queuePacket( makeActorControlSelf( getId(), Network::ActorControl::SetMountBitmask, mount->data().MountOrder, 1 ) ); } Sapphire::Entity::Player::MountList& Sapphire::Entity::Player::getMountGuideBitmask() @@ -1379,6 +1395,9 @@ void Sapphire::Entity::Player::setTitle( uint16_t titleId ) void Sapphire::Entity::Player::setMaxGearSets( uint8_t amount ) { + if (amount == 1) + amount = 5; + m_equippedMannequin = amount; queuePacket( makeActorControlSelf( getId(), SetMaxGearSets, m_equippedMannequin ) ); diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 3c072ed9..d65a6195 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -464,6 +464,9 @@ namespace Sapphire::Entity /*! return a const pointer to the orchestrion bitmask array */ const OrchestrionList& getOrchestrionBitmask() const; + /*! unlock a mount */ + void unlockMount( uint32_t mountId ); + /*! return a const pointer to the setMount guide bitmask array */ MountList& getMountGuideBitmask();