mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Another approach at event improvements
This commit is contained in:
parent
6a13729dca
commit
bafc511db2
16 changed files with 271 additions and 195 deletions
|
@ -322,19 +322,27 @@ namespace Common {
|
|||
enum EventType : uint16_t
|
||||
{
|
||||
Quest = 0x0001,
|
||||
ChocoRent = 0x0002,
|
||||
Warp = 0x0002,
|
||||
Shop = 0x0004,
|
||||
Aetheryte = 0x0005,
|
||||
GuildLeveAssign = 0x0006,
|
||||
GuildLeveAssignment = 0x0006,
|
||||
DefaultTalk = 0x0009,
|
||||
CustomTalk = 0x000B,
|
||||
CompanyLeveOfficer = 0x000C,
|
||||
CraftLeve = 0x000E,
|
||||
ChocoPort = 0x0012,
|
||||
GimmickAccessor = 0x000F,
|
||||
GimmickBill = 0x0010,
|
||||
GimmickRect = 0x0011,
|
||||
ChocoboTaxiStand = 0x0012,
|
||||
Opening = 0x0013,
|
||||
ExitRange = 0x0014,
|
||||
GCShop = 0x0016,
|
||||
GuildOrderGuide = 0x0017,
|
||||
GuildOrderOfficer = 0x0018,
|
||||
Stories = 0x001A,
|
||||
ContentNpc = 0x0019,
|
||||
Story = 0x001A,
|
||||
SpecialShop = 0x001B,
|
||||
BahamutGuide = 0x001C,
|
||||
FcTalk = 0x001F,
|
||||
};
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ struct FFXIVIpcPlayerSpawn : FFXIVIpcBasePacket<PlayerSpawn>
|
|||
uint32_t bNPCName;
|
||||
uint32_t u18;
|
||||
uint32_t u19;
|
||||
uint32_t u20;
|
||||
uint32_t directorId;
|
||||
uint32_t ownerId;
|
||||
uint32_t u22;
|
||||
uint32_t hPMax;
|
||||
|
|
|
@ -45,9 +45,9 @@ namespace Core
|
|||
|
||||
namespace Event
|
||||
{
|
||||
class Event;
|
||||
class EventHandler;
|
||||
|
||||
typedef boost::shared_ptr<Event> EventPtr;
|
||||
typedef boost::shared_ptr<EventHandler> EventPtr;
|
||||
}
|
||||
|
||||
namespace Action
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
||||
#include "Actor/Player.h"
|
||||
#include "Event/Event.h"
|
||||
#include "Event/EventHandler.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
extern Core::Data::ExdData g_exdData;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "Inventory/Item.h"
|
||||
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Event/Event.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include "Action/Action.h"
|
||||
#include "Action/EventAction.h"
|
||||
#include "Action/EventItemAction.h"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "Actor.h"
|
||||
#include "Inventory/Inventory.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include <map>
|
||||
#include <queue>
|
||||
|
||||
|
@ -50,31 +51,33 @@ public:
|
|||
/*! start an event item action */
|
||||
void eventItemActionStart( uint32_t eventId, uint32_t action, ActionCallback finishCallback, ActionCallback interruptCallback, uint64_t additional );
|
||||
/*! start/register a normal event */
|
||||
void eventStart( uint64_t actorId, uint32_t eventId, uint8_t eventParam, uint8_t eventParam1, uint32_t eventParam2 );
|
||||
void eventStart( uint64_t actorId, uint32_t eventId, Event::EventHandler::EventType eventParam, uint8_t eventParam1, uint32_t eventParam2 );
|
||||
/*! play a subevent */
|
||||
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 );
|
||||
/*! play a subevent */
|
||||
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
|
||||
uint32_t eventParam2, uint32_t eventParam3, Scripting::EventReturnCallback eventReturnCallback );
|
||||
uint32_t eventParam2, uint32_t eventParam3, Event::EventHandler::SceneReturnCallback eventReturnCallback );
|
||||
/*! play a subevent */
|
||||
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
|
||||
uint32_t eventParam2, uint32_t eventParam3, uint32_t eventParam4, Scripting::EventReturnCallback eventReturnCallback );
|
||||
uint32_t eventParam2, uint32_t eventParam3, uint32_t eventParam4,
|
||||
Event::EventHandler::SceneReturnCallback eventReturnCallback );
|
||||
/*! play a subevent */
|
||||
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags, Scripting::EventReturnCallback eventReturnCallback );
|
||||
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags,
|
||||
Event::EventHandler::SceneReturnCallback eventReturnCallback );
|
||||
/*! play a subevent */
|
||||
void eventPlay( uint32_t eventId, uint32_t scene, uint32_t flags );
|
||||
/*! finish / unregister an event */
|
||||
void eventFinish( uint32_t eventId, uint32_t freePlayer );
|
||||
/*! add an event to the event array */
|
||||
void addEvent( Event::EventPtr pEvent );
|
||||
void addEvent( Event::EventHandlerPtr pEvent );
|
||||
/*! retrieve an event from the event array */
|
||||
Event::EventPtr getEvent( uint32_t eventId );
|
||||
Event::EventHandlerPtr getEvent( uint32_t eventId );
|
||||
/*! get number of active events */
|
||||
size_t getEventCount();
|
||||
/*! remove an event from the event array */
|
||||
void removeEvent( uint32_t eventId );
|
||||
/*! return the eventlist */
|
||||
std::map< uint32_t, Event::EventPtr >& eventList();
|
||||
std::map< uint32_t, Event::EventHandlerPtr >& eventList();
|
||||
|
||||
void checkEvent( uint32_t eventId );
|
||||
|
||||
|
@ -600,7 +603,7 @@ private:
|
|||
uint16_t m_itemLevel;
|
||||
InventoryPtr m_pInventory;
|
||||
|
||||
std::map< uint32_t, Event::EventPtr > m_eventMap;
|
||||
std::map< uint32_t, Event::EventHandlerPtr > m_eventMap;
|
||||
std::map< uint32_t, uint8_t > m_playerIdToSpawnIdMap; // maps player to spawn id
|
||||
std::queue< uint8_t > m_freeSpawnIdQueue; // queue with spawn ids free to be assigned
|
||||
std::queue< uint8_t > m_freeHateSlotQueue; // queue with "hate slots" free to be assigned
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "Action/EventAction.h"
|
||||
#include "Action/EventItemAction.h"
|
||||
|
||||
#include "Event/Event.h"
|
||||
#include "Event/Event.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include "ServerZone.h"
|
||||
|
||||
extern Core::Logger g_log;
|
||||
|
@ -32,23 +32,23 @@ using namespace Core::Common;
|
|||
using namespace Core::Network::Packets;
|
||||
using namespace Core::Network::Packets::Server;
|
||||
|
||||
void Core::Entity::Player::addEvent( Event::EventPtr pEvent )
|
||||
void Core::Entity::Player::addEvent( Event::EventHandlerPtr pEvent )
|
||||
{
|
||||
m_eventMap[pEvent->getId()] = pEvent;
|
||||
}
|
||||
|
||||
std::map< uint32_t, Core::Event::EventPtr >& Core::Entity::Player::eventList()
|
||||
std::map< uint32_t, Core::Event::EventHandlerPtr >& Core::Entity::Player::eventList()
|
||||
{
|
||||
return m_eventMap;
|
||||
}
|
||||
|
||||
Core::Event::EventPtr Core::Entity::Player::getEvent( uint32_t eventId )
|
||||
Core::Event::EventHandlerPtr Core::Entity::Player::getEvent( uint32_t eventId )
|
||||
{
|
||||
auto it = m_eventMap.find( eventId );
|
||||
if( it != m_eventMap.end() )
|
||||
return it->second;
|
||||
|
||||
return Event::EventPtr( nullptr );
|
||||
return Event::EventHandlerPtr( nullptr );
|
||||
}
|
||||
|
||||
size_t Core::Entity::Player::getEventCount()
|
||||
|
@ -76,10 +76,10 @@ void Core::Entity::Player::checkEvent( uint32_t eventId )
|
|||
|
||||
|
||||
void Core::Entity::Player::eventStart( uint64_t actorId, uint32_t eventId,
|
||||
uint8_t eventType, uint8_t eventParam1,
|
||||
Event::EventHandler::EventType eventType, uint8_t eventParam1,
|
||||
uint32_t eventParam2 )
|
||||
{
|
||||
Event::EventPtr newEvent( new Event::Event( actorId, eventId, eventType, eventParam1, eventParam2 ) );
|
||||
Event::EventHandlerPtr newEvent( new Event::EventHandler( actorId, eventId, eventType, eventParam2 ) );
|
||||
addEvent( newEvent );
|
||||
|
||||
setStateFlag( PlayerStateFlag::Occupied2 );
|
||||
|
@ -99,7 +99,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
}
|
||||
|
||||
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
||||
uint32_t flags, Scripting::EventReturnCallback eventCallback )
|
||||
uint32_t flags, Event::EventHandler::SceneReturnCallback eventCallback )
|
||||
{
|
||||
eventPlay( eventId, scene, flags, 0, 0, eventCallback );
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene, uint32_t
|
|||
|
||||
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
||||
uint32_t flags, uint32_t eventParam2,
|
||||
uint32_t eventParam3, Scripting::EventReturnCallback eventCallback )
|
||||
uint32_t eventParam3, Event::EventHandler::SceneReturnCallback eventCallback )
|
||||
{
|
||||
if( flags & 0x02 )
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
if( !pEvent && getEventCount() )
|
||||
{
|
||||
// We're trying to play a nested event, need to start it first.
|
||||
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
|
||||
eventStart( getId(), eventId, Event::EventHandler::Nest, 0, 0 );
|
||||
pEvent = getEvent( eventId );
|
||||
}
|
||||
else if( !pEvent )
|
||||
|
@ -143,7 +143,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
|
||||
void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
||||
uint32_t flags, uint32_t eventParam2,
|
||||
uint32_t eventParam3, uint32_t eventParam4, Scripting::EventReturnCallback eventCallback )
|
||||
uint32_t eventParam3, uint32_t eventParam4, Event::EventHandler::SceneReturnCallback eventCallback )
|
||||
{
|
||||
if( flags & 0x02 )
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ void Core::Entity::Player::eventPlay( uint32_t eventId, uint32_t scene,
|
|||
if( !pEvent && getEventCount() )
|
||||
{
|
||||
// We're trying to play a nested event, need to start it first.
|
||||
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
|
||||
eventStart( getId(), eventId, Event::EventHandler::Nest, 0, 0 );
|
||||
pEvent = getEvent( eventId );
|
||||
}
|
||||
else if( !pEvent )
|
||||
|
@ -183,7 +183,7 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
|
|||
return;
|
||||
}
|
||||
|
||||
if( getEventCount() > 1 && pEvent->getEventType() != Event::Event::Nest )
|
||||
if( getEventCount() > 1 && pEvent->getEventType() != Event::EventHandler::Nest )
|
||||
{
|
||||
// this is the parent of a nested event, we can't finish it until the parent finishes
|
||||
return;
|
||||
|
@ -191,7 +191,7 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
|
|||
|
||||
switch( pEvent->getEventType() )
|
||||
{
|
||||
case Event::Event::Nest:
|
||||
case Event::EventHandler::Nest:
|
||||
{
|
||||
queuePacket( EventFinishPacket( getId(), pEvent->getId(), pEvent->getEventType(), pEvent->getEventParam3() ) );
|
||||
removeEvent( pEvent->getId() );
|
||||
|
@ -249,7 +249,7 @@ void Core::Entity::Player::eventActionStart( uint32_t eventId,
|
|||
if( !pEvent && getEventCount() )
|
||||
{
|
||||
// We're trying to play a nested event, need to start it first.
|
||||
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
|
||||
eventStart( getId(), eventId, Event::EventHandler::Nest, 0, 0 );
|
||||
pEvent = getEvent( eventId );
|
||||
}
|
||||
else if( !pEvent )
|
||||
|
|
1
src/servers/sapphire_zone/Event/Director.cpp
Normal file
1
src/servers/sapphire_zone/Event/Director.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Director.h"
|
45
src/servers/sapphire_zone/Event/Director.h
Normal file
45
src/servers/sapphire_zone/Event/Director.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef SAPPHIRE_DIRECTOR_H
|
||||
#define SAPPHIRE_DIRECTOR_H
|
||||
|
||||
#include <common/Common.h>
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Event {
|
||||
|
||||
/*!
|
||||
\class Director
|
||||
\brief Base class for all Directors implements sequence and variables
|
||||
|
||||
\author Mordred
|
||||
*/
|
||||
|
||||
class Director
|
||||
{
|
||||
private:
|
||||
/*! Id of the director */
|
||||
uint32_t m_id;
|
||||
|
||||
/*! currect sequence */
|
||||
uint8_t m_sequence;
|
||||
|
||||
/*! current branch */
|
||||
uint8_t m_branch;
|
||||
|
||||
/*! raw storage for flags/vars */
|
||||
uint8_t m_unionData[10];
|
||||
|
||||
public:
|
||||
uint8_t getId() const;
|
||||
uint8_t getSequence() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //SAPPHIRE_DIRECTOR_H
|
|
@ -1,73 +0,0 @@
|
|||
#include "Event.h"
|
||||
|
||||
Core::Event::Event::Event( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam2, uint32_t eventParam3 )
|
||||
: m_actorId( actorId ),
|
||||
m_eventId( eventId ),
|
||||
m_playedScene( false )
|
||||
{
|
||||
|
||||
m_param1 = static_cast< uint16_t >( eventId );
|
||||
m_param2 = static_cast< uint16_t >( eventId >> 16 );
|
||||
|
||||
m_eventType = eventType;
|
||||
m_eventParam2 = eventParam2;
|
||||
m_eventParam3 = eventParam3;
|
||||
|
||||
m_callback = nullptr;
|
||||
}
|
||||
|
||||
uint64_t Core::Event::Event::getActorId() const
|
||||
{
|
||||
return m_actorId;
|
||||
}
|
||||
|
||||
uint32_t Core::Event::Event::getId() const
|
||||
{
|
||||
return m_eventId;
|
||||
}
|
||||
|
||||
uint32_t Core::Event::Event::getParam1() const
|
||||
{
|
||||
return m_param1;
|
||||
}
|
||||
|
||||
uint16_t Core::Event::Event::getParam2() const
|
||||
{
|
||||
return m_param2;
|
||||
}
|
||||
|
||||
uint8_t Core::Event::Event::getEventType() const
|
||||
{
|
||||
return m_eventType;
|
||||
}
|
||||
|
||||
uint32_t Core::Event::Event::getEventParam2() const
|
||||
{
|
||||
return m_eventParam2;
|
||||
}
|
||||
|
||||
uint32_t Core::Event::Event::getEventParam3() const
|
||||
{
|
||||
return m_eventParam3;
|
||||
}
|
||||
|
||||
Core::Scripting::EventReturnCallback Core::Event::Event::getEventReturnCallback() const
|
||||
{
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
void Core::Event::Event::setEventReturnCallback( Scripting::EventReturnCallback callback )
|
||||
{
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
|
||||
bool Core::Event::Event::hasPlayedScene() const
|
||||
{
|
||||
return m_playedScene;
|
||||
}
|
||||
|
||||
void Core::Event::Event::setPlayedScene( bool playedScene )
|
||||
{
|
||||
m_playedScene = playedScene;
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#ifndef _EVENT_H
|
||||
#define _EVENT_H
|
||||
|
||||
#include "../Forwards.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Event {
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
Event( uint64_t actorId, uint32_t eventId, uint8_t eventType, uint8_t eventParam2, uint32_t eventParam3 );
|
||||
|
||||
~Event() {}
|
||||
|
||||
uint64_t getActorId() const;
|
||||
|
||||
uint32_t getId() const;
|
||||
|
||||
uint32_t getParam1() const;
|
||||
|
||||
uint16_t getParam2() const;
|
||||
|
||||
uint8_t getEventType() const;
|
||||
|
||||
uint32_t getEventParam2() const;
|
||||
|
||||
uint32_t getEventParam3() const;
|
||||
|
||||
bool hasPlayedScene() const;
|
||||
|
||||
void setPlayedScene( bool playedScene );
|
||||
|
||||
Scripting::EventReturnCallback getEventReturnCallback() const;
|
||||
|
||||
void setEventReturnCallback( Scripting::EventReturnCallback callback );
|
||||
|
||||
enum EventType : uint8_t
|
||||
{
|
||||
Talk = 1,
|
||||
Emote = 2,
|
||||
DistanceBelow = 3,
|
||||
DistanceOver = 4,
|
||||
BattleReward = 5,
|
||||
Craft = 6,
|
||||
Nest = 7,
|
||||
Item = 8,
|
||||
Drop = 9,
|
||||
WithinRange = 10,
|
||||
OutsideRange = 11,
|
||||
GameStart = 12,
|
||||
GameProgress = 13,
|
||||
EnterTerritory = 15,
|
||||
GameComeBack = 17,
|
||||
ActionResult = 18,
|
||||
MateriaCraft = 19,
|
||||
Fishing = 20,
|
||||
UI = 21,
|
||||
Housing = 22,
|
||||
Say = 23,
|
||||
TableGame = 24,
|
||||
};
|
||||
|
||||
protected:
|
||||
uint64_t m_actorId;
|
||||
uint32_t m_eventId;
|
||||
uint32_t m_param1;
|
||||
uint16_t m_param2;
|
||||
uint8_t m_eventType;
|
||||
uint8_t m_eventParam2;
|
||||
uint32_t m_eventParam3;
|
||||
bool m_playedScene;
|
||||
Scripting::EventReturnCallback m_callback;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
65
src/servers/sapphire_zone/Event/EventHandler.cpp
Normal file
65
src/servers/sapphire_zone/Event/EventHandler.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include "EventHandler.h"
|
||||
|
||||
Core::Event::EventHandler::EventHandler( uint64_t actorId, uint32_t eventId, EventType eventType, uint32_t eventParam3 ) :
|
||||
m_actorId( actorId ),
|
||||
m_eventId( eventId ),
|
||||
m_eventType( eventType ),
|
||||
m_playedScene( false )
|
||||
{
|
||||
m_entryId = static_cast< uint16_t >( eventId );
|
||||
m_type = static_cast< uint16_t >( eventId >> 16 );
|
||||
|
||||
m_eventParam3 = eventParam3;
|
||||
|
||||
m_callback = nullptr;
|
||||
}
|
||||
|
||||
uint64_t Core::Event::EventHandler::getActorId() const
|
||||
{
|
||||
return m_actorId;
|
||||
}
|
||||
|
||||
uint32_t Core::Event::EventHandler::getId() const
|
||||
{
|
||||
return m_eventId;
|
||||
}
|
||||
|
||||
uint8_t Core::Event::EventHandler::getEventType() const
|
||||
{
|
||||
return m_eventType;
|
||||
}
|
||||
|
||||
uint16_t Core::Event::EventHandler::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
uint16_t Core::Event::EventHandler::getEntryId() const
|
||||
{
|
||||
return m_entryId;
|
||||
}
|
||||
|
||||
uint32_t Core::Event::EventHandler::getEventParam3() const
|
||||
{
|
||||
return m_eventParam3;
|
||||
}
|
||||
|
||||
Core::Event::EventHandler::SceneReturnCallback Core::Event::EventHandler::getEventReturnCallback() const
|
||||
{
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
void Core::Event::EventHandler::setEventReturnCallback( SceneReturnCallback callback )
|
||||
{
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
bool Core::Event::EventHandler::hasPlayedScene() const
|
||||
{
|
||||
return m_playedScene;
|
||||
}
|
||||
|
||||
void Core::Event::EventHandler::setPlayedScene( bool playedScene )
|
||||
{
|
||||
m_playedScene = playedScene;
|
||||
}
|
106
src/servers/sapphire_zone/Event/EventHandler.h
Normal file
106
src/servers/sapphire_zone/Event/EventHandler.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
#ifndef _EVENT_H
|
||||
#define _EVENT_H
|
||||
|
||||
#include "../Forwards.h"
|
||||
|
||||
namespace Core {
|
||||
namespace Event {
|
||||
|
||||
class EventHandler
|
||||
{
|
||||
public:
|
||||
enum EventType : uint8_t
|
||||
{
|
||||
Talk = 1,
|
||||
Emote = 2,
|
||||
DistanceBelow = 3,
|
||||
DistanceOver = 4,
|
||||
BattleReward = 5,
|
||||
Craft = 6,
|
||||
Nest = 7,
|
||||
Item = 8,
|
||||
Drop = 9,
|
||||
WithinRange = 10,
|
||||
OutsideRange = 11,
|
||||
GameStart = 12,
|
||||
GameProgress = 13,
|
||||
EnterTerritory = 15,
|
||||
GameComeBack = 17,
|
||||
ActionResult = 18,
|
||||
MateriaCraft = 19,
|
||||
Fishing = 20,
|
||||
UI = 21,
|
||||
Housing = 22,
|
||||
Say = 23,
|
||||
TableGame = 24,
|
||||
};
|
||||
|
||||
enum EventHandlerType : uint16_t
|
||||
{
|
||||
Quest = 0x0001,
|
||||
Warp = 0x0002,
|
||||
Shop = 0x0004,
|
||||
Aetheryte = 0x0005,
|
||||
GuildLeveAssignment = 0x0006,
|
||||
DefaultTalk = 0x0009,
|
||||
CustomTalk = 0x000B,
|
||||
CompanyLeveOfficer = 0x000C,
|
||||
CraftLeve = 0x000E,
|
||||
GimmickAccessor = 0x000F,
|
||||
GimmickBill = 0x0010,
|
||||
GimmickRect = 0x0011,
|
||||
ChocoboTaxiStand = 0x0012,
|
||||
Opening = 0x0013,
|
||||
ExitRange = 0x0014,
|
||||
GCShop = 0x0016,
|
||||
GuildOrderGuide = 0x0017,
|
||||
GuildOrderOfficer = 0x0018,
|
||||
ContentNpc = 0x0019,
|
||||
Story = 0x001A,
|
||||
SpecialShop = 0x001B,
|
||||
BahamutGuide = 0x001C,
|
||||
FcTalk = 0x001F,
|
||||
};
|
||||
|
||||
using SceneReturnCallback = std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > ;
|
||||
|
||||
EventHandler( uint64_t actorId, uint32_t eventId, EventType eventType, uint32_t eventParam3 );
|
||||
|
||||
~EventHandler() {}
|
||||
|
||||
uint64_t getActorId() const;
|
||||
|
||||
uint32_t getId() const;
|
||||
|
||||
uint16_t getType() const;
|
||||
|
||||
uint16_t getEntryId() const;
|
||||
|
||||
uint8_t getEventType() const;
|
||||
|
||||
uint32_t getEventParam3() const;
|
||||
|
||||
bool hasPlayedScene() const;
|
||||
|
||||
void setPlayedScene( bool playedScene );
|
||||
|
||||
SceneReturnCallback getEventReturnCallback() const;
|
||||
|
||||
void setEventReturnCallback( SceneReturnCallback callback );
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
uint64_t m_actorId;
|
||||
uint32_t m_eventId;
|
||||
uint16_t m_entryId;
|
||||
uint16_t m_type;
|
||||
uint8_t m_eventType;
|
||||
uint32_t m_eventParam3;
|
||||
bool m_playedScene;
|
||||
SceneReturnCallback m_callback;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#include "EventHelper.h"
|
||||
#include "Event.h"
|
||||
#include "EventHandler.h"
|
||||
#include <common/Common.h>
|
||||
#include <common/Exd/ExdData.h>
|
||||
|
||||
|
@ -51,7 +51,7 @@ std::string Core::Event::getEventName( uint32_t eventId )
|
|||
return "Aetheryte";
|
||||
return "Aethernet";
|
||||
}
|
||||
case EventType::ChocoPort:
|
||||
case EventType::Warp:
|
||||
{
|
||||
return "ChocoboTaxi";
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Core
|
|||
|
||||
namespace Event
|
||||
{
|
||||
TYPE_FORWARD( Event );
|
||||
TYPE_FORWARD( EventHandler );
|
||||
}
|
||||
|
||||
namespace Action
|
||||
|
@ -71,7 +71,6 @@ namespace Core
|
|||
namespace Scripting
|
||||
{
|
||||
class NativeScriptManager;
|
||||
typedef std::function< void( Entity::Player&, uint32_t, uint16_t, uint16_t, uint16_t ) > EventReturnCallback;
|
||||
}
|
||||
|
||||
typedef std::function< void( Entity::Player&, uint32_t, uint64_t ) > ActionCallback;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "Actor/Player.h"
|
||||
#include "Actor/BattleNpc.h"
|
||||
#include "ServerZone.h"
|
||||
#include "Event/Event.h"
|
||||
#include "Event/EventHandler.h"
|
||||
#include "Event/EventHelper.h"
|
||||
#include "StatusEffect/StatusEffect.h"
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
|
@ -171,7 +171,7 @@ bool Core::Scripting::ScriptManager::onTalk( Entity::Player& player, uint64_t ac
|
|||
{
|
||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||
|
||||
player.eventStart( actorId, eventId, Event::Event::Talk, 0, 0 );
|
||||
player.eventStart( actorId, eventId, Event::EventHandler::Talk, 0, 0 );
|
||||
|
||||
script->onTalk( eventId, player, actorId );
|
||||
|
||||
|
@ -206,7 +206,7 @@ bool Core::Scripting::ScriptManager::onEnterTerritory( Entity::Player& player, u
|
|||
auto script = m_nativeScriptManager->getScript< EventScript >( ScriptType::ScriptedEvent, eventId );
|
||||
if( script )
|
||||
{
|
||||
player.eventStart( player.getId(), eventId, Event::Event::EnterTerritory, 0, player.getZoneId() );
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::EnterTerritory, 0, player.getZoneId() );
|
||||
|
||||
script->onEnterZone( player, eventId, param1, param2 );
|
||||
|
||||
|
@ -229,7 +229,7 @@ bool Core::Scripting::ScriptManager::onWithinRange( Entity::Player& player, uint
|
|||
auto script = m_nativeScriptManager->getScript< EventScript >( ScriptType::ScriptedEvent, eventId );
|
||||
if( script )
|
||||
{
|
||||
player.eventStart( player.getId(), eventId, Event::Event::WithinRange, 1, param1 );
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 );
|
||||
|
||||
script->onWithinRange( player, eventId, param1, x, y, z );
|
||||
|
||||
|
@ -251,7 +251,7 @@ bool Core::Scripting::ScriptManager::onOutsideRange( Entity::Player& player, uin
|
|||
auto script = m_nativeScriptManager->getScript< EventScript >( ScriptType::ScriptedEvent, eventId );
|
||||
if( script )
|
||||
{
|
||||
player.eventStart( player.getId(), eventId, Event::Event::WithinRange, 1, param1 );
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 );
|
||||
|
||||
script->onOutsideRange( player, eventId, param1, x, y, z );
|
||||
|
||||
|
@ -274,7 +274,7 @@ bool Core::Scripting::ScriptManager::onEmote( Entity::Player& player, uint64_t a
|
|||
{
|
||||
player.sendDebug( "Calling: " + objName + "." + eventName );
|
||||
|
||||
player.eventStart( actorId, eventId, Event::Event::Emote, 0, emoteId );
|
||||
player.eventStart( actorId, eventId, Event::EventHandler::Emote, 0, emoteId );
|
||||
|
||||
script->onEmote( actorId, eventId, emoteId, player );
|
||||
|
||||
|
@ -367,7 +367,7 @@ bool Core::Scripting::ScriptManager::onEventItem( Entity::Player& player, uint32
|
|||
auto script = m_nativeScriptManager->getScript< EventScript >( ScriptType::ScriptedEvent, eventId );
|
||||
if( script )
|
||||
{
|
||||
player.eventStart( targetId, eventId, Event::Event::Item, 0, 0 );
|
||||
player.eventStart( targetId, eventId, Event::EventHandler::Item, 0, 0 );
|
||||
|
||||
script->onEventItem( player, eventItemId, eventId, castTime, targetId );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue