feat: add CastPetAction, TogglePetAutocast, PetDismiss, IsPetAttackActive

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.
This commit is contained in:
Kelsi 2026-03-22 22:37:24 -07:00
parent 3f3ed22f78
commit ee6551b286

View file

@ -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<int>(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<int>(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())