Improved walking system.
This commit is contained in:
61
Screeps/Commands.js
Normal file
61
Screeps/Commands.js
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
|
||||
module.exports = {
|
||||
setup(){
|
||||
global.fullReset = fullReset;
|
||||
global.resetRooms = resetRooms;
|
||||
global.resetStructures = resetStructures;
|
||||
global.resetCreeps = resetCreeps;
|
||||
global.resetConstruction = resetConstruction;
|
||||
|
||||
global.buildRoads = buildRoads;
|
||||
}
|
||||
}
|
||||
|
||||
function fullReset(){
|
||||
resetRooms();
|
||||
resetCreeps();
|
||||
resetStructures();
|
||||
resetConstruction();
|
||||
global.started = false;
|
||||
global.compiled = false;
|
||||
return "OK";
|
||||
}
|
||||
|
||||
function resetRooms(){
|
||||
Object.values(Game.rooms).forEach(room => room.memory = {});
|
||||
return "OK";
|
||||
}
|
||||
|
||||
function resetStructures(){
|
||||
Object.values(Game.structures).forEach(structure => structure.memory = {});
|
||||
return "OK";
|
||||
}
|
||||
|
||||
function resetCreeps(){
|
||||
Object.values(Game.creeps).forEach(creep => creep.suicide());
|
||||
return "OK";
|
||||
}
|
||||
|
||||
function resetConstruction(){
|
||||
Object.values(Game.rooms).forEach(room=>room.find(FIND_CONSTRUCTION_SITES).forEach(cs=>cs.remove()));
|
||||
return "OK";
|
||||
}
|
||||
|
||||
function buildRoads(){
|
||||
Object.values(Game.rooms).forEach(room=>
|
||||
{
|
||||
room.memory.layout.sources.forEach(
|
||||
sId => {
|
||||
const source = Game.getObjectById(sId);
|
||||
var roads = [];
|
||||
roads = roads.concat(source.pos.findPathTo(room.controller));
|
||||
roads.pop();
|
||||
roads = roads.concat(source.pos.findPathTo(room.find(FIND_MY_STRUCTURES, { filter:{ structureType:STRUCTURE_SPAWN }})[0]));
|
||||
roads.pop();
|
||||
roads.forEach(tile => room.createConstructionSite(tile.x, tile.y, STRUCTURE_ROAD));
|
||||
}
|
||||
);
|
||||
});
|
||||
return "OK";
|
||||
}
|
||||
Reference in New Issue
Block a user