Desert Combat - Can't attack ogre


#1

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) {
        this.attack(enemy);
    }
}

I still can’t touch him.


#2

Simple error of placing enemy = outside the loop.


#3

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

thanks


#4

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
}