forked from rasmusbergpalm/screeps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtowers
23 lines (21 loc) · 774 Bytes
/
towers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var towers = {
/** @param {Game} game **/
tick: function() {
towers = Game.spawns.Spawn1.room.find(FIND_MY_STRUCTURES, {
filter: { structureType: STRUCTURE_TOWER }
})
_.forEach(towers, function(tower){
var closestDamagedStructure = tower.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => structure.hits < structure.hitsMax
});
if(closestDamagedStructure) {
tower.repair(closestDamagedStructure);
}
var closestHostile = tower.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if(closestHostile) {
tower.attack(closestHostile);
}
})
}
};
module.exports = towers;