From dec41628ad5903a4c35737c352eee70e6e12b2fb Mon Sep 17 00:00:00 2001 From: DuvelCorp Date: Sun, 13 Sep 2026 09:54:04 +0200 Subject: [PATCH] Fix pet loyalty notifications and trim level-up copy - Loyalty now read from MTH_GetCurrentPetInfo().loyaltyLevel; GetPetLoyalty() returns a localized name (not a number), so the loyalty branch never fired - Listen for UNIT_HAPPINESS so a loyalty gain actually triggers the check - Drop redundant 'has leveled up' / 'is now ' openers from pet and loyalty lines, keeping the sarcasm --- api/core-level-tracking.lua | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/api/core-level-tracking.lua b/api/core-level-tracking.lua index 935d8d5..e07f5ef 100644 --- a/api/core-level-tracking.lua +++ b/api/core-level-tracking.lua @@ -87,20 +87,20 @@ local MTH_LT_Priority = { } local MTH_LT_PetLines = { - "has leveled up. It is now statistically better than your last pull.", - "has leveled up. The food budget has noticed.", - "has leveled up. Please do not celebrate by pulling three extra mobs.", - "has leveled up. It remains committed to solving problems with teeth.", - "has leveled up. The wilderness has filed no objection.", - "has leveled up. Your dependable colleague is carrying this team again.", + "It is now statistically better than your last pull.", + "The food budget has noticed.", + "Please do not celebrate by pulling three extra mobs.", + "It remains committed to solving problems with teeth.", + "The wilderness has filed no objection.", + "Your dependable colleague is carrying this team again.", } local MTH_LT_LoyaltyLines = { - [2] = "is now Unruly. It tolerates your leadership as long as the food arrives on time.", - [3] = "is now Submissive. Your authority has been acknowledged, reluctantly.", - [4] = "is now Dependable. It has decided your plans are survivable often enough.", - [5] = "is now Faithful. Please do not reward this trust with an elite pull.", - [6] = "is your Best Friend. Against all evidence, it trusts you completely.", + [2] = "It tolerates your leadership as long as the food arrives on time.", + [3] = "Your authority has been acknowledged, reluctantly.", + [4] = "It has decided your plans are survivable often enough.", + [5] = "Please do not reward this trust with an elite pull.", + [6] = "Against all evidence, it trusts you completely.", } local function MTH_LT_Store() @@ -273,9 +273,13 @@ local function MTH_LT_GetPetState() local level = type(UnitLevel) == "function" and tonumber(UnitLevel("pet")) or nil local name = type(UnitName) == "function" and UnitName("pet") or "Your pet" if not level or level <= 0 then return nil end + -- Loyalty is a localized name via GetPetLoyalty(); reuse the pet service which + -- parses it (plus UI fallbacks) into a numeric 1-6 level. local loyalty = nil - local getPetLoyalty = (type(getglobal) == "function" and getglobal("GetPetLoyalty")) or (_G and _G["GetPetLoyalty"]) - if type(getPetLoyalty) == "function" then loyalty = tonumber(getPetLoyalty()) end + if type(MTH_GetCurrentPetInfo) == "function" then + local info = MTH_GetCurrentPetInfo() + if type(info) == "table" then loyalty = tonumber(info.loyaltyLevel) or nil end + end return { key = tostring(name or "pet"), name = tostring(name or "Your pet"), level = level, loyalty = loyalty } end @@ -296,7 +300,7 @@ local function MTH_LT_HandlePetState() MTH_LT_HandlePetGrowlLevel(state.name, state.level) end if state.loyalty and state.loyalty > 1 and state.loyalty > (tonumber(pet.loyalty) or 0) then - local line = MTH_LT_LoyaltyLines[state.loyalty] or "has gained a loyalty level. The food arrangement appears to be working." + local line = MTH_LT_LoyaltyLines[state.loyalty] or "The food arrangement appears to be working." if MTH_LT_MessageEnabled("petLoyaltyUp", true) then MTH:Print(state.name .. " reached Loyalty Level " .. state.loyalty .. ". " .. line) end if type(MTH_FX_IsEnabled) == "function" and MTH_FX_IsEnabled("level.loyalty") and type(MTH_Celebrate) == "function" then MTH_Celebrate(state.name .. " - Loyalty " .. state.loyalty, line, state.loyalty == 6 and "victory" or "fanfare") @@ -333,7 +337,7 @@ function MTH_LevelTracker_Test(kind, level) return false end local petName = state and state.name or "Your pet" - local line = MTH_LT_LoyaltyLines[loyalty] or "has gained a loyalty level. The food arrangement appears to be working." + local line = MTH_LT_LoyaltyLines[loyalty] or "The food arrangement appears to be working." MTH:Print(petName .. " reached Loyalty Level " .. tostring(loyalty) .. ". " .. line) if type(MTH_Celebrate) == "function" then MTH_Celebrate(petName .. " - Loyalty " .. tostring(loyalty), line, loyalty == 6 and "victory" or "fanfare") @@ -351,6 +355,7 @@ function MTH_LevelTracker_Initialize() MTH_LT_Frame:RegisterEvent("UNIT_LEVEL") MTH_LT_Frame:RegisterEvent("UNIT_PET") MTH_LT_Frame:RegisterEvent("PET_BAR_UPDATE") + MTH_LT_Frame:RegisterEvent("UNIT_HAPPINESS") MTH_LT_Frame:SetScript("OnEvent", function() if event == "PLAYER_ENTERING_WORLD" then local level = type(UnitLevel) == "function" and tonumber(UnitLevel("player")) or nil @@ -364,6 +369,8 @@ function MTH_LevelTracker_Initialize() MTH_LT_RequestPetCheck() elseif event == "PET_BAR_UPDATE" then MTH_LT_RequestPetCheck() + elseif event == "UNIT_HAPPINESS" then + MTH_LT_RequestPetCheck() end end) end