From e0398b0dbb4624f732f3406f6ac64f5cd005f7f8 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sun, 16 Jan 2022 22:45:56 +0100 Subject: [PATCH 1/6] Fix Mount struct --- deps/datReader/Exd/Structs.h | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/deps/datReader/Exd/Structs.h b/deps/datReader/Exd/Structs.h index 688eb16e..e9f9b4fc 100644 --- a/deps/datReader/Exd/Structs.h +++ b/deps/datReader/Exd/Structs.h @@ -1119,16 +1119,15 @@ namespace Component::Excel int8_t CNT; int8_t GEN; int8_t DEF; - int8_t padding0[2]; }; /* 201018 */ struct Mount { MountTextStruct Text; - Component::Excel::StringOffset CallSE; - Component::Excel::StringOffset CallFalseSE; - Component::Excel::StringOffset ExitSE; + StringOffset CallSE; + StringOffset CallFalseSE; + StringOffset ExitSE; float Slowdown; float MoveAccel_Run; float MoveAccel_Walk; @@ -1141,14 +1140,6 @@ namespace Component::Excel float RotateSpeed_WOW; float RotateSpeed_AutoRun; float RotateSpeed_LockOn; - float RotateAccel_FFXIVRun; - float RotateAccel_FFXIVWalk; - float RotateAccel_LockOn; - float BattleMoveSpeed_Run; - float BattleMoveSpeed_RunLR; - float BattleMoveSpeed_Back; - float ScaleMale[6]; - float ScaleFemale[6]; int32_t Model; int32_t EquipHead; int32_t EquipBody; @@ -1157,19 +1148,12 @@ namespace Component::Excel uint16_t BGM; uint16_t Icon; uint16_t Action[2]; - uint8_t ExitMoveDist; - uint8_t ExitMoveSpeed; - uint8_t UIPriority; + uint16_t unknown[2]; + uint8_t unknown2[6]; uint8_t RadiusRate; - uint8_t BaseMotionSpeed_Run; - uint8_t BaseMotionSpeed_Walk; - uint8_t LinkNum; - int8_t SaveIndex; - uint8_t padding1 : 5; - uint8_t ExHotbarEnableConfig : 1; - uint8_t IsFloat : 1; - uint8_t IsEmote : 1; - int8_t padding2[3]; + uint8_t unknown3[3]; + int8_t MountOrder; + uint8_t unknown4 : 4; }; /* 201019 */ 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 2/6] 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(); From 2f9a56e6a117bd9b2c64ea489ed8971507bc449d Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sun, 16 Jan 2022 22:49:58 +0100 Subject: [PATCH 3/6] Add missing namespace --- deps/datReader/Exd/Structs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/datReader/Exd/Structs.h b/deps/datReader/Exd/Structs.h index e9f9b4fc..1f437056 100644 --- a/deps/datReader/Exd/Structs.h +++ b/deps/datReader/Exd/Structs.h @@ -1125,9 +1125,9 @@ namespace Component::Excel struct Mount { MountTextStruct Text; - StringOffset CallSE; - StringOffset CallFalseSE; - StringOffset ExitSE; + Component::Excel::StringOffset CallSE; + Component::Excel::StringOffset CallFalseSE; + Component::Excel::StringOffset ExitSE; float Slowdown; float MoveAccel_Run; float MoveAccel_Walk; From 62dabd571cf532b18b01a1a1505696298f6c6464 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sun, 16 Jan 2022 22:53:02 +0100 Subject: [PATCH 4/6] Fix formatting --- src/world/Actor/Player.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 9aba9187..eb1a0fb5 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1158,7 +1158,6 @@ 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 ) From 637fe3614d22f1d734fd8b77e6ba4a07eac04336 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sun, 16 Jan 2022 22:56:49 +0100 Subject: [PATCH 5/6] Remove logging line --- src/world/Actor/Player.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index eb1a0fb5..59d69950 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1165,8 +1165,6 @@ 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; From c19df0e63775f10f0678f450a24e89969ed14a01 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sun, 16 Jan 2022 23:19:10 +0100 Subject: [PATCH 6/6] More formatting --- src/world/Actor/Player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 59d69950..976d9b8d 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1165,7 +1165,7 @@ void Sapphire::Entity::Player::unlockMount( uint32_t mountId ) auto& exdData = Common::Service< Data::ExdData >::ref(); auto mount = exdData.getRow< Component::Excel::Mount >( mountId ); - if ( mount->data().MountOrder == -1 ) + if( mount->data().MountOrder == -1 ) return; m_mountGuide[ mount->data().MountOrder / 8 ] |= ( 1 << ( mount->data().MountOrder % 8 ) ); @@ -1392,7 +1392,7 @@ void Sapphire::Entity::Player::setTitle( uint16_t titleId ) void Sapphire::Entity::Player::setMaxGearSets( uint8_t amount ) { - if (amount == 1) + if( amount == 1 ) amount = 5; m_equippedMannequin = amount;