screeps/proc.spawning.js

221 lines
12 KiB
JavaScript
Raw Permalink Normal View History

2020-11-09 19:31:39 -06:00
let buildparts = {
spawnminer: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
2020-11-14 01:18:05 -06:00
let CreepName = 'miner_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
2020-11-09 19:31:39 -06:00
for(let spawn of myspawns){
if(!spawn.spawning){
let tobuild=[]
for(let totry of [
2020-11-14 01:18:05 -06:00
[WORK,WORK,WORK,WORK,CARRY,MOVE],
[WORK,WORK,WORK,CARRY,MOVE],
[WORK,WORK,CARRY,MOVE],
[WORK,CARRY,MOVE],
2020-11-09 19:31:39 -06:00
[WORK,MOVE]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
2020-11-17 10:30:13 -06:00
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time, role:'miner'})
2020-11-09 19:31:39 -06:00
}}
},
spawnsourceminer: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
let CreepName = 'sourceminer_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
for(let spawn of myspawns){
if(!spawn.spawning){
let tobuild=[]
for(let totry of [
2022-05-23 15:59:00 -05:00
[WORK,WORK,WORK,WORK,WORK,MOVE]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
2020-11-17 10:30:13 -06:00
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:'sourceminer'})
}}
2020-11-09 19:31:39 -06:00
},
spawnwarrior: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
2020-11-14 01:18:05 -06:00
let CreepName = 'warrior_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
2020-11-09 19:31:39 -06:00
for(let spawn of myspawns){
if(!spawn.spawning){
let tobuild=[]
for(let totry of [
[MOVE,ATTACK,MOVE,ATTACK,MOVE,ATTACK,MOVE,ATTACK,MOVE,ATTACK],
[MOVE,ATTACK,MOVE,ATTACK,MOVE,ATTACK,MOVE,ATTACK],
[MOVE,ATTACK,MOVE,ATTACK,MOVE,ATTACK],
[MOVE,ATTACK,MOVE,ATTACK],
[MOVE,ATTACK]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
2020-11-17 10:30:13 -06:00
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:'warrior'})
2020-11-09 19:31:39 -06:00
}}
},
spawnworker: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
2020-11-14 01:18:05 -06:00
let CreepName = 'worker_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
2020-11-09 19:31:39 -06:00
for(let spawn of myspawns){
if(!spawn.spawning){
for(let totry of [
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY,CARRY],//MOVE*6,WORK*5,CARRY*7
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],// all * 5
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY],//move*5, work*4, carry*5
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//move*4,work*4,carry*4
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY],//move*4, work*3, carry*4
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY], //move*3,work*2, carry*3
[MOVE,WORK,CARRY,MOVE,WORK,CARRY], //move*2, work*2, carry*2
[MOVE,WORK,CARRY,MOVE,CARRY],//move*2, work*1, carry*2
[MOVE,WORK,CARRY]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
if(tobuild != null && tobuild != undefined){
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"phase" + Game.rooms[roomname].memory.phase +"worker"})
} else {
console.log("not enough e in " + roomname + " to spawn")
}
2020-11-09 19:31:39 -06:00
}}
},
spawnmover: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
2020-11-14 01:18:05 -06:00
let CreepName = 'Mover_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
2020-11-09 19:31:39 -06:00
for(let spawn of myspawns){
if(!spawn.spawning){
for(let totry of [
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY],//MOVE*6,WORK*5,CARRY*7
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY],// all * 5
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY],//move*5, work*4, carry*5
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY],//move*4,work*4,carry*4
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY],//move*4, work*3, carry*4
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY], //move*3,work*2, carry*3
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY], //move*2, work*2, carry*2
[MOVE,CARRY,CARRY,MOVE,CARRY],//move*2, work*1, carry*2
[MOVE,CARRY,CARRY]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
2020-11-17 10:30:13 -06:00
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"mover"})
2020-11-09 19:31:39 -06:00
}}
},
spawnmineralmover: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
let CreepName = 'MineralMover_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
for(let spawn of myspawns){
if(!spawn.spawning){
for(let totry of [
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY],//MOVE*6,WORK*5,CARRY*7
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY],// all * 5
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY],//move*5, work*4, carry*5
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY],//move*4,work*4,carry*4
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY],//move*4, work*3, carry*4
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY], //move*3,work*2, carry*3
[MOVE,CARRY,CARRY,MOVE,CARRY,CARRY], //move*2, work*2, carry*2
[MOVE,CARRY,CARRY,MOVE,CARRY],//move*2, work*1, carry*2
[MOVE,CARRY,CARRY]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"mineralmover"})
}}
2020-11-09 19:31:39 -06:00
},
spawnnrworker: function(roomname) {
console.log('1')
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
let CreepName = "nrworker_" + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
for(let spawn of myspawns){
if(!spawn.spawning && spawn.room.energyAvailable > 500){
for(let totry of [
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY,CARRY],//MOVE*6,WORK*5,CARRY*7
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],// all * 5
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY],//move*5, work*4, carry*5
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//move*4,work*4,carry*4
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY],//move*4, work*3, carry*4
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,CARRY], //move*3,work*2, carry*3
[MOVE,WORK,CARRY,MOVE,WORK,CARRY], //move*2, work*2, carry*2
[MOVE,WORK,CARRY,MOVE,CARRY],//move*2, work*1, carry*2
[MOVE,WORK,CARRY]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
}
}
2020-11-17 10:30:13 -06:00
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"nrworker"})
2020-11-09 19:31:39 -06:00
}}
},
spawnclaimer: function(roomname) {
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
Game.rooms[roomname].memory.CreepNum++
let CreepName = "claimer" + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
for(let spawn of myspawns){
if(!spawn.spawning){
for(let totry of [
[CLAIM,MOVE]
]){
let ispossible = spawn.canCreateCreep(totry)
if(ispossible==OK){
tobuild=totry
break;
} else {
console.log("Couldn't find a size that could be made")
}
}
console.log(roomname + ' ' + tobuild)
2020-11-17 10:30:13 -06:00
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:'claimer'})
2020-11-09 19:31:39 -06:00
}}
}
};
module.exports = buildparts;
/*
*/
/*
switch(role){
case 'builder':
break;
default:
console.log('no match')
break;
}
*/