Summits gate is toooooo slow

Level “summits gate”. Work very slow on my PC at workplace, ok (that PC is not too powerfull). But PC at home has i5-6500 and 16gb ddr4 ram, aaaand… same situation. It is very slow after second gate, maybe 1-2 fps. Impossible to control. Tried on chrome and mozilla. Maybe problem in the my code?

var catapults = hero.findByType("catapult");

hero.comPal = function(){
   for(var i = 0; i < paladins.length; i++){
var paladin = paladins[i];
hero.command(paladin, 'move', {x:(hero.pos.x-10), y: hero.pos.y});
hero.command(paladin, 'cast', 'heal', hero);
}
};

hero.comArch = function(){
    for(var a = 0; a < archers.length; a++){
var archer = archers[a];
if (bflag){hero.command(archer, 'defend', {x:bflag.pos.x, y: bflag.pos.y});}
else {hero.command(archer, 'defend', hero);}}
};

hero.comSold = function(){
    for(var s = 0; s < soldiers.length; s++){
var soldier = soldiers[s];
if (bflag){hero.command(soldier, 'defend', {x:bflag.pos.x, y: bflag.pos.y});}
else {hero.command(soldier, 'defend', {x:hero.pos.x+10, y:hero.pos.y});}}
};

hero.comGrif = function(){
    hero.summon("griffin-rider");
    var griffs = hero.findByType('griffin-rider');
    for(var g = 0; g < griffs.length; g++){
var grif = griffs[g];
hero.command(grif, 'defend', hero);}
};

hero.comHero = function(){
    var thrower = throwers[t];
    for (var t = 0; t< throwers.length; t++){
    if (thrower && hero.distanceTo(thrower) < 20  && thrower.health > 0 ) {hero.attack(thrower);}}
    
      for (var w = 0; w< warlocks.length; w++){
    var warlock =warlocks[w];
    if (warlock && hero.distanceTo(warlock) < 20  && warlock.health > 0 ) 
    {
        if(hero.canElectrocute(warlock)){hero.electrocute(warlock);}
        else{hero.attack(warlock);}
    }
    }
     
           for (var v = 0; v< witches.length; v++){
    var witch =witches[v];
    if (witch && hero.distanceTo(witch) < 20  && witch.health > 0 ) 
    {
        if(hero.canElectrocute(witch)){hero.electrocute(witch);}
        else{hero.attack(witch);}
    }
    }
     
     if (gflag)
    {
        if(hero.isReady("jump")){hero.jumpTo({x:gflag.pos.x, y: gflag.pos.y});}
        hero.pickUpFlag(gflag);
    }
       else{ 
           var enemy = hero.findNearest(enemies);
    if(hero.isReady("bash")&&hero.distanceTo(enemy)<5){hero.bash(enemy);}
   if(!gflag){hero.attack(enemy);}}
};


loop {
    var gflag = hero.findFlag("green");
    var bflag = hero.findFlag("black");
   var vflag = hero.findFlag("violet");
   
   var paladins = hero.findByType('paladin');
var archers = hero.findByType('archer');
var soldiers = hero.findByType('soldier');
   
   var throwers = hero.findByType("thrower");
   var warlocks =hero.findByType("warlock");
   var ogres = hero.findByType("ogre");
   var witches = hero.findByType("witch");
   
   var enemies = hero.findEnemies();
      
      if (hero.gold > hero.costOf("griffin-rider")){hero.comGrif();}
      
       var catapult = hero.findNearest(catapults);
       if (catapult && hero.distanceTo(catapult) < 15 && catapult.health > 0) {hero.attack(catapult);}
       
    hero.comPal();
    hero.comArch();
    hero.comSold();
    hero.comHero();
}


How is the framerate before the second gate? The level does need some performance optimization, it’s true. Do you see any different changing your hero.attack(warlocks) to warlock and likewise for hero.attack(witches) so that you are attacking your target instead of the array?

1 Like

Do you see any different changing your hero.attack(warlocks) to warlock and likewise for hero.attack(witches)

Yep ))) my bad, thank you. But anyway, before second gate destroyed fps smooth, and after it drops to freezes.
Two different PC: office pc windows 7 -32bit, home PC windows 10 -64bit. Same perfomance.
On your PC same behaviour?

Upd:
Beat it in a “blind-slideshow-mode”. Awful level. :grimacing: