Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Desert Combat (Help Please)

Hey guys I need help with desert combat because my hero does nothing at all.

Here’s my code:

// while-loops repeat until the condition is false.

var x = x + 0;
var y = y - 10;

var ordersGiven = 0;
while (ordersGiven < 5) {
    // Move down 10 meters.
    hero.moveXY(x, y);
    // Order your ally to "Attack!" with hero.say
    // They can only hear you if you are on the X.
    hero.say("Attack!");

    // Be sure to increment ordersGiven!
    ordersGiven + 0;
}

while(true) {
    var enemy = hero.findNearestEnemy();
    // When you are done giving orders, join the attack.
    if (ordersGiven == 5) {
        hero.attack(enemy);
    }
}

Here put

orderGiven ++;

Here put

var x = hero.pos.x;
var y= hero.pos.y

Before this put

y -= 10
1 Like

Thanks @AnSeDra !! (20 chars)

Did it work? :face_with_raised_eyebrow:

No I just replied in the first second i havent tried it yet

Ok, then try it out.

Yes I tried it and it did I must be pitied for my mistaken ways (I mean thanks)

No problem! Try to learn from your mistakes, alright?

1 Like

okay @AnSeDra!! I will

Then, you can mark the solution, oh and do not make multiple topics about the same level, ok?

1 Like

I turned the other into an off topic

I did 2 so people don’t think it’s solved…

and tried to delete the 1st one

…And okay I won’t anymore