-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrole.reserver.js
More file actions
30 lines (27 loc) · 872 Bytes
/
Copy pathrole.reserver.js
File metadata and controls
30 lines (27 loc) · 872 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
// args = {roomName}
var util = require('util');
var creepCommon = require('creep.common');
module.exports = (args) => ({
prepare: creep => {
const s_room = Game.rooms[args.roomName];
if (creep.room != s_room) {
creep.moveTo(new RoomPosition(25, 25, args.roomName), {visualizePathStyle: {stroke: '#ffffff', range: 10}});
return false;
}
const controller = s_room.controller;
if (creep.pos.inRangeTo(controller, 1)) {
return true;
} else {
creep.moveTo(controller, {visualizePathStyle: {stroke: '#ffffff', range: 1}});
return false;
}
},
source: creep => {
return true;
},
target: creep => {
const target = Game.rooms[args.roomName].controller;
creep.reserveController(target);
return false;
}
});