actions.precombat+=/arcane_intellect
actions.precombat+=/arcane_familiar
actions.precombat+=/conjure_mana_gem
## actions.precombat+=/variable,name=aoe_target_count,op=reset,default=3
## actions.precombat+=/variable,name=conserve_mana,op=set,value=0
actions.precombat+=/variable,name=opener_min_mana,op=setif,condition=talent.arcane_harmony,value=225000,value_else=200000
# Variable used to swap rotation from using totm on the last stack of Spark or the 1st or 2nd
actions.precombat+=/variable,name=totm_on_last_spark_stack,op=set,value=!set_bonus.tier30_4pc
# Variable indicates use of a trinket that boosts stats during burst
actions.precombat+=/variable,name=steroid_trinket_equipped,op=set,value=equipped.gladiators_badge|equipped.irideus_fragment|equipped.erupting_spear_fragment|equipped.spoils_of_neltharus|equipped.tome_of_unstable_power|equipped.timebreaching_talon|equipped.horn_of_valor
# Variable indicates double on use trinkets with Talon/Irideus
actions.precombat+=/variable,name=talon_double_on_use,op=set,value=equipped.timebreaching_talon&equipped.irideus_fragment
actions.precombat+=/mirror_image
# Edited to avoid wasting Evocation between small pulls if Arcane Surge isn't even ready. This also accounts for toggles.
actions.precombat+=/arcane_blast,if=!talent.siphon_storm|cooldown.arcane_surge.remains>15
actions.precombat+=/evocation,if=talent.siphon_storm
# Executed every time the actor is available.
actions=counterspell
actions+=/potion,if=cooldown.arcane_surge.ready
# This is a backup measure in case you fail to pre-evocate with Siphon Storm.
actions+=/evocation,if=talent.siphon_storm&time<10&cooldown.arcane_surge.remains<5
actions+=/time_warp,if=talent.temporal_warp&debuff.sated.up&(cooldown.arcane_surge.ready|boss&fight_remains<=40|buff.arcane_surge.up&fight_remains<=80)
actions+=/lights_judgment,if=buff.arcane_surge.down&debuff.touch_of_the_magi.down&active_enemies>=2
actions+=/bag_of_tricks,if=buff.arcane_surge.down&debuff.touch_of_the_magi.down
# Zerking gets used after surge outside of double lust, but after touch with double lust
actions+=/berserking,if=(prev_gcd.1.arcane_surge&!(buff.temporal_warp.up&buff.bloodlust.up))|(buff.arcane_surge.up&debuff.touch_of_the_magi.up)
actions+=/blood_fury,if=prev_gcd.1.arcane_surge
actions+=/fireblood,if=prev_gcd.1.arcane_surge
actions+=/ancestral_call,if=prev_gcd.1.arcane_surge
### PI/Summer after Radiant Spark when cooldowns are coming up, Autumn after Touch of the Magi cd starts
## actions+=/invoke_external_buff,name=power_infusion,if=((!talent.radiant_spark&prev_gcd.1.arcane_surge)|(talent.radiant_spark&prev_gcd.1.radiant_spark&cooldown.arcane_surge.remains<=(gcd.max*3)))
## actions+=/invoke_external_buff,name=blessing_of_summer,if=(!talent.radiant_spark&prev_gcd.1.arcane_surge)|(talent.radiant_spark&prev_gcd.1.radiant_spark&cooldown.arcane_surge.remains<=(gcd.max*3))
## actions+=/invoke_external_buff,name=blessing_of_autumn,if=cooldown.touch_of_the_magi.remains>5
# Use other trinkets in ST after surge without t30, after touch with t30, and before Surge in AOE, except Talon which is used with spark without t30, or after surge for t30
actions+=/use_items,if=((prev_gcd.1.arcane_surge&!set_bonus.tier30_4pc)|(prev_gcd.2.arcane_surge&debuff.touch_of_the_magi.up&set_bonus.tier30_4pc))|((active_enemies>=variable.aoe_target_count)&cooldown.arcane_surge.ready&prev_gcd.1.nether_tempest)
actions+=/use_item,name=timebreaching_talon,if=((variable.totm_on_last_spark_stack&cooldown.arcane_surge.remains<=(gcd.max*3))|(!variable.totm_on_last_spark_stack&prev_gcd.1.arcane_surge))&(!variable.talon_double_on_use|!buff.bloodlust.up)
## actions+=/use_item,name=tinker_breath_of_neltharion,if=cooldown.arcane_surge.remains&buff.arcane_surge.down&debuff.touch_of_the_magi.down
actions+=/use_item,name=conjured_chillglobe,if=mana.pct>65&(!variable.steroid_trinket_equipped|cooldown.arcane_surge.remains>20)
actions+=/use_item,name=beacon_to_the_beyond,if=!variable.steroid_trinket_equipped|(cooldown.arcane_surge.remains>20&buff.arcane_surge.remains<10)
actions+=/use_item,name=darkmoon_deck_rime,if=!variable.steroid_trinket_equipped|cooldown.arcane_surge.remains>20
actions+=/use_item,name=darkmoon_deck_dance,if=!variable.steroid_trinket_equipped|cooldown.arcane_surge.remains>20
actions+=/use_item,name=darkmoon_deck_inferno,if=!variable.steroid_trinket_equipped|cooldown.arcane_surge.remains>20
actions+=/use_item,name=desperate_invokers_codex,if=!variable.steroid_trinket_equipped|cooldown.arcane_surge.remains>20
actions+=/use_item,name=iceblood_deathsnare,if=!variable.steroid_trinket_equipped|cooldown.arcane_surge.remains>20
## actions+=/variable,name=aoe_spark_phase,op=set,value=1,if=active_enemies>=variable.aoe_target_count&(action.arcane_orb.charges>0|buff.arcane_charge.stack>=3)&cooldown.radiant_spark.ready&cooldown.touch_of_the_magi.remains<=(gcd.max*2)
## actions+=/variable,name=aoe_spark_phase,op=set,value=0,if=variable.aoe_spark_phase&debuff.radiant_spark_vulnerability.down&dot.radiant_spark.remains<7&cooldown.radiant_spark.remains
## actions+=/variable,name=spark_phase,op=set,value=1,if=+actions+=/variable,name=spark_phase,op=set,value=1,if=buff.arcane_charge.stack>3&active_enemies<variable.aoe_target_count&cooldown.radiant_spark.ready&cooldown.touch_of_the_magi.remains<=(gcd.max*7)
## actions+=/variable,name=spark_phase,op=set,value=0,if=variable.spark_phase&debuff.radiant_spark_vulnerability.down&dot.radiant_spark.remains<7&cooldown.radiant_spark.remains
## actions+=/variable,name=opener,op=set,if=debuff.touch_of_the_magi.up&variable.opener,value=0
actions+=/arcane_barrage,if=fight_remains<2
# Cancel Evo if we have enough mana and don't have Siphon Storm talented or if the fight duration is running out
actions+=/evocation,if=buff.arcane_surge.down&debuff.touch_of_the_magi.down&((mana.pct<10&cooldown.touch_of_the_magi.remains<20)|cooldown.touch_of_the_magi.remains<15)&(mana.pct<fight_remains*4),interrupt_if=mana.pct>=95&!talent.siphon_storm|(mana.pct>fight_remains*4)&!(fight_remains>10&cooldown.arcane_surge.remains<1)
# Make a new gem if the encounter is long enough and use it after surge to recoup mana quickly
actions+=/conjure_mana_gem,if=debuff.touch_of_the_magi.down&buff.arcane_surge.down&cooldown.arcane_surge.remains<fight_remains&!mana_gem_charges
actions+=/use_mana_gem,if=talent.cascading_power&buff.clearcasting.stack<2&buff.arcane_surge.up
actions+=/use_mana_gem,line_cd=5,if=!talent.cascading_power&prev_gcd.1.arcane_surge
## TODO: Revisit strict flag on these entries.
# Merged two cooldown_phase entries to reduce CPU consumption.
# Enter cooldown phase when cds are available or coming off cooldown otherwise default to rotation priority
actions+=/call_action_list,name=cooldown_phase,if=(!variable.totm_on_last_spark_stack&(cooldown.arcane_surge.remains<=(gcd.max*(1+(talent.nether_tempest&talent.arcane_echo)))|buff.arcane_surge.up|buff.arcane_overload.up)&cooldown.evocation.remains>45&((cooldown.touch_of_the_magi.remains<gcd.max*4)|cooldown.touch_of_the_magi.remains>20)&active_enemies<variable.aoe_target_count)|(!variable.totm_on_last_spark_stack&cooldown.arcane_surge.remains>30&(cooldown.radiant_spark.ready|dot.radiant_spark.remains|debuff.radiant_spark_vulnerability.up)&(cooldown.touch_of_the_magi.remains<=(gcd.max*3)|debuff.touch_of_the_magi.up)&active_enemies<variable.aoe_target_count)
actions+=/call_action_list,name=aoe_spark_phase,strict=1,if=talent.radiant_spark&variable.aoe_spark_phase
actions+=/call_action_list,name=spark_phase,strict=1,if=variable.totm_on_last_spark_stack&talent.radiant_spark&variable.spark_phase
actions+=/call_action_list,name=aoe_touch_phase,strict=1,if=debuff.touch_of_the_magi.up&active_enemies>=variable.aoe_target_count
actions+=/call_action_list,name=touch_phase,strict=1,if=variable.totm_on_last_spark_stack&debuff.touch_of_the_magi.up&active_enemies<variable.aoe_target_count
actions+=/call_action_list,name=aoe_rotation,strict=1,if=active_enemies>=variable.aoe_target_count
actions+=/call_action_list,name=rotation
actions.aoe_rotation+=/shifting_power,if=(!talent.evocation|cooldown.evocation.remains>12)&(!talent.arcane_surge|cooldown.arcane_surge.remains>12)&(!talent.touch_of_the_magi|cooldown.touch_of_the_magi.remains>12)&buff.arcane_surge.down&((!talent.charged_orb&cooldown.arcane_orb.remains>12)|(action.arcane_orb.charges=0|cooldown.arcane_orb.remains>12))
actions.aoe_rotation+=/nether_tempest,if=(refreshable|!ticking)&buff.arcane_charge.stack=buff.arcane_charge.max_stack&buff.arcane_surge.down&(active_enemies>6|!talent.orb_barrage)
actions.aoe_rotation+=/arcane_barrage,if=(active_enemies<=4|buff.clearcasting.up)&buff.arcane_charge.stack=3
actions.aoe_rotation+=/arcane_orb,if=buff.arcane_charge.stack=0&cooldown.touch_of_the_magi.remains>18
actions.aoe_rotation+=/arcane_barrage,if=buff.arcane_charge.stack=buff.arcane_charge.max_stack|mana.pct<10
actions.aoe_rotation+=/arcane_explosion
actions.aoe_spark_phase=cancel_buff,name=presence_of_mind,if=prev_gcd.1.arcane_blast&cooldown.arcane_surge.remains>75
actions.aoe_spark_phase+=/touch_of_the_magi,use_off_gcd=1,if=prev_gcd.1.arcane_barrage
actions.aoe_spark_phase+=/radiant_spark
actions.aoe_spark_phase+=/arcane_orb,if=buff.arcane_charge.stack<3,line_cd=1
actions.aoe_spark_phase+=/nether_tempest,if=talent.arcane_echo,line_cd=15
actions.aoe_spark_phase+=/arcane_surge
### Waits are used to simulate players allowing radiant spark to increment in stacks
## actions.aoe_spark_phase+=/wait,sec=0.05,if=cooldown.arcane_surge.remains>75&prev_gcd.1.arcane_blast&!talent.presence_of_mind,line_cd=15
## actions.aoe_spark_phase+=/wait,sec=0.05,if=prev_gcd.1.arcane_surge,line_cd=15
## actions.aoe_spark_phase+=/wait,sec=0.05,if=cooldown.arcane_surge.remains<75&debuff.radiant_spark_vulnerability.stack=3&!talent.presence_of_mind,line_cd=15
actions.aoe_spark_phase+=/arcane_barrage,if=cooldown.arcane_surge.remains<75&debuff.radiant_spark_vulnerability.stack=4&!talent.orb_barrage
actions.aoe_spark_phase+=/arcane_barrage,if=(debuff.radiant_spark_vulnerability.stack=2&cooldown.arcane_surge.remains>75)|(debuff.radiant_spark_vulnerability.stack=1&cooldown.arcane_surge.remains<75)&!talent.orb_barrage
# Optimize orb barrage procs during spark at the cost of vulnerabilities, except at 5 or fewer targets where you arcane blast on the 3rd spark stack if its up and you have charges
actions.aoe_spark_phase+=/arcane_barrage,if=(debuff.radiant_spark_vulnerability.stack=1|debuff.radiant_spark_vulnerability.stack=2|(debuff.radiant_spark_vulnerability.stack=3&active_enemies>5)|debuff.radiant_spark_vulnerability.stack=4)&buff.arcane_charge.stack=buff.arcane_charge.max_stack&talent.orb_barrage
actions.aoe_spark_phase+=/presence_of_mind
actions.aoe_spark_phase+=/arcane_blast,if=((debuff.radiant_spark_vulnerability.stack=2|debuff.radiant_spark_vulnerability.stack=3)&!talent.orb_barrage)|(debuff.radiant_spark_vulnerability.remains&talent.orb_barrage)
actions.aoe_spark_phase+=/arcane_barrage,if=(debuff.radiant_spark_vulnerability.stack=4&buff.arcane_surge.up)|(debuff.radiant_spark_vulnerability.stack=3&buff.arcane_surge.down)&!talent.orb_barrage
## actions.aoe_touch_phase+=/variable,name=conserve_mana,op=set,if=debuff.touch_of_the_magi.remains>9,value=1-variable.conserve_mana
actions.aoe_touch_phase+=/arcane_barrage,if=(active_enemies<=4&buff.arcane_charge.stack=3)|buff.arcane_charge.stack=buff.arcane_charge.max_stack
actions.aoe_touch_phase+=/arcane_orb,if=buff.arcane_charge.stack<2
actions.aoe_touch_phase+=/arcane_explosion
actions.cooldown_phase+=/touch_of_the_magi,use_off_gcd=1,if=prev_gcd.1.arcane_barrage
## actions.cooldown_phase+=/variable,name=conserve_mana,op=set,if=cooldown.radiant_spark.ready,value=0+(cooldown.arcane_surge.remains<10)
actions.cooldown_phase+=/shifting_power,if=buff.arcane_surge.down&!talent.radiant_spark
actions.cooldown_phase+=/arcane_orb,if=cooldown.radiant_spark.ready&buff.arcane_charge.stack<buff.arcane_charge.max_stack
actions.cooldown_phase+=/arcane_blast,if=cooldown.radiant_spark.ready&(buff.arcane_charge.stack<2|(buff.arcane_charge.stack<buff.arcane_charge.max_stack&cooldown.arcane_orb.remains>=gcd.max))
actions.cooldown_phase+=/arcane_missiles,if=cooldown.radiant_spark.ready&buff.clearcasting.react&(talent.nether_precision&(buff.nether_precision.down|buff.nether_precision.remains<gcd.max))
actions.cooldown_phase+=/radiant_spark
actions.cooldown_phase+=/nether_tempest,if=talent.arcane_echo,line_cd=30
actions.cooldown_phase+=/arcane_surge
## actions.cooldown_phase+=/wait,sec=0.05,if=prev_gcd.1.arcane_surge,line_cd=15
actions.cooldown_phase+=/arcane_barrage,if=prev_gcd.1.arcane_surge|prev_gcd.1.nether_tempest|prev_gcd.1.radiant_spark
actions.cooldown_phase+=/arcane_blast,if=prev_gcd.1.arcane_barrage|prev_gcd.2.arcane_barrage|prev_gcd.3.arcane_barrage|(prev_gcd.4.arcane_barrage&cooldown.arcane_surge.remains<60)
actions.cooldown_phase+=/presence_of_mind,if=debuff.touch_of_the_magi.remains<=gcd.max
actions.cooldown_phase+=/arcane_blast,if=buff.presence_of_mind.up
# Canceling missile channels as soon as blast is ready to cast
actions.cooldown_phase+=/arcane_missiles,if=buff.nether_precision.down&buff.clearcasting.react,interrupt_if=gcd.remains=0&mana.pct>30&buff.nether_precision.up
actions.cooldown_phase+=/arcane_blast
actions.rotation+=/arcane_orb,if=buff.arcane_charge.stack<3&(buff.bloodlust.down|mana.pct>70|(variable.totm_on_last_spark_stack&cooldown.touch_of_the_magi.remains>30))
actions.rotation+=/shifting_power,if=variable.totm_on_last_spark_stack&(!talent.evocation|cooldown.evocation.remains>12)&(!talent.arcane_surge|cooldown.arcane_surge.remains>12)&(!talent.touch_of_the_magi|cooldown.touch_of_the_magi.remains>12)&buff.arcane_surge.down&fight_remains>15
actions.rotation+=/shifting_power,if=!variable.totm_on_last_spark_stack&buff.arcane_surge.down&cooldown.arcane_surge.remains>45&fight_remains>15
actions.rotation+=/presence_of_mind,if=buff.arcane_charge.stack<3&target.health.pct<35&talent.arcane_bombardment
actions.rotation+=/arcane_blast,if=talent.time_anomaly&buff.arcane_surge.up&buff.arcane_surge.remains<=6
actions.rotation+=/arcane_blast,if=buff.presence_of_mind.up&target.health.pct<35&talent.arcane_bombardment&buff.arcane_charge.stack<3
actions.rotation+=/arcane_missiles,if=buff.clearcasting.react&buff.clearcasting.stack=buff.clearcasting.max_stack
actions.rotation+=/nether_tempest,if=(refreshable|!ticking)&buff.arcane_charge.stack=buff.arcane_charge.max_stack&(buff.temporal_warp.up|mana.pct<10|!talent.shifting_power)&buff.arcane_surge.down&fight_remains>=12
actions.rotation+=/arcane_barrage,if=buff.arcane_charge.stack=buff.arcane_charge.max_stack&mana.pct<50&!talent.evocation&fight_remains>20
actions.rotation+=/arcane_barrage,if=buff.arcane_charge.stack=buff.arcane_charge.max_stack&mana.pct<70&variable.conserve_mana&buff.bloodlust.up&cooldown.touch_of_the_magi.remains>5&fight_remains>20
actions.rotation+=/arcane_missiles,if=buff.clearcasting.react&buff.concentration.up&buff.arcane_charge.stack=buff.arcane_charge.max_stack
actions.rotation+=/arcane_blast,if=buff.arcane_charge.stack=buff.arcane_charge.max_stack&buff.nether_precision.up
actions.rotation+=/arcane_barrage,if=buff.arcane_charge.stack=buff.arcane_charge.max_stack&mana.pct<60&variable.conserve_mana&cooldown.touch_of_the_magi.remains>10&cooldown.evocation.remains>40&fight_remains>20
# Canceling missile channels as soon as blast is ready to cast
actions.rotation+=/arcane_missiles,if=buff.clearcasting.react&buff.nether_precision.down,interrupt_if=gcd.remains=0&buff.nether_precision.up&(mana.pct>30&cooldown.touch_of_the_magi.remains>30|mana.pct>70)
actions.rotation+=/arcane_blast
actions.rotation+=/arcane_barrage
actions.spark_phase+=/nether_tempest,if=!ticking&variable.opener&buff.bloodlust.up,line_cd=45
actions.spark_phase+=/arcane_blast,if=variable.opener&cooldown.arcane_surge.ready&buff.bloodlust.up&mana>=variable.opener_min_mana
actions.spark_phase+=/arcane_missiles,if=variable.opener&buff.bloodlust.up&buff.clearcasting.react&buff.clearcasting.stack>=2&cooldown.radiant_spark.remains<5&buff.nether_precision.down,chain=1
actions.spark_phase+=/arcane_missiles,if=talent.arcane_harmony&buff.arcane_harmony.stack<15&((variable.opener&buff.bloodlust.up)|buff.clearcasting.react&cooldown.radiant_spark.remains<5)&cooldown.arcane_surge.remains<30,chain=1
actions.spark_phase+=/radiant_spark
actions.spark_phase+=/nether_tempest,if=(prev_gcd.4.radiant_spark&cooldown.arcane_surge.remains<=execute_time)|prev_gcd.5.radiant_spark,line_cd=15
actions.spark_phase+=/arcane_surge,if=(!talent.nether_tempest&prev_gcd.4.radiant_spark)|prev_gcd.1.nether_tempest
actions.spark_phase+=/arcane_blast,if=cast_time>=gcd&execute_time<debuff.radiant_spark_vulnerability.remains&(!talent.arcane_bombardment|target.health.pct>=35)&(talent.nether_tempest&prev_gcd.6.radiant_spark|!talent.nether_tempest&prev_gcd.5.radiant_spark)
### Waits are used to simulate players allowing radiant spark to increment in stacks
## actions.spark_phase+=/wait,sec=0.05,if=(talent.nether_tempest&prev_gcd.6.radiant_spark)|(!talent.nether_tempest&prev_gcd.5.radiant_spark),line_cd=15
actions.spark_phase+=/arcane_barrage,if=debuff.radiant_spark_vulnerability.stack=4
actions.spark_phase+=/touch_of_the_magi,use_off_gcd=1,if=prev_gcd.1.arcane_barrage&(action.arcane_barrage.in_flight_remains<=0.2|gcd.remains<=0.2)
actions.spark_phase+=/arcane_blast
actions.spark_phase+=/arcane_barrage
## actions.touch_phase+=/variable,name=conserve_mana,op=set,if=debuff.touch_of_the_magi.remains>9,value=1-variable.conserve_mana
actions.touch_phase+=/presence_of_mind,if=debuff.touch_of_the_magi.remains<=gcd.max
actions.touch_phase+=/arcane_blast,if=buff.presence_of_mind.up&buff.arcane_charge.stack=buff.arcane_charge.max_stack
actions.touch_phase+=/arcane_barrage,if=(buff.arcane_harmony.up|(talent.arcane_bombardment&target.health.pct<35))&debuff.touch_of_the_magi.remains<=gcd.max
actions.touch_phase+=/arcane_missiles,if=buff.clearcasting.stack>1&talent.conjure_mana_gem&cooldown.use_mana_gem.ready,chain=1
actions.touch_phase+=/arcane_blast,if=buff.nether_precision.up
actions.touch_phase+=/arcane_missiles,if=buff.clearcasting.react&(debuff.touch_of_the_magi.remains>execute_time|!talent.presence_of_mind),chain=1
actions.touch_phase+=/arcane_blast
actions.touch_phase+=/arcane_barrage