you do not ask if there generally is an enemy. but i dont want to give you the right answer, because i want to find the solution on your own, because this is really importent!
jeah, thats the way you go. now if you want to, you can reuse your code from above and bash for example instead of just attacking but i think in this level its overrated
Hello, I have a problem with my code. My hero does not attack the office, I do not understand why ?
loop:
enemy = self.findNearest(self.findEnemies())
if enemy:
if enemy.type is "sand-yak":
pass
else:
if enemy.health>0:
if self.cast("chain-lightning", enemy):
self.cast("chain-lightning", enemy)
if self.isReady("bash"):
self.bash(enemy)
if self.canElectrocute(enemy):
self.electrocute(enemy)
else:
self.attack(enemy)
self.moveXY(63, 72)
I checked back at the code, and hero, my hero actually has 1471, and im guessing its the second round (the title has a small 1 next to it) and it says success, with 991 hp left & 1 enemy left too.
Hero:
Code:
while True:
enemy = hero.findNearestEnemy()
if enemy and enemy.type != “sand-yak”:
hero.attack(enemy)
else:
hero.shield()
Hopefully this answers your question! If not reply back to me and I will check for any errors that you find.
@Emblu056 I cant submit the run because it has not been a day yet, but here is my hero and code and i ran it twice and both times it said it was successful. Your hero does run into the wall a bunch of times, but the code works.
Hero:
Code:
while True:
enemies = self.findEnemies()
enemyIndex = 0
while enemyIndex < len(enemies):
Target = enemies[enemyIndex]
enemyIndex += 1
enemy = self.findNearestEnemy()
if enemy.type == “sand-yak”:
self.moveXY(self.pos.x -5, self.pos.y)
if enemy.type != “sand-yak”:
self.attack(enemy)
else:
self.attack(enemy)
@Mr_NotSoPerfect I tried both codes and they both didn’t work. Maybe you need to cleave. Try: self. cleave(enemy). If you have the sword. For the last code you gave me, the hero did nothing and just stood there.