From bb6f017ff55d81990d705531f735ae7f7dd64d2e Mon Sep 17 00:00:00 2001 From: neonvoidx Date: Sat, 13 Jun 2026 22:13:40 -0400 Subject: [PATCH] Adds /pw i, to toggle instance pets This only matters if /pw a is enabled, otherwise it is ignored. /pw i or /pw instance toggles true/false. If disabled, then when entering any instance pet will be desummoned. Upon leaving an instance the behavior returns to existing options. Defaults to true so it's backwards compatible. --- events.lua | 4 ++++ init.lua | 1 + main.lua | 12 ++++++++++++ ui.lua | 15 +++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/events.lua b/events.lua index 559dd2b..b5e754b 100644 --- a/events.lua +++ b/events.lua @@ -114,6 +114,10 @@ local function PLAYER_ENTERING_WORLD(is_login, is_reload) end ns.pet_verified = false C_TimerAfter(delay, function() + if not is_login and not is_reload and ns.is_instance_summoning_blocked() then + ns.dismiss_current_pet() + return + end ns.transitioncheck() -- For the moment, calling this separately, since `transitioncheck` in its current form is abortable ns.events:register_summon_events() diff --git a/init.lua b/init.lua index 64ba511..537988a 100644 --- a/init.lua +++ b/init.lua @@ -34,6 +34,7 @@ local defaults_global = { recentPets = {}, eventAlt = nil, debugMode = false, + instanceSummoning = true, } local defaults_perchar = { diff --git a/main.lua b/main.lua index cabe1fe..7e3b52b 100755 --- a/main.lua +++ b/main.lua @@ -118,6 +118,18 @@ local function forbidden_instance() local _, _, difficulty_id = GetInstanceInfo() if difficulty_id == 8 then return true end end + return not ns.db.instanceSummoning +end + +function ns.dismiss_current_pet() + local actpet = C_PetJournal_GetSummonedPetGUID() + if actpet then + C_PetJournal_SummonPetByGUID(actpet) + end +end + +function ns.is_instance_summoning_blocked() + return forbidden_instance() end -- To test against if pet-on-back aura is found (AFAIK, only Daisy) diff --git a/ui.lua b/ui.lua index dd831e4..b7b9dd4 100755 --- a/ui.lua +++ b/ui.lua @@ -9,6 +9,7 @@ local C_PetJournal_GetBattlePetLink = _G.C_PetJournal.GetBattlePetLink local tostring = _G.tostring local format = _G.format local print = _G.print +local IsInInstance = _G.IsInInstance local CHAR_NAME = UnitName 'player' local MAX_NUM_RECENTS = 20 @@ -239,6 +240,8 @@ function ns.help_display(print_bottomspace) {CO.c .. 'v', ' : ', CO.k .. 'Verbosity: ', CO.s .. 'silent ', '(only failures and warnings are printed to chat); ', CO.c .. 'vv ', 'for ', CO.s .. 'medium ', CO.k .. 'verbosity ', '(new summons); ', CO.c .. 'vvv ', 'for ', CO.s .. 'full ', CO.k .. 'verbosity ', '(also restored pets).'}, + {CO.c .. 'i', ' : ', 'Toggle ', CO.k .. 'auto-summoning in instances', '. (Requires ', CO.c .. '/pw a', ' to be enabled.)'}, + {CO.c .. 's', ' : ', 'Display current ', CO.k .. 'status/settings.'}, {CO.c .. 'h', ' : ', 'This help text.'}, @@ -270,6 +273,8 @@ function ns.status_display(print_topsep, print_bottomsep) {CO.k .. 'Summon Timer ', 'is ', CO.s .. (ns.db.newPetTimer > 0 and (ns.db.newPetTimer/60) .. CO.bn .. ' minutes' or 'disabled'), '. Next random pet in ', CO.e .. ns.remaining_timer_for_display(), '.'}, + {CO.k ..'Auto-summoning in instances ', 'is ', CO.s .. (ns.db.instanceSummoning and 'enabled' or CO.bw .. 'disabled'), '.'}, + {CO.k ..'Automatic summoning while mounted for Skyriding ', 'is ', CO.s .. (ns.db.drSummoning and 'allowed' or 'not allowed'), '.'}, {CO.k .. 'History ', 'of Previous Pets: ', CO.s .. ns.db.numRecents - 1, ' (1 to ' .. MAX_NUM_RECENTS .. ').'}, @@ -359,6 +364,8 @@ function SlashCmdList.PetWalker(msg) ns.status_display(true, true) elseif tonumber(args[1]) then ns:timer_slash_cmd(args[1]) + elseif args[1] == 'i' or args[1] == 'instance' then + ns.instance_summoning_toggle() elseif args[1] == 'sr' then ns.dr_summoning_toggle() elseif args[1] == 't' or args[1] == 'target' then @@ -449,6 +456,14 @@ function ns.charfavs_slash_toggle() -- for slash command only chat_user_notification(format('%sCharacter-specific favorites %s for %s%s.', CO.bn, ns.dbc.charFavsEnabled and 'enabled' or 'disabled', CO.e, CHAR_NAME)) end +function ns.instance_summoning_toggle() + ns.db.instanceSummoning = not ns.db.instanceSummoning + if not ns.db.instanceSummoning and IsInInstance() then + ns.dismiss_current_pet() + end + chat_user_notification(format('%sPet auto-summoning in instances %s.', CO.bn, ns.db.instanceSummoning and 'enabled' or 'disabled')) +end + function ns.dr_summoning_toggle() ns.db.drSummoning = not ns.db.drSummoning chat_user_notification(format('%sSummoning while mounted for Skyriding %s.', CO.bn, ns.db.drSummoning and 'enabled' or 'disabled'))