#name custom_heathendel_tehuti
#speed 6

; 227 : Assault 30
; 291 : Bash 30
; 330 : Enfeebling Blow 30  [Cooldown=StopMightRegen]
; 213 : Whiplash 40  [Cooldown=MeleeSpeedDebuff]
; 508 : Nefritari's Aura 30  [Cooldown=DoT]
; 491 : Wither 30
; 532 : Deathly Dart 30  [Cooldown=DeathlyDart]
; 389 : Life Leech 30  [Cooldown=HealthLeech]
; 400 : Theft of Might 50  [Cooldown=Theft]
; 32766 : Melee autoattack

set VAR 0
set COOLDOWN 0


:begin

; If we can't use skills, go back.
is_busy VAR
if VAR = 1
  goto begin
endif

call waitfortarget
call checkWillCharge
call checkMightCharge
call checkWill
call checkMight
goto begin




:checkWillCharge

getwillcharge VAR
if VAR <= 2
  return
endif
getcooldown "HealthLeech" COOLDOWN
if COOLDOWN != 0
  return
endif

use 389
reset_goto begin
;; return



:checkMightCharge
getmightcharge VAR
if VAR >= 2
  use 291
  reset_goto begin
endif
return



:checkWill
getwill VAR
if VAR < 3
  return
endif

call tryDeathlyDart
call tryNefritarisAura

use 491
reset_goto begin
;; return



:checkMight
call tryEnfeeblingBlow
call tryWhiplash
call tryTheftOfMight
getmight VAR
if VAR >= 3
  use 227
  reset_goto begin
endif
return



:tryEnfeeblingBlow
getmight VAR
if VAR < 5
  return
endif
getcooldown "StopMightRegen" COOLDOWN
if COOLDOWN != 0
  return
endif

use 330
reset_goto begin
;; return




:tryWhiplash
getmight VAR
if VAR < 3
  return
endif
getcooldown "MeleeSpeedDebuff" COOLDOWN
if COOLDOWN != 0
  return
endif

use 213
reset_goto begin
;; return




:tryTheftOfMight
getmight VAR
if VAR < 2
  return
endif
getcooldown "Theft" COOLDOWN
if COOLDOWN != 0
  return
endif

get_target_property "might_charges" VAR
if VAR < 2
  return
endif

use 400
reset_goto begin
;; return



:tryDeathlyDart
getwill VAR
if VAR < 3
  return
endif
getcooldown "DeathlyDart" COOLDOWN
if COOLDOWN != 0
  return
endif
use 532
reset_goto begin
;; return



:tryNefritarisAura
getwill VAR
if VAR < 3
  return
endif
getcooldown "DoT" COOLDOWN
if COOLDOWN != 0
  return
endif

count_enemy_near 150 VAR
if VAR <= 1
  return
endif

use 508
reset_goto begin
;; return



 


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

use 32766
return