-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrole.supergrader.js
131 lines (123 loc) · 3.36 KB
/
role.supergrader.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
/* Super Upgrader drone */
module.exports.role = 'supergrader';
/* sType */
module.exports.sType = 'specialist';
/* Spawn Roster */
module.exports.roster = {
1: 0,
2: 0,
3: 0,
4: 8,
5: 8,
6: 4,
7: 4,
8: 1,
};
/* Costs */
module.exports.cost = {
1 : 0,
2 : 0,
3 : 0,
4 : 1300,
5 : 1800,
6 : 1800,
7 : 1800,
8 : 1800,
};
/* Body Parts at each RCL */
module.exports.body = {
1 : [], 2 : [], 3 : [],
4 : [
WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,MOVE,MOVE
],
5 : [
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,MOVE,
],
6 : [
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,CARRY,
CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,MOVE,
],
7 : [
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,CARRY,
CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,MOVE,
],
8 : [
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,CARRY,
CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,MOVE,
],
};
module.exports.enabled = function (room, debug = false) {
// Define the room
var _room = Game.rooms[room];
var _storage = _room.storage;
// No Storage, no supergraders
if (!_storage || _room.controller.level <= 3) { return false; }
if (_room.memory.charging || _room.controller.level <= 3) {
return false;
} else {
return true;
}
}
/**
* Big Harvester Role
*/
module.exports.run = function(creep) {
if (creep.isTired()) { return; }
// If supergrader is enabled, switch to it, no need for upgraders while supergraders are on
if (creep.room.memory.roles['supergrader'] === false) {
creep.memory.role = 'upgrader';
return;
}
// If we have only a few ticks to live, swap it to harvest mode so it seeks home
if (!creep.memory.dying && creep.ticksToLive < 100) {
creep.say(global.sayWhat);
creep.memory.dying = 'true';
}
// if (creep.room.memory.emergency) {
// delete creep.memory.upgrading;
// delete creep.memory.idle;
// //creep.memory.role = 'harvester';
// return
// }
if(creep.memory.upgrading && creep.carry.energy === 0) {
creep.memory.upgrading = false;
creep.say(global.sayGet);
}
if(!creep.memory.upgrading && creep.carry.energy === creep.carryCapacity) {
creep.memory.upgrading = true;
creep.say(global.sayPut);
}
if (!creep.memory.upgrading) {
if (creep.getNearbyEnergy(true) === ERR_FULL) {
delete creep.memory.energyPickup;
creep.memory.upgrading = true;
}
}
if(creep.memory.upgrading) {
delete creep.memory.energyPickup;
if(creep.upgradeController(Game.rooms[creep.memory.roomName].controller) === ERR_NOT_IN_RANGE) {
creep.travelTo(Game.rooms[creep.memory.roomName].controller);
creep.say(global.sayMove);
} else {
creep.say(global.sayUpgrade);
}
}
}