2022-01-13 23:18:53 -06:00
|
|
|
// 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 <root>/scripts/
|
|
|
|
|
|
|
|
#include "Manager/EventMgr.h"
|
2022-01-14 01:26:54 -06:00
|
|
|
#include <Actor/Player.h>
|
2022-01-13 23:18:53 -06:00
|
|
|
#include <ScriptObject.h>
|
|
|
|
#include <Service.h>
|
|
|
|
|
|
|
|
// Quest Script: ClsArc100_00219
|
|
|
|
// Quest Name: My First Bow
|
|
|
|
// Quest ID: 65755
|
|
|
|
// Start NPC: 1000200
|
|
|
|
// End NPC: 1000200
|
|
|
|
|
|
|
|
using namespace Sapphire;
|
|
|
|
|
|
|
|
class ClsArc100 : public Sapphire::ScriptAPI::QuestScript
|
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
private:
|
|
|
|
// Basic quest information
|
|
|
|
// Quest vars / flags used
|
|
|
|
// UI8AL
|
|
|
|
// UI8BH
|
|
|
|
// UI8BL
|
|
|
|
|
|
|
|
/// Countable Num: 3 Seq: 1 Event: 5 Listener: 37
|
|
|
|
/// Countable Num: 3 Seq: 1 Event: 5 Listener: 49
|
|
|
|
/// Countable Num: 3 Seq: 1 Event: 5 Listener: 47
|
|
|
|
/// Countable Num: 1 Seq: 255 Event: 1 Listener: 1000200
|
|
|
|
// Steps in this quest ( 0 is before accepting,
|
|
|
|
// 1 is first, 255 means ready for turning it in
|
|
|
|
enum Sequence : uint8_t
|
|
|
|
{
|
|
|
|
Seq0 = 0,
|
|
|
|
Seq1 = 1,
|
|
|
|
SeqFinish = 255,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Entities found in the script data of the quest
|
|
|
|
static constexpr auto Actor0 = 1000200;
|
|
|
|
static constexpr auto Enemy0 = 37;//Ground Squirrel
|
|
|
|
static constexpr auto Enemy1 = 49;//Little Ladybug
|
|
|
|
static constexpr auto Enemy2 = 47;//Foest Funguar
|
|
|
|
static constexpr auto Seq0Actor0 = 0;
|
|
|
|
static constexpr auto Seq2Actor0 = 1;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ClsArc100() : Sapphire::ScriptAPI::QuestScript( 65755 ){};
|
|
|
|
~ClsArc100() = default;
|
2022-01-13 23:18:53 -06:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Event Handlers
|
2022-01-14 01:26:54 -06:00
|
|
|
void onTalk( World::Quest &quest, Entity::Player &player, uint64_t actorId ) override
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
|
|
|
switch( actorId )
|
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
case Actor0: {
|
|
|
|
if( quest.getSeq() == Seq0 )
|
|
|
|
Scene00000( quest, player );
|
|
|
|
else if( quest.getSeq() == SeqFinish )
|
|
|
|
Scene00001( quest, player );
|
2022-01-13 23:18:53 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
void onBNpcKill( World::Quest &quest, uint16_t nameId, uint32_t entityId, Sapphire::Entity::Player &player ) override
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
if( nameId != Enemy0 && nameId != Enemy1 && nameId != Enemy2 )
|
2022-01-13 23:18:53 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
auto currentKC37 = quest.getUI8AL() + 1;
|
|
|
|
auto currentKC49 = quest.getUI8BH() + 1;
|
|
|
|
auto currentKC47 = quest.getUI8BL() + 1;
|
|
|
|
|
|
|
|
switch( nameId )
|
|
|
|
{
|
|
|
|
case Enemy0: {
|
2022-01-14 01:26:54 -06:00
|
|
|
if( currentKC37 >= 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8AL( currentKC37 );
|
|
|
|
checkQuestCompletion( quest, player );
|
|
|
|
eventMgr().sendEventNotice( player, getId(), 0, 2, currentKC37, 3 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
2022-01-14 01:26:54 -06:00
|
|
|
else if( currentKC37 < 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8AL( currentKC37 );
|
|
|
|
eventMgr().sendEventNotice( player, getId(), 0, 2, currentKC37, 3 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Enemy1: {
|
2022-01-14 01:26:54 -06:00
|
|
|
if( currentKC49 >= 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8BH( currentKC49 );
|
|
|
|
checkQuestCompletion( quest, player );
|
|
|
|
eventMgr().sendEventNotice( player, getId(), 1, 2, currentKC49, 3 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
2022-01-14 01:26:54 -06:00
|
|
|
else if( currentKC49 < 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8BH( currentKC49 );
|
|
|
|
eventMgr().sendEventNotice( player, getId(), 1, 2, currentKC49, 3 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Enemy2: {
|
2022-01-14 01:26:54 -06:00
|
|
|
if( currentKC47 >= 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8BL( currentKC47 );
|
|
|
|
checkQuestCompletion( quest, player );
|
|
|
|
eventMgr().sendEventNotice( player, getId(), 2, 2, currentKC47, 3 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
2022-01-14 01:26:54 -06:00
|
|
|
else if( currentKC47 < 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8BL( currentKC47 );
|
|
|
|
eventMgr().sendEventNotice( player, getId(), 2, 2, currentKC47, 3 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
private:
|
|
|
|
void checkQuestCompletion( World::Quest &quest, Entity::Player &player )
|
|
|
|
{
|
|
|
|
auto currentKC37 = quest.getUI8AL();
|
|
|
|
auto currentKC49 = quest.getUI8BH();
|
|
|
|
auto currentKC47 = quest.getUI8BL();
|
2022-01-13 23:18:53 -06:00
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
if( currentKC37 == 3 && currentKC49 == 3 && currentKC47 == 3 )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setUI8AL( 0 );
|
|
|
|
quest.setUI8BH( 0 );
|
|
|
|
quest.setUI8BL( 0 );
|
|
|
|
quest.setSeq( SeqFinish );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
2022-01-14 01:26:54 -06:00
|
|
|
}
|
2022-01-13 23:18:53 -06:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Available Scenes in this quest, not necessarly all are used
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
void Scene00000( World::Quest &quest, Entity::Player &player )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
|
|
|
eventMgr().playQuestScene( player, getId(), 0, NONE, bindSceneReturn( &ClsArc100::Scene00000Return ) );
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
void Scene00000Return( World::Quest &quest, Entity::Player &player, const Event::SceneResult &result )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
if( result.getResult( 0 ) == 1 )// accept quest
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
2022-01-14 01:26:54 -06:00
|
|
|
quest.setSeq( Seq1 );
|
2022-01-13 23:18:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
void Scene00001( World::Quest &quest, Entity::Player &player )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
|
|
|
eventMgr().playQuestScene( player, getId(), 1, NONE, bindSceneReturn( &ClsArc100::Scene00001Return ) );
|
|
|
|
}
|
|
|
|
|
2022-01-14 01:26:54 -06:00
|
|
|
void Scene00001Return( World::Quest &quest, Entity::Player &player, const Event::SceneResult &result )
|
2022-01-13 23:18:53 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
if( result.getResult( 0 ) == 1 )
|
|
|
|
{
|
|
|
|
player.finishQuest( getId() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EXPOSE_SCRIPT( ClsArc100 );
|