Creating a Priority Kill List


#1

In trying to create a priority kill list to survive longer by eliminating shamans and throwers first I wrote the following code below, but my hero’s behavior seems unchanged. I was going for:

  1. go to flag and ignore enemies
  2. kill shamans or throwers
  3. kill anything else

So I created an array to collect just the shamans and throwers, and access them one by one to eliminate them before regular enemies.

Any ideas where my logic went wrong?

loop {
    var flag = this.findFlag();
// regular enemies 
    var enemy = this.findNearest(this.findEnemies());
// first enemies to kill
    var killFirst = this.findByType("thrower" || "shaman");
    var index = 0;
// pick one high priority enemy
    var personOfInterest = killFirst[index];
// start off looking for flag if there's one
    if (flag) {
        this.pickUpFlag(flag);
    }
    else if (personOfInterest) {
        if (this.isReady("warcry")) {
            this.warcry();
        }
        else if (this.isReady("electrocute") && this.canElectrocute(enemy) && this.distanceTo(enemy) < 21) {
            this.electrocute(enemy);
            }
        else if (this.isReady("bash") && this.distanceTo(enemy) < 4) {
            this.bash(enemy);
            }
        else{
            this.attack(enemy);
            }
    }
    else if (enemy) {
        if (this.isReady("warcry")) {
            this.warcry();
        }
        else if (this.isReady("electrocute") && this.canElectrocute(enemy) && this.distanceTo(enemy) < 21) {
            this.electrocute(enemy);
            }
        else if (this.isReady("bash") && this.distanceTo(enemy) < 4) {
            this.bash(enemy);
            }
        else{
            this.attack(enemy);
            }
    }
    else{
        this.shield();
    }
}

Thanks in advance for any advice!


#2

Did you check to see if person of interest ever exists?

var killFirst = this.findByType(“thrower” || “shaman”);

looks pretty, but does it actually work?

Personally, I would expect that it does not…

OH . . . even if it does work, you attack enemy, never person of interest (all the “enemy” inside the if personOfInterest need to be personOfInterest, or you need a enemy = personOfInterest as the first line inside the if)