Say command inconsistent?


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];

    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 “”!”.


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!', ...);


Oh, that sounds like a bug I need to fix! I’ll track it over here:


I’ve adjusted the code to reset the say() if the message is the same but the data is different. How about now?