@Main:
SetVar(%EatAt,0)
SetVar(%Moves,0)
Goto(@Move)

@Move:
AddVarNum(%Moves,1)
SetVarHP(%MyHP)
GotoIfVarAbove(@Eat,%MyHP,%EatAt)
SetVarsLastAttackedPlayer(%X,%Y,%ID)
MoveToNoWaitVarVar(%X,%Y)
Sleep(450)
GotoIfVarEquals(@Attack,%Moves,5)
Goto(@Move)

@Attack:
ResetLastServerMessage()
AttackPlayer(%ID)
Sleep(50)
AttackPlayer(%ID)
GotoIfLastServerMessageIs(@Stop,'You have defeated')
GotoIfPlayerInCombat(@Wait)
Goto(@Attack)

@Stop:
Stop()

@Wait:
Sleep(1)
GotoIfPlayerNotInCombat(@Main)
Goto(@Wait)

@Eat:
UseItemByID(373)
Goto(@Move)