-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpawn4.js
139 lines (126 loc) · 4.7 KB
/
Spawn4.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
let Spawn4 = {
run: function(spawn) {
let source0 = 0;
let source1 = 0;
let mineCount = 0;
let upgradeCount = 0;
let buildCount = 0;
let repairCount = 0;
let haulCount = 0;
let mineralBotCount = 0;
let mineralManagerCount = 0;
for (let name in Game.creeps) {
let creep = Game.creeps[name];
if (creep.memory.home == spawn) {
if (creep.memory.role == 'mine' && creep.ticksToLive > 200) {
mineCount++;
if (creep.memory.source == 0) {
source0++;
} else if (creep.memory.source == 1) {
source1++;
}
} else if (creep.memory.role == 'upgrade') {
upgradeCount++;
} else if (creep.memory.role == 'build') {
buildCount++;
} else if (creep.memory.role == 'repair') {
repairCount++;
} else if (creep.memory.role == 'haul') {
haulCount++;
} else if (creep.memory.role == 'mineralBot') {
mineralBotCount++;
} else if (creep.memory.role == 'mineralManager') {
mineralManagerCount++;
}
}
}
let nextSource = 0;
if (source0 > 0) {
nextSource = 1;
}
if (haulCount < 1 && Game.spawns[spawn].room.energyAvailable < 750) {
Game.spawns[spawn].createCreep([
MOVE,MOVE,
CARRY,CARRY,CARRY,CARRY
], 'h' + (Game.time), {
'role': 'haul',
'home': spawn
});
} else if (mineCount < 1 && Game.spawns[spawn].room.energyAvailable < 600) {
Game.spawns[spawn].createCreep([
WORK,WORK,
MOVE,CARRY
], 'm' + (Game.time), {
'role': 'mine',
'source': nextSource,
'home': spawn
});
} else if (mineCount < 2) {
Game.spawns[spawn].createCreep([
WORK,WORK,WORK,WORK,WORK,
MOVE,CARRY
], 'm' + (Game.time), {
'role': 'mine',
'source': nextSource,
'home': spawn
});
} else if (haulCount < 1) {
Game.spawns[spawn].createCreep([
MOVE,MOVE,MOVE,MOVE,MOVE,
CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY
], 'h' + (Game.time), {
'role': 'haul',
'home': spawn
});
} else if (buildCount < 0) {
Game.spawns[spawn].createCreep([
WORK,WORK,WORK,
MOVE,MOVE,MOVE,
CARRY,CARRY,CARRY
], 'b' + (Game.time), {
'role': 'build',
'home': spawn
});
} else if (upgradeCount < 1) {
Game.spawns[spawn].createCreep([
WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
MOVE,
CARRY,CARRY,CARRY,CARRY,CARRY
], 'u' + (Game.time), {
'role': 'upgrade',
'home': spawn
});
} else if (repairCount < 1) {
Game.spawns[spawn].createCreep([
WORK,WORK,
MOVE,MOVE,MOVE,
CARRY,CARRY,CARRY,CARRY
], 'r' + (Game.time), {
'role': 'repair',
'home': spawn
});
} else if (mineralBotCount < 0 && Game.spawns[spawn].room.find(FIND_MINERALS)[0].mineralAmount > 0) {
Game.spawns[spawn].createCreep([
MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,
MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,
MOVE,MOVE,MOVE,MOVE,MOVE,
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY
], 'minBot' + (Game.time), {
'role': 'mineralBot',
'home': spawn
});
} else if (mineralManagerCount < 0) {
Game.spawns[spawn].createCreep([
MOVE,
CARRY,CARRY
], 'minManager' + (Game.time), {
'role': 'mineralManager',
'home': spawn
});
}
}
};
module.exports = Spawn4;