# This shows how to define a function called cleaveWhenClose
# The function defines a parameter called `target`
def cleaveWhenClose(target):
enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
hero.cleave(enemy)
# else, just attack `target`!
else:
hero.attack(enemy)
# This code is not part of the function.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the `enemy` as `target`.
cleaveWhenClose("target")
Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!
This shows how to define a function called cleaveWhenClose
The function defines a parameter called target
def cleaveWhenClose(target):
pass
# Put your attack code here
hero.attack(“target”)
ready = hero.isReady(“cleave”)
# If cleave is ready, then cleave target
# else, just attack `target`!
hero.attack("target")
This code is not part of the function.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the enemy as target.
cleaveWhenClose(“target”)