From 1ce4de9bce9654202626fe0fdfdf451501b7f8b3 Mon Sep 17 00:00:00 2001 From: Parnic Date: Thu, 20 Nov 2008 03:50:59 +0000 Subject: [PATCH] - made the threat module only display while the player is in combat or the player has some threat on his target - added an option to only display the threat module while in a group. set by default --- modules/Threat.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/Threat.lua b/modules/Threat.lua index 2093a2d..0eac0b9 100644 --- a/modules/Threat.lua +++ b/modules/Threat.lua @@ -35,6 +35,7 @@ function IHUD_Threat.prototype:GetDefaultSettings() settings["enabled"] = false settings["aggroAlpha"] = 0.7 settings["usesDogTagStrings"] = false + settings["onlyShowInGroups"] = true return settings end @@ -81,6 +82,23 @@ function IHUD_Threat.prototype:GetOptions() order = 21 } + opts["onlyShowInGroups"] = { + type = 'toggle', + name = 'Only show in groups', + desc = 'Only show the threat bar if you are in a group or you have an active pet', + get = function() + return self.moduleSettings.onlyShowInGroups + end, + set = function(v) + self.moduleSettings.onlyShowInGroups = v + self:Redraw() + end, + disabled = function() + return not self.moduleSettings.enabled + end, + order = 22 + } + return opts end @@ -159,7 +177,13 @@ function IHUD_Threat.prototype:Update(unit) unit = self.unit end - if not UnitExists("target") or not UnitCanAttack("player", "target") or UnitIsDead("target") or UnitIsFriend("player", "target") or UnitPlayerControlled("target") then + if self.moduleSettings.onlyShowInGroups and (GetNumPartyMembers() == 0 and not UnitExists("pet")) then + self:Show(false) + return + end + + if not UnitExists("target") or not UnitCanAttack("player", "target") or UnitIsDead("target") + or UnitIsFriend("player", "target") or UnitPlayerControlled("target") then self:Show(false) return else @@ -169,6 +193,11 @@ function IHUD_Threat.prototype:Update(unit) local isTanking, threatState, scaledPercent, rawPercent = UnitDetailedThreatSituation("player", "target") local scaledPercentZeroToOne + if not self.combat and scaledPercent == 0 then + self:Show(false) + return + end + if not threatState or not scaledPercent or not rawPercent then scaledPercentZeroToOne = 0 scaledPercent = 0