I cannot get nearest unit from custom array, as this.getNearest return null (?)
this.getSoldiersNearBase = function(units){
var arr = ;
for(var i=0;i<units.length;++i){
var u = units[i];
if((u.type===‘soldier’ || u.type===“knight”) && u.pos.x>70) arr.push([u]);
} return arr;};
this.defendBase = function(threat){
this.attack(threat); //ArgumentError is not defined at this line; if(!this.getCooldown('throw')) this.throw(threat); if(!this.getCooldown('jump')) this.jumpTo(threat);};
var enemies = this.getEnemies();
var soldierNearBase = this.getSoldiersNearBase(enemies);
if(soldierNearBase.length > 0){
var threat = this.getNearest(soldierNearBase); this.say(soldierNearBase); //this simple say is to check, that soldierNerBase really constains units// at this moment threat does not contain any information.
/if ask “this.say(threat)” compilier returns “say what?”
this.defendBase(threat);
}