npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

screeps-movement

v1.1.2

Published

A screeps movement library.

Downloads

10

Readme

Screeps Movement

This package is a replacement for the standard Screeps moveTo function.

It has the following features:

  • Path caching / stuck detection
  • Avoids static creeps
  • Push past other creeps
  • Calculates terrain costs
  • Avoid source keepers
  • Avoid / track hostile rooms

In addition it adds the following methods to the Creep type:

  • moveToRoom
  • moveOffRoad
  • fleeFrom
  • setStatic

Install:

Install via NPM in your local dev environment npm install screeps-movement.

Or if you are using the screeps client then create a new module called 'screeps-movement' and copy the contents of this file into it.

Usage

Import the module in your main file. (At the top outside the loop)

JavaScript:

const Movement = require("screeps-movement");

TypeScript:

import * as Movement from "screeps-movement";

Configuration

Optionally, you can apply some custom configuration. It isRecommended to do this immediately after the import statement.

Movement.setConfig(config);

Config Options:

interface CreepsMovementConfig {
    allies?: string[];
    visualise?: boolean;
    calculateCarryWeight?: boolean;
    trackHostileRooms?: boolean;
    defaultStuckLimit?: number;
    staticCreepFilter?: (creep: Creep) => boolean | false;
}

Default Config:

calculateCarryWeight: false,
defaultStuckLimit: 5,
staticCreepFilter: defaultIsStatic, // See setStatic() method below.
trackHostileRooms: false,
visualise: true,

creep.moveTo(target, opts?);

The replacement moveTo should/might/possibly could (who knows) work with any standard moveTo calls you make at present. However additional options have been added that you can now take advantage of.

Any option you can currently pass in via either the PathFinderOpts or MoveToOpts as doucmented in the official screeps documentation has at least a slight chance of working correctly.

However certain things, such as setting the roomCallBack will not work or cause unintended consiquences. As such it is recommended that you use the following options.

worker.moveTo(target.pos, {
    avoidSk?: boolean,                          // Avoid SourceKeepers
    maxStuck?: number,                          // Max ticks before repathing due to being stuck
    plainCost?: number,                         // Plain cost (calculated if not specified)
    swampCost?: number,                         // Swamp cost (calculated if not specified)
    avoidRooms?: string[],                      // An array of roomNames to avoid
    avoidCreeps?: boolean,                      // Avoid creeps when pathing
    avoidHostileRooms?: boolean,                // Avoid tracked hostile rooms if trackHostileRooms option is enabled globally
    range?: number,                             // The range to the target you want to reach
    pushPastFilter?: (creep) => boolean,        // A predicate to determin if the creep should push past another creep.
});
miner.moveTo(source, {
    avoidHostileRooms: true
    range: 1,
    pushPastFilter: (creep) => creep.memory.role === "hauler",
});

You must enable trackHostileRooms in the global options for the avoidHostileRooms option to work.

creep.moveToRoom(roomName, range?);

Your creep will move to the given room at the given range from room center (default 23).

creep.moveToRoom("W7N4"); 
creep.moveToRoom("W7N4", 30); // Move to 5 tiles away from the room.
creep.moveToRoom("W7N4", 10); // Move 15 tiles into the room. 

creep.moveOffRoad(towards?);

Your creep will move off road.

towards - Optional. RoomObject | RoomPosition.

If specified the creep will only move onto an off road spot that is of equal or lesser distance than its current position. The creep will move towards the target if no offroad spot can be found.

if (container.store.energy > creep.carryCapacity || creep.pos.getRangeTo(container) > 5) {
    creep.moveTo(container);
} else {
    creep.moveOffRoad(container);
}

creep.fleeFrom(targets, distance?, maxRooms?);

Your creep will flee from the targets up to the distance specified (default 10). maxRooms can optionally be set (default 1).

const enemies = creep.room.find(FIND_HOSTILE_CREEPS);
if (enemies.length > 0 && creep.pos.findInRange(enemies, 10).length) {
    creep.fleeFrom(enemies, 7);
}

creep.setStatic(value?);

If you don't override the staticCreepFilter method in the global movement options (above). Then you can use this method to ensrure the creeps position is avoided by the pathfinder.

if (creep.memory.inPosition) {
    creep.setStatic(false);
    creep.moveTo(constructionSite);
} else {
    creep.setStatic();
    creep.build(constructionSite);
}