-
Notifications
You must be signed in to change notification settings - Fork 0
/
depoharvester.js
46 lines (40 loc) · 1.26 KB
/
depoharvester.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const body = [WORK,CARRY,MOVE];
//const depoRooms = [W23S10, W24S10];
module.exports = {
run: function (roomName, depoRooms) {
const creepName = 'depoHarvester_' + roomName;
var creep = Game.creeps[creepName];
const observer = Game.rooms[roomName].observer;
for (var room in depoRooms) {
observer.observeRoom(depoRooms[room]);
const depo = Game.rooms[depoRooms[room]](FIND_DEPOSITS, {
filter: depo => {
return depo.ticksToDecay > 5000;
}
});
if(!depo) {
Memory.depo.depoRooms[room].depopos
}
}
if (!creep) {
autoSpawnCreep(creepName, spawnRoomName);
}
else {
}
}
}
function autoSpawnCreep(creepName, spawnRoomName) {
var spawn = getAvaliableSpawn(spawnRoomName);
if (spawn) {
spawn.spawnCreep(body, creepName, {memory: {role: 'scout' }});
}
}
function getAvaliableSpawn(room) {
for (var spawnname in Game.spawns) {
var spawn = Game.spawns[spawnname];
if (spawn.room.name == room && spawn.spawning == null) {
return spawn;
}
}
return null;
}