Help with Salted Earth (with personal goal)[SOLVED]

Hello all, I have an issue trying to do something that is not necessary at this level, but I would like to accomplish it anyway.

That is to do the same objectives but also beating the burl.

The problem is that I made a code to beat the burl but when I run it, the normal code to beat the level stops working normally, it does what is supposed to do for some seconds and then it just stops.

Could you help me pass this in my own personal difficulty? :smiley:

Here are some screenshots about the level/code/inventory:

# Ogres are attacking a nearby settlement!
# Be careful, though, for the ogres have sown the ground with poison.
# Gather coins and defeat the ogres, but avoid the burls and poison!

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
        hero.attack(enemy)
    if enemy.type == "burl":
        enemyPosition = enemy.pos
        if hero.isReady("shadow-vortex"):
            hero.shadowVortex(enemy.pos, [43, 13])
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.moveXY(52, 25)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.moveXY(22, 20)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.moveXY(6, 7)
            hero.attack(enemy)
            hero.attack(enemy)
            hero.attack(enemy)
    item = hero.findNearestItem()
    if item:
        itemPosition = item.pos
        itemX = itemPosition.x
        itemY = itemPosition.y
    # Check the item type to make sure the hero doesn't pick up poison!
    # If the item's type is "gem" or "coin":
    if item.type == "gem" or item.type == "coin":
        # Then move and pick it up:
        hero.moveXY(itemX, itemY)


                         Thank you all and happy new year!

You only need one attack

And I tend to find that using not poison works better. Instead of gem or coin.

When I input one attack per location vs the burl what happens is that it just attacks once an then move to the next location and that is not effective. With my current weapon I need to attack him 20 times if I want to kill him, so I need to kite the maximun possible times between the locations so I avoid being killed by him.

I will try this, but the errors seem to come with the enemy.type code

your shadow vortex positions are wrong

if you want to do a certain cordinate you have to do

hero.shadowVortex(hero.pos, {"x": 54, "y": 3})

also check if there’s a enemy with

if enemy:
1 Like
  1. Delete the if enemy.type == ‘burl’ and everything inside it.
  2. you want to check if there’s enemy when you are attacking. if enemy.type == "munchkin" or enemy.type == "thrower": is not enough. It only checks enemy’s type and not existence.
  3. Combine
    item = hero.findNearestItem()
    if item:
        itemPosition = item.pos
        itemX = itemPosition.x
        itemY = itemPosition.y

and

if item.type == "gem" or item.type == "coin":
        # Then move and pick it up:
        hero.moveXY(itemX, itemY)

This is the solution, thank you, it made my code work

And about the vortex, it made the vortex get an error, sorry :frowning:

Hello, Code Master, I understand that what you are trying to tell me to do is the original objective of the level, but I told that I also wanted to beat the burl :frowning:

But I can say that what you said about that I need to check if there is an enemy is indeed what I was lacking in my code in order to beat the burl and the level, so thank you!

Sorry, didn’t see your text about also killing the burl.

1 Like

NP :slight_smile:

“20 characters or more to approve this answer”

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