Current script (thx th_pion for base)
github.com/thPion/Screeps-Nooby-Guide
This commit is contained in:
18
src/prototype.tower.js
vendored
Normal file
18
src/prototype.tower.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
StructureTower.prototype.defend =
|
||||
function () {
|
||||
// find closes hostile creep
|
||||
var target = this.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
|
||||
// if one is found...
|
||||
if (target != undefined) {
|
||||
// ...FIRE!
|
||||
this.attack(target);
|
||||
}
|
||||
|
||||
var closestDamagedStructure = this.pos.findClosestByRange(FIND_STRUCTURES, {
|
||||
filter: (structure) => structure.hits < structure.hitsMax
|
||||
});
|
||||
|
||||
if(closestDamagedStructure) {
|
||||
this.repair(closestDamagedStructure);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user