I decided to see how far I could get in the brawls and for some reason if I don’t move back to a specific location after attacking my hero just won’t attack enemies after the first four or five. Should this be happening or is there a range of my weapon of 5-30m rather than just 30m and if that is correct then I would be glitching that too. I am using the rapid fire rifle.
This is roughly my code for most of the brawls on all the maps without having to use other abilities.
while True:
enemies = hero.findEnemies()
for enemy in enemies:
if enemy:
hero.attack(enemy)
hero.moveXY(x, y)
findNearestEnemy is searching only alive enemies. However, if enemy is dead after it had been found, then a variable can still contain a reference to the enemy object. It’s a normal practice in programming. It’s a good practice to “check” variables when your code is dynamical (like in CoCo) and running again and again.
I guess what I mean by “weird problem” is that sometimes attacking something that is dead will make your hero say, “but its dead” and then she continues on with the rest of the code.
However, some other times if her attack target is dead she will still say, “but its dead”, and then the code will hang on that line and she will just stand there being beaten to death.
I think I have only seen the second way in the repeatable levels.