Here are 2 commands I’ve scribbled up I figured could be very usefull to other people.

```
this.formRing = function(units, place, size) {
for(var u=0; u < units.length; u++) {
var angle = Math.PI * 2 * (u / units.length);
var defendPos = {x:place.x, y:place.y};
defendPos.x += size * Math.cos(angle);
defendPos.y += size * Math.sin(angle);
this.command(units[u], "defend", defendPos);
}
};
this.formShield = function(units, place, size, target){
var tangR = 0;
if(target){
tangR = Math.atan2(target.pos.y-place.y, target.pos.x-place.x);
}
for(var u=0; u < units.length; u++) {
var angle = Math.PI * 2 * (u / units.length);
var realU = u;
if(tangR){
angle = tangR+(Math.PI * (Math.cos(angle/2)-1));
realU = Math.floor(((tangR)/(Math.PI*2))*units.length)-u;
while(realU >= units.length){
realU -= units.length;
}
while(realU < 0){
realU += units.length;
}
}
var defendPos = {x:place.x, y:place.y};
defendPos.x += size * Math.cos(angle);
defendPos.y += size * Math.sin(angle);
this.command(units[realU], "defend", defendPos);
}
};
```

Example use:

```
this.formRing(this.findByType("archer"), {x:77,y:61}, 6);
this.formShield(this.findByType("soldier"), this.pos, 12, enemy);
```

Where the shield function will automatically do this when there is a target: