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.hasbeeninited=1
|
||||
Game.rooms[name].memory.tickssofar=0
|
||||
Game.rooms[name].memory.maphits={}
|
||||
}
|
||||
}
|
||||
module.exports = initroom
|
36
main.js
36
main.js
@ -3,6 +3,7 @@ global.Empire = require("Empire")
|
||||
let Traveler = require("Traveler")
|
||||
global.verbosity=0
|
||||
module.exports.loop = function () {
|
||||
let decrementcounter = Game.time % 30
|
||||
for(let name in Game.rooms){
|
||||
let myroom=Game.rooms[name]
|
||||
|
||||
@ -20,26 +21,51 @@ module.exports.loop = function () {
|
||||
myroom.memory.tickssofar++
|
||||
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) {
|
||||
if(!Game.creeps[name]) {
|
||||
delete Memory.creeps[name];
|
||||
if(global.verbosity>0){
|
||||
console.log('Clearing non-existing creep memory:', name);
|
||||
}
|
||||
} else {
|
||||
try{
|
||||
let creep = Game.creeps[name]
|
||||
if(creep.spawning) return;
|
||||
if(creep.fatigue>0){
|
||||
creep.say('fatigued')
|
||||
creep.room.createConstructionSite(creep.pos.x,creep.pos.y,STRUCTURE_ROAD)
|
||||
if(creep.room.memory.maphits==undefined){
|
||||
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)
|
||||
//creep.say("TRYING")
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.log("creep error")
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
let flags = Game.flags
|
||||
|
@ -2,6 +2,7 @@
|
||||
let Phase0Worker = {
|
||||
run: function(creep) {
|
||||
let filllevel = _.sum(creep.carry)
|
||||
//creep.say(creep.room.memory.maphits[creep.pos.x + '-' + creep.pos.y].hits)
|
||||
if(creep.memory.working && filllevel == 0) {
|
||||
creep.memory.working = false;
|
||||
creep.say('Gathering');
|
||||
|
@ -6,6 +6,9 @@ let Phase1Worker = {
|
||||
creep.memory.lastpos = creep.pos
|
||||
creep.memory.timeatpos = 0
|
||||
}
|
||||
if(creep.memory.assignedroom==undefined){
|
||||
creep.memory.assignedroom=creep.room.name
|
||||
}
|
||||
let lastpos = _.create(RoomPosition.prototype, creep.memory.lastpos)
|
||||
if(creep.pos.isEqualTo(lastpos)){
|
||||
|
||||
@ -59,8 +62,9 @@ let Phase1Worker = {
|
||||
}else {
|
||||
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
|
||||
creep.say('MTRC')
|
||||
if (road.length > 0) {creep.repair(road);}
|
||||
creep.moveTo(creep.room.controller,{ignoreCreeps:ignorecreeps})
|
||||
if (road.length > 0) {creep.repair(road);}
|
||||
creep.memory.assignedroom=creep.room.name
|
||||
creep.moveTo(Game.rooms[creep.memory.assignedroom].controller,{ignoreCreeps:ignorecreeps})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user