The Storm Siege Topic

Thanks a lot i’ll see if that works! :grin:

1 Like

Ok for some reason it just says it runs but accually does nothing.

1 Like

Is your code indented the way it is in your post? In that case you have two functions inside one another and that might be it. Also, the hero.findEnemies() will also find the enemy hero and enemy towers so be careful.

1 Like

Ok thanks. I’ll try to get that fixed up.

1 Like

Now it cant read the property of strongest.
image

if strongest.health >= 310:
    hero.cast("lightning", strongest.x, strongest.y)
    
1 Like

It isn’t finding an enemy for some reason; can you post a screenshot of the battlefield? There might just not be any enemies on the screen

1 Like

1 Like

Did you move the findStrongestEnemy(enemies) to a seperate function? If so, I don’t see why this wouldn’t work.

1 Like

Nope its the same.

def findStrongestEnemy(enemies):
    strongest = None
    strongestHealth = 0
    enemyIndex = 0
    # While enemyIndex is less than the length of enemies:
    while enemyIndex < len(enemies):
        
        # Set an enemy variable to enemies[enemyIndex]
        en = enemies[enemyIndex]
        # If enemy.health is greater than strongestHealth
        if en.health > strongestHealth:
            # Set `strongest` to enemy
            strongest = en
            # Set strongestHealth to enemy.health
            strongestHealth = en.health
        # Increment enemyIndex
        enemyIndex += 1
return strongest

1 Like

So you are calling the findStrongestEnemy(enemies) function inside the lightning() function and using the result to cast lightning on the strongest enemy?
Where are you using findStrongestEnemy(enemies)? I think that’s the part that is causing the error.

1 Like

I took out the def lightning(): so that there wont be two functions inside of one another.

1 Like

Inside a while true loop.

1 Like

Oh so you are calling findStrongestEnemy(enemies) inside the loop and using the value to use the spell.
Can I see where you use it?

1 Like
while True:
    summongroupB()
    if strongest.health >= 310:
        hero.cast("lightning", strongest.x, strongest.y)
    summongroupD()
    summongroupC()
    
1 Like

You need to set the variable inside the while true loop using the function, it won’t run the function otherwise.
E.g. adding strongest = findStrongestEnemy(hero.findEnemies())

1 Like

Oh ok thanks. :+1: :+1: :+1:

2 Likes

I gtg now thanks for the help ill get back to you to see if it works later.

2 Likes

Bro archers are totally dominating the leaderboard.

1 Like

Hey don’t discount brawlers; they exist as well.
my outdated strategy (still heals towers and hero, but I’m too lazy to update it atm) used brawlers pretty well. (At least I’d like to think so.)

1 Like

During the begining of the arena it was mostly brawlers and catapults. I just spawned them nonstop.

1 Like