Basically, my code isn’t going in order, I am placing buildings in different spots but the code is making some buildings be upgraded.
(also please tell me if this is technically a bug)
(here is my code thing)
Is this inside an event handler that controls one of your guards? If so, you have two guards, so there would be two copies of this code running in parallel. It’s better to do your tower building logic separate from your guard logic.
var guards = hero.findMyGuards();
const guard1 = guards[0];
const guard2 = guards[1];
const place = data.place;
var guard1CanUseRoar = guard1.isReady("roar");
var guard2CanUseRoar = guard2.isReady("roar");
var typeMonster = hero.getMonsterParameters("ogre", "phoneix");
function moveRoar1() {
let findNearestEnemy1 = guard1.findNearestMonster();
if (guard1CanUseRoar) {
guard1.special("haste");
guard1.moveTo(30, 57);
guard1.special("roar");
if (findNearestEnemy1) {
guard1.attack(findNearestEnemy1);
}
else {
guard1.moveTo(30, 57);
}
}
else {
guard1.moveTo(30, 57);
guard1.attack(findNearestEnemy);
}
}
function moveRoar2() {
let findNearestEnemy2 = guard2.findNearestMonster();
if (guard2CanUseRoar) {
guard2.special("haste");
guard2.moveTo(30, 45);
guard2.special("roar");
if (findNearestEnemy2) {
guard2.attack(findNearestEnemy2);
}
else {
guard2.moveTo(30, 45);
}
}
else {
guard2.moveTo(30, 45);
guard2.attack(findNearestEnemy2);
}
}
I’ve formatted the code, but I’m not sure whether you prefer two spaces or four spaces (I used two because that’s what the majority of the code already uses).