This is my code so far.
def commandSoldier(soldier, soldierIndex, numSoldiers):
angle = Math.PI * 2 * soldierIndex / numSoldiers
defendPos = {"x": 41, "y": 40}
defendPos.x += 10 * Math.cos(angle)
defendPos.y += 10 * Math.sin(angle)
hero.command(soldier, "defend", defendPos);
def findStrongestTarget():
mostHealth = 0
bestTarget = None
enemies = hero.findEnemies()
if enemies.health > mostHealth:
bestTarget = enemy
if bestTarget and bestTarget.health > 15:
return bestTarget
else:
return None
def commandArcher(archer):
nearest = archer.findNearestEnemy()
if archerTarget:
hero.command(archer, "attack", archerTarget)
elif nearest:
hero.command(archer, "attack", nearest)
archerTarget = None
while True:
if not archerTarget or archerTarget.health <= 0:
archerTarget = findStrongestTarget()
friends = hero.findFriends()
soldiers = hero.findByType("soldier")
for i in range(len(soldiers)):
soldier = soldiers[i]
commandSoldier(soldier, i, len(soldiers));
hero.command('archer', "attack", enemy)
After the
while True:
if not archerTarget or archerTarget.health <= 0:
archerTarget = findStrongestTarget()
friends = hero.findFriends()
soldiers = hero.findByType("soldier")
chunk, it says to
# Create a variable containing your archers.