[SOLVED] Antipodes level help :/ (python)

so ive got the clone part down pat, but im not sure what I need to write for the attack-the-warlock code? i know what i need to do but im not too sure how to do it. neither my hero nor my archers go and attack the warlock, and they just sit there and i run out of time

heres my code (that wont work):

# When all clones disappears, attack the warlock.
enemy = hero.findNearestEnemy()
if enemy:
    if enemy.type == "warlock":
        while enemy.health > 0:
            hero.command(friend, "attack", enemy)
            hero.attack(enemy)

@cheddarcheese i summon you, you’re super smart

  1. Not sure but it seems useful if you give us the rest of your code as well, it might seem ‘‘down’’ for you but can still contain problems. You can always delete it later/ask a mod to delete if you think it’s a possible spoiler for other people.
  2. Please define what ‘‘wont work’’ means here, does your hero refuse to do anything, does your hero die, there are various scenarios.
  3. In case your hero dies because the warlock is too strong (?), maybe see if there are other ways to attack him.

what you can do before this is wait a few seconds, around: 7 secs and i think it would work, that way, you can be sure that this code runs when all the clones are gone

The other part seems fine, you can delete it if you want.
I see you are trying to make your archers attack the warlock now, does this solve the level?

no, i was using the archers in the first place, i had just added my hero in the mix to see if that’d help but it didnt. and @Aya, im not sure what you mean by wait, i havent learned anything about using wait

Are all the archers attacking? Your code seems a bit incomplete

no, they’re not attacking and everyone just sits there. :confused:

Try commanding all of them. I’m not spoiling the code, but you should know from similar levels :slight_smile:

i thought that’s what i was doing? sorry im a little confused.

In your current code it seems to me like you are not commanding all your archers. There is only a line that states how an individual archer could attack, but none of them is attacking at all

friends = hero.findFriends()
for friend in friends:
    enemy = friend.findNearestEnemy()
    if enemy:
        if enemy.type == "warlock":
            while enemy.health > 0:
                hero.attack(enemy)
                hero.command(friend, "attack", enemy)

is this what you mean? because if so it doesnt work

Try putting the enemy = statement outside of the for loop. With hero. not friend.

nada :confused: (20 characters)

Try taking the hero.attack(enemy) statement out of the for loop. This might be causing the hero to focus on attacking and not on commanding

they still just stand there

Please post your latest code

sure.

friends = hero.findFriends()
enemy = hero.findNearestEnemy()
for friend in friends:
    if enemy:
        if enemy.type == "warlock":
            while enemy.health > 0:
                hero.command(friend, "attack", enemy)

Try putting this particular code you posted in a while loop. I am not sure if that makes a difference, but if it doesn’t, I have another suggestion

So about the wait, i dont recall a level where they teach it, but if you have a watch with hero.wait, you can use it this way: hero.wait(7) this would make it wait for 7 secs