Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Kelvintaph Burgler, hero dies right away!

https://codecombat.com/play/level/kelvintaph-burgler?

// What eldritch artifacts are these? Don't let them blast you!
// The ice gate will open when both ogres are defeated.
hero.moveXY(32, 23);
while(true) {
  var enemy = hero.findNearestEnemy();
  hero.attack(enemy);
}
if (enemy) {
if (hero.isReady("drain-life")) {
  
  hero.canCast("drain-life", enemy);  
} else {
    hero.attack(enemy);
}
}

Try to build a fence to be protected from the robots. Then after your troops finish the work, you can use flags to help your hero dogde the projectiles.

Ok @AnSeDra I will try that right now! I hope it works.

Ok. Continue this topic if you have any more trobule with this level.

This is my code now. What is wrong?

var friend = hero.findFriends();
hero.buildXY("fence", 23, 13);
while(true) {
   var enemy = hero.findNearestEnemy();
    hero.command(friend, "attack", enemy);
}

Your friends can not attack the robots

But how do I make them attack the ogres

Put friend instead of hero here

And check if there is a enemy

ok thanks i will try that @AnSeDra

It says friend has no method of findNearestEnemy

// What eldritch artifacts are these? Don't let them blast you!
// The ice gate will open when both ogres are defeated.
var friend = hero.findFriends();
hero.buildXY("fence", 23, 13);
while (true) {
    if (enemy) {
        var enemy = friend.findNearestEnemy();
        hero.command(friend, "attack", enemy);
    }
}

Any suggestions because it says: “friend has no method of findNearestEnemy”

Please help I am desperate for help

My friends don’t do anything!

The robots just keep shooting the fence while my friends stay still.

Put an

if (enemy){
     #command to attack
}

To check if there is any enemy to attack

And remember that your friends can not see throught walls

// What eldritch artifacts are these? Don't let them blast you!
// The ice gate will open when both ogres are defeated.
var friend = hero.findFriends();
hero.buildXY("fence", 23, 13);
while (true) {
    if (enemy) {
        var enemy = friend.findNearestEnemy();
        hero.command(friend, "attack", enemy);
    }
}

So do I command them to move them first or ???

Put

Before the if with the attack