Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

I need help with Village Warder

#1

def findAndAttackEnemy():
enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()

hero.attack(enemy)

def findAndCleaveEnemy():
# Define a function to cleave enemies (but only when the ability is ready).
if enemy:
hero.attack(enemy)
enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()

hero.cleave(enemy)
pass

while True:
# Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34)
findAndCleaveEnemy()
findAndAttackEnemy()

hero.moveXY(60, 31)
findAndCleaveEnemy()
findAndAttackEnemy()

#2

you need to put

if hero.isReady("cleave"):
    cleave

somewhere in

def findAndCleaveEnemy():
    # Define a function to cleave enemies (but only when the ability is ready).
    if enemy:
        hero.attack(enemy)
    enemy = hero.findNearestEnemy()
    enemy = hero.findNearestEnemy()

    hero.cleave(enemy)
    pass

also, you don’t need to repeat enemy = hero.findNearestEnemy() twice every time

#3

Also in the future, please format you code according to the FAQ.

#4

def findAndAttackEnemy():
enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()

hero.attack(enemy)

def findAndCleaveEnemy():
# Define a function to cleave enemies (but only when the ability is ready).
ready = hero.isReady(“cleave”)
hero.attack(enemy)
ready = hero.isReady(“cleave”)

enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.cleave(enemy)

while True:
# Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34)
findAndCleaveEnemy()
findAndAttackEnemy()

hero.moveXY(60, 31)
findAndCleaveEnemy()
findAndAttackEnemy()

It says it is wrong, but what do I need to fix?

#5

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly

1 Like