From 148243c4022b0b9a0ea0eda965f6467ad8f27378 Mon Sep 17 00:00:00 2001 From: collett Date: Fri, 3 Jan 2020 01:11:19 +0900 Subject: [PATCH] Try to implement a quest. --- src/scripts/quest/SubSea050.cpp | 101 ++++++++++++++++++ src/world/Action/Action.cpp | 16 +-- src/world/Action/EffectBuilder.cpp | 4 +- .../Network/PacketWrappers/EffectPacket.h | 2 +- 4 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 src/scripts/quest/SubSea050.cpp diff --git a/src/scripts/quest/SubSea050.cpp b/src/scripts/quest/SubSea050.cpp new file mode 100644 index 00000000..2a39237c --- /dev/null +++ b/src/scripts/quest/SubSea050.cpp @@ -0,0 +1,101 @@ +#include +#include "Manager/EventMgr.h" +#include +#include "Framework.h" + +using namespace Sapphire; + +// Quest Script: SubSea050_00462 +// Quest Name: On to Summerford +// Quest ID: 65998 +// Start NPC: 1000972 +// End NPC: 1002626 + +class SubSea050 : public Sapphire::ScriptAPI::EventScript +{ + 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 + { + Seq0 = 0, + SeqFinish = 255, + }; + + // Entities found in the script data of the quest + static constexpr auto Actor0 = 1000972; + static constexpr auto Actor1 = 1002626; + static constexpr auto LocActor0 = 1003289; + static constexpr auto LocFace0 = 604; + static constexpr auto LocFace1 = 617; + static constexpr auto LocPosActor0 = 4201224; + static constexpr auto LocPosCam1 = 4201231; + static constexpr auto LocSe1 = 39; + static constexpr auto LocSe2 = 40; + + public: + SubSea050() : Sapphire::ScriptAPI::EventScript( 65998 ){}; + ~SubSea050() = default; + + ////////////////////////////////////////////////////////////////////// + // Event Handlers + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + auto pEventMgr = m_framework->get< World::Manager::EventMgr >(); + auto actor = pEventMgr->mapEventActorToRealActor( actorId ); + + if( actor == Actor0 ) + { + Scene00000( player ); + } + else if( actor == Actor1 ) + { + Scene00002( player ); + } + } + + + private: + ////////////////////////////////////////////////////////////////////// + // Available Scenes in this quest, not necessarly all are used + void Scene00000( Entity::Player& player ) + { + player.playScene( getId(), 0, 0, + [ & ]( Entity::Player& player, const Event::SceneResult& result ) + { + if( result.param2 == 1 ) + { + player.updateQuest( getId(), Sequence::SeqFinish ); + } + }); + } + + void Scene00001( Entity::Player& player ) + { + player.playScene( getId(), 1, HIDE_HOTBAR, + [ & ]( Entity::Player& player, const Event::SceneResult& result ) + { + }); + } + + void Scene00002( Entity::Player& player ) + { + player.playScene( getId(), 2, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, + [ & ]( Entity::Player& player, const Event::SceneResult& result ) + { + if( result.param2 == 1 ) + { + if( player.giveQuestRewards( getId(), result.param3 ) ) + { + player.finishQuest( getId() ); + } + } + }); + } + +}; + +EXPOSE_SCRIPT( SubSea050 ); \ No newline at end of file diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index e637288e..26d89af8 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -357,7 +357,7 @@ void Action::Action::execute() if( !m_actionData->preservesCombo ) { // potential combo starter or correct combo from last action - if ( ( !isComboAction() || isCorrectCombo() ) ) + if( ( !isComboAction() || isCorrectCombo() ) ) { m_pSource->setLastComboActionId( getId() ); } @@ -431,15 +431,15 @@ void Action::Action::buildEffects() auto dmg = calcDamage( isCorrectCombo() ? lutEntry.comboPotency : lutEntry.potency ); m_effectBuilder->damageTarget( actor, dmg.first, dmg.second ); - if ( dmg.first > 0 ) + if( dmg.first > 0 ) actor->onActionHostile( m_pSource ); - if ( isCorrectCombo() ) + if( isCorrectCombo() ) { m_effectBuilder->comboVisualEffect( actor ); } - if ( !isComboAction() || isCorrectCombo() ) + if( !isComboAction() || isCorrectCombo() ) { if( lutEntry.curePotency > 0 ) // actions with self heal { @@ -450,12 +450,12 @@ void Action::Action::buildEffects() m_effectBuilder->selfHeal( actor, m_pSource, lutEntry.curePotency ); } - if ( lutEntry.restoreMPPercentage > 0 ) + if( lutEntry.restoreMPPercentage > 0 ) { m_effectBuilder->restoreMP( actor, m_pSource, m_pSource->getMp() * lutEntry.restoreMPPercentage / 100 ); } - if ( !m_actionData->preservesCombo ) // we need something like m_actionData->hasNextComboAction + if( !m_actionData->preservesCombo ) // we need something like m_actionData->hasNextComboAction { m_effectBuilder->startCombo( actor, getId() ); } @@ -466,13 +466,13 @@ void Action::Action::buildEffects() // todo: calcHealing() m_effectBuilder->healTarget( actor, lutEntry.curePotency ); - if ( lutEntry.restoreMPPercentage > 0 ) + if( lutEntry.restoreMPPercentage > 0 ) { // always restore caster mp I don't think there are any actions that can restore target MP post 5.0 m_effectBuilder->restoreMP( actor, m_pSource, m_pSource->getMp() * lutEntry.restoreMPPercentage / 100 ); } } - else if ( lutEntry.restoreMPPercentage > 0 ) + else if( lutEntry.restoreMPPercentage > 0 ) { m_effectBuilder->restoreMP( m_pSource, m_pSource, m_pSource->getMp() * lutEntry.restoreMPPercentage / 100 ); } diff --git a/src/world/Action/EffectBuilder.cpp b/src/world/Action/EffectBuilder.cpp index d272d7ff..2313c4e9 100644 --- a/src/world/Action/EffectBuilder.cpp +++ b/src/world/Action/EffectBuilder.cpp @@ -90,7 +90,7 @@ void EffectBuilder::damageTarget( Entity::CharaPtr& target, uint32_t amount, Com void EffectBuilder::startCombo( Entity::CharaPtr& target, uint16_t actionId ) { auto resultList = getResultList( target ); - assert( resultList ); + assert( resultList ); EffectResultPtr nextResult = make_EffectResult( target, 0 ); nextResult->startCombo( actionId ); @@ -100,7 +100,7 @@ void EffectBuilder::startCombo( Entity::CharaPtr& target, uint16_t actionId ) void EffectBuilder::comboVisualEffect( Entity::CharaPtr& target ) { auto resultList = getResultList( target ); - assert( resultList ); + assert( resultList ); EffectResultPtr nextResult = make_EffectResult( target, 0 ); nextResult->comboVisualEffect(); diff --git a/src/world/Network/PacketWrappers/EffectPacket.h b/src/world/Network/PacketWrappers/EffectPacket.h index 5aa44c0a..cb062f3f 100644 --- a/src/world/Network/PacketWrappers/EffectPacket.h +++ b/src/world/Network/PacketWrappers/EffectPacket.h @@ -26,7 +26,7 @@ namespace Sapphire::Network::Packets::Server m_data.effectDisplayType = Common::ActionEffectDisplayType::ShowActionName; - std::memset(m_data.effects, 0, sizeof(Common::EffectEntry) * 8); + std::memset( m_data.effects, 0, sizeof( Common::EffectEntry ) * 8 ); } void addEffect( const Common::EffectEntry& effect )