Sarven Brawl 4 help! {Python}

or maybe do this:

while true:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type = "brawler" and hero.isReady("invisibility")
        hero.cast(invisibility, self)
        hero.attack(enemy)
    if enemy:
    hero.attack(enemy)
enemy = hero.findNearestEnemy()

friends = hero.findfriends()
for friend in friends:
if hero.gold > hero.costOf(“soldier”):
hero.summon(“soldier”)
hero.command(friend, “attack”, enemy)

The summoning part should be out of the for loop, and there should be an if friend statement, or there would be an error, like attacking enemy without using if enemy first.

Ok, I am trying @Eric_Tang’s code now.

easiest way to command troops:

while true:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    friend = hero.findFriends()
    for friend in friends:
        hero.command(friend, "attack", friend.findNearest(enemies)
    if hero.gold = hero.costOf("soldier")
       hero.summon('soldier")

@Eric_Tang, your code doesn’t work. My hero doesn’t do anything. Code:

friends = hero.findFriends()
for friend in friends:
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")
        hero.command(friend, "attack", enemy)


Oh, and @cheddarcheese, I will try your code.

check my new code i had a few typos

Ok, I fixed your typos, but it says “Unexpected token” on the last line. Code:

while true:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    friend = fhero.findFriends()
    for friend in friends:
        hero.command(friend, "attack", friend.findNearest(enemies)

what is fhero that is one typo but have you summond troops?

ok wait. That was the past code. Current code:

while true:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    friend = hero.findFriends()
    for friend in friends:
        hero.command(friend, "attack", friend.findNearest(enemies)

It says “Unexpected Token” on the last line

the true should be True

ok. Still doesn’t work:

while True:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    friend = hero.findFriends()
    for friend in friends:
        hero.command(friend, "attack", friend.findNearest(enemies)

Is that your full code?

yeah. That is my full code.

you havent summond troops

ok, wait. I will do that now @Eric_Tang!

@Eric_Tang! I said that the error is “Unexpected Error” on line 8! Code:

while True:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    friend = hero.findFriends()
    if hero.gold >= hero.costOf("artillery"):
        hero.summon("artillery")
    for friend in friends:
        hero.command(friend, "attack", friend.findNearest(enemies)

You can’t summon artillerys

what about griffen-riders Code:

while True:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    friend = hero.findFriends()
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
    for friend in friends:
        hero.command(friend, "attack", friend.findNearest(enemies)

IT SAYS “Unexpected token” ON LINE 8!!!

do hero.command(friend, "attack, enemy)