-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrole.claimer.js
More file actions
34 lines (31 loc) · 962 Bytes
/
Copy pathrole.claimer.js
File metadata and controls
34 lines (31 loc) · 962 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
25
26
27
28
29
30
31
32
33
34
// args = {controllerId}
var util = require('util');
var creepCommon = require('creep.common');
module.exports = (args) => ({
prepare: creep => {
const roomName = 'E39S45';
const controller = Game.getObjectById(args.controllerId);
if (controller) {
if (creep.pos.inRangeTo(controller, 1)) {
return true;
} else {
creep.moveTo(controller, {visualizePathStyle: {stroke: '#ffffff'}});
return false;
}
} else {
creep.moveTo(new RoomPosition(10, 10, roomName));
return false;
}
},
source: creep => {
return true;
},
target: creep => {
const target = Game.getObjectById(args.controllerId);
var result = creep.claimController(target);
if (result != OK) {
console.log('[INFO] claimController failed: ' + result);
}
return false;
}
});