diff --git a/src/common/Network/PacketDef/Ipcs.h b/src/common/Network/PacketDef/Ipcs.h index 0bd3e92c..ee7d3ce8 100644 --- a/src/common/Network/PacketDef/Ipcs.h +++ b/src/common/Network/PacketDef/Ipcs.h @@ -410,6 +410,7 @@ enum ClientZoneIpcType : BuildPresetHandler = 0x0D9, // updated 6.58 hotfix 2 TalkEventHandler = 0x23A, // updated 6.58 hotfix 2 + SayEventHandler = 0x25D, // updated 6.58 hotfix 2 EmoteEventHandler = 0x1B5, // updated 6.58 hotfix 2 WithinRangeEventHandler = 0x38E, // updated 6.58 hotfix 2 OutOfRangeEventHandler = 0x200, // updated 6.58 hotfix 2 diff --git a/src/common/Network/PacketDef/Zone/ClientZoneDef.h b/src/common/Network/PacketDef/Zone/ClientZoneDef.h index 5bfcee7b..7590b8e4 100644 --- a/src/common/Network/PacketDef/Zone/ClientZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ClientZoneDef.h @@ -160,6 +160,13 @@ struct FFXIVIpcEventHandlerTalk : /* 0008 */ uint32_t eventId; }; +struct FFXIVIpcEventHandlerSay : + FFXIVIpcBasePacket< SayEventHandler > +{ + /* 0000 */ uint64_t actorId; + /* 0008 */ uint32_t eventId; +}; + struct FFXIVIpcPingHandler : FFXIVIpcBasePacket< PingHandler > { diff --git a/src/world/Network/GameConnection.cpp b/src/world/Network/GameConnection.cpp index 38c944dd..c2afcd0e 100644 --- a/src/world/Network/GameConnection.cpp +++ b/src/world/Network/GameConnection.cpp @@ -96,6 +96,7 @@ Sapphire::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pH setZoneHandler( ClientZoneIpcType::HousingEditInterior, "HousingEditInterior", &GameConnection::housingEditInterior ); setZoneHandler( ClientZoneIpcType::TalkEventHandler, "EventHandlerTalk", &GameConnection::eventHandlerTalk ); + setZoneHandler( ClientZoneIpcType::SayEventHandler, "EventHandlerSay", &GameConnection::eventHandlerSay ); setZoneHandler( ClientZoneIpcType::EmoteEventHandler, "EventHandlerEmote", &GameConnection::eventHandlerEmote ); setZoneHandler( ClientZoneIpcType::WithinRangeEventHandler, "EventHandlerWithinRange", &GameConnection::eventHandlerWithinRange ); diff --git a/src/world/Network/GameConnection.h b/src/world/Network/GameConnection.h index a49ddad8..b11c62b7 100644 --- a/src/world/Network/GameConnection.h +++ b/src/world/Network/GameConnection.h @@ -133,6 +133,8 @@ namespace Sapphire::Network DECLARE_HANDLER( eventHandlerTalk ); + DECLARE_HANDLER( eventHandlerSay ); + DECLARE_HANDLER( eventHandlerEmote ); DECLARE_HANDLER( eventHandlerWithinRange ); diff --git a/src/world/Network/Handlers/EventHandlers.cpp b/src/world/Network/Handlers/EventHandlers.cpp index 5ae93050..978e6e53 100644 --- a/src/world/Network/Handlers/EventHandlers.cpp +++ b/src/world/Network/Handlers/EventHandlers.cpp @@ -80,6 +80,32 @@ void Sapphire::Network::GameConnection::eventHandlerTalk( const Packets::FFXIVAR } +void Sapphire::Network::GameConnection::eventHandlerSay( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) +{ + auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); + auto& exdData = Common::Service< Data::ExdDataGenerated >::ref(); + auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref(); + + const auto packet = ZoneChannelPacket< Client::FFXIVIpcEventHandlerSay >( inPacket ); + + const auto actorId = packet.data().actorId; + const auto eventId = packet.data().eventId; + + std::string eventName = "onSay"; + std::string objName = eventMgr.getEventName( eventId ); + + player.sendDebug( "Chara: {0} -> {1} \neventId: {2} ({3:08X})", actorId, + eventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ), eventId, eventId ); + + player.sendDebug( "Calling: {0}.{1}", objName, eventName ); + + player.eventStart( actorId, eventId, Event::EventHandler::Say, 0, 0 ); + + scriptMgr.onSay( player, actorId, eventId ); + + player.checkEvent( eventId ); +} + void Sapphire::Network::GameConnection::eventHandlerEmote( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player ) { diff --git a/src/world/Script/NativeScriptApi.cpp b/src/world/Script/NativeScriptApi.cpp index 1702e733..acf1bfc4 100644 --- a/src/world/Script/NativeScriptApi.cpp +++ b/src/world/Script/NativeScriptApi.cpp @@ -99,6 +99,10 @@ namespace Sapphire::ScriptAPI { } + void EventScript::onSay( uint32_t eventId, Entity::Player& player, uint64_t actorId ) + { + } + void EventScript::onBNpcKill( uint32_t nameId, Entity::Player& player ) { } diff --git a/src/world/Script/NativeScriptApi.h b/src/world/Script/NativeScriptApi.h index 315bdad2..a843e6e4 100644 --- a/src/world/Script/NativeScriptApi.h +++ b/src/world/Script/NativeScriptApi.h @@ -150,6 +150,8 @@ namespace Sapphire::ScriptAPI virtual void onTalk( uint32_t eventId, Sapphire::Entity::Player& player, uint64_t actorId ); + virtual void onSay( uint32_t eventId, Sapphire::Entity::Player& player, uint64_t actorId ); + virtual void onBNpcKill( uint32_t nameId, Sapphire::Entity::Player& player ); virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Sapphire::Entity::Player& player ); diff --git a/src/world/Script/ScriptMgr.cpp b/src/world/Script/ScriptMgr.cpp index 718c72be..efb0c0cf 100644 --- a/src/world/Script/ScriptMgr.cpp +++ b/src/world/Script/ScriptMgr.cpp @@ -192,6 +192,17 @@ bool Sapphire::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t ac } } +bool Sapphire::Scripting::ScriptMgr::onSay( Entity::Player& player, uint64_t actorId, uint32_t eventId ) +{ + auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId ); + if( script ) + { + script->onSay( eventId, player, actorId ); + return true; + } + return false; +} + bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) { diff --git a/src/world/Script/ScriptMgr.h b/src/world/Script/ScriptMgr.h index b0a5cb5f..97f0b841 100644 --- a/src/world/Script/ScriptMgr.h +++ b/src/world/Script/ScriptMgr.h @@ -56,6 +56,8 @@ namespace Sapphire::Scripting bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId ); + bool onSay( Entity::Player& player, uint64_t actorId, uint32_t eventId ); + bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ); bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );