Commanding your troops


#1

Hello I’m playing multiplayer mode and I have 3 questions,

1- Is there any place that I can find all commands in this.say()?
2- Can I write functions for troops ?
3- Is it possible to command specific troops to specific targets?

I tried something like this not sure if something like this is possible :

     for (var l = 0; l < archers.length; ++l) {
        if(throwers !== null)
        {
            archers[l].target = ironJaw;
            this.say("Attack, " + archers[l].id, { target: throwers[0] });
        }
        else if(brawlers !== null)
        {
            archers[l].target = brawlers[0];
            this.say("Attack , " + archers[l].id + " " + brawlers[0].id, { target: brawlers[0] });
        }
    }

#2

Hi @Burkay_Ozdemir! Currently the simple say commands are listed in the default code: 'move', 'defend', 'follow', and 'attack'. If you want to have only a subset of your units obey the command, add type: 'archer' to the data, like:

this.say("Attack " + throwers[0].id, {type: 'archers', target: throwers[0]});

But there isn’t more fine-grained control than this in Dungeon Arena. However, in Brawlwood, you can not only write all the logic for all the soldiers, but also their hear(speaker, message, data) callbacks, so you have full control. Give it a try: http://codecombat.com/play/ladder/brawlwood


Desert Combat - What am I missing?
#3

This is a very interesting question. I was searching for the same. I would like to give individual orders to different troops.

Since the method this.Say cant do it. Can I modify the data directly?
For example something like this:

var friends = this.getFriends();
for (i=0; i < friends.length; i++){
 var current= friends[i];
 friends[i].action = move;
 friends[i].targetPos = new Vector ( x: 50, y: 20 + Math.random()*30 );
}

#4

Nope; you can’t directly assign properties to your friends; the API protection disallows that.


#5

Btw, it seems to be type: “archer” (singular).

Got me stuck for a while.


#6

Good point; sorry about that typo!