Summits gate help please

code:

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.move(position)


def attack(target):
    if target:
        if (hero.distanceTo(target) > 10):
            moveTo(target.pos)
        else:
            hero.attack(target)


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
        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 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()
            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()
        attack(target)
    commandFriends()
1 Like

This is a lot of code and a big level. Please provide more details on what you need help with? Are you receiving an error? Are certain sections of the code not running as expected?

1 Like

Yes as @brooksy125 mentioned, because you have so much code on a bigger level, more info would be great. A description of the objectives, errors, and a screenshot would help

Thanks!
:fox_face::fox_face::fox_face:
-@Luke10

Hi @Hayden_Fung, I recommend you write your own code instead of taking it from GitHub. The code there are usually incorrect and you probably won’t learn much if you just use someone’s code.

2 Likes

whats github and how do u know he got it from “Github”

just look at the code! you cant even learn that much in da moutains

ok? i will then and also sorry @Deadpool198 i forgot about the onemonth thing(again)

I know how to hack item First you go to the wait places to join a level then click the left click and click the word inspect then you find the word same like
Mod edit: removed

Does anyone here have a good strategy for Summit’s gate. My code does what it’s supposed to, but I get killed by beam towers.

Have you tried “search-along-forum” strategy?)

what’s that? (20 chars)

Well…
That’s
https://discourse.codecombat.com/search?q=summits%20gate

For example, the strategy I would recommend for the level is like that:

You can see here tip about killing hero by beam-towers f.e.

1 Like

One of the best topic with lots of advices about Summits Gate:

https://discourse.codecombat.com/t/please-help-with-summits-gate/4924/15

what’s the “type” for the doors.

“Door”?? I fell like there’s a capital letter. Click on it on the level and the name after the – is the type. Make sure you include capitals if there are any.
Danny

I can’t click it. I tried.

I think it’s just your nearest enemy.
Also, friends can see the door.

I’m pretty sure the type is “door” and the names are “Outer Gate” and “Inner Gate”.

It’s strange but they are really unclickable. It seems to me that they were when I passed this lvl for the first time. But I may be wrong. :roll_eyes: Anyway I accidentally delete my first Python solution while helping someone with JavaScript. And I don’t remember the way I defined doors for sure. Maybe it was smth like FindNearestByType and attacking if door.health>0.

2 Likes

You can use
nearestDoor = hero.findNearest(hero.findByType("door"))
to get the nearest door, if it exists.

1 Like