#name custom_heathendel_deathknight40b
#speed 6
#queue_jumps call

; 228 : Assault 40
; 446 : Bash 40
; 539 : Concussion 40   [Cooldown=Concussion]
; 448 : Taurian Might 40   [GroupID=44]     NotStatus(IN_COMBAT)
; 5063 : Taurian Might (15%)  [GroupID=44]
; 213 : Whiplash 40  [Cooldown=MeleeSpeedDebuff]
; 346 : Disarm 40   [Cooldown=Disarm]
; 488 : Soul Needles 40
; 492 : Wither 40   [Group=112]
; 373 : Malice Blast : 40
; 32766 : Melee autoattack

set VAR 0
set WILL 0
set MIGHT 0
set COOLDOWN 0


:begin
call waitfortarget

is_busy var
if var = 1
  goto begin
endif

call checkMightCharge
call checkWillCharge
call checkMight
call checkWill
goto begin


:checkWillCharge
getwillcharge VAR
if VAR < 3
  return
endif

use 373
reset_goto begin



:checkWill
getwill WILL
if WILL < 3
  return
endif

call tryWither

use 488
reset_goto begin


:tryMelee
	use 32766
	return

:tryWither
if WILL < 4
  return
endif

get_target_buff_tier 112 VAR
if VAR != 0
  return
endif

use 492
reset_goto begin




:checkMightCharge
getmightcharge VAR
if VAR < 1
  return
endif

use 446
reset_goto begin



:checkMight
getmight MIGHT
if MIGHT < 3
  return
endif

call tryConcussion
call tryWhiplash
call tryDisarm

use 228
reset_goto begin



:tryConcussion
getcooldown "Concussion" COOLDOWN
if COOLDOWN != 0
  return
endif

use 539
reset_goto begin



:tryWhiplash
getcooldown "MeleeSpeedDebuff" COOLDOWN
if COOLDOWN != 0
  return
endif

use 213
reset_goto begin



:tryDisarm
getcooldown "Disarm" COOLDOWN
if COOLDOWN != 0
  return
endif

use 346
reset_goto begin



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



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

get_target TARGID
if TARGID != OLDTARGID
  get_target OLDTARGID
  set ALLOWROOT 1
endif 

call castBuffs
use 32766
return