1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00
sapphire/src/scripts/quest/subquest/gridania/SubFst041.cpp

145 lines
4 KiB
C++
Raw Normal View History

2018-05-29 21:26:51 +02:00
#include <Actor/Player.h>
2018-12-23 03:53:08 +01:00
#include <Manager/EventMgr.h>
2018-05-29 21:26:51 +02:00
#include <ScriptObject.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
2018-05-29 21:26:51 +02:00
using namespace Sapphire;
2018-10-28 21:53:21 +01:00
2018-05-29 21:26:51 +02:00
// Quest Script: SubFst041_00197
// Quest Name: Splitting Shells
// Quest ID: 65733
// Start NPC: 1000432
// End NPC: 1000411
class SubFst041 :
public Sapphire::ScriptAPI::EventScript
2018-05-29 21:26:51 +02:00
{
private:
// Basic quest information
// Quest vars / flags used
// GetQuestUI8AL
// GetQuestUI8BH
enum Sequence :
uint8_t
{
Seq0 = 0,
Seq1 = 1,
SeqFinish = 255,
};
// Quest rewards
static constexpr auto RewardExpFactor = 100;
uint32_t RewardItemOptional[3] = { 4657, 4658, 5823 };
uint32_t RewardItemOptionalCount[3] = { 3, 3, 3 };
// Entities found in the script data of the quest
static constexpr auto Actor0 = 1000432;
static constexpr auto Actor1 = 1000411;
static constexpr auto Enemy0 = 197; //159; WRONG INFO
static constexpr auto Item0 = 2000142;
static constexpr auto Seq0Actor0 = 0;
static constexpr auto Seq2Actor1 = 1;
static constexpr auto Seq2Actor1Npctradeno = 99;
static constexpr auto Seq2Actor1Npctradeok = 100;
public:
SubFst041() :
Sapphire::ScriptAPI::EventScript( 65733 )
{
};
~SubFst041()
{
};
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
2020-03-01 01:00:57 +11:00
auto pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
if( actor == Actor0 )
Scene00000( player );
if( actor == Actor1 )
Scene00001( player );
}
void onBNpcKill( uint32_t npcId, Entity::Player& player ) override
{
if( npcId != Enemy0 )
return;
auto currentKC = player.getQuestUI8BH( getId() );
if ( currentKC + 1 >= 4 )
{
player.setQuestUI8AL( getId(), currentKC + 1 );
player.setQuestUI8BH( getId(), currentKC + 1 );
player.sendQuestMessage( getId(), 1, 0, 0, 0 );
player.updateQuest( getId(), SeqFinish );
}
else
{
player.setQuestUI8AL( getId(), currentKC + 1 );
player.setQuestUI8BH( getId(), currentKC + 1 );
player.sendQuestMessage( getId(), 0, 2, currentKC + 1, 4 );
}
}
private:
void Scene00000( Entity::Player& player )
{
player.playScene( getId(), 0, HIDE_HOTBAR,
[ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param2 == 1 )
{
player.updateQuest( getId(), Seq1 );
}
} );
}
void Scene00001( Entity::Player& player )
{
player.playScene( getId(), 1, HIDE_HOTBAR,
[ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param2 == 1 )
{
Scene00100( player );
}
else
{
Scene00099( player );
}
} );
}
void Scene00099( Entity::Player& player )
{
player.playScene( getId(), 99, HIDE_HOTBAR,
[ & ]( Entity::Player& player, const Event::SceneResult& result )
{
player.playScene( getId(), 99, 0, 0, 0 );
} );
}
void Scene00100( Entity::Player& player )
{
player.playScene( getId(), 100, HIDE_HOTBAR,
[ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param2 == 1 )
{
if( player.giveQuestRewards( getId(), result.param3 ) )
{
player.setQuestUI8BH( getId(), 0 );
player.finishQuest( getId() );
}
}
} );
}
2018-05-29 21:26:51 +02:00
};
EXPOSE_SCRIPT( SubFst041 );