Help On Levels In Mountain

Thanks! I think it will work!

um @eric_tang, now my griffin-riders attack the fangriders on my side of the mine.

Have you read my post?
Lydia

uh lydia i have and it still say the say error

Did you do my changes

yep i did @Eric_Tang

?? Do you also need help? Or are you helping Dragonlouis ?
Lydia

helping
and
@Eric_Tang
maybe i did it in the wrong place


def moveTo(position, fast=True):
    if (hero.isReady("jump") and hero.distanceTo > 10 and fast):
        hero.jumpTo(position)
    else:
        hero.move(position)


def chooseStrategy():
    enemies = hero.findEnemies()
    if hero.gold > hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
    fangrider = hero.findByType("fangrider")
    if (len(fangrider) > 0 and fangrider[0].pos.x < 38):
        return "fight-back"
    else:
        return "collect-coins"


def commandAttack():
    for soldier in hero.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            hero.command(soldier, "attack", enemy)
    pass
    
def pickUpCoin():
    # Добери монеты
    nearestItem = hero.findNearest(hero.findItems())
    if nearestItem:
        moveTo(nearestItem.pos)
    pass
    
def heroAttack(target):
    target = hero.findNearest(hero.findByType("fangrider"))
    if target:
        if (hero.distanceTo(target) < 20):
            moveTo(target.pos)
        elif hero.isReady("chain-lightning"):
            hero.cast("chain-lightning", target)
        else:
            hero.attack(target)
    pass
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    enemy = hero.findNearest(hero.findEnemies())
    if (strategy == "fight-back"):
        heroAttack()
    else:
        pickUpCoin()

I don’t use jump. At all.

oops my guy does i will have to change that

what is ypur armor @Dragonlouis

leaping and dragonplate.

temple guard and thornprick plus flowers?

My code:

# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.

def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold >= hero.costOf("griffin-rider"):
        return"griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "fangrider" and enemy.pos.x > 38:
        return"fight-back"
    # Otherwise, return "collect-coins"
    else:
        return"collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friends = hero.findFriends()
    enemy = hero.findNearestEnemy()
    for friend in friends:
        if enemy.pos.x > 50:
            hero.command(friend, "attack", enemy)
    pass
    
def pickUpCoin():
    # Collect coins
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
    pass
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)
    pass
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        hero.summon("griffin-rider")
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()

Oh I also have deflector

line 6 error still
image
we will need your help @abc

It’s the pos 20 chars

ok so for the heroAttack he should only attack the fangriders that have crossed the range

enemy= hero.findNearest(hero.findByType("fangrider"))

@Falcons118 this is python

Why do you need this?

Try just doing fangrider = hero.findNearest(hero.findByType("fangrider")
And then checking if there is a fangrider and if the fangrider’s x pos is less than 36

I suggest defining friends first. Then doing the for loop. And the friend type is only griffin rider

You could just defind itemPos = item.pos and then using hero.move to move to itemPos

You have to check if there is target, if the hero.distanceTo(target) is less than 30, and if the target’s x pos is less than 38

Delete this

If should be
if the strategy is ā€œgriffin-riderā€
summon griffin-rider
if the strategy is ā€œfight-backā€
heroAttack()
if the strategy is ā€œcollect-coinsā€
pickUpCoin()

Lydia