on backwoods brawl, I use these:
and my code does nothing
#Commented out to stop infinite loop.
# Stay alive for one minute.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
def wait(boba):
for bob in range(boba):
hero.moveXY(hero.pos.x,hero.pos.y)
while True:
enemy = hero.findNearestEnemy()
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-yeti"):
hero.cast("summon-yeti")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
if hero.gold > 20:
soldier = hero.summon("archer")
b = hero.findFriends()
for a in b:
if a.type == "archer":
if hero.findNearestEnemy():
hero.command(a, "defend", hero)
if enemy:
if hero.isReady("magnet-field") and hero.isReady("poison-cloud"):
hero.cast("magnet-field", enemy.pos)
hero.cast("poison-cloud", enemy.pos)
if hero.canCast("chain-lightning"):
hero.cast("chain-lightning", hero.findNearestEnemy())
continue
if hero.canCast("raise-dead"):
hero.cast("raise-dead")
elif hero. canCast("drain-life") and hero.distanceTo(enemy) <15:
hero.cast("drain-life", enemy)
What is the def wait(boba) function for? There is already a wait function, that might be causing a bug. Otherwise I see nothing else that would cause a glitch, except maybe the space in hero. canCast("drain-life")
# Collect 100 gold from two or three groves.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
hero.moveXY(27, 25)
def function(enemy):
#if hero.isready("warcry"):
# hero.warcry()
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
if enemy:
if enemy.health > 140:
hero.attack(enemy)
for friend in friends:
if friend.type == 'yeti' or friend.type == 'skeleton':
if hero.findNearestEnemy():
hero.command(friend, 'attack', hero.findNearestEnemy())
else:
hero.command(friend, 'move', hero.pos)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
if hero.isReady("raise-dead") and enemy:
hero.cast("raise-dead")
if hero.isReady("summon-yeti"):
hero.cast("summon-yeti")
# if hero.isReady("chain-lightning"):
# if hero.findNearestEnemy() and hero.distanceTo(hero.findNearestEnemy()) < 45:
# hero.cast("chain-lightning", hero.findNearestEnemy())
def optimalCoin():
items = hero.findItems()
optimalItem = items[0]
for item in items:
if (item.value)/hero.distanceTo(item.pos) > optimalItem.value/hero.distanceTo(optimalItem.pos) and not (item.pos.x > 40 and item.pos.y > 34):
optimalItem = item
for friend in hero.findFriends():
if friend.type == 'yeti':
hero.command(friend, 'move', optimalItem.pos)
hero.moveXY(optimalItem.pos.x, optimalItem.pos.y)
while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
coin = function(enemy)
if enemy:
function()
if item:
if item.pos.x < 39:
optimalCoin()
else:
optimalCoin()
#hero.moveXY(22, 21)
else:
hero.moveXY(22, 25)
hero.moveXY(18, 26)
No problem. There are two possibilities from what I’ve seen.
Below, the hero kept going between the two points and then stopping when I tested it on a level without coins. So it might be the case when there are no items currently spawned in the level.
if enemy:
function()
elif item:
if item.pos.x < 39:
optimalCoin()
else:
optimalCoin()
#hero.moveXY(22, 21)
else:
hero.moveXY(22, 25)
hero.moveXY(18, 26)
However, when I put it in the backwoods brawl, the hero just dies to ogres so it might be something else that is causing it.
The other is that the coin = function(enemy) may be causing issues when the hero is trying to do something else.
Oh lol no problem, I didn’t even notice; I still went to Backwoods Treasure when I saw the # Collect 100 gold from two or three groves. My backwoods treasure is advanced enough that I die before being able to do very much.