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

[SOLVED] Taunting Level Help

I need help with taunting because my character keeps running into the explosive traps and it keeps doing it repeatedly so I am stuck.

def dealEnemy(enemy):
# If enemy.type is “munchkin”:
    if enemy.type == “munchkin”:
# Then attack it:
hero.attack(enemy)
# If the enemy’s type is “brawler”:
     if enemy.type == “brawler”:
# Then say something to call the brawler:
hero.say(“I dont think so brawler”)
pass
    while True:
        enemy = hero.findNearestEnemy()
    if enemy:
      dealEnemy(enemy)
    else:
        hero.moveXY(30, 34)`

1 Like

I can help you now, but please do not create 1000 topics from level helps that are back to back, thanks.

Mumbo_6

I dont think you should define „dealEnemy“.
You should just do:

While True:
    Enemy = hero.findNearestEnemy
    If enemy and enemy.type == munchkin:
........

You know the rest :smile:

Mumbo_6

The next „else“ to the „if„ should be: elif enemy.type == brawler
elif stands for else-if

Mumbo_6

Okay but now he does not attack anything even though I put hero.attack(enemy).

What’s your code updated?

Mumbo_6

while True:
    if enemy and enemy.type == munchkin:
        enemy = hero.findNearestEnemy()
    # If enemy.type is “munchkin”:
    # Then attack it:
    hero.isReady("cleave")
    hero.cleave(enemy)
    # If the enemy’s type is “brawler”:
    else: 
        
        "enemy.type == “brawler”:"
    # Then say something to call the brawler:
    "hero.say(“I dont think so brawler”)"
pass

Now it keeps saying this

Ok, you have if enemy, but you should not put cleave. Also instead of „if“ you should put: Elif enemy and enemy.type == brawler

Mumbo_6

Where did you put this?

Mumbo_6

When I put hero.attack(enemy) my hero does not attack at all

Can you show me your updated code and a screenshot/quick movie of what’s going wrong?

Mumbo_6

while True:
    # If enemy.type is “munchkin”:
    if enemy and enemy.type == munchkin:
        enemy = hero.findNearestEnemy()
    # Then attack it:
    hero.isReady("cleave")
    hero.cleave(enemy)
    hero.attack(enemy)
    # If the enemy’s type is “brawler”:
    'enemy = hero.findNearestEnemy():'
    '(Elif enemy and enemy.type == brawler)'
    "enemy.type == “brawler”:"
    # Then say something to call the brawler:
    "hero.say(“I dont think so brawler”)"
pass

Indents, indents, indents… it’ll bug you every time. Indent 4 spaces by hero.attack enemy and delete the cleave thing.

Mumbo_6

Also, delete the ‘s

Mumbo_6

And dont put the elif statement in brackets. Delete the findNearestEnemy above the elif aswell, as you defined this at the top of your code

Mumbo_6

It still does not work and btw I am using python so it’s not recognizing it.

Updated code please. Every time you change your code you should send the updated version.

Mumbo_6

while True:
    # If enemy.type is “munchkin”:
    if enemy and enemy.type == munchkin:
        enemy = hero.findNearestEnemy()
        # Then attack it:
        hero.attack(enemy)
        # If the enemy’s type is “brawler”:
        '(Elif enemy and enemy.type == brawler)'
        if enemy and enemy.type == brawler:
            # Then say something to call the brawler"
            hero.say("I don't think so brawler")
pass

When I ran it, it said ran out of time.

Here delete the apostrophes and the brackets.

Mumbo_6