actions.precombat+=/shadowform,if=!buff.shadowform.up
actions.precombat+=/arcane_torrent
actions.precombat+=/variable,name=mind_sear_cutoff,op=set,value=2
actions.precombat+=/variable,name=pool_amount,op=set,value=60
actions.precombat+=/shadow_crash,if=raid_event.adds.in>=25&spell_targets.shadow_crash<=8&!boss&(!set_bonus.tier31_4pc|spell_targets.shadow_crash>1)
actions.precombat+=/vampiric_touch,if=refreshable&!action.shadow_crash.in_flight&(!talent.shadow_crash.enabled|raid_event.adds.in<25|spell_targets.shadow_crash>8|!boss|set_bonus.tier31_4pc&spell_targets.shadow_crash=1)
actions+=/silence
actions+=/variable,name=holding_crash,op=set,value=talent.shadow_crash&!action.shadow_crash.disabled&raid_event.adds.in<15
actions+=/variable,name=all_dots_up,op=set,value=target.time_to_die<8|(dot.shadow_word_pain.ticking&dot.vampiric_touch.ticking|action.shadow_crash.in_flight)&dot.devouring_plague.ticking
actions+=/variable,name=pool_for_cds,op=set,value=(cooldown.void_eruption.remains<=gcd.max*3&talent.void_eruption|cooldown.dark_ascension.up&talent.dark_ascension)|talent.void_torrent&talent.psychic_link&cooldown.void_torrent.remains<=4&(!raid_event.adds.exists&spell_targets.vampiric_touch>1|raid_event.adds.in<=5|raid_event.adds.remains>=6&!variable.holding_crash)&!buff.voidform.up
actions+=/variable,name=max_vts,op=set,default=12,value=spell_targets.vampiric_touch>?12
actions+=/variable,name=is_vt_possible,op=set,value=true,value_else=false,condition=dot.vampiric_touch.refreshable|active_dot.vampiric_touch<cycle_enemies&fight_remains>8
actions+=/variable,name=vts_applied,op=set,value=(active_dot.vampiric_touch+8*action.shadow_crash.in_flight&talent.whispering_shadows)>=variable.max_vts|!variable.is_vt_possible
actions+=/run_action_list,name=aoe,strict=1,if=active_enemies>2
actions+=/run_action_list,name=main
actions.aoe+=/variable,name=dots_up,op=set,value=(active_dot.vampiric_touch+8*(action.shadow_crash.in_flight&talent.whispering_shadows))>=variable.max_vts|!variable.is_vt_possible|fight_remains<8
actions.aoe+=/variable,name=holding_crash,op=set,value=(variable.max_vts-active_dot.vampiric_touch)<4|raid_event.adds.in<10&raid_event.adds.count>(variable.max_vts-active_dot.vampiric_touch),if=variable.holding_crash&talent.whispering_shadows
actions.aoe+=/variable,name=manual_vts_applied,op=set,value=(active_dot.vampiric_touch+8*!variable.holding_crash)>=variable.max_vts|!variable.is_vt_possible
# High Priority action to put out Vampiric Touch on enemies that will live at least 18 seconds, up to 12 targets manually while prepping AoE
actions.aoe+=/vampiric_touch,cycle_targets=1,if=refreshable&target.time_to_die>=18&(dot.vampiric_touch.ticking|!variable.dots_up)&(variable.max_vts>0&!variable.manual_vts_applied&!action.shadow_crash.in_flight|!talent.whispering_shadows)
# Use Shadow Crash to apply Vampiric Touch to as many adds as possible while being efficient with Vampiric Touch refresh windows
actions.aoe+=/shadow_crash,cycle_targets=1,if=!variable.holding_crash&(dot.vampiric_touch.refreshable|dot.vampiric_touch.remains<=target.time_to_die&!buff.voidform.up&(raid_event.adds.in-dot.vampiric_touch.remains)<15)
actions.aoe+=/call_action_list,name=cds,if=fight_remains<30|target.time_to_die>15&(!variable.holding_crash|active_enemies>2)
# Use Shadowfiend or Mindbender on cooldown if DoTs are active and sync with Dark Ascension
actions.aoe+=/mindbender,if=(dot.shadow_word_pain.ticking&variable.dots_up|action.shadow_crash.in_flight&talent.whispering_shadows)&(fight_remains<30|target.time_to_die>15)&(!talent.dark_ascension|cooldown.dark_ascension.remains<gcd.max|fight_remains<15)
# Use Void Bolt at the highest priority
actions.aoe+=/void_bolt,cycle_targets=1
actions.aoe+=/devouring_plague,cycle_targets=1,if=talent.distorted_reality&(active_dot.devouring_plague=0|insanity.deficit<=20)
actions.aoe+=/shadow_word_death,cycle_targets=1,if=dot.devouring_plague.remains&(set_bonus.tier31_4pc|pet.fiend.active&talent.inescapable_torment&set_bonus.tier31_2pc)
# Use Mind Blast when capped on charges and talented into Mind Devourer to fish for the buff or if Inescapable Torment is talented with Mindbender active. Only use when facing 3-7 targets.
actions.aoe+=/mind_blast,cycle_targets=1,if=(cooldown.mind_blast.full_recharge_time<=gcd.max+cast_time|pet.fiend.remains<=cast_time+gcd.max)&pet.fiend.active&talent.inescapable_torment&pet.fiend.remains>cast_time&active_enemies<=7&!buff.mind_devourer.up&dot.devouring_plague.remains>execute_time
# High Priority Shadow Word: Death is Mindbender is expiring in less than 2 seconds
actions.aoe+=/shadow_word_death,cycle_targets=1,if=pet.fiend.remains<=2&pet.fiend.active&talent.inescapable_torment&active_enemies<=7
## actions.aoe+=/call_action_list,name=heal_for_tof,if=!buff.twist_of_fate.up&buff.twist_of_fate_can_trigger_on_ally_heal.up&(talent.rhapsody|talent.divine_star|talent.halo)
# Use Devouring Plague on enemies that will live the longest with distorted reality.
actions.aoe+=/devouring_plague,cycle_targets=1,if=talent.distorted_reality
# Use Devouring Plague to maximize uptime. Short circuit if you are capping on Insanity within 20 or to get out an extra Void Bolt by extending Voidform. With Distorted Reality can maintain more than one at a time in multi-target.
actions.aoe+=/devouring_plague,if=(remains<=gcd.max&!variable.pool_for_cds|insanity.deficit<=20|buff.voidform.up&cooldown.void_bolt.remains>buff.voidform.remains&cooldown.void_bolt.remains<=buff.voidform.remains+2)&!talent.distorted_reality
actions.aoe+=/vampiric_touch,cycle_targets=1,if=refreshable&target.time_to_die>=18&(dot.vampiric_touch.ticking|!variable.dots_up)&(variable.max_vts>0&(cooldown.shadow_crash.remains>=dot.vampiric_touch.remains|variable.holding_crash)&!action.shadow_crash.in_flight|!talent.whispering_shadows)
# Use Shadow Word: Death with Inescapable Torment and Mindbender active and not talented into Insidious Ire and Yogg or Deathspeaker is active
actions.aoe+=/shadow_word_death,cycle_targets=1,if=variable.dots_up&talent.inescapable_torment&pet.fiend.active&((!talent.insidious_ire&!talent.idol_of_yoggsaron)|buff.deathspeaker.up)&!set_bonus.tier31_2pc
# High Priority Mind Spike: Insanity to fish for C'Thun procs when Mind Blast is not capped and Void Torrent is not available and Mindbender is not active
actions.aoe+=/mind_spike_insanity,cycle_targets=1,if=variable.dots_up&cooldown.mind_blast.full_recharge_time>=gcd*3&talent.idol_of_cthun&(!cooldown.void_torrent.up|!talent.void_torrent)
# High Priority Mind Flay: Insanity to fish for C'Thun procs when Mind Blast is not capped and Void Torrent is not available and Mindbender is not active
actions.aoe+=/mind_flay,cycle_targets=1,if=buff.mind_flay_insanity.up&variable.dots_up&cooldown.mind_blast.full_recharge_time>=gcd*3&talent.idol_of_cthun&(!cooldown.void_torrent.up|!talent.void_torrent)
# # Use all charges of Mind Blast if Vampiric Touch and Shadow Word: Pain are active and Mind Devourer is not active or you are prepping Void Eruption
actions.aoe+=/mind_blast,cycle_targets=1,if=variable.dots_up&(!buff.mind_devourer.up|cooldown.void_eruption.up&talent.void_eruption)
# Void Torrent action list for AoE
actions.aoe+=/void_torrent,cycle_targets=1,if=(!variable.holding_crash|raid_event.adds.count%(active_dot.vampiric_touch+raid_event.adds.count)<1.5)&(dot.devouring_plague.remains>=2.5|buff.voidform.up)
# High priority action for Mind Flay: Insanity to fish for Idol of C'Thun procs, cancel as soon as something else is more important and most of the channel has completed
actions.aoe+=/mind_flay,cycle_targets=1,if=buff.mind_flay_insanity.up&talent.idol_of_cthun,interrupt_if=ticks>=2,interrupt_immediate=1
actions.aoe+=/call_action_list,name=filler
# TODO: Check VE/DA enter conditions based on dots
actions.cds+=/potion,if=buff.voidform.up|buff.power_infusion.up|buff.dark_ascension.up&(fight_remains<=cooldown.power_infusion.remains+15)|boss&fight_remains<=30
actions.cds+=/fireblood,if=buff.power_infusion.up|boss&fight_remains<=8
actions.cds+=/berserking,if=buff.power_infusion.up|boss&fight_remains<=12
actions.cds+=/blood_fury,if=buff.power_infusion.up|boss&fight_remains<=15
actions.cds+=/ancestral_call,if=buff.power_infusion.up|boss&fight_remains<=15
# Use Nymue's before we go into our cooldowns
actions.cds+=/use_item,name=nymues_unraveling_spindle,if=variable.dots_up&(fight_remains<30|target.time_to_die>15)&(!talent.dark_ascension|cooldown.dark_ascension.remains<3+gcd.max|fight_remains<15)
# Sync Power Infusion with Voidform or Dark Ascension
actions.cds+=/power_infusion,if=(buff.voidform.up|buff.dark_ascension.up)
# Make sure Mindbender is active before popping Void Eruption and dump charges of Mind Blast before casting
actions.cds+=/void_eruption,if=!cooldown.fiend.up&(pet.fiend.active&cooldown.fiend.remains>=4|!talent.mindbender|active_enemies>2&!talent.inescapable_torment.rank)&(cooldown.mind_blast.charges=0|time>15)
# Make sure Mindbender is active before popping Dark Ascension unless you have insignificant talent points or too many targets
actions.cds+=/dark_ascension,if=pet.fiend.active&cooldown.fiend.remains>=4|!talent.mindbender&!cooldown.fiend.up|active_enemies>2&!talent.inescapable_torment
actions.cds+=/call_action_list,name=trinkets
actions.cds+=/mindbender,if=(dot.shadow_word_pain.ticking&variable.vts_applied|action.shadow_crash.in_flight)
# Use Desperate Prayer to heal up should Shadow Word: Death or other damage bring you below 75%
actions.cds+=/desperate_prayer,if=health.pct<=75
# Cast Vampiric Touch to consume Unfurling Darkness, prefering the target with the lowest DoT duration active
actions.filler+=/vampiric_touch,cycle_targets=1,if=buff.unfurling_darkness.up
## actions.filler+=/call_action_list,name=heal_for_tof,if=!buff.twist_of_fate.up&buff.twist_of_fate_can_trigger_on_ally_heal.up&(talent.rhapsody|talent.divine_star|talent.halo)
# Use PWS with CR talented to trigger TOF if there are no better alternatives available to do this as we still get insanity for a PWS cast.
## actions.filler+=/power_word_shield,if=!buff.twist_of_fate.up&buff.twist_of_fate_can_trigger_on_ally_heal.up&talent.crystalline_reflection
actions.filler+=/call_action_list,name=empowered_filler,if=dot.devouring_plague.remains>action.mind_spike.cast_time|!talent.mind_spike
# Cast Shadow Word: Death if the target is in execute, you have a Deathspeaker proc or you have the Season 3 2-piece bonus
actions.filler+=/shadow_word_death,cycle_targets=1,if=(target.health.pct<20|buff.deathspeaker.up|set_bonus.tier31_2pc)&dot.devouring_plague.ticking
actions.filler+=/shadow_word_death,cycle_targets=1,if=talent.inescapable_torment&pet.fiend.active
actions.filler+=/mindgames,cycle_targets=1
actions.filler+=/devouring_plague,if=buff.voidform.up|cooldown.dark_ascension.up|buff.mind_devourer.up
# Save up to 20s if adds are coming soon.
actions.filler+=/halo,if=spell_targets>1
## Using a heal with no damage kickbacks for TOF is damage neutral, so we will do it.
## actions.filler+=/power_word_life,if=!buff.twist_of_fate.up&buff.twist_of_fate_can_trigger_on_ally_heal.up
actions.filler+=/call_action_list,name=empowered_filler
## actions.filler+=/call_action_list,name=heal_for_tof,if=equipped.rashoks_molten_heart&(active_allies-(10-buff.molten_radiance.value))>=10&buff.molten_radiance.up,line_cd=5
actions.filler+=/mind_spike,cycle_targets=1,
actions.filler+=/mind_flay,cycle_targets=1,chain=1,interrupt_immediate=1,interrupt_if=ticks>=2
actions.filler+=/divine_star
# Use Shadow Crash while moving as a low-priority action when adds will not come in 20 seconds.
actions.filler+=/shadow_crash,if=raid_event.adds.in>20&!set_bonus.tier31_4pc
# Use Shadow Word: Death while moving as a low-priority action in execute
actions.filler+=/shadow_word_death,cycle_targets=1,if=target.health.pct<20
# Use Shadow Word: Death while moving as a low-priority action
actions.filler+=/shadow_word_death,cycle_targets=1
# Use Shadow Word: Pain while moving as a low-priority action with T31 4pc
actions.filler+=/shadow_word_pain,cycle_targets=1,if=set_bonus.tier31_4pc
# Use Shadow Word: Pain while moving as a low-priority action without T31 4pc
actions.filler+=/shadow_word_pain,cycle_targets=1,if=!set_bonus.tier31_4pc
actions.empowered_filler+=/mind_spike_insanity,cycle_targets=1
actions.empowered_filler+=/mind_flay,cycle_targets=1,if=buff.mind_flay_insanity.up
actions.main+=/variable,name=dots_up,op=set,value=active_dot.vampiric_touch=active_enemies|action.shadow_crash.in_flight&talent.whispering_shadows|fight_remains<8
actions.main+=/call_action_list,name=cds,if=fight_remains<30|target.time_to_die>15&(!variable.holding_crash|active_enemies>2)
# Use Shadowfiend and Mindbender on cooldown as long as Vampiric Touch and Shadow Word: Pain are active and sync with Dark Ascension
actions.main+=/mindbender,if=variable.dots_up&(fight_remains<30|target.time_to_die>15)&(!talent.dark_ascension|cooldown.dark_ascension.remains<gcd.max|fight_remains<15)
# Use Void Bolt at the highest priority
actions.main+=/void_bolt,if=variable.dots_up
actions.main+=/devouring_plague,cycle_targets=1,if=remains<=gcd.max|(!talent.distorted_reality|active_enemies=1)&insanity.deficit<=16
actions.main+=/shadow_word_death,if=(set_bonus.tier31_4pc|pet.fiend.active&talent.inescapable_torment&set_bonus.tier31_2pc)&dot.devouring_plague.ticking
# High priority Mind Blast action when using Inescapable Torment
actions.main+=/mind_blast,cycle_targets=1,if=(dot.devouring_plague.remains>execute_time&(cooldown.mind_blast.full_recharge_time<=gcd.max+execute_time)|pet.fiend.remains<=execute_time+gcd.max)&pet.fiend.active&talent.inescapable_torment&pet.fiend.remains>execute_time&active_enemies<=7
# High Priority Shadow Word: Death is Mindbender is expiring in less than 2 seconds
actions.main+=/shadow_word_death,cycle_targets=1,if=dot.devouring_plague.ticking&pet.fiend.remains<=2&pet.fiend.active&talent.inescapable_torment&active_enemies<=7
## actions.main+=/call_action_list,name=heal_for_tof,if=!buff.twist_of_fate.up&buff.twist_of_fate_can_trigger_on_ally_heal.up&(talent.rhapsody|talent.divine_star|talent.halo)
# Spend your Insanity on Devouring Plague at will if the fight will end in less than 10s
actions.main+=/devouring_plague,if=fight_remains<=duration+4
# Use Devouring Plague to maximize uptime. Short circuit if you are capping on Insanity within 20 or to get out an extra Void Bolt by extending Voidform. With Distorted Reality can maintain more than one at a time in multi-target.
actions.main+=/devouring_plague,cycle_targets=1,if=(!talent.distorted_reality|active_enemies=1|remains<=gcd.max)&(insanity.deficit<=35&talent.distorted_reality|buff.dark_ascension.up|buff.mind_devourer.up&cooldown.mind_blast.up)
actions.main+=/void_torrent,cycle_targets=1,if=!variable.holding_crash&talent.idol_of_cthun&cooldown.mind_blast.full_recharge_time>=3&talent.void_eruption&dot.devouring_plague.remains>=2.5
actions.main+=/shadow_word_death,if=set_bonus.tier31_2pc
# Use Shadow Crash as long as you are not holding for adds and Vampiric Touch is within pandemic range
actions.main+=/shadow_crash,if=!variable.holding_crash&(dot.vampiric_touch.refreshable|buff.deaths_torment.stack>9&set_bonus.tier31_4pc&active_enemies>1)
# Consume T31 4pc SWPs
actions.main+=/shadow_word_pain,if=buff.deaths_torment.stack>9&set_bonus.tier31_4pc&active_enemies=1
# Use Shadow Word: Death with Inescapable Torment and Mindbender active and not talented into Insidious Ire and Yogg or Deathspeaker is active
actions.main+=/shadow_word_death,if=variable.dots_up&talent.inescapable_torment&pet.fiend.active&((!talent.insidious_ire&!talent.idol_of_yoggsaron)|buff.deathspeaker.up)&!set_bonus.tier31_2pc
# Put out Vampiric Touch on enemies that will live at least 12s and Shadow Crash is not available soon
actions.main+=/vampiric_touch,cycle_targets=1,if=refreshable&target.time_to_die>=12&(cooldown.shadow_crash.remains>=dot.vampiric_touch.remains|variable.holding_crash|!talent.whispering_shadows)&(!action.shadow_crash.in_flight|!talent.whispering_shadows)
# Use all charges of Mind Blast if Vampiric Touch and Shadow Word: Pain are active and Mind Devourer is not active or you are prepping Void Eruption
actions.main+=/mind_blast,if=(!buff.mind_devourer.up|cooldown.void_eruption.up&talent.void_eruption)
# Void Torrent if you are not holding Shadow Crash for an add pack coming, prefer the target with the most DoTs active. Only cast if Devouring Plague is on that target and will last at least 2 seconds
actions.main+=/void_torrent,cycle_targets=1,if=!variable.holding_crash&(!talent.idol_of_cthun|!talent.void_eruption)&dot.devouring_plague.remains>=2.5,interrupt_if=cooldown.shadow_word_death.ready&pet.fiend.active&set_bonus.tier31_2pc
# Cast Mindgames if all DoTs will be active by the time the cast finishes
actions.main+=/call_action_list,name=filler
# Use Halo to acquire Twist of Fate if an ally can be healed for it and it is not currently up.
actions.heal_for_tof+=/halo
# Use Divine Star to acquire Twist of Fate if an ally can be healed for it and it is not currently up.
actions.heal_for_tof+=/divine_star
# Use Holy Nova when Rhapsody is fully stacked to acquire Twist of Fate if an ally can be healed for it and it is not currently up.
actions.heal_for_tof+=/holy_nova,if=buff.rhapsody.stack=20&talent.rhapsody
actions.trinkets+=/use_item,name=voidmenders_shadowgem,if=buff.power_infusion.up|boss&fight_remains<20
actions.trinkets+=/use_item,name=iridal_the_earths_master,use_off_gcd=1,if=gcd.remains>0|boss&fight_remains<20
actions.trinkets+=/use_item,name=dreambinder_loom_of_the_great_cycle,use_off_gcd=1,if=gcd.remains>0|boss&fight_remains<20
actions.trinkets+=/use_item,name=darkmoon_deck_box_inferno
actions.trinkets+=/use_item,name=darkmoon_deck_box_rime
actions.trinkets+=/use_item,name=darkmoon_deck_box_dance
actions.trinkets+=/use_item,name=conjured_chillglobe
actions.trinkets+=/use_item,name=iceblood_deathsnare,if=(!raid_event.adds.exists|raid_event.adds.up|spell_targets.iceblood_deathsnare>=5)|fight_remains<20
# Use Erupting Spear Fragment with cooldowns, adds are currently active, or the fight will end in less than 20 seconds
actions.trinkets+=/use_item,name=erupting_spear_fragment,if=buff.power_infusion.up|raid_event.adds.up|boss&fight_remains<20
# Use Belor'relos on cooldown except to hold for incoming adds or if already facing 5 or more targets
actions.trinkets+=/use_item,name=belorrelos_the_suncaller,if=(!raid_event.adds.exists|raid_event.adds.up|spell_targets.belorrelos_the_suncaller>=5|fight_remains<20)&equipped.belorrelos_the_suncaller
# Use Beacon to the Beyond on cooldown except to hold for incoming adds or if already facing 5 or more targets
actions.trinkets+=/use_item,name=beacon_to_the_beyond,if=!raid_event.adds.exists|raid_event.adds.up|spell_targets.beacon_to_the_beyond>=5|boss&fight_remains<20
actions.trinkets+=/use_items,if=buff.voidform.up|buff.power_infusion.up|buff.dark_ascension.up|(cooldown.void_eruption.remains>10&trinket.cooldown.duration<=60)|boss&fight_remains<20
actions.trinkets+=/use_item,name=desperate_invokers_codex