yeah. (20 chars suck)
how do i indent???
press tab (what idiot mad 20 chars)
press tab (or four spaces)
Anyways, I made a mistake (you could put everything in a while true loop, but not the enemyIndex = 0
)
oops, I meant
While enemy.health > 0:
hero.attack(enemy)
enemyIndex += 1
ohhh wait 1 sec (i hate 20 char rule)
oh (i hate 20 char rule)
# findEnemies returns a list of all your enemies.
# Only attack shamans. Don't attack yaks!
enemies = hero.findEnemies()
enemyIndex = 0
# Wrap this section in a while loop to iterate all enemies.
# While the enemyIndex is less than the length of enemies
while enemy < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
enemyIndex += 1
# Remember to increment enemyIndex
i has the arrow under the reminder
it* (i hate 20 char rule)
Perfect!
(Though an easier strat would’ve been this:)
while true:
enemy = hero.findNearestEnemy()
if enemy.type == 'shaman':
hero.attack(enemy)
or
while true:
enemy = hero.findNearestByType('shaman')
if enemy:
hero.attack(enemy)
i just followed with the code
stilllllllll doesnt workk
Hmmmm…
Try this:
while true:
enemy = hero.findNearestByType('shaman')
if enemy:
hero.attack(enemy)
(It might be `hero.findByType(‘shaman’, hero.findEnemies())
I went back to the level, and this is the code that works:
while True:
enemy = hero.findByType('shaman',hero.findEnemies())
if enemy:
hero.attack(enemy[0])
You need the index (or the [0] and 0 is the first in a array) to attack
Also, you probably would need good glasses for this to work.
Perfect!
(I was using enchanted lenses for this too)
Tell me when it works (I gtg soon)