Siege of Stonehold Help!


#21

YOU MUST TAKE THE HAMMER AND HAVE MINIMUM 300 HEALTH
javascript

this.buildXY(“fire-trap”, 20,52);
this.buildXY(“fire-trap”, 22,52);
this.buildXY(“fire-trap”, 22,56);
this.moveXY(39, 83);
this.buildXY(“fire-trap”, 18, 88);
this.buildXY(“fire-trap”, 20, 84);
this.buildXY(“fire-trap”, 21, 82);

this.buildXY(“fire-trap”, 32, 72);
this.buildXY(“fire-trap”, 32, 68);
this.buildXY(“fire-trap”, 32,64);

this.buildXY(“fire-trap”, 28, 72);
this.buildXY(“fire-trap”, 28, 68);
this.buildXY(“fire-trap”, 28,64);

this.buildXY(“fire-trap”, 24, 72);
this.buildXY(“fire-trap”, 24, 68);
this.buildXY(“fire-trap”, 24,64);

this.buildXY(“fire-trap”, 20, 72);
this.buildXY(“fire-trap”, 20, 68);
this.buildXY(“fire-trap”, 20,64);

this.moveXY(1, 67);
this.moveXY(2, 67);
loop {
this.shield();

}
//it works great


#22

I need help on this level, if anybody can. I’ve already tried the fire trap approach, but first off, I can’t get it to work, and second, I don’t think that’s the right way to go about doing this.
I’m trying to make Tharin go for the enemies if they are a certain distance away, but when I try to use this:
var enemy = this.findNearestEnemy();
var distance = this.distanceTo(enemy);
if (distance < 11) {
this.cleave(enemy)
It doesn’t work. It says: Find the distance to a target unit, and I’m not sure what that means. Also, can anybody help me so that I only use cleave if it is ready, otherwise I attack? I’ve tried using the this.isReady(“cleave”), but I’m not sure where to put it in my if function. Should I put it in the parenthesis (where I have distance < 11 right now), or should I put it somewhere else? Can anybody help me? Thanks.


#23

Hm… Okay, then. I managed to beat the level with the fire traps, and I think I survived with full health, too. However, I would still like to know another more… subtle way, I guess, of doing this level. But anyhow, WOOHOO!! I made it to the desert!!!


#24

Well I use ninja (the first ranged char [not mage])
and I use the lightning stick I move to the entrance of the “fort” and shoot every-thing
since the lightning stick is a one shot KO it should be pretty easy but you need 300+ health to take down the last orge


#25

I just added a better error message for that one, @abducktion: basically, you’re trying to check the distance to an enemy, but you can’t see an enemy, so you get an error. Put an if (enemy) check around anything that tries to find distanceTo(enemy).

Lightning stick surely makes this level pretty easy, but it’s quite expensive!


#26

Well I am a subscriber so its not that much


#27

Thank you ! Used your instructions with this javascript code :

loop {
    var flag = this.findFlag();
    var enemy = this.findNearestEnemy();
    if (flag) {
        this.pickUpFlag(flag);
    }
    if (enemy) {
        if (this.distanceTo(enemy) < 50) {
            if (this.isReady("cleave")){
                this.cleave(enemy);
            }
            else {
                this.attack(enemy);
            }
        }   
    }
}

#28

You must have 800+ health and do the following:

loop {
    var enemies = this.findEnemies();
    var friends = this.findFriends();
    for(var i = 0; i < enemies.length; ++i) {
        var enemy = enemies[i];
        if (enemy) {
            this.attack(enemy);
        }
var friend = friends[i];
    if(friend && friend.type == "archer" && friend.type == "soldier") {
    var fx = friend.pos.x; 
    var fy = friend.pos.y;
    this.move(fx,fy);
}   
}
}

#29

Tell us how and how you did it @shoodong


#30

Tell us how to do it, or they will suffer


#31

I am not a sub and i beat it with 853 health


#32

Your code needs to have this

if(enemy && this.distanceTo(enemy) < 10) {
    // Your code here
}

#33

Or you can go in with sub 300 health, and plant mines with flags, and move around with flags :stuck_out_tongue: You don’t need 800 hp for this level, cept if you’re using a “Let’s go attack everything” plan


#34

I used a “Let’s go attack everything” so yeah


#35

what is wrong with my code I don’t know what it is


#36

The error message says variable declaration.
You are declaring a variable in the middle of an if statement. You can’t do that.

You code should read:

distance = self.distanceTo(enemy)
if distance < 10:
    do stuff

#37

thankyou but the message still says there is something wrong with the code


#38

Read the error message. What does it say? The big red boxes usually give you clues as to what is wrong.

This error message means that you are trying to put null (nothing) into the distanceTo() method. If there is not an enemy you don’t want to find the distance to it.


#39

THANK YOU SOOOO MUCH, I DEFETED THIS LEVEL SO EASY!!! THANK YOU!!!

Nicole… :smiley: :smile: :wink: :heart: :heart: :heart:


#40

I just moved where the enemy was and barely attacked them, the peasants did pretty much all of the work…
From the way you guys were describing it I thought that it would be really hard, but I only got hit once or twice…
Unless it was made easier by the time I did it, that could be it to…
also my code was ( I use javascript )
while(true) {
var flag = hero.findFlag();
var enemy = hero.findNearestEnemy();
if(flag) {
var flagPos = flag.pos;
var flagX = flag.pos.x;
var flagY = flag.pos.y;
hero.moveXY(flagX, flagY);
hero.pickUpFlag(flag);
}
else {
if(enemy) {
hero.attack(enemy);
}
}
}
simple right?