Cursed Valley - Python


#1

hey guys… need help with my code- dunno wats wrong
while True:
enemy = hero.findNearestEnemy()
# Attack if enemy exists AND enemy.team is “ogres”
# AND enemy.type is "skeleton"
if enemy and enemy.team == “ogres” and enemy.type == “skeleton”:
hero.attack(enemy)

item = hero.findNearestItem()
# Collect if item exists AND item.type is "potion"
# AND hero.health is less than hero.maxHealth / 4
if item and item.type =="potion" and hero.health =="hero.maxHealth" / 4:
    hero.moveXY(item.posx, item.pos.y)

my hero stops moving after killing the first skeleton


#2
if item and item.type =="potion" and hero.health =="hero.maxHealth" / 4:
    hero.moveXY(item.posx, item.pos.y)

is your problem
I would try removing quotes from hero.maxHealth
also should be item.pos.x


#3

im sorry…i was still not able to finish it

here is my code

item = hero.findNearestItem()
# Collect if item exists AND item.type is “potion”
# AND hero.health is less than hero.maxHealth / 4
if item and item.type ==“potion” and hero.health == hero.maxHealth / 4:
hero.moveXY(item.pos.x, item.pos.y)