WoWInterface SVN MyThreat

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 14 to Rev 15
    Reverse comparison

Rev 14 → Rev 15

MyThreat/MyThreat.lua
1,4 → 1,5
local MYTHREAT_VERSION = '1.3.4';
local MYTHREAT_VERSION = '1.4';
local MYTHREAT_ADJUST_VALUE = -410065408;
 
local options = {
type='group',
208,6 → 209,19
MyThreat:Print('Current version: ' .. MYTHREAT_VERSION);
end,
},
autoAdjust = {
type = 'toggle',
name = 'Auto-adjust threat',
desc = 'Auto-adjusts threat when abilities such as Fade and Mirror Image are active.',
get = function()
return MyThreat.db.profile.autoAdjust;
end,
set = function()
MyThreat.db.profile.autoAdjust = not MyThreat.db.profile.autoAdjust;
 
MyThreat:Process();
end;
}
}
};
 
250,6 → 264,7
},
fontSize = 16,
tankMode = false,
autoAdjust = true,
}
});
 
567,8 → 582,17
function MyThreat:GetThreat(pUnit, pTarget)
 
local isTanking, _, _, _, threatValue = UnitDetailedThreatSituation(pUnit, pTarget);
local adjusted = false;
 
-- adjust threat for Mirror Image and Fade abilities
if (threatValue and threatValue < 0 and pUnit == "player" and MyThreat.db.profile.autoAdjust) then
 
threatValue = threatValue - MYTHREAT_ADJUST_VALUE;
adjusted = true;
 
end
 
return threatValue, isTanking;
return threatValue, isTanking, adjusted;
 
end
 
577,7 → 601,7
function MyThreat:Process()
 
-- use current handler to get threat information
local threatDiff, threatDiffPercent, tankName = MyThreat.threatSourceHandler();
local threatDiff, threatDiffPercent, tankName, adjusted = MyThreat.threatSourceHandler();
 
-- if there is a current tank
if (tankName ~= nil and threatDiff ~= nil and threatDiffPercent ~= nil) then
593,36 → 617,54
MyThreat_ThreatFrameThreatPlayerName:Show();
 
end
 
local threatText, relativeThreatText;
local r = 0;
local g = 1;
local b = 0;
 
-- set the label for absolute threat diff
-- set the text for absolute threat diff
if (threatDiff >= 1000 or threatDiff <= -1000) then
MyThreat_ThreatFrameThreatDiff:SetText(format("%.2f", threatDiff / 1000) .. "k");
threatText = format("%.2f", threatDiff / 1000) .. "k";
else
MyThreat_ThreatFrameThreatDiff:SetText(format("%.0f", threatDiff));
threatText = format("%.0f", threatDiff);
end
 
-- set relative text
relativeThreatText = format("%.0f", threatDiffPercent * 100) .. "%";
 
if (adjusted) then
 
r = 0.4;
g = 0.8;
b = 0.95;
 
threatText = "(" .. threatText .. ")";
relativeThreatText = "(" .. relativeThreatText .. ")";
 
else
 
-- set the label for relative threat diff
MyThreat_ThreatFrameThreatPercDiff:SetText(format("%.0f", threatDiffPercent * 100) .. "%");
 
 
local r = 0;
local g = 1;
 
-- set the right bar colors
if (threatDiff <= MyThreat.db.profile.red.absolute or threatDiffPercent >= MyThreat.db.profile.red.relative) then
r = 1;
g = 0;
elseif (threatDiff <= MyThreat.db.profile.orange.absolute or threatDiffPercent >= MyThreat.db.profile.orange.relative) then
r = 1;
g = 0.5;
elseif (threatDiff <= MyThreat.db.profile.yellow.absolute or threatDiffPercent >= MyThreat.db.profile.yellow.relative) then
r = 1;
g = 1;
-- set the right bar colors
if (threatDiff <= MyThreat.db.profile.red.absolute or threatDiffPercent >= MyThreat.db.profile.red.relative) then
r = 1;
g = 0;
elseif (threatDiff <= MyThreat.db.profile.orange.absolute or threatDiffPercent >= MyThreat.db.profile.orange.relative) then
r = 1;
g = 0.5;
elseif (threatDiff <= MyThreat.db.profile.yellow.absolute or threatDiffPercent >= MyThreat.db.profile.yellow.relative) then
r = 1;
g = 1;
end
 
end
 
-- adjust labels
MyThreat_ThreatFrameThreatDiff:SetText(threatText);
MyThreat_ThreatFrameThreatPercDiff:SetText(relativeThreatText);
 
MyThreat_ThreatFrameThreatDiff:SetTextColor(r,g,0);
MyThreat_ThreatFrameThreatPercDiff:SetTextColor(r,g,0);
MyThreat_ThreatFrameThreatPlayerName:SetTextColor(r,g,0);
MyThreat_ThreatFrameThreatDiff:SetTextColor(r,g,b);
MyThreat_ThreatFrameThreatPercDiff:SetTextColor(r,g,b);
MyThreat_ThreatFrameThreatPlayerName:SetTextColor(r,g,b);
 
MyThreat_ThreatFrameThreatPlayerName:SetText(tankName);
 
658,7 → 700,8
return nil, nil, nil;
end
 
local currentTankName, currentTankThreat, playerThreat, threatDiff, threatDiffPercent;
local currentTankName, currentTankThreat, playerThreat, threatDiff, threatDiffPercent, adjusted;
adjusted = false;
 
-- first try for targettarget mode before using full scanning
if (UnitExists("targettarget")) then
698,7 → 741,7
 
if (currentTankName ~= nil) then
 
playerThreat = MyThreat:GetThreat("player", "target");
playerThreat, _, adjusted = MyThreat:GetThreat("player", "target");
 
if (playerThreat ~= nil) then
 
710,7 → 753,7
end
 
 
return threatDiff, threatDiffPercent, currentTankName;
return threatDiff, threatDiffPercent, currentTankName, adjusted;
 
end
 
723,8 → 766,9
return nil, nil, nil;
end
 
local currentTrailing, currentTrailingThreat, playerThreat, threatDiff, threatDiffPercent;
local currentTrailing, currentTrailingThreat, playerThreat, threatDiff, threatDiffPercent, adjusted;
currentTrailingThreat = 0;
adjusted = false;
 
for pName, uid in MyThreat:GetPartyUnitIds() do
 
745,7 → 789,7
 
if (currentTrailing ~= nil) then
 
playerThreat = MyThreat:GetThreat("player", "target");
playerThreat, _, adjusted = MyThreat:GetThreat("player", "target");
 
if (playerThreat ~= nil) then
 
757,7 → 801,7
end
 
 
return threatDiff, threatDiffPercent, currentTrailing;
return threatDiff, threatDiffPercent, currentTrailing, adjusted;
 
end
 
770,7 → 814,7
return nil, nil, nil;
end
 
local currentLowestFocus, currentLowestFocusThreat, playerThreat, threatDiff, threatDiffPercent;
local currentLowestFocus, currentLowestFocusThreat, playerThreat, threatDiff, threatDiffPercent, adjusted;
currentLowestFocusThreat = nil;
 
for i = 1, MyThreat.focusUnitsNum, 1 do
790,7 → 834,7
 
if (currentLowestFocus ~= nil) then
 
playerThreat = MyThreat:GetThreat("player", "target");
playerThreat, _, adjusted = MyThreat:GetThreat("player", "target");
 
if (playerThreat ~= nil) then
 
802,7 → 846,7
end
 
 
return threatDiff, threatDiffPercent, currentLowestFocus;
return threatDiff, threatDiffPercent, currentLowestFocus, adjusted;
 
end
 
MyThreat/MyThreat.toc
4,7 → 4,7
## Author: Brimm
## SavedVariables: MyThreatDB
## SavedVariablesPerCharacter: MyThreatDBPC
## Version: 1.3.4
## Version: 1.4
## X-Category: Interface Enhancements
## OptionalDeps: Ace3