Quantcast

Mage: Add default scripts for Arcane, Fire, and Frost specializations.

Johnny C. Lam [04-30-14 - 18:35]
Mage: Add default scripts for Arcane, Fire, and Frost specializations.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1347 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleSimulationCraft.lua
scripts/files.xml
scripts/ovale_mage.lua
scripts/ovale_mage_spells.lua
diff --git a/OvaleSimulationCraft.lua b/OvaleSimulationCraft.lua
index a8e7d29..ddb3d3c 100644
--- a/OvaleSimulationCraft.lua
+++ b/OvaleSimulationCraft.lua
@@ -336,6 +336,7 @@ do
 				tinsert(simc.symbols, "frost_armor_buff")
 				return "if BuffExpires(frost_armor_buff) Spell(frost_armor)"
 			end,
+		["^icy_veins$"] = "IcyVeins()",
 		["^molten_armor$"] = function(simc, action)
 				tinsert(simc.symbols, "molten_armor_buff")
 				return "if BuffExpires(molten_armor_buff) Spell(molten_armor)"
@@ -659,6 +660,7 @@ do
 				return "DebuffStacks(arcane_charge_debuff)"
 			end,
 		["^buff%.rune_of_power%.remains$"] = "RuneOfPowerRemains()",
+		["^cooldown%.icy_veins%.remains$"] = "IcyVeinsCooldownRemains()",
 		-- Monk
 		["^dot%.zen_sphere%.ticking$"] = function(simc, action)
 				tinsert(simc.symbols, "zen_sphere_buff")
@@ -868,7 +870,7 @@ do
 				tinsert(simc.symbols, "mana_gem")
 				return "ItemCharges(mana_gem)"
 			end,
-		["^mastery_value$"] = "MasteryEffect()",
+		["^mastery_value$"] = "MasteryEffect() / 100",
 		["^multiplier$"] = "DamageMultiplier()",
 		["^position_front$"] = "False(position_front)",	-- XXX
 		["^rage$"] = "Rage()",
diff --git a/scripts/files.xml b/scripts/files.xml
index 24c6070..8515449 100644
--- a/scripts/files.xml
+++ b/scripts/files.xml
@@ -6,6 +6,8 @@
 	<Script file="ovale_druid_spells.lua" />
 	<Script file="ovale_hunter.lua" />
 	<Script file="ovale_hunter_spells.lua" />
+	<Script file="ovale_mage.lua" />
+	<Script file="ovale_mage_spells.lua" />
 	<Script file="ovale_monk.lua" />
 	<Script file="ovale_monk_spells.lua" />
 	<Script file="ovale_paladin.lua" />
diff --git a/scripts/ovale_mage.lua b/scripts/ovale_mage.lua
new file mode 100644
index 0000000..4129ca2
--- /dev/null
+++ b/scripts/ovale_mage.lua
@@ -0,0 +1,621 @@
+local _, Ovale = ...
+local OvaleScripts = Ovale.OvaleScripts
+
+do
+	local name = "Ovale"
+	local desc = "[5.4] Ovale: Arcane, Fire, Frost"
+	local code = [[
+# Ovale mage script based on SimulationCraft.
+#	Last updated: 2014-04-27
+
+Include(ovale_items)
+Include(ovale_racials)
+Include(ovale_mage_spells)
+
+AddCheckBox(opt_aoe L(AOE) default)
+AddCheckBox(opt_icons_left "Left icons")
+AddCheckBox(opt_icons_right "Right icons")
+
+###
+### Arcane
+###
+# Based on SimulationCraft profile "Mage_Arcane_T16H".
+#	class=mage
+#	spec=arcane
+#	talents=http://us.battle.net/wow/en/tool/talent-calculator#ea!0...11
+#	glyphs=mana_gem/mirror_image/arcane_power
+
+AddFunction ArcaneAoeActions
+{
+	#flamestrike
+	Spell(flamestrike)
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+	#arcane_barrage,if=buff.arcane_charge.stack>=4
+	if DebuffStacks(arcane_charge_debuff) >= 4 Spell(arcane_barrage)
+	#arcane_explosion
+	Spell(arcane_explosion)
+}
+
+AddFunction ArcaneSingleTargetActions
+{
+	#arcane_barrage,if=buff.alter_time.up&buff.alter_time.remains<2
+	if BuffPresent(alter_time_buff) and BuffRemains(alter_time_buff) < 2 Spell(arcane_barrage)
+	#arcane_missiles,if=buff.alter_time.up
+	if BuffPresent(arcane_missiles_buff) and BuffPresent(alter_time_buff) Spell(arcane_missiles)
+	#arcane_blast,if=buff.alter_time.up
+	if BuffPresent(alter_time_buff) Spell(arcane_blast)
+	#arcane_blast,if=buff.profound_magic.up&buff.arcane_charge.stack>3&mana.pct>93
+	if BuffPresent(profound_magic_buff) and DebuffStacks(arcane_charge_debuff) > 3 and ManaPercent() > 93 Spell(arcane_blast)
+	#arcane_missiles,if=(buff.arcane_missiles.stack=2&cooldown.arcane_power.remains>0)|(buff.arcane_charge.stack>=4&cooldown.arcane_power.remains>8)
+	if BuffPresent(arcane_missiles_buff) and { { BuffStacks(arcane_missiles_buff) == 2 and SpellCooldown(arcane_power) > 0 } or { DebuffStacks(arcane_charge_debuff) >= 4 and SpellCooldown(arcane_power) > 8 } } Spell(arcane_missiles)
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+	#arcane_barrage,if=buff.arcane_charge.stack>=4&mana.pct<95
+	if DebuffStacks(arcane_charge_debuff) >= 4 and ManaPercent() < 95 Spell(arcane_barrage)
+	#presence_of_mind
+	if TalentPoints(presence_of_mind_talent) Spell(presence_of_mind)
+	#arcane_blast
+	Spell(arcane_blast)
+}
+
+AddFunction ArcaneSingleTargetMovingActions
+{
+	#arcane_barrage,if=buff.alter_time.up&buff.alter_time.remains<2
+	if BuffPresent(alter_time_buff) and BuffRemains(alter_time_buff) < 2 Spell(arcane_barrage)
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+	#arcane_barrage,if=buff.arcane_charge.stack>=4&mana.pct<95
+	if DebuffStacks(arcane_charge_debuff) >= 4 and ManaPercent() < 95 Spell(arcane_barrage)
+	#presence_of_mind
+	if TalentPoints(presence_of_mind_talent) Spell(presence_of_mind)
+	#arcane_blast
+	if BuffPresent(presence_of_mind_buff) Spell(arcane_blast)
+	#arcane_barrage,moving=1
+	Spell(arcane_barrage)
+	#fire_blast,moving=1
+	Spell(fire_blast)
+	#ice_lance,moving=1
+	Spell(ice_lance)
+}
+
+AddFunction ArcaneDefaultActions
+{
+	#cancel_buff,name=alter_time,moving=1
+	#conjure_mana_gem,if=mana_gem_charges<3&target.debuff.invulnerable.react
+	if ItemCharges(mana_gem) < 3 and target.InCombat(no) ConjureManaGem()
+	#run_action_list,name=aoe,if=active_enemies>=6
+	#run_action_list,name=single_target,if=active_enemies<6
+}
+
+AddFunction ArcaneDefaultManaActions
+{
+	#rune_of_power,if=buff.rune_of_power.remains<cast_time
+	if TalentPoints(rune_of_power_talent) and RuneOfPowerRemains() < CastTime(rune_of_power) Spell(rune_of_power)
+	#rune_of_power,if=cooldown.arcane_power.remains=0&buff.rune_of_power.remains<buff.arcane_power.duration
+	if TalentPoints(rune_of_power_talent) and Spell(arcane_power) and RuneOfPowerRemains() < SpellData(arcane_power_buff duration) Spell(rune_of_power)
+	#evocation,if=buff.invokers_energy.down
+	if TalentPoints(invocation_talent) and BuffExpires(invokers_energy_buff) Spell(evocation)
+	#evocation,if=cooldown.arcane_power.remains=0&buff.invokers_energy.remains<buff.arcane_power.duration
+	if TalentPoints(invocation_talent) and Spell(arcane_power) and BuffRemains(invokers_energy_buff) < SpellData(arcane_power_buff duration) Spell(evocation)
+	#evocation,if=mana.pct<50,interrupt_if=mana.pct>95&buff.invokers_energy.remains>10
+	if not TalentPoints(rune_of_power_talent) and ManaPercent() < 50 Spell(evocation)
+}
+
+AddFunction ArcaneDefaultCdActions
+{
+	#counterspell,if=target.debuff.casting.react
+	if target.IsInterruptible() Spell(counterspell)
+	UseRacialInterruptActions()
+
+	unless { TalentPoints(rune_of_power_talent) and RuneOfPowerRemains() < CastTime(rune_of_power) }
+		or { TalentPoints(rune_of_power_talent) and Spell(arcane_power) and RuneOfPowerRemains() < SpellData(arcane_power_buff duration) }
+		or { TalentPoints(invocation_talent) and BuffExpires(invokers_energy_buff) }
+		or { TalentPoints(invocation_talent) and Spell(arcane_power) and BuffRemains(invokers_energy_buff) < SpellData(arcane_power_buff duration) }
+		or { not TalentPoints(rune_of_power_talent) and ManaPercent() < 50 and Spell(evocation) }
+	{
+		#mirror_image
+		Spell(mirror_image)
+		#mana_gem,if=mana.pct<80&buff.alter_time.down
+		if ManaPercent() < 80 and BuffExpires(alter_time_buff) UseManaGem()
+		#arcane_power,if=time_to_bloodlust>180&((buff.rune_of_power.remains>=buff.arcane_power.duration&buff.arcane_missiles.stack=2&buff.arcane_charge.stack>2)|target.time_to_die<buff.arcane_power.duration+5),moving=0
+		if TalentPoints(rune_of_power_talent) and TimeToBloodlust() > SpellData(arcane_power cd) and { { RuneOfPowerRemains() >= SpellData(arcane_power_buff duration) and BuffStacks(arcane_missiles_buff) == 2 and DebuffStacks(arcane_charge_debuff) > 2 } or target.TimeToDie() < SpellData(arcane_power_buff duration) + 5 } Spell(arcane_power)
+		#arcane_power,if=time_to_bloodlust>180&((buff.invokers_energy.remains>=buff.arcane_power.duration&buff.arcane_missiles.stack=2&buff.arcane_charge.stack>2)|target.time_to_die<buff.arcane_power.duration+5),moving=0
+		if TalentPoints(invocation_talent) and TimeToBloodlust() > SpellData(arcane_power cd) and { { BuffRemains(invokers_energy_buff) >= SpellData(arcane_power_buff duration) and BuffStacks(arcane_missiles_buff) == 2 and DebuffStacks(arcane_charge_debuff) > 2 } or target.TimeToDie() < SpellData(arcane_power_buff duration) + 5 } Spell(arcane_power)
+		#arcane_power,if=time_to_bloodlust>180&((buff.arcane_missiles.stack=2&buff.arcane_charge.stack>2)|target.time_to_die<buff.arcane_power.duration+5),moving=0
+		if not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and TimeToBloodlust() > SpellData(arcane_power cd) and { { BuffStacks(arcane_missiles_buff) == 2 and DebuffStacks(arcane_charge_debuff) > 2 } or target.TimeToDie() < SpellData(arcane_power_buff duration) + 5 } Spell(arcane_power)
+		#blood_fury,if=buff.alter_time.down&(buff.arcane_power.up|cooldown.arcane_power.remains>15|target.time_to_die<18)
+		if BuffExpires(alter_time_buff) and { BuffPresent(arcane_power_buff) or SpellCooldown(arcane_power) > 15 or target.TimeToDie() < 18 } Spell(blood_fury)
+		#berserking,if=buff.alter_time.down&(buff.arcane_power.up|target.time_to_die<18)
+		if BuffExpires(alter_time_buff) and { BuffPresent(arcane_power_buff) or target.TimeToDie() < 18 } Spell(berserking)
+		#jade_serpent_potion,if=buff.alter_time.down&(buff.arcane_power.up|target.time_to_die<50)
+		if BuffExpires(alter_time_buff) and { BuffPresent(arcane_power_buff) or target.TimeToDie() < 50 } UsePotionIntellect()
+		#use_item,slot=hands,sync=alter_time_activate,if=buff.alter_time.down
+		if Spell(alter_time_activate) and BuffExpires(alter_time_buff) UseItemActions()
+		#alter_time,if=buff.alter_time.down&buff.arcane_power.up
+		if BuffExpires(alter_time_buff) and BuffPresent(arcane_power_buff) Spell(alter_time)
+		#use_item,slot=hands,if=(cooldown.alter_time_activate.remains>45|target.time_to_die<25)&buff.rune_of_power.remains>20
+		if TalentPoints(rune_of_power_talent) and { SpellCooldown(alter_time_activate) > 45 or target.TimeToDie() < 25 } and RuneOfPowerRemains() > 20 UseItemActions()
+		#use_item,slot=hands,if=(cooldown.alter_time_activate.remains>45|target.time_to_die<25)&buff.invokers_energy.remains>20
+		if TalentPoints(invocation_talent) and { SpellCooldown(alter_time_activate) > 45 or target.TimeToDie() < 25 } and BuffRemains(invokers_energy_buff) > 20 UseItemActions()
+		#use_item,slot=hands,if=cooldown.alter_time_activate.remains>45|target.time_to_die<25
+		if not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and { SpellCooldown(alter_time_activate) > 45 or target.TimeToDie() < 25 } UseItemActions()
+	}
+}
+
+AddFunction ArcanePrecombatActions
+{
+	#flask,type=warm_sun
+	#food,type=mogu_fish_stew
+	#arcane_brilliance
+	if BuffExpires(critical_strike any=1) or BuffExpires(spell_power_multiplier any=1) Spell(arcane_brilliance)
+	#frost_armor,if=set_bonus.tier16_2pc=1
+	if ArmorSetBonus(T16_caster 2) == 1 and BuffExpires(frost_armor_buff) Spell(frost_armor)
+	#mage_armor,if=set_bonus.tier16_2pc=0
+	if ArmorSetBonus(T16_caster 2) == 0 and BuffExpires(mage_armor_buff) Spell(mage_armor)
+	#snapshot_stats
+}
+
+AddFunction ArcanePrecombatManaActions
+{
+	#evocation
+	if TalentPoints(invocation_talent) Spell(evocation)
+	#rune_of_power
+	if TalentPoints(rune_of_power_talent) Spell(rune_of_power)
+}
+
+AddFunction ArcanePrecombatCdActions
+{
+	#jade_serpent_potion
+	UsePotionIntellect()
+	#mirror_image
+	Spell(mirror_image)
+}
+
+### Arcane icons.
+
+AddIcon mastery=arcane help=Blink size=small checkboxon=opt_icons_left
+{
+	if TalentPoints(cold_snap_talent) and HealthPercent() < 30 Spell(cold_snap)
+	Spell(blink)
+}
+
+AddIcon mastery=arcane help=moving size=small checkboxon=opt_icons_left
+{
+	ArcaneSingleTargetMovingActions()
+}
+
+AddIcon mastery=arcane help=mana
+{
+	if InCombat(no) ArcanePrecombatManaActions()
+	ArcaneDefaultManaActions()
+}
+
+AddIcon mastery=arcane help=main
+{
+	if InCombat(no) ArcanePrecombatActions()
+	ArcaneDefaultActions()
+	ArcaneSingleTargetActions()
+}
+
+AddIcon mastery=arcane help=aoe checkboxon=opt_aoe
+{
+	if InCombat(no) ArcanePrecombatActions()
+	ArcaneDefaultActions()
+	ArcaneAoeActions()
+}
+
+AddIcon mastery=arcane help=cd
+{
+	ArcaneDefaultCdActions()
+}
+
+AddIcon mastery=arcane help=cd size=small checkboxon=opt_icons_right
+{
+	if BuffExpires(burst_haste any=1) and DebuffExpires(burst_haste_debuff) Spell(time_warp)
+}
+
+AddIcon mastery=arcane help=cd size=small checkboxon=opt_icons_right
+{
+	UseItemActions()
+}
+
+###
+### Fire
+###
+# Based on SimulationCraft profile "Mage_Fire_T16H".
+#	class=mage
+#	spec=fire
+#	talents=http://us.battle.net/wow/en/tool/talent-calculator#eZ!0...11
+#	glyphs=combustion/counterspell
+
+AddFunction FireDefaultActions
+{
+	#cancel_buff,name=alter_time,moving=1
+	#conjure_mana_gem,if=mana_gem_charges<3&target.debuff.invulnerable.react
+	if ItemCharges(mana_gem) < 3 and target.InCombat(no) ConjureManaGem()
+	#presence_of_mind,sync=alter_time_activate,if=buff.alter_time.down
+	if TalentPoints(presence_of_mind_talent) and Spell(alter_time_activate) and BuffExpires(alter_time_buff) Spell(presence_of_mind)
+	#presence_of_mind,if=cooldown.alter_time_activate.remains>60|target.time_to_die<5
+	if TalentPoints(presence_of_mind_talent) and { SpellCooldown(alter_time_activate) > 60 or target.TimeToDie() < 5 } Spell(presence_of_mind)
+	#pyroblast,if=buff.pyroblast.react|buff.presence_of_mind.up
+	if BuffPresent(pyroblast_buff) or BuffPresent(presence_of_mind_buff) Spell(pyroblast)
+	#inferno_blast,if=buff.heating_up.react&buff.pyroblast.down
+	if BuffPresent(heating_up_buff) and BuffExpires(pyroblast_buff) Spell(inferno_blast)
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+	#scorch,moving=1
+	if Speed() > 0 Spell(scorch)
+	#fireball
+	Spell(fireball)
+}
+
+AddFunction FireDefaultAoeActions
+{
+	#cancel_buff,name=alter_time,moving=1
+	#conjure_mana_gem,if=mana_gem_charges<3&target.debuff.invulnerable.react
+	if ItemCharges(mana_gem) < 3 and target.InCombat(no) ConjureManaGem()
+	#presence_of_mind,sync=alter_time_activate,if=buff.alter_time.down
+	if TalentPoints(presence_of_mind_talent) and Spell(alter_time_activate) and BuffExpires(alter_time_buff) Spell(presence_of_mind)
+	#presence_of_mind,if=cooldown.alter_time_activate.remains>60|target.time_to_die<5
+	if TalentPoints(presence_of_mind_talent) and { SpellCooldown(alter_time_activate) > 60 or target.TimeToDie() < 5 } Spell(presence_of_mind)
+	#flamestrike,if=active_enemies>=5
+	if Enemies() >= 5 Spell(flamestrike)
+	#inferno_blast,if=dot.combustion.ticking&active_enemies>1
+	if target.DebuffPresent(combustion_debuff) Spell(inferno_blast)
+	#pyroblast,if=buff.pyroblast.react|buff.presence_of_mind.up
+	if BuffPresent(pyroblast_buff) or BuffPresent(presence_of_mind_buff) Spell(pyroblast)
+	#inferno_blast,if=buff.heating_up.react&buff.pyroblast.down
+	if BuffPresent(heating_up_buff) and BuffExpires(pyroblast_buff) Spell(inferno_blast)
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+}
+
+AddFunction FireDefaultShortCdActions
+{
+	#rune_of_power,if=buff.rune_of_power.remains<cast_time&buff.alter_time.down
+	if TalentPoints(rune_of_power_talent) and RuneOfPowerRemains() < CastTime(rune_of_power) and BuffExpires(alter_time_buff) Spell(rune_of_power)
+	#rune_of_power,if=cooldown.alter_time_activate.remains=0&buff.rune_of_power.remains<6
+	if TalentPoints(rune_of_power_talent) and Spell(alter_time_activate) and RuneOfPowerRemains() < 6 Spell(rune_of_power)
+	#evocation,if=buff.rune_of_power.remains<cast_time&buff.alter_time.down
+	if TalentPoints(invocation_talent) and BuffRemains(invokers_energy_buff) < CastTime(rune_of_power) and BuffExpires(alter_time_buff) Spell(evocation)
+	#evocation,if=cooldown.alter_time_activate.remains=0&buff.rune_of_power.remains<6
+	if TalentPoints(invocation_talent) and Spell(alter_time_activate) and BuffRemains(invokers_energy_buff) < 6 Spell(evocation)
+	#evocation,if=buff.alter_time.down&mana.pct<20,interrupt_if=mana.pct>95
+	if not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and BuffExpires(alter_time_buff) and ManaPercent() < 20 Spell(evocation)
+	#combustion,if=target.time_to_die<22
+	if target.TimeToDie() < 22 Spell(combustion)
+	#combustion,if=dot.ignite.tick_dmg>=((3*action.pyroblast.crit_damage)*mastery_value*0.5)
+	if target.DebuffPresent(ignite_debuff) and target.TickValue(ignite_debuff) >= { { 3 * target.CritDamage(pyroblast) } * MasteryEffect() / 100 * 0.5 } Spell(combustion)
+	#combustion,if=dot.ignite.tick_dmg>=((action.fireball.crit_damage+action.inferno_blast.crit_damage+action.pyroblast.hit_damage)*mastery_value*0.5)&dot.pyroblast.ticking&buff.alter_time.down&buff.pyroblast.down&buff.presence_of_mind.down
+	if target.DebuffPresent(ignite_debuff) and target.TickValue(ignite_debuff) >= { { target.CritDamage(fireball) + target.CritDamage(inferno_blast) + target.Damage(pyroblast) } * MasteryEffect() / 100 * 0.5 } and target.DebuffPresent(pyroblast_debuff) and BuffExpires(alter_time_buff) and BuffExpires(pyroblast_buff) and BuffExpires(presence_of_mind_buff) Spell(combustion)
+}
+
+AddFunction FireDefaultCdActions
+{
+	#counterspell,if=target.debuff.casting.react
+	if target.IsInterruptible() Spell(counterspell)
+	UseRacialInterruptActions()
+
+	unless { TalentPoints(rune_of_power_talent) and RuneOfPowerRemains() < CastTime(rune_of_power) and BuffExpires(alter_time_buff) }
+		or { TalentPoints(rune_of_power_talent) and Spell(alter_time_activate) and RuneOfPowerRemains() < 6 }
+		or { TalentPoints(invocation_talent) and BuffRemains(invokers_energy_buff) < CastTime(rune_of_power) and BuffExpires(alter_time_buff) }
+		or { TalentPoints(invocation_talent) and Spell(alter_time_activate) and BuffRemains(invokers_energy_buff) < 6 }
+		or { not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and BuffExpires(alter_time_buff) and ManaPercent() < 20 and Spell(evocation) }
+	{
+		#berserking,if=buff.alter_time.down&target.time_to_die<18
+		if BuffExpires(alter_time_buff) and target.TimeToDie() < 18 Spell(berserking)
+		#jade_serpent_potion,if=buff.alter_time.down&target.time_to_die<45
+		if BuffExpires(alter_time_buff) and target.TimeToDie() < 45 UsePotionIntellect()
+		#mirror_image
+		Spell(mirror_image)
+
+		unless { target.TimeToDie() < 22 and Spell(combustion) }
+			or { target.LastEstimatedDamage(ignite_debuff) >= { { 3 * target.CritDamage(pyroblast) } * MasteryEffect() * 0.5 } and Spell(combustion) }
+			or { target.LastEstimatedDamage(ignite_debuff) >= { { target.CritDamage(fireball) + target.CritDamage(inferno_blast) + target.Damage(pyroblast) } * MasteryEffect() * 0.5 } and target.DebuffPresent(pyroblast_debuff) and BuffExpires(alter_time_buff) and BuffExpires(pyroblast_buff) and BuffExpires(presence_of_mind_buff) and Spell(combustion) }
+		{
+			#blood_fury,if=buff.alter_time.down&(cooldown.alter_time_activate.remains>30|target.time_to_die<18)
+			if BuffExpires(alter_time_buff) and { SpellCooldown(alter_time_activate) > 30 or target.TimeToDie() < 18 } Spell(blood_fury)
+			#berserking,sync=alter_time_activate,if=buff.alter_time.down
+			if Spell(alter_time_activate) and BuffExpires(alter_time_buff) Spell(berserking)
+			#jade_serpent_potion,sync=alter_time_activate,if=buff.alter_time.down
+			if Spell(alter_time_activate) and BuffExpires(alter_time_buff) UsePotionIntellect()
+			#use_item,slot=hands,sync=alter_time_activate
+			if Spell(alter_time_activate) UseItemActions()
+			#alter_time,if=time_to_bloodlust>180&buff.alter_time.down&buff.pyroblast.react
+			if TimeToBloodlust() > 180 and BuffExpires(alter_time_buff) and BuffPresent(pyroblast_buff) Spell(alter_time)
+			#use_item,slot=hands,if=cooldown.alter_time_activate.remains>40|target.time_to_die<12
+			if SpellCooldown(alter_time_activate) > 40 or target.TimeToDie() < 12 UseItemActions()
+		}
+	}
+}
+
+AddFunction FirePrecombatActions
+{
+	#flask,type=warm_sun
+	#food,type=mogu_fish_stew
+	#arcane_brilliance
+	if BuffExpires(critical_strike any=1) or BuffExpires(spell_power_multiplier any=1) Spell(arcane_brilliance)
+	#molten_armor
+	if BuffExpires(molten_armor_buff) Spell(molten_armor)
+	#snapshot_stats
+}
+
+AddFunction FirePrecombatShortCdActions
+{
+	#evocation
+	if TalentPoints(invocation_talent) Spell(evocation)
+	#rune_of_power
+	if TalentPoints(rune_of_power_talent) Spell(rune_of_power)
+}
+
+AddFunction FirePrecombatCdActions
+{
+	#jade_serpent_potion
+	UsePotionIntellect()
+	#mirror_image
+	Spell(mirror_image)
+}
+
+### Fire icons.
+
+AddIcon mastery=fire help=Blink size=small checkboxon=opt_icons_left
+{
+	if TalentPoints(cold_snap_talent) and HealthPercent() < 30 Spell(cold_snap)
+	Spell(blink)
+}
+
+AddIcon mastery=fire help=Combustion size=small checkboxon=opt_icons_left
+{
+	Spell(combustion)
+}
+
+AddIcon mastery=fire help=shortcd
+{
+	if InCombat(no) FirePrecombatShortCdActions()
+	FireDefaultShortCdActions()
+}
+
+AddIcon mastery=fire help=main
+{
+	if InCombat(no) FirePrecombatActions()
+	FireDefaultActions()
+}
+
+AddIcon mastery=fire help=aoe checkboxon=opt_aoe
+{
+	if InCombat(no) FirePrecombatActions()
+	FireDefaultAoeActions()
+}
+
+AddIcon mastery=fire help=cd
+{
+	FireDefaultCdActions()
+}
+
+AddIcon mastery=fire help=cd size=small checkboxon=opt_icons_right
+{
+	if BuffExpires(burst_haste any=1) and DebuffExpires(burst_haste_debuff) Spell(time_warp)
+}
+
+AddIcon mastery=fire help=cd size=small checkboxon=opt_icons_right
+{
+	UseItemActions()
+}
+
+###
+### Frost
+###
+# Based on SimulationCraft profile "Mage_Frost_T16H".
+#	class=mage
+#	spec=frost
+#	talents=http://us.battle.net/wow/en/tool/talent-calculator#eb!0...11
+#	glyphs=evocation/icy_veins/splitting_ice
+
+AddFunction FrostDefaultActions
+{
+	#cancel_buff,name=alter_time,moving=1
+	#conjure_mana_gem,if=mana_gem_charges<3&target.debuff.invulnerable.react
+	if ItemCharges(mana_gem) < 3 and target.InCombat(no) ConjureManaGem()
+	#frostfire_bolt,if=buff.alter_time.up&buff.brain_freeze.up
+	if BuffPresent(alter_time_buff) and BuffPresent(brain_freeze_buff) Spell(frostfire_bolt)
+	#ice_lance,if=buff.alter_time.up&buff.fingers_of_frost.up
+	if BuffPresent(alter_time_buff) and BuffPresent(fingers_of_frost_buff) Spell(ice_lance)
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+	#frostfire_bolt,if=buff.brain_freeze.react&cooldown.icy_veins.remains>2
+	if BuffPresent(brain_freeze_buff) and { IcyVeins() or IcyVeinsCooldownRemains() > 2 } Spell(frostfire_bolt)
+	#ice_lance,if=buff.frozen_thoughts.react&buff.fingers_of_frost.up
+	if ArmorSetBonus(T16_caster 2) == 1 and BuffPresent(frozen_thoughts_buff) and BuffPresent(fingers_of_frost_buff) Spell(ice_lance)
+	#ice_lance,if=buff.fingers_of_frost.up&(buff.fingers_of_frost.remains<2|(buff.fingers_of_frost.stack>1&cooldown.icy_veins.remains>2))
+	if ArmorSetBonus(T16_caster 2) == 1 and BuffPresent(fingers_of_frost_buff) and { BuffRemains(fingers_of_frost_buff) < 2 or { BuffStacks(fingers_of_frost_buff) > 1 and { IcyVeins() or IcyVeinsCooldownRemains() > 2 } } } Spell(ice_lance)
+	#ice_lance,if=buff.fingers_of_frost.react&cooldown.icy_veins.remains>2
+	if ArmorSetBonus(T16_caster 2) == 0 and BuffPresent(fingers_of_frost_buff) and { IcyVeins() or IcyVeinsCooldownRemains() > 2 } Spell(ice_lance)
+	#frostbolt
+	Spell(frostbolt)
+}
+
+AddFunction FrostDefaultShortCdActions
+{
+	#rune_of_power,if=buff.rune_of_power.remains<cast_time&buff.alter_time.down
+	if TalentPoints(rune_of_power_talent) and RuneOfPowerRemains() < CastTime(rune_of_power) and BuffExpires(alter_time_buff) Spell(rune_of_power)
+	#rune_of_power,if=cooldown.icy_veins.remains=0&buff.rune_of_power.remains<20
+	if TalentPoints(rune_of_power_talent) and IcyVeins() and RuneOfPowerRemains() < 20 Spell(rune_of_power)
+	#evocation,if=buff.invokers_energy.remains<cast_time&buff.alter_time.down
+	if TalentPoints(invocation_talent) and BuffRemains(invokers_energy_buff) < CastTime(rune_of_power) and BuffExpires(alter_time_buff) Spell(evocation)
+	#evocation,if=cooldown.icy_veins.remains=0&buff.rune_of_power.remains<20
+	if TalentPoints(invocation_talent) and IcyVeins() and BuffRemains(invokers_energy_buff) < 20 Spell(evocation)
+	#evocation,if=mana.pct<50,interrupt_if=mana.pct>95
+	if not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and ManaPercent() < 50 Spell(evocation)
+	#frozen_orb
+	Spell(frozen_orb)
+}
+
+AddFunction FrostDefaultCdActions
+{
+	#counterspell,if=target.debuff.casting.react
+	if target.IsInterruptible() Spell(counterspell)
+	UseRacialInterruptActions()
+
+	unless { TalentPoints(rune_of_power_talent) and RuneOfPowerRemains() < CastTime(rune_of_power) and BuffExpires(alter_time_buff) }
+		or { TalentPoints(rune_of_power_talent) and IcyVeins() and RuneOfPowerRemains() < 20 }
+		or { TalentPoints(invocation_talent) and BuffRemains(invokers_energy_buff) < CastTime(rune_of_power) and BuffExpires(alter_time_buff) }
+		or { TalentPoints(invocation_talent) and IcyVeins() and BuffRemains(invokers_energy_buff) < 20 }
+		or { not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and ManaPercent() < 50 and Spell(evocation) }
+	{
+		#mirror_image
+		Spell(mirror_image)
+		#icy_veins,if=time_to_bloodlust>180&((buff.brain_freeze.react|buff.fingers_of_frost.react)|target.time_to_die<22),moving=0
+		if TimeToBloodlust() > 180 and { { BuffPresent(brain_freeze_buff) or BuffPresent(fingers_of_frost_buff) } or target.TimeToDie() < 22 } IcyVeins()
+		#blood_fury,if=buff.icy_veins.up|cooldown.icy_veins.remains>30|target.time_to_die<18
+		if BuffPresent(icy_veins_buff) or IcyVeinsCooldownRemains() > 30 or target.TimeToDie() < 18 Spell(blood_fury)
+		#berserking,if=buff.icy_veins.up|target.time_to_die<18
+		if BuffPresent(icy_veins_buff) or target.TimeToDie() < 18 Spell(berserking)
+		#jade_serpent_potion,if=buff.icy_veins.up|target.time_to_die<45
+		if BuffPresent(icy_veins_buff) or target.TimeToDie() < 45 UsePotionIntellect()
+		#presence_of_mind,if=buff.icy_veins.up|cooldown.icy_veins.remains>15|target.time_to_die<15
+		if BuffPresent(icy_veins_buff) or IcyVeinsCooldownRemains() > 15 or target.TimeToDie() < 15 Spell(presence_of_mind)
+		#use_item,slot=hands,sync=alter_time_activate,if=buff.alter_time.down
+		if Spell(alter_time_activate) and BuffExpires(alter_time_buff) UseItemActions()
+		#alter_time,if=buff.alter_time.down&buff.icy_veins.up
+		if BuffExpires(alter_time_buff) and BuffPresent(icy_veins_buff) Spell(alter_time)
+		#use_item,slot=hands,if=(cooldown.alter_time_activate.remains>45&buff.rune_of_power.remains>20)|target.time_to_die<25" )
+		if TalentPoints(rune_of_power_talent) and { { SpellCooldown(alter_time_activate) > 45 and RuneOfPowerRemains() > 20 } or target.TimeToDie() < 25 } UseItemActions()
+		#use_item,slot=hands,if=(cooldown.alter_time_activate.remains>45&buff.invokers_energy.remains>20)|target.time_to_die<25
+		if TalentPoints(invocation_talent) and { { SpellCooldown(alter_time_activate) > 45 and BuffRemains(invokers_energy_buff) > 20 } or target.TimeToDie() < 25 } UseItemActions()
+		#use_item,slot=hands,if=cooldown.alter_time_activate.remains>45|target.time_to_die<25
+		if not TalentPoints(rune_of_power_talent) and not TalentPoints(invocation_talent) and { SpellCooldown(alter_time_activate) > 45 or target.TimeToDie() < 25 } UseItemActions()
+	}
+}
+
+AddFunction FrostPrecombatActions
+{
+	#flask,type=warm_sun
+	#food,type=mogu_fish_stew
+	#arcane_brilliance
+	if BuffExpires(critical_strike any=1) or BuffExpires(spell_power_multiplier any=1) Spell(arcane_brilliance)
+	#frost_armor
+	if BuffExpires(frost_armor_buff) Spell(frost_armor)
+	#water_elemental
+	if pet.Present(no) Spell(water_elemental)
+	#snapshot_stats
+}
+
+AddFunction FrostPrecombatShortCdActions
+{
+	#evocation
+	if TalentPoints(invocation_talent) Spell(evocation)
+	#rune_of_power
+	if TalentPoints(rune_of_power_talent) Spell(rune_of_power)
+}
+
+AddFunction FrostPrecombatCdActions
+{
+	#jade_serpent_potion
+	UsePotionIntellect()
+	#mirror_image
+	Spell(mirror_image)
+}
+
+# Frost AoE rotation from Icy Veins Frost Mage Class Guide:
+#	http://icy-veins.com/frost-mage-wow-pve-dps-rotation-cooldowns-abilities#sec-2
+#
+AddFunction FrostAoeActions
+{
+	# Cast Flamestrike on cooldown.
+	#flamestrike,if=active_enemies>=5
+	if Enemies() >= 5 Spell(flamestrike)
+
+	# Cast glyphed Cone of Cold on cooldown.
+	if Glyph(glyph_of_cone_of_cold) Spell(cone_of_cold)
+
+	# Cast mage bomb on at least one target.
+	#nether_tempest,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>6
+	if TalentPoints(nether_tempest_talent) and { not target.DebuffPresent(nether_tempest_debuff) or target.DebuffRemains(nether_tempest_debuff) < target.TickTime(nether_tempest_debuff) } and target.TimeToDie() > 6 Spell(nether_tempest)
+	#living_bomb,cycle_targets=1,if=(!ticking|remains<tick_time)&target.time_to_die>tick_time*3
+	if TalentPoints(living_bomb_talent) and { not target.DebuffPresent(living_bomb_debuff) or target.DebuffRemains(living_bomb_debuff) < target.TickTime(living_bomb_debuff) } and target.TimeToDie() > target.TickTime(living_bomb_debuff) * 3 Spell(living_bomb)
+	#frost_bomb,if=!ticking&target.time_to_die>tick_time*3
+	if TalentPoints(frost_bomb_talent) and not target.DebuffPresent(frost_bomb_debuff) and target.TimeToDie() > target.TickTime(frost_bomb_debuff) * 3 Spell(frost_bomb)
+
+	# Toss out Frozen Orb to generate Fingers of Frost to use with Ice Lance.
+	# Ice Lance should be glyphed for maximum cleave damage.
+	if BuffExpires(fingers_of_frost_buff) Spell(frozen_orb)
+	if BuffPresent(fingers_of_frost_buff) Spell(ice_lance)
+
+	# Blizzard as filler.
+	Spell(blizzard)
+}
+
+### Frost icons.
+
+AddIcon mastery=frost help=Blink size=small checkboxon=opt_icons_left
+{
+	if TalentPoints(cold_snap_talent) and HealthPercent() < 30 Spell(cold_snap)
+	Spell(blink)
+}
+
+AddIcon mastery=frost help=combustion size=small checkboxon=opt_icons_left
+{
+	if pet.Present() Spell(water_elemental_freeze)
+}
+
+AddIcon mastery=frost help=shortcd
+{
+	if InCombat(no) FrostPrecombatShortCdActions()
+	FrostDefaultShortCdActions()
+}
+
+AddIcon mastery=frost help=main
+{
+	if InCombat(no) FrostPrecombatActions()
+	FrostDefaultActions()
+}
+
+AddIcon mastery=frost help=aoe checkboxon=opt_aoe
+{
+	if InCombat(no) FrostPrecombatActions()
+	FrostAoeActions()
+}
+
+AddIcon mastery=frost help=cd
+{
+	FrostDefaultCdActions()
+}
+
+AddIcon mastery=frost help=cd size=small checkboxon=opt_icons_right
+{
+	if BuffExpires(burst_haste any=1) and DebuffExpires(burst_haste_debuff) Spell(time_warp)
+}
+
+AddIcon mastery=frost help=cd size=small checkboxon=opt_icons_right
+{
+	UseItemActions()
+}
+]]
+
+	OvaleScripts:RegisterScript("MAGE", name, desc, code)
+end
diff --git a/scripts/ovale_mage_spells.lua b/scripts/ovale_mage_spells.lua
new file mode 100644
index 0000000..2374ba3
--- /dev/null
+++ b/scripts/ovale_mage_spells.lua
@@ -0,0 +1,218 @@
+local _, Ovale = ...
+local OvaleScripts = Ovale.OvaleScripts
+
+do
+	local name = "ovale_mage_spells"
+	local desc = "[5.4.7] Ovale: Mage spells"
+	local code = [[
+# Mage spells and functions.
+#	Last updated: 2014-04-21
+
+Define(alter_time 108978)
+	SpellInfo(alter_time cd=180)
+Define(alter_time_activate 108978)
+Define(alter_time_buff 110909)
+	SpellInfo(alter_time_buff duration=6)
+Define(arcane_barrage 44425)
+	SpellInfo(arcane_barrage cd=3)
+	SpellAddDebuff(arcane_barrage arcane_charge_debuff=0 if_spell=arcane_charge)
+Define(arcane_blast 30451)
+	SpellAddDebuff(arcane_blast arcane_charge_debuff=1 if_spell=arcane_charge)
+	SpellAddBuff(arcane_blast profound_magic_buff=0 itemset=T16_caster itemcount=2 mastery=arcane)
+Define(arcane_brilliance 1459)
+Define(arcane_charge 114664)
+Define(arcane_charge_debuff 36032)
+	SpellInfo(arcane_charge_debuff duration=10 maxstacks=4)
+Define(arcane_explosion 1449)
+	SpellAddDebuff(arcane_explosion arcane_charge_debuff=refresh if_spell=arcane_charge))
+Define(arcane_missiles 5143)
+	SpellInfo(arcane_missiles duration=2)
+	SpellAddDebuff(arcane_missiles arcane_charge_debuff=1 if_spell=arcane_charge))
+Define(arcane_missiles_buff 79683)
+	SpellInfo(arcane_missiles_buff duration=20 maxstacks=2)
+Define(arcane_power 12042)
+	SpellInfo(arcane_power cd=90)
+	SpellInfo(arcane_power addcd=90 glyph=glyph_of_arcane_power)
+	SpellAddBuff(arcane_power arcane_power_buff=1)
+Define(arcane_power_buff 12042)
+	SpellInfo(arcane_power_buff duration=15)
+	SpellInfo(arcane_power_buff addduration=15 glyph=glyph_of_arcane_power)
+Define(blink 1953)
+	SpellInfo(blink cd=15)
+Define(blizzard 10)
+	SpellInfo(blizzard channel=8 haste=spell)
+Define(brain_freeze_buff 57761)
+	SpellInfo(brain_freeze_buff duration=15)
+Define(cold_snap 11958)
+	SpellInfo(cold_snap cd=180)
+Define(cold_snap_talent 12)
+Define(combustion 11129)
+	SpellInfo(combustion cd=45)
+	SpellInfo(combustion cd=90 glyph=glyph_of_combustion)
+	SpellInfo(combustion cd=36 itemset=T14 itemcount=4)
+	SpellInfo(combustion cd=72 glyph=glyph_of_combustion itemset=T14 itemcount=4)
+	SpellAddTargetDebuff(combustion combustion_debuff=1)
+Define(combustion_debuff 83853)
+	SpellInfo(combustion_aura duration=10 haste=spell tick=1)
+	SpellInfo(combustion_aura addduration=10 glyph=glyph_of_combustion)
+Define(cone_of_cold 120)
+	SpellInfo(cone_of_cold cd=10)
+Define(conjure_brilliant_mana_gem 119316)
+Define(conjure_mana_gem 759)
+Define(counterspell 2139)
+	SpellInfo(counterspell cd=24)
+Define(evocation 12051)
+	SpellInfo(evocation cd=120 channel=3 haste=spell)
+	SpellInfo(evocation cd=0 talent=invocation_talent)
+	SpellAddDebuff(evocation arcane_charge_debuff=0 if_spell=arcane_charge)
+Define(fingers_of_frost_buff 44544)
+	SpellInfo(fingers_of_frost_buff duration=15 maxstacks=2)
+Define(fire_blast 2136)
+	SpellInfo(fire_blast cd=8)
+Define(fireball 133)
+	SpellInfo(fireball base=1561 bonussp=1.5)
+	SpellDamageDebuff(fireball pyromaniac_debuff=1.1)
+Define(flamestrike 2120)
+	SpellInfo(flamestrike cd=12 duration=8 haste=spell tick=2)
+Define(frost_armor 7302)
+Define(frost_armor_buff 7302)
+Define(frost_bomb 112948)
+	SpellInfo(frost_bomb cd=10 cd_haste=spell)
+	SpellAddTargetDebuff(frost_bomb frost_bomb_debuff=1)
+	SpellAddTargetDebuff(frost_bomb pyromaniac_debuff=1 if_spell=pyromaniac)
+Define(frost_bomb_debuff 112948)
+	SpellInfo(frost_bomb_debuff duration=4 haste=spell tick=4)
+Define(frost_bomb_talent 15)
+Define(frostbolt 116)
+	SpellAddBuff(frostbolt frozen_thoughts_buff=0 itemset=T16_caster itemcount=2 mastery=frost)
+Define(frostfire_bolt 44614)
+	SpellAddBuff(frostfire_bolt brain_freeze_buff=0 mastery=frost)
+	SpellAddBuff(frostfire_bolt frozen_thoughts_buff=0 itemset=T16_caster itemcount=2 mastery=frost)
+	SpellDamageDebuff(frostfire_bolt pyromaniac_debuff=1.1)
+Define(frozen_orb 84714)
+	SpellInfo(frozen_orb cd=60)
+Define(frozen_thoughts_buff 146557)
+	SpellInfo(frozen_thoughts_buff duration=15)
+Define(glyph_of_arcane_power 62210)
+Define(glyph_of_combustion 56368)
+Define(glyph_of_cone_of_cold 115705)
+Define(glyph_of_icy_veins 56364)
+Define(glyph_of_mana_gem 56383)
+Define(heating_up_buff 48107)
+	SpellInfo(heating_up_buff duration=10)
+Define(ice_floes 108839)
+	SpellAddBuff(ice_floes ice_floes_buff=1)
+Define(ice_floes_buff 108839)
+	SpellInfo(ice_floes_buff duration=15)
+Define(ice_floes_talent 3)
+Define(ice_lance 30455)
+	SpellAddBuff(ice_lance fingers_of_frost_buff=-1)
+	SpellAddBuff(ice_lance frozen_thoughts_buff=0 itemset=T16_caster itemcount=2 mastery=frost)
+Define(icy_veins 12472)
+	SpellInfo(icy_veins cd=180 duration=20)
+	SpellInfo(icy_veins addcd=-90 itemset=T14 itemcount=4)
+	SpellAddBuff(icy_veins icy_veins=1)
+Define(icy_veins_glyphed 131078)
+	SpellInfo(icy_veins_glyphed cd=180 duration=20)
+	SpellInfo(icy_veins_glyphed addcd=-90 itemset=T14 itemcount=4)
+	SpellAddBuff(icy_veins_glyphed icy_veins_glyphed=1)
+SpellList(icy_veins_buff 12472 131078)
+Define(ice_ward 111264)
+	SpellInfo(ice_ward cd=20)
+	SpellAddTargetBuff(ice_ward ice_ward_buff=1)
+Define(ice_ward_buff 111264)
+	SpellInfo(ice_ward_buff duration=30)
+Define(ice_ward_talent 8)
+Define(ignite_debuff 12654)
+	SpellInfo(ignite_debuff duration=4 tick=2)
+Define(inferno_blast 108853)
+	SpellInfo(inferno_blast cd=8)
+	SpellInfo(inferno_blast base=624.5 bonussp=0.6)
+	SpellDamageDebuff(inferno_blast pyromaniac_debuff=1.1)
+Define(invocation_talent 16)
+Define(invokers_energy_buff 116257)
+	SpellInfo(invokers_energy_buff duration=60)
+Define(living_bomb 44457)
+	SpellInfo(living_bomb gcd=1)
+	SpellAddTargetDebuff(living_bomb living_bomb_debuff=1)
+	SpellAddTargetDebuff(living_bomb pyromaniac_debuff=1 if_spell=pyromaniac)
+Define(living_bomb_debuff 44457)
+	SpellInfo(living_bomb duration=12 haste=spell tick=3)
+Define(living_bomb_talent 14)
+Define(mage_armor 6117)
+Define(mage_armor_buff 6117)
+Define(mirror_image 55342)
+	SpellInfo(mirror_image cd=180)
+Define(molten_armor 30482)
+Define(molten_armor_buff 30482)
+Define(nether_tempest 114923)
+	SpellAddTargetDebuff(nether_tempest nether_tempest_debuff=1)
+	SpellAddTargetDebuff(nether_tempest pyromaniac_debuff=1 if_spell=pyromaniac)
+Define(nether_tempest_debuff 114923)
+	SpellInfo(nether_tempest_debuff duration=12 haste=spell tick=1)
+Define(nether_tempest_talent 13)
+Define(presence_of_mind 12043)
+	SpellInfo(presence_of_mind cd=90)
+	SpellAddBuff(presence_of_mind presence_of_mind_buff=1)
+Define(presence_of_mind_buff 12043)
+	SpellInfo(presence_of_mind_buff duration=86400)	# XXX
+Define(presence_of_mind_talent 1)
+Define(profound_magic_buff 145252)
+	SpellInfo(profound_magic_buff duration=10)
+Define(pyroblast 11366)
+	SpellInfo(pyroblast base=2061 bonussp=1.98)
+	SpellAddBuff(pyroblast pyroblast_buff=0)
+	SpellAddTargetDebuff(pyroblast pyroblast_debuff=1)
+	SpellDamageBuff(pyroblast pyroblast_buff=1.25)
+	SpellDamageDebuff(pyroblast pyromaniac_debuff=1.1)
+Define(pyroblast_buff 48108)
+	SpellInfo(pyroblast_buff duration=15)
+Define(pyroblast_debuff 11366)
+	SpellInfo(pyroblast_debuff duration=18 haste=spell tick=3)
+	SpellInfo(pyroblast_debuff base=2061 bonussp=1.98)
+Define(pyromaniac 132209)
+Define(pyromaniac_debuff 132210)
+	SpellInfo(pyromaniac_debuff duration=15)
+Define(rune_of_power 116011)
+	SpellAddBuff(rune_of_power rune_of_power_buff=1)
+Define(rune_of_power_buff 116014)
+	SpellInfo(rune_of_power_buff duration=60)
+Define(rune_of_power_talent 17)
+Define(scorch 2948)
+Define(time_warp 80353)
+	SpellInfo(time_warp cd=300)
+Define(water_elemental 31687)
+	SpellInfo(water_elemental cd=60)
+Define(water_elemental_freeze 33395)
+	SpellInfo(water_elemental_freeze cd=25)
+
+Define(brilliant_mana_gem 81901)
+Define(mana_gem 36799)
+
+AddFunction ConjureManaGem
+{
+	if Glyph(glyph_of_mana_gem) and ItemCharges(brilliant_mana_gem) <10 Spell(conjure_brilliant_mana_gem)
+	if Glyph(glyph_of_mana_gem no) and ItemCharges(mana_gem) <3 Spell(conjure_mana_gem)
+}
+
+AddFunction UseManaGem
+{
+	if Glyph(glyph_of_mana_gem) Item(brilliant_mana_gem)
+	if Glyph(glyph_of_mana_gem no) Item(mana_gem)
+}
+
+AddFunction IcyVeins
+{
+	if Glyph(glyph_of_icy_veins) Spell(icy_veins_glyphed)
+	if Glyph(glyph_of_icy_veins no) Spell(icy_veins)
+}
+
+AddFunction IcyVeinsCooldownRemains
+{
+	if Glyph(glyph_of_icy_veins) SpellCooldown(icy_veins_glyphed)
+	if Glyph(glyph_of_icy_veins no) SpellCooldown(icy_veins)
+}
+]]
+
+	OvaleScripts:RegisterScript("MAGE", name, desc, code, "include")
+end