From 4c59f1f13620ef68274a25f5ff2e31aa9ba2adb7 Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Tue, 1 Apr 2025 18:40:26 -0700 Subject: [PATCH] fix faerie fire for real --- Localization.lua | 8 +- spells/druid.lua | 16 +-- utils.lua | 286 ++++++++++++++++++++++++++--------------------- 3 files changed, 170 insertions(+), 140 deletions(-) diff --git a/Localization.lua b/Localization.lua index d427c6f..ae760f0 100644 --- a/Localization.lua +++ b/Localization.lua @@ -100,8 +100,8 @@ L:RegisterTranslations("enUS", function() ["entangling roots"] = true, ["sleep"] = true, ["faerie fire"] = true, - ["faerie fire (bear)"] = true, - ["faerie fire (feral)"] = true, + ["faerie fire (bear)()"] = true, + ["faerie fire (feral)()"] = true, ["hibernate"] = true, ["insect swarm"] = true, ["moonfire"] = true, @@ -273,8 +273,8 @@ L:RegisterTranslations("zhCN", function() ["entangling roots"] = "纠缠根须", ["sleep"] = "沉睡", ["faerie fire"] = "精灵之火", - ["faerie fire (bear)"] = "精灵之火(熊形态)", - ["faerie fire (feral)"] = "精灵之火(野性形态)", + ["faerie fire (bear)()"] = "精灵之火(熊形态)", + ["faerie fire (feral)()"] = "精灵之火(野性形态)", ["hibernate"] = "休眠", ["insect swarm"] = "虫群", ["moonfire"] = "月火术", diff --git a/spells/druid.lua b/spells/druid.lua index bc51118..2252af0 100644 --- a/spells/druid.lua +++ b/spells/druid.lua @@ -17,15 +17,15 @@ function getDruidSpells() [9749] = { name = L["faerie fire"], rank = 3, duration = 40 }, [9907] = { name = L["faerie fire"], rank = 4, duration = 40 }, - [16855] = { name = L["faerie fire (bear)"], rank = 1, duration = 40 }, - [17387] = { name = L["faerie fire (bear)"], rank = 2, duration = 40 }, - [17388] = { name = L["faerie fire (bear)"], rank = 3, duration = 40 }, - [17389] = { name = L["faerie fire (bear)"], rank = 4, duration = 40 }, + [16855] = { name = L["faerie fire (bear)()"], rank = 1, duration = 40 }, + [17387] = { name = L["faerie fire (bear)()"], rank = 2, duration = 40 }, + [17388] = { name = L["faerie fire (bear)()"], rank = 3, duration = 40 }, + [17389] = { name = L["faerie fire (bear)()"], rank = 4, duration = 40 }, - [16857] = { name = L["faerie fire (feral)"], rank = 1, duration = 40 }, - [17390] = { name = L["faerie fire (feral)"], rank = 2, duration = 40 }, - [17391] = { name = L["faerie fire (feral)"], rank = 3, duration = 40 }, - [17392] = { name = L["faerie fire (feral)"], rank = 4, duration = 40 }, + [16857] = { name = L["faerie fire (feral)()"], rank = 1, duration = 40 }, + [17390] = { name = L["faerie fire (feral)()"], rank = 2, duration = 40 }, + [17391] = { name = L["faerie fire (feral)()"], rank = 3, duration = 40 }, + [17392] = { name = L["faerie fire (feral)()"], rank = 4, duration = 40 }, [2637] = { name = L["hibernate"], rank = 1, duration = 20 }, [18657] = { name = L["hibernate"], rank = 2, duration = 30 }, diff --git a/utils.lua b/utils.lua index 8c85076..2f6d6d7 100644 --- a/utils.lua +++ b/utils.lua @@ -1,182 +1,212 @@ if not Cursive.superwow then - return + return end local utils = {} utils.strsplit = function(delimiter, subject) - if not subject then return nil end - local delimiter, fields = delimiter or ":", {} - local pattern = string.format("([^%s]+)", delimiter) - string.gsub(subject, pattern, function(c) fields[table.getn(fields)+1] = c end) - return unpack(fields) + if not subject then + return nil + end + local delimiter, fields = delimiter or ":", {} + local pattern = string.format("([^%s]+)", delimiter) + string.gsub(subject, pattern, function(c) + fields[table.getn(fields) + 1] = c + end) + return unpack(fields) end utils.round = function(input, places) - if not places then places = 0 end - if type(input) == "number" and type(places) == "number" then - local pow = 1 - for i = 1, places do pow = pow * 10 end - return floor(input * pow + 0.5) / pow - end + if not places then + places = 0 + end + if type(input) == "number" and type(places) == "number" then + local pow = 1 + for i = 1, places do + pow = pow * 10 + end + return floor(input * pow + 0.5) / pow + end end utils.IsValidAnchor = function(anchor) - if anchor == "TOP" then return true end - if anchor == "TOPLEFT" then return true end - if anchor == "TOPRIGHT" then return true end - if anchor == "CENTER" then return true end - if anchor == "LEFT" then return true end - if anchor == "RIGHT" then return true end - if anchor == "BOTTOM" then return true end - if anchor == "BOTTOMLEFT" then return true end - if anchor == "BOTTOMRIGHT" then return true end - return false + if anchor == "TOP" then + return true + end + if anchor == "TOPLEFT" then + return true + end + if anchor == "TOPRIGHT" then + return true + end + if anchor == "CENTER" then + return true + end + if anchor == "LEFT" then + return true + end + if anchor == "RIGHT" then + return true + end + if anchor == "BOTTOM" then + return true + end + if anchor == "BOTTOMLEFT" then + return true + end + if anchor == "BOTTOMRIGHT" then + return true + end + return false end utils.GetBestAnchor = function(self) - local scale = self:GetScale() - local x, y = self:GetCenter() - local a = GetScreenWidth() / scale / 3 - local b = GetScreenWidth() / scale / 3 * 2 - local c = GetScreenHeight() / scale / 3 * 2 - local d = GetScreenHeight() / scale / 3 - if not x or not y then return end + local scale = self:GetScale() + local x, y = self:GetCenter() + local a = GetScreenWidth() / scale / 3 + local b = GetScreenWidth() / scale / 3 * 2 + local c = GetScreenHeight() / scale / 3 * 2 + local d = GetScreenHeight() / scale / 3 + if not x or not y then + return + end - if x < a and y > c then - return "TOPLEFT" - elseif x > a and x < b and y > c then - return "TOP" - elseif x > b and y > c then - return "TOPRIGHT" - elseif x < a and y > d and y < c then - return "LEFT" - elseif x > a and x < b and y > d and y < c then - return "CENTER" - elseif x > b and y > d and y < c then - return "RIGHT" - elseif x < a and y < d then - return "BOTTOMLEFT" - elseif x > a and x < b and y < d then - return "BOTTOM" - elseif x > b and y < d then - return "BOTTOMRIGHT" - end + if x < a and y > c then + return "TOPLEFT" + elseif x > a and x < b and y > c then + return "TOP" + elseif x > b and y > c then + return "TOPRIGHT" + elseif x < a and y > d and y < c then + return "LEFT" + elseif x > a and x < b and y > d and y < c then + return "CENTER" + elseif x > b and y > d and y < c then + return "RIGHT" + elseif x < a and y < d then + return "BOTTOMLEFT" + elseif x > a and x < b and y < d then + return "BOTTOM" + elseif x > b and y < d then + return "BOTTOMRIGHT" + end end utils.ConvertFrameAnchor = function(self, anchor) - local scale, x, y, _ = self:GetScale(), nil, nil, nil + local scale, x, y, _ = self:GetScale(), nil, nil, nil - if anchor == "CENTER" then - x, y = self:GetCenter() - x, y = x - GetScreenWidth()/2/scale, y - GetScreenHeight()/2/scale - elseif anchor == "TOPLEFT" then - x, y = self:GetLeft(), self:GetTop() - GetScreenHeight()/scale - elseif anchor == "TOP" then - x, _ = self:GetCenter() - x, y = x - GetScreenWidth()/2/scale, self:GetTop() - GetScreenHeight()/scale - elseif anchor == "TOPRIGHT" then - x, y = self:GetRight() - GetScreenWidth()/scale, self:GetTop() - GetScreenHeight()/scale - elseif anchor == "RIGHT" then - _, y = self:GetCenter() - x, y = self:GetRight() - GetScreenWidth()/scale, y - GetScreenHeight()/2/scale - elseif anchor == "BOTTOMRIGHT" then - x, y = self:GetRight() - GetScreenWidth()/scale, self:GetBottom() - elseif anchor == "BOTTOM" then - x, _ = self:GetCenter() - x, y = x - GetScreenWidth()/2/scale, self:GetBottom() - elseif anchor == "BOTTOMLEFT" then - x, y = self:GetLeft(), self:GetBottom() - elseif anchor == "LEFT" then - _, y = self:GetCenter() - x, y = self:GetLeft(), y - GetScreenHeight()/2/scale - end + if anchor == "CENTER" then + x, y = self:GetCenter() + x, y = x - GetScreenWidth() / 2 / scale, y - GetScreenHeight() / 2 / scale + elseif anchor == "TOPLEFT" then + x, y = self:GetLeft(), self:GetTop() - GetScreenHeight() / scale + elseif anchor == "TOP" then + x, _ = self:GetCenter() + x, y = x - GetScreenWidth() / 2 / scale, self:GetTop() - GetScreenHeight() / scale + elseif anchor == "TOPRIGHT" then + x, y = self:GetRight() - GetScreenWidth() / scale, self:GetTop() - GetScreenHeight() / scale + elseif anchor == "RIGHT" then + _, y = self:GetCenter() + x, y = self:GetRight() - GetScreenWidth() / scale, y - GetScreenHeight() / 2 / scale + elseif anchor == "BOTTOMRIGHT" then + x, y = self:GetRight() - GetScreenWidth() / scale, self:GetBottom() + elseif anchor == "BOTTOM" then + x, _ = self:GetCenter() + x, y = x - GetScreenWidth() / 2 / scale, self:GetBottom() + elseif anchor == "BOTTOMLEFT" then + x, y = self:GetLeft(), self:GetBottom() + elseif anchor == "LEFT" then + _, y = self:GetCenter() + x, y = self:GetLeft(), y - GetScreenHeight() / 2 / scale + end - return anchor, utils.round(x, 2), utils.round(y, 2) + return anchor, utils.round(x, 2), utils.round(y, 2) end local _r, _g, _b, _a utils.rgbhex = function(r, g, b, a) - if type(r) == "table" then - if r.r then - _r, _g, _b, _a = r.r, r.g, r.b, (r.a or 1) - elseif table.getn(r) >= 3 then - _r, _g, _b, _a = r[1], r[2], r[3], (r[4] or 1) - end - elseif tonumber(r) then - _r, _g, _b, _a = r, g, b, (a or 1) - end + if type(r) == "table" then + if r.r then + _r, _g, _b, _a = r.r, r.g, r.b, (r.a or 1) + elseif table.getn(r) >= 3 then + _r, _g, _b, _a = r[1], r[2], r[3], (r[4] or 1) + end + elseif tonumber(r) then + _r, _g, _b, _a = r, g, b, (a or 1) + end - if _r and _g and _b and _a then - -- limit values to 0-1 - _r = _r + 0 > 1 and 1 or _r + 0 - _g = _g + 0 > 1 and 1 or _g + 0 - _b = _b + 0 > 1 and 1 or _b + 0 - _a = _a + 0 > 1 and 1 or _a + 0 - return string.format("|c%02x%02x%02x%02x", _a*255, _r*255, _g*255, _b*255) - end + if _r and _g and _b and _a then + -- limit values to 0-1 + _r = _r + 0 > 1 and 1 or _r + 0 + _g = _g + 0 > 1 and 1 or _g + 0 + _b = _b + 0 > 1 and 1 or _b + 0 + _a = _a + 0 > 1 and 1 or _a + 0 + return string.format("|c%02x%02x%02x%02x", _a * 255, _r * 255, _g * 255, _b * 255) + end - return "" + return "" end utils.GetReactionColor = function(unitstr) - local color = UnitReactionColor[UnitReaction(unitstr, "player")] - local r, g, b = .8, .8, .8 + local color = UnitReactionColor[UnitReaction(unitstr, "player")] + local r, g, b = .8, .8, .8 - if color then - r, g, b = color.r, color.g, color.b - end + if color then + r, g, b = color.r, color.g, color.b + end - return utils.rgbhex(r,g,b), r, g, b + return utils.rgbhex(r, g, b), r, g, b end utils.GetUnitColor = function(unitstr) - local r, g, b = .8, .8, .8 + local r, g, b = .8, .8, .8 - if UnitIsPlayer(unitstr) then - local _, class = UnitClass(unitstr) + if UnitIsPlayer(unitstr) then + local _, class = UnitClass(unitstr) - if RAID_CLASS_COLORS[class] then - r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b - end - else - return utils.GetReactionColor(unitstr) - end + if RAID_CLASS_COLORS[class] then + r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b + end + else + return utils.GetReactionColor(unitstr) + end - return utils.rgbhex(r,g,b), r, g, b + return utils.rgbhex(r, g, b), r, g, b end utils.GetLevelColor = function(unitstr) - local color = GetDifficultyColor(UnitLevel(unitstr)) - local r, g, b = .8, .8, .8 + local color = GetDifficultyColor(UnitLevel(unitstr)) + local r, g, b = .8, .8, .8 - if color then - r, g, b = color.r, color.g, color.b - end + if color then + r, g, b = color.r, color.g, color.b + end - return utils.rgbhex(r,g,b), r, g, b + return utils.rgbhex(r, g, b), r, g, b end utils.GetLevelString = function(unitstr) - local level = UnitLevel(unitstr) - if level == -1 then level = "??" end + local level = UnitLevel(unitstr) + if level == -1 then + level = "??" + end - local elite = UnitClassification(unitstr) - if elite == "worldboss" then - level = level .. "B" - elseif elite == "rareelite" then - level = level .. "R+" - elseif elite == "elite" then - level = level .. "+" - elseif elite == "rare" then - level = level .. "R" - end + local elite = UnitClassification(unitstr) + if elite == "worldboss" then + level = level .. "B" + elseif elite == "rareelite" then + level = level .. "R+" + elseif elite == "elite" then + level = level .. "+" + elseif elite == "rare" then + level = level .. "R" + end - return level + return level end utils.GetSpellNameNoRank = function(spellName) - return string.lower(string.gsub(spellName, "%([rR]ank %d%)", "")) + return string.lower(string.gsub(spellName, "%([rR]ank %d%)", "")) end Cursive.utils = utils