If I run the following code for Tharin, my minions will attack the first thrower that pops out, but after it’s dead they start attacking the enemy hero for some reason (ignoring subsequent throwers that get created)? I don’t really understand what’s going on. I also haven’t been able to find any documentation to help me understand the problem.
Edit: This was in Dungeon Arena.
var enemies = this.getEnemies();
var target = null;
for(var i = 0; i < enemies.length; i++) {
if(enemies[i].type == 'thrower')
target = enemies[i];
}
if(target)
this.say("Attack!", {target: target});
Is your hero alive to say attack? This code looks fine, as long as there’s nothing afterward having him say something else. You could debug it by changing the first argument of this.say to “Attack “+target.id+”!”.
Yes, the hero is alive. If I add the debug command you suggested, the target id is right, but the soliders still go after the wrong dude. I think maybe I need to add strategy:‘kamikaze’? Because by default they go after the nearest enemy? Or maybe the one that’s attacking them? Not sure, there seem to be a lot of little weird issues that make it hard to pinpoint any one bug.
It seems like it has to do with the say string changing. I think I get more consistent results if I do this.say('Attack! ' + Math.random(), ...);
than if I do this.say('Attack!', ...);