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

Treasure Cave - fire-traps don't blow up after 5 sec [SOLVED]

#1

Hi there!

I am not able to finish this level, because fire-traps just don’t blow up after 5 sec. Probably it’s my fault and I did something wrong. Actually, I tried to solve it in a few ways and nothing.

Please help me!
This is a video of my tries: http://recordit.co/hqtd57cq9x

and screenshot

1 Like
#2

This level must be preset for the specific spot to place the mine. The X in the clearing above the camp is where you are supposed to place the mine. It will draw the Yeti up there while you circle around.

1 Like
#3

Thank you! I tried, it worked. For some reason I still can’t collect all coins, but I’ll try to figured it out.

#4

Finally, my code looks like this, but I think it’s cheating :smiley:

hero.wait(2);
hero.buildXY("fire-trap", 64, 44);
hero.moveXY(73, 43);
hero.cast("invisibility", hero);
hero.moveXY(43, 10);
var enemy = hero.findNearestEnemy();
if (enemy && hero.canCast("summon-undead", enemy)) {
    hero.cast("summon-undead");
}
hero.moveXY(25, 37);
for (var i = 0; i <= 3; i++) {
    if (i%2 === 0) {
        hero.moveXY(hero.pos.x - 5, hero.pos.y);
    }
    else {
        hero.moveXY(hero.pos.x + 5, hero.pos.y);
    }
    hero.moveXY(hero.pos.x, hero.pos.y - 2);
}
hero.buildXY("fire-trap", 16, 32);
hero.moveXY(68, 10);

and video http://recordit.co/tlxsdLMWlO

edit: @ xython mine is 20 without optimization. I tried to optimize and it became too fast :slight_smile: and I had to change a code a bit.

#5

It’s more interesting to see your solution as a video :-). And copy&paste your code doesn’t run without some minor corrections- so it isn’t a solution to be deleted-). I congratulate your decision to post a video - this is so rare in the forum.
A visualization of possible solution with ‘simple’ hero - https://player.vimeo.com/video/334179359?autoplay=1
I had difficulties with hero.findItems() - so it’s a little bit cheating - hard coded coins position…
Edit: @korven - what is your time? Mine is 17.8 without optimization and I think you must move faster with Hushbaum. One reason to be slow I think is the moveXY action - I almost never use it replacing with a code like :

while(hero.distanceTo(pos) > 0) 
  hero.move(pos);

Without cheating ( finding all coins and gems in every seed without hard coded position, same path, same hero and adding at some point invisibility time is 17.1 s. I think a counterclockwise motion with another hero and invisibility can be better, but it’s enough is enough… :slight_smile:

2 Likes
#6

Good job on completing the level! Also good job on getting that far in codecombat! :+1:
As a reminder we encourage that when you post your code, post it according to our community guidlines.
Basically all you have to do is put these ` three times no spaces before and after your code!
so this:

hero.attack(enemy)

becomes:

hero.attack(enemy)

This is what it would look like

This makes it easier to read your code and helps us best figure out the solution to your problem!

Good job again with the level!
:fox_face::fox_face::fox_face:
@Luke10

1 Like
#7

Thank you very much!
I fixed it. Completely agree with you that code looks much better

1 Like
#8

You’re Welcome :smile:
Happy Coding
-@Luke10