/Mikmage
if UnitClass("player") == "Mage" then |
Mikmage = CreateFrame("Frame") |
Mikmage.events = {"PLAYER_ENTERING_WORLD", "PLAYER_REGEN_ENABLED", "PLAYER_REGEN_DISABLED", "UNIT_POWER_FREQUENT", "UNIT_AURA", "PLAYER_SPECIALIZATION_CHANGED"} |
Mikmage.events = {"PLAYER_ENTERING_WORLD", "PLAYER_REGEN_ENABLED", "PLAYER_REGEN_DISABLED", "UNIT_POWER_FREQUENT", "UNIT_AURA"} |
Mikmage.buttons1 = {[1] = {"Suggestion","Interface\\ICONS\\INV_Misc_QuestionMark"}} |
Mikmage.buttons2 = {[1] = {"Mana","INTERFACE\\ICONS\\thumbsup"}, [2] = {"ArcaneCharge",select(3,GetSpellInfo(114664))}, [3] = {"ArcaneMissiles",select(3,GetSpellInfo(5143))}, [4] = {"MageBomb",select(3,GetSpellInfo(GetSpellInfo(125430)))}, [5] = {"RuneofPower",select(3,GetSpellInfo(116011))}} |
Mikmage.buttons3 = {[1] = {"MirrorImage",select(3,GetSpellInfo(55342))}, [2] = {"ArcanePower",select(3,GetSpellInfo(12042))}, [3] = {"AlterTime",select(3,GetSpellInfo(108978))}} |
Mikmage.buttons4 = {[1] = {"Buff","Interface\\ICONS\\INV_Misc_QuestionMark"}} |
Mikmage.defaults = {["Frame1"] = {point = "BOTTOMLEFT", x = 320, y = 70}, ["Frame2"] = {point = "BOTTOMLEFT", x = 320, y = 120}, ["Frame3"] = {point = "BOTTOMLEFT", x = 320, y = 170}, ["Frame4"] = {point = "CENTER", x = 0, y = 0}, ["noob"] = true, ["scale"] = 1.5, ["lock"] = true, ["disabled"] = false} |
Mikmage.defaults = {["Frame1"] = {point = "BOTTOMLEFT", x = 320, y = 70}, ["Frame2"] = {point = "BOTTOMLEFT", x = 320, y = 120}, ["Frame3"] = {point = "BOTTOMLEFT", x = 320, y = 170}, ["Frame4"] = {point = "CENTER", x = 0, y = 0}, ["noob"] = true, ["scale"] = 1.5, ["lock"] = true, ["disabled"] = false, ["crosshair"] = true,} |
Mikmage.TimeSinceLastUpdate = 0 |
-- if DB not active, create it from defaults |
if not MikmageDB then MikmageDB = Mikmage.defaults end |
-- Register events |
for k,v in pairs(Mikmage.events) do Mikmage:RegisterEvent(v) end |
-- Makes text colored by percent |
local function colorify(percent,text) |
local r,g,b = percent > 0.5 and 2 * (1 - percent) or 1, percent > 0.5 and 1 or 2 * percent, 0 |
return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)..text.."|r" |
end |
-- textures for missing player buffs |
local bufftextures = { |
[0] = "Interface\\ICONS\\INV_Misc_QuestionMark", |
[1] = select(3,GetSpellInfo(6117)), -- Mage Armor |
[2] = select(3,GetSpellInfo(1459)), -- Arcane Brilliance |
} |
-- textures for spell suggestions |
local spelltextures = { |
[1] = select(3,GetSpellInfo(116011)), -- Rune of Power |
[2] = select(3,GetSpellInfo(GetSpellInfo(125430))), -- Mage Bomb |
[5] = select(3,GetSpellInfo(2948)), -- Scorch |
} |
local updatetime = 0.1 -- Calm down bro! |
local updatetime = 0.1 -- Calm down bro! |
local function onUpdate(self, elapsed) |
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed |
-- Rune of Power is not up, cast Rune of Power |
if not RuneofPower then priority = 1 |
-- Player's Mage Bomb is not up, cast Mage Bomb |
elseif select(2,GetSpellCooldown(Mikmage.spells["Mage Bomb"][1])) < (1.5-(1.5*floor(UnitSpellHaste("player"))/100)) and (not MageBomb or (MageBomb and MageBombCaster ~= "player")) then priority = 2 |
elseif select(2,GetSpellCooldown(Mikmage.spells["Mage Bomb"][1])) < 1.5 and (not MageBomb or (MageBomb and MageBombCaster ~= "player")) then priority = 2 |
-- Arcane Charge is not at 6 stacks, cast Arcane Blast |
elseif not ArcaneCharge or (ArcaneCharge and ArcaneChargeStack < 6) then priority = 3 |
-- Arcane Charge is at 6 stacks and Arcane Missiles proc is on, cast Arcane Missiles |
local MirrorImage = select(2,GetSpellCooldown(Mikmage.spells["Mirror Image"][1])) |
local ArcanePower = select(2,GetSpellCooldown(Mikmage.spells["Arcane Power"][1])) |
local AlterTime = select(2,GetSpellCooldown(Mikmage.spells["Alter Time"][1])) |
if (MirrorImage ~= nil and MirrorImage > (1.5-(1.5*floor(UnitSpellHaste("player"))/100))) then Mikmage.MirrorImage:Hide() else Mikmage.MirrorImage:Show() end |
if (ArcanePower ~= nil and ArcanePower > (1.5-(1.5*floor(UnitSpellHaste("player"))/100))) then Mikmage.ArcanePower:Hide() else Mikmage.ArcanePower:Show() end |
if UnitAura("player",Mikmage.spells["Alter Time"][1]) or (AlterTime ~= nil and AlterTime > (1.5-(1.5*floor(UnitSpellHaste("player"))/100))) then Mikmage.AlterTime:Hide() else Mikmage.AlterTime:Show() end |
if (MirrorImage ~= nil and MirrorImage > 1.5) then Mikmage.MirrorImage:Hide() else Mikmage.MirrorImage:Show() end |
if (ArcanePower ~= nil and ArcanePower > 1.5) then Mikmage.ArcanePower:Hide() else Mikmage.ArcanePower:Show() end |
if UnitAura("player",Mikmage.spells["Alter Time"][1]) or (AlterTime ~= nil and AlterTime > 1.5) then Mikmage.AlterTime:Hide() else Mikmage.AlterTime:Show() end |
self.TimeSinceLastUpdate = 0 |
if Mikmage.unlocked then |
Mikmage.MirrorImage:Show() |
Mikmage.ArcanePower:Show() |
Mikmage.AlterTime:Show() |
end |
end |
end |
if self[event] then return self[event](self, event, ...) end |
end) |
-- Update icon for Mage Bomb, player may have changed the talent between fights. |
function Mikmage.UpdateMageBomb() |
-- GetSpellInfo from 'GetSpellInfo("Mage Bomb")' will result the current Mage Bomb (ie. Nether Tempest): |
Mikmage.spells["Mage Bomb"] = {[1] = GetSpellInfo(GetSpellInfo(125430)), [2] = select(3,GetSpellInfo(GetSpellInfo(125430)))} |
end |
-- Check if spellsuggestion is enabled |
function Mikmage.CheckSuggestion() |
if MikmageDB.noob then Mikmage.Suggestion:Show() else Mikmage.Suggestion:Hide() end |
if Mikmage.unlocked then |
Mikmage.Suggestion:Show() |
end |
end |
-- Check are you standing on a Rune of Power |
function Mikmage.CheckRuneofPower() |
local RuneofPower = UnitAura("player",Mikmage.spells["Rune of Power"][1]) |
if RuneofPower then |
else |
Mikmage.RuneofPower:Show () |
end |
if Mikmage.unlocked then |
Mikmage.RuneofPower:Show() |
end |
end |
-- Check do you have clearcast for Arcane Missiles |
function Mikmage.CheckArcaneMissiles() |
local ArcaneMissiles,_,_,ArcaneMissilesStack = UnitAura("player",Mikmage.spells["Arcane Missiles!"][1]) |
if ArcaneMissiles then |
Mikmage.ArcaneMissiles:Hide() |
Mikmage.ArcaneMissiles.text:SetText("0") |
end |
if Mikmage.unlocked then |
Mikmage.ArcaneMissiles:Show() |
end |
end |
-- Check do you have 6 stacks of Arcane Charge "debuff" |
function Mikmage.CheckArcaneCharge() |
local ArcaneCharge,_,_,ArcaneChargeStack = UnitDebuff("player",Mikmage.spells["Arcane Charge"][1]) |
if ArcaneCharge then |
Mikmage.ArcaneCharge:Hide() |
Mikmage.ArcaneCharge.text:SetText("0") |
end |
if Mikmage.unlocked then |
Mikmage.ArcaneCharge:Show() |
end |
end |
-- Check is Mage Bomb active on the target |
function Mikmage.CheckMageBomb() |
-- GetSpellInfo from 'GetSpellInfo("Mage Bomb")' will result the current Mage Bomb (ie. Nether Tempest): |
local MageBomb,_,_,_,_,_,_,MageBombCaster = UnitDebuff("target",Mikmage.spells["Mage Bomb"][1]) |
local MageBombIcon = select(3,GetSpellInfo(Mikmage.spells["Mage Bomb"][1])) |
Mikmage.MageBomb.texture:SetTexture(MageBombIcon) |
else |
Mikmage.MageBomb:Show() |
end |
if Mikmage.unlocked then |
Mikmage.MageBomb:Show() |
end |
end |
-- Color mana button border and change the icon depending on how much mana you got |
function Mikmage.CheckMana() |
local percent = UnitPower("player")/UnitPowerMax("player") |
if floor(percent*100) >= 90 then |
Mikmage.Mana.border:SetVertexColor(1,0,0,1) |
end |
if InCombatLockdown() then Mikmage.Mana:Show() else Mikmage.Mana:Hide() end |
if Mikmage.unlocked then |
Mikmage.Mana:Show() |
end |
end |
-- This function will always work, nevermind the spec you are at the moment. |
function Mikmage.CheckBuffs() |
local buffprio = 0 |
local MageArmor = UnitAura("player",Mikmage.spells["Mage Armor"][1]) |
Mikmage.Buff.texture:SetTexture("Interface\\ICONS\\INV_Misc_QuestionMark") |
Mikmage.Buff:Hide() |
end |
if Mikmage.unlocked then |
Mikmage.Buff:Show() |
end |
end |
function Mikmage.CreateBars() |
local finetune = 1 |
-- Create 4x frames for buttons |
for i=1,4 do |
Mikmage["Frame"..i] = CreateFrame("Frame",Mikmage["Frame"..i],UIParent) |
local frame = Mikmage["Frame"..i] |
frame:RegisterForDrag("LeftButton") |
frame:SetMovable(true) |
frame:SetUserPlaced(true) |
frame.text = frame:CreateFontString(nil, "ARTWORK","GameFontNormal") |
--frame.text:SetFont("Fonts\\ARIALN.ttf",20,"OUTLINE") |
frame.text:SetPoint("CENTER",frame) |
frame:SetScript("OnDragStart", function(self) |
self:StartMoving() |
end) |
self:StopMovingOrSizing() |
MikmageDB["Frame"..i].point, MikmageDB["Frame"..i].x, MikmageDB["Frame"..i].y = "BOTTOMLEFT", self:GetLeft(), self:GetBottom() |
end) |
end |
Mikmage.Frame1.text:SetText("What\nspell\nnext?") |
Mikmage.Frame2.text:SetText("Mana, Active/Missing spells") |
Mikmage.Frame3.text:SetText("DPS spells OOC") |
Mikmage.Frame4.text:SetText("Buffs\nyou\nneed") |
-- Create buttons in numerical order |
for i=1,4 do |
prevpos = false |
end |
-- Color borders |
Mikmage.MageBomb.border:SetVertexColor(1,0,0,1) |
Mikmage.RuneofPower.border:SetVertexColor(1,0,0,1) |
Mikmage.ArcaneCharge.border:SetVertexColor(0,1,0,1) |
Mikmage.ArcaneCharge.text:SetText("0") |
Mikmage.ArcaneMissiles.text:SetText("0") |
-- SetPoint frames |
for i=1,4 do |
Mikmage["Frame"..i]:SetPoint(MikmageDB["Frame"..i].point, MikmageDB["Frame"..i].x, MikmageDB["Frame"..i].y) |
end |
-- Cache spells |
end |
-- Cache spells |
function Mikmage.CacheSpells() |
Mikmage.spells = { |
["Mage Armor"] = {[1] = GetSpellInfo(6117), [2] = select(3,GetSpellInfo(6117))}, |
["Frost Armor"] = {[1] = GetSpellInfo(7302), [2] = select(3,GetSpellInfo(7302))}, |
["Arcane Power"] = {[1] = GetSpellInfo(12042), [2] = select(3,GetSpellInfo(12042))}, |
["Alter Time"] = {[1] = GetSpellInfo(108978), [2] = select(3,GetSpellInfo(108978))}, |
} |
Mikmage.CheckBuffs() |
end |
function Mikmage.CheckSpecialization() |
end |
function Mikmage:PLAYER_ENTERING_WORLD() |
Mikmage:UnregisterEvent("PLAYER_ENTERING_WORLD") |
Mikmage:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") |
Mikmage:UnregisterEvent("PLAYER_ENTERING_WORLD") -- We do not need this anymore |
Mikmage:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") -- Register this by hand, then the eventgroup can be massunregistered |
Mikmage:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED") -- Register this by hand because it fires before PEW (when spells are being cached) |
Mikmage.CacheSpells() |
Mikmage.CreateBars() |
Mikmage.CheckBuffs() |
end |
function Mikmage:ACTIVE_TALENT_GROUP_CHANGED() |
end |
function Mikmage:PLAYER_REGEN_ENABLED() |
for i=1,4 do |
for k,v in pairs(Mikmage["buttons"..i]) do Mikmage[v[1]]:Hide() end |
if not Mikmage.unlocked then |
for i=1,4 do |
for k,v in pairs(Mikmage["buttons"..i]) do Mikmage[v[1]]:Hide() end |
end |
end |
Mikmage.CheckBuffs() |
Mikmage.ArcaneMissiles.text:SetText("0") |
end |
elseif a == "move" then |
for i=1,4 do |
Mikmage.unlocked = true |
Mikmage["Frame"..i]:Show() |
for k,v in pairs(Mikmage["buttons"..i]) do Mikmage[v[1]]:Show() end |
end |
elseif a == "lock" then |
for i=1,4 do |
Mikmage.unlocked = false |
Mikmage["Frame"..i]:Hide() |
for k,v in pairs(Mikmage["buttons"..i]) do Mikmage[v[1]]:Hide() end |
end |
Mikmage.CheckBuffs() |
elseif a == "crosshair" then |
if Mikmage.crosshair then |
Mikmage.crosshair = false |
ChatFrame1:AddMessage("Mikmage: Rune of Power crosshair disabled") |
else |
Mikmage.crosshair = true |
ChatFrame1:AddMessage("Mikmage: Rune of Power crosshair enabled") |
end |
elseif a == "" or a == nil then |
return |
else |
end |
end |
local Crosshair = CreateFrame("Frame",nil,UIParent) |
Crosshair:SetPoint("CENTER",UIParent,"CENTER",0,0) |
Crosshair:SetSize(100, 100) |
Crosshair:SetFrameStrata("HIGH") |
Crosshair.texture1 = Crosshair:CreateTexture() |
Crosshair.texture1:SetTexture(1,0.1,0.5,1) |
Crosshair.texture1:SetPoint("CENTER",Crosshair) |
Crosshair.texture1:SetSize(100, 3) |
Crosshair.texture2 = Crosshair:CreateTexture() |
Crosshair.texture2:SetTexture(1,0.1,0.5,1) |
Crosshair.texture2:SetPoint("CENTER",Crosshair) |
Crosshair.texture2:SetSize(3, 100) |
Crosshair:Hide() |
Crosshair:RegisterEvent("CURRENT_SPELL_CAST_CHANGED") |
Crosshair:SetScript("OnEvent", function(self,event,arg1,arg2) |
if MikmageDB.crosshair then |
if event == "CURRENT_SPELL_CAST_CHANGED" then |
if IsCurrentSpell(Mikmage.spells["Rune of Power"][1]) then |
self:Show() |
self:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET") |
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") |
end |
elseif event == "UNIT_SPELLCAST_FAILED_QUIET" or event == "UNIT_SPELLCAST_SUCCEEDED" or event == "UNIT_SPELLCAST_INTERRUPTED" then |
if arg1 == "player" and arg2 == Mikmage.spells["Rune of Power"][1] then |
self:Hide() |
self:UnregisterEvent("UNIT_SPELLCAST_FAILED_QUIET") |
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED") |
end |
end |
end |
end) |
end |