From 63f39d7fda00bdbb18e32cfc21f0d7ae397a0fd9 Mon Sep 17 00:00:00 2001 From: collett Date: Wed, 16 Feb 2022 04:03:13 +0900 Subject: [PATCH] limsa msq up to first quest battle --- src/scripts/quest/ManSea002.cpp | 76 +++--- src/scripts/quest/ManSea005.cpp | 216 ++++++++++++++++++ .../quest/subquest/limsa/SubSea050.cpp | 136 +++++++++++ .../quest/subquest/limsa/SubSea051.cpp | 130 +++++++++++ 4 files changed, 512 insertions(+), 46 deletions(-) create mode 100644 src/scripts/quest/ManSea005.cpp create mode 100644 src/scripts/quest/subquest/limsa/SubSea050.cpp create mode 100644 src/scripts/quest/subquest/limsa/SubSea051.cpp diff --git a/src/scripts/quest/ManSea002.cpp b/src/scripts/quest/ManSea002.cpp index 207f1570..4afd769a 100644 --- a/src/scripts/quest/ManSea002.cpp +++ b/src/scripts/quest/ManSea002.cpp @@ -79,7 +79,7 @@ public: private: - void checkQuestCompletion( Entity::Player& player, uint32_t varIdx ) + void checkQuestCompletion( World::Quest& quest, Entity::Player& player, uint32_t varIdx ) { if( varIdx == 1 ) { @@ -94,24 +94,20 @@ private: eventMgr().sendEventNotice( player, getId(), 0, 0, 0, 0 ); } - auto pQuest = player.getQuest( getId() ); - if( !pQuest ) - return; - - auto QUEST_VAR_ATTUNE = pQuest->getUI8AL(); - auto QUEST_VAR_CLASS = pQuest->getUI8BH(); - auto QUEST_VAR_TRADE = pQuest->getUI8BL(); + auto QUEST_VAR_ATTUNE = quest.getUI8AL(); + auto QUEST_VAR_CLASS = quest.getUI8BH(); + auto QUEST_VAR_TRADE = quest.getUI8BL(); if( QUEST_VAR_ATTUNE == 1 && QUEST_VAR_CLASS == 1 && QUEST_VAR_TRADE == 1 ) { - pQuest->setSeq( SEQ_FINISH ); + quest.setSeq( SEQ_FINISH ); } } void Scene00000( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 0, HIDE_HOTBAR, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { if( result.getResult( 0 ) == 1 ) { @@ -122,21 +118,18 @@ private: void Scene00001( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 1, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 1, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - auto pQuest = player.getQuest( getId() ); - if( !pQuest ) - return; - pQuest->setSeq( SEQ_1 ); - pQuest->setUI8CH( 1 ); + quest.setSeq( SEQ_1 ); + quest.setUI8CH( 1 ); } ); } void Scene00002( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 2, HIDE_HOTBAR, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 2, HIDE_HOTBAR, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { Scene00003( player ); } ); @@ -144,21 +137,18 @@ private: void Scene00003( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 3, SET_EOBJ_BASE | HIDE_HOTBAR | INVIS_EOBJ, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 3, SET_EOBJ_BASE | HIDE_HOTBAR | INVIS_EOBJ, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - auto pQuest = player.getQuest( getId() ); - if( !pQuest ) - return; - pQuest->setUI8BL( 1 ); - checkQuestCompletion( player, 0 ); + quest.setUI8BL( 1 ); + checkQuestCompletion( quest, player, 0 ); } ); } void Scene00004( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 4, HIDE_HOTBAR, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 4, HIDE_HOTBAR, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { if( result.getResult( 0 ) == 1 ) { @@ -171,35 +161,29 @@ private: void Scene00005( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 5, SET_EOBJ_BASE | HIDE_HOTBAR | INVIS_EOBJ, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 5, SET_EOBJ_BASE | HIDE_HOTBAR | INVIS_EOBJ, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - auto pQuest = player.getQuest( getId() ); - if( !pQuest ) - return; - pQuest->setUI8CH( 0 ); - pQuest->setUI8BH( 1 ); - checkQuestCompletion( player, 1 ); + quest.setUI8CH( 0 ); + quest.setUI8BH( 1 ); + checkQuestCompletion( quest, player, 1 ); } ); } void Scene00006( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 6, HIDE_HOTBAR, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 6, HIDE_HOTBAR, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { - auto pQuest = player.getQuest( getId() ); - if( !pQuest ) - return; - pQuest->setUI8AL( 1 ); - checkQuestCompletion( player, 2 ); + quest.setUI8AL( 1 ); + checkQuestCompletion( quest, player, 2 ); } ); } void Scene00007( Entity::Player& player ) { - eventMgr().playScene( player, getId(), 7, SET_EOBJ_BASE | HIDE_HOTBAR | INVIS_EOBJ, - [ & ]( Entity::Player& player, const Event::SceneResult& result ) + eventMgr().playQuestScene( player, getId(), 7, SET_EOBJ_BASE | HIDE_HOTBAR | INVIS_EOBJ, + [ & ]( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) { if( result.getResult( 0 ) == 1 ) { diff --git a/src/scripts/quest/ManSea005.cpp b/src/scripts/quest/ManSea005.cpp new file mode 100644 index 00000000..78191ea1 --- /dev/null +++ b/src/scripts/quest/ManSea005.cpp @@ -0,0 +1,216 @@ +// FFXIVTheMovie.ParserV3.8 +// fake IsAnnounce table +#include +#include +#include +#include "Manager/TerritoryMgr.h" +#include "Manager/EventMgr.h" +#include "Territory/Territory.h" +#include + +using namespace Sapphire; + +class ManSea005 : public Sapphire::ScriptAPI::QuestScript +{ +public: + ManSea005() : Sapphire::ScriptAPI::QuestScript( 66079 ){}; + ~ManSea005() = default; + + //SEQ_0, 1 entries + //SEQ_1, 1 entries + //SEQ_2, 1 entries + //SEQ_255, 1 entries + + //ACTOR0 = 1002626 + //CUTSCENE02 = 134 + //CUTSCENE03 = 56 + //CUTSCENE04 = 135 + //EOBJECT0 = 2001582 + //EVENTACTIONPROCESSMIDDLE = 16 + //ITEM0 = 2000522 + //QUESTBATTLE0 = 35 + //SEQ0ACTOR0LQ = 90 + //TERRITORYTYPE0 = 252 + //TERRITORYTYPE1 = 134 + + 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(Talk, QuestOffer, TargetCanMove), id=STAELWYRN + // +Callback Scene00001: Normal(Talk, FadeIn, QuestAccept, TargetCanMove), id=STAELWYRN + break; + } + //seq 1 event item ITEM0 = UI8BH max stack 1 + case 1: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00003( quest, player ); // Scene00003: Normal(QuestBattle, YesNo, SystemTalk), id=unknown + break; + } + //seq 2 event item ITEM0 = UI8BH max stack 1 + case 2: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00004( quest, player ); // Scene00004: Normal(CutScene, AutoFadeIn), id=unknown + break; + } + //seq 255 event item ITEM0 = UI8BH max stack 1 + case 255: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00005( quest, player ); // Scene00005: NpcTrade(Basic), id=unknown + // +Callback Scene00006: Normal(Talk, FadeIn, QuestReward, QuestComplete, TargetCanMove), id=STAELWYRN + 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 onBNpcKill( World::Quest& quest, uint16_t nameId, uint32_t entityId, Sapphire::Entity::Player& player ) override + { + onProgress( quest, player, EVENT_ON_BNPC_KILL, static_cast< uint64_t >( nameId ), entityId, 0 ); + } + + 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 ) + { + quest.setSeq( 2 ); + } + void checkProgressSeq2( World::Quest& quest, Entity::Player& player ) + { + quest.setSeq( 255 ); + quest.setUI8BH( 1 ); + } + + void Scene00000( World::Quest& quest, Entity::Player& player ) //SEQ_0: , , + { + playerMgr().sendDebug( player, "ManSea005:66079 calling Scene00000: Normal(Talk, QuestOffer, TargetCanMove), id=STAELWYRN" ); + 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, "ManSea005:66079 calling Scene00001: Normal(Talk, FadeIn, QuestAccept, TargetCanMove), id=STAELWYRN" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq0( quest, player ); + }; + eventMgr().playQuestScene( player, getId(), 1, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00003( World::Quest& quest, Entity::Player& player ) //SEQ_1: , , + { + playerMgr().sendDebug( player, "ManSea005:66079 calling Scene00003: Normal(QuestBattle, YesNo, SystemTalk), id=unknown" ); + eventMgr().eventActionStart( player, getId(), 16, [ & ]( Entity::Player& player, uint32_t eventId, uint64_t additional ) + { + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + //quest battle + eventMgr().eventFinish( player, result.eventId, 1 ); + teriMgr().createAndJoinQuestBattle( player, 35 ); + } + }; + eventMgr().playQuestScene( player, getId(), 3, HIDE_HOTBAR, callback ); + }, nullptr, getId() ); + } + + void Scene00004( World::Quest& quest, Entity::Player& player ) //SEQ_2: , , + { + playerMgr().sendDebug( player, "ManSea005:66079 calling Scene00004: Normal(CutScene, AutoFadeIn), id=unknown" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + checkProgressSeq2( quest, player ); + playerMgr().sendDebug( player, "Finished with AutoFadeIn scene, reloading zone..." ); + eventMgr().eventFinish( player, result.eventId, 1 ); + warpMgr().requestWarp( player, Common::WarpType::WARP_TYPE_NORMAL, player.getPos(), player.getRot() ); + }; + eventMgr().playQuestScene( player, getId(), 4, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } + + void Scene00005( World::Quest& quest, Entity::Player& player ) //SEQ_255: , , + { + playerMgr().sendDebug( player, "ManSea005:66079 calling Scene00005: NpcTrade(Basic), id=unknown" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + Scene00006( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 5, HIDE_HOTBAR, callback ); + } + void Scene00006( World::Quest& quest, Entity::Player& player ) //SEQ_255: , , + { + playerMgr().sendDebug( player, "ManSea005:66079 calling Scene00006: Normal(Talk, FadeIn, QuestReward, QuestComplete, TargetCanMove), id=STAELWYRN" ); + 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(), 6, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } +}; + +EXPOSE_SCRIPT( ManSea005 ); diff --git a/src/scripts/quest/subquest/limsa/SubSea050.cpp b/src/scripts/quest/subquest/limsa/SubSea050.cpp new file mode 100644 index 00000000..0e40a006 --- /dev/null +++ b/src/scripts/quest/subquest/limsa/SubSea050.cpp @@ -0,0 +1,136 @@ +// FFXIVTheMovie.ParserV3.8 +// fake IsAnnounce table +#include +#include +#include +#include "Manager/TerritoryMgr.h" +#include "Manager/EventMgr.h" +#include "Territory/Territory.h" +#include + +using namespace Sapphire; + +class SubSea050 : public Sapphire::ScriptAPI::QuestScript +{ +public: + SubSea050() : Sapphire::ScriptAPI::QuestScript( 65998 ){}; + ~SubSea050() = default; + + //SEQ_0, 1 entries + //SEQ_255, 1 entries + + //ACTOR0 = 1000972 + //ACTOR1 = 1002626 + //LOCACTOR0 = 1003289 + //LOCFACE0 = 604 + //LOCFACE1 = 617 + //LOCPOSACTOR0 = 4201224 + //LOCPOSCAM1 = 4201231 + //LOCSE1 = 39 + //LOCSE2 = 40 + + 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(Talk, QuestOffer, QuestAccept, TargetCanMove), id=BADERON + break; + } + case 255: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00002( quest, player ); // Scene00002: Normal(Talk, FadeIn, QuestReward, QuestComplete, TargetCanMove), id=STAELWYRN + 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 onBNpcKill( World::Quest& quest, uint16_t nameId, uint32_t entityId, Sapphire::Entity::Player& player ) override + { + onProgress( quest, player, EVENT_ON_BNPC_KILL, static_cast< uint64_t >( nameId ), entityId, 0 ); + } + + 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 ); + } + + void Scene00000( World::Quest& quest, Entity::Player& player ) //SEQ_0: , , + { + playerMgr().sendDebug( player, "SubSea050:65998 calling Scene00000: Normal(Talk, QuestOffer, QuestAccept, TargetCanMove), id=BADERON" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + checkProgressSeq0( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, callback ); + } + + void Scene00002( World::Quest& quest, Entity::Player& player ) //SEQ_255: , , + { + playerMgr().sendDebug( player, "SubSea050:65998 calling Scene00002: Normal(Talk, FadeIn, QuestReward, QuestComplete, TargetCanMove), id=STAELWYRN" ); + 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(), 2, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, callback ); + } +}; + +EXPOSE_SCRIPT( SubSea050 ); diff --git a/src/scripts/quest/subquest/limsa/SubSea051.cpp b/src/scripts/quest/subquest/limsa/SubSea051.cpp new file mode 100644 index 00000000..3a394f5e --- /dev/null +++ b/src/scripts/quest/subquest/limsa/SubSea051.cpp @@ -0,0 +1,130 @@ +// FFXIVTheMovie.ParserV3.8 +// fake IsAnnounce table +#include +#include +#include +#include "Manager/TerritoryMgr.h" +#include "Manager/EventMgr.h" +#include "Territory/Territory.h" +#include + +using namespace Sapphire; + +class SubSea051 : public Sapphire::ScriptAPI::QuestScript +{ +public: + SubSea051() : Sapphire::ScriptAPI::QuestScript( 65999 ){}; + ~SubSea051() = default; + + //SEQ_0, 1 entries + //SEQ_255, 1 entries + + //ACTOR0 = 1002626 + //SEQ0ACTOR0 = 0 + //SEQ1ACTOR0 = 1 + + 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(Talk, QuestOffer, QuestAccept, TargetCanMove, SystemTalk), id=STAELWYRN + break; + } + case 255: + { + if( type != EVENT_ON_BNPC_KILL ) Scene00001( quest, player ); // Scene00001: Normal(Talk, QuestReward, QuestComplete, TargetCanMove, SystemTalk), id=STAELWYRN + 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 onBNpcKill( World::Quest& quest, uint16_t nameId, uint32_t entityId, Sapphire::Entity::Player& player ) override + { + onProgress( quest, player, EVENT_ON_BNPC_KILL, static_cast< uint64_t >( nameId ), entityId, 0 ); + } + + 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 ); + } + + void Scene00000( World::Quest& quest, Entity::Player& player ) //SEQ_0: , , + { + playerMgr().sendDebug( player, "SubSea051:65999 calling Scene00000: Normal(Talk, QuestOffer, QuestAccept, TargetCanMove, SystemTalk), id=STAELWYRN" ); + auto callback = [ & ]( World::Quest& quest, Entity::Player& player , const Event::SceneResult& result ) + { + if( result.numOfResults > 0 && result.getResult( 0 ) == 1 ) + { + checkProgressSeq0( quest, player ); + } + }; + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, callback ); + } + + void Scene00001( World::Quest& quest, Entity::Player& player ) //SEQ_255: , , + { + playerMgr().sendDebug( player, "SubSea051:65999 calling Scene00001: Normal(Talk, QuestReward, QuestComplete, TargetCanMove, SystemTalk), id=STAELWYRN" ); + 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(), 1, HIDE_HOTBAR, callback ); + } +}; + +EXPOSE_SCRIPT( SubSea051 );