mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
Catch-Up Commit
This commit is contained in:
parent
2199b449bb
commit
6ede729aed
@ -46,6 +46,13 @@ module.exports = {
|
|||||||
let newmax = Game.rooms[roomname].memory[rolename]
|
let newmax = Game.rooms[roomname].memory[rolename]
|
||||||
return 'Old Max:'+currentmax+' New Max:'+newmax
|
return 'Old Max:'+currentmax+' New Max:'+newmax
|
||||||
},
|
},
|
||||||
|
setmax: function(role,roomname,count){
|
||||||
|
let rolename = 'max' + role + 's'
|
||||||
|
let currentmax = Game.rooms[roomname].memory[rolename]
|
||||||
|
Game.rooms[roomname].memory[rolename] = count
|
||||||
|
let newmax = Game.rooms[roomname].memory[rolename]
|
||||||
|
return 'Old Max:'+currentmax+' New Max:'+newmax
|
||||||
|
},
|
||||||
increase: function(role,roomname){
|
increase: function(role,roomname){
|
||||||
let rolename = 'max' + role + 's'
|
let rolename = 'max' + role + 's'
|
||||||
let currentmax = Game.rooms[roomname].memory[rolename]
|
let currentmax = Game.rooms[roomname].memory[rolename]
|
||||||
|
2
NOTES.js
2
NOTES.js
@ -1,5 +1,5 @@
|
|||||||
if(containers.count==0 && structure_extensions.count==0 && storage.count==0 && miners.count==0){spawn harvester} else { spawn miners and haulers}
|
if(containers.count==0 && structure_extensions.count==0 && storage.count==0 && miners.count==0){spawn harvester} else { spawn miners and haulers}
|
||||||
|
require('role.' + creep.memory.role).run(creep)
|
||||||
_.forEach(Game.creeps, creep => creep.suicide())
|
_.forEach(Game.creeps, creep => creep.suicide())
|
||||||
_.forEach(Game.rooms[roomname].constructionSites, cs=>cs.remove())
|
_.forEach(Game.rooms[roomname].constructionSites, cs=>cs.remove())
|
||||||
serializePos: function(pos) {
|
serializePos: function(pos) {
|
||||||
|
@ -40,6 +40,8 @@ let buildparts = {
|
|||||||
for(let spawn of myspawns){
|
for(let spawn of myspawns){
|
||||||
if(!spawn.spawning){
|
if(!spawn.spawning){
|
||||||
for(let totry of [
|
for(let totry of [
|
||||||
|
[MOVE,MOVE,MOVE,MOVE,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY],
|
||||||
|
[MOVE,MOVE,MOVE,WORK,WORK,WORK,CARRY,CARRY,CARRY],
|
||||||
[MOVE,MOVE,WORK,WORK,CARRY,CARRY],
|
[MOVE,MOVE,WORK,WORK,CARRY,CARRY],
|
||||||
[MOVE,WORK,CARRY]
|
[MOVE,WORK,CARRY]
|
||||||
|
|
||||||
@ -236,16 +238,14 @@ let buildparts = {
|
|||||||
for(let spawn of myspawns){
|
for(let spawn of myspawns){
|
||||||
if(!spawn.spawning){
|
if(!spawn.spawning){
|
||||||
for(let totry of [
|
for(let totry of [
|
||||||
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL8
|
||||||
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL7
|
||||||
[WORK,WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL6
|
||||||
[WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL5
|
||||||
[WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL4
|
||||||
[WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL3
|
||||||
[WORK,WORK,WORK,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL2
|
||||||
[MOVE,MOVE,WORK,WORK,WORK,CARRY,CARRY,CARRY],
|
[MOVE,WORK,CARRY]//RCL1
|
||||||
[MOVE,MOVE,WORK,WORK,CARRY,CARRY],
|
|
||||||
[MOVE,WORK,CARRY]
|
|
||||||
]){
|
]){
|
||||||
let ispossible = spawn.canCreateCreep(totry)
|
let ispossible = spawn.canCreateCreep(totry)
|
||||||
if(ispossible==OK){
|
if(ispossible==OK){
|
||||||
|
35
initroom.js
Normal file
35
initroom.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
let initroom = {
|
||||||
|
run: function(name) {
|
||||||
|
console.log('Initing room ' + name)
|
||||||
|
if(Game.rooms[name].memory.CreepNum == undefined){Game.rooms[name].memory.CreepNum=0}
|
||||||
|
if(Game.rooms[name].memory.minbuildpct == undefined){Game.rooms[name].memory.minbuildpct=-1}
|
||||||
|
if(Game.rooms[name].memory.minupgradepct == undefined){Game.rooms[name].memory.minupgradepct=.5}
|
||||||
|
if(Game.rooms[name].memory.minrepairpct == undefined){Game.rooms[name].memory.minrepairpct=.5}
|
||||||
|
if(Game.rooms[name].memory.maxbuilders == undefined){ Game.rooms[name].memory.maxbuilders =1 }
|
||||||
|
if(Game.rooms[name].memory.maxnrbuilders == undefined){ Game.rooms[name].memory.maxnrbuilders =0 }
|
||||||
|
if(Game.rooms[name].memory.maxclaimers == undefined){ Game.rooms[name].memory.maxclaimers =0 }
|
||||||
|
if(Game.rooms[name].memory.maxupgraders == undefined){ Game.rooms[name].memory.maxupgraders = 2 }
|
||||||
|
if(Game.rooms[name].memory.maxminers == undefined){ Game.rooms[name].memory.maxminers = 2 }
|
||||||
|
if(Game.rooms[name].memory.maxminer2s == undefined){ Game.rooms[name].memory.maxminer2s = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxnrminers == undefined){ Game.rooms[name].memory.maxnrminers = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxhaulers == undefined){ Game.rooms[name].memory.maxhaulers = 2 }
|
||||||
|
if(Game.rooms[name].memory.maxhauler2s == undefined){ Game.rooms[name].memory.maxhauler2s = 1 }
|
||||||
|
if(Game.rooms[name].memory.maxhauler3s == undefined){ Game.rooms[name].memory.maxhauler3s = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxwarriors == undefined){ Game.rooms[name].memory.maxwarriors = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxtowerrechargers == undefined){ Game.rooms[name].memory.maxtowerrechargers = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxharvesters == undefined){ Game.rooms[name].memory.maxharvesters = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxharvester2s == undefined){ Game.rooms[name].memory.maxharvester2s = 0 }
|
||||||
|
if(Game.rooms[name].memory.maxrepairbots == undefined){ Game.rooms[name].memory.maxrepairbots = 1 }
|
||||||
|
if(Game.rooms[name].memory.minworkenergypct == undefined){ Game.rooms[name].memory.minworkenergypct = 0.3 }
|
||||||
|
if(Game.rooms[name].memory.builderparkx==undefined){Game.rooms[name].memory.builderparkx=24}
|
||||||
|
if(Game.rooms[name].memory.builderparky==undefined){Game.rooms[name].memory.builderparky=24}
|
||||||
|
if(Game.rooms[name].memory.hauler2parkx==undefined){Game.rooms[name].memory.hauler2parkx=24}
|
||||||
|
if(Game.rooms[name].memory.hauler2parky==undefined){Game.rooms[name].memory.hauler2parky=24}
|
||||||
|
if(Game.rooms[name].memory.upgraderparkx==undefined){Game.rooms[name].memory.upgraderparkx=24}
|
||||||
|
if(Game.rooms[name].memory.upgraderparky==undefined){Game.rooms[name].memory.upgraderparky=24}
|
||||||
|
if(Game.rooms[name].memory.warriorparkx==undefined){Game.rooms[name].memory.warriorparkx=15}
|
||||||
|
if(Game.rooms[name].memory.warriorparky==undefined){Game.rooms[name].memory.warriorparky=34}
|
||||||
|
Game.rooms[name].memory.hasbeeninited=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = initroom
|
125
main.js
125
main.js
@ -1,39 +1,37 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
global.Empire = require("Empire")
|
global.Empire = require("Empire")
|
||||||
let roleBuilder=require('role.builder');
|
//let runTower = require('tower');
|
||||||
let roleClaimer=require('role.claimer');
|
//let assignMiners=require('sproc')
|
||||||
let roleMiner=require('role.miner');
|
//let processSpawns=require('spawnprocessing')
|
||||||
let roleHauler=require('role.hauler')
|
//let minerals=require('mineralprocessing')
|
||||||
let roleHauler2=require('role.hauler2')
|
//let minedproc = require('MinedMineralProc')
|
||||||
let roleUpgrader=require('role.upgrader')
|
//let runSources=require('sourceprocessing')
|
||||||
let roleTowerrecharger=require('role.recharger')
|
global.verbosity=0
|
||||||
let runSources=require('sourceprocessing')
|
|
||||||
let roleRepairbot=require('role.repairbot')
|
|
||||||
let runTower = require('tower');
|
|
||||||
let assignMiners=require('sproc')
|
|
||||||
let roleWarrior=require('role.warrior')
|
|
||||||
let rolenrBuilder=require('role.nrbuilder')
|
|
||||||
let rolenrMiner=require('role.nrminer')
|
|
||||||
let processSpawns=require('spawnprocessing')
|
|
||||||
let minerals=require('mineralprocessing')
|
|
||||||
let roleMiner2=require('role.miner2')
|
|
||||||
let roleHauler3=require('role.mineralhauler')
|
|
||||||
let minedproc = require('MinedMineralProc')
|
|
||||||
module.exports.loop = function () {
|
module.exports.loop = function () {
|
||||||
console.log('---START---')
|
if(global.verbosity>0){
|
||||||
|
console.log('---START---')
|
||||||
|
}
|
||||||
for(let name in Memory.creeps) {
|
for(let name in Memory.creeps) {
|
||||||
if(!Game.creeps[name]) {
|
if(!Game.creeps[name]) {
|
||||||
delete Memory.creeps[name];
|
delete Memory.creeps[name];
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('Clearing non-existing creep memory:', name);
|
console.log('Clearing non-existing creep memory:', name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
|
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
|
||||||
let name = myroom.name
|
let name = myroom.name
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('---'+name+'---')
|
console.log('---'+name+'---')
|
||||||
runTower.tick(name);
|
}
|
||||||
assignMiners.tick(name)
|
if(Game.rooms[name].memory.hasbeeninited==undefined){
|
||||||
runSources.tick(name)
|
console.log('initing')
|
||||||
minedproc.tick(name)
|
require('initroom').run(name)
|
||||||
|
}
|
||||||
|
require('tower').tick(name);
|
||||||
|
require('sproc').tick(name) // assignMiners
|
||||||
|
require('sourceprocessing').tick(name)
|
||||||
|
require('MinedMineralProc').tick(name)
|
||||||
try{
|
try{
|
||||||
let roomenergy = Game.rooms[name].energyAvailable
|
let roomenergy = Game.rooms[name].energyAvailable
|
||||||
let allstorage = Game.rooms[name].find(FIND_STRUCTURES, {filter: (s) => {return ( s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_STORAGE)}})
|
let allstorage = Game.rooms[name].find(FIND_STRUCTURES, {filter: (s) => {return ( s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_STORAGE)}})
|
||||||
@ -53,87 +51,26 @@ module.exports.loop = function () {
|
|||||||
Game.rooms[name].memory.storagepercent = usedstorage/mycapacity
|
Game.rooms[name].memory.storagepercent = usedstorage/mycapacity
|
||||||
Game.rooms[name].memory.containerstoragepercent = containerusedstorage/containercapacity
|
Game.rooms[name].memory.containerstoragepercent = containerusedstorage/containercapacity
|
||||||
if(!(Game.rooms[name].memory.containerstoragepercent >-.1)){Game.rooms[name].memory.containerstoragepercent=0}
|
if(!(Game.rooms[name].memory.containerstoragepercent >-.1)){Game.rooms[name].memory.containerstoragepercent=0}
|
||||||
|
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('-------')
|
console.log('-------')
|
||||||
console.log('Room "'+name+'" has '+roomenergy+' energy : Using ' + usedstorage + ' of ' + mycapacity + ', ' + Game.rooms[name].memory.storagepercent * 100 + '% Storage, ' + containerusedstorage + ' of ' + containercapacity + ':' + Game.rooms[name].memory.containerstoragepercent *100+ '% in containers')
|
console.log('Room "'+name+'" has '+roomenergy+' energy : Using ' + usedstorage + ' of ' + mycapacity + ', ' + Game.rooms[name].memory.storagepercent * 100 + '% Storage, ' + containerusedstorage + ' of ' + containercapacity + ':' + Game.rooms[name].memory.containerstoragepercent *100+ '% in containers')
|
||||||
|
}
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
if(Game.rooms[name].memory.CreepNum == undefined){Game.rooms[name].memory.CreepNum=0}
|
require('spawnprocessing').tick(name)
|
||||||
if(Game.rooms[name].memory.minbuildpct == undefined){Game.rooms[name].memory.minbuildpct=.5}
|
require('mineralprocessing').tick(name)
|
||||||
if(Game.rooms[name].memory.minupgradepct == undefined){Game.rooms[name].memory.minupgradepct=.5}
|
|
||||||
if(Game.rooms[name].memory.minrepairpct == undefined){Game.rooms[name].memory.minrepairpct=.5}
|
|
||||||
if(Game.rooms[name].memory.maxbuilders == undefined){ Game.rooms[name].memory.maxbuilders =1 }
|
|
||||||
if(Game.rooms[name].memory.maxnrbuilders == undefined){ Game.rooms[name].memory.maxnrbuilders =0 }
|
|
||||||
if(Game.rooms[name].memory.maxclaimers == undefined){ Game.rooms[name].memory.maxclaimers =0 }
|
|
||||||
if(Game.rooms[name].memory.maxupgraders == undefined){ Game.rooms[name].memory.maxupgraders = 2 }
|
|
||||||
if(Game.rooms[name].memory.maxminers == undefined){ Game.rooms[name].memory.maxminers = 2 }
|
|
||||||
if(Game.rooms[name].memory.maxminer2s == undefined){ Game.rooms[name].memory.maxminer2s = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxnrminers == undefined){ Game.rooms[name].memory.maxnrminers = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxhaulers == undefined){ Game.rooms[name].memory.maxhaulers = 2 }
|
|
||||||
if(Game.rooms[name].memory.maxhauler2s == undefined){ Game.rooms[name].memory.maxhauler2s = 1 }
|
|
||||||
if(Game.rooms[name].memory.maxhauler3s == undefined){ Game.rooms[name].memory.maxhauler3s = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxwarriors == undefined){ Game.rooms[name].memory.maxwarriors = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxtowerrechargers == undefined){ Game.rooms[name].memory.maxtowerrechargers = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxharvesters == undefined){ Game.rooms[name].memory.maxharvesters = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxharvester2s == undefined){ Game.rooms[name].memory.maxharvester2s = 0 }
|
|
||||||
if(Game.rooms[name].memory.maxrepairbots == undefined){ Game.rooms[name].memory.maxrepairbots = 0 }
|
|
||||||
if(Game.rooms[name].memory.minworkenergypct == undefined){ Game.rooms[name].memory.minworkenergypct = 0.3 }
|
|
||||||
if(Game.rooms[name].memory.builderparkx==undefined){Game.rooms[name].memory.builderparkx=24}
|
|
||||||
if(Game.rooms[name].memory.builderparky==undefined){Game.rooms[name].memory.builderparky=24}
|
|
||||||
if(Game.rooms[name].memory.hauler2parkx==undefined){Game.rooms[name].memory.hauler2parkx=24}
|
|
||||||
if(Game.rooms[name].memory.hauler2parky==undefined){Game.rooms[name].memory.hauler2parky=24}
|
|
||||||
if(Game.rooms[name].memory.upgraderparkx==undefined){Game.rooms[name].memory.upgraderparkx=24}
|
|
||||||
if(Game.rooms[name].memory.upgraderparky==undefined){Game.rooms[name].memory.upgraderparky=24}
|
|
||||||
if(Game.rooms[name].memory.warriorparkx==undefined){Game.rooms[name].memory.warriorparkx=15}
|
|
||||||
if(Game.rooms[name].memory.warriorparky==undefined){Game.rooms[name].memory.warriorparky=34}
|
|
||||||
processSpawns.tick(name)
|
|
||||||
minerals.tick(name)
|
|
||||||
}
|
}
|
||||||
let mycreeps = Game.creeps
|
let mycreeps = Game.creeps
|
||||||
for(let mycreep in mycreeps){
|
for(let mycreep in mycreeps){
|
||||||
try{
|
try{
|
||||||
let creep = mycreeps[mycreep]
|
let creep = mycreeps[mycreep]
|
||||||
if(creep.memory.role == 'miner'){
|
require('role.' + creep.memory.role).run(creep)
|
||||||
roleMiner.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role=='miner2'){
|
|
||||||
roleMiner2.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'claimer'){
|
|
||||||
roleClaimer.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'hauler'){
|
|
||||||
roleHauler.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'hauler2'){
|
|
||||||
roleHauler2.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'hauler3'){
|
|
||||||
roleHauler3.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'builder'){
|
|
||||||
roleBuilder.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'upgrader'){
|
|
||||||
roleUpgrader.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role=='towerrecharger'){
|
|
||||||
roleTowerrecharger.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role == 'repairbot'){
|
|
||||||
roleRepairbot.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role=='warrior'){
|
|
||||||
roleWarrior.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role=='nrbuilder'){
|
|
||||||
rolenrBuilder.run(creep)
|
|
||||||
}
|
|
||||||
if(creep.memory.role=='nrminer'){
|
|
||||||
rolenrMiner.run(creep)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//console.log(e.toString)
|
//console.log(e.toString)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
console.log('----END---')
|
if(global.verbosity>0){
|
||||||
|
console.log('----END---')
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,7 +8,9 @@ let assignMiner2s = {
|
|||||||
let myminers = _.filter(allminers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='miner'));
|
let myminers = _.filter(allminers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='miner'));
|
||||||
let sourcecount = sources.length
|
let sourcecount = sources.length
|
||||||
let persrc = allminers.length / sourcecount
|
let persrc = allminers.length / sourcecount
|
||||||
console.log('My Assigned miner2s: ' +myminers.length + ' Max per source:' + persrc + ' Total Miner2s:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length)
|
if(global.verbosity>0){
|
||||||
|
console.log('My Assigned miner2s: ' +myminers.length + ' Max per source:' + persrc + ' Total Miner2s:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length)
|
||||||
|
}
|
||||||
if(unassignedminers.length > 0){
|
if(unassignedminers.length > 0){
|
||||||
if(myminers.length >= persrc){
|
if(myminers.length >= persrc){
|
||||||
//break;
|
//break;
|
||||||
|
14
proc.sales.js
Normal file
14
proc.sales.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Create order for energy and set price, store order id in room
|
||||||
|
if terminal has more than X in it, extend the sell order
|
||||||
|
if energy cost is below X buy it, and resell it at higher price
|
||||||
|
|
||||||
|
Game.market.createOrder(ORDER_SELL,RESOURCE_ENERGY,PRICE,AMOUNT,ROOM)
|
||||||
|
Game.market.createOrder(ORDER_SELL,RESOURCE_ENERGY,.03,10000,'W53N52')
|
||||||
|
Game.market.extendOrder('5953e604f605574924e58ec0',10000)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
};
|
@ -16,7 +16,7 @@ let roleBuilder = {
|
|||||||
if(creep.memory.building) {
|
if(creep.memory.building) {
|
||||||
|
|
||||||
if(creep.memory.buildsite==undefined|| Game.getObjectById(creep.memory.buildsite.id) == undefined){
|
if(creep.memory.buildsite==undefined|| Game.getObjectById(creep.memory.buildsite.id) == undefined){
|
||||||
creep.memory.buildsite = Game.rooms[creep.memory.originroom].find(FIND_CONSTRUCTION_SITES)[0];
|
creep.memory.buildsite = creep.pos.findClosestByRange(FIND_CONSTRUCTION_SITES);
|
||||||
}
|
}
|
||||||
let target = Game.getObjectById(creep.memory.buildsite.id)
|
let target = Game.getObjectById(creep.memory.buildsite.id)
|
||||||
if(target) {
|
if(target) {
|
||||||
|
@ -18,4 +18,4 @@ let roleClaimer = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = roleClaimer;
|
module.exports = roleClaimer;
|
||||||
|
@ -9,7 +9,7 @@ let rolenrBuilder = {
|
|||||||
creep.memory.building = true;
|
creep.memory.building = true;
|
||||||
creep.say('building');
|
creep.say('building');
|
||||||
}
|
}
|
||||||
if(Game.flags.nrbuild.room == creep.room){
|
if(Game.flags.nrbuild.pos.isEqualTo(creep.pos) && creep.room == Game.flags.nrbuild.room){
|
||||||
if(creep.memory.originroom === undefined){
|
if(creep.memory.originroom === undefined){
|
||||||
creep.memory.originroom = creep.room.name
|
creep.memory.originroom = creep.room.name
|
||||||
creep.memory.role = 'builder'
|
creep.memory.role = 'builder'
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
let assignMiners=require('sproc')
|
let assignMiners=require('sproc')
|
||||||
let rolenrMiner = {
|
let rolenrMiner = {
|
||||||
run: function(creep) {
|
run: function(creep) {
|
||||||
if(Game.flags.nrbuild.room == creep.room){
|
|
||||||
|
if(Game.flags.nrbuild.pos.isEqualTo(creep.pos) && creep.room == Game.flags.nrbuild.room){
|
||||||
if(creep.memory.destsource==undefined){
|
if(creep.memory.destsource===undefined){
|
||||||
|
console.log("changing role from nrminer to miner")
|
||||||
creep.memory.role='miner'
|
creep.memory.role='miner'
|
||||||
assignMiners(creep.roomName)
|
assignMiners(creep.roomName)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,9 @@ let runSources = {
|
|||||||
let myhaulers = _.filter(allhaulers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='hauler'));
|
let myhaulers = _.filter(allhaulers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='hauler'));
|
||||||
let sourcecount = sources.length
|
let sourcecount = sources.length
|
||||||
let persrc = allhaulers.length / sourcecount
|
let persrc = allhaulers.length / sourcecount
|
||||||
console.log('My Assigned Haulers: ' +myhaulers.length + ' Max per source:' + persrc + ' Total Haulers:' + allhaulers.length + ' Total Sources:' + sourcecount + ' Unassigned Haulers:' + unassignedhaulers.length)
|
if(global.verbosity>0){
|
||||||
|
console.log('My Assigned Haulers: ' +myhaulers.length + ' Max per source:' + persrc + ' Total Haulers:' + allhaulers.length + ' Total Sources:' + sourcecount + ' Unassigned Haulers:' + unassignedhaulers.length)
|
||||||
|
}
|
||||||
if(unassignedhaulers.length > 0){
|
if(unassignedhaulers.length > 0){
|
||||||
if(myhaulers.length < persrc){
|
if(myhaulers.length < persrc){
|
||||||
unassignedhaulers[0].memory.destsource = source
|
unassignedhaulers[0].memory.destsource = source
|
||||||
|
@ -7,8 +7,10 @@ let processSpawns = {
|
|||||||
}
|
}
|
||||||
let energyready = Game.rooms[roomname].energyAvailable
|
let energyready = Game.rooms[roomname].energyAvailable
|
||||||
let energymax = Game.rooms[roomname].energyCapacityAvailable
|
let energymax = Game.rooms[roomname].energyCapacityAvailable
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log(Game.rooms[roomname].memory.tickssincespawn)
|
console.log(Game.rooms[roomname].memory.tickssincespawn)
|
||||||
console.log(energyready / energymax)
|
console.log(energyready / energymax)
|
||||||
|
}
|
||||||
if(energyready==energymax || energyready / energymax > .5 ||Game.rooms[roomname].memory.tickssincespawn>50){
|
if(energyready==energymax || energyready / energymax > .5 ||Game.rooms[roomname].memory.tickssincespawn>50){
|
||||||
Game.rooms[roomname].memory.tickssincespawn=0
|
Game.rooms[roomname].memory.tickssincespawn=0
|
||||||
let allcreeps = _.filter(Game.rooms[roomname].find(FIND_MY_CREEPS));
|
let allcreeps = _.filter(Game.rooms[roomname].find(FIND_MY_CREEPS));
|
||||||
@ -29,62 +31,92 @@ let processSpawns = {
|
|||||||
//console.log(allcreeps.length + " " + allbuilders.length + " " + allminers.length + " " + allhaulers.length + " " + allhauler2s.length + " " + alltowerrechargers.length + " " + allrepairbots.length + " " + allupgraders.length + " " + allwarriors.length)
|
//console.log(allcreeps.length + " " + allbuilders.length + " " + allminers.length + " " + allhaulers.length + " " + allhauler2s.length + " " + alltowerrechargers.length + " " + allrepairbots.length + " " + allupgraders.length + " " + allwarriors.length)
|
||||||
for(let spawn of myspawns){
|
for(let spawn of myspawns){
|
||||||
if(!spawn.spawning && !spawn.memory.spawnqueued){
|
if(!spawn.spawning && !spawn.memory.spawnqueued){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('WOULD SPAWN AT '+ spawn.name)
|
console.log('WOULD SPAWN AT '+ spawn.name)
|
||||||
|
}
|
||||||
//spawn.memory.spawnqueued=true
|
//spawn.memory.spawnqueued=true
|
||||||
|
|
||||||
if(Game.rooms[roomname].memory.maxminers > allminers.length){
|
if(Game.rooms[roomname].memory.maxminers > allminers.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn miner')
|
console.log('spawn miner')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'miner')
|
buildparts.tick(roomname,'miner')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
} else if(Game.rooms[roomname].memory.maxminer2s > allminer2s.length){
|
} else if(Game.rooms[roomname].memory.maxminer2s > allminer2s.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn miner2s')
|
console.log('spawn miner2s')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'miner2')
|
buildparts.tick(roomname,'miner2')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
} else if(Game.rooms[roomname].memory.maxhaulers > allhaulers.length){
|
} else if(Game.rooms[roomname].memory.maxhaulers > allhaulers.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn hauler')
|
console.log('spawn hauler')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'hauler')
|
buildparts.tick(roomname,'hauler')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
}else if(Game.rooms[roomname].memory.maxhauler3s > allhauler3s.length){
|
}else if(Game.rooms[roomname].memory.maxhauler3s > allhauler3s.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn hauler3')
|
console.log('spawn hauler3')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'hauler3')
|
buildparts.tick(roomname,'hauler3')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
}else if(Game.rooms[roomname].memory.maxupgraders > allupgraders.length){
|
}else if(Game.rooms[roomname].memory.maxupgraders > allupgraders.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn upgrader')
|
console.log('spawn upgrader')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'upgrader')
|
buildparts.tick(roomname,'upgrader')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
} else if(Game.rooms[roomname].memory.maxhauler2s > allhauler2s.length){
|
} else if(Game.rooms[roomname].memory.maxhauler2s > allhauler2s.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn hauler2')
|
console.log('spawn hauler2')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'hauler2')
|
buildparts.tick(roomname,'hauler2')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
} else if(Game.rooms[roomname].memory.maxtowerrechargers > alltowerrechargers.length){
|
} else if(Game.rooms[roomname].memory.maxtowerrechargers > alltowerrechargers.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn towerrecharger')
|
console.log('spawn towerrecharger')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'towerrecharger')
|
buildparts.tick(roomname,'towerrecharger')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
} else if(Game.rooms[roomname].memory.maxrepairbots > allrepairbots.length){
|
} else if(Game.rooms[roomname].memory.maxrepairbots > allrepairbots.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn repairbot')
|
console.log('spawn repairbot')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'repairbot')
|
buildparts.tick(roomname,'repairbot')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
}else if(Game.rooms[roomname].memory.maxbuilders > allbuilders.length){
|
}else if(Game.rooms[roomname].memory.maxbuilders > allbuilders.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn builder')
|
console.log('spawn builder')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'builder')
|
buildparts.tick(roomname,'builder')
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
} else if (Game.rooms[roomname].memory.maxwarriors > allwarriors.length){
|
} else if (Game.rooms[roomname].memory.maxwarriors > allwarriors.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn warrior')
|
console.log('spawn warrior')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'warrior')
|
buildparts.tick(roomname,'warrior')
|
||||||
} else if(Game.rooms[roomname].memory.maxclaimers > allclaimers.length){
|
} else if(Game.rooms[roomname].memory.maxclaimers > allclaimers.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn claimer')
|
console.log('spawn claimer')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'claimer')
|
buildparts.tick(roomname,'claimer')
|
||||||
} else if(Game.rooms[roomname].memory.maxnrbuilders > allnrbuilders.length){
|
} else if(Game.rooms[roomname].memory.maxnrbuilders > allnrbuilders.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn nrbuilder')
|
console.log('spawn nrbuilder')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'nrbuilder')
|
buildparts.tick(roomname,'nrbuilder')
|
||||||
} else if(Game.rooms[roomname].memory.maxnrminers > allnrminers.length){
|
} else if(Game.rooms[roomname].memory.maxnrminers > allnrminers.length){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('spawn nrminer')
|
console.log('spawn nrminer')
|
||||||
|
}
|
||||||
buildparts.tick(roomname,'nrminer')
|
buildparts.tick(roomname,'nrminer')
|
||||||
} else {}
|
} else {}
|
||||||
|
|
||||||
} else if (!spawn.spawning && spawn.memory.spawnqueued) {
|
} else if (!spawn.spawning && spawn.memory.spawnqueued) {
|
||||||
spawn.memory.spawnqueued=false
|
spawn.memory.spawnqueued=false
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log('clearing spawn queue')
|
console.log('clearing spawn queue')
|
||||||
|
}
|
||||||
} else if (spawn.spawning && !spawn.memory.spawnqueued){
|
} else if (spawn.spawning && !spawn.memory.spawnqueued){
|
||||||
spawn.memory.spawnqueued=true
|
spawn.memory.spawnqueued=true
|
||||||
}
|
}
|
||||||
|
4
sproc.js
4
sproc.js
@ -8,7 +8,9 @@ let assignMiners = {
|
|||||||
let myminers = _.filter(allminers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='miner'));
|
let myminers = _.filter(allminers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='miner'));
|
||||||
let sourcecount = sources.length
|
let sourcecount = sources.length
|
||||||
let persrc = allminers.length / sourcecount
|
let persrc = allminers.length / sourcecount
|
||||||
console.log('My Assigned Miners: ' +myminers.length + ' Max per source:' + persrc + ' Total Miners:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length)
|
if(global.verbosity>0){
|
||||||
|
console.log('My Assigned Miners: ' +myminers.length + ' Max per source:' + persrc + ' Total Miners:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length)
|
||||||
|
}
|
||||||
if(unassignedminers.length > 0){
|
if(unassignedminers.length > 0){
|
||||||
if(myminers.length >= persrc){
|
if(myminers.length >= persrc){
|
||||||
//break;
|
//break;
|
||||||
|
8
tower.js
8
tower.js
@ -34,9 +34,15 @@ var towers = {
|
|||||||
{
|
{
|
||||||
if(closestDamagedStructure) {
|
if(closestDamagedStructure) {
|
||||||
if(Game.rooms[roomname].memory.containerstoragepercent > .8){
|
if(Game.rooms[roomname].memory.containerstoragepercent > .8){
|
||||||
|
if(global.verbosity>0){
|
||||||
console.log("tower repairing. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent)
|
console.log("tower repairing. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent)
|
||||||
|
}
|
||||||
tower.repair(closestDamagedStructure);
|
tower.repair(closestDamagedStructure);
|
||||||
} else { console.log("tower waiting for more storage. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent)}
|
} else {
|
||||||
|
if(global.verbosity>0){
|
||||||
|
console.log("tower waiting for more storage. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user