Skip to content

Instantly share code, notes, and snippets.

Avatar

Clarence "Sparr" Risher sparr

View GitHub Profile
@ags131
ags131 / main.js
Created Sep 14, 2016
Screeps Source Keeper Source
View main.js
PathFinder.use(true);
for (var i in Game.creeps) {
var creep = Game.creeps[i], source = undefined;
if (!creep.room) {
continue;
}
if (creep.memory.sourceId) {
source = Game.getObjectById(creep.memory.sourceId);
}
if(!source) {
@ags131
ags131 / findAttack.js
Created Sep 14, 2016
Screeps Invader Source Code
View findAttack.js
var flee = require('flee');
function checkPath(pos1, pos2) {
var path = pos1.findPathTo(pos2);
if (!path.length) {
return false;
}
return path[path.length - 1].x == pos2.x && path[path.length - 1].y == pos2.y;
}
function costCallbackIgnoreRamparts(roomName, cm) {
var ramparts = Game.rooms[roomName].find(FIND_STRUCTURES, {filter: i => i.structureType == STRUCTURE_RAMPART || i.structureType == STRUCTURE_WALL});
You can’t perform that action at this time.