Help with "stillness in motion"


#1

I need help in “stillness in motion” . Here is my code. when i run this code it says that " this.shield();" is not a function. and my hero dies. What am i doing wrong? Please help. Thank you.

    var enemy = this.findNearestEnemy();
    // If there is an enemy, then...
    if(enemy) {
        var distance = this.distanceTo(enemy);
        
        // Create a distance variable with distanceTo.
       
        // If the distance is less than 5 meters, then attack.
                if(distance < 5){
                  this.attack(enemy);
        }
        
        // Else (the enemy is far away), then shield.
                 else{
                    this.shield();
                 }
                               
    // Else (there is no enemy)}...
   }  else {
        // ... then move back to the X.
        this.moveXY(40, 34);
    }
}

#2

What shield do you have equipped?


#3

Also, just for reference use this.isReady() for the shield ability.


#4

Thank you guys. I did not realize that my hero did not have a shield. so i changed my hero, equipped her with shield and sword, and i got through.


#5

No problem, Reshmi_Naveen. :smile: :smile: