Quantcast
--[[-----------------------------------------------------------------------
	oUF: Stardust - a layout for the oUF framework
	Copyright (c) 2016 Andrew Mordecai <armordecai@protonmail.ch>
	This code is released under the zlib license; see LICENSE for details.
-------------------------------------------------------------------------]]

local _, Stardust = ...

local _, class = UnitClass("player")

local b = {
	ALL = 0,
	SELF = 1,
	MINE = 2,
	FRIEND = 4,
	FRIEND_OOC = 8, -- for long term buffs and non-combat effects
	ENEMY = 16,
}

local t = {
	[  2825] = b.ALL, -- Bloodlust
	[ 32182] = b.ALL, -- Heroism
	-- Crowd Control >= 10 seconds
	[   710] = b.ALL, -- Banish
	[  2094] = b.ALL, -- Blind
	[ 33796] = b.ALL, -- Cyclone
	[   605] = b.ALL, -- Dominate Mind
	[   339] = b.ALL, -- Entangling Roots
	[118699] = b.ALL, -- Fear
	[  3355] = b.ALL, -- Freezing Trap
	[ 51514] = b.ALL, -- Hex
							-- TODO: find spell ID for Hex with Glyph of the Compy
	[  5484] = b.ALL, -- Howl of Terror
	[115078] = b.ALL, -- Paralysis
	[   118] = b.ALL, -- Polymorph
	[161353] = b.ALL, -- Polymorph (bear cub)
	[ 61305] = b.ALL, -- Polymorph (cat)
	[161354] = b.ALL, -- Polymorph (monkey)
	[161372] = b.ALL, -- Polymorph (peacock)
	[161355] = b.ALL, -- Polymorph (penguin)
	[ 28272] = b.ALL, -- Polymorph (pig)
	[126819] = b.ALL, -- Polymorph (porcupine)
	[ 61721] = b.ALL, -- Polymorph (rabbit)
	[ 61780] = b.ALL, -- Polymorph (turkey)
	[ 28271] = b.ALL, -- Polymorph (turtle)
	[ 20066] = b.ALL, -- Repentance
	[ 82691] = b.ALL, -- Ring of Frost
	[  6770] = b.ALL, -- Sap
	[  9484] = b.ALL, -- Shackle Undead
	[ 10326] = b.ALL, -- Turn Evil
	[ 19386] = b.ALL, -- Wyvern Sting
	-- Racial Abilities
	[ 25046] = b.MINE, -- Arcane Torrent (energy)
	[ 28730] = b.MINE, -- Arcane Torrent (mana)
	[ 50613] = b.MINE, -- Arcane Torrent (runic power)
	[ 69179] = b.MINE, -- Arcane Torrent (rage)
	[ 80483] = b.MINE, -- Arcane Torrent (focus)
	[129597] = b.MINE, -- Arcane Torrent (chi)
	[155145] = b.MINE, -- Arcane Torrent (holy power)
	[ 26297] = b.MINE, -- Berserking
	[ 20572] = b.MINE, -- Blood Fury (attack power)
	[ 33697] = b.MINE, -- Blood Fury (melee attack power + spell power)
	[ 33702] = b.MINE, -- Blood Fury (spell power)
	[ 68992] = b.MINE, -- Darkflight
	[107079] = b.MINE, -- Quaking Palm
	[ 58984] = b.MINE, -- Shadowmeld
	[ 20594] = b.MINE, -- Stoneform
	[ 20549] = b.MINE, -- War Stomp
}
if class == "DEATHKNIGHT" then
elseif class == "DEMONHUNTER" then
elseif class == "DRUID" then
	t[ 22812] = b.MINE -- Barkskin
	t[ 50334] = b.MINE -- Berserk (bear)
	t[106951] = b.MINE -- Berserk (cat)
	t[155835] = b.MINE -- Bristling Fur
	t[112071] = b.MINE -- Celestial Alignment
	t[102351] = b.MINE -- Cenarion Ward (buff)
	t[102352] = b.MINE -- Cenarion Ward (heal)
	t[ 16870] = b.MINE -- Clearcasting
	t[135700] = b.MINE -- Clearcasting (from Omen of Clarity)
	t[  1850] = b.MINE -- Dash
	t[137452] = b.MINE -- Displacer Beast
	t[145162] = b.MINE -- Dream of Cenarius
	t[157228] = b.MINE -- Empowered Moonkin
	t[  6795] = b.MINE -- Growl
	t[108291] = b.MINE -- Heart of the Wild (balance)
	t[108292] = b.MINE -- Heart of the Wild (feral)
	t[108293] = b.MINE -- Heart of the Wild (guardian)
	t[108294] = b.MINE -- Heart of the Wild (restoration)
	t[    99] = b.MINE -- Incapacitating Roar
	t[102560] = b.MINE -- Incarnation: Chosen of Elune
	t[102543] = b.MINE -- Incarnation: King of the Jungle
	t[102558] = b.MINE -- Incarnation: Son of Ursoc
	t[ 33891] = b.MINE -- Incarnation: Tree of Life
	t[102342] = b.MINE -- Ironbark
	t[ 33745] = b.MINE -- Lacerate
	t[ 33763] = b.MINE -- Lifebloom
	t[164547] = b.MINE -- Lunar Empowerment (from Starsurge)
	t[ 22570] = b.MINE -- Maim
	-- TODO: find spell ID for mangle slow debuff
	t[  1126] = b.FRIEND_OOC -- Mark of the Wild
	t[102359] = b.MINE -- Mass Entanglement
	t[  5211] = b.MINE -- Mighty Bash
	t[164812] = b.MINE -- Moonfire (TODO?)
	t[132158] = b.MINE -- Nature's Swiftness
	t[124974] = b.MINE -- Nature's Vigil
	t[ 69369] = b.MINE -- Predatory Swiftness
	t[  5215] = b.MINE -- Prowl
	t[158792] = b.MINE -- Pulverize
	t[155722] = b.MINE -- Rake
	t[  8936] = b.MINE -- Regrowth
	t[   774] = b.MINE -- Rejuvenation
	t[  1079] = b.MINE -- Rip
	t[132402] = b.MINE -- Savage Defense
	t[ 52610] = b.MINE -- Savage Roar
	t[164545] = b.MINE -- Solar Empowerment (from Starsurge)
	t[114108] = b.MINE -- Soul of the Forest
	t[106989] = b.MINE -- Stampeding Roar
	t[184989] = b.MINE -- Starfall
	t[152221] = b.MINE -- Stellar Flare
	t[164815] = b.MINE -- Sunfire
	t[ 61336] = b.MINE -- Survival Instincts
	t[ 77758] = b.MINE -- Thrash (bear)
	t[106830] = b.MINE -- Thrash (cat)
	t[  5217] = b.MINE -- Tiger's Fury
	t[102416] = b.MINE -- Wild Charge (aquatic)
	t[ 16979] = b.MINE -- Wild Charge (bear)
	t[ 49376] = b.MINE -- Wild Charge (cat)
	t[ 48438] = b.MINE -- Wild Growth
elseif class == "HUNTER" then
elseif class == "MAGE" then
elseif class == "MONK" then
elseif class == "PALADIN" then
elseif class == "PRIEST" then
elseif class == "ROGUE" then
elseif class == "SHAMAN" then
	t[108281] = b.MINE -- Ancestral Guidance
	t[ 16188] = b.MINE -- Ancestral Swiftness
	t[114050] = b.MINE -- Ascendance (elemental)
	t[114051] = b.MINE -- Ascendance (enhancement)
	t[114052] = b.MINE -- Ascendance (restoration)
	t[108271] = b.MINE -- Astral Shift
	t[   974] = b.MINE -- Earth Shield
	t[  3600] = b.MINE -- Earthbind (Totem)
	t[ 64695] = b.MINE -- Earthgrab (Totem)
	t[157174] = b.MINE -- Elemental Fusion
	t[ 16166] = b.MINE -- Elemental Mastery
--	t[162557] = b.MINE -- Enhanced Unleash
	t[  8050] = b.MINE -- Flame Shock
	t[  8056] = b.MINE -- Frost Shock
	t[ 63685] = b.MINE -- Frozen Power (from Frost Shock with talent)
	t[  8178] = b.SELF -- Grounding Totem Effect
	t[ 89523] = b.SELF -- Grounding Totem (with Glyph of Grounding Totem)
	t[ 77762] = b.MINE -- Lava Surge
--	t[ 31616] = b.SELF -- Nature's Guardian
	t[ 61295] = b.MINE -- Riptide
	t[ 30823] = b.MINE -- Shamanistic Rage
	t[ 98007] = b.FRIEND -- Spirit Link Totem (TODO?)
	t[151175] = b.FRIEND -- Spirit Link Totem (TODO?)
	t[ 58875] = b.MINE -- Spirit Walk
	t[ 79206] = b.MINE -- Spiritwalker's Grace
	t[118905] = b.MINE -- Static Charge (from Capacitor Totem)
	t[114893] = b.MINE -- Stone Bulwark
	t[ 17364] = b.MINE -- Stormstrike
	t[ 53390] = b.MINE -- Tidal Waves
	t[165462] = b.MINE -- Unleash Flame
	t[ 73685] = b.MINE -- Unleash Life
	t[118470] = b.MINE -- Unleashed Fury (elemental)
	t[118473] = b.MINE -- Unleashed Fury (restoration)
	t[   546] = b.FRIEND_OOC -- Water Walking
--	t[114896] = b.MINE -- Windwalk Totem
	t[115356] = b.MINE -- Windstrike (replaces Stormstrike during Ascendance)
elseif class == "WARLOCK" then
	t[   980] = b.MINE -- Agony
	t[117828] = b.MINE -- Backdraft
	t[111397] = b.MINE -- Blood Horror (self buff)
	t[137143] = b.MINE -- Blood Horror (debuff)
	t[111400] = b.MINE -- Burning Rush
	t[124915] = b.MINE -- Chaos Wave
	t[ 17962] = b.MINE -- Conflagrate
	t[146739] = b.MINE -- Corruption
	t[110913] = b.MINE -- Dark Bargain (absorb)
	t[110914] = b.MINE -- Dark Bargain (dot)
	t[109773] = b.FRIEND_OOC -- Dark Intent
	t[108359] = b.MINE -- Dark Regeneration
	t[113858] = b.MINE -- Dark Soul: Instability
	t[113861] = b.MINE -- Dark Soul: Knowledge
	t[113860] = b.MINE -- Dark Soul: Misery
	t[   603] = b.MINE -- Doom
	t[114635] = b.MINE -- Ember Tap (with glyph)
	t[  1098] = b.ALL -- Enslave Demon
	t[108683] = b.MINE -- Fire and Brimstone
	t[ 47960] = b.MINE -- Hand of Gul'dan
	t[ 48181] = b.MINE -- Haunt
	t[ 80240] = b.MINE -- Havoc
	t[  6262] = b.MINE -- Healthstone (with glyph) (TODO?)
	t[157736] = b.MINE -- Immolate
	t[108686] = b.MINE -- Immolate (with Fire and Brimstone)
	t[137587] = b.MINE -- Kil'jaeden's Cunning
	t[  1454] = b.MINE -- Life Tab (with glyph) (TODO?)
	t[171018] = b.MINE -- Meteor Strike
	t[  6789] = b.MINE -- Mortal Coil
	t[122355] = b.MINE -- Molten Core
	t[104232] = b.MINE -- Rain of Fire
	t[108416] = b.MINE -- Sacrificial Pact
	t[ 27243] = b.MINE -- Seed of Corruption
	t[114790] = b.MINE -- Seed of Corruption (with Soulburn)
	t[ 30283] = b.MINE -- Shadowfury
	t[ 86211] = b.MINE -- Soul Swap
	t[ 74434] = b.MINE -- Soulburn
	t[ 20707] = b.FRIEND -- Soulstone
	t[  5697] = b.FRIEND_OOC -- Unending Breath
	t[104773] = b.MINE -- Unending Resolve
	t[ 30108] = b.MINE -- Unstable Affliction
elseif class == "WARRIOR" then
end

---------------------------
-- Functions
---------------------------

local UnitAffectingCombat = UnitAffectingCombat
local UnitIsUnit = UnitIsUnit
local UnitReaction = UnitReaction

function Stardust.AuraFilter(element, unit, icon, name, _, _, count, dispelType, duration, expires, caster, isStealable, _, spellID, canApplyAura, isBossDebuff)
	local x = t[spellID]
	if isBossDebuff or caster == "vehicle" or x == b.ALL then
		return true
	elseif x == b.MINE then
		return icon.isPlayer or caster == "pet"
	elseif x == b.FRIEND then
		return UnitReaction(unit, "player") >= 4
	elseif x == b.FRIEND_OOC then
		return UnitReaction(unit, "player") >= 4 and not UnitAffectingCombat("player")
	elseif x == b.ENEMY then
		return UnitReaction(unit, "player") < 4
	elseif x == b.SELF then
		return UnitIsUnit(unit, "player")
	end
end