Summit gate [HELP]

void summonGriffin(){
    if(hero.gold > hero.costOf("griffin-rider")){
        hero.summon("griffin-rider");
    }
}

void griffin(auto friend){
    auto enemy = hero.findNearest(hero.findByType("fangrider"));
    
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

void attack(auto enemy){
    if(enemy){
        if(hero.isReady("jump")){
            hero.jumpTo(enemy.pos);
        }else if(hero.isReady("bash")){
            hero.bash(enemy);
            hero.cast("chain-lightning", enemy);
        }else{
            hero.attack(enemy);
        }
    }
}

void hero_tactics(){
    auto enemy = hero.findNearest(hero.findByType("catapult"));
    if(hero.time < 35){
        attack(enemy);
    }else{
        auto enemy = hero.findNearestEnemy();
        attack(enemy);
    }
}

void commandTroops(){
    auto friends = hero.findFriends();
    for(int i = 0; i < friends.length; i ++){
        auto friend = friends[i];
        if(friend.type=="soldier"){
            soldier(friend);
        }else if(friend.type == "archer"){
            archer(friend);
        }else if(friend.type == "paladin"){
            paladin(friend);
        }else if(friend.type == "griffin-rider"){
            griffin(friend);
        }
    }
}

auto findWeakest(){
    auto friends = hero.findFriends();
    auto low = 0;
    auto lowest = null;
    for(int i = 0; i < friends.length; i++){
        auto friend = friends[i];
        if(friend.health < low){
            low = friend.health;
            lowest = friend;
        }
    }
    return lowest;
}

auto paladin(auto friend){
    if(friend.canCast("heal")){
        auto low = findWeakest();
        if(low){
            hero.command(friend, "cast", "heal", low);
        }else if(hero.health < hero.maxHealth / 2){
            hero.command(friend, "cast", "heal", hero);
        }
    }else if(friend.health < 200){
        hero.command(friend, "shield");
    }else{
        auto enemy = hero.findNearestEnemy();
        if(enemy){
            hero.command(friend, "attack", enemy);
        }
    }
}

auto soldier(auto friend){
    auto enemy = friend.findNearestEnemy();
    if(hero.time > 15){
        auto enemy = hero.findNearest(hero.findByType("fangrider"));
    }
    
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

auto archer(auto friend){
    auto enemy = hero.findNearest(hero.findByType("fangrider"));
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

void move_fast(auto position){
    if(hero.isReady("jump")){
        hero.jumpTo(position);
    }else{
        hero.move(position);
    }
}

int main() {
    // Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
    move_fast({83, 39});
    while(true) {
        commandTroops();
        summonGriffin();
        hero_tactics();
    }
    return 0;
}

why does paladin not attacking enemies at all and also hero doesn’t break the door after finish stage 1

else if(hero.time < 12){
            stage = 2;
            hero.say("stage 2");
            hero_tactics();
            move_fast({92, 37});

12 seconds have passed, still stage 2 is not active at all.

also.

here the new code


auto stage = 0;
void summonGriffin(){
    if(hero.gold > hero.costOf("griffin-rider")){
        hero.summon("griffin-rider");
    }
}

void griffin(auto friend){
    auto enemy = hero.findNearest(hero.findByType("fangrider"));
    
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

void attack(auto enemy){
    if(enemy){
        if(hero.isReady("jump")){
            hero.jumpTo(enemy.pos);
        }else if(hero.isReady("bash")){
            hero.bash(enemy);
            hero.cast("chain-lightning", enemy);
        }else{
            hero.attack(enemy);
        }
    }
}

void hero_tactics(){
    auto enemy = null;
    if(stage == 1){
        enemy = hero.findNearest(hero.findByType("catapult"));
    }else if(stage == 2){
        enemy = hero.findNearestEnemy();
    }
    
    if(enemy){
        attack(enemy);
    }
}

void commandTroops(){
    auto friends = hero.findFriends();
    for(int i = 0; i < friends.length; i ++){
        auto friend = friends[i];
        if(friend.type=="soldier"){
            soldier(friend);
        }else if(friend.type == "archer"){
            archer(friend);
        }else if(friend.type == "paladin"){
            paladin(friend);
        }else if(friend.type == "griffin-rider"){
            griffin(friend);
        }
    }
}

auto findWeakest(){
    auto friends = hero.findFriends();
    auto low = 0;
    auto lowest = null;
    for(int i = 0; i < friends.length; i++){
        auto friend = friends[i];
        if(friend.type == "paladin" && friend.health < low){
            low = friend.health;
            lowest = friend;
        }
    }
    return lowest;
}

auto paladin(auto friend){
    if(friend.canCast("heal")){
        auto low = null;
       
        if(hero.health < hero.maxHealth * 0.8){
            low = hero;
        }else{
            low = findWeakest();
        }
        
        if(low){
            hero.command(friend, "cast", "heal", low);
        }
    }else{
        auto enemy = hero.findNearestEnemy();
        if(enemy){
            hero.command(friend, "attack", enemy);
        }
    }
}

auto soldier(auto friend){
    auto enemy = friend.findNearestEnemy();
    if(hero.time > 12){
        auto enemy = hero.findNearest(hero.findByType("fangrider"));
    }
    
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

auto archer(auto friend){
    auto enemy = hero.findNearest(hero.findByType("fangrider"));
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

void move_fast(auto position){
    if(hero.isReady("jump")){
        hero.jumpTo(position);
    }else{
        hero.move(position);
    }
}

int main() {
    // Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
    auto catapult = hero.findNearest(hero.findByType("catapult"));
    move_fast({83, 39});
    commandTroops();
    while(true) {
        if(catapult){
            stage = 1;
            
            hero_tactics();
        }else if(hero.time < 12){
            stage = 2;
            hero.say("stage 2");
            hero_tactics();
            move_fast({92, 37});
        }else{
            summonGriffin();
        }
    }
    return 0;
}

can someone tell me why hero.time is not working or i been using it wrong

i don’t do java script but that is a less than sighn not a grater than sighn

yes i know, but previous level i saw they do it like this

Example:

// If it's the first 10 seconds, attack.
        if (hero.time < 10) {
            auto enemy = hero.findNearestEnemy();
            if(enemy && enemy.type != "palisade"){
                hero.attack(enemy);
            }
        }

also the level name is 'Keeping Time" in desert.

i try by using this method

else if(hero.pos.x == 93 && hero.pos.y == 36){
            stage = 2;
            hero.say("stage 2");
            hero_tactics();
            summonGriffin();

why doesn’t it work

void hero_tactics(){
    auto enemy = null;
    if(stage == 1){
        enemy = hero.findNearest(hero.findByType("catapult"));
        if(hero.time < 20){
            move_fast({93, 36});
        }
    }else if(stage == 2){
        enemy = hero.findNearestEnemy();
    }
    

stage 2 still not activated

because of this

if(hero.time < 20){
            move_fast({93, 36});
        }

can anyone help me why hero.time doesn’t work

here full code:


auto stage = 0;
void summonGriffin(){
    if(hero.gold > hero.costOf("griffin-rider")){
        hero.summon("griffin-rider");
    }
}

void griffin(auto friend){
    auto enemy = hero.findNearest(hero.findByType("fangrider"));
    
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

void attack(auto enemy){
    if(enemy){
        if(hero.isReady("jump")){
            hero.jumpTo(enemy.pos);
        }else if(hero.isReady("bash")){
            hero.bash(enemy);
            hero.cast("chain-lightning", enemy);
        }else{
            hero.attack(enemy);
        }
    }
}

void hero_tactics(){
    auto enemy = null;
    if(stage == 1){
        enemy = hero.findNearest(hero.findByType("catapult"));
        if(hero.time < 20){
            move_fast({93, 36});
        }
    }else if(stage == 2){
        enemy = hero.findNearestEnemy();
    }
    
    if(enemy){
        attack(enemy);
    }
}

void commandTroops(){
    auto friends = hero.findFriends();
    for(int i = 0; i < friends.length; i ++){
        auto friend = friends[i];
        if(friend.type=="soldier"){
            soldier(friend);
        }else if(friend.type == "archer"){
            archer(friend);
        }else if(friend.type == "paladin"){
            paladin(friend);
        }else if(friend.type == "griffin-rider"){
            griffin(friend);
        }
    }
}

auto findWeakest(){
    auto friends = hero.findFriends();
    auto low = 0;
    auto lowest = null;
    for(int i = 0; i < friends.length; i++){
        auto friend = friends[i];
        if(friend.type == "paladin" && friend.health < low){
            low = friend.health;
            lowest = friend;
        }
    }
    return lowest;
}

auto paladin(auto friend){
    if(friend.canCast("heal")){
        auto low = null;
       
        if(hero.health < hero.maxHealth * 0.8){
            low = hero;
        }else{
            low = findWeakest();
        }
        
        if(low){
            hero.command(friend, "cast", "heal", low);
        }
    }else{
        auto enemy = hero.findNearestEnemy();
        if(enemy){
            hero.command(friend, "attack", enemy);
        }
    }
}

auto soldier(auto friend){
    auto enemy = friend.findNearestEnemy();
    if(hero.time > 12){
        auto enemy = hero.findNearest(hero.findByType("fangrider"));
    }
    
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

auto archer(auto friend){
    auto enemy = hero.findNearest(hero.findByType("fangrider"));
    if(enemy){
        hero.command(friend, "attack", enemy);
    }
}

void move_fast(auto position){
    if(hero.isReady("jump")){
        hero.jumpTo(position);
    }else{
        hero.move(position);
    }
}

int main() {
    // Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
    auto catapult = hero.findNearest(hero.findByType("catapult"));
    move_fast({83, 39});
    while(true) {
        commandTroops();
        if(catapult){
            stage = 1;
            
            hero_tactics();
            summonGriffin();
        }else if(hero.pos.x == 93 && hero.pos.y == 36){
            stage = 2;
            hero.say("stage 2");
            hero_tactics();
            summonGriffin();
        }else{
            summonGriffin();
        }
    }
    return 0;
}