From cfb9408b2ecd9df0cef89f1ce619d712f3665fbd Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Wed, 17 Jan 2024 20:51:17 -0800 Subject: [PATCH 1/4] implement initial CNJ job quests - ClsCnj998 - ClsCnj999 --- .../quest/classquest/CNJ/ClsCnj998.cpp | 105 ++++++++++++++++++ .../quest/classquest/CNJ/ClsCnj999.cpp | 72 ++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 src/scripts/quest/classquest/CNJ/ClsCnj998.cpp create mode 100644 src/scripts/quest/classquest/CNJ/ClsCnj999.cpp diff --git a/src/scripts/quest/classquest/CNJ/ClsCnj998.cpp b/src/scripts/quest/classquest/CNJ/ClsCnj998.cpp new file mode 100644 index 00000000..4789e5d6 --- /dev/null +++ b/src/scripts/quest/classquest/CNJ/ClsCnj998.cpp @@ -0,0 +1,105 @@ +// This is an automatically generated C++ script template +// Content needs to be added by hand to make it function +// In order for this script to be loaded, move it to the correct folder in /scripts/ + +#include "Manager/EventMgr.h" +#include +#include +#include + +// Quest Script: ClsCnj998_00133 +// Quest Name: Way of the Conjurer +// Quest ID: 65669 +// Start NPC: 1000323 (Madelle) +// End NPC: 1000692 (E-Sumi-Yan) + +using namespace Sapphire; + +class ClsCnj998 : public Sapphire::ScriptAPI::QuestScript +{ +private: + // Basic quest information + // Quest vars / flags used + // UI8AL + + /// Countable Num: 1 Seq: 255 Event: 1 Listener: 1000692 + // Steps in this quest ( 0 is before accepting, + // 1 is first, 255 means ready for turning it in + enum Sequence : uint8_t + { + Seq0 = 0, + SeqFinish = 255, + }; + + // Entities found in the script data of the quest + static constexpr auto Actor0 = 1000323;// Madelle ( Pos: -234.028000 -4.000220 -11.062800 Teri: 133 ) + static constexpr auto Actor1 = 1000692;// E-sumi-yan ( Pos: -258.808014 -5.773500 -27.237400 Teri: 133 ) + static constexpr auto Classjob = 6; + static constexpr auto GearsetUnlock = 1905; + static constexpr auto LogmessageMonsterNotePageUnlock = 1009; + static constexpr auto UnlockImageClassCnj = 25; + +public: + ClsCnj998() : Sapphire::ScriptAPI::QuestScript( 65669 ){}; + ~ClsCnj998() = default; + + ////////////////////////////////////////////////////////////////////// + // Event Handlers + void onTalk( World::Quest& quest, Entity::Player& player, uint64_t actorId ) override + { + switch( actorId ) + { + case Actor0: + { + if( quest.getSeq() == Seq0 ) + Scene00000( quest, player ); + break; + } + case Actor1: + { + if( quest.getSeq() == SeqFinish ) + Scene00001( quest, player ); + break; + } + } + } + + +private: + ////////////////////////////////////////////////////////////////////// + // Available Scenes in this quest, not necessarly all are used + ////////////////////////////////////////////////////////////////////// + + void Scene00000( World::Quest& quest, Entity::Player& player ) + { + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, bindSceneReturn( &ClsCnj998::Scene00000Return ) ); + } + + void Scene00000Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) + { + if( result.getResult( 0 ) == 1 )// accept quest + { + quest.setSeq( SeqFinish ); + } + } + + ////////////////////////////////////////////////////////////////////// + + void Scene00001( World::Quest& quest, Entity::Player& player ) + { + eventMgr().playQuestScene( player, getId(), 1, FADE_OUT | HIDE_UI, bindSceneReturn( &ClsCnj998::Scene00001Return ) ); + } + + void Scene00001Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) + { + + if( result.getResult( 0 ) == 1 ) + { + player.finishQuest( getId() ); + player.setLevelForClass( 1, Sapphire::Common::ClassJob::Conjurer ); + player.addGearSet(); + } + } +}; + +EXPOSE_SCRIPT( ClsCnj998 ); \ No newline at end of file diff --git a/src/scripts/quest/classquest/CNJ/ClsCnj999.cpp b/src/scripts/quest/classquest/CNJ/ClsCnj999.cpp new file mode 100644 index 00000000..abd19e3e --- /dev/null +++ b/src/scripts/quest/classquest/CNJ/ClsCnj999.cpp @@ -0,0 +1,72 @@ +// This is an automatically generated C++ script template +// Content needs to be added by hand to make it function +// In order for this script to be loaded, move it to the correct folder in /scripts/ + +#include "Manager/EventMgr.h" +#include +#include +#include + +// Quest Script: ClsCnj999_00182 +// Quest Name: So You Want to Be a Conjurer +// Quest ID: 65718 +// Start NPC: 1000323 (Madelle) +// End NPC: 1000323 (Madelle) + +using namespace Sapphire; + +class ClsCnj999 : public Sapphire::ScriptAPI::QuestScript +{ +private: + // Basic quest information + // Quest vars / flags used + + // Steps in this quest ( 0 is before accepting, + // 1 is first, 255 means ready for turning it in + enum Sequence : uint8_t + { + }; + static constexpr auto Actor0 = 1000323; + + + // Entities found in the script data of the quest + +public: + ClsCnj999() : Sapphire::ScriptAPI::QuestScript( 65718 ){}; + ~ClsCnj999() = default; + + ////////////////////////////////////////////////////////////////////// + // Event Handlers + void onTalk( World::Quest& quest, Entity::Player& player, uint64_t actorId ) override + { + switch( actorId ) + { + case Actor0: + { + Scene00000( quest, player ); + break; + } + } + } + + +private: + ////////////////////////////////////////////////////////////////////// + // Available Scenes in this quest, not necessarly all are used + ////////////////////////////////////////////////////////////////////// + + void Scene00000( World::Quest& quest, Entity::Player& player ) + { + eventMgr().playQuestScene( player, getId(), 0, HIDE_HOTBAR, bindSceneReturn( &ClsCnj999::Scene00000Return ) ); + } + + void Scene00000Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result ) + { + if( result.getResult( 0 ) == 1 ) + { + player.finishQuest( getId(), 0 ); + } + } +}; + +EXPOSE_SCRIPT( ClsCnj999 ); \ No newline at end of file From 8f408c4e5e733a012bdeb9b486cdf3a5179fb95b Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 10 May 2024 16:13:45 -0700 Subject: [PATCH 2/4] Add condition to increment currentKC in SubFst011 Prevents repeated excess quest progress event notices if Enemy0 is killed after kill count is already reached --- src/scripts/quest/subquest/gridania/SubFst011.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scripts/quest/subquest/gridania/SubFst011.cpp b/src/scripts/quest/subquest/gridania/SubFst011.cpp index 5c7286b6..dfda7acc 100644 --- a/src/scripts/quest/subquest/gridania/SubFst011.cpp +++ b/src/scripts/quest/subquest/gridania/SubFst011.cpp @@ -67,8 +67,11 @@ public: case Enemy0: { auto currentKC = quest.getUI8AL(); - quest.setUI8AL( currentKC + 1 ); - eventMgr().sendEventNotice( player, getId(), 0, 2, currentKC + 1, 6 ); + if( currentKC < 6 ) + { + quest.setUI8AL( currentKC + 1 ); + eventMgr().sendEventNotice( player, getId(), 0, 2, currentKC + 1, 6 ); + } if( currentKC + 1 >= 6 ) quest.setSeq( SeqFinish ); From 3008404c22317103f96491752e2b82493dfe2998 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 12 May 2024 11:21:04 -0700 Subject: [PATCH 3/4] add remove condition casting in EventMgr fixes issue where using EventItemAction during quests makes the player stuck casting --- src/world/Manager/EventMgr.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/world/Manager/EventMgr.cpp b/src/world/Manager/EventMgr.cpp index e2b87ef4..51861d85 100644 --- a/src/world/Manager/EventMgr.cpp +++ b/src/world/Manager/EventMgr.cpp @@ -552,6 +552,9 @@ void EventMgr::eventFinish( Sapphire::Entity::Player& player, uint32_t eventId, if( player.hasCondition( Common::PlayerCondition::WatchingCutscene ) ) player.removeCondition( Common::PlayerCondition::WatchingCutscene ); + + if( player.hasCondition( Common::PlayerCondition::Casting )) + player.removeCondition( Common::PlayerCondition::Casting ); player.removeEvent( pEvent->getId() ); From 4679420d8449307c099724860ebb1b64daf4bfc2 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 12 May 2024 12:01:21 -0700 Subject: [PATCH 4/4] fix infinite loop trying to return from Event Scene00099 doesn't do anything and causes server to infinitely attempt to return from it --- src/scripts/quest/subquest/gridania/SubFst009.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scripts/quest/subquest/gridania/SubFst009.cpp b/src/scripts/quest/subquest/gridania/SubFst009.cpp index 6d1a63c0..a61e2e8c 100644 --- a/src/scripts/quest/subquest/gridania/SubFst009.cpp +++ b/src/scripts/quest/subquest/gridania/SubFst009.cpp @@ -96,8 +96,6 @@ class SubFst009 : public Sapphire::ScriptAPI::QuestScript { if (result.getResult(0) == 1) Scene00100(quest, player); - else - Scene00099(quest, player); } //////////////////////////////////////////////////////////////////////