mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
fixed errors in state tracking and removed excess logging
This commit is contained in:
parent
52d492863d
commit
d482d39d16
@ -13,8 +13,6 @@ var roleBuilder = {
|
|||||||
usedstorage+=_.sum(allcontainers[i].store)
|
usedstorage+=_.sum(allcontainers[i].store)
|
||||||
mycapacity+=allcontainers[i].storeCapacity
|
mycapacity+=allcontainers[i].storeCapacity
|
||||||
}
|
}
|
||||||
console.log(usedstorage + " " + mycapacity)
|
|
||||||
|
|
||||||
var storagepercent = usedstorage/mycapacity
|
var storagepercent = usedstorage/mycapacity
|
||||||
|
|
||||||
var ttl = creep.ticksToLive
|
var ttl = creep.ticksToLive
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
var roleHauler = {
|
var roleHauler = {
|
||||||
run: function(creep) {
|
run: function(creep) {
|
||||||
|
if(creep.memory.hauling == undefined){creep.memory.hauling=false}
|
||||||
|
if(creep.memory.hauling && creep.carry.energy == 0) {
|
||||||
|
creep.memory.hauling = false;
|
||||||
|
creep.say('gathering');
|
||||||
|
}
|
||||||
|
if(!creep.memory.hauling && creep.carry.energy == creep.carryCapacity) {
|
||||||
|
creep.memory.hauling = true;
|
||||||
|
creep.say('hauling');
|
||||||
|
}
|
||||||
var sources = creep.room.find(FIND_DROPPED_ENERGY );
|
var sources = creep.room.find(FIND_DROPPED_ENERGY );
|
||||||
|
if(creep.memory.hauling==false){
|
||||||
if(creep.pickup(sources[0]) == ERR_NOT_IN_RANGE && creep.carryCapacity/2 > creep.carry.energy) {
|
if(creep.pickup(sources[0]) == ERR_NOT_IN_RANGE && creep.carryCapacity/2 > creep.carry.energy) {
|
||||||
creep.moveTo(sources[0]);
|
creep.moveTo(sources[0]);
|
||||||
} else if(sources != undefined )
|
}
|
||||||
|
}else {
|
||||||
|
if(sources != undefined )
|
||||||
{ var spawntargets = creep.room.find(FIND_STRUCTURES, {
|
{ var spawntargets = creep.room.find(FIND_STRUCTURES, {
|
||||||
filter: (structure) => {
|
filter: (structure) => {
|
||||||
return ((structure.structureType == STRUCTURE_EXTENSION || structure.structureType == STRUCTURE_SPAWN) &&structure.energy < structure.energyCapacity)
|
return ((structure.structureType == STRUCTURE_EXTENSION || structure.structureType == STRUCTURE_SPAWN) &&structure.energy < structure.energyCapacity)
|
||||||
@ -31,6 +43,7 @@ var roleHauler = {
|
|||||||
creep.say("NS,NT")
|
creep.say("NS,NT")
|
||||||
creep.moveTo(Game.flags.Flag1);
|
creep.moveTo(Game.flags.Flag1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
spawn: function(){
|
spawn: function(){
|
||||||
var myrole='hauler';
|
var myrole='hauler';
|
||||||
|
@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
/** @param {Creep} creep **/
|
/** @param {Creep} creep **/
|
||||||
run: function(creep) {
|
run: function(creep) {
|
||||||
|
if(creep.memory.hauling == undefined){creep.memory.hauling=false}
|
||||||
|
if(creep.memory.hauling && creep.carry.energy == 0) {
|
||||||
|
creep.memory.hauling = false;
|
||||||
|
creep.say('gathering');
|
||||||
|
}
|
||||||
|
if(!creep.memory.hauling && creep.carry.energy == creep.carryCapacity) {
|
||||||
|
creep.memory.hauling = true;
|
||||||
|
creep.say('hauling');
|
||||||
|
}
|
||||||
|
if(creep.memory.hauling==false){
|
||||||
if(creep.carryCapacity > creep.carry.energy){
|
if(creep.carryCapacity > creep.carry.energy){
|
||||||
var container = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
var container = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
||||||
filter: (structure) => {
|
filter: (structure) => {
|
||||||
@ -27,6 +37,7 @@
|
|||||||
creep.moveTo(Game.flags.Flag1);
|
creep.moveTo(Game.flags.Flag1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
spawn: function(){
|
spawn: function(){
|
||||||
var myrole='hauler2';
|
var myrole='hauler2';
|
||||||
|
@ -11,7 +11,6 @@ var roleRepairbot = {
|
|||||||
creep.memory.repairing = true;
|
creep.memory.repairing = true;
|
||||||
creep.say('repairing');
|
creep.say('repairing');
|
||||||
}
|
}
|
||||||
console.log(creep.name)
|
|
||||||
if(creep.memory.repairing==false){
|
if(creep.memory.repairing==false){
|
||||||
var container = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
var container = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
||||||
filter: (structure) => {
|
filter: (structure) => {
|
||||||
|
2
tower.js
2
tower.js
@ -25,8 +25,6 @@ var towers = {
|
|||||||
usedstorage+=_.sum(allcontainers[i].store)
|
usedstorage+=_.sum(allcontainers[i].store)
|
||||||
mycapacity+=allcontainers[i].storeCapacity
|
mycapacity+=allcontainers[i].storeCapacity
|
||||||
}
|
}
|
||||||
console.log(usedstorage + " " + mycapacity)
|
|
||||||
|
|
||||||
var storagepercent = usedstorage/mycapacity
|
var storagepercent = usedstorage/mycapacity
|
||||||
var importantstructures = tower.room.find(FIND_STRUCTURES, {
|
var importantstructures = tower.room.find(FIND_STRUCTURES, {
|
||||||
filter: (structure) => {
|
filter: (structure) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user