From ee6551b286deb637827bdf23e1cc82f6d4e41fc0 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 22 Mar 2026 22:37:24 -0700 Subject: [PATCH] feat: add CastPetAction, TogglePetAutocast, PetDismiss, IsPetAttackActive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete the pet action bar interaction: - CastPetAction(index) — cast the pet spell at the given bar slot by sending the packed action via sendPetAction - TogglePetAutocast(index) — toggle autocast for the pet spell at the given slot via togglePetSpellAutocast - PetDismiss() — send dismiss pet command - IsPetAttackActive() — whether pet is currently in attack mode Together with the previous pet bar functions (HasPetUI, GetPetActionInfo, PetAttack, PetFollow, PetWait, PetPassiveMode, PetDefensiveMode), this completes the pet action bar system for hunters/warlocks/DKs. --- src/addons/lua_engine.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 63ba7595..70b4a137 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -5118,6 +5118,38 @@ void LuaEngine::registerCoreAPI() { gh->sendPetAction(0x00000007 | (0u << 16), 0); // REACT_PASSIVE return 0; }}, + {"CastPetAction", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + int index = static_cast(luaL_checknumber(L, 1)); + if (!gh || !gh->hasPet() || index < 1 || index > game::GameHandler::PET_ACTION_BAR_SLOTS) return 0; + uint32_t packed = gh->getPetActionSlot(index - 1); + uint32_t spellId = packed & 0x00FFFFFF; + if (spellId != 0) { + uint64_t target = gh->hasTarget() ? gh->getTargetGuid() : gh->getPetGuid(); + gh->sendPetAction(packed, target); + } + return 0; + }}, + {"TogglePetAutocast", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + int index = static_cast(luaL_checknumber(L, 1)); + if (!gh || !gh->hasPet() || index < 1 || index > game::GameHandler::PET_ACTION_BAR_SLOTS) return 0; + uint32_t packed = gh->getPetActionSlot(index - 1); + uint32_t spellId = packed & 0x00FFFFFF; + if (spellId != 0) gh->togglePetSpellAutocast(spellId); + return 0; + }}, + {"PetDismiss", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + if (gh && gh->hasPet()) + gh->sendPetAction(0x00000007 | (3u << 24), 0); // CMD_DISMISS + return 0; + }}, + {"IsPetAttackActive", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + lua_pushboolean(L, gh && gh->getPetCommand() == 2 ? 1 : 0); // 2=attack + return 1; + }}, {"PetDefensiveMode", [](lua_State* L) -> int { auto* gh = getGameHandler(L); if (gh && gh->hasPet())