mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-26 16:50:15 +00:00
Add pet tracking via SMSG_PET_SPELLS and dismiss pet button
This commit is contained in:
parent
a1f73fdd39
commit
74b78cd10b
5 changed files with 45 additions and 2 deletions
|
|
@ -1836,6 +1836,9 @@ void GameHandler::handlePacket(network::Packet& packet) {
|
|||
case Opcode::SMSG_GUILD_COMMAND_RESULT:
|
||||
handleGuildCommandResult(packet);
|
||||
break;
|
||||
case Opcode::SMSG_PET_SPELLS:
|
||||
handlePetSpells(packet);
|
||||
break;
|
||||
case Opcode::SMSG_PETITION_SHOWLIST:
|
||||
handlePetitionShowlist(packet);
|
||||
break;
|
||||
|
|
@ -3322,6 +3325,7 @@ void GameHandler::selectCharacter(uint64_t characterGuid) {
|
|||
actionBar = {};
|
||||
playerAuras.clear();
|
||||
targetAuras.clear();
|
||||
petGuid_ = 0;
|
||||
playerXp_ = 0;
|
||||
playerNextLevelXp_ = 0;
|
||||
serverPlayerLevel_ = 1;
|
||||
|
|
@ -9261,6 +9265,18 @@ void GameHandler::cancelAura(uint32_t spellId) {
|
|||
socket->send(packet);
|
||||
}
|
||||
|
||||
void GameHandler::handlePetSpells(network::Packet& packet) {
|
||||
if (packet.getSize() - packet.getReadPos() < 8) return;
|
||||
petGuid_ = packet.readUInt64();
|
||||
LOG_DEBUG("SMSG_PET_SPELLS: petGuid=0x", std::hex, petGuid_, std::dec);
|
||||
}
|
||||
|
||||
void GameHandler::dismissPet() {
|
||||
if (petGuid_ == 0 || state != WorldState::IN_WORLD || !socket) return;
|
||||
auto packet = PetActionPacket::build(petGuid_, 0x07000000);
|
||||
socket->send(packet);
|
||||
}
|
||||
|
||||
void GameHandler::setActionBarSlot(int slot, ActionBarSlot::Type type, uint32_t id) {
|
||||
if (slot < 0 || slot >= ACTION_BAR_SLOTS) return;
|
||||
actionBar[slot].type = type;
|
||||
|
|
|
|||
|
|
@ -2890,6 +2890,13 @@ network::Packet CancelAuraPacket::build(uint32_t spellId) {
|
|||
return packet;
|
||||
}
|
||||
|
||||
network::Packet PetActionPacket::build(uint64_t petGuid, uint32_t action) {
|
||||
network::Packet packet(wireOpcode(Opcode::CMSG_PET_ACTION));
|
||||
packet.writeUInt64(petGuid);
|
||||
packet.writeUInt32(action);
|
||||
return packet;
|
||||
}
|
||||
|
||||
bool CastFailedParser::parse(network::Packet& packet, CastFailedData& data) {
|
||||
data.castCount = packet.readUInt8();
|
||||
data.spellId = packet.readUInt32();
|
||||
|
|
|
|||
|
|
@ -4720,14 +4720,13 @@ void GameScreen::renderGuildRoster(game::GameHandler& gameHandler) {
|
|||
|
||||
void GameScreen::renderBuffBar(game::GameHandler& gameHandler) {
|
||||
const auto& auras = gameHandler.getPlayerAuras();
|
||||
if (auras.empty()) return;
|
||||
|
||||
// Count non-empty auras
|
||||
int activeCount = 0;
|
||||
for (const auto& a : auras) {
|
||||
if (!a.isEmpty()) activeCount++;
|
||||
}
|
||||
if (activeCount == 0) return;
|
||||
if (activeCount == 0 && !gameHandler.hasPet()) return;
|
||||
|
||||
auto* assetMgr = core::Application::getInstance().getAssetManager();
|
||||
|
||||
|
|
@ -4813,6 +4812,16 @@ void GameScreen::renderBuffBar(game::GameHandler& gameHandler) {
|
|||
ImGui::PopID();
|
||||
shown++;
|
||||
}
|
||||
// Dismiss Pet button
|
||||
if (gameHandler.hasPet()) {
|
||||
if (shown > 0) ImGui::Spacing();
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.6f, 0.2f, 0.2f, 0.9f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.3f, 0.3f, 1.0f));
|
||||
if (ImGui::Button("Dismiss Pet", ImVec2(-1, 0))) {
|
||||
gameHandler.dismissPet();
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue