Improved walking system.

This commit is contained in:
douwe
2025-08-24 12:08:22 +02:00
parent 98b123ee0d
commit cc0de10471
26 changed files with 858 additions and 154 deletions

25
Screeps/JobMiner.js Normal file
View File

@@ -0,0 +1,25 @@
module.exports = {
begin(creep){},
tick(creep){
const source = Game.getObjectById(creep.memory.job.source);
if(!creep.pos.isNearTo(source)) { creep.moveTo(source); return; }
if(!(Game.time%100)) scanForContainer(creep, source);
moveToContainer(creep);
creep.harvest(source);
}
}
function moveToContainer(creep){
const container = Game.getObjectById(creep.memory.container);
if(!container) return;
if(container.pos.x === creep.pos.x && container.pos.y === creep.pos.y) return;
creep.moveTo(container);
}
function scanForContainer(creep, source){
const container = source.pos.findInRange(FIND_STRUCTURES, 1, {
filter:{structureType:STRUCTURE_CONTAINER}
})[0];
if(container) creep.memory.container = container.id;
}