Again, it’s fine as long as it is in the same topic
Please read this topics before posting your code, it requires little effort.
Here is my code, my hero dies every time.
self.moveXY(68, 78)
back = 0
while True:
enemys = self.findEnemies()
index = 0
closest_soldier = None
soldier_dist = 999
closest_archer = None
archer_dist = 999
closest = None
dist = 999
while(index<len(enemys)):
distance = self.distanceTo(enemys[index])
if(enemys[index].health>0 and enemys[index].type != "sand-yak" ):
if(enemys[index].type == 'archer' and distance<archer_dist):
archer_dist=distance
closest_archer = enemys[index]
if(enemys[index].type == 'soldier' and distance<soldier_dist):
soldier_dist=distance
closest_soldier = enemys[index]
if(distance<dist):
soldier_dist=dist
closest = enemys[index]
index +=1
if(closest_soldier and soldier_dist<10):
enemy = closest_soldier
elif(closest_archer and archer_dist<20):
enemy = closest_archer
else:
enemy = closest
if(enemy):
if(self.health<self.maxHealth/2.5 and back==0):
self.moveXY(40, 85)
back = 1
elif(self.health<self.maxHealth/5 and back==1):
self.moveXY(40, 85)
back = 2
elif(self.isReady("electrocute")):
self.electrocute(enemy)
elif(self.isReady("bash")):
self.bash(enemy)
elif(self.isReady("power-up")):
self.powerUp()
self.attack(enemy)
elif(self.isReady("cleave")):
self.cleave(enemy)
else:
self.attack(enemy)
HP:900
Damage:6 (bash=74.5)
(have electrocute)
i only posted on here because i dont know how to make my own.
Please try to write your own. Because you won’t learn anything if ou don’t write it. Hint: try to cleave near enemy archers.
I meant to say my own question, also, I cant cleave
You have to have a sword that can cleave like long sword
Ok, ill try that out.
It didn’t work, my hero did cleave when there were no enemies around. @milton.jinich
Show me your updated code
ok.
self.moveXY(68, 78)
back = 0
while True:
enemys = self.findEnemies()
index = 0
closest_soldier = None
soldier_dist = 999
closest_archer = None
archer_dist = 999
closest = None
dist = 999
while(index<len(enemys)):
distance = self.distanceTo(enemys[index])
if(enemys[index].health>0 and enemys[index].type != "sand-yak" ):
if(enemys[index].type == 'archer' and distance<archer_dist):
archer_dist=distance
closest_archer = enemys[index]
if(enemys[index].type == 'soldier' and distance<soldier_dist):
soldier_dist=distance
closest_soldier = enemys[index]
if(distance<dist):
soldier_dist=dist
closest = enemys[index]
index +=1
if(closest_soldier and soldier_dist<10):
enemy = closest_soldier
elif(closest_archer and archer_dist<20):
enemy = closest_archer
else:
enemy = closest
if(enemy):
if(self.health<self.maxHealth/2.5 and back==0):
self.moveXY(40, 85)
back = 1
elif(self.health<self.maxHealth/5 and back==1):
self.moveXY(40, 85)
back = 2
elif(self.isReady("electrocute")):
self.electrocute(enemy)
elif(self.isReady("bash")):
self.bash(enemy)
elif(self.isReady("power-up")):
self.powerUp()
self.attack(enemy)
elif(self.isReady("cleave")):
self.cleave(enemy)
else:
self.attack(enemy)
Can you give me a screen shot of your equipment
try to electrecute a archer using
if hero.isReady("electrocute") and enemy.type != "soldier":
hero.castElectrocute("enemy")
else:
hero.attack(enemy)
um, electrocute doesn’t do any dmg. electrocute a soldier, as it slows it’s victims down.
Try to move near clone’s archers and cleave there.
Exactly it will slow the archer down making it harder to attack making your team do more damage and more of your soldier/archers survive and you win.
when i try to do this it says “elif must be paired with an if”
I thought it slowed move speed, not attack speed.
how do I do that? (20 Chars)
Use moveXY. 20 chars