# Advance through the forgotten tomb.
# Be wary, traps lay in wait to ruin your day!
# The Paladins volunteer to lead the way.
# Command them to shield against incoming projectiles.
while True:
friends = hero.findFriends()
# findEnemyMissiles finds all dangerous projectiles.
projectiles = hero.findEnemyMissiles()
for friend in friends:
if friend.type is "paladin":
# Find the projectile nearest to the friend:
nearestProjectile = hero.findNearest(projectiles)
# If the projectile exists
if nearestProjectile:
if friend.distanceTo(nearestProjectile) < 11:
hero.command(friend, "shield", friend)
# AND is closer than 10 meters to the paladin:
# Command the friend to "shield"
# ELSE, when there is no potential danger:
else:
# Advance the paladin:
hero.command(friend, "moveXY", {friend.pos.x + 10, friend.pos.y})
pass
else:
# If not a paladin, just advance:
hero.command(friend, "moveXY", {friend.pos.x + 10, friend.pos.y})
pass
# Advance the hero in the x direction:
hero.moveXY(hero.pos.x + 10, hero.pos.y)
Error
None, but only my middle paladin moves and shields.
You are finding the nearest projectile towards you, so that will always be the middle projectiles, therefore only the middle paladin can shield from the middle projectiles. Don’t find the nearest projectile loop over all the projectiles.
# Advance through the forgotten tomb.
# Be wary, traps lay in wait to ruin your day!
# The Paladins volunteer to lead the way.
# Command them to shield against incoming projectiles.
while True:
friends = hero.findFriends()
# findEnemyMissiles finds all dangerous projectiles.
projectiles = hero.findEnemyMissiles()
for friend in friends:
if friend.type is "paladin":
# Find the projectile nearest to the friend:
nearestProjectile = friend.findNearest(projectiles)
# If the projectile exists
if nearestProjectile and friend.distanceTo (nearestProjectile) < 10:
hero.command(friend, "shield", friend)
# AND is closer than 10 meters to the paladin:
# Command the friend to "shield"
# ELSE, when there is no potential danger:
else:
# Advance the paladin:
hero.command(friend, "move", {'x':friend.pos.x + 10,'y': friend.pos.y})
pass
else:
# If not a paladin, just advance:
hero.command(friend, "move", {'x':friend.pos.x + 10,'y': friend.pos.y})
pass
# Advance the hero in the x direction:
hero.moveXY(hero.pos.x + 10, hero.pos.y)
Well I changed the numbers for paladins and hero and non-paladins allies destination and complete the level (one of paladins dies anyway though).
I put 8 instead of 10 for paladins and 5 for hero.
I target other allies to 31,45.