Bash 'em all. Please Help


#1
while(true) {
  var enemies = hero.findEnemies();
  var enemyIndex = 0;
while(enemyIndex < enemies.length) {
    var enemy = enemies[enemyIndex];
    hero.bash(enemy);
    hero.moveXY(40, 33);
    enemyIndex ++;
 }
}

The thing is that when hero bashes enemy[0], it can’t reach bombs so enemy[0] stays alive, but when hero bashes enemy[1,2,3] it works for them.
So may be there is a bug or something. Can you please help me with that. Thank you.


#2

if (hero.isReady(‘bash’) && hero.isPathClear(hero.pos, enemy.pos))
Before hero.bash(enemy) it’s much safer to check if bash is ready and if path to the enemy is clear. After blowing all fire traps it’s easy to collect the gold.


#3

Doesn’t work for me.


#4

see your glasses
image


#5

I still have the same problem - when hero bashes enemy[0], it can’t reach bombs so enemy[0] stays alive, but when hero bashes enemy[1,2,3] it works for them.


#6
while (true) {
    var enemies = hero.findEnemies();
    var enemyIndex = 0;
    while (enemyIndex < enemies.length) {
        var enemy = enemies[enemyIndex];
        if (hero.isReady('bash') && hero.isPathClear(hero.pos, enemy.pos))
            hero.bash(enemy);
        hero.moveXY(40, 33);
        enemyIndex++;
    }
}

only this code work Ok


#7

Man. It does not.
Same troubles.
Try it for your self. Just paiste the code.
https://codecombat.com/play/level/bash-em-all?


#8

try this link https://codecombat.com/play/level/bash-em-all?session=5aa16b726353c7002936fb54


#9
while (true) {
    var enemies = hero.findEnemies();
    var enemyIndex = 0;
    while (enemyIndex < enemies.length) {
        var enemy = enemies[enemyIndex];
        if (hero.isReady('bash') && hero.isPathClear(hero.pos, enemy.pos)) 
            hero.bash(enemy);
            hero.moveXY(40, 33);
        enemyIndex++;
  }
  
      var items = hero.findItems();
       var itemIndex = 0;
       while(itemIndex < items.length) {
        var gem = items[itemIndex];
        if(hero.isPathClear(hero.pos, gem.pos)) 
         hero.moveXY(gem.pos.x, gem.pos.y);
       itemIndex ++;
  }
 
}

So here is my code
It works for your hero Ida
But it doesn’t for my Ida, she just stops in the middle.

i’m depressed :slightly_frowning_face:


#10

If you want a help tailored to your hero try this:
1 - open https://codecombat.com/play/level/bash-em-all
2 - run image
3 - with Chrome browser Ctrl+Shift+I or


4 - Developer Tools will open

5 - Seacrch for the string
|Thor's Archer| Generated random seed -1099223392 of type submissionCount from sessionIDs 5aa16b726353c7002936fb54 submissionCount 2
6 - Copy the number of your sessionIDs - it is like 5aa16b726353c7002936fb54
7. after https://codecombat.com/play/level/bash-em-all put
?session=5aa16b726353c7002936fb54 to have link https://codecombat.com/play/level/bash-em-all?session=5aa16b726353c7002936fb54 as a whole
8 - post it to get help

as a side note: I tried your code and it runs flawlessly with my hero