I SOLVED IT. Maybe I should take down one of my posts. Rest In Peace Rotten General. Took me 5 days to finish.
Congrats for solving it!
Which post should I mark as solved? This is my first topic.
Ok, that works too…nice implementation actually
For the other part, I summoned paladins, rather than soldiers is all it means. It will help, but is not required…soldiers work too.
Next…command(). Since I used pallys, I took advantage of their heal and defend capabilities. You might want to try playing with something like:
define soldiers
iterate through the soldiers # as you are doing already
define the nearest enemy # already doing this too
if there is an enemy and the soldier health is greater than 1/2 max health
command attack enemy
otherwise
command defend hero
or something like that. However, your code looks pretty solid as it is, so this is only a suggestion for better/quicker results
attack()…looks pretty good as is
Will do the final after you’ve taken a look at this.
Pick which ever post you feel helped the most.
I used anya…maxed armor and the sword of the forgotten
Oh. I was using Okar with maxed armor and sword of the forgotten
The case is officially closed
def SUPERPOWERMODE():
enemy = hero.findNearestEnemy()
if enemy:
while (enemy.health > 0):
if (hero.distanceTo(enemy) > 10):
hero.move(enemy.pos)
elif (hero.isReady("bash")):
hero.bash(enemy)
elif (hero.canCast('chain-lightning', enemy)):
hero.cast('chain-lightning', enemy)
else:
hero.attack(enemy)
def collectCoin():
coins = hero.findItems()
for i in range(len(coins)):
coin = coins[i]
if coin:
hero.move(coin.pos)
pass
def summoningSoldier():
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
pass
def summoningArcher():
if hero.gold > hero.costOf("archer"):
hero.summon("archer")
pass
def commandTheArcher():
friends = hero.findFriends()
for j in range(len(friends)):
friend = friends[j]
enemies = hero.findEnemies()
enemy = hero.findNearestEnemy()
if friend.type == "archer":
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {"x": 31, "y": 40})
pass
def commandTheSoldier():
friends = hero.findFriends()
for j in range(len(friends)):
friend = friends[j]
enemies = hero.findEnemies()
for enemy in enemies:
if friend.type == "soldier":
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {"x": 31, "y": 40})
hero.moveXY(55, 10)
hero.wait(2)
SUPERPOWERMODE(hero.findNearestEnemy())
collectCoin()
hero.moveXY(55, 33)
hero.moveXY(49, 37)
hero.moveXY(19, 40)
for i in range(1, 20):
summoningSoldier()
summoningArcher()
commandTheSoldier()
commandTheArcher()
hero.moveXY(55, 48)
while True:
SUPERPOWERMODE(hero.findNearestEnemy())
commandTheSoldier()
commandTheArcher()
collectCoin()
help pls the problem is soldier/archer not helping me defeating enemy why eh?
Instead of doing this, try:
for friend in friends:
#do something like commanding to attack
same goes for the soldier function
Wait, isn’t this topic supposed to be closed? Who opened it (after all, it is rather old and it was my first ever topic)
def SUPERPOWERMODE():
enemy = hero.findNearestEnemy()
if enemy:
while (enemy.health > 0):
if (hero.distanceTo(enemy) > 10):
hero.move(enemy.pos)
elif (hero.isReady("bash")):
hero.bash(enemy)
elif (hero.canCast('chain-lightning', enemy)):
hero.cast('chain-lightning', enemy)
else:
hero.attack(enemy)
def collectCoin():
coins = hero.findItems()
for coin in coins:
if coin:
hero.move(coin.pos)
pass
def summoningSoldier():
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
pass
def summoningArcher():
if hero.gold > hero.costOf("archer"):
hero.summon("archer")
pass
def commandTheArcher():
friends = hero.findFriends()
for friend in friends:
enemies = hero.findEnemies()
enemy = hero.findNearestEnemy()
if friend.type == "archer":
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {"x": 31, "y": 40})
pass
def commandTheSoldier():
friends = hero.findFriends()
for friend in friends:
enemies = hero.findEnemies()
for enemy in enemies:
if friend.type == "soldier":
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {"x": 31, "y": 40})
hero.moveXY(55, 10)
hero.wait(2)
SUPERPOWERMODE(hero.findNearestEnemy())
collectCoin()
hero.moveXY(55, 33)
hero.moveXY(49, 37)
hero.moveXY(19, 40)
for i in range(1, 20):
summoningSoldier()
summoningArcher()
commandTheSoldier()
commandTheArcher()
hero.moveXY(55, 48)
while True:
SUPERPOWERMODE(hero.findNearestEnemy())
commandTheSoldier()
commandTheArcher()
collectCoin()
still. they not moving