From add5c215d48179402785b556ceb2d623c69e60ab Mon Sep 17 00:00:00 2001 From: collett Date: Fri, 10 Feb 2023 09:33:00 +0900 Subject: [PATCH 01/12] gold saucer intro quest --- .../quest/subquest/goldsaucer/SubGsc001.cpp | 218 +++++++++++++ .../quest/subquest/goldsaucer/SubGsc002.cpp | 296 ++++++++++++++++++ 2 files changed, 514 insertions(+) create mode 100644 src/scripts/quest/subquest/goldsaucer/SubGsc001.cpp create mode 100644 src/scripts/quest/subquest/goldsaucer/SubGsc002.cpp diff --git a/src/scripts/quest/subquest/goldsaucer/SubGsc001.cpp b/src/scripts/quest/subquest/goldsaucer/SubGsc001.cpp new file mode 100644 index 00000000..47a31eb4 --- /dev/null +++ b/src/scripts/quest/subquest/goldsaucer/SubGsc001.cpp @@ -0,0 +1,218 @@ +// FFXIVTheMovie.ParserV3.10 +// param used: +//ACTOR1 = dummy1 +//SCENE_2 = dummy1 +//SCENE_5 = ELYENORA +#include +#include +#include +#include "Manager/TerritoryMgr.h" +#include "Manager/EventMgr.h" +#include "Territory/Territory.h" + +using namespace Sapphire; + +class SubGsc001 : public Sapphire::ScriptAPI::QuestScript +{ +public: + SubGsc001() : Sapphire::ScriptAPI::QuestScript( 65970 ){}; + ~SubGsc001() = default; + + //SEQ_0, 2 entries + //SEQ_255, 3 entries + + //ACTOR0 = 1011565 + //ACTOR1 = 1011566 + //ACTOR2 = 1004433 + //BGM0 = 250 + //ITEM0 = 2001555 + //NCUT0 = 769 + //NCUT1 = 770 + //POPRANGE0 = 5654039 + //SCREENIMAGE0 = 272 + + static constexpr auto EVENT_ON_TALK = 0; + static constexpr auto EVENT_ON_EMOTE = 1; + static constexpr auto EVENT_ON_BNPC_KILL = 2; + static constexpr auto EVENT_ON_WITHIN_RANGE = 3; + static constexpr auto EVENT_ON_ENTER_TERRITORY = 4; + static constexpr auto EVENT_ON_EVENT_ITEM = 5; + static constexpr auto EVENT_ON_EOBJ_HIT = 6; + static constexpr auto EVENT_ON_SAY = 7; + +private: + void onProgress( World::Quest& quest, Entity::Player& player, uint32_t type, uint64_t param1, uint32_t param2, uint32_t param3 ) + { + switch( quest.getSeq() ) + { + case 0: + { + if( param1 == 1011565 ) // ACTOR0 = TRADER00434 + { + if( quest.getUI8AL() != 1 ) + { + Scene00000( quest, player ); // Scene00000: Normal(QuestOffer), id=unknown + // +Callback Scene00001: Normal(Talk, QuestAccept, TargetCanMove), id=TRADER00434 + } + break; + } + if( param1 == 1011566 ) // ACTOR1 = dummy1 + { + Scene00002( quest, player ); // Scene00002: Empty(None), id=dummy1 + break; + } + break; + } + //seq 255 event item ITEM0 = UI8BH max stack 1 + case 255: + { + if( param1 == 1004433 ) // ACTOR2 = ELYENORA + { + Scene00003( quest, player ); // Scene00003: NpcTrade(Talk, TargetCanMove), id=unknown + // +Callback Scene00004: Normal(Talk, YesNo, TargetCanMove, CanCancel), id=ELYENORA + // +Callback Scene00005: Normal(CutScene, FadeIn, QuestReward, QuestComplete, AutoFadeIn), id=ELYENORA + break; + } + if( param1 == 1011565 ) // ACTOR0 = TRADER00434 + { + Scene00006( quest, player ); // Scene00006: Normal(Talk, TargetCanMove), id=TRADER00434 + break; + } + if( param1 == 1011566 ) // ACTOR1 = unknown + { + Scene00007( quest, player ); // Scene00007: Empty(None), id=unknown + break; + } + break; + } + default: + { + playerMgr().sendUrgent( player, "Sequence {} not defined.", quest.getSeq() ); + break; + } + } + } + +public: + void onTalk( World::Quest& quest, Entity::Player& player, uint64_t actorId ) override + { + onProgress( quest, player, EVENT_ON_TALK, actorId, 0, 0 ); + } + + void onEmote( World::Quest& quest, uint64_t actorId, uint32_t emoteId, Sapphire::Entity::Player& player ) override + { + playerMgr().sendDebug( player, "emote: {}", emoteId ); + onProgress( quest, player, EVENT_ON_EMOTE, actorId, 0, emoteId ); + } + + void onWithinRange( World::Quest& quest, Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z ) override + { + onProgress( quest, player, EVENT_ON_WITHIN_RANGE, static_cast< uint64_t >( param1 ), 0, 0 ); + } + + void onEnterTerritory( World::Quest& quest, Sapphire::Entity::Player& player, uint16_t param1, uint16_t param2 ) override + { + onProgress( quest, player, EVENT_ON_ENTER_TERRITORY, static_cast< uint64_t >( param1 ), static_cast< uint32_t >( param2 ), 0 ); + } + void onEventItem( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId ) override + { + onProgress( quest, player, EVENT_ON_EVENT_ITEM, actorId, 0, 0 ); + } + void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override + { + onProgress( quest, player, EVENT_ON_EOBJ_HIT, actorId, actionId, 0 ); + } + void onSay( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t sayId ) override + { + onProgress( quest, player, EVENT_ON_SAY, actorId, sayId, 0 ); + } + +private: + void checkProgressSeq0( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 255 ); + quest.setUI8BH( 1 ); + } + + void Scene00000( World::Quest& quest, Entity::Player& player ) //SEQ_0: ACTOR0, UI8AL = 1, Flag8(1)=True + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00000: Normal(QuestOffer), id=unknown" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + Scene00001( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, callback ); + } + void Scene00001( World::Quest& quest, Entity::Player& player ) //SEQ_0: ACTOR0, UI8AL = 1, Flag8(1)=True + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00001: Normal(Talk, QuestAccept, TargetCanMove), id=TRADER00434" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq0( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 1, HIDE_HOTBAR, callback ); + } + + void Scene00002( World::Quest& quest, Entity::Player& player ) //SEQ_0: ACTOR1, , + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00002: Empty(None), id=dummy1" ); + } + + void Scene00003( World::Quest& quest, Entity::Player& player ) //SEQ_255: ACTOR2, , + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00003: NpcTrade(Talk, TargetCanMove), id=unknown" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + Scene00004( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 3, HIDE_HOTBAR, callback ); + } + void Scene00004( World::Quest& quest, Entity::Player& player ) //SEQ_255: ACTOR2, , + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00004: Normal(Talk, YesNo, TargetCanMove, CanCancel), id=ELYENORA" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.errorCode == 0 || ( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) ) + { + Scene00005( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 4, HIDE_HOTBAR, callback ); + } + void Scene00005( World::Quest& quest, Entity::Player& player ) //SEQ_255: ACTOR2, , + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00005: Normal(CutScene, FadeIn, QuestReward, QuestComplete, AutoFadeIn), id=ELYENORA" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + player.finishQuest( getId(), result.getResult( 1 ) ); + eventMgr().eventFinish( player, result.eventId, 1 ); + warpMgr().requestMoveTerritory( player, Common::WarpType::WARP_TYPE_NORMAL, teriMgr().getZoneByTerritoryTypeId( 144 )->getGuId(), { -34.5, 0.64, 100 }, -1.58 ); + } + }; + eventMgr().playQuestScene( player, getId(), 5, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00006( World::Quest& quest, Entity::Player& player ) //SEQ_255: ACTOR0, , + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00006: Normal(Talk, TargetCanMove), id=TRADER00434" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + }; + eventMgr().playQuestScene( player, getId(), 6, HIDE_HOTBAR, callback ); + } + + void Scene00007( World::Quest& quest, Entity::Player& player ) //SEQ_255: ACTOR1, , + { + playerMgr().sendDebug( player, "SubGsc001:65970 calling Scene00007: Empty(None), id=unknown" ); + } +}; + +EXPOSE_SCRIPT( SubGsc001 ); diff --git a/src/scripts/quest/subquest/goldsaucer/SubGsc002.cpp b/src/scripts/quest/subquest/goldsaucer/SubGsc002.cpp new file mode 100644 index 00000000..e56c22c4 --- /dev/null +++ b/src/scripts/quest/subquest/goldsaucer/SubGsc002.cpp @@ -0,0 +1,296 @@ +// FFXIVTheMovie.ParserV3.10 +#include +#include +#include +#include "Manager/TerritoryMgr.h" +#include "Manager/EventMgr.h" + +using namespace Sapphire; + +class SubGsc002 : public Sapphire::ScriptAPI::QuestScript +{ +public: + SubGsc002() : Sapphire::ScriptAPI::QuestScript( 65971 ){}; + ~SubGsc002() = default; + + //SEQ_0, 1 entries + //SEQ_1, 2 entries + //SEQ_2, 1 entries + //SEQ_3, 1 entries + //SEQ_4, 1 entries + //SEQ_5, 1 entries + //SEQ_6, 1 entries + //SEQ_255, 1 entries + + //ACTOR0 = 1011022 + //ACTOR1 = 1010448 + //ACTOR2 = 1011038 + //ACTOR3 = 1010478 + //ACTOR4 = 1011080 + //ACTOR5 = 1011079 + //ACTOR6 = 1011084 + //BGM0 = 250 + //LOCACTIONTIMELINE001 = 1072 + //LOCCHECKQUEST001 = 66996 + //LOCCHECKQUEST002 = 65625 + //LOCCHECKQUEST003 = 65964 + //LOCENPC001 = 1011586 + //LOCLEVELENPC001 = 5581118 + //LOCLEVELENPC002 = 5581208 + //LOCLEVELENPC003 = 5584143 + //LOCLEVELENPC004 = 5653245 + //LOCLEVELENPC005 = 5581064 + + static constexpr auto EVENT_ON_TALK = 0; + static constexpr auto EVENT_ON_EMOTE = 1; + static constexpr auto EVENT_ON_BNPC_KILL = 2; + static constexpr auto EVENT_ON_WITHIN_RANGE = 3; + static constexpr auto EVENT_ON_ENTER_TERRITORY = 4; + static constexpr auto EVENT_ON_EVENT_ITEM = 5; + static constexpr auto EVENT_ON_EOBJ_HIT = 6; + static constexpr auto EVENT_ON_SAY = 7; + +private: + void onProgress( World::Quest& quest, Entity::Player& player, uint32_t type, uint64_t param1, uint32_t param2, uint32_t param3 ) + { + switch( quest.getSeq() ) + { + case 0: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00000( quest, player ); // Scene00000: Normal(QuestOffer, TargetCanMove), id=unknown + // +Callback Scene00001: Normal(Talk, QuestAccept, TargetCanMove), id=RECEPTIONIDT00434 + break; + } + case 1: + { + if( param1 == 1010448 ) // ACTOR1 = INFORMATION00435 + { + if( quest.getUI8AL() != 1 ) + { + Scene00002( quest, player ); // Scene00002: Normal(Talk, FadeIn, TargetCanMove, ENpcBind), id=INFORMATION00435 + } + break; + } + if( param1 == 1011022 ) // ACTOR0 = RECEPTIONIDT00434 + { + Scene00003( quest, player ); // Scene00003: Normal(Talk, TargetCanMove), id=RECEPTIONIDT00434 + break; + } + break; + } + case 2: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00004( quest, player ); // Scene00004: Normal(Talk, TargetCanMove), id=EXCHANGE00435 + break; + } + case 3: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00005( quest, player ); // Scene00005: Normal(Talk, FadeIn, TargetCanMove, ENpcBind), id=CARDSHOP00435 + break; + } + case 4: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00006( quest, player ); // Scene00006: Normal(Talk, FadeIn, TargetCanMove, ENpcBind), id=GATENPCA00435 + break; + } + case 5: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00007( quest, player ); // Scene00007: Normal(Talk, FadeIn, TargetCanMove), id=BUNNY00435 + break; + } + case 6: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00008( quest, player ); // Scene00008: Normal(Talk, FadeIn, TargetCanMove), id=GATENPCB00435 + break; + } + case 255: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00009( quest, player ); // Scene00009: Normal(Talk, FadeIn, QuestReward, QuestComplete, TargetCanMove), id=INFORMATION00435 + break; + } + default: + { + playerMgr().sendUrgent( player, "Sequence {} not defined.", quest.getSeq() ); + break; + } + } + } + +public: + void onTalk( World::Quest& quest, Entity::Player& player, uint64_t actorId ) override + { + onProgress( quest, player, EVENT_ON_TALK, actorId, 0, 0 ); + } + + void onEmote( World::Quest& quest, uint64_t actorId, uint32_t emoteId, Sapphire::Entity::Player& player ) override + { + playerMgr().sendDebug( player, "emote: {}", emoteId ); + onProgress( quest, player, EVENT_ON_EMOTE, actorId, 0, emoteId ); + } + + void onWithinRange( World::Quest& quest, Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z ) override + { + onProgress( quest, player, EVENT_ON_WITHIN_RANGE, static_cast< uint64_t >( param1 ), 0, 0 ); + } + + void onEnterTerritory( World::Quest& quest, Sapphire::Entity::Player& player, uint16_t param1, uint16_t param2 ) override + { + onProgress( quest, player, EVENT_ON_ENTER_TERRITORY, static_cast< uint64_t >( param1 ), static_cast< uint32_t >( param2 ), 0 ); + } + void onEventItem( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId ) override + { + onProgress( quest, player, EVENT_ON_EVENT_ITEM, actorId, 0, 0 ); + } + void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) override + { + onProgress( quest, player, EVENT_ON_EOBJ_HIT, actorId, actionId, 0 ); + } + void onSay( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t sayId ) override + { + onProgress( quest, player, EVENT_ON_SAY, actorId, sayId, 0 ); + } + +private: + void checkProgressSeq0( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 1 ); + } + void checkProgressSeq1( World::Quest& quest, Entity::Player& player ) + { + if( quest.getUI8AL() == 1 ) + { + quest.setUI8AL( 0 ); + quest.setBitFlag8( 1, false ); + quest.setSeq( 2 ); + } + } + void checkProgressSeq2( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 3 ); + } + void checkProgressSeq3( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 4 ); + } + void checkProgressSeq4( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 5 ); + } + void checkProgressSeq5( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 6 ); + } + void checkProgressSeq6( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 255 ); + } + + void Scene00000( World::Quest& quest, Entity::Player& player ) //SEQ_0: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00000: Normal(QuestOffer, TargetCanMove), id=unknown" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + Scene00001( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, callback ); + } + void Scene00001( World::Quest& quest, Entity::Player& player ) //SEQ_0: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00001: Normal(Talk, QuestAccept, TargetCanMove), id=RECEPTIONIDT00434" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq0( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 1, HIDE_HOTBAR, callback ); + } + + void Scene00002( World::Quest& quest, Entity::Player& player ) //SEQ_1: ACTOR1, UI8AL = 1, Flag8(1)=True(Todo:0) + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00002: Normal(Talk, FadeIn, TargetCanMove, ENpcBind), id=INFORMATION00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + quest.setUI8AL( 1 ); + quest.setBitFlag8( 1, true ); + eventMgr().sendEventNotice( player, getId(), 0, 0, 0, 0 ); + checkProgressSeq1( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 2, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00003( World::Quest& quest, Entity::Player& player ) //SEQ_1: ACTOR0, , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00003: Normal(Talk, TargetCanMove), id=RECEPTIONIDT00434" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + }; + eventMgr().playQuestScene( player, getId(), 3, HIDE_HOTBAR, callback ); + } + + void Scene00004( World::Quest& quest, Entity::Player& player ) //SEQ_2: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00004: Normal(Talk, TargetCanMove), id=EXCHANGE00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq2( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 4, HIDE_HOTBAR, callback ); + } + + void Scene00005( World::Quest& quest, Entity::Player& player ) //SEQ_3: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00005: Normal(Talk, FadeIn, TargetCanMove, ENpcBind), id=CARDSHOP00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq3( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 5, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00006( World::Quest& quest, Entity::Player& player ) //SEQ_4: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00006: Normal(Talk, FadeIn, TargetCanMove, ENpcBind), id=GATENPCA00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq4( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 6, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00007( World::Quest& quest, Entity::Player& player ) //SEQ_5: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00007: Normal(Talk, FadeIn, TargetCanMove), id=BUNNY00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq5( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 7, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00008( World::Quest& quest, Entity::Player& player ) //SEQ_6: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00008: Normal(Talk, FadeIn, TargetCanMove), id=GATENPCB00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq6( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 8, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00009( World::Quest& quest, Entity::Player& player ) //SEQ_255: , , + { + playerMgr().sendDebug( player, "SubGsc002:65971 calling Scene00009: Normal(Talk, FadeIn, QuestReward, QuestComplete, TargetCanMove), id=INFORMATION00435" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + player.finishQuest( getId(), result.getResult( 1 ) ); + } + }; + eventMgr().playQuestScene( player, getId(), 9, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } +}; + +EXPOSE_SCRIPT( SubGsc002 ); From de31ef68ca09e58a93f78b07340850fa2b025b3c Mon Sep 17 00:00:00 2001 From: Lucy <44952533+Skyliegirl33@users.noreply.github.com> Date: Thu, 9 Feb 2023 19:56:28 +0100 Subject: [PATCH 02/12] Fix splitItem --- src/world/Network/Handlers/InventoryHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/Network/Handlers/InventoryHandler.cpp b/src/world/Network/Handlers/InventoryHandler.cpp index 2cd3f5a8..954761a1 100644 --- a/src/world/Network/Handlers/InventoryHandler.cpp +++ b/src/world/Network/Handlers/InventoryHandler.cpp @@ -26,7 +26,7 @@ void Sapphire::Network::GameConnection::itemOperation( const Packets::FFXIVARR_P const auto packet = ZoneChannelPacket< FFXIVIpcClientInventoryItemOperation >( inPacket ); const auto operationType = packet.data().OperationType; - const auto splitCount = packet.data().SrcStack; + const auto splitCount = packet.data().DstStack; const auto fromSlot = packet.data().SrcContainerIndex; const auto fromContainer = packet.data().SrcStorageId; From 1e3fe5e9c22cd70a441161e2499329452a948b97 Mon Sep 17 00:00:00 2001 From: Lucy <44952533+Skyliegirl33@users.noreply.github.com> Date: Thu, 9 Feb 2023 05:22:05 +0100 Subject: [PATCH 03/12] Fix UpdateInventorySlot to use right opcode --- src/common/Network/PacketDef/Zone/ServerZoneDef.h | 6 ++++++ .../Network/PacketWrappers/UpdateInventorySlotPacket.h | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 585b74db..fe9b938c 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -1145,6 +1145,12 @@ namespace Sapphire::Network::Packets::WorldPackets::Server ZoneProtoDownNormalItem item; }; + struct FFXIVIpcUpdateItem : FFXIVIpcBasePacket< UpdateItem > + { + uint32_t contextId; + ZoneProtoDownNormalItem item; + }; + struct FFXIVIpcItemSize : FFXIVIpcBasePacket< ItemSize > { uint32_t contextId; diff --git a/src/world/Network/PacketWrappers/UpdateInventorySlotPacket.h b/src/world/Network/PacketWrappers/UpdateInventorySlotPacket.h index c80c7fb0..3b843113 100644 --- a/src/world/Network/PacketWrappers/UpdateInventorySlotPacket.h +++ b/src/world/Network/PacketWrappers/UpdateInventorySlotPacket.h @@ -11,17 +11,17 @@ namespace Sapphire::Network::Packets::WorldPackets::Server /** * @brief The update inventory-slot packet. */ - class UpdateInventorySlotPacket : public ZoneChannelPacket< FFXIVIpcNormalItem > + class UpdateInventorySlotPacket : public ZoneChannelPacket< FFXIVIpcUpdateItem > { public: UpdateInventorySlotPacket( uint32_t playerId, uint16_t slot, uint16_t storageId, const Item& item, uint32_t contextId ) : - ZoneChannelPacket< FFXIVIpcNormalItem >( playerId, playerId ) + ZoneChannelPacket< FFXIVIpcUpdateItem >( playerId, playerId ) { initialize( slot, storageId, item, contextId ); }; UpdateInventorySlotPacket( uint32_t playerId, uint16_t slot, uint16_t storageId, uint32_t contextId ) : - ZoneChannelPacket< FFXIVIpcNormalItem >( playerId, playerId ) + ZoneChannelPacket< FFXIVIpcUpdateItem >( playerId, playerId ) { initialize( slot, storageId, contextId ); }; @@ -37,6 +37,7 @@ namespace Sapphire::Network::Packets::WorldPackets::Server m_data.item.flags = static_cast< uint8_t >( item.isHq() ? 1 : 0 ); m_data.item.refine = item.getSpiritbond(); m_data.item.stain = static_cast< uint8_t >( item.getStain() ); + m_data.item.durability = item.getDurability(); m_data.item.signatureId = 0; }; From dac6c6341440609277fad663ea471e44a334ed47 Mon Sep 17 00:00:00 2001 From: Lucy <44952533+Skyliegirl33@users.noreply.github.com> Date: Wed, 8 Feb 2023 21:44:51 +0100 Subject: [PATCH 04/12] Fix dyeing and implement removeItem method --- src/common/Network/CommonActorControl.h | 1 + src/world/Actor/Player.cpp | 12 +++-- src/world/Actor/Player.h | 2 + src/world/Actor/PlayerInventory.cpp | 48 +++++++++++++++++++ .../Network/Handlers/PacketCommandHandler.cpp | 6 ++- 5 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/common/Network/CommonActorControl.h b/src/common/Network/CommonActorControl.h index 2c971c47..e6e36a3f 100644 --- a/src/common/Network/CommonActorControl.h +++ b/src/common/Network/CommonActorControl.h @@ -548,6 +548,7 @@ namespace Sapphire::Network::ActorControl REQUEST_SALVAGE_SUCCESS_RATE = 0x1B2, MOBHUNT_RECEIPT_ORDER = 0x1B3, MOBHUNT_BREAK_ORDER = 0x1B4, + DYE_ITEM = 0x1B5, EMOTE = 0x1F4, EMOTE_WITH_WARP = 0x1F5, EMOTE_CANCEL = 0x1F6, diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index b29d3cfd..1ff17bd0 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -1624,13 +1624,19 @@ void Player::dyeItemFromDyeingInfo() if( !itemToDye || !dyeToUse ) return; - uint32_t stainColorID = dyeToUse->getAdditionalData(); - itemToDye->setStain( stainColorID ); + if( !removeItem( dyeToUse->getId() ) ) + return; - // TODO: subtract/remove dye used + uint32_t stainColorID = dyeToUse->getAdditionalData(); + bool shouldDye = stainColorID != 0; + bool invalidateGearSet = stainColorID != itemToDye->getStain(); + itemToDye->setStain( stainColorID ); insertInventoryItem( static_cast< Sapphire::Common::InventoryType >( itemToDyeContainer ), static_cast< uint16_t >( itemToDyeSlot ), itemToDye ); writeItem( itemToDye ); + + auto dyePkt = makeActorControlSelf( getId(), DyeMsg, itemToDye->getId(), shouldDye, invalidateGearSet ); + queuePacket( dyePkt ); } void Player::resetObjSpawnIndex() diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index b5261d1a..2d45ba86 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -722,6 +722,8 @@ namespace Sapphire::Entity ItemPtr addItem( uint32_t catalogId, uint32_t quantity = 1, bool isHq = false, bool slient = false, bool canMerge = true ); + bool removeItem( uint32_t catalogId, uint32_t quantity = 1, bool isHq = false ); + void moveItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot ); void swapItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot ); diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index 1d5118c1..acff88c5 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -720,6 +720,54 @@ Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_ return item; } +bool Sapphire::Entity::Player::removeItem( uint32_t catalogId, uint32_t quantity, bool isHq ) +{ + std::vector< uint16_t > bags = { Bag0, Bag1, Bag2, Bag3 }; + + for( auto bag : bags ) + { + auto storage = m_storageMap[ bag ]; + + for( uint16_t slot = 0; slot < storage->getMaxSize(); slot++ ) + { + if( quantity == 0 ) + break; + + auto item = storage->getItem( slot ); + + // remove any matching items + if( item && item->getId() == catalogId ) + { + uint32_t count = item->getStackSize(); + uint32_t maxStack = item->getMaxStackSize(); + + // check slot is same quality + if( item->isHq() != isHq ) + continue; + + // update stack + int32_t newStackSize = count - quantity; + if( newStackSize <= 0 ) + { + quantity = std::abs( newStackSize ); + discardItem( bag, slot ); + } + else + { + quantity = 0; + item->setStackSize( newStackSize ); + + insertInventoryItem( static_cast< Sapphire::Common::InventoryType >( bag ), slot, item ); + + writeItem( item ); + } + } + } + } + + return quantity == 0; +} + void Sapphire::Entity::Player::moveItem( uint16_t fromInventoryId, uint16_t fromSlotId, uint16_t toInventoryId, uint16_t toSlot ) { diff --git a/src/world/Network/Handlers/PacketCommandHandler.cpp b/src/world/Network/Handlers/PacketCommandHandler.cpp index e72a5d4c..902bbb4a 100644 --- a/src/world/Network/Handlers/PacketCommandHandler.cpp +++ b/src/world/Network/Handlers/PacketCommandHandler.cpp @@ -182,6 +182,8 @@ const char* packetCommandToString( uint16_t commandId ) return "MOBHUNT_RECEIPT_ORDER"; case MOBHUNT_BREAK_ORDER: return "MOBHUNT_BREAK_ORDER"; + case DYE_ITEM: + return "DYE_ITEM"; case EMOTE: return "EMOTE"; case EMOTE_WITH_WARP: @@ -623,7 +625,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_ player.teleportQuery( static_cast< uint16_t >( param11 ) ); break; } - /* case PacketCommand::DyeItem: // Dye item + case PacketCommand::DYE_ITEM: // Dye item { // param11 = item to dye container // param12 = item to dye slot @@ -631,7 +633,7 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_ // param4 = dye bag slot player.setDyeingInfo( param11, param12, param2, param4 ); break; - }*/ + } case PacketCommand::DIRECTOR_INIT_RETURN: // Director init finish { pZone->onInitDirector( player ); From 2b57b734715b92ce109ca2228ffa52eb221cf9f9 Mon Sep 17 00:00:00 2001 From: Alice Ogeda Date: Fri, 10 Feb 2023 12:11:11 -0300 Subject: [PATCH 05/12] first batch of moving packet/logic out of player to playermgr; --- .../quest/subquest/mordhona/GaiUsc605.cpp | 10 +- src/world/Action/Action.cpp | 14 +-- src/world/Action/EffectResult.cpp | 5 +- src/world/Action/EventAction.cpp | 14 ++- src/world/Action/MountAction.cpp | 13 +-- src/world/Actor/Player.cpp | 89 +++-------------- src/world/Actor/Player.h | 21 ++-- src/world/Manager/DebugCommandMgr.cpp | 4 +- src/world/Manager/EventMgr.cpp | 8 +- src/world/Manager/PlayerMgr.cpp | 99 +++++++++++++++++-- src/world/Manager/PlayerMgr.h | 6 ++ .../Network/Handlers/GMCommandHandlers.cpp | 8 +- .../Network/Handlers/PacketCommandHandler.cpp | 6 +- src/world/Territory/InstanceContent.cpp | 4 +- 14 files changed, 170 insertions(+), 131 deletions(-) diff --git a/src/scripts/quest/subquest/mordhona/GaiUsc605.cpp b/src/scripts/quest/subquest/mordhona/GaiUsc605.cpp index 243bc6f7..8bd58dbf 100644 --- a/src/scripts/quest/subquest/mordhona/GaiUsc605.cpp +++ b/src/scripts/quest/subquest/mordhona/GaiUsc605.cpp @@ -396,7 +396,7 @@ private: { eventMgr().sendEventNotice( player, getId(), 3, 0 ); quest.setSeq( Seq5 ); - player.setMount( Mount0 ); + playerMgr().onMountUpdate( player, Mount0 ); } ////////////////////////////////////////////////////////////////////// @@ -490,7 +490,7 @@ private: void Scene00017Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - player.setMount( Mount0 ); + playerMgr().onMountUpdate( player, Mount0 ); } ////////////////////////////////////////////////////////////////////// @@ -562,7 +562,7 @@ private: void Scene00023Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - player.setMount( Mount0 ); + playerMgr().onMountUpdate( player, Mount0 ); } ////////////////////////////////////////////////////////////////////// @@ -611,7 +611,7 @@ private: { eventMgr().sendEventNotice( player, getId(), 6, 0 ); quest.setSeq( Seq8 ); - player.setMount( 0 ); + playerMgr().onMountUpdate( player, 0 ); } } @@ -646,7 +646,7 @@ private: void Scene00030Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - player.setMount( Mount0 ); + playerMgr().onMountUpdate( player, Mount0 ); } ////////////////////////////////////////////////////////////////////// diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 5a26c0f6..ca9762b2 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -320,7 +320,7 @@ void Action::Action::start() if( player ) { - player->setStateFlag( PlayerStateFlag::Casting ); + Service< World::Manager::PlayerMgr >::ref().onSendStateFlags( *player, PlayerStateFlag::Casting ); } } @@ -368,14 +368,14 @@ void Action::Action::interrupt() // things that aren't players don't care about cooldowns and state flags if( m_pSource->isPlayer() ) { - auto player = m_pSource->getAsPlayer(); + auto pPlayer = m_pSource->getAsPlayer(); // todo: reset cooldown for actual player // reset state flag //player->unsetStateFlag( PlayerStateFlag::Occupied1 ); - player->setLastActionTick( 0 ); - player->unsetStateFlag( PlayerStateFlag::Casting ); + pPlayer->setLastActionTick( 0 ); + Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *pPlayer, PlayerStateFlag::Casting ); } if( hasCastTime() ) @@ -424,10 +424,10 @@ void Action::Action::execute() 0x219, m_id, m_id, m_id, m_id ); m_pSource->sendToInRangeSet( control, true );*/ - if( auto player = m_pSource->getAsPlayer() ) + if( auto pPlayer = m_pSource->getAsPlayer(); pPlayer ) { - player->setLastActionTick( 0 ); - player->unsetStateFlag( PlayerStateFlag::Casting ); + pPlayer->setLastActionTick( 0 ); + Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *pPlayer, PlayerStateFlag::Casting ); } } diff --git a/src/world/Action/EffectResult.cpp b/src/world/Action/EffectResult.cpp index d32c92fd..7d69febf 100644 --- a/src/world/Action/EffectResult.cpp +++ b/src/world/Action/EffectResult.cpp @@ -2,6 +2,9 @@ #include +#include +#include + #include "Actor/Chara.h" #include "Actor/Player.h" @@ -133,7 +136,7 @@ void EffectResult::execute() case Common::ActionEffectType::CALC_RESULT_TYPE_MOUNT: { auto pPlayer = m_target->getAsPlayer(); - pPlayer->setMount( m_value ); + Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( *pPlayer, m_value ); break; } diff --git a/src/world/Action/EventAction.cpp b/src/world/Action/EventAction.cpp index 7c7e6249..94708b0e 100644 --- a/src/world/Action/EventAction.cpp +++ b/src/world/Action/EventAction.cpp @@ -4,9 +4,12 @@ #include #include +#include +#include -#include "Network/PacketWrappers/ActorControlPacket.h" -#include "Network/PacketWrappers/ActorControlSelfPacket.h" +#include +#include +#include #include "Actor/Player.h" @@ -14,7 +17,6 @@ #include "WorldServer.h" #include "Session.h" #include "Network/GameConnection.h" -#include "Manager/EventMgr.h" #include "EventAction.h" @@ -54,9 +56,11 @@ void Action::EventAction::start() if( m_pSource->isPlayer() ) { + auto pPlayer = m_pSource->getAsPlayer(); + m_pSource->sendToInRangeSet( control, true ); - if( m_pSource->getAsPlayer()->hasStateFlag( PlayerStateFlag::InNpcEvent ) ) - m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::InNpcEvent ); + if( pPlayer->hasStateFlag( PlayerStateFlag::InNpcEvent ) ) + Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *pPlayer, PlayerStateFlag::InNpcEvent ); } else m_pSource->sendToInRangeSet( control ); diff --git a/src/world/Action/MountAction.cpp b/src/world/Action/MountAction.cpp index 757de387..c5276d46 100644 --- a/src/world/Action/MountAction.cpp +++ b/src/world/Action/MountAction.cpp @@ -2,17 +2,19 @@ #include -#include "Actor/Player.h" +#include +#include + +#include #include -#include "Network/PacketWrappers/ActorControlSelfPacket.h" +#include #include #include #include "WorldServer.h" #include "Session.h" -#include "Network/GameConnection.h" using namespace Sapphire; using namespace Sapphire::Network::Packets; @@ -59,20 +61,19 @@ void MountAction::start() m_pSource->sendToInRangeSet( castPacket, true ); - player->setStateFlag( Common::PlayerStateFlag::Casting ); + Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( *player, Common::PlayerStateFlag::Casting ); auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 ); auto& server = Common::Service< World::WorldServer >::ref(); server.queueForPlayer( m_pSource->getAsPlayer()->getCharacterId(), actionStartPkt ); - } void MountAction::execute() { assert( m_pSource ); - m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting ); + Common::Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *m_pSource->getAsPlayer(), Common::PlayerStateFlag::Casting ); m_effectBuilder->mount( m_pSource, m_mountId ); m_effectBuilder->buildAndSendPackets( { m_pSource } ); } \ No newline at end of file diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index b29d3cfd..9a752446 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -670,8 +670,6 @@ void Player::learnSong( uint8_t songId, uint32_t itemId ) Util::valueToFlagByteIndexValue( songId, value, index ); m_orchestrion[ index ] |= value; - - Service< World::Manager::PlayerMgr >::ref().onUnlockOrchestrion( *this, songId, itemId ); } bool Player::hasReward( Common::UnlockEntry unlockId ) const @@ -955,7 +953,6 @@ bool Player::hasStateFlag( Common::PlayerStateFlag flag ) const void Player::setStateFlag( Common::PlayerStateFlag flag ) { - auto prevOnlineStatus = getOnlineStatus(); auto iFlag = static_cast< int32_t >( flag ); uint16_t index; @@ -963,22 +960,6 @@ void Player::setStateFlag( Common::PlayerStateFlag flag ) Util::valueToFlagByteIndexValue( iFlag, value, index ); m_stateFlags[ index ] |= value; - - auto newOnlineStatus = getOnlineStatus(); - sendStateFlags( prevOnlineStatus != newOnlineStatus ); -} - -void Player::setStateFlags( std::vector< Common::PlayerStateFlag > flags ) -{ - for( const auto& flag : flags ) - { - setStateFlag( flag ); - } -} - -void Player::sendStateFlags( bool updateInRange ) -{ - Service< World::Manager::PlayerMgr >::ref().onSendStateFlags( *this, updateInRange ); } void Player::unsetStateFlag( Common::PlayerStateFlag flag ) @@ -986,8 +967,6 @@ void Player::unsetStateFlag( Common::PlayerStateFlag flag ) if( !hasStateFlag( flag ) ) return; - auto prevOnlineStatus = getOnlineStatus(); - auto iFlag = static_cast< int32_t >( flag ); uint16_t index; @@ -995,60 +974,21 @@ void Player::unsetStateFlag( Common::PlayerStateFlag flag ) Util::valueToFlagByteIndexValue( iFlag, value, index ); m_stateFlags[ index ] ^= value; - - auto newOnlineStatus = getOnlineStatus(); - sendStateFlags( prevOnlineStatus != newOnlineStatus ); } void Player::update( uint64_t tickCount ) { - if( m_hp <= 0 && m_status != ActorStatus::Dead ) - { - die(); - Service< World::Manager::PlayerMgr >::ref().onDeath( *this ); - } - - if( !isAlive() ) - return; - - m_lastUpdate = tickCount; - - if( !checkAction() ) - { - if( m_targetId && m_currentStance == Common::Stance::Active && isAutoattackOn() ) - { - auto mainWeap = getItemAt( Common::GearSet0, Common::GearSetSlot::MainHand ); - - // @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need... - for( const auto& actor : m_inRangeActor ) - { - if( actor->getId() == m_targetId && actor->getAsChara()->isAlive() && mainWeap ) - { - auto chara = actor->getAsChara(); - - // default autoattack range - float range = 3.f + chara->getRadius() + getRadius() * 0.5f; - - // default autoattack range for ranged classes - if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer ) - range = 25.f + chara->getRadius() + getRadius() * 0.5f; - - if( Util::distance( getPos(), actor->getPos() ) <= range ) - { - if( ( tickCount - m_lastAttack ) > mainWeap->getDelay() ) - { - m_lastAttack = tickCount; - autoAttack( actor->getAsChara() ); - } - } - } - } - } - } + // todo: better way to handle this override chara update + Service< World::Manager::PlayerMgr >::ref().onUpdate( *this, tickCount ); Chara::update( tickCount ); } +uint64_t Player::getLastAttack() const +{ + return m_lastAttack; +} + void Player::setLastAttack( uint64_t tickCount ) { m_lastAttack = tickCount; @@ -1112,6 +1052,11 @@ const Player::OrchestrionList& Player::getOrchestrionBitmask() const return m_orchestrion; } +void Player::setOrchestrionBitmask( const Player::OrchestrionList& orchestrion ) +{ + m_orchestrion = orchestrion; +} + void Player::unlockMount( uint32_t mountId ) { auto& exdData = Common::Service< Data::ExdData >::ref(); @@ -1373,21 +1318,11 @@ uint8_t Player::getEquipDisplayFlags() const void Player::setMount( uint32_t mountId ) { m_mount = mountId; - - Service< World::Manager::PlayerMgr >::ref().onMountUpdate( *this, m_mount ); } void Player::setCompanion( uint8_t id ) { - auto& exdData = Common::Service< Data::ExdData >::ref(); - - auto companion = exdData.getRow< Excel::Companion >( id ); - if( !id ) - return; - m_companionId = id; - - Service< World::Manager::PlayerMgr >::ref().onCompanionUpdate( *this, m_companionId ); } uint8_t Player::getCurrentCompanion() const diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index b5261d1a..fbb5ebab 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -83,6 +83,10 @@ namespace Sapphire::Entity /*! Event called on every session iteration */ void update( uint64_t tickCount ) override; + /*! get last attack tick for player */ + uint64_t getLastAttack() const; + + /*! set last attack tick for player */ void setLastAttack( uint64_t tickCount ); // Quest @@ -418,7 +422,7 @@ namespace Sapphire::Entity /*! check if aetheryte is already registered */ bool isAetheryteRegistered( uint8_t aetheryteId ) const; - /*! return a const pointer to the aetheryte unlock bitmask array */ + /*! return aetheryte mask */ uint8_t getAetheryteMaskAt( uint8_t index ) const; /*! return a pointer to the aetheryte unlock bitmask array */ @@ -433,13 +437,13 @@ namespace Sapphire::Entity /*! discover subarea subid fo map map_id, also send udpate packet */ void discover( int16_t map_id, int16_t sub_id ); - /*! return a pointer to the discovery bitmask array */ + /*! return a reference to the discovery bitmask array */ Discovery& getDiscoveryBitmask(); /*! helper/debug function to reset all discovered areas */ void resetDiscovery(); - /*! get a pointer to the howto bitmask array */ + /*! get a reference to the howto bitmask array */ HowToList& getHowToArray(); /*! update bitmask for how-to's seen */ @@ -454,22 +458,25 @@ namespace Sapphire::Entity /*! check if an action is already unlocked in the bitmask. */ bool hasReward( Common::UnlockEntry unlockId ) const; - /*! return a const pointer to the unlock bitmask array */ + /*! return a const reference to the unlock bitmask array */ const UnlockList& getUnlockBitmask() const; - /*! return a const pointer to the orchestrion bitmask array */ + /*! return a const reference to the orchestrion bitmask array */ const OrchestrionList& getOrchestrionBitmask() const; + /*! set orchestrion bitmask array */ + void setOrchestrionBitmask( const OrchestrionList& orchestrion ); + /*! unlock a mount */ void unlockMount( uint32_t mountId ); /*! unlock a companion */ void unlockCompanion( uint32_t companionId ); - /*! return a const pointer to the minion guide bitmask array */ + /*! return a reference to the minion guide bitmask array */ MinionList& getMinionGuideBitmask(); - /*! return a const pointer to the setMount guide bitmask array */ + /*! return a reference to the setMount guide bitmask array */ MountList& getMountGuideBitmask(); bool checkAction() override; diff --git a/src/world/Manager/DebugCommandMgr.cpp b/src/world/Manager/DebugCommandMgr.cpp index d6a30186..2061f715 100644 --- a/src/world/Manager/DebugCommandMgr.cpp +++ b/src/world/Manager/DebugCommandMgr.cpp @@ -269,8 +269,8 @@ void DebugCommandMgr::set( char* data, Entity::Player& player, std::shared_ptr< int32_t id; sscanf( params.c_str(), "%d", &id ); - player.setMount( 0 ); - player.setMount( static_cast< uint32_t >( id )); + Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( player, 0 ); + Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( player, id ); } else if( subCommand == "weatheroverride" || subCommand == "wo" ) { diff --git a/src/world/Manager/EventMgr.cpp b/src/world/Manager/EventMgr.cpp index 5f52d7f6..1241e74b 100644 --- a/src/world/Manager/EventMgr.cpp +++ b/src/world/Manager/EventMgr.cpp @@ -555,12 +555,12 @@ void EventMgr::eventFinish( Sapphire::Entity::Player& player, uint32_t eventId, } if( player.hasStateFlag( Common::PlayerStateFlag::WatchingCutscene ) ) - player.unsetStateFlag( Common::PlayerStateFlag::WatchingCutscene ); + Common::Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( player, Common::PlayerStateFlag::WatchingCutscene ); player.removeEvent( pEvent->getId() ); if( freePlayer == 1 ) - player.unsetStateFlag( Common::PlayerStateFlag::InNpcEvent ); + Common::Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( player, Common::PlayerStateFlag::InNpcEvent ); } void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t eventId, Event::EventHandler::EventType eventType, uint8_t eventParam1, @@ -571,7 +571,7 @@ void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t ev newEvent->setEventFinishCallback( std::move( callback ) ); player.addEvent( newEvent ); - player.setStateFlag( Common::PlayerStateFlag::InNpcEvent ); + Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( player, Common::PlayerStateFlag::InNpcEvent ); server.queueForPlayer( player.getCharacterId(), std::make_shared< EventStartPacket >( player.getId(), actorId, eventId, eventType, eventParam1, eventParam2 ) ); @@ -836,7 +836,7 @@ Sapphire::Event::EventHandlerPtr EventMgr::bootstrapSceneEvent( Entity::Player& } if( flags & CONDITION_CUTSCENE ) - player.setStateFlag( Common::PlayerStateFlag::WatchingCutscene ); + Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( player, Common::PlayerStateFlag::WatchingCutscene ); return pEvent; } diff --git a/src/world/Manager/PlayerMgr.cpp b/src/world/Manager/PlayerMgr.cpp index 060ce7ed..4ae175d4 100644 --- a/src/world/Manager/PlayerMgr.cpp +++ b/src/world/Manager/PlayerMgr.cpp @@ -13,8 +13,8 @@ #include #include -#include "Script/ScriptMgr.h" -#include "WorldServer.h" +#include