Thanks a lot i’ll see if that works!
Ok for some reason it just says it runs but accually does nothing.
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.
Ok thanks. I’ll try to get that fixed up.
Now it cant read the property of strongest.
if strongest.health >= 310:
hero.cast("lightning", strongest.x, strongest.y)
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
Did you move the findStrongestEnemy(enemies) to a seperate function? If so, I don’t see why this wouldn’t work.
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
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.
I took out the def lightning():
so that there wont be two functions inside of one another.
Inside a while true loop.
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?
while True:
summongroupB()
if strongest.health >= 310:
hero.cast("lightning", strongest.x, strongest.y)
summongroupD()
summongroupC()
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())
Oh ok thanks.
I gtg now thanks for the help ill get back to you to see if it works later.
Bro archers are totally dominating the leaderboard.
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.)
During the begining of the arena it was mostly brawlers and catapults. I just spawned them nonstop.