1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 15:17:46 +00:00
sapphire/src/scripts/quest/subquest/gridania/SubFst002.cpp

88 lines
2.2 KiB
C++
Raw Normal View History

2018-03-07 08:14:42 +01:00
#include <Actor/Player.h>
2018-12-23 03:53:08 +01:00
#include "Manager/EventMgr.h"
2018-06-18 13:14:11 +00:00
#include <ScriptObject.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
2018-03-07 08:14:42 +01:00
using namespace Sapphire;
2018-10-28 21:53:21 +01:00
2018-03-07 08:14:42 +01:00
// Quest Script: SubFst002_00025
// Quest Name: Quarrels with Squirrels
// Quest ID: 65561
// Start NPC: 1000263
// End NPC: 1000263
class SubFst002 :
public Sapphire::ScriptAPI::EventScript
2018-03-07 08:14:42 +01:00
{
private:
static constexpr auto SEQ_0 = 0;
static constexpr auto SEQ_1 = 1;
static constexpr auto SEQ_2 = 2;
static constexpr auto SEQ_FINISH = 255;
static constexpr auto ACTOR0 = 1000263;
static constexpr auto ENEMY0 = 37;
static constexpr auto SEQ_0_ACTOR0 = 0;
static constexpr auto SEQ_2_ACTOR0 = 1;
2018-03-07 08:14:42 +01:00
void Scene00000( Entity::Player& player )
{
auto callback = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param2 == 1 ) // accept quest
2018-03-07 08:14:42 +01:00
{
player.updateQuest( getId(), SEQ_1 );
}
};
2018-03-07 08:14:42 +01:00
player.playScene( getId(), 0, NONE, callback );
}
2018-03-07 08:14:42 +01:00
void Scene00001( Entity::Player& player )
{
auto callback = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param2 == 1 ) // finish quest
2018-03-07 08:14:42 +01:00
{
if( player.giveQuestRewards( getId(), 0 ) )
player.finishQuest( getId() );
}
};
2018-03-07 08:14:42 +01:00
player.playScene( getId(), 1, NONE, callback );
}
2018-03-07 08:14:42 +01:00
public:
SubFst002() :
Sapphire::ScriptAPI::EventScript( 65561 )
{
}
2018-03-07 08:14:42 +01:00
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
2020-03-01 01:00:57 +11:00
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
2018-03-07 08:14:42 +01:00
if( actor == ACTOR0 && !player.hasQuest( getId() ) )
Scene00000( player );
else if( actor == ACTOR0 && player.getQuestSeq( getId() ) == SEQ_FINISH )
Scene00001( player );
}
2018-03-07 08:14:42 +01:00
void onBNpcKill( uint32_t npcId, Entity::Player& player ) override
{
if( npcId != ENEMY0 )
return;
2018-03-07 08:14:42 +01:00
auto currentKC = player.getQuestUI8AL( getId() ) + 1;
2018-03-07 08:14:42 +01:00
if( currentKC >= 6 )
player.updateQuest( getId(), SEQ_FINISH );
else
{
player.setQuestUI8AL( getId(), currentKC );
player.sendQuestMessage( getId(), 0, 2, currentKC, 6 );
}
}
2018-03-07 08:14:42 +01:00
};
EXPOSE_SCRIPT( SubFst002 );