2017-12-10 01:52:03 +11:00
|
|
|
#ifndef NATIVE_SCRIPT_API
|
|
|
|
#define NATIVE_SCRIPT_API
|
|
|
|
|
|
|
|
#include <string>
|
2021-09-07 16:50:13 +02:00
|
|
|
#include <Event/EventHandler.h>
|
2018-09-24 09:03:29 -04:00
|
|
|
#include "ForwardsZone.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
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
namespace Sapphire
|
2018-11-13 20:43:29 +11:00
|
|
|
{
|
|
|
|
class Framework;
|
|
|
|
}
|
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
namespace Sapphire::ScriptAPI
|
2017-12-10 01:52:03 +11:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
/*!
|
2018-11-13 21:34:44 +11:00
|
|
|
* @brief The base class that any script should inherit from and set the type param accordingly
|
|
|
|
*/
|
|
|
|
class ScriptObject
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
uint32_t m_id;
|
|
|
|
std::size_t m_type;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
* @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 );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Gets the ID set for this script
|
|
|
|
*
|
|
|
|
* @return The allocated ID of the script set during object construction
|
|
|
|
*/
|
|
|
|
virtual uint32_t getId() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Gets the unique identifier (hash_code) of the script
|
|
|
|
*
|
|
|
|
* @return The hash_code of the script
|
|
|
|
*/
|
|
|
|
virtual std::size_t getType() const;
|
|
|
|
};
|
2018-11-13 20:43:29 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
/*!
|
2018-11-13 21:34:44 +11:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to status effects.
|
|
|
|
*/
|
|
|
|
class StatusEffectScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit StatusEffectScript( uint32_t effectId );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called on each tick that a status effect is active on an actor
|
|
|
|
*
|
|
|
|
* @param actor the actor the status effect is ticking on
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onTick( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect is applied to an actor
|
|
|
|
*
|
|
|
|
* @param actor the actor on which the status effect was applied to
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onApply( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @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
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onRemove( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect expires
|
|
|
|
*
|
|
|
|
* @param actor The actor on which the efect expired on
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onExpire( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @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
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onPlayerCollision( Sapphire::Entity::Chara& actor, Sapphire::Entity::Chara& actorHit );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the owner finishes a cast
|
|
|
|
*
|
|
|
|
* @param actor The actor who finished a cast
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onPlayerFinishCast( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect owner was damaged
|
|
|
|
*
|
|
|
|
* @param actor The actor that was damaged
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onPlayerDamaged( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Called when the status effect owner dies
|
|
|
|
*
|
|
|
|
* @param actor The actor that died
|
|
|
|
*/
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onPlayerDeath( Sapphire::Entity::Chara& actor );
|
2018-11-13 21:34:44 +11:00
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2018-11-13 21:34:44 +11:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to actions
|
|
|
|
*/
|
|
|
|
class ActionScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
2019-06-02 00:34:22 +10:00
|
|
|
explicit ActionScript( uint32_t actionId );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
virtual void onStart( Sapphire::World::Action::Action& action );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
virtual void onExecute( Sapphire::World::Action::Action& action );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
virtual void onInterrupt( Sapphire::World::Action::Action& action );
|
2018-11-13 21:34:44 +11:00
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
/*!
|
2018-11-13 21:34:44 +11:00
|
|
|
* @brief The base class for any scripts that implement behaviour related to the event system.
|
|
|
|
* This includes but is not limited to: NPCs, shops, some world objects
|
|
|
|
*/
|
|
|
|
class EventScript : public ScriptObject
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
template< typename Ret, class Obj >
|
2018-11-29 16:55:48 +01:00
|
|
|
inline std::function< void( Sapphire::Entity::Player& ) > bindScene( Ret ( Obj::*f )( Sapphire::Entity::Player& ) )
|
2018-11-13 21:34:44 +11:00
|
|
|
{
|
|
|
|
return std::bind( f, static_cast< Obj* >( this ), std::placeholders::_1 );
|
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
public:
|
2019-03-23 17:02:47 +11:00
|
|
|
explicit EventScript( uint32_t eventId );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onTalk( uint32_t eventId, Sapphire::Entity::Player& player, uint64_t actorId );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-02-02 23:32:36 +11:00
|
|
|
virtual void onBNpcKill( uint32_t nameId, Sapphire::Entity::Player& player );
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Sapphire::Entity::Player& player );
|
2018-03-22 23:45:17 +11:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onEnterTerritory( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-03-23 17:02:47 +11:00
|
|
|
virtual void onWithinRange( Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1,float x, float y, float z );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onOutsideRange( Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-03-23 17:02:47 +11:00
|
|
|
virtual void onEventItem( Sapphire::Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime,
|
|
|
|
uint64_t targetId );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
virtual void onEventHandlerTradeReturn( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
|
2018-11-13 21:34:44 +11:00
|
|
|
uint32_t catalogId );
|
2019-02-10 22:13:47 +11:00
|
|
|
|
2019-03-19 00:01:34 +11:00
|
|
|
virtual void onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId );
|
2021-08-16 17:18:29 +09:00
|
|
|
|
|
|
|
virtual void onEventYield( Sapphire::Entity::Player& player, uint16_t scene, std::vector< uint32_t > param );
|
2021-09-07 16:50:13 +02:00
|
|
|
|
2021-09-08 11:25:16 +02:00
|
|
|
virtual Event::EventHandler::QuestAvailability getQuestAvailability( Sapphire::Entity::Player& player, uint32_t eventId );
|
2018-11-13 21:34:44 +11:00
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-30 23:15:58 +11:00
|
|
|
/*!
|
|
|
|
* @brief The base class for scripts that implement behaviour related to Event Objects (EObjs)
|
|
|
|
*/
|
|
|
|
class EventObjectScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit EventObjectScript( uint32_t eobjId );
|
|
|
|
|
|
|
|
virtual void onTalk( uint32_t eventId, Sapphire::Entity::Player& player, Entity::EventObject& eobj );
|
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
/*!
|
|
|
|
* @brief The base class for any scripts that implement behaviour related to BattleNPCs
|
|
|
|
*/
|
|
|
|
class BattleNpcScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit BattleNpcScript( uint32_t npcId );
|
|
|
|
};
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
/*!
|
|
|
|
* @brief The base class for any scripts that implement behaviour related to zones
|
|
|
|
*/
|
|
|
|
class ZoneScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit ZoneScript( uint32_t zoneId );
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
virtual void onZoneInit();
|
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
/*!
|
|
|
|
* @brief The base class for any scripts that implement behaviour related to instance content zones
|
|
|
|
*/
|
|
|
|
class InstanceContentScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit InstanceContentScript( uint32_t instanceContentId );
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2019-02-20 19:53:54 +11:00
|
|
|
virtual void onInit( Sapphire::InstanceContent& instance );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-04-04 23:29:52 +02:00
|
|
|
virtual void onUpdate( Sapphire::InstanceContent& instance, uint64_t tickCount );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-02-20 19:53:54 +11:00
|
|
|
virtual void onEnterTerritory( Sapphire::InstanceContent& instance, Sapphire::Entity::Player& player, uint32_t eventId,
|
2019-03-23 17:02:47 +11:00
|
|
|
uint16_t param1, uint16_t param2 );
|
2018-11-13 21:34:44 +11:00
|
|
|
};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-03-31 01:39:49 +01:00
|
|
|
/*!
|
|
|
|
* @brief The base class for any scripts that implement behaviour related to instance content zones
|
|
|
|
*/
|
|
|
|
class QuestBattleScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit QuestBattleScript( uint32_t questBattleId );
|
|
|
|
|
2019-04-07 13:27:56 +02:00
|
|
|
virtual void onDutyComplete( Sapphire::QuestBattle& instance, Entity::Player& player );
|
|
|
|
|
2019-04-17 00:10:32 +02:00
|
|
|
virtual void onDutyCommence( QuestBattle& instance, Entity::Player& player );
|
|
|
|
|
2019-04-02 00:00:58 +02:00
|
|
|
virtual void onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player );
|
|
|
|
|
2019-03-31 01:39:49 +01:00
|
|
|
virtual void onInit( Sapphire::QuestBattle& instance );
|
|
|
|
|
2019-04-04 23:29:52 +02:00
|
|
|
virtual void onUpdate( Sapphire::QuestBattle& instance, uint64_t tickCount );
|
2019-03-31 01:39:49 +01:00
|
|
|
|
|
|
|
virtual void onEnterTerritory( Sapphire::QuestBattle& instance, Sapphire::Entity::Player& player, uint32_t eventId,
|
|
|
|
uint16_t param1, uint16_t param2 );
|
|
|
|
};
|
|
|
|
|
2021-08-16 17:18:29 +09:00
|
|
|
class PublicContentScript : public ScriptObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit PublicContentScript( uint32_t contentId );
|
|
|
|
|
|
|
|
virtual void onInit( Sapphire::PublicContent& instance );
|
|
|
|
|
|
|
|
virtual void onUpdate( Sapphire::PublicContent& instance, uint64_t tickCount );
|
|
|
|
|
|
|
|
virtual void onPlayerZoneIn( Sapphire::PublicContent& instance, Sapphire::Entity::Player& player );
|
|
|
|
|
|
|
|
virtual void onLeaveTerritory( Sapphire::PublicContent& instance, Sapphire::Entity::Player& player );
|
|
|
|
|
|
|
|
virtual void onEnterTerritory( Sapphire::PublicContent& instance, Sapphire::Entity::Player& player, uint32_t eventId,
|
|
|
|
uint16_t param1, uint16_t param2 );
|
|
|
|
};
|
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
}
|
2018-02-09 02:34:43 +11:00
|
|
|
|
2018-02-28 10:26:03 +01:00
|
|
|
#endif
|