#name custom_heathendel_knightrogue40p
#speed 6
#queue_jumps call

; 228 : Assault 40
; 446 : Bash 40
; 448 : Taurian Might 40   [GroupID=44]
; 5063 : Taurian Might (15%)  [GroupID=44]
; 344 : Thor's Mighty Blow 50  [Cooldown=ThorsMightyBlow]
; 342 - Earthshaker : 50  [Might=4]
; 282 : Pierce 40  [Cooldown=Pierce]
; 32766 : Melee autoattack


set VAR 0
set COOLDOWN 0
set MIGHT 0
set USETHOR 0


:begin
call waitfortarget
call checkMightCharge
call checkMight
goto begin




; NOTE: Thor's Mighty Blow is set to use at 3 charges.  If it can't be used, it'll spam 1
; charge bash instead.

:checkMightCharge
getmightcharge VAR
if VAR < 1
  return
endif

call tryThorsMightyBlow

if USETHOR = 0
  use 446
  reset_goto begin
endif
return



:checkMight
getmight MIGHT
if MIGHT < 3
  return
endif

call tryEarthshaker
call tryPierce

use 228
reset_goto begin




:castBuffs
get_buff_tier 44 VAR
if VAR = 0
  use 5063
endif
return


:tryMelee
use 32766
return


:tryEarthshaker
getcooldown "Earthshaker" var
if var != 0
  return
endif
count_enemy_near 50 TCOUNT
if TCOUNT < 2
  return
endif

; Easy way to wait for more might to regenerate
; Exit the call as if the skill was casted, preventing other skills
; further in the cycle from being used.
if MIGHT < 4
  wait 500
  reset_goto begin
endif

use 342
reset_goto begin



:tryPierce
getcooldown "Pierce" COOLDOWN
if COOLDOWN != 0
  return
endif

use 282
reset_goto begin



:tryThorsMightyBlow
getcooldown "ThorsMightyBlow" COOLDOWN
if COOLDOWN != 0
  set USETHOR 0
  return
endif

set USETHOR 1

getmightcharge VAR
if VAR < 3
  return
endif

use 344
reset_goto begin




:waitfortarget
has_target VAR
if VAR = 0
  wait 1000
  goto waitfortarget
endif

call castBuffs
use 32766
return