From 2f0d7294dfcfb8d010e4726e0cf06b8f04f07728 Mon Sep 17 00:00:00 2001 From: avitasia Date: Mon, 2 Mar 2026 08:46:07 -0800 Subject: [PATCH] add NP_PreserveGreaterDemonAutocast --- Localization.lua | 6 ++++++ helper.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ settings.lua | 20 ++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/Localization.lua b/Localization.lua index a8dcb82..2c372a2 100644 --- a/Localization.lua +++ b/Localization.lua @@ -160,6 +160,9 @@ L:RegisterTranslations("enUS", function() ["Enable GUID Unit Event Filtering"] = true, ["When enabled, suppresses high-frequency GUID events that cause spam in older addons — specifically UNIT_AURA, UNIT_HEALTH, UNIT_MANA, and similar events below UNIT_COMBAT, plus UNIT_NAME_UPDATE, UNIT_PORTRAIT_UPDATE, UNIT_INVENTORY_CHANGED, and PLAYER_GUILD_UPDATE. UNIT_COMBAT_GUID and other less frequent GUID events are still fired. Has no effect if Enable GUID Unit Events is disabled. This is a direct replacement for the 'Filter GUID Events' option in PerfBoost."] = true, + + ["Preserve Greater Demon Autocast"] = true, + ["Whether to remember and restore Felguard/Doomguard autocast preferences when swapping or resummoning those greater demons."] = true, } end) @@ -323,5 +326,8 @@ L:RegisterTranslations("zhCN", function() ["Enable GUID Unit Event Filtering"] = "启用GUID单位事件过滤", ["When enabled, suppresses high-frequency GUID events that cause spam in older addons — specifically UNIT_AURA, UNIT_HEALTH, UNIT_MANA, and similar events below UNIT_COMBAT, plus UNIT_NAME_UPDATE, UNIT_PORTRAIT_UPDATE, UNIT_INVENTORY_CHANGED, and PLAYER_GUILD_UPDATE. UNIT_COMBAT_GUID and other less frequent GUID events are still fired. Has no effect if Enable GUID Unit Events is disabled. This is a direct replacement for the 'Filter GUID Events' option in PerfBoost."] = "启用后,将屏蔽对旧版插件造成刷屏的高频 GUID 事件——具体包括 UNIT_COMBAT 以下的事件(如 UNIT_AURA、UNIT_HEALTH、UNIT_MANA 等),以及 UNIT_NAME_UPDATE、UNIT_PORTRAIT_UPDATE、UNIT_INVENTORY_CHANGED 和 PLAYER_GUILD_UPDATE。UNIT_COMBAT_GUID 及其他低频 GUID 事件仍会正常触发。若已禁用「启用GUID单位事件」,则此设置无效。此选项直接替代 PerfBoost 中的「过滤GUID事件」功能。", + + ["Preserve Greater Demon Autocast"] = "保留大型恶魔自动施法", + ["Whether to remember and restore Felguard/Doomguard autocast preferences when swapping or resummoning those greater demons."] = "切换或重新召唤地狱守卫/末日守卫时,是否记忆并恢复其自动施法设置。", } end) diff --git a/helper.lua b/helper.lua index 203768f..3aab435 100644 --- a/helper.lua +++ b/helper.lua @@ -768,3 +768,47 @@ end --Nampower:RegisterEvent("UNIT_COMBAT", onUnitCombat) --Nampower:RegisterEvent("UNIT_COMBAT_GUID", onUnitCombatGuid) + +-- SPELL_CAST_EVENT - fires when you (or certain pets) initiate a spell cast +-- Triggered client-side before the cast is sent to the server. +-- Only fires for spells you initiated. +-- Parameters: +-- success (int) - 1 if cast succeeded, 0 if failed +-- spellId (int) - spell ID +-- castType (int) - see Cast Type Constants below +-- targetGuid (string) - guid string like "0xF5300000000000A5" +-- itemId (int) - item ID that triggered the spell, 0 if not item-triggered + +-- Cast Type Constants +local CAST_TYPE_NORMAL = 0 +local CAST_TYPE_NON_GCD = 1 +local CAST_TYPE_ON_SWING = 2 +local CAST_TYPE_CHANNEL = 3 +local CAST_TYPE_TARGETING = 4 +local CAST_TYPE_TARGETING_NON_GCD = 5 + +local CAST_TYPE_NAMES = { + [0] = "Normal", + [1] = "NonGCD", + [2] = "OnSwing", + [3] = "Channel", + [4] = "Targeting", + [5] = "TargetingNonGCD", +} + +function GetCastTypeName(castType) + return CAST_TYPE_NAMES[castType] or "Unknown" +end + +local function onSpellCastEvent(success, spellId, castType, targetGuid, itemId) + local spellName = GetSpellRecField and GetSpellRecField(spellId, "name") or spellId + local castTypeName = GetCastTypeName(castType) + local successText = success == 1 and "OK" or "FAILED" + local itemText = itemId ~= 0 and (" | Item: " .. tostring(itemId)) or "" + print(string.format( + "SPELL_CAST_EVENT: [%s] %s (id:%d) | Type: %s | Target: %s%s", + successText, tostring(spellName), spellId, castTypeName, tostring(targetGuid), itemText + )) +end + +--Nampower:RegisterEvent("SPELL_CAST_EVENT", onSpellCastEvent) diff --git a/settings.lua b/settings.lua index 5838495..1d39e15 100644 --- a/settings.lua +++ b/settings.lua @@ -1074,6 +1074,26 @@ if Nampower:HasMinimumVersion(2, 39, 0) then } end +if Nampower:HasMinimumVersion(3, 1, 0) then + Nampower.cmdtable.args.qol_options.args.NP_PreserveGreaterDemonAutocast = { + type = "toggle", + name = L["Preserve Greater Demon Autocast"], + desc = L["Whether to remember and restore Felguard/Doomguard autocast preferences when swapping or resummoning those greater demons."], + order = 25, + get = function() + return GetCVar("NP_PreserveGreaterDemonAutocast") == "1" + end, + set = function(v) + Nampower.db.profile.NP_PreserveGreaterDemonAutocast = v + if v == true then + SetCVar("NP_PreserveGreaterDemonAutocast", "1") + else + SetCVar("NP_PreserveGreaterDemonAutocast", "0") + end + end, + } +end + local deuce = Nampower:NewModule("Nampower Options Menu") deuce.hasFuBar = IsAddOnLoaded("FuBar") and FuBar deuce.consoleCmd = not deuce.hasFuBar