Created
October 15, 2015 14:30
-
-
Save obble/db06ac0d057c44c697d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Settings | |
local showPets = false | |
local enableAddOn = true | |
local showFriendly = false | |
local showDebuffs = true | |
--Don't edit | |
local currentDebuffs = {} | |
local Players = {} | |
local Targets = {} | |
--classes rgb colors | |
local ClassColor = | |
{ | |
["Druid"] = {1.00,0.49,0.04}, | |
["Hunter"] = {0.67,0.83,0.45}, | |
["Mage"] = {0.41,0.80,0.94}, | |
["Paladin"] = {0.96,0.55,0.73}, | |
["Priest"] = {1,1,1}, | |
["Rogue"] = {1.00,0.96,0.41}, | |
["Shaman"] = {0.96,0.55,0.73},--{0.0,0.44,0.87}, | |
["Warlock"] = {0.58,0.51,0.79}, | |
["Warrior"] = {0.78,0.61,0.43}, | |
} | |
local listaDebuffs = {"Interface\Icons\Spell_Nature_Polymorph", "Interface\Icons\Spell_Frost_FrostNova"} | |
SLASH_HELLOWORLD1 = '/cnp'; -- 3. | |
function SlashCmdList.HELLOWORLD(msg, editbox) -- 4. | |
--print("Hello, World!"); | |
local count = 0 | |
--for _ in Targets do count = count + 1 end | |
for _,v in pairs(listaDebuffs) do | |
if v == "Interface\Icons\Spell_Nature_Polymorph" then | |
DEFAULT_CHAT_FRAME:AddMessage("teste poly") | |
break | |
end | |
end | |
end | |
function cnpHandleEvent(event) --Handles wow events | |
if event == "PLAYER_ENTERING_WORLD" then | |
if (enableAddOn) then | |
ShowNameplates() | |
if (showFriendly) then | |
ShowFriendNameplates() | |
else | |
HideFriendNameplates() | |
end | |
else | |
HideNameplates() | |
HideFriendNameplates() | |
end | |
end | |
if event == "PLAYER_TARGET_CHANGED" or event == "UNIT_AURA" then | |
getDebuffs() | |
end | |
end | |
function getDebuffs() --get debuffs on current target and store it in list | |
local i = 1 | |
currentDebuffs = {} | |
local debuff = UnitDebuff("target", i) | |
while debuff do | |
currentDebuffs[i] = debuff | |
i = i + 1 | |
debuff = UnitDebuff("target", i) | |
end | |
end | |
function cnpUpdate() --updates the frames ~every 20-50ms | |
CustomNameplates_OnUpdate() | |
end | |
local function IsNamePlateFrame(frame) | |
local overlayRegion = frame:GetRegions() | |
if not overlayRegion or overlayRegion:GetObjectType() ~= "Texture" or overlayRegion:GetTexture() ~= "Interface\\Tooltips\\Nameplate-Border" then | |
return false | |
end | |
return true | |
end | |
local function isPet(name) | |
PetsRU = {"Рыжая полосатая кошка", "Серебристая полосатая кошка", "Бомбейская кошка", "Корниш-рекс", | |
"Ястребиная сова", "Большая рогатая сова", "Макао", "Сенегальский попугай", "Черная королевская змейка", | |
"Бурая змейка", "Багровая змейка", "Луговая собачка", "Тараканище", "Анконская курица", "Щенок ворга", | |
"Паучок Дымной Паутины", "Механическая курица", "Птенец летучего хамелеона", "Зеленокрылый ара", "Гиацинтовый ара", | |
"Маленький темный дракончик", "Маленький изумрудный дракончик", "Маленький багровый дракончик", "Сиамская кошка", | |
"Пещерная крыса без сознания", "Механическая белка", "Крошечная ходячая бомба", "Крошка Дымок", "Механическая жаба", | |
"Заяц-беляк"} | |
for _, petName in pairs(PetsRU) do | |
if name == petName then | |
return true | |
end | |
end | |
PetsENG = {"Orange Tabby", "Silver Tabby", "Bombay", "Cornish Rex", "Hawk Owl", "Great Horned Owl", | |
"Cockatiel", "Senegal", "Black Kingsnake", "Brown Snake", "Crimson Snake", "Prairie Dog", "Cockroach", | |
"Ancona Chicken", "Worg Pup", "Smolderweb Hatchling", "Mechanical Chicken", "Sprite Darter", "Green Wing Macaw", | |
"Hyacinth Macaw", "Tiny Black Whelpling", "Tiny Emerald Whelpling", "Tiny Crimson Whelpling", "Siamese", | |
"Unconscious Dig Rat", "Mechanical Squirrel", "Pet Bombling", "Lil' Smokey", "Lifelike Mechanical Toad"} | |
for _, petName in pairs(PetsENG) do | |
if name == petName then | |
return true | |
end | |
end | |
return false | |
end | |
local function fillPlayerDB(name) | |
if Targets[name] == nil then | |
TargetByName(name, true) | |
table.insert(Targets, name) | |
Targets[name] = "ok" | |
if UnitIsPlayer("target") then | |
local class = UnitClass("target") | |
table.insert(Players, name) | |
Players[name] = {["class"] = class} | |
end | |
end | |
end | |
function CustomNameplates_OnUpdate() | |
local frames = { WorldFrame:GetChildren() } | |
for _, namePlate in ipairs(frames) do | |
if IsNamePlateFrame(namePlate) then | |
local HealthBar = namePlate:GetChildren() | |
local Border, Glow, Name, Level, _, RaidTargetIcon = namePlate:GetRegions() | |
--Healthbar | |
HealthBar:SetStatusBarTexture("Interface\\AddOns\\CustomNameplates\\barSmall") | |
HealthBar:ClearAllPoints() | |
HealthBar:SetPoint("CENTER", namePlate, "CENTER", -10, -10) | |
--HealthBar:SetWidth(100) --Edit this for width of the healthbar | |
--HealthBar:SetHeight(10) --Edit this for height of the healthbar | |
--HealthbarBackground | |
if HealthBar.bg == nil then | |
HealthBar.bg = HealthBar:CreateTexture(nil, "BORDER") | |
HealthBar.bg:SetTexture(0,0,0,0.85) | |
HealthBar.bg:ClearAllPoints() | |
HealthBar.bg:SetPoint("CENTER", namePlate, "CENTER", -10, -10) | |
HealthBar.bg:SetWidth(HealthBar:GetWidth() + 1.5) | |
HealthBar.bg:SetHeight(HealthBar:GetHeight() + 1.5) | |
end | |
--RaidTarget | |
RaidTargetIcon:ClearAllPoints() | |
RaidTargetIcon:SetWidth(15) --Edit this for width of the raidicon | |
RaidTargetIcon:SetHeight(15) --Edit this for height of the raidicon | |
RaidTargetIcon:SetPoint("BOTTOMLEFT", HealthBar, "BOTTOMLEFT", -18, -4) --Last two parameters are x,y coords for position relative to Healthbar | |
if namePlate.debuffIcons == nil then | |
namePlate.debuffIcons = {} | |
end | |
--DebuffIcons on TargetPlates | |
for j=1,16,1 do | |
if namePlate.debuffIcons[j] == nil and j<=8 then --first row | |
namePlate.debuffIcons[j] = namePlate:CreateTexture(nil, "BORDER") | |
namePlate.debuffIcons[j]:SetTexture(0,0,0,0) | |
namePlate.debuffIcons[j]:ClearAllPoints() | |
namePlate.debuffIcons[j]:SetPoint("BOTTOMLEFT", HealthBar, "BOTTOMLEFT", (j-1) * 14, -17) --Edit this for position of the debufficons, change 12 to the width of the icon in this case | |
namePlate.debuffIcons[j]:SetWidth(14) --Edit this for width of the debufficons | |
namePlate.debuffIcons[j]:SetHeight(14) --Edit this for height of the debufficons | |
elseif namePlate.debuffIcons[j] == nil and j>8 then --second row | |
namePlate.debuffIcons[j] = namePlate:CreateTexture(nil, "BORDER") | |
namePlate.debuffIcons[j]:SetTexture(0,0,0,0) | |
namePlate.debuffIcons[j]:ClearAllPoints() | |
namePlate.debuffIcons[j]:SetPoint("BOTTOMLEFT", HealthBar, "BOTTOMLEFT", (j-9) * 14, -31) --as in first row | |
namePlate.debuffIcons[j]:SetWidth(14) | |
namePlate.debuffIcons[j]:SetHeight(14) | |
end | |
end | |
if UnitExists("target") and HealthBar:GetAlpha() == 1 and showDebuffs then --Sets the texture of debuffs to debufficons | |
local j = 1 | |
local k = 1 | |
for j, e in ipairs(currentDebuffs) do | |
namePlate.debuffIcons[j]:SetTexture(currentDebuffs[j]) | |
namePlate.debuffIcons[j]:SetTexCoord(.078, .92, .079, .937) | |
namePlate.debuffIcons[j]:SetAlpha(0.9) | |
k = k + 1 | |
end | |
for j=k,16,1 do | |
namePlate.debuffIcons[j]:SetTexture(nil) | |
end | |
else | |
for j=1,16,1 do | |
namePlate.debuffIcons[j]:SetTexture(nil) | |
end | |
end | |
--combo points | |
local cp = GetComboPoints() | |
if not namePlate.cp then | |
namePlate.cp = namePlate:CreateFontString(nil, 'OVERLAY') | |
namePlate.cp:SetFont(STANDARD_TEXT_FONT, 15) | |
namePlate.cp:SetPoint('BOTTOMLEFT', Name, 'TOPLEFT') | |
namePlate.cp:SetTextColor(0, .8, .4) | |
namePlate.cp:Hide() | |
end | |
if namePlate.cp and UnitExists("target") and HealthBar:GetAlpha() == 1 and cp > 0 then | |
namePlate.cp:Show() | |
namePlate.cp:SetText(cp) | |
else namePlate.cp:Hide() | |
end | |
end | |
--Border:Hide() | |
Glow:Hide() | |
--Name:SetFontObject(GameFontNormal) | |
--Name:SetFont("Interface\\AddOns\\CustomNameplates\\Fonts\\Ubuntu-C.ttf",13) | |
--Name:SetPoint("BOTTOM", namePlate, "CENTER", 0, -4) | |
--Level:SetFontObject(GameFontNormal) | |
--Level:SetFont("Interface\\AddOns\\CustomNameplates\\Fonts\\Helvetica_Neue_LT_Com_77_Bold_Condensed.ttf",12) -- | |
--Level:SetPoint("TOPLEFT", Name, "RIGHT", 3, 4) | |
--Name:SetText("123") | |
HealthBar:Show() | |
Name:Show() | |
Level:Show() | |
if showPets ~= true then | |
if isPet(Name:GetText()) then | |
HealthBar:Hide() | |
Name:Hide() | |
Level:Hide() | |
end | |
end | |
local red, green, blue, _ = Name:GetTextColor() --Set Color of Namelabel | |
-- Print(red.." "..green.." "..blue) | |
if red > 0.99 and green == 0 and blue == 0 then | |
Name:SetTextColor(1,0.4,0.2,0.85) | |
elseif red > 0.99 and green > 0.81 and green < 0.82 and blue == 0 then | |
Name:SetTextColor(1,1,1,0.85) | |
end | |
local red, green, blue, _ = Level:GetTextColor() --Set Color of Level | |
if red > 0.99 and green == 0 and blue == 0 then | |
Level:SetTextColor(1,0.4,0.2,0.85) | |
elseif red > 0.99 and green > 0.81 and green < 0.82 and blue == 0 then | |
Level:SetTextColor(1,1,1,0.85) | |
end | |
local name = Name:GetText() --Set Name text and saves it in a list | |
if Players[name] == nil and UnitName("target") == nil and string.find(name, "%s") == nil and string.len(name) <= 12 and Targets[name] == nil then | |
fillPlayerDB(name) | |
ClearTarget() | |
end | |
local red, green, blue, _ = HealthBar:GetStatusBarColor() --Set Color of Healthbar | |
if blue > 0.99 and red == 0 and green == 0 then | |
HealthBar:SetStatusBarColor(0.2,0.6,1,0.85) | |
elseif red == 0 and green > 0.99 and blue == 0 then | |
HealthBar:SetStatusBarColor(0.6,1,0,0.85) | |
elseif red > 0.99 and green == 0 and blue == 0 then | |
if Players[name] ~= nil then -- player exists in list - only for red frames | |
local pClass = Players[name]["class"] | |
HealthBar:SetStatusBarColor(ClassColor[pClass][1],ClassColor[pClass][2],ClassColor[pClass][3],0.85) | |
end | |
end | |
--healthbar colored with respective player's class color | |
--if Players[name] ~= nil then -- player exists in list | |
-- HealthBar:SetStatusBarColor(ClassColor[Players[name]["class"]][1],ClassColor[Players[name]["class"]][2],ClassColor[Players[name]["class"]][3],0.85) | |
--end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment