2017-12-10 01:52:03 +11:00
|
|
|
#ifndef NATIVE_SCRIPT_API
|
|
|
|
#define NATIVE_SCRIPT_API
|
|
|
|
|
|
|
|
#include <string>
|
2018-01-17 20:09:16 +11:00
|
|
|
#include <typeinfo>
|
|
|
|
#include <typeindex>
|
2018-08-12 22:30:18 +10:00
|
|
|
#include <Event/EventHandler.h>
|
2018-02-28 10:26:03 +01:00
|
|
|
#include "Forwards.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;
|
|
|
|
|
2018-07-24 23:16:26 +10:00
|
|
|
// todo: this is shit
|
2017-12-13 14:05:50 +11:00
|
|
|
// constant script ids for certain events
|
|
|
|
#define EVENTSCRIPT_AETHERYTE_ID 0x50000
|
|
|
|
#define EVENTSCRIPT_AETHERNET_ID 0x50001
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class that any script should inherit from and set the type param accordingly
|
2018-07-24 22:22:19 +10:00
|
|
|
*/
|
2017-12-10 01:52:03 +11:00
|
|
|
class ScriptObject
|
|
|
|
{
|
|
|
|
protected:
|
2018-08-29 21:40:59 +02:00
|
|
|
uint32_t m_id;
|
|
|
|
std::size_t m_type;
|
2017-12-10 01:52:03 +11:00
|
|
|
|
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
/*!
|
|
|
|
* @param id an ID which uniquely identifies this script in relation to it's type
|
|
|
|
* @param type The RTTI hash code of the implementing type to uniquely identify it
|
|
|
|
*/
|
|
|
|
ScriptObject( uint32_t id, std::size_t type ) :
|
|
|
|
m_id( id ),
|
|
|
|
m_type( type )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Gets the ID set for this script
|
|
|
|
*
|
|
|
|
* @return The allocated ID of the script set during object construction
|
|
|
|
*/
|
|
|
|
virtual uint32_t getId() const
|
|
|
|
{
|
|
|
|
return m_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Gets the unique identifier (hash_code) of the script
|
|
|
|
*
|
|
|
|
* @return The hash_code of the script
|
|
|
|
*/
|
|
|
|
virtual std::size_t getType() const
|
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to status effects.
|
2018-07-24 22:22:19 +10:00
|
|
|
*/
|
2018-08-29 21:40:59 +02:00
|
|
|
class StatusEffectScript :
|
|
|
|
public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
explicit StatusEffectScript( uint32_t effectId ) :
|
|
|
|
ScriptObject( effectId, typeid( StatusEffectScript ).hash_code() )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called on each tick that a status effect is active on an actor
|
|
|
|
*
|
|
|
|
* @param actor the actor the status effect is ticking on
|
|
|
|
*/
|
|
|
|
virtual void onTick( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect is applied to an actor
|
|
|
|
*
|
|
|
|
* @param actor the actor on which the status effect was applied to
|
|
|
|
*/
|
|
|
|
virtual void onApply( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the actor (usually a player) removes the status effect by right clicking it
|
|
|
|
*
|
|
|
|
* @param actor The actor on which the effect was removed from
|
|
|
|
*/
|
|
|
|
virtual void onRemove( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect expires
|
|
|
|
*
|
|
|
|
* @param actor The actor on which the efect expired on
|
|
|
|
*/
|
|
|
|
virtual void onExpire( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the player with the status effect collides with another player, eg. hot potato
|
|
|
|
*
|
|
|
|
* @param actor The actor which has status effect
|
|
|
|
* @param actorHit The actor who collided with the status effect owner
|
|
|
|
*/
|
|
|
|
virtual void onPlayerCollision( Entity::Chara& actor, Entity::Chara& actorHit )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the owner finishes a cast
|
|
|
|
*
|
|
|
|
* @param actor The actor who finished a cast
|
|
|
|
*/
|
|
|
|
virtual void onPlayerFinishCast( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect owner was damaged
|
|
|
|
*
|
|
|
|
* @param actor The actor that was damaged
|
|
|
|
*/
|
|
|
|
virtual void onPlayerDamaged( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect owner dies
|
|
|
|
*
|
|
|
|
* @param actor The actor that died
|
|
|
|
*/
|
|
|
|
virtual void onPlayerDeath( Entity::Chara& actor )
|
|
|
|
{
|
|
|
|
}
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to actions
|
2018-07-24 22:22:19 +10:00
|
|
|
*/
|
2018-08-29 21:40:59 +02:00
|
|
|
class ActionScript :
|
|
|
|
public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
explicit ActionScript( uint32_t abilityId ) :
|
|
|
|
ScriptObject( abilityId, typeid( ActionScript ).hash_code() )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onStart( Entity::Chara& sourceActor, Entity::Chara& targetActor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onCastFinish( Entity::Player& player, Entity::Chara& targetActor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onInterrupt( Entity::Chara& sourceActor/*, Core::Entity::Chara targetActor*/ )
|
|
|
|
{
|
|
|
|
}
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to the event system.
|
2018-07-24 22:22:19 +10:00
|
|
|
* This includes but is not limited to: NPCs, shops, some world objects
|
|
|
|
*/
|
2018-08-29 21:40:59 +02:00
|
|
|
class EventScript :
|
|
|
|
public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
2018-03-22 23:45:17 +11:00
|
|
|
protected:
|
2018-08-29 21:40:59 +02:00
|
|
|
template< typename Ret, class Obj >
|
|
|
|
inline Event::EventHandler::SceneChainCallback bindScene( Ret ( Obj::*f )( Entity::Player& ) )
|
|
|
|
{
|
|
|
|
return std::bind( f, static_cast< Obj* >( this ), std::placeholders::_1 );
|
|
|
|
}
|
2018-03-22 23:45:17 +11:00
|
|
|
|
2017-12-10 01:52:03 +11:00
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
explicit EventScript( uint32_t questId ) :
|
|
|
|
ScriptObject( questId, typeid( EventScript ).hash_code() )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onNpcKill( uint32_t npcId, Entity::Player& player )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Entity::Player& player )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onEnterTerritory( 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
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to BattleNPCs
|
2018-07-24 22:22:19 +10:00
|
|
|
*/
|
2018-08-29 21:40:59 +02:00
|
|
|
class BattleNpcScript :
|
|
|
|
public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
explicit BattleNpcScript( uint32_t npcId ) :
|
|
|
|
ScriptObject( npcId, typeid( BattleNpcScript ).hash_code() )
|
|
|
|
{
|
|
|
|
}
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to zones
|
2018-07-24 22:22:19 +10:00
|
|
|
*/
|
2018-08-29 21:40:59 +02:00
|
|
|
class ZoneScript :
|
|
|
|
public ScriptObject
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
explicit ZoneScript( uint32_t zoneId ) :
|
|
|
|
ScriptObject( zoneId, typeid( ZoneScript ).hash_code() )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onZoneInit()
|
|
|
|
{
|
|
|
|
}
|
2017-12-10 01:52:03 +11:00
|
|
|
};
|
|
|
|
|
2018-07-24 22:22:19 +10:00
|
|
|
/*!
|
2018-07-24 23:16:26 +10:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to instance content zones
|
2018-07-24 22:22:19 +10:00
|
|
|
*/
|
2018-08-29 21:40:59 +02:00
|
|
|
class InstanceContentScript :
|
|
|
|
public ScriptObject
|
2018-02-09 02:34:43 +11:00
|
|
|
{
|
|
|
|
public:
|
2018-08-29 21:40:59 +02:00
|
|
|
explicit InstanceContentScript( uint32_t instanceContentId ) :
|
|
|
|
ScriptObject( uint32_t{ 0x8003 } << 16 | instanceContentId, typeid( InstanceContentScript ).hash_code() )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onInit( InstanceContentPtr instance )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onUpdate( InstanceContentPtr instance, uint32_t currTime )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void onEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
|
|
|
uint16_t param2 )
|
|
|
|
{
|
|
|
|
}
|
2018-02-09 02:34:43 +11:00
|
|
|
};
|
|
|
|
|
2018-02-28 10:26:03 +01:00
|
|
|
#endif
|