mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-25 19:17:45 +00:00
Try to implement a quest.
This commit is contained in:
parent
1c89e16c27
commit
148243c402
4 changed files with 112 additions and 11 deletions
101
src/scripts/quest/SubSea050.cpp
Normal file
101
src/scripts/quest/SubSea050.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include <Actor/Player.h>
|
||||
#include "Manager/EventMgr.h"
|
||||
#include <ScriptObject.h>
|
||||
#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 );
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Add table
Reference in a new issue