forked from VladThePaler/screeps.behaviour-action-pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreep.action.bulldozing.js
30 lines (30 loc) · 1.11 KB
/
creep.action.bulldozing.js
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
30
const action = new Creep.Action('bulldozing');
module.exports = action;
action.maxPerAction = 2;
action.maxPerTarget = 1;
action.isValidTarget = function(target) {
if (!target.room.my && target.room.controller && target.room.controller.safeMode) return false;
return target instanceof ConstructionSite && Task.reputation.notAlly(target.owner.username);
};
action.newTarget = function(creep) {
const target = _(creep.room.constructionSites)
.filter(action.isValidTarget)
.max(target => {
let rating;
if (target.structureType === STRUCTURE_SPAWN) {
rating = 20000;
} else {
rating = 10000;
}
rating += target.progress / target.progressTotal * 10000;
rating -= creep.pos.getRangeTo(target);
return rating;
});
if (target instanceof ConstructionSite) return target;
};
action.work = function(creep) {
return creep.move(creep.pos.getDirectionTo(creep.target));
};
action.onAssignment = function(creep) {
if (SAY_ASSIGNMENT) creep.say(String.fromCodePoint(0x1F4CC), SAY_PUBLIC);
};