<<< def moveTo(position, fast=True):
if (hero.isReady(“jump”) and hero.distanceTo > 10 and fast):
hero.jumpTo(position)
else:
hero.move(position)
pickup coin
def pickUpNearestItem(items):
nearestItem = hero.findNearest(items)
if nearestItem:
moveTo(nearestItem.pos)
add soldier
summonTypes = [‘archer’,
‘peasant’]
def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)
def findNearest(index):
top = False
left = False
if (index == 0):
top = True
left = True
elif (index == 1):
top = True
elif (index == 3):
left = True
items = hero.findItems()
for item in items:
if (item.pos.y > 66 and top and left and item.pos.x < 76):
return item
elif (item.pos.y < 66 and not top and left and item.pos.x < 76):
return item
elif (item.pos.y > 66 and top and not left and item.pos.x > 76):
return item
elif (item.pos.y < 66 and not top and not left and item.pos.x > 76):
return item
return None
commands attack
def commandTroops():
index = 0
for friend in hero.findFriends():
if friend.type == ‘peasant’:
item = findNearest(index)
index += 1
if item:
hero.command(friend, ‘move’, item.pos)
else:
enemy = hero.findNearestEnemy()
archers = hero.findFriends()
while True:
summonTroops()
commandTroops()
enemy = hero.findNearestEnemy()
attack(enemy>>>
I would like to make a peasant who will walk around and get me gold. Then, I will get some troops to help. But that irritating duck comes up and says I can’t command “arrow-tower” WTF
def moveTo(position, fast=True):
if (hero.isReady("jump") and hero.distanceTo > 10 and fast):
hero.jumpTo(position)
else:
hero.move(position)
def pickUpNearestItem(items):
nearestItem = hero.findNearest(items)
if nearestItem:
moveTo(nearestItem.pos)
summonTypes = ['archer',
'peasant']
def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)
def findNearest(index):
top = False
left = False
if (index == 0):
top = True
left = True
elif (index == 1):
top = True
elif (index == 3):
left = True
items = hero.findItems()
for item in items:
if (item.pos.y > 66 and top and left and item.pos.x < 76):
return item
elif (item.pos.y < 66 and not top and left and item.pos.x < 7):
return item
elif (item.pos.y > 66 and top and not left and item.pos.x > 7):
return item
elif (item.pos.y < 66 and not top and not left and item.pos.x > 76):
return item
return None
def commandTroops():
index = 0
for friend in hero.findFriends():
if friend.type == 'peasant':
item = findNearest(index)
index += 1
if item:
hero.command(friend, 'move', item.pos)
else:
enemy = hero.findNearestEnemy()
archers = hero.findFriends()
if enemy:
hero.command(archers, "attack", enemy)
def attack(target):
if target:
if (hero.distanceTo(target) > 10):
moveTo(enemy.pos)
elif (hero.isReady("bash")):
hero.bash(enemy)
elif (hero.isReady("power-up")):
hero.powerUp()
hero.attack(enemy)
elif (hero.isReady("cleave")):
hero.cleave(enemy)
else:
hero.attack(enemy)
while True:
summonTroops()
commandTroops()
enemy = hero.findNearestEnemy()
attack(enemy)
Ok I think this is better
It took me forever to do this
I think I found the problem. Is your problem that it won’t complete the level? It says incomplete because you have to submit it for it to work. You have to be crafty with it though, this level gets hard overtime.
yeah, you can’t command towers. if you are comanding a soldier, make sure the friend’s type is equal to soldier, or just make sure the friend’s type is not equal to tower.