-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreep.passiveRepair.js
More file actions
29 lines (28 loc) · 1 KB
/
Creep.passiveRepair.js
File metadata and controls
29 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var CreepPassiveRepair = function() {
var workBodyparts = this.getActiveBodyparts(WORK);
var structures = this.room.memory.found.structures;
var repairTargets = this.pos.findInRange(structures, 1, {
filter: function(structure) {
if(structure.hits < structure.hitsMax) {
if(structure.hitsMax - structure.hits > REPAIR_POWER * workBodyparts) {
if(structure.structureType === STRUCTURE_RAMPART) {
if(structure.hits > 100000) {
return false;
} else {
return true;
}
} else {
return true;
}
}
}
}
});
repairTargets.sort(function(a, b) {
return (a.hits / a.hitsMax) - (b.hits / b.hitsMax);
});
if(repairTargets.length > 0) {
this.repair(repairTargets[0]);
}
};
module.exports = CreepPassiveRepair;