// Form up soldiers and archers in rectangle formations.
int main() {
// The distance between units.
auto step = 8;
// First form up soldiers.
auto sergeant = hero.findNearest(hero.findByType("soldier"));
// The coordinates of the bottom left corner.
auto soldierX = 8;
auto soldierY = 8;
// The width and height of the formation.
auto width = sergeant.rectWidth;
auto height = sergeant.rectHeight;
for (float x = soldierX; x <= soldierX + width; x += 8) {
for (float y = soldierY; y <= soldierY + height; y += 8) {
hero.summon("soldier");
auto lastUnit = hero.built[hero.built.size()-1];
// Command the last built unit by using the x/y variables:
hero.command(lastUnit, "move", {'x':x, 'y':y })
}
}
// Next form up archers.
auto sniper = hero.findNearest(hero.findByType("archer"));
// The coordinates of the bottom left corner.
auto archerX1 = 48;
auto archerY1 = 8;
// The coordinates of the top right corner.
auto archerX2 = sniper.archerX2;
auto archerY2 = sniper.archerY2;
for (float x = archerX1; x <= archerX2; x += 8) {
for (float y = archerY1; y <= archerY2; y += 8) {
// Summon an archer.
hero.summon("archer");
// Find the last built unit.
auto lastUnit = hero.built[len(hero.built)-1];
// Command the last built unit by using the x/y variables:
hero.command(lastUnit, "move", {'x':x, 'y':y })
}
}
return 0;
}
erorr on hero.command()