守时
花钱花钱,有钱别攒着,该买装备买装备。
# 使用你的新技能来选择你要做什么: hero.time
while True:
# 如果是前十秒,攻击。
if hero.time < 10:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
pass
# 否则,如果是前35秒,收集硬币。
elif hero.time < 35:
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x, item.pos.y)
pass
# 35秒后,再次发起攻击!
else:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
pass
沙丘苦战(挑战关卡)
这关简直太变态了,你需要不断的尝试才知道关卡是怎么回事。word天!!!
1.首先你需要完全的控制旗子。
2.用旗子控制好你的英雄。
3.要向右走3个场景,每个场景中消灭3个骷髅
4.这关坑的地方就是由于作者没有给骷髅怪还有牦牛怪定义类型,所以无法用类型去实现是否攻击牦牛,你只能用旗子控制
5.初始碰到boss的时候,会无法获取Boss的状态,你需要和boss绕圈圈。
6.注意乌鸦,前期会给你提示,后期遇到Boss的时候会给你血瓶。
7.boss会招3-5波小骷髅,打死小骷髅后,Boss的状态才会变成可攻击状态。
8.尽量保证你的血量在1000以上,否则在英雄无法控制的情况下,你会被牦牛撞死。。。
9.英雄不受控制的情况下就多插旗吧。
10.我这里代码简单写了,大家可以自行添加,比如使用你的宠物捡血瓶,判断英雄的血量等。
11.多来几遍,祝你好运!!
# 去关卡的最右边找到新的区域。
# 查看指南了解更多详情。
def pickUpFlag():
flag = hero.findFlag()
if flag:
hero.pickUpFlag(flag)
while True:
pickUpFlag()
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
else:
pickUpFlag()
囤积黄金
第三章我们会比之前学到很多新的东西,好,我们本节学习如何跳出循环。
# 收集25金,然后告诉 Naria 总数。
# 当totalGold >= 25,使用 break 来停止收集。
totalGold = 0
while True:
coin = hero.findNearestItem()
if coin:
# 捡起硬币。
hero.moveXY(coin.pos.x,coin.pos.y)
# 将硬币的价值加到totalGold。
# 使用以下方法得到它的价值:: coin.value
totalGold += coin.value
pass
if totalGold >= 25:
# 这会中断跳出循环并执行循环下面的语句。
# 循环结束后,运行循环后的代码。
break
# 完成收集黄金!
hero.moveXY(58, 33)
# 去告诉 Naria 你收集了多少黄金。
hero.say("I collect" + totalGold + "Naria")
沙漠蘑菇
你需要换一个高级的宠物,否则不能开始关卡。
# 收集9个蘑菇。
# 这个函数让宠物给你取回药水。
def onSpawn(event):
while True:
# 宠物可以根据类型找到最近的物品。
potion = pet.findNearestByType("potion")
# 如果存在药水则让宠物取回:
if potion:
pet.fetch(potion)
pet.on("spawn", onSpawn)
# 蘑菇有毒,不要太快收集。
while True:
someItem = hero.findNearestItem()
if someItem and hero.health > hero.maxHealth / 3:
# 收集someItem:
hero.moveXY(someItem.pos.x,someItem.pos.y)
蘑菇之声
# 打败骷髅并打开宝箱。
def onSpawn (event):
# 宠物要找到生命药水(类型是 "potion"):
potion = pet.findNearestByType("potion")
# 并将它取回:
pet.fetch(potion)
# 宠物要找到金钥匙(类型是"gold-key"):
key = pet.findNearestByType("gold-key")
# 并将它取回:
pet.fetch(key)
# 宠物可以发现的不仅仅是物品:
skeleton = pet.findNearestByType("skeleton")
pet.on("spawn", onSpawn)
while True:
if skeleton.health > 0:
hero.attack(skeleton)
else:
hero.moveXY(31, 38)
钥匙陷阱
# 获得三把钥匙并释放圣骑士。
def onSpawn(event):
# 宠物需要找到并拿回3把钥匙。
# 你需要后续类型的物品:
# "bronze-key"、"silver-key"和"gold-key"。
key1 = pet.findNearestByType("bronze-key")
pet.fetch(key1)
key2 = pet.findNearestByType("silver-key")
pet.fetch(key2)
key3 = pet.findNearestByType("gold-key")
pet.fetch(key3)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
if enemy and enemy.team == "ogres":
hero.attack(enemy)
if hero.health < 300:
# 你也可以在主线程中使用宠物。
potion = pet.findNearestByType("potion")
if potion:
hero.moveXY(potion.pos.x, potion.pos.y)
追逐他们
# 打败食人魔和治疗英雄
# 宠物是你唯一的希望。
def onSpawn(e):
while True:
enemy = pet.findNearestByType("munchkin")
if enemy and pet.isReady("chase"):
pet.chase(enemy)
# 寻找并获取 "potion"
potion = pet.findNearestByType("potion")
if potion:
pet.fetch(potion)
# 在 "spawn" 事件中分配 "onSpawn" ”处理程序:
pet.on("spawn",onSpawn)
地下商业
# 积攒300黄金并逃出地牢。
def onSpawn(event):
# 派遣宠物绕地牢找走动:
#coin = pet.findNearestByType("gold-coin")
# 别忘了让它回到英雄那里:
#pet.moveXY(coin.pos.x, coin.pos.y)
#pet.moveXY(hero.pos.x, hero.pos.y)
pet.moveXY(21, 11)
pet.moveXY(72, 12)
pet.moveXY(68,56)
pet.moveXY(23, 58)
pet.moveXY(5, 35)
pet.moveXY(hero.pos.x, hero.pos.y)
def pickCoin():
item = hero.findNearestItem()
if item:
distance = hero.distanceTo(item)
if distance < 10:
hero.moveXY(item.pos.x,item.pos.y)
pet.on("spawn", onSpawn)
while True:
# 守护农民:
#goldTotal = 0
enemy = hero.findNearestEnemy()
if enemy:
distance = hero.distanceTo(enemy)
if distance < 5 and hero.isReady('bash'):
hero.bash(enemy)
hero.attack(enemy)
hero.moveXY(23, 35)
# 当你的黄金数目超过300,移动到红色标记:
#item = hero.findNearestItem()
pickCoin()
if hero.gold > 300:
hero.moveXY(50, 34)
布朗噪声
一遍一遍的不断尝试,费脑细胞啊费脑细胞。。。
# 收集宝藏并逃脱。
# 准备好英雄和宠物。
pet.moveXY(32, 28)
hero.moveXY(10, 19)
# 分散骷髅的注意力。
pet.distractionNoise()
# 当骷髅分心时偷偷潜行。
hero.moveXY(10, 46)
# 重复这个动作来获得宝藏:
hero.moveXY(46, 35)
pet.moveXY(64, 28)
pet.distractionNoise()
hero.moveXY(46, 28)
hero.moveXY(70, 9)
hero.moveXY(46, 22)
pet.distractionNoise()
# 逃出地牢(红色标记):
hero.moveXY(40, 56)