{SOLVED}Summits Gate help (Python)

Gear:

summonTypes = ['griffin-rider']
tactick = 'hold'
stage = 1
def summonTroops():
    type = summonTypes[len(self.built)%len(summonTypes)]
    if self.gold > self.costOf(type):
        self.summon(type)
        
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = self.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(self.health<self.maxHealth*0.8):
            target = self
        else:
            target = lowestHealthPaladin()        
        if target:
            self.command(paladin, "cast", "heal", target)
    elif(paladin.health<100):
        self.command(paladin, "shield")   
    elif stage<4:
        self.command(paladin, "move", {'x':94, 'y':34})
    elif stage==5:
        self.command(paladin, "move", {'x':284, 'y':33})
    else:
        target = self.findNearest(self.findEnemies())
        if(warlock):
            target = warlock
        if(target):
            self.command(paladin, "attack", target)
            
def commandSoldier(soldier):         
     target = self.findNearest(self.findEnemies())
     if(warlock):
            target = warlock
     if stage==3:
        self.command(soldier, "move", {'x':84, 'y':34})
     elif(target):
        self.command(soldier, "attack", target)
        
def commandFriends():
    friends = self.findFriends()
    for friend in friends: 
        if tactick == 'hold':            
            self.command(friend, "defend", {'x':1, 'y':40})
        elif friend.type == "paladin":
            commandPaladin(friend)
        else:
            commandSoldier(friend)
            
def moveTo(position):
    if(self.isReady("jump")):
        self.jumpTo(position)
    else:
        self.move(position)
        
def attack(target):
    if target:
        if(self.distanceTo(target)>10):
            moveTo(target.pos)        
        else:
            self.attack(target)
            
def pickUpNearestItem():
    nearestItem = self.findNearest(self.findItems())
    if nearestItem:
        moveTo(nearestItem.pos)
commandFriends()
self.moveXY(31, 56)   
while True: 
    catapult = self.findNearest(self.findByType('catapult'))
    warlock = self.findNearest(self.findByType('warlock'))
    target = self.findNearest(self.findEnemies())
    nearestItem = self.findNearest(self.findItems())
    now = self.now()
    if catapult:
        stage = 1
        attack(catapult)
    elif now<20:
        tactick = 'defend'
        stage = 2        
        moveTo({"x":50, "y":33})
    elif stage<4:        
        if target:
            stage = 3
            attack(target)
        else:
            moveTo({"x":172, "y":46})
        if self.pos.x>170:
            stage = 4
    elif stage<5:
        if self.pos.x<240:
            moveTo({"x":274, "y":35})
            tactick = 'defend'
        elif nearestItem and self.distanceTo(nearestItem)<10:
            pickUpNearestItem()
            tactick = 'attack'
        elif(warlock):
            target = warlock
            summonTroops()
            attack(target)
        elif target and target.type!='gates':
            attack(target)
        elif nearestItem and self.distanceTo(nearestItem)<45:
            pickUpNearestItem()
            tactick = 'defend'
            summonTroops()  
        else:
            attack(target)
        if self.pos.x>290:
            stage = 5
            tactick = 'attack'
        else:
            summonTroops()
            attack(target)
            commandFriends()

I am using Ned. And I don’t know why i am failing this level. This is the final level in Cloudrip Mountain. @riticmaster908 I need help please.

level link

So basically, which stage do you reach? Is there any error popping up? How are you dying?

I reach stage 3. I only kill 33/63 enemies.

So the towers or what?

I get to the beam towers right after the first set of gates. I edited my code a little bit.

My newer code:

summonTypes = ['griffin-rider']
tactick = 'hold'
stage = 1
def summonTroops():
    type = summonTypes[len(self.built)%len(summonTypes)]
    if self.gold > self.costOf(type):
        self.summon(type)
        
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = self.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(self.health<self.maxHealth*0.8):
            target = self
        else:
            target = lowestHealthPaladin()        
        if target:
            self.command(paladin, "cast", "heal", target)
    elif(paladin.health<100):
        self.command(paladin, "shield")   
    elif stage<4:
        self.command(paladin, "move", {'x':94, 'y':34})
    elif stage==5:
        self.command(paladin, "move", {'x':284, 'y':33})
    else:
        target = self.findNearest(self.findEnemies())
        if(warlock):
            target = warlock
        if(target):
            self.command(paladin, "attack", target)
            
def commandSoldier(soldier):         
    target = self.findNearest(self.findEnemies())
    if(warlock):
            target = warlock
    if stage==3:
        self.command(soldier, "move", {'x':84, 'y':34})
    elif(target):
        self.command(soldier, "attack", target)
        
def commandFriends():
    friends = self.findFriends()
    for friend in friends: 
        if tactick == 'hold':            
            self.command(friend, "defend", {'x':1, 'y':40})
        elif friend.type == "paladin":
            commandPaladin(friend)
        else:
            commandSoldier(friend)
            
def moveTo(position):
    if(self.isReady("jump")):
        self.jumpTo(position)
    else:
        self.move(position)
        
def attack(target):
    if target:
        if(self.distanceTo(target)>10):
            moveTo(target.pos)        
        else:
            self.attack(target)
            
def pickUpNearestItem():
    nearestItem = self.findNearest(self.findItems())
    if nearestItem:
        moveTo(nearestItem.pos)
commandFriends()
self.moveXY(31, 56)   
while True: 
    catapult = self.findNearest(self.findByType('catapult'))
    warlock = self.findNearest(self.findByType('warlock'))
    target = self.findNearest(self.findEnemies())
    nearestItem = self.findNearest(self.findItems())
    now = self.now()
    if catapult:
        stage = 1
        attack(catapult)
    elif now<20:
        tactick = 'defend'
        stage = 2        
        moveTo({"x":50, "y":33})
    elif stage<4:        
        if target:
            stage = 3
            attack(target)
        else:
            moveTo({"x":172, "y":46})
        if self.pos.x>170:
            stage = 4
    elif stage<5:
        if self.pos.x<240:
            moveTo({"x":274, "y":35})
            tactick = 'defend'
        elif nearestItem and self.distanceTo(nearestItem)<10:
            pickUpNearestItem()
            tactick = 'attack'
        elif(warlock):
            target = warlock
            summonTroops()
            attack(target)
        elif target and target.type!='gates':
            attack(target)
        elif nearestItem and self.distanceTo(nearestItem)<45:
            pickUpNearestItem()
            tactick = 'defend'
            summonTroops()  
        else:
            attack(target)
        if self.pos.x>290:
            stage = 5
            tactick = 'attack'
        else:
            summonTroops()
            attack(target)
            commandFriends()

Im gonna look into it when im free

Okay, take your time

what is the problem? do you not survive?

I do not survive past the first gate now

try using better gear and a better sword, also command ur paladins to heal you whenever you get past 1st gate so you dont die from beams

And so it begins again…

Why do people copy the same code from the same place? I mean, it was copied so many times…
I’d recommend you writing your own code. If you write the code, you understand what is there, and when you do not, you don’t.

2 Likes

@ZAX155 Don’t worry , i am here
I think you can use “not while true loop code”

Some ex:

for friend in hero.findFriends():
    #do what ever you want
for enemy in hero.findEnemies():
    if enemy.type == 'catapult':
        hero.attack(enemy)

somthing like that

1 Like

@ZAX155 these are the hints i can gave you, for more hints, just feel free to @ me

1 Like

if i did that, I won’t move and i fail the level

Last 3 enemies are HARD, try submitting your code many times, even I sometimes fail with equipment from Kelvintaph like BS4

1 Like

I have submitted many times. I think it i have submitted around 30 or 40 times

Hmmm, you need to get better equipment then… do some Kelvintaph levels that don’t really need equipment and then:

  1. buy deflector
  2. buy order of the paladin
  3. use infinite lenses if you have them
  4. equip order of the paladin instead of the steel ring
  5. change your code (to use order of the paladin)
1 Like

I can’t do that. I need to pass this level to do Glacier levels

No, you can access the levels with direct links