while True:
flag = hero.findFlag()
enemy = hero.findNearestEnemy()
if flag:
# Pick up the flag.
hero.pickUpFlag(flag)
hero.say("I should pick up the flag.")
elif enemy:
# Only attack if the enemy distance is < 10 meters
if self.distanceTo(enemy) < 10:
hero.attack(enemy)
please Help!
# Ты должен убедиться, что ты атакуешь врагов, которые находятся рядом с тобой!
while True:
flag = hero.findFlag()
enemy = hero.findNearestEnemy()
if flag:
# Возьми флаг.
hero.pickUpFlag(flag)
#hero.say("Я должен взять флаг.")
hero.say("Я должен взять флаг.")
elif enemy:
# Атакуй врага, если он находится на расстоянии < 10 метров
if (hero.distanceTo(enemy)< 10):
if hero.isReady("cleave"):
hero.cleave(enemy)
This line should not have parenthesis around the entire method.
Эта строка не должна иметь круглых скобок вокруг всего метода.
It should be:
Должен быть
Hi hehe, sorry for the late reply.
The only problem I see in your code is
hero.cleave() only has one parameter (thing in the bracket), if you get rid of “enemy” and the comma it will work.
I did it with your code (with that change) and you can win only using cleave, you just have to time it right. When all the ogres have come into the circles.
When you say “big ogres”, is your level different from mine? Mine only has small ogres (munchkins), is that what you meant when you said “big ogres”
Danny
A few things. Oddly enough, the method cleave doesn’t really need a parameter, but it helps with targeting. It will run the code with two parameters, but seems to take the first variable. One thing to keep in mind, when you check for one variable, you don’t want to switch the variable after it.
elif nearest and hero.distanceTo(nearest) < 10: # checking for nearest
# Only attack if the enemy distance is < 10 meters
enemy = hero.findNearestEnemy() # look for a new enemy after checking nearest
hero.attack(enemy)
Even as it is, you code will pass the level. You can’t defeat them because your hero is dying? I’m wondering if you need better armor.