Creeps disappear
-
Hey guys, I'm new to here. I created four creeps last night, three of them looking for energy, and one for building.
However, when I woke up this morning, all four creeps are gone.
I'm pretty sure they were not attacked since I'm still under protection.
My question is, do the creeps disappear after certain time?
-
Yes, you have to account for this in your code, and auto-rebuild them when they die.
If you check the documentation, you can see that you can check how long a creep has to live by checking the value of Game.creeps["JimmysCreepName"].ticksToLive
Hope that helps!
-
Each creep lives for 1500 ticks.
http://support.screeps.com/hc/en-us/articles/203022092-Spawning-creeps
-
You need to learn the following
1) How to perform a find for all your creeps and get a count.
Game.Spawns['Spawn1'].room.find(FIND_MY_CREEPS).length
2) How to set some limit for how many creeps you want at one time. Hint: If you just spawn low level creeps as fast as possible, you will never have energy for anything else.
3) How to spawn a creep.
Game.Spawns['Spawn1'].createCreep([WORK,CARRY,MOVE],
utils.generateName('Worker'),
{role: 'worker'})4) How to clean up old creep memory so you don't run out
for(var name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name)
}
}5) How to break all this up into modules and manage your energy. Then build roads, containers, warriors, mines, nuclear silos .. MUHAHAHHAHAHaahaha
Its a LOT of work and it will take you MONTHS to get a great strategy. But chip away at it a little at a time. USE THE SIMULATOR to try things out. You can spawn in items and speed up time for testing. After 1 week you will want to quit cause its too hard. Tell that little @#$@$ part of your brain to shut up and press on. Once you get it .. you will be hooked!
Here is an old, declassified and military redacted script of mine .. MUHAHAHA Learn how to make modules!var utils = require('utils');
// region Variables
var debug = false
// endregion
// region Module Implementation
module.exports =
{
/**
* This logic loop handles generating new units (room by room)
*
* Thi is a flexible function that can be called from any CZar to control creep dynamics
* @param minWorkers The minimum number of workers (in this room) that must be active before any other type is created
* @param maxWorkers The max number of workers (in this room) that should ever be active
*/
ensureStaffingLevels: function(minWorkers, maxWorkers)
{
for(var i in Game.spawns) {
var thisSpawn = Game.spawns[i]
var totalCreeps = getTotalCreepCount(thisSpawn)
var totalWorkers = getTotalWorkerCreepCount(thisSpawn)
// First make sure we have the min number of workers.
if (totalWorkers < minWorkers){
generateWorkerCreep(thisSpawn, true)
return
}
// After we have the minWorkers we can focus on other creeps
var totalCurators = getTotalCuratorCreepCount(thisSpawn)
if(totalCurators == 0) {
thisSpawn.createCreep(generateCuratorBodyParts(thisSpawn),
`${thisSpawn.name}-Curator`, {role: 'curator'});
return
}
if( totalWorkers < maxWorkers)
{
generateWorkerCreep(thisSpawn, false)
return
}
}
},
decommissionUnusedResources: function()
{
for(var name in Memory.creeps) {
if(!Game.creeps[name]) {
delete Memory.creeps[name];
console.log('Clearing non-existing creep memory:', name)
}
}
},
generateWorkerCreep: generateWorkerCreep,
generateMeleeGuardCreep: generateMeleeGuardCreep,
generateRangedGuardCreep: generateRangedGuardCreep,
generateWorkerBodyParts: generateWorkerBodyParts
}