血条插件优化2
This commit is contained in:
parent
4faed26cf8
commit
342f39f8ff
@ -30,36 +30,38 @@ Creature_MultiLifeMultiplierAddon = Creature_MultiLifeMultiplierAddon or
|
||||
{
|
||||
SavedData = {}, -- 现在按GUID存储,不是Entry
|
||||
CreatureTemplates = {}, -- 新增:按Entry存储模板数据
|
||||
CurrentTargetGUID = nil, -- 改为存储GUID
|
||||
lastDamageTrackTime = 0, -- 独立追踪冷却计时
|
||||
lastShakeTime = 0, -- 独立震动冷却计时
|
||||
-- 保存原始目标框架状态
|
||||
originalTargetFrameState =
|
||||
{
|
||||
wasShown = false
|
||||
}
|
||||
lastTargetWasCustom = false -- 跟踪上一次选择的目标类型
|
||||
}
|
||||
|
||||
-- 初始化函数
|
||||
function Creature_MultiLifeMultiplierAddon:Initialize()
|
||||
self:InitializeProgressBar()
|
||||
self:RegisterEvents() --事件
|
||||
self:BuffInitialize() -- 初始化BUFF文件
|
||||
self:ClassMarkersInitialize() -- 初始化职业标记系统
|
||||
|
||||
if self.BuffInitialize then
|
||||
self:BuffInitialize() -- 初始化BUFF文件
|
||||
end
|
||||
|
||||
if self.ClassMarkersInitialize then
|
||||
self:ClassMarkersInitialize() -- 初始化职业标记系统
|
||||
end
|
||||
end
|
||||
|
||||
-- 创建血条
|
||||
function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
-- 创建主框架(不参与震动)
|
||||
-- 创建主框架
|
||||
self.CustomHealthFrame = CreateFrame("Frame", "CustomHealthFrame", UIParent)
|
||||
self.CustomHealthFrame:SetSize(HEALTHFRAME_W, HEALTHFRAME_H)
|
||||
self.CustomHealthFrame:SetPoint("BOTTOM", UIParent, "TOP", 0, -80)
|
||||
self.CustomHealthFrame:SetBackdrop({
|
||||
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
|
||||
})
|
||||
self.CustomHealthFrame:Hide()
|
||||
if self.CustomHealthFrame.SetFrameLevel then
|
||||
self.CustomHealthFrame:SetFrameLevel(10)
|
||||
end
|
||||
|
||||
-- 背景血条(直接放在CustomHealthFrame中)
|
||||
|
||||
-- 背景血条
|
||||
self.healthBarBg = CreateFrame("StatusBar", nil, self.CustomHealthFrame)
|
||||
self.healthBarBg:SetSize(HEALTHFRAME_W, HEALTHFRAME_H)
|
||||
self.healthBarBg:SetPoint("TOP", self.CustomHealthFrame, "TOP", 0, 0) -- 调整锚点
|
||||
@ -117,7 +119,7 @@ function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
self.HealthPerAttImg = HealthPerFeame:CreateTexture(nil, "OVERLAY")
|
||||
self.HealthPerAttImg:SetSize(15, 15)
|
||||
self.HealthPerAttImg:SetPoint("LEFT", HealthPerFeame, "LEFT", 18, 0)
|
||||
self.HealthPerAttImg:SetTexture("Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\HealthPerAttImg")
|
||||
self.HealthPerAttImg:SetTexture("Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\HealthPerAtt")
|
||||
|
||||
-- 右下方百分比文本
|
||||
self.HealthPerText = HealthPerFeame:CreateFontString(nil, "OVERLAY")
|
||||
@ -158,7 +160,7 @@ function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
-- 创建生物类型按钮
|
||||
self.CreateTypeButton = CreateFrame("Button", nil, border)
|
||||
self.CreateTypeButton:SetSize(15, 15)
|
||||
self.CreateTypeButton:SetPoint("BOTTOMLEFT", self.CreateClassificationButton, "BOTTOMRIGHT", 5, 0)
|
||||
self.CreateTypeButton:SetPoint("BOTTOMLEFT", self.CreateClassificationButton, "BOTTOMRIGHT", 5, 0)
|
||||
self.CreateTypeButton:SetNormalTexture("Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\StatusBar")
|
||||
|
||||
-- 创建等级文本
|
||||
@ -206,7 +208,7 @@ function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
self.bossIcon = self.portraitFrame:CreateTexture(nil, "ARTWORK")
|
||||
self.bossIcon:SetSize(25, 25)
|
||||
self.bossIcon:SetPoint("LEFT", self.healthBar, "RIGHT", 10, 0)
|
||||
self.bossIcon:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Skull")
|
||||
self.bossIcon:SetTexture("Interface\\TARGETINGFRAME\\UI-TargetingFrame-Skull")
|
||||
self.bossIcon:Hide()
|
||||
|
||||
------------------------------------------ 下方总血条 ------------------------------------------
|
||||
@ -232,6 +234,7 @@ function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
self.Z_border.maskOverlay:SetPoint("TOPRIGHT", self.Z_border.healthBar, "TOPRIGHT", 0, 0)
|
||||
self.Z_border.maskOverlay:SetPoint("BOTTOMRIGHT", self.Z_border.healthBar, "BOTTOMRIGHT", 0, 0)
|
||||
self.Z_border.maskOverlay:SetWidth(0) -- 初始宽度为0(满血状态)
|
||||
print("总血量宽度= 0 --初始化的时候")
|
||||
-- 创建遮罩纹理
|
||||
self.Z_border.maskTexture = self.Z_border.maskOverlay:CreateTexture(nil, "ARTWORK")
|
||||
self.Z_border.maskTexture:SetAllPoints(self.Z_border.maskOverlay)
|
||||
@ -242,8 +245,8 @@ function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
self.Z_border.WFrame:SetAllPoints(self.Z_border)
|
||||
self.Z_border.WFrame:SetFrameLevel(self.Z_border.healthBar:GetFrameLevel() + 2)
|
||||
self.Z_border.WFrame:SetBackdrop({
|
||||
bgFile = "Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\Z_border_healthWFrame",
|
||||
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", edgeSize = 5
|
||||
bgFile = "Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\Z_border_healthWFrame",
|
||||
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", edgeSize = 5
|
||||
})
|
||||
|
||||
-- 总血条闪光效果层
|
||||
@ -251,7 +254,7 @@ function Creature_MultiLifeMultiplierAddon:InitializeProgressBar()
|
||||
self.Z_border.flashEffectBar:SetAllPoints(self.Z_border.healthBar)
|
||||
self.Z_border.flashEffectBar:SetStatusBarTexture("Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\StatusBar")
|
||||
self.Z_border.flashEffectBar:SetMinMaxValues(0, 100)
|
||||
--self.Z_border.flashEffectBar:SetFrameLevel(15)
|
||||
self.Z_border.flashEffectBar:SetFrameLevel(6)
|
||||
self.Z_border.flashEffectBar:Hide()
|
||||
|
||||
------------------------------------------ 其他初始化 ------------------------------------------
|
||||
@ -272,11 +275,8 @@ end
|
||||
-- 隐藏默认目标框体
|
||||
function Creature_MultiLifeMultiplierAddon:SafeHideDefaultTargetFrame()
|
||||
if TargetFrame:IsShown() then
|
||||
self.originalTargetFrameState.wasShown = true
|
||||
TargetFrame:Hide()
|
||||
TargetFrame:UnregisterAllEvents()
|
||||
else
|
||||
self.originalTargetFrameState.wasShown = false
|
||||
end
|
||||
end
|
||||
|
||||
@ -471,7 +471,7 @@ function Creature_MultiLifeMultiplierAddon:PlayLayerBreakEffect(oldHealth, newHe
|
||||
|
||||
self.damageTrackBar:SetValue(MAX_HEALTH_PER_LAYER)
|
||||
self.damageTrackBar:Show()
|
||||
self.damageTrackBar:SetAlpha(1.0) -- 更明显的透明度
|
||||
self.damageTrackBar:SetAlpha(1.0) -- 更明显的透明度
|
||||
|
||||
-- 添加调试输出
|
||||
-- print("[调试] 播放层破碎效果,从层", math.floor((oldHealth - 1) / MAX_HEALTH_PER_LAYER) + 1, "到层",
|
||||
@ -609,14 +609,16 @@ function Creature_MultiLifeMultiplierAddon:PlayLayerTransitionEffect(oldLayer, n
|
||||
local fadeIn = self.layerAnimGroup:CreateAnimation("Alpha")
|
||||
fadeIn:SetOrder(1)
|
||||
fadeIn:SetDuration(0.2)
|
||||
fadeIn:SetFromAlpha(0)
|
||||
fadeIn:SetToAlpha(1)
|
||||
fadeIn:SetChange(1) -- 从0变为1
|
||||
|
||||
local fadeOut = self.layerAnimGroup:CreateAnimation("Alpha")
|
||||
fadeOut:SetOrder(2)
|
||||
fadeOut:SetDuration(0.5)
|
||||
fadeOut:SetFromAlpha(1)
|
||||
fadeOut:SetToAlpha(0)
|
||||
fadeOut:SetChange(-1) -- 从1变为0
|
||||
|
||||
self.layerAnimGroup:SetScript("OnPlay", function()
|
||||
self.layerTransitionFrame:SetAlpha(0) -- 设置初始透明度
|
||||
end)
|
||||
|
||||
self.layerAnimGroup:SetScript("OnFinished", function()
|
||||
self.layerTransitionFrame:Hide()
|
||||
@ -730,9 +732,8 @@ function Creature_MultiLifeMultiplierAddon:PlayDamageTrackEffect(oldHealth, newH
|
||||
end
|
||||
|
||||
-- 更新血条
|
||||
function Creature_MultiLifeMultiplierAddon:UpdateHealthBar(data)
|
||||
function Creature_MultiLifeMultiplierAddon:UpdateHealthBar(data,isDead)
|
||||
if not data then return end
|
||||
|
||||
-- 保存旧的血量值用于伤害跟踪效果
|
||||
local oldHealth = data.lastHealth or data.currentHealth
|
||||
|
||||
@ -759,7 +760,7 @@ function Creature_MultiLifeMultiplierAddon:UpdateHealthBar(data)
|
||||
self.healthBarBg:SetStatusBarColor(currentLayerColor.r * 0.3, currentLayerColor.g * 0.3,
|
||||
currentLayerColor.b * 0.3)
|
||||
self.healthBarBg:SetValue(MAX_HEALTH_PER_LAYER)
|
||||
self.healthBarBg:Show() -- 保持显示,不要隐藏
|
||||
self.healthBarBg:Show() -- 保持显示,不要隐藏
|
||||
end
|
||||
|
||||
-- 更新主血条
|
||||
@ -802,41 +803,17 @@ function Creature_MultiLifeMultiplierAddon:UpdateHealthBar(data)
|
||||
-- 更新层数文本
|
||||
self.layerText:SetText(string.format("X %d", remainingLayers))
|
||||
|
||||
-- 更新血量文本 - 添加死亡状态显示
|
||||
if data.currentHealth <= 0 then
|
||||
|
||||
self.healthText:SetTextColor(0.7, 0.7, 0.7) -- 设置为灰色
|
||||
|
||||
self.healthText:SetText("死亡")
|
||||
self.nameText:SetTextColor(0.7, 0.7, 0.7) -- 生物名称文本灰色
|
||||
self.levelText:SetTextColor(0.7, 0.7, 0.7) -- 生物等级文本设置为灰色
|
||||
|
||||
self.layerText:SetTextColor(0.5, 0.5, 0.5) -- 血量层数文本设置为灰色
|
||||
self.HealthPerAttImg:SetTexture("Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\HealthPerAtt")
|
||||
self.HealthPerAttImg:SetTexCoord(0.5, 1, 0, 1)
|
||||
self.portraitIcon:SetDesaturated(true) -- 去除饱和度
|
||||
self.healthText:SetPoint("CENTER", self.CustomHealthFrame, "CENTER", 0, 0) -- 死亡文本在中间
|
||||
else
|
||||
-- 更新血量文本
|
||||
if not isDead then
|
||||
self.healthText:SetText(string.format("%.0f / %.0f", data.currentHealth, data.healthPerBar))
|
||||
self.healthText:SetTextColor(1, 1, 1) -- 恢复白色
|
||||
self.healthText:SetPoint("BOTTOMRIGHT", self.healthBarBg, "TOPRIGHT", 0, 5) --恢复位置
|
||||
|
||||
-- layerTransitionText创建时机不对,需要在对象存在时才设置
|
||||
local color = self:GetColorForLayer(remainingLayers, 99)
|
||||
if self.layerTransitionText then
|
||||
self.layerTransitionText:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
self.layerText:SetTextColor(color.r, color.g, color.b)
|
||||
|
||||
self.nameText:SetTextColor(255 / 255, 255 / 255, 255) -- 生物名称文本恢复颜色
|
||||
self.levelText:SetTextColor(255 / 255, 255 / 255, 255) -- 生物等级文本恢复颜色
|
||||
self.HealthPerAttImg:SetTexture("Interface\\AddOns\\SM_BloodVolumeExpansion\\img\\HealthPerAtt")
|
||||
self.HealthPerAttImg:SetTexCoord(0, 0.5, 0, 1)
|
||||
self.HealthPerText:SetTextColor(150 / 200, 140 / 255, 0) -- 总血量百分比文本设置为正常
|
||||
self.portraitIcon:SetDesaturated(false) -- 恢复饱和度
|
||||
|
||||
self.healthText:SetTextColor(1, 1, 1) -- 恢复白色
|
||||
end
|
||||
|
||||
-- 获取层级血条颜色
|
||||
local color = self:GetColorForLayer(remainingLayers, 99)
|
||||
if self.layerTransitionText then
|
||||
self.layerTransitionText:SetTextColor(color.r, color.g, color.b)
|
||||
end
|
||||
-- 更新血量百分比文本和总血条遮罩
|
||||
local currentHealth = tonumber(data.currentHealth) or 0
|
||||
local healthPerBar = tonumber(data.healthPerBar) or 1
|
||||
@ -853,27 +830,31 @@ function Creature_MultiLifeMultiplierAddon:UpdateHealthBar(data)
|
||||
if oldHealth > data.currentHealth then
|
||||
self:PlayTotalHealthBarFlash(healthPer) -- 使用已计算好的百分比
|
||||
end
|
||||
|
||||
-- 强制限制百分比范围
|
||||
healthPer = math.max(0, math.min(100, healthPer))
|
||||
|
||||
-- 更新百分比文本
|
||||
-- 统一更新百分比文本
|
||||
if healthPer >= 99.995 and healthPer <= 100.005 then
|
||||
self.HealthPerText:SetText("100%")
|
||||
self.Z_border.maskOverlay:SetAlpha(0)
|
||||
else
|
||||
self.Z_border.maskOverlay:SetAlpha(1)
|
||||
local formatted = string.format("%.2f", healthPer)
|
||||
if formatted:find("%.00$") then
|
||||
self.HealthPerText:SetText(string.format("%.0f%", healthPer) .. "%")
|
||||
self.HealthPerText:SetText(string.format("%.0f%%", healthPer))
|
||||
else
|
||||
self.HealthPerText:SetText(formatted .. "%")
|
||||
end
|
||||
end
|
||||
|
||||
-- 更新遮罩覆盖层(血量损失的部分)
|
||||
-- 统一更新遮罩覆盖层(血量损失的部分)
|
||||
local lostHealthPercent = 100 - healthPer
|
||||
local maxWidth = self.Z_border.healthBar:GetWidth()
|
||||
local maskWidth = (lostHealthPercent / 100) * maxWidth
|
||||
print("总血量宽度= --更新血条的时候maskWidth= "..maskWidth)
|
||||
|
||||
self.Z_border.maskOverlay:SetWidth(maskWidth)
|
||||
|
||||
end
|
||||
|
||||
-- 播放伤害效果
|
||||
@ -894,100 +875,7 @@ function Creature_MultiLifeMultiplierAddon:PlayDamageEffects()
|
||||
end
|
||||
end
|
||||
|
||||
-- 更新自定义血条框体
|
||||
function Creature_MultiLifeMultiplierAddon:UpdateCustomHealthFrame()
|
||||
local targetGUID = UnitGUID("target")
|
||||
|
||||
self:SetCreatureTypeIcon("target")
|
||||
self:SetCreatureClassificationIcon("target")
|
||||
|
||||
-- 重置原始目标框架状态
|
||||
self.originalTargetFrameState.wasShown = false
|
||||
|
||||
-- 如果没有目标,隐藏所有框架
|
||||
if not targetGUID or not UnitExists("target") then
|
||||
self.CustomHealthFrame:Hide()
|
||||
TargetFrame:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
-- 获取目标Entry
|
||||
local targetEntry = tonumber(targetGUID:sub(8, 12), 16)
|
||||
-- 检查是否是扩展血量生物
|
||||
if self.CreatureTemplates[targetEntry] then
|
||||
-- 统一的死亡状态检查
|
||||
local isDead = UnitIsDeadOrGhost("target")
|
||||
-- 无论生死都要创建数据(如果不存在)
|
||||
if not self.SavedData[targetGUID] then
|
||||
self.SavedData[targetGUID] = {
|
||||
entry = targetEntry,
|
||||
healthPerBar = self.CreatureTemplates[targetEntry].healthPerBar,
|
||||
currentHealth = isDead and 0 or self.CreatureTemplates[targetEntry].healthPerBar,
|
||||
lastHealth = isDead and 0 or self.CreatureTemplates[targetEntry].healthPerBar
|
||||
}
|
||||
end
|
||||
|
||||
local data = self.SavedData[targetGUID]
|
||||
|
||||
-- 隐藏默认目标框架
|
||||
self:SafeHideDefaultTargetFrame()
|
||||
TargetFrame:Hide()
|
||||
TargetFrame:UnregisterAllEvents()
|
||||
|
||||
-- 根据死亡状态更新血量
|
||||
if isDead then
|
||||
data.currentHealth = 0
|
||||
elseif data.currentHealth == 0 then
|
||||
-- 如果之前是死亡状态,现在复活了,恢复满血
|
||||
data.currentHealth = data.healthPerBar
|
||||
end
|
||||
self:UpdateHealthBar(data)
|
||||
self.nameText:SetText(UnitName("target"))
|
||||
self.levelText:SetText("Lv" .. UnitLevel("target"))
|
||||
|
||||
-- 安全的头像设置
|
||||
if UnitExists("target") and not UnitIsPlayer("target") then
|
||||
SetPortraitTexture(self.portraitIcon, "target")
|
||||
end
|
||||
|
||||
if UnitClassification("target") == "worldboss" then
|
||||
self.bossIcon:Show()
|
||||
else
|
||||
self.bossIcon:Hide()
|
||||
end
|
||||
|
||||
-- 控制 UpdateBuffs 调用频率
|
||||
if self.lastBuffUpdateTime == nil or (GetTime() - self.lastBuffUpdateTime) > 1.0 then
|
||||
self:UpdateBuffs()
|
||||
self.lastBuffUpdateTime = GetTime()
|
||||
else
|
||||
end
|
||||
-- 隐藏默认连击点系统
|
||||
self:HideDefaultComboPoints()
|
||||
if self.lastClassMarkerUpdateTime == nil or (GetTime() - self.lastClassMarkerUpdateTime) > 0.3 then
|
||||
self:UpdateClassMarkers() -- 更新职业标记
|
||||
self.lastClassMarkerUpdateTime = GetTime()
|
||||
end
|
||||
|
||||
self.CustomHealthFrame:Show()
|
||||
else
|
||||
-- 对于普通生物,隐藏自定义框架并恢复默认框架
|
||||
self.CustomHealthFrame:Hide()
|
||||
TargetFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
TargetFrame:RegisterEvent("UNIT_HEALTH")
|
||||
TargetFrame:RegisterEvent("UNIT_POWER_UPDATE")
|
||||
TargetFrame:Show()
|
||||
self.originalTargetFrameState.wasShown = true
|
||||
|
||||
-- 恢复默认连击点显示
|
||||
self:RestoreDefaultComboPoints()
|
||||
|
||||
-- 隐藏自定义职业标记
|
||||
self:HideAllClassMarkers()
|
||||
end
|
||||
end
|
||||
|
||||
-- 处理插件事件
|
||||
-- 处理插件事件 分离目标切换和血量更新逻辑
|
||||
function Creature_MultiLifeMultiplierAddon:SM_MultiLifeMultiplierEvent(event, ...)
|
||||
if event == 'CHAT_MSG_ADDON' then
|
||||
local Packet, Msg, Type, Sender = ...
|
||||
@ -995,25 +883,21 @@ function Creature_MultiLifeMultiplierAddon:SM_MultiLifeMultiplierEvent(event, ..
|
||||
local entry, healthPerBar = strsplit(",", Msg)
|
||||
entry = tonumber(entry)
|
||||
healthPerBar = tonumber(healthPerBar)
|
||||
|
||||
if healthPerBar and healthPerBar > 0 then
|
||||
self.CreatureTemplates[entry] = {
|
||||
healthPerBar = healthPerBar
|
||||
}
|
||||
end
|
||||
elseif Packet == 'SM_S_UPDATE_CREATURE_HEALTH' then
|
||||
|
||||
local entry, currentHealth, maxHealth = strsplit(",", Msg)
|
||||
entry = tonumber(entry)
|
||||
currentHealth = tonumber(currentHealth)
|
||||
|
||||
-- 只有当前目标是这个Entry时才更新
|
||||
local targetGUID = UnitGUID("target")
|
||||
if targetGUID and self.CreatureTemplates[entry] then
|
||||
local targetEntry = tonumber(targetGUID:sub(8, 12), 16)
|
||||
|
||||
if targetEntry == entry then
|
||||
|
||||
-- 使用目标GUID作为键值
|
||||
if not self.SavedData[targetGUID] then
|
||||
self.SavedData[targetGUID] = {
|
||||
@ -1022,26 +906,23 @@ function Creature_MultiLifeMultiplierAddon:SM_MultiLifeMultiplierEvent(event, ..
|
||||
currentHealth = currentHealth,
|
||||
lastHealth = currentHealth
|
||||
}
|
||||
else
|
||||
if currentHealth > self.SavedData[targetGUID].lastHealth then
|
||||
-- 血量增加(自动回血),也需要更新UI
|
||||
self.SavedData[targetGUID].lastHealth = self.SavedData[targetGUID].currentHealth
|
||||
self.SavedData[targetGUID].currentHealth = currentHealth
|
||||
elseif currentHealth < self.SavedData[targetGUID].lastHealth then
|
||||
-- 血量减少(受到伤害)
|
||||
self:PlayDamageEffects()
|
||||
self.SavedData[targetGUID].lastHealth = self.SavedData[targetGUID].currentHealth
|
||||
self.SavedData[targetGUID].currentHealth = currentHealth
|
||||
end
|
||||
end
|
||||
self:UpdateCustomHealthFrame()
|
||||
-- 【修改】只更新血量数据,不重新设置整个UI
|
||||
self:UpdateHealthData(targetGUID, currentHealth)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif event == "PLAYER_TARGET_CHANGED" then
|
||||
-- 在目标改变时,先确保默认框架状态正确
|
||||
self.originalTargetFrameState.wasShown = false
|
||||
self:UpdateCustomHealthFrame()
|
||||
-- 【修改】只处理目标切换逻辑
|
||||
self:OnTargetChanged()
|
||||
-- 当单位的三维模型更改时触发。
|
||||
elseif event == "UNIT_MODEL_CHANGED" then
|
||||
|
||||
-- 设置头像
|
||||
if UnitExists("target") and not UnitIsPlayer("target") then
|
||||
SetPortraitTexture(self.portraitIcon, "target")
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1054,6 +935,7 @@ function Creature_MultiLifeMultiplierAddon:RegisterEvents()
|
||||
frame:RegisterEvent('PLAYER_LEAVING_WORLD')
|
||||
frame:RegisterEvent('PLAYER_TARGET_CHANGED')
|
||||
frame:RegisterEvent('ADDON_LOADED')
|
||||
frame:RegisterEvent('UNIT_MODEL_CHANGED')
|
||||
|
||||
frame:SetScript('OnEvent', function(_, event, ...)
|
||||
if event == 'PLAYER_LOGIN' then
|
||||
@ -1075,4 +957,473 @@ function Creature_MultiLifeMultiplierAddon:RegisterEvents()
|
||||
end)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- 【新增】处理目标切换(只处理UI框架切换和静态信息)
|
||||
function Creature_MultiLifeMultiplierAddon:OnTargetChanged()
|
||||
local targetGUID = UnitGUID("target")
|
||||
local targetEntry = targetGUID and tonumber(targetGUID:sub(8, 12), 16) or 0
|
||||
|
||||
-- 获取当前目标类型
|
||||
local isCustomCreature = self.CreatureTemplates[targetEntry] and true or false
|
||||
local hasTarget = targetGUID and UnitExists("target") and true or false
|
||||
|
||||
-- 【新增】立即更新状态标志,防止UpdateHealthData干扰
|
||||
local previousState = self.usingCustomFrame
|
||||
|
||||
-- 状态转换处理
|
||||
if hasTarget then
|
||||
if isCustomCreature then
|
||||
-- 切换到自定义生物
|
||||
self.usingCustomFrame = true -- 提前设置状态
|
||||
self:InitializeTargetData(targetGUID, targetEntry)
|
||||
self:SetupCustomHealthFrame()
|
||||
self:UpdateStaticTargetInfo()
|
||||
else
|
||||
-- 切换到普通生物
|
||||
self.usingCustomFrame = false -- 【提前设置状态】
|
||||
if previousState then
|
||||
-- 从自定义生物切换过来
|
||||
self:ForceCompleteUIReset()
|
||||
self:RestoreDefaultTargetFrame()
|
||||
else
|
||||
-- 确保默认框架正常显示
|
||||
self:EnsureDefaultFrameVisible()
|
||||
end
|
||||
end
|
||||
else
|
||||
-- 无目标状态
|
||||
self.usingCustomFrame = false -- 【提前设置状态】
|
||||
self.CustomHealthFrame:Hide()
|
||||
if previousState then
|
||||
-- 从自定义生物切换到无目标
|
||||
self:RestoreDefaultTargetFrame()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 【新增】完全重置所有UI状态,确保目标切换时没有任何残留
|
||||
function Creature_MultiLifeMultiplierAddon:ForceCompleteUIReset()
|
||||
-- 停止所有动画
|
||||
if self.damageTrackBar and self.damageTrackBar.animationData then
|
||||
self.damageTrackBar.animationData.isAnimating = false
|
||||
self.damageTrackBar:Hide()
|
||||
self.damageTrackBar:SetAlpha(0)
|
||||
end
|
||||
|
||||
if self.flashEffectBar and self.flashEffectBar.animationData then
|
||||
self.flashEffectBar.animationData.isAnimating = false
|
||||
self.flashEffectBar:Hide()
|
||||
self.flashEffectBar:SetAlpha(0)
|
||||
end
|
||||
|
||||
if self.Z_border and self.Z_border.flashEffectBar and self.Z_border.flashEffectBar.animationData then
|
||||
self.Z_border.flashEffectBar.animationData.isAnimating = false
|
||||
self.Z_border.flashEffectBar:Hide()
|
||||
self.Z_border.flashEffectBar:SetAlpha(0)
|
||||
end
|
||||
|
||||
-- 强制隐藏自定义框架
|
||||
if self.CustomHealthFrame then
|
||||
self.CustomHealthFrame:Hide()
|
||||
end
|
||||
|
||||
if self.layerText then
|
||||
self.layerText:SetText("")
|
||||
self.layerText:SetTextColor(1, 1, 1)
|
||||
end
|
||||
|
||||
if self.HealthPerText then
|
||||
self.HealthPerText:SetText("100%")
|
||||
self.HealthPerText:SetTextColor(150 / 200, 140 / 255, 0)
|
||||
end
|
||||
|
||||
-- 隐藏所有图标和按钮
|
||||
if self.bossIcon then
|
||||
self.bossIcon:Hide()
|
||||
end
|
||||
|
||||
if self.CreateClassificationButton then
|
||||
self.CreateClassificationButton:Hide()
|
||||
end
|
||||
|
||||
if self.CreateTypeButton then
|
||||
self.CreateTypeButton:Hide()
|
||||
end
|
||||
|
||||
-- 重置头像
|
||||
if self.portraitIcon then
|
||||
self.portraitIcon:SetTexture(nil)
|
||||
self.portraitIcon:SetDesaturated(false)
|
||||
end
|
||||
|
||||
-- 重置血条状态
|
||||
if self.healthBar then
|
||||
self.healthBar:SetValue(0)
|
||||
self.healthBar:SetStatusBarColor(1, 0, 0)
|
||||
end
|
||||
|
||||
if self.healthBarBg then
|
||||
self.healthBarBg:SetValue(0)
|
||||
self.healthBarBg:Hide()
|
||||
end
|
||||
|
||||
-- 重置总血条遮罩
|
||||
if self.Z_border and self.Z_border.maskOverlay then
|
||||
self.Z_border.maskOverlay:SetWidth(0) -- 【修复】改为0,不是100
|
||||
print("总血量宽度= 0 --完全重置所有UI状态的时候")
|
||||
end
|
||||
|
||||
-- 强制刷新TargetFrame
|
||||
if TargetFrame_Update then
|
||||
TargetFrame_Update(TargetFrame)
|
||||
end
|
||||
end
|
||||
|
||||
-- 【新增】恢复默认目标框架
|
||||
function Creature_MultiLifeMultiplierAddon:RestoreDefaultTargetFrame()
|
||||
-- 【新增】确保自定义框架完全隐藏
|
||||
if self.CustomHealthFrame then
|
||||
self.CustomHealthFrame:Hide()
|
||||
end
|
||||
|
||||
-- 仅在需要时重新注册事件
|
||||
if not TargetFrame:IsEventRegistered("PLAYER_TARGET_CHANGED") then
|
||||
TargetFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
end
|
||||
if not TargetFrame:IsEventRegistered("UNIT_HEALTH") then
|
||||
TargetFrame:RegisterEvent("UNIT_HEALTH")
|
||||
end
|
||||
if not TargetFrame:IsEventRegistered("UNIT_POWER_UPDATE") then
|
||||
TargetFrame:RegisterEvent("UNIT_POWER_UPDATE")
|
||||
end
|
||||
|
||||
-- 仅在目标存在时显示
|
||||
if UnitExists("target") then
|
||||
TargetFrame:Show()
|
||||
end
|
||||
|
||||
-- 恢复默认连击点显示
|
||||
self:RestoreDefaultComboPoints()
|
||||
|
||||
-- 隐藏自定义职业标记
|
||||
self:HideAllClassMarkers()
|
||||
end
|
||||
|
||||
-- 【新增】只更新血量相关数据(频繁调用时使用)
|
||||
function Creature_MultiLifeMultiplierAddon:UpdateHealthData(targetGUID, currentHealth)
|
||||
-- 【新增】检查当前是否应该使用自定义框架
|
||||
if not self.usingCustomFrame then
|
||||
return -- 如果不使用自定义框架,直接返回
|
||||
end
|
||||
|
||||
-- 【新增】检查目标GUID是否匹配当前目标
|
||||
local currentTargetGUID = UnitGUID("target")
|
||||
if currentTargetGUID ~= targetGUID then
|
||||
return -- 如果GUID不匹配,说明目标已经切换,直接返回
|
||||
end
|
||||
|
||||
-- 获取玩家对当前目标的威胁值
|
||||
local isTanking, status, scaled, raw, threatValue = UnitDetailedThreatSituation("player", "target")
|
||||
if not self.SavedData[targetGUID] then return end
|
||||
|
||||
local data = self.SavedData[targetGUID]
|
||||
|
||||
-- 【新增】如果是初始化更新,跳过避免重复
|
||||
if data.isInitialUpdate then
|
||||
return
|
||||
end
|
||||
|
||||
-- 【新增】防止重复调用
|
||||
if data.currentHealth == currentHealth then
|
||||
return
|
||||
end
|
||||
|
||||
-- 更新血量数据
|
||||
if currentHealth > data.lastHealth then
|
||||
-- 血量增加(自动回血),也需要更新UI
|
||||
data.lastHealth = data.currentHealth
|
||||
data.currentHealth = currentHealth
|
||||
elseif currentHealth < data.lastHealth then
|
||||
-- 血量减少(受到伤害)
|
||||
self:PlayDamageEffects()
|
||||
data.lastHealth = data.currentHealth
|
||||
data.currentHealth = currentHealth
|
||||
end
|
||||
|
||||
-- 只更新血条,不重新设置整个UI
|
||||
print("只更新血条,不重新设置整个UI")
|
||||
self:UpdateHealthBar(data)
|
||||
|
||||
-- 【新增】定期更新buff和连击点(控制频率避免性能问题)
|
||||
local currentTime = GetTime()
|
||||
|
||||
-- 每0.1秒更新一次buff显示
|
||||
if not self.lastBuffUpdateTime or currentTime - self.lastBuffUpdateTime > 0.1 then
|
||||
self:UpdateBuffs()
|
||||
self.lastBuffUpdateTime = currentTime
|
||||
end
|
||||
|
||||
-- 每0.05秒更新一次连击点(连击点变化更频繁)
|
||||
if not self.lastClassMarkerUpdateTime or currentTime - self.lastClassMarkerUpdateTime > 0.05 then
|
||||
self:UpdateClassMarkers()
|
||||
self.lastClassMarkerUpdateTime = currentTime
|
||||
end
|
||||
end
|
||||
|
||||
-- 【新增】初始化目标数据
|
||||
function Creature_MultiLifeMultiplierAddon:InitializeTargetData(targetGUID, targetEntry)
|
||||
if not self.SavedData[targetGUID] then
|
||||
local isDead = UnitIsDeadOrGhost("target")
|
||||
self.SavedData[targetGUID] = {
|
||||
entry = targetEntry,
|
||||
healthPerBar = self.CreatureTemplates[targetEntry].healthPerBar,
|
||||
currentHealth = isDead and 0 or self.CreatureTemplates[targetEntry].healthPerBar,
|
||||
lastHealth = isDead and 0 or self.CreatureTemplates[targetEntry].healthPerBar
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- 【新增】设置自定义血条框架
|
||||
function Creature_MultiLifeMultiplierAddon:SetupCustomHealthFrame()
|
||||
-- 隐藏默认目标框架
|
||||
TargetFrame:Hide()
|
||||
TargetFrame:UnregisterAllEvents()
|
||||
|
||||
-- 隐藏默认连击点系统
|
||||
self:HideDefaultComboPoints()
|
||||
|
||||
-- 显示自定义血条框架
|
||||
self.CustomHealthFrame:Show()
|
||||
end
|
||||
|
||||
-- 【新增】更新静态目标信息(只在目标切换时调用)
|
||||
function Creature_MultiLifeMultiplierAddon:UpdateStaticTargetInfo()
|
||||
-- 【重要】先设置基础信息,无论是否死亡都需要显示
|
||||
self:SetCreatureTypeIcon("target") --设置生物类型图标(野兽、龙类等...)
|
||||
self:SetCreatureClassificationIcon("target") --设置生物分类图标(普通、精英等...)
|
||||
|
||||
-- 设置名称和等级
|
||||
self.nameText:SetText(UnitName("target"))
|
||||
self.levelText:SetText("Lv" .. UnitLevel("target"))
|
||||
|
||||
-- 设置头像
|
||||
if UnitExists("target") and not UnitIsPlayer("target") then
|
||||
SetPortraitTexture(self.portraitIcon, "target")
|
||||
end
|
||||
|
||||
-- 设置BOSS图标
|
||||
if UnitClassification("target") == "worldboss" then
|
||||
self.bossIcon:Show()
|
||||
else
|
||||
self.bossIcon:Hide()
|
||||
end
|
||||
|
||||
-- 检查死亡状态
|
||||
local isDead = UnitIsDeadOrGhost("target")
|
||||
|
||||
if isDead then
|
||||
-- 如果目标死亡,设置死亡状态但不返回,继续处理血条数据
|
||||
self:SetDeadTargetState()
|
||||
else
|
||||
-- 如果不是死亡状态,恢复正常状态
|
||||
self:RestoreNormalTargetState()
|
||||
end
|
||||
|
||||
-- 获取当前目标数据并更新血条
|
||||
local targetGUID = UnitGUID("target")
|
||||
if targetGUID and self.SavedData[targetGUID] then
|
||||
local data = self.SavedData[targetGUID]
|
||||
-- 根据死亡状态更新血量
|
||||
if isDead then
|
||||
data.currentHealth = 0
|
||||
elseif data.currentHealth == 0 then
|
||||
-- 如果之前是死亡状态,现在复活了,恢复满血
|
||||
data.currentHealth = data.healthPerBar
|
||||
end
|
||||
-- 【新增】添加标记,表示这是目标切换时的初始化调用
|
||||
data.isInitialUpdate = true
|
||||
self:UpdateHealthBar(data,isDead)
|
||||
data.isInitialUpdate = false
|
||||
end
|
||||
|
||||
-- 只有在非死亡状态下才初始化buff和职业标记
|
||||
if not isDead then
|
||||
-- 初始化职业标记
|
||||
self:UpdateClassMarkers()
|
||||
self.lastClassMarkerUpdateTime = GetTime()
|
||||
|
||||
-- 初始化Buff显示
|
||||
self:UpdateBuffs()
|
||||
self.lastBuffUpdateTime = GetTime()
|
||||
end
|
||||
end
|
||||
|
||||
-- 新增辅助函数:确保默认框架可见
|
||||
function Creature_MultiLifeMultiplierAddon:EnsureDefaultFrameVisible()
|
||||
-- 轻量级检查,确保默认框架处于活动状态
|
||||
if not TargetFrame:IsShown() and UnitExists("target") then
|
||||
TargetFrame:Show()
|
||||
end
|
||||
end
|
||||
|
||||
-- 新增调试函数
|
||||
function Creature_MultiLifeMultiplierAddon:DebugTargetInfo(isCustom, hasTarget)
|
||||
local targetType = hasTarget and (isCustom and "自定义生物" or "普通生物") or "无目标"
|
||||
print(string.format("目标切换: %s | 状态: %s", targetType, self.usingCustomFrame and "使用自定义框架" or "使用默认框架"))
|
||||
end
|
||||
|
||||
-- 【新增】设置目标存活状态的所有UI效果
|
||||
function Creature_MultiLifeMultiplierAddon:RestoreNormalTargetState()
|
||||
-- 恢复所有纹理饱和度
|
||||
if self.portraitIcon then
|
||||
self.portraitIcon:SetDesaturated(false)
|
||||
end
|
||||
|
||||
if self.CreateClassificationButton then
|
||||
local texture = self.CreateClassificationButton:GetNormalTexture()
|
||||
if texture then
|
||||
texture:SetDesaturated(false)
|
||||
end
|
||||
end
|
||||
if self.CreateTypeButton then
|
||||
local texture = self.CreateTypeButton:GetNormalTexture()
|
||||
if texture then
|
||||
texture:SetDesaturated(false)
|
||||
end
|
||||
end
|
||||
|
||||
if self.HealthPerText then
|
||||
self.HealthPerText:SetTextColor(150 / 200, 140 / 255, 0)
|
||||
end
|
||||
|
||||
-- 目标颜色值 - 如果为真,将返回更合适的单位选择颜色。例如,如果用于已死亡的敌方目标,默认返回红色(敌方),但扩展返回将是灰色(已死亡)
|
||||
local red, green, blue, alpha = UnitSelectionColor("target")
|
||||
self.levelText:SetTextColor(red, green, blue, alpha) --等级文本设置为返回的颜色
|
||||
self.nameText:SetTextColor(red, green, blue, alpha) --名称文本设置为返回的颜色
|
||||
|
||||
-- 【关键】重置总血条遮罩
|
||||
|
||||
self.Z_border.maskOverlay:SetAlpha(0)
|
||||
self.Z_border.maskOverlay:SetWidth(0)
|
||||
-- print("总血量宽度= 0 --目标存活状态的时候")
|
||||
|
||||
if self.healthText then
|
||||
self.healthText:SetText("")
|
||||
self.healthText:SetFont("Fonts\\ZYKai_T.TTF", 12, "OUTLINE, MONOCHROME")
|
||||
self.healthText:SetTextColor(1, 1, 1)
|
||||
self.healthText:ClearAllPoints() --重置位置之前需要清除之前的位置设置
|
||||
self.healthText:SetPoint("BOTTOMRIGHT", self.healthBarBg, "TOPRIGHT", 0, 5) -- 血量文本放到右上角
|
||||
end
|
||||
|
||||
-- 右下方百分比攻击存活状态
|
||||
if self.HealthPerAttImg then
|
||||
self.HealthPerAttImg:SetTexCoord(0, 0.5, 0, 1)
|
||||
end
|
||||
|
||||
-- 右下方百分比文本存活颜色
|
||||
self.HealthPerText:SetTextColor(150 / 200, 140 / 255, 0) -- 总血量百分比文本设置为正常
|
||||
|
||||
-- 头像颜色存活饱和度正常
|
||||
self.portraitIcon:SetDesaturated(false)
|
||||
end
|
||||
|
||||
-- 【新增】设置目标死亡状态的所有UI效果
|
||||
function Creature_MultiLifeMultiplierAddon:SetDeadTargetState()
|
||||
-- 血条清零
|
||||
if self.healthBar then
|
||||
self.healthBar:SetValue(0)
|
||||
end
|
||||
if self.healthBarBg then
|
||||
self.healthBarBg:SetValue(0)
|
||||
self.healthBarBg:Show()
|
||||
end
|
||||
|
||||
-- 头型纹理去除饱和度
|
||||
if self.portraitIcon then
|
||||
self.portraitIcon:SetDesaturated(true) -- 去除饱和度
|
||||
end
|
||||
|
||||
-- 生物分类按钮图标去除饱和度
|
||||
if self.CreateClassificationButton then
|
||||
local texture = self.CreateClassificationButton:GetNormalTexture()
|
||||
if texture then
|
||||
texture:SetDesaturated(true)
|
||||
end
|
||||
end
|
||||
|
||||
-- 生物类型按钮图标去除饱和度
|
||||
if self.CreateTypeButton then
|
||||
local texture = self.CreateTypeButton:GetNormalTexture()
|
||||
if texture then
|
||||
texture:SetDesaturated(true)
|
||||
end
|
||||
end
|
||||
|
||||
-- 血量文本设置为灰色
|
||||
if self.healthText then
|
||||
self.healthText:SetTextColor(0.7, 0.7, 0.7) -- 设置为灰色
|
||||
self.healthText:SetText("死亡")
|
||||
self.healthText:SetFont("Fonts\\ZYKai_T.TTF", 16, "OUTLINE, MONOCHROME")
|
||||
self.healthText:ClearAllPoints() --重置位置之前需要清除之前的位置设置
|
||||
self.healthText:SetPoint("CENTER", self.CustomHealthFrame, "CENTER", 0, 0) -- 死亡文本在中间
|
||||
print("血量文本-目标死亡状态")
|
||||
end
|
||||
|
||||
-- 生物名称文本设置为灰色
|
||||
if self.nameText then
|
||||
self.nameText:SetTextColor(0.7, 0.7, 0.7)
|
||||
end
|
||||
|
||||
-- 生物等级文本设置为灰色
|
||||
if self.levelText then
|
||||
self.levelText:SetTextColor(0.7, 0.7, 0.7)
|
||||
end
|
||||
|
||||
-- 血量层数文本设置为灰色
|
||||
if self.layerText then
|
||||
self.layerText:SetTextColor(0.5, 0.5, 0.5)
|
||||
end
|
||||
|
||||
if self.HealthPerText then
|
||||
self.HealthPerText:SetTextColor(0.5, 0.5, 0.5)
|
||||
self.HealthPerText:SetText("......")
|
||||
end
|
||||
|
||||
-- 移除所有职业标记
|
||||
if self.HideAllClassMarkers then
|
||||
self:HideAllClassMarkers()
|
||||
end
|
||||
|
||||
-- 移除所有buff和debuff
|
||||
if self.RemoveAllBuffs then
|
||||
self:RemoveAllBuffs() --利用UpdateBuffs也能隐藏buff
|
||||
end
|
||||
|
||||
-- 隐藏Boss图标(死亡时不显示威胁等级)
|
||||
if self.bossIcon then
|
||||
self.bossIcon:Hide()
|
||||
end
|
||||
|
||||
-- 停止所有动画效果
|
||||
if self.damageTrackBar and self.damageTrackBar.animationData then
|
||||
self.damageTrackBar.animationData.isAnimating = false
|
||||
self.damageTrackBar:Hide()
|
||||
end
|
||||
if self.flashEffectBar and self.flashEffectBar.animationData then
|
||||
self.flashEffectBar.animationData.isAnimating = false
|
||||
self.flashEffectBar:Hide()
|
||||
end
|
||||
|
||||
-- 设置攻击图标为死亡状态
|
||||
if self.HealthPerAttImg then
|
||||
self.HealthPerAttImg:SetTexCoord(0.5, 1, 0, 1) -- 切换到死亡图标
|
||||
end
|
||||
|
||||
-- 总血条也设置为死亡状态
|
||||
if self.Z_border and self.Z_border.maskOverlay then
|
||||
self.Z_border.maskOverlay:SetWidth(self.Z_border.healthBar:GetWidth()) -- 完全遮罩
|
||||
print("死亡状态下的总血量宽度= --死亡状态的时候"..self.Z_border.healthBar:GetWidth())
|
||||
end
|
||||
end
|
||||
|
||||
Creature_MultiLifeMultiplierAddon:Initialize()
|
||||
|
||||
@ -171,7 +171,6 @@ function Creature_MultiLifeMultiplierAddon:UpdateBuffs()
|
||||
button.importantBorder:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
-- 闪烁效果检查
|
||||
if duration and expirationTime then
|
||||
local timeLeft = tonumber(expirationTime) - GetTime()
|
||||
@ -180,11 +179,13 @@ function Creature_MultiLifeMultiplierAddon:UpdateBuffs()
|
||||
if not button.flashAnimation then
|
||||
button.flashAnimation = button:CreateAnimationGroup()
|
||||
local flash = button.flashAnimation:CreateAnimation("Alpha")
|
||||
flash:SetFromAlpha(1)
|
||||
flash:SetToAlpha(0.3)
|
||||
flash:SetChange(-0.7) -- 从1变为0.3,变化量为-0.7
|
||||
flash:SetDuration(0.5)
|
||||
flash:SetSmoothing("IN_OUT")
|
||||
button.flashAnimation:SetLooping("BOUNCE")
|
||||
-- 设置初始透明度
|
||||
button.flashAnimation:SetScript("OnPlay", function()
|
||||
button:SetAlpha(1)
|
||||
end)
|
||||
end
|
||||
button.flashAnimation:Play()
|
||||
else
|
||||
@ -252,7 +253,7 @@ function Creature_MultiLifeMultiplierAddon:UpdateBuffs()
|
||||
-- 设置debuff边框颜色
|
||||
if button.border then
|
||||
-- 根据debuffType设置不同的纹理坐标和颜色
|
||||
if debuffType == "Magic" then --魔法类型的负面效果(蓝色)
|
||||
if debuffType == "Magic" then --魔法类型的负面效果(蓝色)
|
||||
button.border:SetTexCoord(0.296875, 0.5703125, 0, 0.515625)
|
||||
button.border:SetVertexColor(0.2, 0.6, 1.0)
|
||||
elseif debuffType == "Disease" then --疾病类型的负面效果(棕色)
|
||||
@ -305,11 +306,12 @@ function Creature_MultiLifeMultiplierAddon:UpdateBuffs()
|
||||
if not button.flashAnimation then
|
||||
button.flashAnimation = button:CreateAnimationGroup()
|
||||
local flash = button.flashAnimation:CreateAnimation("Alpha")
|
||||
flash:SetFromAlpha(1)
|
||||
flash:SetToAlpha(0.3)
|
||||
flash:SetChange(-0.7)
|
||||
flash:SetDuration(0.5)
|
||||
flash:SetSmoothing("IN_OUT")
|
||||
button.flashAnimation:SetLooping("BOUNCE")
|
||||
button.flashAnimation:SetScript("OnPlay", function()
|
||||
button:SetAlpha(1)
|
||||
end)
|
||||
end
|
||||
button.flashAnimation:Play()
|
||||
else
|
||||
@ -354,3 +356,32 @@ function Creature_MultiLifeMultiplierAddon:UpdateBuffs()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 在初始化部分之后添加这个移除函数
|
||||
function Creature_MultiLifeMultiplierAddon:RemoveAllBuffs()
|
||||
-- 隐藏所有buff按钮
|
||||
if self.buffButtons then
|
||||
for i = 1, #self.buffButtons do
|
||||
local button = self.buffButtons[i]
|
||||
button:Hide()
|
||||
|
||||
-- 停止闪烁动画(如果有)
|
||||
if button.flashAnimation then
|
||||
button.flashAnimation:Stop()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 隐藏所有debuff按钮
|
||||
if self.debuffButtons then
|
||||
for i = 1, #self.debuffButtons do
|
||||
local button = self.debuffButtons[i]
|
||||
button:Hide()
|
||||
|
||||
-- 停止闪烁动画(如果有)
|
||||
if button.flashAnimation then
|
||||
button.flashAnimation:Stop()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,31 +1,30 @@
|
||||
-- 职业标记系统
|
||||
print("职业标记系统开始加载")
|
||||
|
||||
-- 初始化职业标记系统
|
||||
function Creature_MultiLifeMultiplierAddon:ClassMarkersInitialize()
|
||||
-- 获取玩家职业(使用英文常量)
|
||||
local _, englishClass = UnitClass("player")
|
||||
-- 根据职业创建相应的标记框架
|
||||
if englishClass == "ROGUE" then
|
||||
if englishClass == "ROGUE" then --潜行者
|
||||
self:CreateComboPointSystem()
|
||||
elseif englishClass == "WARLOCK" then
|
||||
self:CreateWarlockMarkers()
|
||||
self:CreateWarlockMarkers() --术士
|
||||
elseif englishClass == "HUNTER" then
|
||||
self:CreateHunterMarkers()
|
||||
self:CreateHunterMarkers() --猎人
|
||||
elseif englishClass == "MAGE" then
|
||||
self:CreateMageMarkers()
|
||||
self:CreateMageMarkers() --法师
|
||||
elseif englishClass == "DRUID" then
|
||||
self:CreateDruidMarkers()
|
||||
--self:CreateDruidMarkers() --德鲁伊
|
||||
self:CreateComboPointSystem()
|
||||
elseif englishClass == "PRIEST" then
|
||||
self:CreatePriestMarkers()
|
||||
self:CreatePriestMarkers() --牧师
|
||||
elseif englishClass == "PALADIN" then
|
||||
self:CreatePaladinMarkers()
|
||||
self:CreatePaladinMarkers() --圣骑士
|
||||
elseif englishClass == "DEATHKNIGHT" then
|
||||
self:CreateDeathKnightMarkers()
|
||||
self:CreateDeathKnightMarkers() --死亡骑士
|
||||
elseif englishClass == "SHAMAN" then
|
||||
self:CreateShamanMarkers()
|
||||
self:CreateShamanMarkers() --萨满
|
||||
elseif englishClass == "WARRIOR" then
|
||||
self:CreateWarriorMarkers()
|
||||
self:CreateWarriorMarkers() --战士
|
||||
else
|
||||
print("未知职业或不支持的职业:", englishClass)
|
||||
end
|
||||
@ -46,22 +45,15 @@ function Creature_MultiLifeMultiplierAddon:CreateComboPointSystem()
|
||||
-- 添加背景用于调试可见性
|
||||
local debugBg = self.comboPointFrame:CreateTexture(nil, "BACKGROUND")
|
||||
debugBg:SetAllPoints(self.comboPointFrame)
|
||||
-- debugBg:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||
-- debugBg:SetVertexColor(1, 1, 1, 0.3) -- 半透明红色背景用于调试
|
||||
self.comboPoints = {}
|
||||
for i = 1, 5 do
|
||||
local pointFrame = CreateFrame("Frame", "CustomComboPoint" .. i, self.comboPointFrame)
|
||||
pointFrame:SetSize(10, 10)
|
||||
|
||||
local yOffset = (i - 1) * -9 -- 每个连击点间隔9像素
|
||||
pointFrame:SetPoint("TOP", self.comboPointFrame, "TOP", 0, yOffset)
|
||||
|
||||
-- 背景
|
||||
local pointBg = pointFrame:CreateTexture(nil, "BACKGROUND")
|
||||
pointBg:SetAllPoints(pointFrame)
|
||||
-- pointBg:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||
-- pointBg:SetVertexColor(0.2, 0.2, 0.2, 0.8)
|
||||
|
||||
-- 图标
|
||||
local point = pointFrame:CreateTexture(nil, "ARTWORK")
|
||||
point:SetSize(10, 10)
|
||||
@ -74,10 +66,36 @@ function Creature_MultiLifeMultiplierAddon:CreateComboPointSystem()
|
||||
pointBg:Show()
|
||||
point:Show()
|
||||
|
||||
-- 在按钮创建部分添加闪光纹理
|
||||
local flash = pointFrame:CreateTexture(nil, "OVERLAY")
|
||||
flash:SetSize(16, 16) -- 放大一点
|
||||
flash:SetPoint("CENTER", pointFrame, "CENTER", 0, 0)
|
||||
flash:SetTexture("Interface\\Buttons\\UI-Panel-Button-Glow")
|
||||
flash:SetBlendMode("ADD")
|
||||
flash:Hide()
|
||||
|
||||
-- 创建动画组
|
||||
local flashAnim = flash:CreateAnimationGroup()
|
||||
local fadeIn = flashAnim:CreateAnimation("Alpha")
|
||||
fadeIn:SetDuration(0.2)
|
||||
fadeIn:SetOrder(1)
|
||||
|
||||
local fadeOut = flashAnim:CreateAnimation("Alpha")
|
||||
fadeOut:SetDuration(0.2)
|
||||
fadeOut:SetOrder(2)
|
||||
|
||||
-- 设置动画结束后的回调
|
||||
flashAnim:SetScript("OnFinished", function()
|
||||
flash:Hide()
|
||||
end)
|
||||
|
||||
self.comboPoints[i] = {
|
||||
frame = pointFrame,
|
||||
background = pointBg,
|
||||
icon = point
|
||||
icon = point,
|
||||
|
||||
flash = flash,
|
||||
flashAnim = flashAnim
|
||||
}
|
||||
end
|
||||
-- 暂时显示框架用于调试
|
||||
@ -135,8 +153,6 @@ end
|
||||
|
||||
-- 德鲁伊标记系统(DoT追踪)
|
||||
function Creature_MultiLifeMultiplierAddon:CreateDruidMarkers()
|
||||
print("创建德鲁伊标记系统")
|
||||
|
||||
-- 月火术标记
|
||||
self.moonfireFrame = CreateFrame("Frame", nil, self.CustomHealthFrame)
|
||||
self.moonfireFrame:SetSize(25, 25)
|
||||
@ -160,8 +176,6 @@ end
|
||||
|
||||
-- 牧师标记系统
|
||||
function Creature_MultiLifeMultiplierAddon:CreatePriestMarkers()
|
||||
print("创建牧师标记系统")
|
||||
|
||||
-- 真言术:痛标记
|
||||
self.shadowWordPainFrame = CreateFrame("Frame", nil, self.CustomHealthFrame)
|
||||
self.shadowWordPainFrame:SetSize(25, 25)
|
||||
@ -185,8 +199,6 @@ end
|
||||
|
||||
-- 圣骑士标记系统
|
||||
function Creature_MultiLifeMultiplierAddon:CreatePaladinMarkers()
|
||||
print("创建圣骑士标记系统")
|
||||
|
||||
-- 审判标记
|
||||
self.judgementFrame = CreateFrame("Frame", nil, self.CustomHealthFrame)
|
||||
self.judgementFrame:SetSize(25, 25)
|
||||
@ -200,7 +212,7 @@ end
|
||||
|
||||
-- 死亡骑士标记系统
|
||||
function Creature_MultiLifeMultiplierAddon:CreateDeathKnightMarkers()
|
||||
print("创建死亡骑士标记系统")
|
||||
|
||||
|
||||
-- 血疫标记
|
||||
self.bloodPlagueFrame = CreateFrame("Frame", nil, self.CustomHealthFrame)
|
||||
@ -225,7 +237,7 @@ end
|
||||
|
||||
-- 萨满标记系统
|
||||
function Creature_MultiLifeMultiplierAddon:CreateShamanMarkers()
|
||||
print("创建萨满标记系统")
|
||||
|
||||
|
||||
-- 大地震击标记
|
||||
self.earthShockFrame = CreateFrame("Frame", nil, self.CustomHealthFrame)
|
||||
@ -240,7 +252,7 @@ end
|
||||
|
||||
-- 战士标记系统
|
||||
function Creature_MultiLifeMultiplierAddon:CreateWarriorMarkers()
|
||||
print("创建战士标记系统")
|
||||
|
||||
|
||||
-- 破甲标记
|
||||
self.sunderArmorFrame = CreateFrame("Frame", nil, self.CustomHealthFrame)
|
||||
@ -265,25 +277,26 @@ function Creature_MultiLifeMultiplierAddon:UpdateClassMarkers()
|
||||
|
||||
-- 潜行者连击点更新
|
||||
if englishClass == "ROGUE" then
|
||||
self:UpdatComboPointSystem() -- 盗贼连击点标记更新
|
||||
self:UpdatComboPointSystem() -- 盗贼连击点标记更新
|
||||
elseif englishClass == "WARLOCK" then
|
||||
self:UpdateWarlockMarkers() -- 术士标记更新逻辑
|
||||
self:UpdateWarlockMarkers() -- 术士标记更新逻辑
|
||||
elseif englishClass == "HUNTER" then
|
||||
self:UpdateHunterMarkers() -- 猎人标记更新逻辑
|
||||
self:UpdateHunterMarkers() -- 猎人标记更新逻辑
|
||||
elseif englishClass == "MAGE" then
|
||||
self:UpdateMageMarkers() --法师标记更新逻辑
|
||||
self:UpdateMageMarkers() --法师标记更新逻辑
|
||||
elseif englishClass == "DRUID" then
|
||||
self:UpdateDruidMarkers() -- 德鲁伊标记更新逻辑
|
||||
--self:UpdateDruidMarkers() -- 德鲁伊标记更新逻辑
|
||||
self:UpdatComboPointSystem() -- 盗贼连击点标记更新
|
||||
elseif englishClass == "PRIEST" then
|
||||
self:UpdatePriestMarkers() -- 牧师标记更新逻辑
|
||||
self:UpdatePriestMarkers() -- 牧师标记更新逻辑
|
||||
elseif englishClass == "PALADIN" then
|
||||
self:UpdatePaladinMarkers() -- 圣骑士标记更新逻辑
|
||||
self:UpdatePaladinMarkers() -- 圣骑士标记更新逻辑
|
||||
elseif englishClass == "DEATHKNIGHT" then
|
||||
self:UpdateDeathKnightMarkers() -- 死亡骑士标记更新逻辑
|
||||
elseif englishClass == "SHAMAN" then
|
||||
self:UpdateShamanMarkers() -- 萨满标记更新逻辑
|
||||
self:UpdateShamanMarkers() -- 萨满标记更新逻辑
|
||||
elseif englishClass == "WARRIOR" then
|
||||
self:UpdateWarriorMarkers() -- 战士标记更新逻辑
|
||||
self:UpdateWarriorMarkers() -- 战士标记更新逻辑
|
||||
end
|
||||
end
|
||||
|
||||
@ -364,7 +377,6 @@ function Creature_MultiLifeMultiplierAddon:UpdatComboPointSystem()
|
||||
|
||||
-- 检查是否达到满连击点
|
||||
local isMaxCombo = (comboPoints == 5)
|
||||
|
||||
for i = 1, 5 do
|
||||
if self.comboPoints[i] then
|
||||
if i <= comboPoints then
|
||||
@ -380,6 +392,16 @@ function Creature_MultiLifeMultiplierAddon:UpdatComboPointSystem()
|
||||
UIFrameFlash(self.comboPoints[i].frame, 0.3, 0.5, 50, true, 0, 0)
|
||||
-- 更高亮的颜色
|
||||
self.comboPoints[i].icon:SetVertexColor(0, 1, 0)
|
||||
|
||||
----------------------------- 动画版本闪烁 --不好看 -----------------------------
|
||||
-- self.comboPoints[i].flash:Show()
|
||||
-- self.comboPoints[i].flashAnim:Play()
|
||||
-- -- 动画结束后隐藏闪光效果
|
||||
-- self.comboPoints[i].flashAnim:SetScript("OnFinished", function()
|
||||
-- self.comboPoints[i].flash:Hide()
|
||||
-- end)
|
||||
----------------------------- 动画版本闪烁 --不好看 -----------------------------
|
||||
|
||||
else
|
||||
-- 停止闪烁,确保框架可见
|
||||
UIFrameFlashStop(self.comboPoints[i].frame)
|
||||
@ -467,5 +489,3 @@ end
|
||||
-- 战士标记更新逻辑(暂时为空)
|
||||
function Creature_MultiLifeMultiplierAddon:UpdateWarriorMarkers()
|
||||
end
|
||||
|
||||
print("职业markers文件结束")
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
local SM_Blood_Creature_TYPE_ICONS =
|
||||
{
|
||||
["野兽"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["龙类"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["恶魔"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["元素生物"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["巨人"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["亡灵"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["人型生物"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["小动物"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["机械"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["未指定"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["图腾"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["非战斗宠物"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["气体云雾"] = "Interface\\Icons\\ability_hunter_beastwithin",
|
||||
["野兽"] = "Interface\\Icons\\ability_druid_catform",
|
||||
["龙类"] = "Interface\\Icons\\ability_hunter_pet_dragonhawk",
|
||||
["恶魔"] = "Interface\\Icons\\spell_shadow_summonfelhunter",
|
||||
["元素生物"] = "Interface\\Icons\\spell_fire_elemental_totem",
|
||||
["巨人"] = "Interface\\Icons\\ability_warrior_titansgrip",
|
||||
["亡灵"] = "Interface\\Icons\\spell_deathknight_classicon",
|
||||
["人型生物"] = "Interface\\Icons\\achievement_character_human_male",
|
||||
["小动物"] = "Interface\\Icons\\ability_hunter_pet_rabbit",
|
||||
["机械"] = "Interface\\Icons\\ability_hunter_pet_netherray",
|
||||
["未指定"] = "Interface\\Icons\\inv_misc_questionmark",
|
||||
["图腾"] = "Interface\\Icons\\spell_nature_reincarnation",
|
||||
["非战斗宠物"] = "Interface\\Icons\\ability_hunter_beastcall",
|
||||
["气体云雾"] = "Interface\\Icons\\spell_nature_fog",
|
||||
}
|
||||
|
||||
local SM_Blood_Creature_CLASSIFICATION_ICONS = {
|
||||
["worldboss"] = "Interface\\TargetingFrame\\UI-TargetingFrame-Skull",
|
||||
["rareelite"] = "Interface\\Icons\\Achievement_General_StayClassy",
|
||||
["elite"] = "Interface\\Icons\\Achievement_PVP_A_A",
|
||||
["rare"] = "Interface\\Icons\\Achievement_General_StayClassy",
|
||||
["normal"] = "Interface\\Icons\\Achievement_General",
|
||||
["trivial"] = "Interface\\Icons\\Achievement_General_StayClassy",
|
||||
["trivial"] = "Interface\\Icons\\Spell_Shadow_NightOfTheDead", -- 微不足道 - 嘲讽技能
|
||||
["normal"] = "Interface\\Icons\\Spell_Shadow_DemonicPact", -- 普通 - 基础战斗技能
|
||||
["elite"] = "Interface\\Icons\\Spell_Nature_RemoveDisease", -- 精英 - 双持武器表示威胁
|
||||
["rare"] = "Interface\\Icons\\Spell_Holy_DevineAegis", -- 稀有
|
||||
["rareelite"] = "Interface\\Icons\\Spell_Holy_HopeAndGrace", -- 稀有精英
|
||||
["worldboss"] = "Interface\\ICONS\\INV_Staff_99", -- 世界BOSS
|
||||
}
|
||||
|
||||
--设置生物类型图标(野兽、龙类等...)
|
||||
function Creature_MultiLifeMultiplierAddon:SetCreatureTypeIcon(unit)
|
||||
local creatureType = UnitCreatureType(unit)
|
||||
if creatureType and SM_Blood_Creature_TYPE_ICONS[creatureType] then
|
||||
@ -37,13 +37,16 @@ function Creature_MultiLifeMultiplierAddon:SetCreatureTypeIcon(unit)
|
||||
self.CreateTypeButton:SetScript("OnLeave", function(self)
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
|
||||
self.CreateTypeButton:Show()
|
||||
else
|
||||
self.CreateTypeButton:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
--设置生物分类图标(普通、精英等...)
|
||||
function Creature_MultiLifeMultiplierAddon:SetCreatureClassificationIcon(unit)
|
||||
local classification = UnitClassification(unit)
|
||||
|
||||
print("classification= ",classification)
|
||||
if classification and SM_Blood_Creature_CLASSIFICATION_ICONS[classification] then
|
||||
self.CreateClassificationButton:SetNormalTexture(SM_Blood_Creature_CLASSIFICATION_ICONS[classification])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user