| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -29,6 +29,9 @@ module.exports = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (let room of Object.values(Game.rooms)) { | 
					 | 
					 | 
					 | 
					    for (let room of Object.values(Game.rooms)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      let spawns = room.find(FIND_MY_SPAWNS) | 
					 | 
					 | 
					 | 
					      let spawns = room.find(FIND_MY_SPAWNS) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      room.memory.spawingRoom = spawns.length > 0 | 
					 | 
					 | 
					 | 
					      room.memory.spawingRoom = spawns.length > 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (!room.memory.spawnContainers) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        room.memory.spawnContainers = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if (!room.memory.harvestingSpots) { | 
					 | 
					 | 
					 | 
					      if (!room.memory.harvestingSpots) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        room.memory.harvestingSpots = {} | 
					 | 
					 | 
					 | 
					        room.memory.harvestingSpots = {} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -51,6 +54,45 @@ module.exports = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ).map(el => el.structure.id) | 
					 | 
					 | 
					 | 
					        ).map(el => el.structure.id) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (Game.time % 10 === 0 && room.controller.my) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        room.memory.spawnContainers = [] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        for (let spawn of spawns) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          let containers = spawn.pos.findInRange(FIND_STRUCTURES, 4, {filter: s => s.structureType === STRUCTURE_CONTAINER}) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          if (containers.length > 0) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            containers.forEach(el => room.memory.spawnContainers.push(el.id)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          let storagesInLevel = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            1: 0, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            2: 1, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            3: 2, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          if (containers.length < storagesInLevel[room.controller.level] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              && spawn.pos.findInRange(FIND_MY_CONSTRUCTION_SITES, 4, {filter: s => s.structureType === STRUCTURE_CONTAINER}).length === 0){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            let ring = 2 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            let x = spawn.pos.x | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            let y = spawn.pos.y | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            let result = ERR_INVALID_TARGET | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            while (ring <= 4 && result === ERR_INVALID_TARGET) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              if (ring % 2 === 0 && (x === spawn.pos.x || y === spawn.pos.y)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                result = room.createConstructionSite(x, y, STRUCTURE_CONTAINER) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              x += 2 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              if (x > spawn.pos.x + ring) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                x = spawn.pos.x - ring | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                y += 2 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              if (y > spawn.pos.y + ring) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                ring += 2 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                x = spawn.pos.x - ring | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                y = spawn.pos.y - ring | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if (!room.memory.sourcesData) { | 
					 | 
					 | 
					 | 
					      if (!room.memory.sourcesData) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        room.memory.sourcesData = {} | 
					 | 
					 | 
					 | 
					        room.memory.sourcesData = {} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -66,14 +108,25 @@ module.exports = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          } | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if (spawns.length > 0 && (Game.time + 5) % 100 === 0 && room.find(FIND_MY_CONSTRUCTION_SITES).length === 0) { | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (spawns.length > 0 && (Game.time + 5) % 10 === 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          && room.find( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              FIND_MY_CONSTRUCTION_SITES, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              {filter: s => s.structureType === STRUCTURE_EXTENSION}).length === 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        let spawn = spawns[0] | 
					 | 
					 | 
					 | 
					        let spawn = spawns[0] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        let extensions = room.find(FIND_MY_STRUCTURES, {filter: s => s.structureType === STRUCTURE_EXTENSION}) | 
					 | 
					 | 
					 | 
					        let extensions = room.find(FIND_MY_STRUCTURES, {filter: s => s.structureType === STRUCTURE_EXTENSION}) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (CONTROLLER_STRUCTURES.extension[room.controller.level] > extensions.length) { | 
					 | 
					 | 
					 | 
					        if (CONTROLLER_STRUCTURES.extension[room.controller.level] > extensions.length) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          let ring = 0 | 
					 | 
					 | 
					 | 
					          let ring = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          let x = spawn.pos.x | 
					 | 
					 | 
					 | 
					          let x = spawn.pos.x | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          let y = spawn.pos.y | 
					 | 
					 | 
					 | 
					          let y = spawn.pos.y | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          while (ring < 10 && room.createConstructionSite(x, y, STRUCTURE_EXTENSION) === ERR_INVALID_TARGET) { | 
					 | 
					 | 
					 | 
					          let result = ERR_INVALID_TARGET | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          while (ring < 10 && result === ERR_INVALID_TARGET) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (ring === 2 && y === spawn.pos.y) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              result = room.createConstructionSite(x, y, STRUCTURE_CONTAINER) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              result = room.createConstructionSite(x, y, STRUCTURE_EXTENSION) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            x += 2 | 
					 | 
					 | 
					 | 
					            x += 2 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (x > spawn.pos.x + ring) { | 
					 | 
					 | 
					 | 
					            if (x > spawn.pos.x + ring) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              x = spawn.pos.x - ring | 
					 | 
					 | 
					 | 
					              x = spawn.pos.x - ring | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -124,7 +177,11 @@ module.exports = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          } | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        else if (roleName === 'harvester') { | 
					 | 
					 | 
					 | 
					        else if (roleName === 'harvester') { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          for (let source of spawn.room.find(FIND_SOURCES)) { | 
					 | 
					 | 
					 | 
					          for (let [sourceId, sourceData] of _.sortBy(Object.entries(spawn.room.memory.sourcesData), el => el[1].spawnDistance * -1)) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            let source = Game.getObjectById(sourceId) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (!source) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              continue | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            let spots = spawn.room.memory.harvestingSpots[source.id] | 
					 | 
					 | 
					 | 
					            let spots = spawn.room.memory.harvestingSpots[source.id] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            let harvestingCapacity = 0 | 
					 | 
					 | 
					 | 
					            let harvestingCapacity = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            let sourceHarvesters = _.filter(roleCreeps, {memory: {source: source.id}}) | 
					 | 
					 | 
					 | 
					            let sourceHarvesters = _.filter(roleCreeps, {memory: {source: source.id}}) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |