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

[SOLVED] Oasis, Desert, Python

I’m using Hattori with 856 health. My code is below…

while True:
    enemy = hero.findNearestEnemy()
    if enemy and hero.distanceTo(enemy) < 10:
        x = hero.pos.x - 10
        y = hero.pos.y
        x = hero.pos.x + 10
        y = hero.pos.y
    hero.moveXY(x, y)

At the end, my hero can’t properly dodge the Sand Yak.


I have used the same code above, and am left with -25 health.


You are taking a snapshot view of the hero’s x and y…this is a dynamic, which constantly changes as the hero moves. Instead, try taking a static view.

Your hero.pos.y is not going to change, so there is no need to redefine it after the first time. Instead, try something like this:

while True

define x
define y
if enemy and distance is less than 10, then
    redefine x, decrementing it by 10
    redefine x, incrementing it by 10

The reason was actually because I wasn’t wearing fast enough boots, but thanks for the help!

1 Like

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