diff --git a/Localization.lua b/Localization.lua index 6aea140..72c418d 100644 --- a/Localization.lua +++ b/Localization.lua @@ -47,12 +47,18 @@ L:RegisterTranslations("enUS", function() ["Cooldown Queue Window (ms)"] = true, ["The window in ms before a spell coming off cooldown finishes where the next will get queued"] = true, + ["Cast Options"] = true, + ["Options for controlling casting behavior"] = true, + ["Advanced options"] = true, ["Collection of various advanced options"] = true, ["Double Cast to End Channel Early"] = true, ["Whether to allow double casting a spell within 350ms to end channeling on the next tick. Takes into account your ChannelLatencyReductionPercentage."] = true, + ["Quickcast Targeting Spells on Double Cast"] = true, + ["Allows casting targeting spells by attempting to cast them twice as opposed to the default client behavior which cancels the targeting indicator"] = true, + ["Interrupt Channels Outside Queue Window"] = true, ["Whether to allow interrupting channels (the original client behavior) when trying to cast a spell outside the channeling queue window"] = true, @@ -161,12 +167,18 @@ L:RegisterTranslations("zhCN", function() ["Cooldown Queue Window (ms)"] = "冷却结束队列窗口(ms)", ["The window in ms before a spell coming off cooldown finishes where the next will get queued"] = "法术冷却结束前多少毫秒(ms)可将该法术加入队列", + ["Cast Options"] = "施法选项", + ["Options for controlling casting behavior"] = "控制施法行为的选项", + ["Advanced options"] = "高级选项", ["Collection of various advanced options"] = "各类高级选项集合", ["Double Cast to End Channel Early"] = "双重施法提前结束引导", ["Whether to allow double casting a spell within 350ms to end channeling on the next tick. Takes into account your ChannelLatencyReductionPercentage."] = "是否允许350毫秒内双重施法以在下一个伤害周期提前结束引导。受引导延迟削减比例影响。", + ["Quickcast Targeting Spells on Double Cast"] = "双重施法快速施放目标区域法术", + ["Allows casting targeting spells by attempting to cast them twice as opposed to the default client behavior which cancels the targeting indicator"] = "允许通过双次尝试施法来释放目标区域法术,而非默认客户端行为(取消目标指示器)", + ["Interrupt Channels Outside Queue Window"] = "队列窗口外允许打断引导", ["Whether to allow interrupting channels (the original client behavior) when trying to cast a spell outside the channeling queue window"] = "在引导法术队列窗口外尝试施法时,是否允许打断引导(默认客户端行为)", diff --git a/NampowerSettings.toc b/NampowerSettings.toc index b276df1..d6b6fa3 100644 --- a/NampowerSettings.toc +++ b/NampowerSettings.toc @@ -22,3 +22,4 @@ libs\FuBarPlugin\FuBarPlugin-2.0.lua Localization.lua settings.lua +helper.lua diff --git a/helper.lua b/helper.lua new file mode 100644 index 0000000..fff32ca --- /dev/null +++ b/helper.lua @@ -0,0 +1,110 @@ +if not Nampower:HasMinimumVersion(2, 14, 0) then + return +end + +local function GetSpellMod(num) + local modifierTypes = { + [0] = "DAMAGE", + [1] = "DURATION", + [2] = "THREAT", + [3] = "ATTACK_POWER", + [4] = "CHARGES", + [5] = "RANGE", + [6] = "RADIUS", + [7] = "CRITICAL_CHANCE", + [8] = "ALL_EFFECTS", + [9] = "NOT_LOSE_CASTING_TIME", + [10] = "CASTING_TIME", + [11] = "COOLDOWN", + [12] = "SPEED", + [14] = "COST", + [15] = "CRIT_DAMAGE_BONUS", + [16] = "RESIST_MISS_CHANCE", + [17] = "JUMP_TARGETS", + [18] = "CHANCE_OF_SUCCESS", + [19] = "ACTIVATION_TIME", + [20] = "EFFECT_PAST_FIRST", + [21] = "CASTING_TIME_OLD", + [22] = "DOT", + [23] = "HASTE", + [24] = "SPELL_BONUS_DAMAGE", + [27] = "MULTIPLE_VALUE", + [28] = "RESIST_DISPEL_CHANCE" + } + return modifierTypes[num] or "UNKNOWN" +end + +function PrintTable(tbl, indent) + indent = indent or 0 + local prefix = string.rep(" ", indent) + + for k, v in pairs(tbl) do + if type(v) == "table" then + print(prefix .. tostring(k) .. ":") + PrintTable(v, indent + 1) + else + print(prefix .. tostring(k) .. ": " .. tostring(v)) + end + end +end + +if CombatLogAdd then + function PrintTableToCombatLog(tbl, indent) + indent = indent or 0 + local prefix = string.rep(" ", indent) + + for k, v in pairs(tbl) do + if type(v) == "table" then + CombatLogAdd(prefix .. tostring(k) .. ":") + PrintTableToCombatLog(v, indent + 1) + else + CombatLogAdd(prefix .. tostring(k) .. ": " .. tostring(v)) + end + end + end + + function LogUnitData(unit) + local data = GetUnitData(unit) + if data then + PrintTableToCombatLog(data) + else + print("No unit data available") + end + end + + function LogSpellData(spellId) + local data = GetSpellRec(spellId) + if data then + PrintTableToCombatLog(data) + else + print("No spell data available") + end + end +end + +function PrintUnitData(unit) + local data = GetUnitData(unit) + if data then + PrintTable(data) + else + print("No unit data available") + end +end + +function PrintSpellMods(spellId) + for i = 0, 28 do + local flatMod, percentMod, ret = GetSpellModifiers(spellId, i) + if ret > 0 then + print(GetSpellMod(i) .. " (" .. tostring(i) .. "): flat:" .. tostring(flatMod) .. " percent:" .. tostring(percentMod)) + end + end +end + +function PrintSpellData(spellId) + local data = GetSpellRec(spellId) + if data then + PrintTable(data) + else + print("No spell data available") + end +end diff --git a/settings.lua b/settings.lua index b3830fd..c6cd21d 100644 --- a/settings.lua +++ b/settings.lua @@ -1,8 +1,7 @@ local L = AceLibrary("AceLocale-2.2"):new("NampowerSettings") -- No Nampower v2, no need for settings -local has_v2_nampower = pcall(GetCVar, "NP_QueueCastTimeSpells") -if not has_v2_nampower then +if not GetNampowerVersion then DEFAULT_CHAT_FRAME:AddMessage(L["|cffffcc00Nampower v2|cffffaaaa not present hiding settings."]) return end @@ -394,17 +393,34 @@ Nampower.cmdtable = { name = " ", order = 50, }, - advanced_options = { + cast_options = { type = "group", - name = L["Advanced options"], - desc = L["Collection of various advanced options"], - order = 60, + name = L["Cast Options"], + desc = L["Options for controlling casting behavior"], + order = 55, args = { + NP_QuickcastTargetingSpells = { + type = "toggle", + name = L["Quickcast Targeting Spells"], + desc = L["Whether to enable quick casting for ALL spells with terrain targeting"], + order = 5, + get = function() + return GetCVar("NP_QuickcastTargetingSpells") == "1" + end, + set = function(v) + Nampower.db.profile.NP_QuickcastTargetingSpells = v + if v == true then + SetCVar("NP_QuickcastTargetingSpells", "1") + else + SetCVar("NP_QuickcastTargetingSpells", "0") + end + end, + }, NP_DoubleCastToEndChannelEarly = { type = "toggle", name = L["Double Cast to End Channel Early"], desc = L["Whether to allow double casting a spell within 350ms to end channeling on the next tick. Takes into account your ChannelLatencyReductionPercentage."], - order = 33, + order = 15, get = function() return GetCVar("NP_DoubleCastToEndChannelEarly") == "1" end, @@ -417,6 +433,19 @@ Nampower.cmdtable = { end end, }, + }, + }, + spacerc2 = { + type = "header", + name = " ", + order = 58, + }, + advanced_options = { + type = "group", + name = L["Advanced options"], + desc = L["Collection of various advanced options"], + order = 60, + args = { NP_InterruptChannelsOutsideQueueWindow = { type = "toggle", name = L["Interrupt Channels Outside Queue Window"], @@ -451,23 +480,6 @@ Nampower.cmdtable = { end end, }, - NP_QuickcastTargetingSpells = { - type = "toggle", - name = L["Quickcast Targeting Spells"], - desc = L["Whether to enable quick casting for ALL spells with terrain targeting"], - order = 105, - get = function() - return GetCVar("NP_QuickcastTargetingSpells") == "1" - end, - set = function(v) - Nampower.db.profile.NP_QuickcastTargetingSpells = v - if v == true then - SetCVar("NP_QuickcastTargetingSpells", "1") - else - SetCVar("NP_QuickcastTargetingSpells", "0") - end - end, - }, NP_ReplaceMatchingNonGcdCategory = { type = "toggle", name = L["Replace Matching Non GCD Category"], @@ -649,28 +661,11 @@ Nampower.cmdtable = { }, }, }, - spacer6 = { + spacerd = { type = "header", name = " ", order = 90, }, - NP_PreventRightClickTargetChange = { - type = "toggle", - name = L["Prevent Right Click Target Change"], - desc = L["Whether to prevent right-clicking from changing your current target when in combat. If you don't have a target right click will still change your target even with this on. This is mainly to prevent accidentally changing targets in combat when trying to adjust your camera."], - order = 100, - get = function() - return GetCVar("NP_PreventRightClickTargetChange") == "1" - end, - set = function(v) - Nampower.db.profile.NP_PreventRightClickTargetChange = v - if v == true then - SetCVar("NP_PreventRightClickTargetChange", "1") - else - SetCVar("NP_PreventRightClickTargetChange", "0") - end - end, - }, }, } @@ -693,12 +688,30 @@ if Nampower:HasMinimumVersion(2, 8, 6) then } end +Nampower.cmdtable.args.advanced_options.args.NP_PreventRightClickTargetChange = { + type = "toggle", + name = L["Prevent Right Click Target Change"], + desc = L["Whether to prevent right-clicking from changing your current target when in combat. If you don't have a target right click will still change your target even with this on. This is mainly to prevent accidentally changing targets in combat when trying to adjust your camera."], + order = 140, + get = function() + return GetCVar("NP_PreventRightClickTargetChange") == "1" + end, + set = function(v) + Nampower.db.profile.NP_PreventRightClickTargetChange = v + if v == true then + SetCVar("NP_PreventRightClickTargetChange", "1") + else + SetCVar("NP_PreventRightClickTargetChange", "0") + end + end, +} + if Nampower:HasMinimumVersion(2, 11, 0) then - Nampower.cmdtable.args.NP_SpamProtectionEnabled = { + Nampower.cmdtable.args.advanced_options.args.NP_SpamProtectionEnabled = { type = "toggle", name = L["Spam Protection"], desc = L["Whether to enable spam protection functionality that blocks spamming spells while waiting for the server to respond to your initial cast due to issues spamming can cause"], - order = 120, + order = 135, get = function() return GetCVar("NP_SpamProtectionEnabled") == "1" end, @@ -712,11 +725,11 @@ if Nampower:HasMinimumVersion(2, 11, 0) then end, } - Nampower.cmdtable.args.NP_PreventRightClickPvPAttack = { + Nampower.cmdtable.args.advanced_options.args.NP_PreventRightClickPvPAttack = { type = "toggle", name = L["Prevent Right Click PvP Attack"], desc = L["Whether to prevent right-clicking on PvP flagged players to avoid accidental PvP attacks"], - order = 130, + order = 145, get = function() return GetCVar("NP_PreventRightClickPvPAttack") == "1" end, @@ -733,6 +746,26 @@ else DEFAULT_CHAT_FRAME:AddMessage(L["|cffffcc00Nampower dll update available.|cffffcc00 Some settings may be hidden until you update."]) end +if Nampower:HasMinimumVersion(2, 15, 0) then + Nampower.cmdtable.args.cast_options.args.NP_QuickcastOnDoubleCast = { + type = "toggle", + name = L["Quickcast Targeting Spells on Double Cast"], + desc = L["Allows casting targeting spells by attempting to cast them twice as opposed to the default client behavior which cancels the targeting indicator"], + order = 10, + get = function() + return GetCVar("NP_QuickcastOnDoubleCast") == "1" + end, + set = function(v) + Nampower.db.profile.NP_QuickcastOnDoubleCast = v + if v == true then + SetCVar("NP_QuickcastOnDoubleCast", "1") + else + SetCVar("NP_QuickcastOnDoubleCast", "0") + end + end, + } +end + local deuce = Nampower:NewModule("Nampower Options Menu") deuce.hasFuBar = IsAddOnLoaded("FuBar") and FuBar deuce.consoleCmd = not deuce.hasFuBar