Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Desert Combat - Can't attack ogre


I get all my solders to attack the picket line, I move over and help take it down, then just stand there while “Arelt” kills everyone… then me. It’s like he is not listed as an enemy. I even dumbed down the code to a basic attack

// When you're done giving orders, join the attack.
enemy = this.findNearestEnemy();
loop {
    if (enemy) {

I still can’t touch him.


Simple error of placing enemy = outside the loop.


D’OH! Seems obvious now.
Since I attacked the picket line, I didn’t consider it at the time.



as long you are set up the enemy = self.findNerestEnemy() is inside the loop not outside the loop it will not find the enemy or wont attack at all.

for example look good

loop {
enemy = self.findNerestEnemy()
// the code here

other example wont attack

enemy = self.findNerestIEnemy()
loop {
// the code here