大家好,我是新來的,我在頂峰之門卡關,可以請大家幫忙嗎?
這是我的代碼,我不知道如何讓自己回血。
# 突破至聖殿,並擊敗食人魔首領
def attackSikll():
enemy = hero.findNearestEnemy()
if enemy and hero.distanceTo(enemy) < 10:
if hero.isReady("bash"):
hero.bash(enemy)
else:
hero.attack(enemy)
def PickUpcoin():
item = hero.findNearestItem()
if item and hero.distanceTo(item):
hero.move(item.pos)
def commandtroop():
if hero.gold > hero.costOf("griffin-rider"):
hero.summon("griffin-rider")
while True:
flag = hero.findFlag("green")
health = hero.health
if flag:
if hero.isReady("jump"):
hero.jumpTo(flag)
else:
hero.pickUpFlag(flag)
attackSikll()
PickUpcoin()
commandtroop()
friend()
def friend():
enemy = hero.findNearest(hero.findEnemies())
if enemy:
# 遍歷你所有的士兵,命令他們攻擊。
soldiers = hero.findFriends()
soldierIndex = 0
while soldierIndex<len(soldiers):
soldier = soldiers[soldierIndex]
hero.command(soldier, "attack", enemy)
soldierIndex+=1
謝謝