Current script (thx th_pion for base)

github.com/thPion/Screeps-Nooby-Guide
This commit is contained in:
2018-05-17 12:01:49 +02:00
parent 67a1270663
commit 220a110ae1
13 changed files with 807 additions and 0 deletions

18
src/prototype.tower.js vendored Normal file
View 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);
}
};