-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.spawn.js
More file actions
25 lines (21 loc) · 913 Bytes
/
prototype.spawn.js
File metadata and controls
25 lines (21 loc) · 913 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
module.exports = function() {
// create a new function for StructureSpawn
StructureSpawn.prototype.createCustomCreep =
function(energy, roleName) {
// create a balanced body as big as possible with the given energy
var numberOfPartsC = Math.floor(energy / 200);
var body = [];
if (numberOfPartsC >= 7) {var numberOfParts = 6;} else {var numberOfParts = numberOfPartsC;}
for (let i = 0; i < numberOfParts; i++) {
body.push(WORK);
}
for (let i = 0; i < numberOfParts; i++) {
body.push(CARRY);
}
for (let i = 0; i < numberOfParts; i++) {
body.push(MOVE);
}
// create creep with the created body and the given role
return this.createCreep(body, undefined,{ role: roleName, working: false });
};
};