Return to the Thornbush

my hero is puting the traps at the enemy position

# The function maybeBuildTrap defines TWO parameters!
def maybeBuildTrap(x, y):
    # Use x and y as the coordinates to move to.
    hero.moveXY(x, y)
    enemy = hero.findNearestEnemy()
    if enemy:
        # Use buildXY to build a "fire-trap" at the given x and y.
        hero.buildXY("fire-trap", enemy.pos.x, enemy.pos.y)

while True:
    # This calls maybeBuildTrap, with the coordinates of the top entrance.
    maybeBuildTrap(43, 50)
    
    # Now use maybeBuildTrap at the left entrance!
    maybeBuildTrap(25, 34)
    # Now use maybeBuildTrap at the bottom entrance!
    maybeBuildTrap(43, 20)
    

Try to do x, y instead of enemy.pos.x, enemy.pos.y. That should do the trick

2 Likes

ok thanks i will try that

it worked thanks man

2 Likes

Your welcome mark a checkmark next to whichever post helped you solve this.

@logan_jordan whenever someone helps you solve the problem with your code(@milton.jinich in this situation), please mark a checkmark next to to the post that helped you the most, because he was the one that helped you solve your problem. Thanks!
-Grzmot

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.