Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 2x 4x 2x 2x 1x 1x 1x 1x 1x 3x 3x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x | const roleScout = {
run: function (creep) {
if (!creep.memory.targetRoom) {
// Fix: Game.map.describeExits() can return null
const exits = Game.map.describeExits(creep.room.name);
if (exits && Object.keys(exits).length > 0) {
const rooms = Object.keys(exits);
const exitValues = Object.values(exits);
creep.memory.targetRoom = exitValues[Math.floor(Math.random() * exitValues.length)];
} else {
// No exits found, stay in current room
creep.say('β οΈ');
return;
}
}
Eif (creep.memory.targetRoom) {
if (creep.room.name !== creep.memory.targetRoom) {
const exitDir = Game.map.findExit(creep.room.name, creep.memory.targetRoom);
const exit = creep.room.findExitTo(creep.memory.targetRoom);
if (exitDir !== ERR_NO_PATH && exit !== ERR_NO_PATH) {
creep.moveTo(new RoomPosition(25, 25, creep.memory.targetRoom));
} else E{
// Path not found, reset target
creep.memory.targetRoom = undefined;
creep.say('π«');
}
} else {
// Arrived at target room
creep.say('π');
// Scan room
const hostiles = creep.room.find(FIND_HOSTILE_CREEPS);
const resources = creep.room.find(FIND_DROPPED_RESOURCES);
const structures = creep.room.find(FIND_STRUCTURES);
// Initialize visited memory if needed
Iif (!creep.memory.visited) {
creep.memory.visited = {};
}
// Record visit
Eif (!creep.memory.visited[creep.room.name]) {
creep.memory.visited[creep.room.name] = {
time: Game.time,
hostiles: hostiles.length,
resources: resources.length,
structures: structures.length,
};
console.log(
`πΊοΈ Scout visited ${creep.room.name}: hostiles=${hostiles.length}, resources=${resources.length}, structures=${structures.length}`
);
}
// Reset target to find new room
creep.memory.targetRoom = undefined;
}
}
},
};
module.exports = roleScout;
|