153 lines
4.3 KiB
Lua
153 lines
4.3 KiB
Lua
--TSU
|
|
--COMBAT_LOG_EVENT_UNFILTERED NAME_PLATE_UNIT_ADDED NAME_PLATE_UNIT_REMOVED
|
|
function(allstates, e, unit, ...)
|
|
if e == "NAME_PLATE_UNIT_ADDED" then
|
|
if UnitIsPlayer(unit) then
|
|
--if UnitIsEnemy("player", unit) then
|
|
local hp = UnitHealth(unit)
|
|
local maxHp = UnitHealthMax(unit)
|
|
local hppp = aura_env.round(hp / maxHp * 100, 2)
|
|
local shortHP = aura_env.shorten(hp)
|
|
local shortmaxHP = aura_env.shorten(maxHp)
|
|
local name = UnitName(unit)
|
|
local class = UnitClass(unit)
|
|
allstates[unit] =
|
|
{
|
|
changed = true,
|
|
show = true,
|
|
resort = true,
|
|
progressType = "static",
|
|
value = hp,
|
|
total = maxHp,
|
|
index = hppp,
|
|
name = name,
|
|
hppp = hppp,
|
|
shortHP = shortHP,
|
|
shortmaxHP = shortmaxHP,
|
|
class = class,
|
|
}
|
|
return true
|
|
--end
|
|
end
|
|
elseif e == "NAME_PLATE_UNIT_REMOVED" then
|
|
if UnitIsPlayer(unit) then
|
|
--if UnitIsEnemy("player", unit) then
|
|
if allstates[unit] then
|
|
allstates[unit].show = false
|
|
allstates[unit].changed = true
|
|
return true
|
|
end
|
|
--end
|
|
end
|
|
elseif e == "COMBAT_LOG_EVENT_UNFILTERED" then
|
|
local se = select(1, ...)
|
|
if se == "SPELL_DAMAGE" or se == "SPELL_DAMAGE_PERIODIC" or se == "SPELL_HEAL" or se == "SPELL_HEAL_PERIODIC" then
|
|
local clogname = select(4, ...)
|
|
clogname = clogname:gsub("%-.+", "")
|
|
local unit = "nameplate"
|
|
for k,v in pairs(allstates) do
|
|
if allstates[k].name == clogname then
|
|
for i = 1, 40 do
|
|
local nplname = UnitName("nameplate" .. i)
|
|
if nplname == clogname then
|
|
unit = unit .. i
|
|
break
|
|
end
|
|
end
|
|
break
|
|
end
|
|
end
|
|
if UnitIsPlayer(unit) then
|
|
--if UnitIsEnemy("player", unit) then
|
|
if allstates[unit] then
|
|
local hp = UnitHealth(unit)
|
|
local maxHp = UnitHealthMax(unit)
|
|
local shortHP = aura_env.shorten(hp)
|
|
local shortmaxHP = aura_env.shorten(maxHp)
|
|
allstates[unit].value = hp
|
|
allstates[unit].total = maxHP
|
|
allstates[unit].shortHP = shortHP
|
|
allstates[unit].shortmaxHP = shortmaxHP
|
|
allstates[unit].show = true
|
|
allstates[unit].changed = true
|
|
return true
|
|
end
|
|
--end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--ANIMATION
|
|
function()
|
|
if aura_env.statee then
|
|
return aura_env.classColor(aura_env.statee.class)
|
|
end
|
|
end
|
|
|
|
--INIT
|
|
aura_env.round = function(var, n)
|
|
if (n) then
|
|
var = math.floor((var * 10^n) + 0.5) / (10^n)
|
|
else
|
|
var = math.floor(var+0.5)
|
|
end
|
|
return var
|
|
end
|
|
aura_env.shorten = function(val)
|
|
local function round(var, n)
|
|
if (n) then
|
|
var = math.floor((var * 10^n) + 0.5) / (10^n)
|
|
else
|
|
var = math.floor(var+0.5)
|
|
end
|
|
return var
|
|
end
|
|
local n = 2
|
|
if val < 1e3 then
|
|
return round(val, n)
|
|
elseif val > 1e3 and val < 1e6 then
|
|
return round(val / 1e3, n) .. "k"
|
|
elseif val > 1e6 and val < 1e9 then
|
|
return round(val / 1e6, n) .. "M"
|
|
elseif val > 1e9 then
|
|
return round(val / 1e9, n) .. "G"
|
|
end
|
|
end
|
|
aura_env.classColor = function(class)
|
|
if class == "Death Knight" then return 0.77, 0.12, 0.23, 1 elseif
|
|
class == "Demon Hunter" then return 0.64, 0.19, 0.79, 1 elseif
|
|
class == "Druid" then return 1, 0.49, 0.04, 1 elseif
|
|
class == "Hunter" then return 0.67, 0.83, 0.45, 1 elseif
|
|
class == "Mage" then return 0.25, 0.78, 0.92, 1 elseif
|
|
class == "Monk" then return 0, 1, 0.59, 1 elseif
|
|
class == "Paladin" then return 0.96, 0.55, 0.73, 1 elseif
|
|
class == "Priest" then return 1, 1, 1, 1 elseif
|
|
class == "Rogue" then return 1, 0.96, 0.41, 1 elseif
|
|
class == "Shaman" then return 0, 0.44, 0.87, 1 elseif
|
|
class == "Warlock" then return 0.53, 0.53, 0.93, 1 elseif
|
|
class == "Warrior" then return 0.78, 0.61, 0.43, 1 else
|
|
return 1, 1, 1, 1 end
|
|
end
|
|
aura_env.round = function(var, n)
|
|
if (n) then
|
|
var = math.floor((var * 10^n) + 0.5) / (10^n)
|
|
else
|
|
var = math.floor(var+0.5)
|
|
end
|
|
return var
|
|
end
|
|
aura_env.grad = function(c)
|
|
--c expected as [0, 1]
|
|
if c > 0.5 then
|
|
c = 1 - (2 * (c - 0.5))
|
|
return c, 1, 0, 1
|
|
else
|
|
c = c * 2
|
|
return 1, c, 0, 1
|
|
end
|
|
end
|
|
aura_env.range = function(val, min, max, max2)
|
|
val = 1 - (((max - val) / (max - min)) * max2)
|
|
return val
|
|
end |