2017-12-10 01:52:03 +11:00
|
|
|
#ifndef NATIVE_SCRIPT_API
|
|
|
|
#define NATIVE_SCRIPT_API
|
|
|
|
|
|
|
|
#include <string>
|
2017-12-10 02:49:22 +11:00
|
|
|
#include <Actor/Actor.h>
|
|
|
|
#include <Actor/Player.h>
|
|
|
|
#include <StatusEffect/StatusEffect.h>
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2017-12-10 17:13:57 +11:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define EXPORT __declspec( dllexport )
|
|
|
|
#else
|
|
|
|
#define EXPORT __attribute__((visibility("default")))
|
|
|
|
#endif
|
|
|
|
|
2017-12-11 21:10:54 +11:00
|
|
|
using namespace Core;
|
|
|
|
|
2017-12-13 14:05:50 +11:00
|
|
|
// constant script ids for certain events
|
|
|
|
#define EVENTSCRIPT_AETHERYTE_ID 0x50000
|
|
|
|
#define EVENTSCRIPT_AETHERNET_ID 0x50001
|
|
|
|
|
2017-12-12 14:57:13 +11:00
|
|
|
enum ScriptType
|
|
|
|
{
|
2018-01-04 16:14:14 +11:00
|
|
|
None,
|
|
|
|
ScriptedStatusEffect,
|
|
|
|
ScriptedAction,
|
|
|
|
ScriptedEvent,
|
|
|
|
ScriptedBattleNpc,
|
|
|
|
ScriptedZone
|
2017-12-12 14:57:13 +11:00
|
|
|
};
|
|
|
|
|
2017-12-10 01:52:03 +11:00
|
|
|
class ScriptObject
|
|
|
|
{
|
|
|
|
protected:
|
2017-12-11 21:10:54 +11:00
|
|
|
std::string m_scriptName;
|
|
|
|
uint32_t m_id;
|
2017-12-12 14:57:13 +11:00
|
|
|
ScriptType m_type;
|
2017-12-10 01:52:03 +11:00
|
|
|
|
|
|
|
public:
|
2017-12-12 14:57:13 +11:00
|
|
|
ScriptObject( std::string name, uint32_t id, ScriptType type ) :
|
2017-12-11 21:10:54 +11:00
|
|
|
m_scriptName( name ),
|
2017-12-12 14:57:13 +11:00
|
|
|
m_id( id ),
|
|
|
|
m_type( type )
|
2017-12-10 02:13:54 +11:00
|
|
|
{ }
|
|
|
|
|
2017-12-11 21:10:54 +11:00
|
|
|
virtual const std::string& getName() const
|
2017-12-10 02:13:54 +11:00
|
|
|
{
|
|
|
|
return m_scriptName;
|
|
|
|
}
|
2017-12-11 21:10:54 +11:00
|
|
|
|
|
|
|
virtual uint32_t getId() const
|
|
|
|
{
|
|
|
|
return m_id;
|
|
|
|
}
|
2017-12-12 14:57:13 +11:00
|
|
|
|
|
|
|
virtual ScriptType getType() const
|
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-12-10 03:01:21 +11:00
|
|
|
class StatusEffectScript : public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2017-12-10 02:13:54 +11:00
|
|
|
StatusEffectScript( std::string name, uint32_t effectId ) :
|
2018-01-04 16:14:14 +11:00
|
|
|
ScriptObject( name, effectId, ScriptType::ScriptedStatusEffect )
|
2017-12-10 02:13:54 +11:00
|
|
|
{ }
|
|
|
|
|
2017-12-11 22:21:37 +11:00
|
|
|
virtual void onTick( Entity::Actor& actor ) { }
|
|
|
|
virtual void onApply( Entity::Actor& actor ) { }
|
|
|
|
virtual void onRemove( Entity::Actor& actor ) { }
|
|
|
|
virtual void onExpire( Entity::Actor& actor ) { }
|
|
|
|
virtual void onPlayerCollision( Entity::Actor& actor, Entity::Actor& actorHit ) { }
|
|
|
|
virtual void onPlayerFinishCast( Entity::Actor& actor ) { }
|
|
|
|
virtual void onPlayerDamaged( Entity::Actor& actor ) { }
|
|
|
|
virtual void onPlayerDeath( Entity::Actor& actor ) { }
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-12-10 15:31:48 +11:00
|
|
|
class ActionScript : public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2017-12-10 15:31:48 +11:00
|
|
|
ActionScript( std::string name, uint32_t abilityId ) :
|
2018-01-04 16:14:14 +11:00
|
|
|
ScriptObject( name, abilityId, ScriptType::ScriptedAction )
|
2017-12-10 02:13:54 +11:00
|
|
|
{ }
|
|
|
|
|
2017-12-11 22:21:37 +11:00
|
|
|
virtual void onStart( Entity::Actor& sourceActor, Entity::Actor& targetActor ) { }
|
|
|
|
virtual void onCastFinish( Entity::Player& player, Entity::Actor& targetActor ) { }
|
|
|
|
virtual void onInterrupt( Entity::Actor& sourceActor/*, Core::Entity::Actor targetActor*/ ) { }
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-12-13 22:19:00 +11:00
|
|
|
class EventScript : public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2017-12-13 22:19:00 +11:00
|
|
|
EventScript( std::string name, uint32_t questId ) :
|
2018-01-04 16:14:14 +11:00
|
|
|
ScriptObject( name, questId, ScriptType::ScriptedEvent )
|
2017-12-10 02:13:54 +11:00
|
|
|
{ }
|
|
|
|
|
2017-12-11 22:52:10 +11:00
|
|
|
virtual void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) { }
|
2017-12-11 21:10:54 +11:00
|
|
|
virtual void onNpcKill( uint32_t npcId, Entity::Player& player ) { }
|
|
|
|
virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Entity::Player& player ) { }
|
2017-12-13 22:19:00 +11:00
|
|
|
virtual void onEnterZone( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) { }
|
|
|
|
virtual void onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z ) { }
|
|
|
|
virtual void onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z ) { }
|
|
|
|
virtual void onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId ) { }
|
|
|
|
virtual void onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId ) { }
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-12-10 03:01:21 +11:00
|
|
|
class BattleNpcScript : public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2017-12-10 02:13:54 +11:00
|
|
|
BattleNpcScript( std::string name, uint32_t npcId ) :
|
2018-01-04 16:14:14 +11:00
|
|
|
ScriptObject( name, npcId, ScriptType::ScriptedBattleNpc )
|
2017-12-10 02:13:54 +11:00
|
|
|
{ }
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
2017-12-10 03:01:21 +11:00
|
|
|
class ZoneScript : public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2017-12-10 02:13:54 +11:00
|
|
|
ZoneScript( std::string name, uint32_t zoneId ) :
|
2018-01-04 16:14:14 +11:00
|
|
|
ScriptObject( name, zoneId, ScriptType::ScriptedZone )
|
2017-12-10 02:13:54 +11:00
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void onZoneInit() { }
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|