1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00

loading works, sprint works

This commit is contained in:
GokuWeedLord 2017-12-11 21:10:54 +11:00
parent f926b03034
commit 388adacf3b
6 changed files with 71 additions and 85 deletions

View file

@ -11,6 +11,19 @@ public:
if( actor->isPlayer() ) if( actor->isPlayer() )
actor->getAsPlayer()->sendDebug( "tick tock bitch" ); actor->getAsPlayer()->sendDebug( "tick tock bitch" );
} }
virtual void onApply( Entity::ActorPtr actor )
{
if( actor->isPlayer() )
actor->getAsPlayer()->sendDebug( "status50 applied" );
}
virtual void onExpire( Entity::ActorPtr actor )
{
if( actor->isPlayer() )
actor->getAsPlayer()->sendDebug( "status50 timed out" );
}
}; };
EXPORT_STATUSEFFECTSCRIPT( Status50 ) EXPORT_STATUSEFFECTSCRIPT( Status50 )

View file

@ -77,25 +77,25 @@ namespace Core {
if( handle ) if( handle )
{ {
// todo: this is shit // todo: this is shit
if( auto script = m_loader.getScriptObject< StatusEffectScript >( handle ) ) if( auto script = m_loader.getScriptObject< StatusEffectScript >( handle, "StatusEffectScript" ) )
{ {
m_statusEffectScripts.insert( std::make_pair( script->getEffectId(), script ) ); m_statusEffectScripts[ script->getId() ] = script;
} }
else if( auto script = m_loader.getScriptObject< ActionScript >( handle ) ) else if( auto script = m_loader.getScriptObject< ActionScript >( handle, "ActionScript" ) )
{ {
m_actionScripts.insert( std::make_pair( script->getActionId(), script ) ); m_actionScripts[ script->getId() ] = script;
} }
else if( auto script = m_loader.getScriptObject< QuestScript >( handle ) ) else if( auto script = m_loader.getScriptObject< QuestScript >( handle, "QuestScript" ) )
{ {
m_questScripts.insert( std::make_pair( script->getQuestId(), script ) ); m_questScripts[ script->getId() ] = script;
} }
else if( auto script = m_loader.getScriptObject< BattleNpcScript >( handle ) ) else if( auto script = m_loader.getScriptObject< BattleNpcScript >( handle, "BattleNpcScript" ) )
{ {
m_battleNpcScripts.insert( std::make_pair( script->getNpcId(), script ) ); m_battleNpcScripts[ script->getId() ] = script;
} }
else if( auto script = m_loader.getScriptObject< ZoneScript >( handle ) ) else if( auto script = m_loader.getScriptObject< ZoneScript >( handle, "ZoneScript" ) )
{ {
m_zoneScripts.insert( std::make_pair( script->getZoneId(), script ) ); m_zoneScripts[ script->getId() ] = script;
} }
else else
{ {

View file

@ -22,129 +22,93 @@ extern "C" EXPORT base* get##base() \
#define EXPORT_BATTLENPCSCRIPT( type ) EXPORT_SCRIPTOBJECT( type, BattleNpcScript ) #define EXPORT_BATTLENPCSCRIPT( type ) EXPORT_SCRIPTOBJECT( type, BattleNpcScript )
#define EXPORT_ZONESCRIPT( type ) EXPORT_SCRIPTOBJECT( type, ZoneScript ) #define EXPORT_ZONESCRIPT( type ) EXPORT_SCRIPTOBJECT( type, ZoneScript )
using namespace Core;
class ScriptObject class ScriptObject
{ {
protected: protected:
const std::string m_scriptName; std::string m_scriptName;
uint32_t m_id;
public: public:
ScriptObject( std::string name ) : ScriptObject( std::string name, uint32_t id ) :
m_scriptName( name ) m_scriptName( name ),
m_id( id )
{ } { }
const std::string getName() virtual const std::string& getName() const
{ {
return m_scriptName; return m_scriptName;
} }
virtual uint32_t getId() const
{
return m_id;
}
}; };
class StatusEffectScript : public ScriptObject class StatusEffectScript : public ScriptObject
{ {
protected:
const uint32_t m_effectId;
public: public:
StatusEffectScript( std::string name, uint32_t effectId ) : StatusEffectScript( std::string name, uint32_t effectId ) :
ScriptObject( name ), ScriptObject( name, effectId )
m_effectId( effectId )
{ } { }
const uint32_t getEffectId( ) virtual void onTick( Entity::ActorPtr actor ) { }
{ virtual void onApply( Entity::ActorPtr actor ) { }
return m_effectId; virtual void onRemove( Entity::ActorPtr actor ) { }
} virtual void onExpire(Entity::ActorPtr actor) { }
virtual void onPlayerCollision( Entity::ActorPtr actor, Entity::ActorPtr actorHit ) { }
virtual void onTick( Core::Entity::ActorPtr actor ) { } virtual void onPlayerFinishCast( Entity::ActorPtr actor ) { }
virtual void onApply( Core::Entity::ActorPtr actor ) { } virtual void onPlayerDamaged( Entity::ActorPtr actor ) { }
virtual void onRemove( Core::Entity::ActorPtr actor ) { } virtual void onPlayerDeath( Entity::ActorPtr actor ) { }
virtual void onExpire(Core::Entity::ActorPtr actor) { }
virtual void onPlayerCollision( Core::Entity::ActorPtr actor, Core::Entity::ActorPtr actorHit ) { }
virtual void onPlayerFinishCast( Core::Entity::ActorPtr actor ) { }
virtual void onPlayerDamaged( Core::Entity::ActorPtr actor ) { }
virtual void onPlayerDeath( Core::Entity::ActorPtr actor ) { }
}; };
class ActionScript : public ScriptObject class ActionScript : public ScriptObject
{ {
protected:
const uint32_t m_actionId;
public: public:
ActionScript( std::string name, uint32_t abilityId ) : ActionScript( std::string name, uint32_t abilityId ) :
ScriptObject( name ), ScriptObject( name, abilityId )
m_actionId( abilityId )
{ } { }
const uint32_t getActionId() virtual void onStart( Entity::Actor sourceActor, Entity::ActorPtr targetActor ) { }
{ virtual void onCastFinish( Entity::Player& player, Entity::ActorPtr targetActor ) { }
return m_actionId; virtual void onInterrupt( Entity::ActorPtr sourceActor/*, Core::Entity::Actor targetActor*/ ) { }
}
virtual void onStart( Core::Entity::Actor sourceActor, Core::Entity::ActorPtr targetActor ) { }
virtual void onCastFinish( Core::Entity::Player player, Core::Entity::ActorPtr targetActor ) { }
virtual void onInterrupt( Core::Entity::Actor sourceActor/*, Core::Entity::Actor targetActor*/ ) { }
}; };
class QuestScript : public ScriptObject class QuestScript : public ScriptObject
{ {
protected:
const uint32_t m_questId;
public: public:
QuestScript( std::string name, uint32_t questId ) : QuestScript( std::string name, uint32_t questId ) :
ScriptObject( name ), ScriptObject( name, questId )
m_questId( questId )
{ } { }
const uint32_t getQuestId() virtual void onTalk(uint32_t eventId, Entity::Player& player, uint64_t actorId) { }
{ virtual void onNpcKill( uint32_t npcId, Entity::Player& player ) { }
return m_questId; virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Entity::Player& player ) { }
}
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 : public ScriptObject class BattleNpcScript : public ScriptObject
{ {
protected:
const uint32_t m_npcId;
public: public:
BattleNpcScript( std::string name, uint32_t npcId ) : BattleNpcScript( std::string name, uint32_t npcId ) :
ScriptObject( name ), ScriptObject( name, npcId )
m_npcId( npcId )
{ } { }
const uint32_t getNpcId()
{
return m_npcId;
}
}; };
class ZoneScript : public ScriptObject class ZoneScript : public ScriptObject
{ {
protected:
const uint32_t m_zoneId;
public: public:
ZoneScript( std::string name, uint32_t zoneId ) : ZoneScript( std::string name, uint32_t zoneId ) :
ScriptObject( name ), ScriptObject( name, zoneId )
m_zoneId( zoneId )
{ } { }
const uint32_t getZoneId()
{
return m_zoneId;
}
virtual void onZoneInit() { } virtual void onZoneInit() { }
virtual void onEnterZone( Core::Entity::Player pPlayer, uint32_t eventId, uint16_t param1, uint16_t param2 ) { } virtual void onEnterZone( Entity::Player& pPlayer, uint32_t eventId, uint16_t param1, uint16_t param2 ) { }
}; };
#endif #endif

View file

@ -60,12 +60,12 @@ ModuleHandle Core::Scripting::ScriptLoader::loadModule( std::string path )
return handle; return handle;
} }
ScriptObject* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handle, std::string name ) ScriptObject* Core::Scripting::ScriptLoader::getScriptObjectExport( ModuleHandle handle, std::string name )
{ {
typedef ScriptObject* (*getScriptObjectType)(); typedef ScriptObject* (*getScriptObjectType)();
auto fn = boost::str( boost::format( "get%1%" ) % name ); auto fn = boost::str( boost::format( "get%1%" ) % name );
g_log.info( "getting symbol: " + fn ); g_log.debug( "getting symbol: " + fn );
#ifdef _WIN32 #ifdef _WIN32
getScriptObjectType func = reinterpret_cast< getScriptObjectType >( GetProcAddress( handle, fn.c_str() ) ); getScriptObjectType func = reinterpret_cast< getScriptObjectType >( GetProcAddress( handle, fn.c_str() ) );
@ -74,7 +74,14 @@ ScriptObject* Core::Scripting::ScriptLoader::getScriptObject( ModuleHandle handl
#endif #endif
if( func ) if( func )
return func(); {
auto ptr = func();
g_log.debug( "got ScriptObject @ 0x" + boost::str( boost::format( "%|08X|" ) % ptr ) );
g_log.debug( "script info -> name: " + std::string( ptr->getName() ) + ", id: " + std::to_string( ptr->getId() ) );
return ptr;
}
else else
return nullptr; return nullptr;
} }

View file

@ -30,12 +30,12 @@ namespace Scripting {
bool unloadScript( std::string ); bool unloadScript( std::string );
bool unloadScript( ModuleHandle ); bool unloadScript( ModuleHandle );
ScriptObject* getScriptObject( ModuleHandle handle, std::string name ); ScriptObject* getScriptObjectExport( ModuleHandle handle, std::string name );
template< typename T > template< typename T >
T* getScriptObject( ModuleHandle handle ) T* getScriptObject( ModuleHandle handle, std::string name )
{ {
return static_cast< T* >( getScriptObject( handle, typeid( T ).name() ) ); return static_cast< T* >( getScriptObjectExport( handle, name ) );
} }
}; };

View file

@ -47,6 +47,8 @@ bool Core::Scripting::ScriptManager::init()
auto& path = *itr; auto& path = *itr;
g_log.debug( "got module: " + path ); g_log.debug( "got module: " + path );
m_nativeScriptHandler->loadScript( path );
} }
return true; return true;