I can’t seem to land the hunting party bonus, here is my code.
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for friend in friends:
# If they see an enemy then command to attack.
enemy = friend.findNearestEnemy()
if friend.health < 100 and friend.type == "soldier" or friend.health < 15 and friend.type == "archer":
hero.command(friend, "move", {'x': friend.pos.x - 1, 'y': friend.pos.y})
elif enemy:
hero.command(friend, "attack", enemy)
continue
# Command to move east by small steps.
hero.command(friend, "move", {'x': friend.pos.x + 0.3, 'y': friend.pos.y})
1 Like
I’d recommend putting the “move” portion in an else statement after the else-if enemy one so if there is an enemy they won’t move forward. Currently one of the archers dies because it keeps moving forward even though there are enemies in range.
system
Closed
December 13, 2023, 9:22pm
3
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.