Summits-gate with out //This line archers do not form a circle

The main my that I don’t understood that with out" //This line "archers do not form a circle

hero.c = function(s, x, y, h, o ) {
if(h===undefined) h = false;
if(o===undefined) o = false;
hero.say(h);//This line
var d=6,e=null;
var defendPos = {x: x, y: y};
var angle = Math.PI * 2;
for(var i=0; i<s.length; i++)
{
if(s[i])
{
defendPos = {x: x, y: y};
angle = Math.PI * 2;
if(s[i].type==“soldier”) {if(o) d=5; else d=7;}
if(s[i].type==“archer”) {if(o) d=7; else d=4;}
if(s[i].type==“paladin”) {if(h&&o) d=4; else{ if(h) d=8; else d=2;}}
angle = angle * i / s.length;
if(h) angle = angle/2-Math.PI/2;
if(h&&o) angle = angle+Math.PI;
defendPos.x += d * Math.cos(angle);
defendPos.y += d * Math.sin(angle);
e=null;
if(hero.findEnemies()) e=s[i].findNearest(hero.findEnemies());

    if(h){
        if(s[i].type=="soldier") { if(e&&s[i].distanceTo(e)<6)
            hero.command(s[i], "attack", e);
                    else hero.command(s[i], "move", defendPos);}
        if(s[i].type=="archer") { if(e&&s[i].distanceTo(e)<13)
            hero.command(s[i], "attack", e);
                    else hero.command(s[i], "move", defendPos);}
        if(s[i].type=="paladin") {    
            if (s[i].canCast("heal",hero)) this.command(s[i], "cast", "heal", hero);
            else {if(s[i].canCast("heal",s[i]))this.command(s[i], "cast", "heal", s[i]);}
        }
    }
    else hero.command(s[i], "move", defendPos);

    }
}

};

hero.c( hero.findByType(“soldier”) , 52, 38, true);
hero.c( hero.findByType(“archer”), 6, 38);
if(hero.now()>4) hero.say(“message”);
if( hero.now()>5.6){
var sa = hero.findByType(“soldier”);
var a1=sa[0];
var a2=sa[1];
sa[0]=null;
sa[1]=null;
hero.command(a1, “move”,{x:88, y:61});
hero.command(a2, “move”,{x:88, y:7});
while( hero.now<6.7)
hero.c(sa , 17, 38);
}

but at all if in line “if( hero.now()>5.6){” not be executed

@Eggzz can you use the code format button to ensure your code is formatted properly and easy to read.

can you please tell me what is wrong with my code
this is my code:

summonTypes = ['griffin-rider']
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.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()

We are glad to help, but where did you copy the code?
From Codecombat Stuck on "Summits Gate"
Or [Solved]Summits Gate: Help Needed! ?

That’s not really good to copy others’ codes. You don’t learn when you copy code. When you write your own, I’ll help you. :slightly_smiling_face:

1 Like