diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index cdaae38c..261a3105 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -535,6 +535,10 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System GameMessages::HandleBBBSaveRequest(inStream, entity, sysAddr); break; + case GAME_MSG_CONTROL_BEHAVIOR: + GameMessages::HandleControlBehaviors(inStream, entity, sysAddr); + break; + case GAME_MSG_PROPERTY_ENTRANCE_SYNC: GameMessages::HandlePropertyEntranceSync(inStream, entity, sysAddr); break; diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 292afc71..ba410b70 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -2420,6 +2420,42 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* SEND_PACKET; } +void GameMessages::SendSmash(Entity* entity, float force, float ghostOpacity, LWOOBJID killerID, bool ignoreObjectVisibility) { + CBITSTREAM + CMSGHEADER + + bitStream.Write(entity->GetObjectID()); + bitStream.Write(GAME_MSG::GAME_MSG_SMASH); + + bitStream.Write(ignoreObjectVisibility); + bitStream.Write(force); + bitStream.Write(ghostOpacity); + bitStream.Write(killerID); + + SEND_PACKET_BROADCAST +} + +void GameMessages::SendUnSmash(Entity* entity, LWOOBJID builderID, float duration) { + CBITSTREAM + CMSGHEADER + + bitStream.Write(entity->GetObjectID()); + bitStream.Write(GAME_MSG::GAME_MSG_UNSMASH); + + bitStream.Write(builderID != LWOOBJID_EMPTY); + if (builderID != LWOOBJID_EMPTY) bitStream.Write(builderID); + + bitStream.Write(duration != 3.0f); + if (duration != 3.0f) bitStream.Write(duration); + + SEND_PACKET_BROADCAST +} + +void GameMessages::HandleControlBehaviors(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { + // TODO + Game::logger->Log("GameMessages", "Recieved Control Behavior GameMessage, but property behaviors are unimplemented.\n"); +} + void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { /* ___ ___ diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 18e1467e..fc49ad70 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -122,6 +122,39 @@ namespace GameMessages { void SendStartCelebrationEffect(Entity* entity, const SystemAddress& sysAddr, int celebrationID); + /** + * Sends a message to an Entity to smash itself, but not delete or destroy itself from the world + * + * @param entity The Entity that will smash itself into bricks + * @param force The force the Entity will be smashed with + * @param ghostOpacity The ghosting opacity of the smashed Entity + * @param killerID The Entity that invoked the smash, if none exists, this should be LWOOBJID_EMPTY + * @param ignoreObjectVisibility Whether or not to ignore the objects visibility + */ + void SendSmash(Entity* entity, float force, float ghostOpacity, LWOOBJID killerID, bool ignoreObjectVisibility = false); + + /** + * Sends a message to an Entity to UnSmash itself (aka rebuild itself over a duration) + * + * @param entity The Entity that will UnSmash itself + * @param builderID The Entity that invoked the build (LWOOBJID_EMPTY if none exists or invoked the rebuild) + * @param duration The duration for the Entity to rebuild over. 3 seconds by default + */ + void SendUnSmash(Entity* entity, LWOOBJID builderID = LWOOBJID_EMPTY, float duration = 3.0f); + + /** + * @brief This GameMessage is the one that handles all of the property behavior incoming messages from the client. + * + * The GameMessage struct can be located here https://lcdruniverse.org/lu_packets/lu_packets/world/gm/server/struct.ControlBehaviors.html + * For information on the AMF3 format can be found here https://rtmp.veriskope.com/pdf/amf3-file-format-spec.pdf + * For any questions regarding AMF3 you can contact EmosewaMC on GitHub + * + * @param inStream The incoming data sent from the client + * @param entity The Entity that sent the message + * @param sysAddr The SystemAddress that sent the message + */ + void HandleControlBehaviors(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); + // Rails stuff void SendSetRailMovement(const LWOOBJID& objectID, bool pathGoForward, std::u16string pathName, uint32_t pathStart, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS, diff --git a/dNet/dMessageIdentifiers.h b/dNet/dMessageIdentifiers.h index 5ad3921c..cb46b5d1 100644 --- a/dNet/dMessageIdentifiers.h +++ b/dNet/dMessageIdentifiers.h @@ -274,6 +274,7 @@ enum GAME_MSG : unsigned short { GAME_MSG_REQUEST_DIE = 38, GAME_MSG_PLAY_EMOTE = 41, GAME_MSG_PLAY_ANIMATION = 43, + GAME_MSG_CONTROL_BEHAVIOR = 48, GAME_MSG_SET_NAME = 72, GAME_MSG_ECHO_START_SKILL = 118, GAME_MSG_START_SKILL = 119, @@ -345,6 +346,8 @@ enum GAME_MSG : unsigned short { GAME_MSG_DISPLAY_MESSAGE_BOX = 529, GAME_MSG_MESSAGE_BOX_RESPOND = 530, GAME_MSG_CHOICE_BOX_RESPOND = 531, + GAME_MSG_SMASH = 537, + GAME_MSG_UNSMASH = 538, GAME_MSG_SET_SHOOTING_GALLERY_RETICULE_EFFECT = 548, GAME_MSG_PLACE_MODEL_RESPONSE = 0x223, GAME_MSG_SET_JET_PACK_MODE = 561,