-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspawner.js
71 lines (60 loc) · 3.5 KB
/
spawner.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
var spawnerCode = {
run: function(spawner) {
/*if (Game.time%5 == 0) {
var isTime = true;}
else{
var isTime = false;
}*/
var isTime = true;
//basic harvester spawning; CARRY MOVE WORK; cost: 200
var harvestersbasic = _.filter(Game.creeps, (creep) => creep.memory.type == 'harvester basic');
if (harvestersbasic.length != 0 && isTime && Memory.numbers.prevHBcount !== harvestersbasic.length) {
console.log("Basic Harvesters: " + harvestersbasic.length)
}
Memory.numbers.prevHBcount = harvestersbasic.length
if(harvestersbasic.length < 2) {
var newName = spawner.createCreep([WORK,CARRY,MOVE], undefined, {role: "harvester", type: "harvester basic"});
console.log("Spawning new basic harvester: " + newName);
}
//basic upgrader spawning; CARRY MOVE WORK; cost: 200
var upgradersbasic = _.filter(Game.creeps, (creep) => creep.memory.type == "upgrader basic");
if (upgradersbasic.length != 0 && isTime && Memory.numbers.prevUBcount !== upgradersbasic.length) {
console.log("Basic Upgraders: " + upgradersbasic.length)
}
Memory.numbers.prevUBcount = upgradersbasic.length
if(upgradersbasic.length < 2) {
var newName = spawner.createCreep([WORK,CARRY,MOVE], undefined, {role: "upgrader", type: "upgrader basic"});
console.log("Spawning new basic upgrader: " + newName);
}
//basic builder spawning; ; CARRY MOVE WORK; cost: 200
var buildersbasic = _.filter(Game.creeps, (creep) => creep.memory.type == "builder basic");
if (buildersbasic.length != 0 && isTime && Memory.numbers.prevBBcount !== buildersbasic.length) {
console.log("Basic Builders " + buildersbasic.length);
}
Memory.numbers.prevBBcount = buildersbasic.length
if (buildersbasic.length < 2) {
var newName = spawner.createCreep ([WORK, CARRY, MOVE], undefined, {role: "builder", type: "builder basic"})
console.log ("Spawning new basic builder: " + newName)
}
//basic repairer spawning; CARRY MOVE WORK; cost: 200
var repairersbasic = _.filter(Game.creeps, (creep) => creep.memory.type == "repairer basic");
if (repairersbasic.length != 0 && isTime && Memory.numbers.prevRBcount != repairersbasic.length) {
console.log("Basic Repairers " + repairersbasic.length);
}
Memory.numbers.prevRBcount = repairersbasic.length
if (repairersbasic.length < 2) {
var newName = spawner.createCreep ([WORK, CARRY, MOVE], undefined, {role: "repairer", type: "repairer basic"})
console.log ("Spawning new basic repairer: " + newName)
}
//image
if(Game.spawns["Home"].spawning) {
var spawningCreep = Game.creeps[Game.spawns["Home"].spawning.name];
Game.spawns["Home"].room.visual.text(
"Spawning" + spawningCreep.memory.type,
Game.spawns["Home"].pos.x + 1,
Game.spawns["Home"].pos.y,
{align: "left", opacity: 0.8});
}
}
};
module.exports = spawnerCode;