Summit gate javascript help

here the code
// Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
// summon troops
var stage = 1;
var tacktick = 'hold';
var summonTypes = ['griffin-rider'];
function summon() {
    var types = summonTypes[hero.built.length % summonTypes.length];
    if (hero.gold >= hero.costOf(types)) {
        hero.summon(types);
    }
}

/* -summon
   -command
   -findlowhelt
   -attack
   -strat
   -move
   -collect
   -command troop
   
*/

function findLowHelt() {
    var lowestHealth = 99999;
    var lowestFriend = null;
    var friends = hero.findFriends();
    for (var f = 0; f < friends.length; f++) {
        var friend = friends[f];
        if (friend.health < lowestHealth && friend.health < friend.maxHealth) {
            lowestHealth = friend.health;
            lowestFriend = friend;
        }
    }
    return lowestFriend;
}

function commandPal(pal, warlock) {
    var friends = hero.findFriends();
    var low = findLowHelt();
    for (var i = 0; i < friends.length; i ++) {
        var friend = friends[i];
        if (low) {
            if (pal.canCast("heal", low)) {
                hero.command(pal, "cast", "heal", low);
            }
        } else if (pal.health < 100) {
            hero.command(pal, "shield");
        } else if (stage < 4) {
            hero.command(paladin, "move", {'x': 94, 'y': 34});
        } else if (stage == 5) {
            hero.command(paladin, "move", {'x': 284, 'y': 33});
        } else {
            var enemy = pal.findNearestEnemy();
            if (warlock) {
                enemy = warlock;
            }
            if (enemy) {
                hero.command(pal, "attack", enemy);
            }
        }
        
    }
} 

function commandSol(sol, warlock) {
    var enemy = sol.findNearestEnemy();
    if (warlock) {
        enemy = warlock;
    } if (stage == 3) {
        hero.command(soldier, "move", {'x': 84, 'y': 34});
    } else if (enemy) {
        hero.command(sol, "attack", enemy);
    }
    
}

function commandTroops() {
    var friends = hero.findFriends();
    var warlock = hero.findNearest(hero.findByType("warlock"));
    for (var i = 0; i < friends.length; i ++) {
        var friend = friends[i];
        if (tacktick == 'hold') {
            hero.command(friend, "defend", {'x': 1, 'y': 40});
        } else if (friend.type == "paladin") {
            commandPal(friend, warlock);
        } else {
            commandSol(friend, warlock);
        }
    }
}

function move(pos) {
    if (hero.isReady("jump")) {
        hero.jumpTo(pos);
    }
    else {
        hero.move(pos);
    }
}

function attack(target) {
    if (target) {
        if (hero.distanceTo(target) < 10) {
            move(target.pos);
        } else if (hero.isReady("bash")) {
            hero.bash(target);
        } else if (hero.canCast("chain-lightning", target)) {
            hero.cast("chain-lightning", target);
        } else {
            hero.attack(target);
        }
         
    }
}

function pickUp() {
    var item = hero.findNearestItem();
    if (item) {
        move(item.pos);
    }
}

commandTroops();
hero.moveXY(31, 56);
while(true) {
    var catal = hero.findNearest(hero.findByType("catapult"));
    var warlok = hero.findNearest(hero.findByType("warlock"));
    var enemy = hero.findNearestEnemy();
    var item = hero.findNearestItem();
    var time = hero.time;
    if (catal) {
        stage = 1;
        attack(catal);
    } else if (time < 20) {
        tacktick = 'defend';
        stage = 2;
        move({"x": 50, "y": 33});
    } else if (stage < 4) {
        if (enemy) {
            stage = 3;
            attack(enemy);
        }
        else {
            move({"x": 172, "y": 46});
        }
        if (hero.pos.x > 170) {
            stage = 4;
        }
    } else if (stage < 5) {
        if (hero.pos.x < 240) {
            move({"x": 274, "y": 35});
            tacktick = 'defend';
        } else if (item && hero.distanceTo(item) < 10) {
            pickUp();
            tacktick = "attack";
        } else if (warlok) {
            enemy = warlok;
            summon();
            attack(enemy);
        } else if (enemy && enemy.type != 'gates') {
            attack(enemy);
        } else if (item && hero.distanceTo(item) < 45) {
            pickUp();
            tacktick = 'defend';
            summon();
        } else {
            attack(enemy);
        } if (hero.pos.x > 290) {
            stage = 5;
        } 
        tacktick = attack;
    } else {
        summon();
        attack(enemy);
    } commandTroops();
    
}

help while hero trying to kill catapult catapult kill him first anyone have idea how do i avoid getting kiiled?

I would recommend moving soldiers towards the catapults instead of the hero.

1 Like

I just had my character attack the catapults and they didn’t hit me.

1 Like

oh ok sip 20 cahrrrrrr

how’d u do that. 20 char

This is the section of code i use to attack:

(it is in python tho)
def attack():
    enemy = hero.findNearestEnemy()
    if enemy and hero.canCast("chain-lightning") and enemy.type != "beam-tower":
        hero.cast("chain-lightning", self)
    elif enemy and hero.canCast("time-travel") and hero.health < 1800:
        hero.cast("time-travel", self)
    elif enemy:
        hero.attack(enemy)

Gear:
image

cool 200 characterssss

wait how u use time travel i never use them before

It’s the watch’s powerup and once you activate it it will continue your code for three seconds and then put you back where you were when you activated it.

so it basiclly return back time?

But only for the person you “cast” it on

oh i should use that