# 矮人正在攻击!
# 攻击会有规律的一波波袭来。
# 可以的话,使用劈斩来清理大量敌人。
while True:
enemy = hero.findNearestEnemy()
# 使用带有‘isReady’的if语句来检查 “cleave”
if enemy:
if hero.isReady("cleave"):
hero.cleave(enemy)
# 劈斩!
# 否则,如果 cleave 还没准备好的话:
else:
hero.attack(enemy)
# 攻击最近的食人魔!
34.收割小食人魔
# 铲除所有遗留的小食人魔
# 确保你有足够的护甲。
while True:
enemy = hero.findNearestEnemy()
ready = hero.isReady("cleave")
if ready:
hero.cleave(enemy)
else:
hero.attack(enemy)
35.敏捷的匕首
# 长距离用你的弓,短距离用匕首
while True:
enemy = hero.findNearestEnemy()
if enemy:
distance = hero.distanceTo(enemy)
if distance < hero.throwRange:
# 向敌人扔你的匕首
hero.throw(enemy)
# else:
# 用你的弓攻击敌人
# hero.attack(enemy)
36.弹片
# 使用炸药干掉食人魔
# 然后用你的弓干掉他们
while True:
enemy = hero.findNearestEnemy()
if enemy:
if hero.isReady("throw"):
distance = hero.distanceTo(enemy)
# 如果食人魔距离多于15米的时候,扔炸药炸他
# 使用 if 来比较距离和15
if distance > 15:
hero.throw(enemy)
# 使用 else 来攻击它如果你不能够炸它
else:
hero.attack(enemy)
37.LONG-RANGE DIVISION
# Destroy the mines!
# Use `say` to call out the range to the mines.
# Use division to calculate the range.
enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
hero.say(distanceToEnemy/3)
hero.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
hero.say(distanceToEnemy/1.5)
hero.say("Fire!")
# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")
hero.say("Charge!!")
# Now, use a while-true loop to attack the enemies.
while True:
enemy = hero.findNearestEnemy()
hero.attack(enemy)