2018-03-06 22:22:19 +01:00
|
|
|
#include <Logging/Logger.h>
|
2021-11-27 00:53:57 +01:00
|
|
|
#include <Exd/ExdData.h>
|
2018-03-06 22:22:19 +01:00
|
|
|
|
2018-10-25 13:38:06 +11:00
|
|
|
#include <watchdog/Watchdog.h>
|
2020-02-29 22:30:10 +11:00
|
|
|
#include <Service.h>
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2019-07-21 22:33:33 +10:00
|
|
|
#include "Territory/Territory.h"
|
2018-12-01 00:27:16 +11:00
|
|
|
#include "Territory/InstanceContent.h"
|
2019-03-31 11:27:11 +02:00
|
|
|
#include "Territory/QuestBattle.h"
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
2018-11-30 23:15:58 +11:00
|
|
|
#include "Actor/EventObject.h"
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "WorldServer.h"
|
2018-01-09 23:50:54 +01:00
|
|
|
#include "Event/EventHandler.h"
|
2019-02-10 23:28:15 +11:00
|
|
|
#include "Action/Action.h"
|
2018-12-23 03:53:08 +01:00
|
|
|
|
|
|
|
#include "Manager/EventMgr.h"
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "Manager/PlayerMgr.h"
|
2022-01-10 23:50:44 +01:00
|
|
|
#include "Manager/TerritoryMgr.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "StatusEffect/StatusEffect.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "Script/ScriptMgr.h"
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "NativeScriptMgr.h"
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "WorldServer.h"
|
2018-01-28 11:16:34 +01:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "Quest/Quest.h"
|
|
|
|
|
|
|
|
using namespace Sapphire::World::Manager;
|
2018-01-28 11:16:34 +01:00
|
|
|
// enable the ambiguity fix for every platform to avoid #define nonsense
|
|
|
|
#define WIN_AMBIGUITY_FIX
|
2017-12-14 22:30:06 +11:00
|
|
|
|
2019-10-14 18:41:16 +11:00
|
|
|
namespace fs = std::filesystem;
|
2018-10-25 13:38:06 +11:00
|
|
|
|
2020-03-01 01:00:57 +11:00
|
|
|
Sapphire::Scripting::ScriptMgr::ScriptMgr() :
|
2018-08-29 21:40:59 +02:00
|
|
|
m_firstScriptChangeNotificiation( false )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2020-03-01 01:00:57 +11:00
|
|
|
m_nativeScriptMgr = createNativeScriptMgr();
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Scripting::ScriptMgr::~ScriptMgr()
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
Watchdog::unwatchAll();
|
2017-12-14 22:30:06 +11:00
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
void Sapphire::Scripting::ScriptMgr::update()
|
2017-12-14 22:30:06 +11:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
m_nativeScriptMgr->processLoadQueue();
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::init()
|
2017-12-10 23:51:06 +11:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
std::set< std::string > files;
|
2021-11-27 00:53:57 +01:00
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
2017-12-10 23:51:06 +11:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
auto status = loadDir( server.getConfig().scripts.path, files, m_nativeScriptMgr->getModuleExtension() );
|
2017-12-10 23:51:06 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( !status )
|
|
|
|
{
|
2019-01-25 22:43:04 +11:00
|
|
|
Logger::error( "ScriptMgr: failed to load modules, the server will not function correctly without scripts loaded." );
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
|
|
|
}
|
2018-04-04 11:25:07 +10:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
uint32_t scriptsFound = 0;
|
|
|
|
uint32_t scriptsLoaded = 0;
|
2017-12-14 22:30:06 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
for( auto itr = files.begin(); itr != files.end(); ++itr )
|
|
|
|
{
|
|
|
|
auto& path = *itr;
|
2017-12-10 23:51:06 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
scriptsFound++;
|
2017-12-14 22:30:06 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( m_nativeScriptMgr->loadScript( path ) )
|
|
|
|
scriptsLoaded++;
|
|
|
|
}
|
2017-12-10 23:51:06 +11:00
|
|
|
|
2019-01-04 22:37:01 +11:00
|
|
|
Logger::info( "ScriptMgr: Loaded {0}/{1} modules", scriptsLoaded, scriptsFound );
|
2017-12-14 22:30:06 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
watchDirectories();
|
2017-12-14 22:30:06 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
2017-12-10 23:51:06 +11:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
void Sapphire::Scripting::ScriptMgr::watchDirectories()
|
2017-12-14 22:30:06 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
|
|
|
auto shouldWatch = server.getConfig().scripts.hotSwap;
|
2018-08-29 21:40:59 +02:00
|
|
|
if( !shouldWatch )
|
|
|
|
return;
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
Watchdog::watchMany( server.getConfig().scripts.path + "*" +
|
2018-08-29 21:40:59 +02:00
|
|
|
m_nativeScriptMgr->getModuleExtension(),
|
|
|
|
[ this ]( const std::vector< ci::fs::path >& paths )
|
|
|
|
{
|
|
|
|
if( !m_firstScriptChangeNotificiation )
|
|
|
|
{
|
|
|
|
// for whatever reason, the first time this runs, it detects every file as changed
|
|
|
|
// so we're always going to ignore the first notification
|
|
|
|
m_firstScriptChangeNotificiation = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
for( const auto& path : paths )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
if( m_nativeScriptMgr->isModuleLoaded( path.stem().string() ) )
|
|
|
|
{
|
2019-01-04 22:37:01 +11:00
|
|
|
Logger::debug( "Reloading changed script: {0}", path.stem().string() );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
m_nativeScriptMgr->queueScriptReload( path.stem().string() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-04 22:37:01 +11:00
|
|
|
Logger::debug( "Loading new script: {0}", path.stem().string() );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
m_nativeScriptMgr->loadScript( path.string() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
2017-12-14 22:30:06 +11:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2019-01-04 22:37:01 +11:00
|
|
|
Logger::info( "ScriptMgr: loading scripts from: {0}", dirname );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-25 13:38:06 +11:00
|
|
|
if( !fs::exists( dirname ) )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2018-12-23 03:53:08 +01:00
|
|
|
Logger::error( "ScriptMgr: scripts directory doesn't exist" );
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-25 13:38:06 +11:00
|
|
|
fs::path targetDir( dirname );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-25 13:38:06 +11:00
|
|
|
fs::directory_iterator iter( targetDir );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-25 15:15:27 +02:00
|
|
|
for( const auto& i : iter )
|
2018-09-26 08:47:22 -04:00
|
|
|
{
|
2018-10-25 15:15:27 +02:00
|
|
|
if( fs::is_regular_file( i ) && fs::path( i ).extension() == ext )
|
2018-09-26 08:47:22 -04:00
|
|
|
{
|
2018-10-26 14:11:02 +02:00
|
|
|
files.insert( fs::path( i ).string() );
|
2018-09-26 08:47:22 -04:00
|
|
|
}
|
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
if( !files.empty() )
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
{
|
2018-12-23 03:53:08 +01:00
|
|
|
Logger::error( "ScriptMgr: couldn't find any script modules" );
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
void Sapphire::Scripting::ScriptMgr::onPlayerFirstEnterWorld( Entity::Player& player )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2017-12-10 01:52:03 +11:00
|
|
|
// try
|
|
|
|
// {
|
|
|
|
// std::string test = m_onFirstEnterWorld( player );
|
|
|
|
// }
|
|
|
|
// catch( const std::exception &e )
|
|
|
|
// {
|
|
|
|
// std::string what = e.what();
|
|
|
|
// }
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
|
|
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
|
|
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
{
|
|
|
|
auto questInfo = exdData.getRow< Component::Excel::Quest >( eventId );
|
|
|
|
if( questInfo )
|
|
|
|
{
|
|
|
|
World::Manager::PlayerMgr::sendUrgent( player, "Quest not implemented: {0} ({1})", questInfo->getString( questInfo->data().Text.Name ), eventId );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
|
|
|
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
|
|
|
|
|
|
|
|
auto questId = static_cast< uint16_t >( eventId );
|
|
|
|
if( player.hasQuest( eventId ) )
|
|
|
|
{
|
2021-12-22 00:40:11 +01:00
|
|
|
World::Quest preQ;
|
2021-11-27 00:53:57 +01:00
|
|
|
auto questIdx = player.getQuestIndex( questId );
|
|
|
|
auto& quest = player.getQuestByIndex( questIdx );
|
2021-12-22 00:40:11 +01:00
|
|
|
preQ = quest;
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onTalk( quest, player, actor );
|
2021-12-22 00:40:11 +01:00
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
2021-11-27 00:53:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto newQuest = World::Quest( questId, 0, 0 );
|
|
|
|
script->onTalk( newQuest, player, actor );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// all other types....
|
|
|
|
|
2018-11-30 23:15:58 +11:00
|
|
|
// check if the actor is an eobj and call its script if we have one
|
2022-01-10 23:50:44 +01:00
|
|
|
auto& teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
|
|
|
auto zone = teriMgr.getTerritoryByGuId( player.getTerritoryId() );
|
2022-01-13 22:51:47 +01:00
|
|
|
if( auto eobj = zone ? zone->getEObj( static_cast< uint32_t >( actorId ) ) : nullptr )
|
2018-11-30 23:15:58 +11:00
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventObjectScript >( eobj->getObjectId() );
|
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
script->onTalk( eventId, player, *eobj );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for a direct eventid match first, otherwise default to base type
|
2018-11-22 13:12:21 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
2018-11-20 22:52:57 +11:00
|
|
|
if( script )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2018-11-20 22:52:57 +11:00
|
|
|
script->onTalk( eventId, player, actorId );
|
|
|
|
return true;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2018-11-20 22:52:57 +11:00
|
|
|
else
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2018-12-02 02:01:41 +01:00
|
|
|
script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId & 0xFFFF0000 );
|
2018-11-20 22:52:57 +11:00
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
script->onTalk( eventId, player, actorId );
|
|
|
|
return true;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
|
|
|
|
|
|
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
if( player.hasQuest( eventId ) )
|
|
|
|
{
|
|
|
|
auto idx = player.getQuestIndex( eventId );
|
|
|
|
auto& quest = player.getQuestByIndex( idx );
|
|
|
|
script->onEnterTerritory( quest, player, param1, param2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
script->onEnterTerritory( player, eventId, param1, param2 );
|
|
|
|
}
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2022-01-16 19:40:21 +01:00
|
|
|
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
|
|
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
|
|
|
|
|
|
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
if( player.hasQuest( eventId ) )
|
|
|
|
{
|
|
|
|
auto idx = player.getQuestIndex( eventId );
|
|
|
|
auto& quest = player.getQuestByIndex( idx );
|
|
|
|
World::Quest preQ = quest;
|
|
|
|
script->onWithinRange( quest, player, eventId, param1, x, y, z );
|
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
script->onWithinRange( player, eventId, param1, x, y, z );
|
|
|
|
}
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2022-01-16 19:40:21 +01:00
|
|
|
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
|
|
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
|
|
|
|
|
|
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
if( player.hasQuest( eventId ) )
|
|
|
|
{
|
|
|
|
auto idx = player.getQuestIndex( eventId );
|
|
|
|
auto& quest = player.getQuestByIndex( idx );
|
|
|
|
World::Quest preQ = quest;
|
|
|
|
script->onOutsideRange( quest, player, eventId, param1, x, y, z );
|
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
script->onOutsideRange( player, eventId, param1, x, y, z );
|
|
|
|
}
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId, uint8_t emoteId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
|
|
|
|
2022-01-14 12:51:37 +01:00
|
|
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
|
|
|
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
|
2021-11-27 00:53:57 +01:00
|
|
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
|
|
|
if( player.hasQuest( eventId ) )
|
|
|
|
{
|
|
|
|
auto idx = player.getQuestIndex( eventId );
|
|
|
|
auto& quest = player.getQuestByIndex( idx );
|
2022-01-16 19:40:21 +01:00
|
|
|
World::Quest preQ = quest;
|
2022-01-14 12:51:37 +01:00
|
|
|
script->onEmote( quest, actor, emoteId, player );
|
2022-01-16 19:40:21 +01:00
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
2021-11-27 00:53:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
|
|
|
if( !script )
|
|
|
|
return false;
|
2022-01-14 12:51:37 +01:00
|
|
|
script->onEmote( actor, eventId, emoteId, player );
|
2021-11-27 00:53:57 +01:00
|
|
|
}
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2,
|
2018-12-02 02:01:41 +01:00
|
|
|
uint16_t param3 )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2018-11-13 21:34:44 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
script->onEventHandlerTradeReturn( player, eventId, subEvent, param, catalogId );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-12-17 23:13:27 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint64_t targetId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
2018-08-29 21:40:59 +02:00
|
|
|
std::string eventName = "onEventItem";
|
2020-03-01 01:00:57 +11:00
|
|
|
std::string objName = eventMgr.getEventName( eventId );
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Calling: {0}.{1} - {2}", objName, eventName, eventId );
|
2017-12-13 22:19:00 +11:00
|
|
|
|
2022-01-23 23:00:50 +01:00
|
|
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
|
|
|
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( targetId ) );
|
|
|
|
|
2021-12-17 23:13:27 +01:00
|
|
|
auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
|
|
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
|
|
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
2021-12-17 23:13:27 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
auto questId = static_cast< uint16_t >( eventId );
|
|
|
|
if( player.hasQuest( eventId ) )
|
|
|
|
{
|
|
|
|
World::Quest preQ;
|
|
|
|
auto questIdx = player.getQuestIndex( questId );
|
|
|
|
auto& quest = player.getQuestByIndex( questIdx );
|
|
|
|
preQ = quest;
|
2022-01-23 23:00:50 +01:00
|
|
|
script->onEventItem( quest, player, actor );
|
2021-12-17 23:13:27 +01:00
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-12-13 22:19:00 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-12-22 00:40:11 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onBNpcKill( Entity::Player& player, uint16_t nameId, uint32_t layoutId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2019-02-02 23:32:36 +11:00
|
|
|
// loop through all active quests and try to call available onBNpcKill callbacks
|
2018-08-29 21:40:59 +02:00
|
|
|
for( size_t i = 0; i < 30; i++ )
|
|
|
|
{
|
2022-01-13 21:00:47 +01:00
|
|
|
auto quest = player.getQuestByIndex( static_cast< uint16_t >( i ) );
|
2021-11-27 00:53:57 +01:00
|
|
|
if( quest.getId() == 0 )
|
2018-08-29 21:40:59 +02:00
|
|
|
continue;
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
uint32_t questId = quest.getId() | Event::EventHandler::EventHandlerType::Quest << 16;
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2021-12-21 12:02:22 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( questId );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
2020-03-01 01:00:57 +11:00
|
|
|
std::string objName = eventMgr.getEventName( questId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Calling: {0}.onBnpcKill nameId#{1}", objName, nameId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2021-12-21 12:02:22 +01:00
|
|
|
|
|
|
|
World::Quest preQ = quest;
|
2021-12-22 00:40:11 +01:00
|
|
|
script->onBNpcKill( quest, nameId, layoutId, player );
|
2021-12-21 12:02:22 +01:00
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2019-03-19 00:01:34 +11:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId )
|
2019-02-10 22:13:47 +11:00
|
|
|
{
|
2020-03-01 01:00:57 +11:00
|
|
|
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
2019-02-11 00:40:00 +11:00
|
|
|
bool didCallScript = false;
|
2019-02-10 22:13:47 +11:00
|
|
|
|
2022-01-23 23:00:50 +01:00
|
|
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
|
|
|
auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) );
|
|
|
|
|
2019-02-10 22:13:47 +11:00
|
|
|
for( size_t i = 0; i < 30; i++ )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto quest = player.getQuestByIndex( static_cast< uint16_t >( i ));
|
|
|
|
if( quest.getId() == 0 )
|
2019-02-10 22:13:47 +11:00
|
|
|
continue;
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
uint32_t questId = quest.getId() | Event::EventHandler::EventHandlerType::Quest << 16;
|
2019-02-10 22:13:47 +11:00
|
|
|
|
2022-01-13 21:00:47 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( questId );
|
2019-02-10 22:13:47 +11:00
|
|
|
if( script )
|
|
|
|
{
|
2019-02-11 00:40:00 +11:00
|
|
|
didCallScript = true;
|
2020-03-01 01:00:57 +11:00
|
|
|
std::string objName = eventMgr.getEventName( questId );
|
2019-02-10 22:13:47 +11:00
|
|
|
|
2022-01-23 23:00:50 +01:00
|
|
|
PlayerMgr::sendDebug( player, "Calling: {0}.onEObjHit actorId#{1}, questId#{2}", objName, actor, quest.getId() );
|
2019-02-10 22:13:47 +11:00
|
|
|
|
2022-01-13 21:00:47 +01:00
|
|
|
World::Quest preQ = quest;
|
2022-01-23 23:00:50 +01:00
|
|
|
script->onEObjHit( quest, player, actor, actionId );
|
2022-01-13 21:00:47 +01:00
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
2019-02-10 22:13:47 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-11 00:40:00 +11:00
|
|
|
return didCallScript;
|
2019-02-10 22:13:47 +11:00
|
|
|
}
|
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onExecute( World::Action::Action& action )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2019-03-07 21:58:12 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( action.getId() );
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
2019-02-11 00:40:00 +11:00
|
|
|
{
|
2019-03-07 21:58:12 +11:00
|
|
|
script->onExecute( action );
|
2019-02-11 00:40:00 +11:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2019-02-10 23:28:15 +11:00
|
|
|
}
|
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInterrupt( World::Action::Action& action )
|
2019-02-10 23:28:15 +11:00
|
|
|
{
|
2019-03-07 21:58:12 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( action.getId() );
|
2019-02-10 23:28:15 +11:00
|
|
|
|
|
|
|
if( script )
|
2019-02-11 00:40:00 +11:00
|
|
|
{
|
2019-03-07 21:58:12 +11:00
|
|
|
script->onInterrupt( action );
|
2019-02-11 00:40:00 +11:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2019-02-10 23:28:15 +11:00
|
|
|
}
|
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onStart( World::Action::Action& action )
|
2019-02-10 23:28:15 +11:00
|
|
|
{
|
2019-03-07 21:58:12 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ActionScript >( action.getId() );
|
2019-02-10 23:28:15 +11:00
|
|
|
|
|
|
|
if( script )
|
2019-02-11 00:40:00 +11:00
|
|
|
{
|
2019-03-07 21:58:12 +11:00
|
|
|
script->onStart( action );
|
2019-02-11 00:40:00 +11:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onStatusReceive( Entity::CharaPtr pActor, uint32_t effectId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2018-11-13 21:34:44 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::StatusEffectScript >( effectId );
|
2018-01-04 16:14:14 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
if( pActor->isPlayer() )
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( *pActor->getAsPlayer(), "Calling status receive for statusid#{0}", effectId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
script->onApply( *pActor );
|
|
|
|
return true;
|
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onStatusTick( Entity::CharaPtr pChara, Sapphire::StatusEffect::StatusEffect& effect )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2018-11-13 21:34:44 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::StatusEffectScript >( effect.getId() );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
if( pChara->isPlayer() )
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( *pChara->getAsPlayer(), "Calling status tick for statusid#{0}", effect.getId() );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
script->onTick( *pChara );
|
|
|
|
return true;
|
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onStatusTimeOut( Entity::CharaPtr pChara, uint32_t effectId )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2018-11-13 21:34:44 +11:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::StatusEffectScript >( effectId );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
if( pChara->isPlayer() )
|
2021-11-27 00:53:57 +01:00
|
|
|
PlayerMgr::sendDebug( *pChara->getAsPlayer(), "Calling status timeout for statusid#{0}", effectId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
script->onExpire( *pChara );
|
|
|
|
return true;
|
|
|
|
}
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onZoneInit( const Territory& zone )
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::ZoneScript >( zone.getTerritoryTypeId() );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
script->onZoneInit();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2017-08-18 17:29:36 +02:00
|
|
|
}
|
2017-12-12 01:45:24 +11:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInstanceInit( InstanceContent& instance )
|
2018-02-09 02:34:43 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance.getDirectorId() );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onInit( instance );
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-02-09 02:34:43 +11:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInstanceUpdate( InstanceContent& instance, uint64_t tickCount )
|
2018-02-09 02:34:43 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance.getDirectorId() );
|
2018-03-06 00:10:36 +01:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onUpdate( instance, tickCount );
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
|
|
|
}
|
2018-02-09 02:34:43 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
return false;
|
2018-02-09 02:34:43 +11:00
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInstanceEnterTerritory( InstanceContent& instance, Entity::Player& player,
|
2018-12-02 02:01:41 +01:00
|
|
|
uint32_t eventId, uint16_t param1, uint16_t param2 )
|
2018-03-05 22:10:14 +11:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::InstanceContentScript >( instance.getDirectorId() );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onEnterTerritory( instance, player, eventId, param1, param2 );
|
2018-08-29 21:40:59 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-03-05 22:10:14 +11:00
|
|
|
}
|
|
|
|
|
2019-04-02 00:00:58 +02:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onPlayerSetup( QuestBattle& instance, Entity::Player& player )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance.getDirectorId() );
|
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
script->onPlayerSetup( instance, player );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInstanceInit( QuestBattle& instance )
|
2019-03-31 11:27:11 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance.getDirectorId() );
|
2019-03-31 11:27:11 +02:00
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onInit( instance );
|
2019-03-31 11:27:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInstanceUpdate( QuestBattle& instance, uint64_t tickCount )
|
2019-03-31 11:27:11 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance.getDirectorId() );
|
2019-03-31 11:27:11 +02:00
|
|
|
|
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onUpdate( instance, tickCount );
|
2019-03-31 11:27:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-17 00:10:32 +02:00
|
|
|
|
|
|
|
bool Sapphire::Scripting::ScriptMgr::onDutyCommence( QuestBattle& instance, Entity::Player& player )
|
|
|
|
{
|
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance.getDirectorId() );
|
|
|
|
|
|
|
|
if( script )
|
|
|
|
{
|
|
|
|
script->onDutyCommence( instance, player );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool Sapphire::Scripting::ScriptMgr::onInstanceEnterTerritory( QuestBattle& instance, Entity::Player& player,
|
2019-03-31 11:27:11 +02:00
|
|
|
uint32_t eventId, uint16_t param1, uint16_t param2 )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance.getDirectorId() );
|
2019-03-31 11:27:11 +02:00
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
script->onEnterTerritory( instance, player, eventId, param1, param2 );
|
2019-03-31 11:27:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Scripting::NativeScriptMgr& Sapphire::Scripting::ScriptMgr::getNativeScriptHandler()
|
2017-12-12 01:45:24 +11:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
return *m_nativeScriptMgr;
|
2017-12-12 01:45:24 +11:00
|
|
|
}
|
2019-04-07 13:27:56 +02:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool
|
|
|
|
Sapphire::Scripting::ScriptMgr::onDutyComplete( QuestBattle& instance, Sapphire::Entity::Player& player )
|
2019-04-07 13:27:56 +02:00
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance.getDirectorId() );
|
2021-08-16 17:18:29 +09:00
|
|
|
if( script )
|
|
|
|
{
|
2021-11-27 00:53:57 +01:00
|
|
|
World::Quest preQ;
|
|
|
|
auto questIdx = player.getQuestIndex( instance.getQuestId() );
|
|
|
|
auto& quest = player.getQuestByIndex( questIdx );
|
|
|
|
preQ = quest;
|
|
|
|
script->onDutyComplete( instance, player );
|
|
|
|
if( quest != preQ )
|
|
|
|
player.updateQuest( quest );
|
2021-08-16 17:18:29 +09:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|