Screeps Wiki
Advertisement

The Creep is one of the primary entities used in Screeps. Creeps are created at player spawns, and are made up of several body parts - each capable of performing various actions (e.g. - harvesting energy, moving around the room, building structures, and engaging in combat).

Creeps

Body Parts

Creeps are composed of a sequence of one to thirty of the seven different body parts. These components each provide the creeps with 100 hit points and a corresponding ability. Each part has weight, which increases creep fatigue as it traverses terrain tiles, with the exception of the MOVE module; the more parts a creep bears, the more difficult it is for it to move.

Body part Build cost Effect
MOVE 50 Moves the creep. Reduces creep fatigue by 1/tick. See movement.
WORK 20 Harvests energy from target source. Gathers 2 energy/tick.
Constructs a target structure. Builds the designated structure at a construction site, at 5 points/tick, consuming 5 energy/tick. See building Costs.
Repairs a target structure. Repairs a structure for 15 hits/tick. Consumes 0.1 energy/hit repaired.
CARRY 50 Stores energy. Contains up to 50 energy units. Weighs nothing when empty.
ATTACK 80 Attacks a target creep/structure. Deals 30 damage/tick. Short-ranged attack (1 tile).
RANGED_ATTACK 150 Attacks a target creep/structure. Deals 15 damage/tick. Long-ranged attack (1 to 3 tiles).
HEAL 200 Heals a target creep. Restores 10 hit points/tick.
TOUGH 5 No effect. Provides cheap hit points to creep body.

It is important to note that the order in which parts are added to a creep is important! The sequence of parts dictate which components will be damaged first when a creep is attacked. If a part takes 100 points of damage, it will be completely disabled - the creep may no longer use that part's ability.

Sequence of Actions

Creeps will get several actions scheduled to execute per tick. These will then be executed in a fixed order. Not all actions can be executed, for example a creep can't heal and attack in 1 tick.

  1. dropEnergy
  2. transferEnergy
  3. pickup
  4. heal or repair or build or attack or harvest
  5. rangedAttack
  6. suicide

Important to note is that rangedAttack is separate from attack and heal. A creep can therefore do both in 1 tick.

Movement

Restrictions

An ai can order a creep to move. However, there are restrictions that might limit the creeps to be able to do so:

  • A fatigue creep will not move until its fatigue has been vanished
  • Physical limits might prevent a creep from moving, sometimes even if the move order succeed (ordering a creep to walk where an other creeps has walked to will not work)
  • You can only order your own creeps (ordering enemy creeps to move might not work, for example)
  • Creeps are required to have at least one MOVE body part to be capable of movement (a creep might have spawned without, enemies might have disabled all MOVE body parts)

When moving

If a creep manages to move:

  • Creeps do gain fatigue dependent on the terrain surface its arriving (current terrain fatigue factors are 1x for roads, 2x for plains and 10x for swamps)
  • The fatigue factor multiplied by the fatigue gained by the creep itself is the total fatigue to be added to the creep (a creep generating 4 fatigues on swamps with factor 10, has a total of 40 fatigue)
  • To calculate the fatigue of the creep alone without the road factor:
    • Every body part adds 1 fatigue cost
    • Move parts and empty CARRY parts are an exception and add 0 fatigue cost instead of 1

Fatigue reduction

Fatigue will be reduced at a rate of active MOVE parts times 2. A creep with 2 MOVE parts, allows a creep to loose 4 fatigue per game tick. Fatigue will not drop below 0.

Formule

Fn = Fc + (W x Tf x Fz) - (2 x M)

Where:

  • Fn = new fatigue
  • Fc = current fatigue
  • W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
  • Tf = terrain factor (1x for roads, 2x for plains, 10x for swamp)
  • Fz = Fatigue equals to zero (1x if fatigue is 0, 0x if fatigue > 0)
  • M = number of MOVE parts

Calculating movement

Therefore, to maintain the maximum movement speed of 1 tile/tick over plain terrain, a creep must have at least as many MOVE parts as all the other body parts combined. Note that fatigue may never be reduced to below 0. If a creep has fewer MOVE parts than its weight dictates, its movement speed will be slowed accordingly, as seen by the increased number of ticks needed to recover from its fatigue.

Using the formula above with  [ATTACK, ATTACK, TOUGH, MOVE, MOVE], crossing a plain terrain tile:

Tick 1, move 1 tile: Fn = 0 + (3 x 2 x 1) - (2 x 2) => 0 + 6 - 4 => 2 fatigue
Tick 2, fatigued: Fn = 2 + (3 x 2 x 0) - (2 x 2) => 2 + 0 - 4 => -2 => 0 fatigue
Tick 3, move 1 tile: ...

Some other examples:

[WORK, MOVE]: 1 tile/tick.
[WORK, CARRY, MOVE]: 1 tile/tick if not bearing energy, 1 tile/2 ticks if loaded.
[ATTACK, ATTACK, MOVE, MOVE]: 1 tile/tick.

Calculating movement rate

Tweaking the formule given above can make it easier to calculate the expected move rate

Mr = ceil((W x Tf x Fz) / (2 x M))

Where:

  • Mr= Movement rate
  • Fc= current fatigue
  • W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
  • Tf= terrain factor (1x for roads, 2x for plains, 10x for swamp)
  • Fz= Fatigue equals to zero (1x if fatigue is 0, 0x if fatigue > 0)
  • M = number of MOVE parts

Doing Work

Creeps with the WORK body part can perform a variety of tasks.

Harvesting

Harvesting is performed on energy source tiles. Creeps are able to harvest energy at a rate of 2 energy/tick per WORK module. If a creep does not have any CARRY body parts, or it reaches its carrying capacity, it cannot hold the energy harvested, and will instead drop the energy to the ground.

Construction

Creeps can construct structures on construction sites, at a rate of 5 points/tick, costing 1 energy/tick, per WORK module. If a creep does not have any CARRY body parts, it cannot provide the necessary energy to build the structure.

Repair

Repairing is done to target damaged structures. A creep can restore 15 points/tick to a target structure, spending 0.1 energy per hit point repaired, per WORK module equipped. If a creep does not have any CARRY body parts, it cannot provide the necessary energy to repair the structure.

API

Methods

  • attack(target)
  • build(target)
  • dropEnergy([amount])
  • getActiveBodyParts(type)
  • harvest(target)
  • heal(target)
  • move(direction)
  • moveTo(x,y)
  • moveTo(target, [opts])
  • pickup(target)
  • rangedAttack(target)
  • repair(target)
  • suicide()
  • transferEnergy(target, [amount])

Properties

  • id
  • name
  • owner
  • room
  • pos
  • memory
  • my
  • spawning
  • body
  • energy
  • energyCapacity
  • hits
  • hitsMax
  • ticksToLive
  • fatigue

References

Advertisement