Grim Determination Issue


#1

I’m having trouble with the level Grim Determination. I run my code, no errors, but the function commandFriends() wont run, I have use say() to test this. Here is my code…

this.lowestHealthPaladin = function () {
    var lowestHealth = 99999;
    var lowestFriend = null;
    var friends = this.findFriends();
    for (var f = 0; f < friends.length; f++) {
        var friend = friends[f];
        if (friend.type != "paladin") {
            continue;
        }
        if (friend.health < lowestHealth && friend.health < friend.maxHealth) {
            lowestHealth = friend.health;
            lowestFriend = friend;
        }
    }
    return lowestFriend;
};
this.commandPaladin = function (paladin) {
    var minHealth = 0.8 * paladin.maxHealth;
    if (paladin.canCast("heal") && this.lowestHealthPaladin().health < minHealth) {
        this.command(paladin, "cast", "heal", this.lowestHealthPaladin());
    } else {
        this.command(paladin, "attack", paladin.findNearest(this.findEnemies()));
    }
};
this.commandPeasant = function (unit) {
    var coin = unit.findNearest(this.findItems());
    this.command(unit, "move", coin.pos);
};
this.commandGriffin = function (unit) {
    var enemy = unit.findNearest(this.findEnemies());
    this.command(unit, "attack", enemy);
};
this.commandFriends = function () {
    var friends = this.findFriends();
    for (var i = 0; i < friends.length; i++) {
        var friend = friends[i];
        if (friend.type == "peasant") {
            this.commandPeasant(friend);
        } else if (friend.type == "griffin-rider") {
            this.commandGriffin(friend);
        } else if (friend.type == "paladin") {
            this.commandPaladin(friend);
        }
    }
};
loop {
    this.commandFriends();
}

Thanks in advance for any help. :slight_smile:


#2

This is an issue that will be fixed by our new parser, coming soon.

For now, if you take your commandFriends() code and put it directly into the main loop, that should allow you to keep going. :slight_smile:


#3

Thank you. :slight_smile: