New Level: Shield Rush


#1

Level ends before second wave engages.

Code used:
if (this.isReady(“cleave”))
this.cleave(this.findNearestEnemy());
else
this.shield();


#2

I’ve fixed it up now so that it’ll keep going. You’ll probably want to put that code in a loop, though.


#3

Works correctly now, and a loop was indeed needed! Is there a way to mark this as solved now?


#4
loop
{
    if (this.isReady("cleave")); 
    {
        this.cleave(this.findNearestEnemy());
    }
    else 
    {
    this.shield();
    }
}

I dont understand what is my mistake, anyone can help me?


#5

Remove the semicolon after your if statement as it ends the statement prematurely. It’s similar to not using the semicolon after else as it’s a condition.


#6

Thanks so much for this post!! lol i also had the semi colon and tried for half an hour to find the problem before i checked here. all fixed now :smiley:


#8

I tried to do this level in Clojure and it seems as if shield is not working right? I can’t survive until cleave is ready again. When I did this in python, shield() had a different sprite and I could tell I was taking less damage. In Clojure (.shield this) did not change the sprite and might not be lowering damage?

This is the code I thought would work.

(dotimes [n 100]
    (if (.isReady this "cleave")
        (.cleave this (.findNearestEnemy this))
        (.shield this)
    )
)

#9

If you reverse the order of the if/else clauses, can you get the shield to work? (Wondering if it’s a problem with shield or our if-statements in Clojure.)


#10

The if/else seems to be working because I can replace shield with (.say this n) and get what iteration I’m on. I tried putting just a shield in a loop and I seem to die about the same rate as if I have no code.

I can create a new thread of a github issue if there is a better place for this.


#11

I think it might be related to this one: https://github.com/codecombat/aether/issues/124


#12

It doesn´t work to me:

loop {
    if (this.isReady("cleave"))
this.cleave(this.findNearestEnemy());

else
this.shield();

}

#13

I found I didn’t survive until the second cleave was ready (javascript), but you could try moving to the bottom right of the field, this gives you a it more time without being attacked, and then the cleave becomes ready.


#14

It´s make me crazy, i quick!


#15

It seems like something has changed to cause this level not to pass anymore with my old working code. Perhaps the newer item have less health to survive the second attack now. Nick, could you take a look?

loop {
    if (this.isReady("cleave"))
        this.cleave(this.findNearestEnemy());
    else
        this.shield();
}

#16

Ah, thanks for the heads up! We had noticed a typo with the female ogre munchkin speed and corrected it, but that broke the balance in this level. I’ve adjusted it again; let me know how it goes.


#17

This code should work:

loop:

if self.isReady("cleave"):
    enemy = self.findNearestEnemy()
    self.cleave(enemy)

else:
    self.shield()
  self.attack(enemy)

if it doesn’t maybe you don’t have enough health???


#18

I’ve been stuck for the past 30 minutes, not sure what I did wrong.


#19

I think you don’t have enough health to survive until the second cleave is ready. You might need to upgrade your armor.


#20

Yeah, Hattori isn’t quite as tough as Tharin or Anya (he’s faster and does more damage), so he needs more armor to survive levels like this.


#21

Please Check the shield action if working or not using python language , i tried to use it even before cleaving them and it doesn’t work , The if/else stat is working good but the shield function ain’t working pls fix it