聊天重做前缓存

This commit is contained in:
rucky
2026-04-09 09:46:47 +08:00
parent 6e18269bfd
commit e915bbd74a
39 changed files with 8501 additions and 2308 deletions

View File

@@ -338,6 +338,58 @@ local BASE_SPELL_CRIT = {
DRUID = 1.8, SHAMAN = 2.3, PALADIN = 0,
}
--------------------------------------------------------------------------------
-- Temporary weapon enchant crit detection (sharpening stones / scopes)
-- Scans tooltip green text for crit keywords, returns crit% bonus (e.g. 2)
--------------------------------------------------------------------------------
local _tempEnchTip
local function GetTempEnchantCrit(slotId)
if not GetWeaponEnchantInfo then return 0 end
-- slotId 16=MainHand, 17=OffHand, 18=Ranged
local hasMain, _, _, hasOff
hasMain, _, _, hasOff = GetWeaponEnchantInfo()
if slotId == 16 and not hasMain then return 0 end
if slotId == 17 and not hasOff then return 0 end
if slotId == 18 and not hasMain and not hasOff then
-- ranged slot: some servers report via hasMain for ranged-only classes
-- try scanning anyway if there's a ranged weapon equipped
if not GetInventoryItemLink("player", 18) then return 0 end
end
if not _tempEnchTip then
_tempEnchTip = CreateFrame("GameTooltip", "SFramesCPTempEnchTip", UIParent, "GameTooltipTemplate")
_tempEnchTip:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -300, -300)
end
local tip = _tempEnchTip
tip:SetOwner(UIParent, "ANCHOR_NONE")
tip:ClearLines()
tip:SetInventoryItem("player", slotId)
local n = tip:NumLines()
if not n or n < 2 then return 0 end
for i = 2, n do
local obj = _G["SFramesCPTempEnchTipTextLeft" .. i]
if obj then
local txt = obj:GetText()
if txt and txt ~= "" then
local r, g, b = obj:GetTextColor()
-- green text = enchant/buff line
if g > 0.8 and r < 0.5 and b < 0.5 then
-- Match patterns like: "+2% 致命一击" / "+2% Critical" / "致命一击几率提高2%"
local _, _, pct = string.find(txt, "(%d+)%%%s*致命")
if not pct then _, _, pct = string.find(txt, "致命.-(%d+)%%") end
if not pct then _, _, pct = string.find(txt, "(%d+)%%%s*[Cc]rit") end
if not pct then _, _, pct = string.find(txt, "[Cc]rit.-(%d+)%%") end
if not pct then _, _, pct = string.find(txt, "(%d+)%%%s*暴击") end
if not pct then _, _, pct = string.find(txt, "暴击.-(%d+)%%") end
if pct then return tonumber(pct) or 0 end
end
end
end
end
return 0
end
local function CalcMeleeCrit()
local _, class = UnitClass("player")
class = class or ""
@@ -523,8 +575,9 @@ local function FullMeleeCrit()
end
local gearCrit = GetGearBonus("CRIT")
local talentCrit = GetTalentBonus("meleeCrit")
return baseCrit + agiCrit + gearCrit + talentCrit,
baseCrit, agiCrit, gearCrit, talentCrit
local tempCrit = GetTempEnchantCrit(16)
return baseCrit + agiCrit + gearCrit + talentCrit + tempCrit,
baseCrit, agiCrit, gearCrit, talentCrit, tempCrit
end
local function FullRangedCrit()
local _, class = UnitClass("player")
@@ -537,8 +590,9 @@ local function FullRangedCrit()
end
local gearCrit = GetGearBonus("RANGEDCRIT") + GetGearBonus("CRIT")
local talentCrit = GetTalentBonus("rangedCrit")
return baseCrit + agiCrit + gearCrit + talentCrit,
baseCrit, agiCrit, gearCrit, talentCrit
local tempCrit = GetTempEnchantCrit(18)
return baseCrit + agiCrit + gearCrit + talentCrit + tempCrit,
baseCrit, agiCrit, gearCrit, talentCrit, tempCrit
end
local function FullSpellCrit()
local _, class = UnitClass("player")
@@ -659,6 +713,7 @@ CS.FullSpellHit = FullSpellHit
CS.GetTalentDetailsFor = GetTalentDetailsFor
CS.GetGearBonus = GetGearBonus
CS.GetItemBonusLib = GetItemBonusLib
CS.GetTempEnchantCrit = GetTempEnchantCrit
CS.AGI_PER_MELEE_CRIT = AGI_PER_MELEE_CRIT
SFrames.CharacterPanel.CS = CS
@@ -2009,7 +2064,7 @@ function CP:BuildEquipmentPage()
local crit = CS.SafeGetMeleeCrit()
CS.TipKV("当前暴击率:", string.format("%.2f%%", crit), 0.7,0.7,0.75, 1,1,0.5)
else
local total, base, agiC, gearC, talC = CS.FullMeleeCrit()
local total, base, agiC, gearC, talC, tempC = CS.FullMeleeCrit()
CS.TipLine("来源分项:", 0.5,0.8,1)
if base > 0 then CS.TipKV(" 基础暴击:", string.format("%.2f%%", base)) end
if agiC > 0 then CS.TipKV(" 敏捷暴击:", string.format("%.2f%%", agiC)) end
@@ -2021,6 +2076,9 @@ function CP:BuildEquipmentPage()
d.name, d.rank, d.maxRank, d.bonus), 0.55,0.55,0.6)
end
end
if tempC and tempC > 0 then
CS.TipKV(" 临时附魔(磨刀石)", string.format("+%d%%", tempC), 0.7,0.7,0.75, 0.3,1,0.3)
end
GameTooltip:AddLine(" ")
CS.TipKV("合计暴击率:", string.format("%.2f%%", total), 0.7,0.7,0.75, 1,1,0.5)
CS.TipLine("Buff 暴击未计入)", 0.8,0.5,0.3)
@@ -2135,7 +2193,7 @@ function CP:BuildEquipmentPage()
if fromAPI then
CS.TipKV("当前暴击率:", string.format("%.2f%%", CS.SafeGetRangedCrit()), 0.7,0.7,0.75, 1,1,0.5)
else
local total, base, agiC, gearC, talC = CS.FullRangedCrit()
local total, base, agiC, gearC, talC, tempC = CS.FullRangedCrit()
CS.TipLine("来源分项:", 0.5,0.8,1)
if base > 0 then CS.TipKV(" 基础暴击:", string.format("%.2f%%", base)) end
if agiC > 0 then CS.TipKV(" 敏捷暴击:", string.format("%.2f%%", agiC)) end
@@ -2147,6 +2205,9 @@ function CP:BuildEquipmentPage()
d.name, d.rank, d.maxRank, d.bonus), 0.55,0.55,0.6)
end
end
if tempC and tempC > 0 then
CS.TipKV(" 临时附魔(瞄准镜)", string.format("+%d%%", tempC), 0.7,0.7,0.75, 0.3,1,0.3)
end
GameTooltip:AddLine(" ")
CS.TipKV("合计暴击率:", string.format("%.2f%%", total), 0.7,0.7,0.75, 1,1,0.5)
CS.TipLine("Buff 暴击未计入)", 0.8,0.5,0.3)