Skip to content
Sriep edited this page Aug 6, 2016 · 3 revisions

Route

These are orders that can be put on a rooms build queue. route.base handles the build queues.

Routes are added to the build queue uisng the roueBase.attachRoute(roomName, routeType, order, priority, reference) member funciton. Each route in the build queue has a due, poriority and respawn memeber.

How to decided next build

  • The due value for each creep order is decremented by one each tick.
  • Only orders with due less than or equal to zero are options to be spawned.
  • The order with the highest priority and due <= 0 is chosen to be spawned each tick.
  • If two orders have the same priority, then the order with the lowest due is chosen.
  • After an ordered creep is succesfully spawned its respawn valeu is examined. If its respawn value is zero the route is removed from the build queue. If it is nonzero then the due value is set to the respawn value. This allows reqular repeatable creep builds.

Requirments for a route object

  • The filename should start "route."
  • The main exported function is a constructor.
  • The constructor must create a type member with a value equal to the part of the filename after "route.". Ideally there should be a matching ROUTE_ entry in gc.js
  • There should be prototype.spawn(build, spawn) function which takes the build details and a spawn and attepts to spawn a creep and returning the result of a call to spawn.createCreep.

Here is an example, the stats object is a wrapper added by a statistics object that recoders all creep builds.

RouteScout.prototype.spawn = function (build, spawn) {
    var name = stats.createCreep(spawn, build.body, undefined, undefined);
    if (_.isString(name)) {
        roleBase.switchRoles(Game.creeps[name],
            gc.ROLE_SCOUT,
            build.targetRoom
        );
        Game.creeps[name].memory.buildReference = build.targetRoom;
    }
    return name;
};
Clone this wiki locally