Summit's Gate [Last Level] Python [solved]

well the problem is l could get in “Breach The Inner Gate” but then hero goes some places that l don’t want to and l want my warriors to attack if it’s possible :expressionless:

tactick = 'hold'
stage = 1


def summonTroops():
    type = summonTypes[len(hero.built) % len(summonTypes)]
    if hero.gold > hero.costOf(type):
        hero.summon(type)


def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend
    return lowestFriend


def commandPaladin(paladin):
    if (paladin.canCast("heal")):
        if (hero.health < hero.maxHealth * 0.8):
            target = self
        else:
            target = lowestHealthPaladin()
        if target:
            hero.command(paladin, "cast", "heal", target)
    elif (paladin.health < 100):
        hero.command(paladin, "shield")
    elif stage < 4:
        hero.command(paladin, "move", {'x': 94, 'y': 34})
    elif stage == 5:
        hero.command(paladin, "move", {'x': 284, 'y': 33})
    else:
        target = hero.findNearestEnemy()
        if (warlock):
            target = warlock
        if (target):
            hero.command(paladin, "attack", target)


def commandSoldier(soldier):
    target = hero.findNearestEnemy()
    if (warlock):
        target = warlock
    if stage == 3:
        hero.command(soldier, "move", {'x': 84, 'y': 34})
    elif (target):
        hero.command(soldier, "attack", target)


def commandFriends():
    friends = hero.findFriends()
    for friend in friends:
        if tactick == 'hold':
            hero.command(friend, "defend", {'x': 1, 'y': 40})
        elif friend.type == "paladin":
            commandPaladin(friend)
        else:
            commandSoldier(friend)


def moveTo(position):
    if (hero.isReady("jump")):
        hero.jumpTo(position)
    else:
        hero.moveXY(95, 62)
        hero.wait(5)
        hero.moveXY(94, 7)



def pickUpNearestItem():
    nearestItem = hero.findNearestItem()
    if nearestItem:
        moveTo(nearestItem.pos)


commandFriends()
hero.moveXY(31, 56)
while True:
    catapult = hero.findNearest(hero.findByType('catapult'))
    warlock = hero.findNearest(hero.findByType('warlock'))
    target = hero.findNearestEnemy()
    nearestItem = hero.findNearestItem()
    now = hero.now()
    if catapult:
        stage = 1
        hero.attack(catapult)
    elif now < 20:
        tactick = 'defend'
        stage = 2
        moveTo({"x": 50, "y": 33})
    elif stage < 4:
        if target:
            stage = 3
            hero.attack(target)
        else:
            moveTo({"x": 172, "y": 46})
        if hero.pos.x > 170:
            stage = 4
    elif stage < 5:
        if hero.pos.x < 240:
            moveTo({"x": 274, "y": 35})
            tactick = 'defend'
        elif nearestItem and hero.distanceTo(nearestItem) < 10:
            pickUpNearestItem()
            tactick = 'attack'
        elif (warlock):
            target = warlock
            summonTroops()
            hero.attack(target)
        elif target and target.type != 'gates':
            attack(target)
        elif nearestItem and hero.distanceTo(nearestItem) < 45:
            pickUpNearestItem()
            tactick = 'defend'
            summonTroops()
        else:
            attack(target)
        if hero.pos.x > 290:
            stage = 5
        tactick = 'attack'
    else:
        summonTroops()
        hero.attack(target)
    commandFriends()
    

Perhaps you should try writing your own code. That would help you understand it.
I can help you do that, but I’m not going to help you to fix someone else’s code (so many people use this, I actually recognized it.)
Danny

4 Likes

Why don’t you simply command the troops to attack the enemies and attack the door?

I once had a code that worked but now it doesn’t. I can give the idea of my code to you. wait…

How can l get healed?
Well l haven’t wanted to type so many codes so l just used flag for my characters movements it’s simple but l need to get healed l have like 3300 health and 270 for each attack by sword and l am no wizard but l wanna know if there is anything l could do to get healed well here is my avatar oh and l have 12.000 gem if l need to buy anything to complete this level.

while True:
    hero.wait(1)
    if hero.time > 10:
        if hero.gold > hero.costOf("soldier"):
            self.summon("soldier")
        
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        
        while soldierIndex < len(soldiers):
            soldier = soldiers[soldierIndex]
            hero.command(soldier, "attack", enemy)
            soldierIndex +=1
            
    enemy = hero.findNearestEnemy()
    green = hero.findFlag("green")
    nearest = hero.findNearestEnemy()
    if green:
        hero.pickUpFlag(green)
    elif nearest and hero.distanceTo(nearest) < 25:
        # Attack!
        hero.attack(enemy)
        pass

use bs3 to command your paladins to heal you when they are ready and when you health is low

l tried but it told me that you dont have a subject to use castheal

I finally done it. İt was pretty hard

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.