mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 15:47:46 +00:00
oh my god it finally fucking builds without issue
This commit is contained in:
parent
d0dc716b2d
commit
bb7ea6740d
10 changed files with 472 additions and 537 deletions
|
@ -1,16 +0,0 @@
|
||||||
#include <chaiscript/chaiscript_stdlib.hpp>
|
|
||||||
#include <chaiscript/chaiscript.hpp>
|
|
||||||
#include "ChaiscriptStdLib.h"
|
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
|
|
||||||
std::shared_ptr< chaiscript::Module > Core::Scripting::create_chaiscript_stdlib()
|
|
||||||
{
|
|
||||||
return chaiscript::Std_Lib::library();
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr< chaiscript::ChaiScript > Core::Scripting::create_chaiscript()
|
|
||||||
{
|
|
||||||
auto chai = boost::make_shared< chaiscript::ChaiScript >();
|
|
||||||
//create_chaiscript_bindings( chai );
|
|
||||||
return chai;
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef CHAISCRIPT_STDLIB
|
|
||||||
#define CHAISCRIPT_STDLIB
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
namespace chaiscript
|
|
||||||
{
|
|
||||||
class Module;
|
|
||||||
class ChaiScript;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core { namespace Scripting {
|
|
||||||
|
|
||||||
std::shared_ptr<chaiscript::Module> create_chaiscript_stdlib();
|
|
||||||
boost::shared_ptr< chaiscript::ChaiScript > create_chaiscript();
|
|
||||||
|
|
||||||
} }
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -70,6 +70,7 @@ namespace Core
|
||||||
|
|
||||||
namespace Scripting
|
namespace Scripting
|
||||||
{
|
{
|
||||||
|
class NativeScript;
|
||||||
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
|
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
63
src/servers/Server_Zone/Script/NativeScript.cpp
Normal file
63
src/servers/Server_Zone/Script/NativeScript.cpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#include "NativeScript.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
namespace Scripting {
|
||||||
|
|
||||||
|
NativeScript::NativeScript( )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
StatusEffectScript* NativeScript::getStatusEffectScript( uint32_t statusId )
|
||||||
|
{
|
||||||
|
return m_statusEffectScripts.at( statusId );
|
||||||
|
}
|
||||||
|
|
||||||
|
AbilityScript* NativeScript::getAbilityScript( uint32_t abilityId )
|
||||||
|
{
|
||||||
|
return m_abilityScripts.at( abilityId );
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestScript* NativeScript::getQuestScript( uint32_t questId )
|
||||||
|
{
|
||||||
|
return m_questScripts.at( questId );
|
||||||
|
}
|
||||||
|
|
||||||
|
BattleNpcScript* NativeScript::getBattleNpcScript( uint32_t npcId )
|
||||||
|
{
|
||||||
|
return m_battleNpcScripts.at( npcId );
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneScript* NativeScript::getZoneScript( uint32_t zoneId )
|
||||||
|
{
|
||||||
|
return m_zoneScripts.at( zoneId );
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeScript::removeStatusEffectScript( uint32_t statusId )
|
||||||
|
{
|
||||||
|
m_statusEffectScripts.erase( statusId );
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeScript::removeAbilityScript( uint32_t abilityId )
|
||||||
|
{
|
||||||
|
m_abilityScripts.erase( abilityId );
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeScript::removeQuestScript( uint32_t questId )
|
||||||
|
{
|
||||||
|
m_questScripts.erase( questId );
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeScript::removeBattleNpcScript( uint32_t npcId )
|
||||||
|
{
|
||||||
|
m_battleNpcScripts.erase( npcId );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr< NativeScript > create_script_engine( )
|
||||||
|
{
|
||||||
|
return boost::make_shared< NativeScript >( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
src/servers/Server_Zone/Script/NativeScript.h
Normal file
50
src/servers/Server_Zone/Script/NativeScript.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef NATIVE_SCRIPT_H
|
||||||
|
#define NATIVE_SCRIPT_H
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <Server_Common/Crypt/md5.h>
|
||||||
|
|
||||||
|
#include "NativeScriptApi.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
namespace Scripting {
|
||||||
|
|
||||||
|
class NativeScript
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
std::unordered_map< uint32_t, StatusEffectScript* > m_statusEffectScripts;
|
||||||
|
std::unordered_map< uint32_t, AbilityScript* > m_abilityScripts;
|
||||||
|
std::unordered_map< uint32_t, QuestScript* > m_questScripts;
|
||||||
|
std::unordered_map< uint32_t, BattleNpcScript* > m_battleNpcScripts;
|
||||||
|
std::unordered_map< uint32_t, ZoneScript* > m_zoneScripts;
|
||||||
|
|
||||||
|
public:
|
||||||
|
NativeScript( );
|
||||||
|
|
||||||
|
StatusEffectScript* getStatusEffectScript( uint32_t statusId );
|
||||||
|
AbilityScript* getAbilityScript( uint32_t abilityId );
|
||||||
|
QuestScript* getQuestScript( uint32_t questId );
|
||||||
|
BattleNpcScript* getBattleNpcScript( uint32_t npcId );
|
||||||
|
ZoneScript* getZoneScript( uint32_t zoneId );
|
||||||
|
|
||||||
|
void removeStatusEffectScript( uint32_t statusId );
|
||||||
|
void removeAbilityScript( uint32_t abilityId );
|
||||||
|
void removeQuestScript( uint32_t questId );
|
||||||
|
void removeBattleNpcScript( uint32_t npcId );
|
||||||
|
|
||||||
|
|
||||||
|
void clearAllScripts();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr< NativeScript > create_script_engine( );
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
129
src/servers/Server_Zone/Script/NativeScriptApi.h
Normal file
129
src/servers/Server_Zone/Script/NativeScriptApi.h
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
#ifndef NATIVE_SCRIPT_API
|
||||||
|
#define NATIVE_SCRIPT_API
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <Server_Zone/Actor/Actor.h>
|
||||||
|
#include <Server_Zone/Actor/Player.h>
|
||||||
|
#include <Server_Zone/StatusEffect/StatusEffect.h>
|
||||||
|
|
||||||
|
#define EXPORT_SCRIPTOBJECT( type, base ) \
|
||||||
|
extern "C" __declspec( dllexport ) __cdecl base* get##base() \
|
||||||
|
{ return static_cast< base* >( new type ); }
|
||||||
|
|
||||||
|
#define EXPORT_STATUSEFFECTSCRIPT( type ) EXPORT_SCRIPTOBJECT( type, StatusEffectScript )
|
||||||
|
#define EXPORT_ABILITYSCRIPT( type ) EXPORT_SCRIPTOBJECT( type, AbilityScript )
|
||||||
|
#define EXPORT_QUESTSCRIPT( type ) EXPORT_SCRIPTOBJECT( type, QuestScript )
|
||||||
|
#define EXPORT_BATTLENPCSCRIPT( type ) EXPORT_SCRIPTOBJECT( type, BattleNpcScript )
|
||||||
|
#define EXPORT_ZONESCRIPT( type ) EXPORT_SCRIPTOBJECT( type, ZoneScript )
|
||||||
|
|
||||||
|
class ScriptObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
const std::string m_scriptName;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ScriptObject( std::string name ) :
|
||||||
|
m_scriptName( name )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
std::string getName() const
|
||||||
|
{
|
||||||
|
return m_scriptName;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void onScriptUnload( ) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class StatusEffectScript : ScriptObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
const uint32_t m_effectId;
|
||||||
|
const uint32_t m_baseDuration;
|
||||||
|
public:
|
||||||
|
StatusEffectScript( std::string name, uint32_t effectId, uint32_t duration ) :
|
||||||
|
ScriptObject( name ),
|
||||||
|
m_effectId( effectId ),
|
||||||
|
m_baseDuration( duration )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
uint32_t getEffectId( ) const
|
||||||
|
{
|
||||||
|
return m_effectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getBaseDuration( ) const
|
||||||
|
{
|
||||||
|
return m_baseDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Core::StatusEffect::StatusEffect applyEffect( Core::Entity::Actor sourceActor, Core::Entity::Actor targetActor ) { }
|
||||||
|
virtual void onTick(Core::Entity::ActorPtr actor) { }
|
||||||
|
virtual void onApply(Core::Entity::ActorPtr actor) { }
|
||||||
|
virtual void onRemove( Core::Entity::Actor actor ) { }
|
||||||
|
virtual void onExpire(Core::Entity::ActorPtr actor) { }
|
||||||
|
virtual void onPlayerCollision( Core::Entity::Actor actor, Core::Entity::Actor actorHit ) { }
|
||||||
|
virtual void onPlayerFinishCast( Core::Entity::Actor actor ) { }
|
||||||
|
virtual void onPlayerDamaged( Core::Entity::Actor actor ) { }
|
||||||
|
virtual bool onPlayerDeath( Core::Entity::Actor actor ) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class AbilityScript : ScriptObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
uint32_t m_abilityId;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AbilityScript( std::string name, uint32_t abilityId ) :
|
||||||
|
ScriptObject( name ),
|
||||||
|
m_abilityId( abilityId )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
uint32_t GetAbilityId( )
|
||||||
|
{
|
||||||
|
return m_abilityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void onStart( Core::Entity::Actor sourceActor, Core::Entity::Actor targetActor ) { }
|
||||||
|
virtual bool onCastFinish(Core::Entity::Player player, Core::Entity::ActorPtr targetActor) { }
|
||||||
|
virtual void onInterrupt( Core::Entity::Actor sourceActor/*, Core::Entity::Actor targetActor*/ ) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class QuestScript : ScriptObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
uint32_t QuestId;
|
||||||
|
public:
|
||||||
|
QuestScript( std::string name, uint32_t questId ) :
|
||||||
|
ScriptObject( name ),
|
||||||
|
QuestId( questId )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void onTalk(uint32_t eventId, Core::Entity::Player player, uint64_t actorId) { }
|
||||||
|
virtual void onNpcKill( uint32_t npcId, Core::Entity::Player player ) { }
|
||||||
|
virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Core::Entity::Player player ) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BattleNpcScript : ScriptObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BattleNpcScript( std::string name ) :
|
||||||
|
ScriptObject( name )
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
class ZoneScript : ScriptObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ZoneScript( std::string name ) :
|
||||||
|
ScriptObject( name )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void onZoneInit() { }
|
||||||
|
virtual void onEnterZone( Core::Entity::Player pPlayer, uint32_t eventId, uint16_t param1, uint16_t param2 ) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,7 +2,7 @@
|
||||||
#include <Server_Common/Exd/ExdData.h>
|
#include <Server_Common/Exd/ExdData.h>
|
||||||
#include <chaiscript/chaiscript.hpp>
|
#include <chaiscript/chaiscript.hpp>
|
||||||
|
|
||||||
#include <Server_Common/Script/ChaiscriptStdLib.h>
|
#include "NativeScript.h"
|
||||||
|
|
||||||
#include "Zone/Zone.h"
|
#include "Zone/Zone.h"
|
||||||
#include "Actor/Player.h"
|
#include "Actor/Player.h"
|
||||||
|
@ -26,7 +26,7 @@ extern Core::ServerZone g_serverZone;
|
||||||
|
|
||||||
Core::Scripting::ScriptManager::ScriptManager()
|
Core::Scripting::ScriptManager::ScriptManager()
|
||||||
{
|
{
|
||||||
m_pChaiHandler = create_chaiscript();
|
m_nativeScriptHandler = create_script_engine();
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Scripting::ScriptManager::~ScriptManager()
|
Core::Scripting::ScriptManager::~ScriptManager()
|
||||||
|
@ -57,15 +57,15 @@ void Core::Scripting::ScriptManager::loadDir( std::string dirname, std::set<std:
|
||||||
|
|
||||||
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
|
void Core::Scripting::ScriptManager::onPlayerFirstEnterWorld( Entity::Player& player )
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
std::string test = m_onFirstEnterWorld( player );
|
// std::string test = m_onFirstEnterWorld( player );
|
||||||
}
|
// }
|
||||||
catch( const std::exception &e )
|
// catch( const std::exception &e )
|
||||||
{
|
// {
|
||||||
std::string what = e.what();
|
// std::string what = e.what();
|
||||||
g_log.Log( LoggingSeverity::error, what );
|
// g_log.Log( LoggingSeverity::error, what );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
bool Core::Scripting::ScriptManager::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
||||||
|
@ -76,17 +76,11 @@ bool Core::Scripting::ScriptManager::registerBnpcTemplate( std::string templateN
|
||||||
|
|
||||||
void Core::Scripting::ScriptManager::reload()
|
void Core::Scripting::ScriptManager::reload()
|
||||||
{
|
{
|
||||||
auto handler = create_chaiscript();
|
// auto handler = create_chaiscript();
|
||||||
m_pChaiHandler.swap( handler );
|
// m_pChaiHandler.swap( handler );
|
||||||
init();
|
// init();
|
||||||
}
|
}
|
||||||
|
|
||||||
const boost::shared_ptr< chaiscript::ChaiScript >& Core::Scripting::ScriptManager::getHandler() const
|
|
||||||
{
|
|
||||||
return m_pChaiHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
|
bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onTalk";
|
std::string eventName = "onTalk";
|
||||||
|
@ -102,23 +96,138 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac
|
||||||
|
|
||||||
uint16_t eventType = eventId >> 16;
|
uint16_t eventType = eventId >> 16;
|
||||||
|
|
||||||
try
|
auto script = m_nativeScriptHandler->getQuestScript( eventId );
|
||||||
|
if( script )
|
||||||
{
|
{
|
||||||
// Get object from engine
|
|
||||||
auto obj = m_pChaiHandler->eval( objName );
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
|
||||||
player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 );
|
player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 );
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &,
|
script->onTalk( eventId, player, actorId );
|
||||||
uint32_t, Entity::Player&, uint64_t ) > >( eventName );
|
|
||||||
fn( obj, eventId, player, actorId );
|
|
||||||
|
|
||||||
player.checkEvent( eventId );
|
player.checkEvent( eventId );
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
else
|
||||||
{
|
{
|
||||||
player.sendDebug( e.what( ) );
|
if ( eventType == Common::EventType::Quest )
|
||||||
|
{
|
||||||
|
auto questInfo = g_exdData.getQuestInfo( eventId );
|
||||||
|
if ( questInfo )
|
||||||
|
{
|
||||||
|
player.sendUrgent( "Quest not implemented: " + questInfo->name );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, uint32_t eventId,
|
||||||
|
uint16_t param1, uint16_t param2 )
|
||||||
|
{
|
||||||
|
std::string eventName = "onEnterTerritory";
|
||||||
|
std::string objName = Event::getEventName( eventId );
|
||||||
|
|
||||||
|
auto script = m_nativeScriptHandler->getZoneScript( player.getZoneId() );
|
||||||
|
if( script )
|
||||||
|
{
|
||||||
|
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
|
||||||
|
player.eventStart( player.getId(), eventId, Event::Event::EnterTerritory, 0, player.getZoneId() );
|
||||||
|
|
||||||
|
script->onEnterZone( player, eventId, param1, param2 );
|
||||||
|
|
||||||
|
player.checkEvent( eventId );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||||
|
float x, float y, float z )
|
||||||
|
{
|
||||||
|
// std::string eventName = "onWithinRange";
|
||||||
|
// std::string objName = Event::getEventName( eventId );
|
||||||
|
//
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// // Get object from engine
|
||||||
|
// auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
||||||
|
//
|
||||||
|
// player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
//
|
||||||
|
// player.eventStart( player.getId(), eventId, Event::Event::WithinRange, 1, param1 );
|
||||||
|
//
|
||||||
|
// auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
|
||||||
|
// float, float, float ) > >( eventName );
|
||||||
|
// fn( obj, eventId, player, param1, x, y, z );
|
||||||
|
//
|
||||||
|
// player.checkEvent( eventId );
|
||||||
|
// }
|
||||||
|
// catch( std::exception& e )
|
||||||
|
// {
|
||||||
|
// player.sendDebug( e.what() );
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
||||||
|
float x, float y, float z )
|
||||||
|
{
|
||||||
|
// std::string eventName = "onOutsideRange";
|
||||||
|
// std::string objName = Event::getEventName( eventId );
|
||||||
|
//
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// // Get object from engine
|
||||||
|
// auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
||||||
|
//
|
||||||
|
// player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
//
|
||||||
|
// player.eventStart( player.getId(), eventId, Event::Event::OutsideRange, 1, param1 );
|
||||||
|
//
|
||||||
|
// auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
|
||||||
|
// float, float, float ) > >( eventName );
|
||||||
|
// fn( obj, eventId, player, param1, x, y, z );
|
||||||
|
//
|
||||||
|
// player.checkEvent( eventId );
|
||||||
|
// }
|
||||||
|
// catch( std::exception& e )
|
||||||
|
// {
|
||||||
|
// player.sendDebug( e.what() );
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t actorId,
|
||||||
|
uint32_t eventId, uint8_t emoteId )
|
||||||
|
{
|
||||||
|
std::string eventName = "onEmote";
|
||||||
|
std::string objName = Event::getEventName( eventId );
|
||||||
|
|
||||||
|
auto script = m_nativeScriptHandler->getQuestScript( eventId );
|
||||||
|
if( script )
|
||||||
|
{
|
||||||
|
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
|
||||||
|
player.eventStart( actorId, eventId, Event::Event::Emote, 0, emoteId );
|
||||||
|
|
||||||
|
script->onEmote( actorId, eventId, emoteId, player );
|
||||||
|
|
||||||
|
player.checkEvent( eventId );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint16_t eventType = eventId >> 16;
|
||||||
|
|
||||||
if( eventType == Common::EventType::Quest )
|
if( eventType == Common::EventType::Quest )
|
||||||
{
|
{
|
||||||
|
@ -129,134 +238,9 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, uint32_t eventId,
|
|
||||||
uint16_t param1, uint16_t param2 )
|
|
||||||
{
|
|
||||||
std::string eventName = "onEnterTerritory";
|
|
||||||
std::string objName = Event::getEventName( eventId );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get object from engine
|
|
||||||
auto obj = m_pChaiHandler->eval( objName );
|
|
||||||
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
player.eventStart( player.getId(), eventId, Event::Event::EnterTerritory, 0, player.getZoneId() );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t,
|
|
||||||
Entity::Player&, uint16_t, uint16_t ) > >( eventName );
|
|
||||||
fn( obj, eventId, player, param1, param2 );
|
|
||||||
|
|
||||||
player.checkEvent( eventId );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
player.sendDebug( e.what() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
|
||||||
float x, float y, float z )
|
|
||||||
{
|
|
||||||
std::string eventName = "onWithinRange";
|
|
||||||
std::string objName = Event::getEventName( eventId );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get object from engine
|
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
|
||||||
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
player.eventStart( player.getId(), eventId, Event::Event::WithinRange, 1, param1 );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
|
|
||||||
float, float, float ) > >( eventName );
|
|
||||||
fn( obj, eventId, player, param1, x, y, z );
|
|
||||||
|
|
||||||
player.checkEvent( eventId );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
player.sendDebug( e.what() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1,
|
|
||||||
float x, float y, float z )
|
|
||||||
{
|
|
||||||
std::string eventName = "onOutsideRange";
|
|
||||||
std::string objName = Event::getEventName( eventId );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get object from engine
|
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
|
||||||
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
player.eventStart( player.getId(), eventId, Event::Event::OutsideRange, 1, param1 );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&, uint32_t,
|
|
||||||
float, float, float ) > >( eventName );
|
|
||||||
fn( obj, eventId, player, param1, x, y, z );
|
|
||||||
|
|
||||||
player.checkEvent( eventId );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
player.sendDebug( e.what() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t actorId,
|
|
||||||
uint32_t eventId, uint8_t emoteId )
|
|
||||||
{
|
|
||||||
std::string eventName = "onEmote";
|
|
||||||
std::string objName = Event::getEventName( eventId );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
|
||||||
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
player.eventStart( actorId, eventId, Event::Event::Emote, 0, emoteId );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
|
|
||||||
uint64_t, uint8_t ) > >( eventName );
|
|
||||||
fn( obj, eventId, player, actorId, emoteId );
|
|
||||||
|
|
||||||
player.checkEvent( eventId );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
uint16_t eventType = eventId >> 16;
|
|
||||||
|
|
||||||
if( eventType == Common::EventType::Quest )
|
|
||||||
{
|
|
||||||
auto questInfo = g_exdData.getQuestInfo( eventId );
|
|
||||||
if( questInfo )
|
|
||||||
{
|
|
||||||
player.sendDebug( "Quest not implemented: " + questInfo->name + "\n" + e.what() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,50 +291,52 @@ bool Core::Scripting::ScriptManager::onEventHandlerReturn( Entity::Player& playe
|
||||||
bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId,
|
bool Core::Scripting::ScriptManager::onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId,
|
||||||
uint16_t subEvent, uint16_t param, uint32_t catalogId )
|
uint16_t subEvent, uint16_t param, uint32_t catalogId )
|
||||||
{
|
{
|
||||||
std::string eventName = Event::getEventName( eventId ) + "_TRADE";
|
// std::string eventName = Event::getEventName( eventId ) + "_TRADE";
|
||||||
|
//
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// auto fn = m_pChaiHandler->eval< std::function< void( Entity::Player&, uint32_t,
|
||||||
|
// uint16_t, uint16_t, uint32_t ) > >( eventName );
|
||||||
|
// fn( player, eventId, subEvent, param, catalogId );
|
||||||
|
// }
|
||||||
|
// catch( ... )
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return true;
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( Entity::Player&, uint32_t,
|
|
||||||
uint16_t, uint16_t, uint32_t ) > >( eventName );
|
|
||||||
fn( player, eventId, subEvent, param, catalogId );
|
|
||||||
}
|
|
||||||
catch( ... )
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32_t eventItemId,
|
bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32_t eventItemId,
|
||||||
uint32_t eventId, uint32_t castTime, uint64_t targetId )
|
uint32_t eventId, uint32_t castTime, uint64_t targetId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onEventItem";
|
// std::string eventName = "onEventItem";
|
||||||
std::string objName = Event::getEventName( eventId );
|
// std::string objName = Event::getEventName( eventId );
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
// auto obj = m_pChaiHandler->eval( Event::getEventName( eventId ) );
|
||||||
|
//
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
// player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||||
|
//
|
||||||
player.eventStart( targetId, eventId, Event::Event::Item, 0, 0 );
|
// player.eventStart( targetId, eventId, Event::Event::Item, 0, 0 );
|
||||||
|
//
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
|
// auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, uint32_t, Entity::Player&,
|
||||||
uint32_t, uint32_t, uint64_t ) > >( eventName );
|
// uint32_t, uint32_t, uint64_t ) > >( eventName );
|
||||||
fn( obj, eventId, player, eventItemId, castTime, targetId );
|
// fn( obj, eventId, player, eventItemId, castTime, targetId );
|
||||||
}
|
// }
|
||||||
catch( std::exception& e )
|
// catch( std::exception& e )
|
||||||
{
|
// {
|
||||||
player.sendNotice( e.what() );
|
// player.sendNotice( e.what() );
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t nameId )
|
bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t nameId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onBnpcKill_" + std::to_string( nameId );
|
std::string eventName = "onBnpcKill_" + std::to_string( nameId );
|
||||||
|
@ -364,23 +350,15 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint16_t questId = activeQuests->c.questId;
|
uint16_t questId = activeQuests->c.questId;
|
||||||
if( questId != 0 )
|
|
||||||
|
auto script = m_nativeScriptHandler->getQuestScript( questId );
|
||||||
|
if( script )
|
||||||
{
|
{
|
||||||
auto obj = m_pChaiHandler->eval( Event::getEventName( 0x00010000 | questId ) );
|
|
||||||
std::string objName = Event::getEventName( 0x00010000 | questId );
|
std::string objName = Event::getEventName( 0x00010000 | questId );
|
||||||
|
|
||||||
player.sendDebug("Calling: " + objName + "." + eventName);
|
player.sendDebug("Calling: " + objName + "." + eventName);
|
||||||
|
|
||||||
try
|
script->onNpcKill( nameId, player );
|
||||||
{
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player& ) > >(eventName);
|
|
||||||
fn( obj, player );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
g_log.info( e.what() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,115 +367,71 @@ bool Core::Scripting::ScriptManager::onMobKill( Entity::Player& player, uint16_t
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
|
bool Core::Scripting::ScriptManager::onCastFinish( Entity::Player& player, Entity::ActorPtr pTarget, uint32_t actionId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onFinish";
|
auto script = m_nativeScriptHandler->getAbilityScript( actionId );
|
||||||
|
|
||||||
try
|
if( script )
|
||||||
{
|
script->onCastFinish( player, pTarget );
|
||||||
auto obj = m_pChaiHandler->eval( "skillDef_" + std::to_string( actionId ) );
|
|
||||||
std::string objName = "skillDef_" + std::to_string( actionId );
|
|
||||||
|
|
||||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Player&,
|
|
||||||
Entity::Actor& ) > >( eventName );
|
|
||||||
fn( obj, player, *pTarget );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
player.sendUrgent( e.what() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
bool Core::Scripting::ScriptManager::onStatusReceive( Entity::ActorPtr pActor, uint32_t effectId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onReceive";
|
auto script = m_nativeScriptHandler->getStatusEffectScript( effectId );
|
||||||
|
if( script )
|
||||||
try
|
|
||||||
{
|
|
||||||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
|
||||||
std::string objName = "statusDef_" + std::to_string( effectId );
|
|
||||||
|
|
||||||
if( pActor->isPlayer() )
|
|
||||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&) > >( eventName );
|
|
||||||
fn( obj, *pActor );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
{
|
||||||
if( pActor->isPlayer() )
|
if( pActor->isPlayer() )
|
||||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
pActor->getAsPlayer()->sendDebug( "Calling status recieve for statusid: " + effectId );
|
||||||
}
|
|
||||||
|
script->onApply( pActor );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect )
|
bool Core::Scripting::ScriptManager::onStatusTick( Entity::ActorPtr pActor, Core::StatusEffect::StatusEffect& effect )
|
||||||
{
|
{
|
||||||
std::string eventName = "onTick";
|
auto script = m_nativeScriptHandler->getStatusEffectScript( effect.getId() );
|
||||||
|
if( script )
|
||||||
try
|
|
||||||
{
|
|
||||||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effect.getId() ) );
|
|
||||||
std::string objName = "statusDef_" + std::to_string( effect.getId() );
|
|
||||||
|
|
||||||
if( pActor->isPlayer() )
|
|
||||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor&,
|
|
||||||
StatusEffect::StatusEffect& ) > >( eventName );
|
|
||||||
fn( obj, *pActor, effect );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
{
|
||||||
if( pActor->isPlayer() )
|
if( pActor->isPlayer() )
|
||||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
pActor->getAsPlayer()->sendDebug( "Calling status tick for statusid: " + effect.getId() );
|
||||||
}
|
|
||||||
|
script->onTick( pActor );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId )
|
bool Core::Scripting::ScriptManager::onStatusTimeOut( Entity::ActorPtr pActor, uint32_t effectId )
|
||||||
{
|
{
|
||||||
std::string eventName = "onTimeOut";
|
auto script = m_nativeScriptHandler->getStatusEffectScript( effectId );
|
||||||
|
if( script )
|
||||||
try
|
|
||||||
{
|
|
||||||
auto obj = m_pChaiHandler->eval( "statusDef_" + std::to_string( effectId ) );
|
|
||||||
std::string objName = "statusDef_" + std::to_string( effectId );
|
|
||||||
|
|
||||||
if( pActor->isPlayer() )
|
|
||||||
pActor->getAsPlayer()->sendDebug( "Calling: " + objName + "." + eventName );
|
|
||||||
|
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( chaiscript::Boxed_Value &, Entity::Actor& ) > >( eventName );
|
|
||||||
fn( obj, *pActor );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
{
|
||||||
if( pActor->isPlayer() )
|
if( pActor->isPlayer() )
|
||||||
pActor->getAsPlayer()->sendUrgent( e.what() );
|
pActor->getAsPlayer()->sendDebug( "Calling status tick for statusid: " + effectId );
|
||||||
}
|
|
||||||
|
script->onExpire( pActor );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
bool Core::Scripting::ScriptManager::onZoneInit( ZonePtr pZone )
|
||||||
{
|
{
|
||||||
std::string eventName = "onZoneInit_" + pZone->getInternalName();
|
auto script = m_nativeScriptHandler->getZoneScript( pZone->getId() );
|
||||||
|
if( script )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
auto fn = m_pChaiHandler->eval< std::function< void( Zone& ) > >( eventName );
|
script->onZoneInit();
|
||||||
fn( *pZone );
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
g_log.info( e.what() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Core
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr< chaiscript::ChaiScript > m_pChaiHandler;
|
boost::shared_ptr< NativeScript > m_nativeScriptHandler;
|
||||||
|
|
||||||
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
|
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
|
||||||
// auto fn = m_pChaiHandler->eval< std::function<const std::string( Entity::Player ) > >( "onFirstEnterWorld" );
|
// auto fn = m_pChaiHandler->eval< std::function<const std::string( Entity::Player ) > >( "onFirstEnterWorld" );
|
||||||
|
|
|
@ -1,207 +0,0 @@
|
||||||
#include <chaiscript/chaiscript.hpp>
|
|
||||||
|
|
||||||
#include <Server_Common/Config/XMLConfig.h>
|
|
||||||
#include <Server_Common/Logging/Logger.h>
|
|
||||||
#include <Server_Common/Script/ChaiscriptStdLib.h>
|
|
||||||
|
|
||||||
#include "ServerZone.h"
|
|
||||||
|
|
||||||
#include "Script/ScriptManager.h"
|
|
||||||
|
|
||||||
#include "Zone/Zone.h"
|
|
||||||
#include "Actor/Player.h"
|
|
||||||
#include "Actor/BattleNpc.h"
|
|
||||||
#include "Event/Event.h"
|
|
||||||
#include "Event/EventHelper.h"
|
|
||||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
||||||
#include "StatusEffect/StatusEffect.h"
|
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
extern Core::Logger g_log;
|
|
||||||
extern Core::ServerZone g_serverZone;
|
|
||||||
|
|
||||||
int Core::Scripting::ScriptManager::init()
|
|
||||||
{
|
|
||||||
// ACTOR / PLAYER BINDINGS
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getName ), "getName" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getId ), "getId" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getHp ), "getHp" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getMp ), "getMp" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTp ), "getTp" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getLevel ), "getLevel" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::getTargetId ), "getTargetId" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffect ), "addStatusEffect" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectById ), "addStatusEffectById" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::addStatusEffectByIdIfNotExist ), "addStatusEffectByIdIfNotExist" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Actor::takeDamage ), "takeDamage" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::forceZoneing ), "setZone" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getClassAsInt ), "getClass" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getRace ), "getRace" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getGender ), "getGender" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::gainExp ), "gainExp" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::unlock ), "unlock" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::registerAetheryte ), "aetheryteRegister" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::learnAction ), "learnAction" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getHomepoint ), "getHomepoint" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setHomepoint ), "setHomepoint" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::returnToHomepoint ), "returnToHomepoint" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::teleport ), "teleport" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::prepareZoning ), "prepareZoning" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::isInCombat ), "isInCombat" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getCurrency ), "getCurrency" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::addCurrency ), "addCurrency" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::removeCurrency ), "removeCurrency" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getCrystal ), "getCrystals" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::addCrystal ), "addCrystals" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::removeCrystal ), "removeCrystals" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::updateQuest ), "questUpdate" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::finishQuest ), "questFinish" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::sendQuestMessage ), "questMessage" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestSeq ), "questGetSeq" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::hasQuest ), "hasQuest" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getZoneId ), "getZoneId" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::handleScriptSkill ), "handleScriptSkill" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getOpeningSequence ), "getOpeningSequence" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setOpeningSequence ), "setOpeningSequence" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Core::Event::mapEventActorToRealActor ), "mapActor" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8A ), "getQuestUI8A" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8B ), "getQuestUI8B" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8C ), "getQuestUI8C" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8D ), "getQuestUI8D" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8E ), "getQuestUI8E" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8F ), "getQuestUI8F" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8AH ), "getQuestUI8AH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8BH ), "getQuestUI8BH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8CH ), "getQuestUI8CH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8DH ), "getQuestUI8DH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8EH ), "getQuestUI8EH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8FH ), "getQuestUI8FH" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8AL ), "getQuestUI8AL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8BL ), "getQuestUI8BL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8CL ), "getQuestUI8CL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8DL ), "getQuestUI8DL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8EL ), "getQuestUI8EL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI8FL ), "getQuestUI8FL" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI16A ), "getQuestUI16A" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI16B ), "getQuestUI16B" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI16C ), "getQuestUI16C" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestUI32A ), "getQuestUI32A" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestBitFlag8 ), "getQuestBitFlag8" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestBitFlag16 ), "getQuestBitFlag16" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestBitFlag24 ), "getQuestBitFlag24" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestBitFlag32 ), "getQuestBitFlag32" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestBitFlag40 ), "getQuestBitFlag40" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::getQuestBitFlag48 ), "getQuestBitFlag48" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8A ), "setQuestUI8A" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8B ), "setQuestUI8B" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8C ), "setQuestUI8C" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8D ), "setQuestUI8D" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8E ), "setQuestUI8E" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8F ), "setQuestUI8F" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8AH ), "setQuestUI8AH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8BH ), "setQuestUI8BH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8CH ), "setQuestUI8CH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8DH ), "setQuestUI8DH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8EH ), "setQuestUI8EH" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8FH ), "setQuestUI8FH" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8AL ), "setQuestUI8AL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8BL ), "setQuestUI8BL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8CL ), "setQuestUI8CL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8DL ), "setQuestUI8DL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8EL ), "setQuestUI8EL" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI8FL ), "setQuestUI8FL" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI16A ), "setQuestUI16A" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI16B ), "setQuestUI16B" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI16C ), "setQuestUI16C" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestUI32A ), "setQuestUI32A" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag8 ), "setQuestBitFlag8" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag16 ), "setQuestBitFlag16" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag24 ), "setQuestBitFlag24" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag32 ), "setQuestBitFlag32" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag40 ), "setQuestBitFlag40" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::setQuestBitFlag48 ), "setQuestBitFlag48" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add(chaiscript::fun(&Entity::Player::giveQuestRewards), "giveQuestRewards");
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ), "eventPlay" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t, EventReturnCallback >( &Entity::Player::eventPlay ), "eventPlay" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun< void, Entity::Player, uint32_t, uint32_t, uint32_t >( &Entity::Player::eventPlay ), "eventPlay" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::eventActionStart ), "eventActionStart" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::eventItemActionStart ), "eventItemActionStart" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::changePosition ), "changePos" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::tryAddItem ), "tryAddItem" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::isAetheryteRegistered ), "isAetheryteRegistered" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Entity::Player::isActionLearned ), "isActionLearned" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::base_class< Entity::Actor, Entity::Player >() );
|
|
||||||
m_pChaiHandler->add( chaiscript::base_class< Entity::Actor, Entity::BattleNpc >() );
|
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Entity::Actor >(), "Actor" );
|
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Entity::Player >(), "Player" );
|
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Entity::BattleNpc >(), "BattleNpc" );
|
|
||||||
m_pChaiHandler->add( chaiscript::user_type< StatusEffect::StatusEffect >(), "StatusEffect" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &StatusEffect::StatusEffect::registerTickEffect ), "registerTickEffect" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::user_type< Zone >(), "Zone" );
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( &Zone::getName ), "getName" );
|
|
||||||
|
|
||||||
m_pChaiHandler->add( chaiscript::fun( ®isterBnpcTemplate ), "registerBnpcTemplate" );
|
|
||||||
|
|
||||||
// EVENT BINDINGS
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
std::set< std::string > chaiFiles;
|
|
||||||
|
|
||||||
loadDir( g_serverZone.getConfig()->getValue< std::string >( "Settings.General.ScriptPath", "../scripts/chai" ), chaiFiles );
|
|
||||||
|
|
||||||
uint16_t scriptCount = 0;
|
|
||||||
uint16_t errorCount = 0;
|
|
||||||
for( auto itr = chaiFiles.begin(); itr != chaiFiles.end(); ++itr )
|
|
||||||
{
|
|
||||||
auto& fileName = *itr;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_pChaiHandler->eval_file( fileName );
|
|
||||||
scriptCount++;
|
|
||||||
}
|
|
||||||
catch( std::exception& e )
|
|
||||||
{
|
|
||||||
g_log.Log( LoggingSeverity::error, e.what() );
|
|
||||||
errorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
g_log.info( "\tloaded " + std::to_string( scriptCount ) +
|
|
||||||
" scripts, " + std::to_string( errorCount ) + " errors." );
|
|
||||||
|
|
||||||
std::function<std::string( Entity::Player& ) > f =
|
|
||||||
m_pChaiHandler->eval< std::function<std::string( Entity::Player& ) > >( "onFirstEnterWorld" );
|
|
||||||
|
|
||||||
m_onFirstEnterWorld = f;
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
|
||||||
g_log.info( "ZoneMgr: Setting up zones" );
|
g_log.info( "ZoneMgr: Setting up zones" );
|
||||||
g_zoneMgr.createZones();
|
g_zoneMgr.createZones();
|
||||||
|
|
||||||
g_scriptMgr.init();
|
// g_scriptMgr.init();
|
||||||
|
|
||||||
std::vector< std::thread > thread_list;
|
std::vector< std::thread > thread_list;
|
||||||
thread_list.emplace_back( std::thread( std::bind( &Network::Hive::Run, hive.get() ) ) );
|
thread_list.emplace_back( std::thread( std::bind( &Network::Hive::Run, hive.get() ) ) );
|
||||||
|
|
Loading…
Add table
Reference in a new issue