-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpatch.powerCreep.js
More file actions
24 lines (21 loc) · 816 Bytes
/
patch.powerCreep.js
File metadata and controls
24 lines (21 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const CreepMover = require("creepmover");
const PathBuilder = require("pathbuilder");
const ff = require("helper.friendFoeRecognition");
PowerCreep.prototype.goTo = function(target, options) {
// TODO: make this the default
if(options && options.newPathing) {
let mover = new CreepMover(this, target, options);
return mover.move();
}
let builder = new PathBuilder();
options = options || {}
if(options.avoidHostiles) {
builder.avoidHostiles = true;
if(_.some(ff.findHostiles(this.room), (c) => _.some(c.parts, (p) => p.type === ATTACK || p.type === RANGED_ATTACK))) {
options.reusePath = 0;
}
}
options.costCallback = builder.getAdditiveCallback();
return this.moveTo(target, options);
}
PowerCreep.prototype.isCreep = true;