From 3cecd151744f92194cbb2406ba9c3cbecfb8fd68 Mon Sep 17 00:00:00 2001 From: claywar Date: Tue, 7 May 2024 12:56:21 -0400 Subject: [PATCH] [packet] Implement C->S 0x119, S->C 0x11A - Emote List --- scripts/enum/key_item.lua | 1 + src/map/packet_system.cpp | 12 +++++ src/map/packets/CMakeLists.txt | 2 + src/map/packets/char_emote_list.cpp | 63 ++++++++++++++++++++++++ src/map/packets/char_emote_list.h | 76 +++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 src/map/packets/char_emote_list.cpp create mode 100644 src/map/packets/char_emote_list.h diff --git a/scripts/enum/key_item.lua b/scripts/enum/key_item.lua index 8689e00d464..1de61d168dc 100644 --- a/scripts/enum/key_item.lua +++ b/scripts/enum/key_item.lua @@ -2763,6 +2763,7 @@ xi.keyItem = SHADOW_THRONE = 2833, LEAF_BENCH = 2834, ASTRAL_CUBE = 2835, + CHOCOBO_CHAIR_II = 2836, REISENJIMA_SANCTORIUM_ORB = 2837, SAKURA_AND_THE_MAGICKED_NET = 2838, REAPER = 2839, diff --git a/src/map/packet_system.cpp b/src/map/packet_system.cpp index 05fb56f6471..2e336f46690 100644 --- a/src/map/packet_system.cpp +++ b/src/map/packet_system.cpp @@ -96,6 +96,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "packets/char_abilities.h" #include "packets/char_appearance.h" #include "packets/char_check.h" +#include "packets/char_emote_list.h" #include "packets/char_emotion.h" #include "packets/char_emotion_jump.h" #include "packets/char_equip.h" @@ -8313,6 +8314,16 @@ void SmallPacket0x118(map_session_data_t* const PSession, CCharEntity* const PCh } } +/************************************************************************ + * * + * Request Emote List * + * * + ************************************************************************/ +void SmallPacket0x119(map_session_data_t* const PSession, CCharEntity* const PChar, CBasicPacket& data) +{ + PChar->pushPacket(new CCharEmoteListPacket(PChar)); +} + /************************************************************************ * * * Set Job Master Display * @@ -8480,6 +8491,7 @@ void PacketParserInitialize() PacketSize[0x116] = 0x00; PacketParser[0x116] = &SmallPacket0x116; PacketSize[0x117] = 0x00; PacketParser[0x117] = &SmallPacket0x117; PacketSize[0x118] = 0x00; PacketParser[0x118] = &SmallPacket0x118; + PacketSize[0x119] = 0x00; PacketParser[0x119] = &SmallPacket0x119; PacketSize[0x11B] = 0x00; PacketParser[0x11B] = &SmallPacket0x11B; PacketSize[0x11D] = 0x00; PacketParser[0x11D] = &SmallPacket0x11D; // clang-format on diff --git a/src/map/packets/CMakeLists.txt b/src/map/packets/CMakeLists.txt index 1a41f17156d..117f0b6f28e 100644 --- a/src/map/packets/CMakeLists.txt +++ b/src/map/packets/CMakeLists.txt @@ -34,6 +34,8 @@ set(PACKET_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/char_appearance.h ${CMAKE_CURRENT_SOURCE_DIR}/char_check.cpp ${CMAKE_CURRENT_SOURCE_DIR}/char_check.h + ${CMAKE_CURRENT_SOURCE_DIR}/char_emote_list.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/char_emote_list.h ${CMAKE_CURRENT_SOURCE_DIR}/char_emotion.cpp ${CMAKE_CURRENT_SOURCE_DIR}/char_emotion.h ${CMAKE_CURRENT_SOURCE_DIR}/char_emotion_jump.cpp diff --git a/src/map/packets/char_emote_list.cpp b/src/map/packets/char_emote_list.cpp new file mode 100644 index 00000000000..a79ca6d7acd --- /dev/null +++ b/src/map/packets/char_emote_list.cpp @@ -0,0 +1,63 @@ +/* +=========================================================================== + + Copyright (c) 2024 LandSandBoat Dev Teams + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/ + +=========================================================================== +*/ + +#include "char_emote_list.h" +#include "common/socket.h" +#include "entities/baseentity.h" +#include "lua/luautils.h" +#include "utils/charutils.h" + +CCharEmoteListPacket::CCharEmoteListPacket(CCharEntity* PChar) +{ + this->setType(0x11A); + this->setSize(0x0C); + + // RUN and GEO are not sequential with the rest of the list, so grab those two separate offsets first. + // Geomancer begins with bit 20, so create the offset based on an ID with that value subtracted. + auto warriorKeyItem = lua["xi"]["keyItem"]["JOB_GESTURE_WARRIOR"].get(); + auto geomancerKeyItem = lua["xi"]["keyItem"]["JOB_GESTURE_GEOMANCER"].get(); + + uint32 jobEmotes = 0; + for (const auto& keyItemName : jobGestureKeyItems) + { + auto keyItemId = lua["xi"]["keyItem"][keyItemName].get(); + if (charutils::hasKeyItem(PChar, keyItemId)) + { + uint16 bitOffset = keyItemId < geomancerKeyItem ? warriorKeyItem : geomancerKeyItem - 20; + jobEmotes |= 1 << (keyItemId - bitOffset); + } + } + + auto imperialChairKeyItem = lua["xi"]["keyItem"]["IMPERIAL_CHAIR"].get(); + + uint16 chairEmotes = 0; + for (const auto& keyItemName : chairKeyItems) + { + auto keyItemId = lua["xi"]["keyItem"][keyItemName].get(); + if (charutils::hasKeyItem(PChar, keyItemId)) + { + chairEmotes |= 1 << (keyItemId - imperialChairKeyItem); + } + } + + ref(0x04) = jobEmotes; + ref(0x08) = chairEmotes; +} diff --git a/src/map/packets/char_emote_list.h b/src/map/packets/char_emote_list.h new file mode 100644 index 00000000000..1fdc5dd64e9 --- /dev/null +++ b/src/map/packets/char_emote_list.h @@ -0,0 +1,76 @@ +/* +=========================================================================== + + Copyright (c) 2024 LandSandBoat Dev Teams + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/ + +=========================================================================== +*/ + +#ifndef _CCHAREMOTELIST_H +#define _CCHAREMOTELIST_H + +#include "common/cbasetypes.h" + +#include "basic.h" + +std::vector const jobGestureKeyItems = { + "JOB_GESTURE_WARRIOR", + "JOB_GESTURE_MONK", + "JOB_GESTURE_WHITE_MAGE", + "JOB_GESTURE_BLACK_MAGE", + "JOB_GESTURE_RED_MAGE", + "JOB_GESTURE_THIEF", + "JOB_GESTURE_PALADIN", + "JOB_GESTURE_DARK_KNIGHT", + "JOB_GESTURE_BEASTMASTER", + "JOB_GESTURE_BARD", + "JOB_GESTURE_RANGER", + "JOB_GESTURE_SAMURAI", + "JOB_GESTURE_NINJA", + "JOB_GESTURE_DRAGOON", + "JOB_GESTURE_SUMMONER", + "JOB_GESTURE_BLUE_MAGE", + "JOB_GESTURE_CORSAIR", + "JOB_GESTURE_PUPPETMASTER", + "JOB_GESTURE_DANCER", + "JOB_GESTURE_SCHOLAR", + "JOB_GESTURE_GEOMANCER", + "JOB_GESTURE_RUNE_FENCER", +}; + +std::vector const chairKeyItems = { + "IMPERIAL_CHAIR", + "DECORATIVE_CHAIR", + "ORNATE_STOOL", + "REFINED_CHAIR", + "PORTABLE_CONTAINER", + "CHOCOBO_CHAIR", + "EPHRAMADIAN_THRONE", + "SHADOW_THRONE", + "LEAF_BENCH", + "ASTRAL_CUBE", + "CHOCOBO_CHAIR_II", +}; + +class CCharEntity; + +class CCharEmoteListPacket : public CBasicPacket +{ +public: + CCharEmoteListPacket(CCharEntity* PChar); +}; + +#endif