mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
Changes to road making rules
This commit is contained in:
parent
e72a3f37dd
commit
aaa8c26d65
@ -8,6 +8,7 @@ let initroom = {
|
|||||||
Game.rooms[name].memory.minrepairpct=.5
|
Game.rooms[name].memory.minrepairpct=.5
|
||||||
Game.rooms[name].memory.hasbeeninited=1
|
Game.rooms[name].memory.hasbeeninited=1
|
||||||
Game.rooms[name].memory.tickssofar=0
|
Game.rooms[name].memory.tickssofar=0
|
||||||
|
Game.rooms[name].memory.maphits={}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = initroom
|
module.exports = initroom
|
38
main.js
38
main.js
@ -3,6 +3,7 @@ global.Empire = require("Empire")
|
|||||||
let Traveler = require("Traveler")
|
let Traveler = require("Traveler")
|
||||||
global.verbosity=0
|
global.verbosity=0
|
||||||
module.exports.loop = function () {
|
module.exports.loop = function () {
|
||||||
|
let decrementcounter = Game.time % 30
|
||||||
for(let name in Game.rooms){
|
for(let name in Game.rooms){
|
||||||
let myroom=Game.rooms[name]
|
let myroom=Game.rooms[name]
|
||||||
|
|
||||||
@ -20,26 +21,51 @@ module.exports.loop = function () {
|
|||||||
myroom.memory.tickssofar++
|
myroom.memory.tickssofar++
|
||||||
require('Room.Phase' + myroom.memory.phase).run(name)
|
require('Room.Phase' + myroom.memory.phase).run(name)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for(let pos in myroom.memory.maphits){
|
||||||
|
if((myroom.memory.maphits[pos].lastwalked < (Game.time - 1000)) && (myroom.memory.maphits[pos].hits>0)){
|
||||||
|
if(decrementcounter== 0){
|
||||||
|
myroom.memory.maphits[pos].hits--
|
||||||
|
}
|
||||||
|
} else if(myroom.memory.maphits[pos].hits==0){
|
||||||
|
delete myroom.memory.maphits[pos]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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){
|
if(global.verbosity>0){
|
||||||
console.log('Clearing non-existing creep memory:', name);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try{
|
try{
|
||||||
let creep = Game.creeps[name]
|
let creep = Game.creeps[name]
|
||||||
if(creep.spawning) return;
|
if(creep.spawning) return;
|
||||||
if(creep.fatigue>0){
|
if(creep.fatigue>0){
|
||||||
creep.say('fatigued')
|
if(creep.room.memory.maphits==undefined){
|
||||||
creep.room.createConstructionSite(creep.pos.x,creep.pos.y,STRUCTURE_ROAD)
|
creep.room.memory.maphits={}
|
||||||
|
}
|
||||||
|
//creep.room.createConstructionSite(creep.pos.x,creep.pos.y,STRUCTURE_ROAD)
|
||||||
|
if(creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y] ==undefined){
|
||||||
|
creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y]={}
|
||||||
|
creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y].lastwalked = Game.time
|
||||||
|
creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y].hits=1
|
||||||
|
} else {
|
||||||
|
creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y].hits++
|
||||||
|
if(creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y].hits > 5){
|
||||||
|
if(creep.room.memory.phase>0){
|
||||||
|
creep.room.createConstructionSite(creep.pos.x,creep.pos.y,STRUCTURE_ROAD)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require('role.' + creep.memory.role).run(creep)
|
require('role.' + creep.memory.role).run(creep)
|
||||||
//creep.say("TRYING")
|
//creep.say("TRYING")
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
console.log("creep error")
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let flags = Game.flags
|
let flags = Game.flags
|
||||||
|
@ -7,4 +7,4 @@ let rolenrBuilder = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = rolenrBuilder;
|
module.exports = rolenrBuilder;
|
@ -2,6 +2,7 @@
|
|||||||
let Phase0Worker = {
|
let Phase0Worker = {
|
||||||
run: function(creep) {
|
run: function(creep) {
|
||||||
let filllevel = _.sum(creep.carry)
|
let filllevel = _.sum(creep.carry)
|
||||||
|
//creep.say(creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y].hits)
|
||||||
if(creep.memory.working && filllevel == 0) {
|
if(creep.memory.working && filllevel == 0) {
|
||||||
creep.memory.working = false;
|
creep.memory.working = false;
|
||||||
creep.say('Gathering');
|
creep.say('Gathering');
|
||||||
|
@ -6,6 +6,9 @@ let Phase1Worker = {
|
|||||||
creep.memory.lastpos = creep.pos
|
creep.memory.lastpos = creep.pos
|
||||||
creep.memory.timeatpos = 0
|
creep.memory.timeatpos = 0
|
||||||
}
|
}
|
||||||
|
if(creep.memory.assignedroom==undefined){
|
||||||
|
creep.memory.assignedroom=creep.room.name
|
||||||
|
}
|
||||||
let lastpos = _.create(RoomPosition.prototype, creep.memory.lastpos)
|
let lastpos = _.create(RoomPosition.prototype, creep.memory.lastpos)
|
||||||
if(creep.pos.isEqualTo(lastpos)){
|
if(creep.pos.isEqualTo(lastpos)){
|
||||||
|
|
||||||
@ -59,8 +62,9 @@ let Phase1Worker = {
|
|||||||
}else {
|
}else {
|
||||||
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
|
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
|
||||||
creep.say('MTRC')
|
creep.say('MTRC')
|
||||||
if (road.length > 0) {creep.repair(road);}
|
if (road.length > 0) {creep.repair(road);}
|
||||||
creep.moveTo(creep.room.controller,{ignoreCreeps:ignorecreeps})
|
creep.memory.assignedroom=creep.room.name
|
||||||
|
creep.moveTo(Game.rooms[creep.memory.assignedroom].controller,{ignoreCreeps:ignorecreeps})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user