# Executed before combat begins. Accepts non-harmful actions only.
actions.precombat=snapshot_stats
actions.precombat+=/summon_pet,if=talent.unbreakable_bond
actions.precombat+=/use_item,name=algethar_puzzle_box
actions.precombat+=/aimed_shot

# Executed every time the actor is available.
actions=variable,name=trueshot_ready,value=!talent.bullseye|(fight_remains>cooldown.trueshot.duration+10|buff.bullseye.stack=buff.bullseye.max_stack|target.time_to_pct_20>60)&(cooldown.explosive_shot.remains>=15|cooldown.explosive_shot.ready)|fight_remains<25|time<10
# For DungeonRoute, hold Trueshot at the end of pulls.
actions+=/variable,name=trueshot_ready,op=setif,condition=fight_style.dungeonroute,value_else=variable.trueshot_ready,value=raid_event.pull.remains>20|raid_event.pull.in>45|talent.calling_the_shots

actions+=/retarget,target_if=max:target.health,line_cd=5,if=fight_style.dungeonroute
actions+=/auto_shot
actions+=/call_action_list,name=cds
actions+=/call_action_list,name=trinkets
actions+=/call_action_list,name=draoe,if=active_enemies>2&talent.trick_shots&hero_tree.dark_ranger
actions+=/call_action_list,name=sentaoe,if=active_enemies>2&talent.trick_shots&hero_tree.sentinel
actions+=/call_action_list,name=drst,if=hero_tree.dark_ranger
actions+=/call_action_list,name=sentst,if=hero_tree.sentinel

actions.cds=invoke_external_buff,name=power_infusion,if=buff.trueshot.remains>12|fight_remains<13
actions.cds+=/berserking,if=buff.trueshot.up|fight_remains<13
actions.cds+=/blood_fury,if=buff.trueshot.up|cooldown.trueshot.remains>30|fight_remains<16
actions.cds+=/ancestral_call,if=buff.trueshot.up|cooldown.trueshot.remains>30|fight_remains<16
actions.cds+=/fireblood,if=buff.trueshot.up|cooldown.trueshot.remains>30|fight_remains<9
actions.cds+=/lights_judgment,if=buff.trueshot.down
actions.cds+=/potion,if=buff.trueshot.up&(buff.bloodlust.up|fight_remains<120-30*talent.calling_the_shots)|fight_remains<31
# Potion of Recklessness (Crit) has little to no value for execute Trueshots as we are crit hard-capped, so use Luster instead. Luster 7s before Trueshot allows for Font to be used in the last 3s of Luster (since the on-use trinket popped with Trueshot puts Font on a 20s CD).
actions.cds+=/potion,name=liquid_luster_2,if=potion.potion_of_recklessness&buff.bullseye.up&cooldown.trueshot.remains<7&(fight_style.dungeonroute|cooldown.explosive_shot.remains>=25|cooldown.explosive_shot.remains<10)|fight_remains<31

actions.drst=black_arrow,if=buff.precise_shots.up
actions.drst+=/explosive_shot,target_if=min:dot.explosive_shot.remains,if=set_bonus.mid2_4pc&active_enemies>1&!fight_style.dungeonroute&(!talent.tactical_reload|!buff.lock_and_load.up)
# In DRoute, prioritize Rapid Fire over Explosive Shot to maximize the RF CDR from Explo.
actions.drst+=/explosive_shot,if=(!talent.tactical_reload|!buff.lock_and_load.up)&(!cooldown.rapid_fire.ready|!fight_style.dungeonroute)
actions.drst+=/volley
actions.drst+=/aimed_shot,if=buff.trueshot.up&buff.precise_shots.down&cooldown.black_arrow.ready|full_recharge_time<gcd+cast_time
actions.drst+=/trueshot,if=variable.trueshot_ready
actions.drst+=/rapid_fire
actions.drst+=/wailing_arrow
# Multi-Shot as a PS spender on 2T with Hydra talented. In DRoute, do it on 3 or more targets.
actions.drst+=/multishot,target_if=max:debuff.spotters_mark.down,if=buff.precise_shots.up&active_enemies>1&talent.aspect_of_the_hydra&(!fight_style.dungeonroute|active_enemies>2)
actions.drst+=/arcane_shot,if=buff.precise_shots.up
actions.drst+=/aimed_shot
actions.drst+=/black_arrow
actions.drst+=/steady_shot

actions.draoe=explosive_shot,target_if=min:dot.explosive_shot.remains,if=set_bonus.mid2_4pc&!fight_style.dungeonroute&(!talent.tactical_reload|!buff.lock_and_load.up)
# In DRoute, prioritize Rapid Fire over Explosive Shot to maximize the RF CDR from Explo.
actions.draoe+=/explosive_shot,if=(!talent.tactical_reload|!buff.lock_and_load.up)&(!cooldown.rapid_fire.ready|!fight_style.dungeonroute)
actions.draoe+=/volley
actions.draoe+=/aimed_shot,if=buff.trick_shots.remains>cast_time&full_recharge_time<gcd+cast_time
actions.draoe+=/black_arrow,if=buff.precise_shots.up
actions.draoe+=/multishot,if=buff.trick_shots.down
actions.draoe+=/trueshot,if=variable.trueshot_ready
actions.draoe+=/rapid_fire,if=buff.trick_shots.remains>execute_time
actions.draoe+=/wailing_arrow,if=!cooldown.black_arrow.ready
actions.draoe+=/multishot,if=buff.precise_shots.up
actions.draoe+=/aimed_shot,if=buff.trick_shots.remains>cast_time
actions.draoe+=/black_arrow
actions.draoe+=/multishot,if=focus>cost+action.aimed_shot.cost
actions.draoe+=/steady_shot

actions.sentaoe=explosive_shot,target_if=min:dot.explosive_shot.remains,if=set_bonus.mid2_4pc&!fight_style.dungeonroute&(!talent.tactical_reload|!buff.lock_and_load.up)
# In DRoute, prioritize Rapid Fire over Explosive Shot to maximize the RF CDR from Explo.
actions.sentaoe+=/explosive_shot,if=(!talent.tactical_reload|!buff.lock_and_load.up)&(!cooldown.rapid_fire.ready|!fight_style.dungeonroute)
actions.sentaoe+=/volley
actions.sentaoe+=/trueshot,if=variable.trueshot_ready
actions.sentaoe+=/moonlight_chakram,if=buff.moonlight_chakram.remains<gcd.max
actions.sentaoe+=/multishot,target_if=max:debuff.sentinels_mark.down,if=buff.precise_shots.up&!talent.aspect_of_the_hydra|buff.trick_shots.down
actions.sentaoe+=/aimed_shot,target_if=max:debuff.sentinels_mark.up,if=debuff.sentinels_mark.react&buff.bulletstorm.up
actions.sentaoe+=/rapid_fire
actions.sentaoe+=/aimed_shot,target_if=max:debuff.sentinels_mark.up,if=buff.trick_shots.remains>cast_time
actions.sentaoe+=/moonlight_chakram
actions.sentaoe+=/multishot,if=focus>cost+action.aimed_shot.cost
actions.sentaoe+=/steady_shot

actions.sentst=explosive_shot,target_if=min:dot.explosive_shot.remains,if=set_bonus.mid2_4pc&active_enemies>1&!fight_style.dungeonroute&(!talent.tactical_reload|!buff.lock_and_load.up)
# In DRoute, prioritize Rapid Fire over Explosive Shot to maximize the RF CDR from Explo.
actions.sentst+=/explosive_shot,if=(!talent.tactical_reload|!buff.lock_and_load.up)&(!cooldown.rapid_fire.ready|!fight_style.dungeonroute)
actions.sentst+=/volley
actions.sentst+=/trueshot,if=variable.trueshot_ready
actions.sentst+=/moonlight_chakram,if=buff.moonlight_chakram.remains<5
actions.sentst+=/aimed_shot,if=debuff.sentinels_mark.react&buff.bulletstorm.up&active_enemies>1&fight_style.dungeonroute
actions.sentst+=/aimed_shot,if=buff.trueshot.up&buff.precise_shots.down&active_enemies=1
actions.sentst+=/rapid_fire,if=buff.precise_shots.down|buff.trueshot.up|active_enemies>1&talent.aspect_of_the_hydra|!talent.no_scope
actions.sentst+=/kill_shot,if=buff.precise_shots.up
# Multi-Shot as a PS spender on 2T with Hydra talented. In DRoute, do it on 3 or more targets.
actions.sentst+=/multishot,target_if=max:debuff.sentinels_mark.down,if=buff.precise_shots.up&active_enemies>1&talent.aspect_of_the_hydra&(!fight_style.dungeonroute|active_enemies>2)
actions.sentst+=/arcane_shot,if=buff.precise_shots.up
actions.sentst+=/aimed_shot,target_if=max:debuff.sentinels_mark.up
actions.sentst+=/moonlight_chakram
actions.sentst+=/steady_shot

# A buff trinket that lines up cleanly with Trueshot; use with Trueshot.
actions.trinkets=use_items,check_existing=0,slots=trinket1:trinket2,if=this_trinket.has_use_buff&this_trinket.cooldown.duration%%cooldown.trueshot.duration=0&(buff.trueshot.remains>14|this_trinket.is.algethar_puzzle_box&variable.trueshot_ready&cooldown.trueshot.remains<5)

# A buff trinket paired with a trinket that matches the above line; use with Trueshot if the other trinket is not ready or use without Trueshot if the other trinket will come up for the next Trueshot.
actions.trinkets+=/use_items,check_existing=0,slots=trinket1:trinket2,if=this_trinket.has_use_buff&other_trinket.has_use_buff&other_trinket.cooldown.duration%%cooldown.trueshot.duration=0&(buff.trueshot.remains>14&other_trinket.cooldown.remains|cooldown.trueshot.remains>20&other_trinket.cooldown.remains<=cooldown.trueshot.remains)

# A buff trinket, use with Trueshot or in the last ~20 seconds of the fight.
actions.trinkets+=/use_items,check_existing=0,slots=trinket1:trinket2,if=this_trinket.has_use_buff&(buff.trueshot.remains>14|buff.trueshot.up&fight_remains<cooldown.trueshot.remains+15|fight_remains<21)

# A damage trinket; use when Trueshot has at least 20 seconds remaining on its cooldown.
actions.trinkets+=/use_items,check_existing=0,slots=trinket1:trinket2,if=this_trinket.has_use_damage&cooldown.trueshot.remains>20
