Screeps Wiki
(→‎Methods: Update api)
Tags: Visual edit apiedit
Tag: Visual edit
(19 intermediate revisions by 11 users not shown)
Line 4: Line 4:
   
 
==Body Parts==
 
==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.
+
Creeps are composed of a sequence of one to fifty 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.
 
{| border="0" cellpadding="1" cellspacing="1" class="article-table" style="width: 100%;"
 
{| border="0" cellpadding="1" cellspacing="1" class="article-table" style="width: 100%;"
 
|-
 
|-
Line 13: Line 13:
 
|MOVE
 
|MOVE
 
|50
 
|50
|Moves the creep. Reduces creep fatigue by 1/tick. See [[Creep#Movement|movement]].
+
|Moves the creep. Reduces creep fatigue by 2/tick. See [[Creep#Movement|movement]].
 
|-
 
|-
 
| rowspan="3" |WORK
 
| rowspan="3" |WORK
| rowspan="3" |20
+
| rowspan="3" |100
 
|Harvests [[energy]] from target [[source]]. Gathers 2 energy/tick.
 
|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 1 energy/point. See [[Structure#Building Costs|building Costs]].
 
|Constructs a target [[structure]]. Builds the designated structure at a [[construction site]], at 5 points/tick, consuming 1 energy/point. See [[Structure#Building Costs|building Costs]].
 
|-
 
|-
|Repairs a target structure. Repairs a structure for 20 hits/tick. Consumes 0.1 energy/hit repaired, rounded up to the nearest whole number.
+
|Repairs a target structure. Repairs a structure for 100 hits/tick. Consumes 0.01 energy/hit repaired, rounded up to the nearest whole number.
 
|-
 
|-
 
|CARRY
 
|CARRY
Line 36: Line 36:
 
|-
 
|-
 
|HEAL
 
|HEAL
|200
+
|250
 
|Heals a target creep. Restores 12 hit points/tick at short range (1 tile) or 4 hits/tick at a distance (up to 3 tiles).
 
|Heals a target creep. Restores 12 hit points/tick at short range (1 tile) or 4 hits/tick at a distance (up to 3 tiles).
 
|-
 
|-
 
|TOUGH
 
|TOUGH
|20
+
|10
 
|No effect other than the 100 hit points all body parts add. This provides a cheap way to add hit points to a creep.
 
|No effect other than the 100 hit points all body parts add. This provides a cheap way to add hit points to a creep.
  +
|-
  +
|CLAIM
  +
|600
  +
|
 
|}
 
|}
 
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.
 
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.
Line 57: Line 61:
 
# suicide
 
# suicide
   
Important to note is that rangedAttack is separate from attack and heal. A creep can therefore do both in 1 tick.
+
Important to note is that rangedAttack is separate from attack and heal. A creep can therefore do both in 1 tick.
 
==Movement==
 
==Movement==
   
Line 63: Line 67:
 
AI can order a creep to move. However, there are restrictions that might limit the creeps to be able to do so:
 
AI can order a creep to move. However, there are restrictions that might limit the creeps to be able to do so:
 
* A creep having fatigue will not move until its fatigue reaches 0
 
* A creep having fatigue will not move until its fatigue reaches 0
* Creep cannot walk into a wall, a structure (unless this is its own ramparts), or into another creep (unless the other creep moves to another tile during the same tick)
+
* Creep cannot walk into a wall, a structure (unless this is its own ramparts or a container), or into another creep (unless the other creep moves to another tile during the same tick)
 
* You can only control your own creeps. You cannot control creeps of other players.
 
* You can only control your own creeps. You cannot control creeps of other players.
 
* Creeps must have at least one active MOVE'' ''body part to be able to move. Creep cannot move, if it was spawned without MOVE body parts, or if its all MOVE body parts were destroyed by enemy.
 
* Creeps must have at least one active MOVE'' ''body part to be able to move. Creep cannot move, if it was spawned without MOVE body parts, or if its all MOVE body parts were destroyed by enemy.
Line 69: Line 73:
 
=== When moving ===
 
=== When moving ===
 
* Creep's speed cannot be more than 1 per tick
 
* Creep's speed cannot be more than 1 per tick
* The visited road tile receives 1 damage due to wear
 
   
 
=== Fatigue ===
 
=== Fatigue ===
Depending on proportion of number of MOVE body parts to other body parts which a creep has, and also on type of terrain the creep is stepping into, the creep might acquire non-zero fatigue. This would prevent the creep from making any further movements, until fatigue value drops to zero.
+
Depending on proportion of number of MOVE body parts to other body parts which a creep has, and also on type of terrain the creep is stepping into, the creep might acquire non-zero fatigue. This would prevent the creep from making any further movements, until fatigue value drops to zero.
   
 
As a rule of thumb for the number of MOVE body parts to reach the maximum speed: a creep needs half the number of non-MOVE body parts travelling on road, the same number of non-MOVE body parts travelling on plain and 5 times the number of non-MOVE body parts travelling on swamp.
 
As a rule of thumb for the number of MOVE body parts to reach the maximum speed: a creep needs half the number of non-MOVE body parts travelling on road, the same number of non-MOVE body parts travelling on plain and 5 times the number of non-MOVE body parts travelling on swamp.
   
 
The initial fatigue value, which is acquired after move, could be calculated using the following formula:
 
The initial fatigue value, which is acquired after move, could be calculated using the following formula:
F = W * K - 2 * M
+
F = 2 * (W * K - M)
 
 
 
Where:
 
Where:
 
F = initial fatigue value
 
F = initial fatigue value
 
W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
 
W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
K = terrain factor (1x for road, 2x for plain, 10x for swamp)
+
K = terrain factor (0.5x for road, 1x for plain, 5x for swamp)
 
M = number of MOVE parts
 
M = number of MOVE parts
 
After that, with every game tick creep's fatigue is reduced by 2*M, until its value reaches zero. Creep can make next move at the same moment when its fatigue value has reached zero.
 
After that, with every game tick creep's fatigue is reduced by 2*M, until its value reaches zero. Creep can make next move at the same moment when its fatigue value has reached zero.
   
 
Minimum time between moves could be calculated using the following formula:
 
Minimum time between moves could be calculated using the following formula:
t = ceil(k * W / M)
+
t = ceil(K * W / M)
 
 
 
Where:
 
Where:
 
t = time (game ticks)
 
t = time (game ticks)
k = terrain factor (1x for plain, 0.5x for road, 5x for swamp)
+
K = terrain factor (0.5x for road, 1x for plain, 5x for swamp)
 
W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
 
W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
 
M = number of MOVE parts
 
M = number of MOVE parts
 
For example, when creep has 1 MOVE part and 1 WORK part, when stepping into plain:
 
For example, when creep has 1 MOVE part and 1 WORK part, when stepping into plain:
F = 1 * 2 - 2 * 1 = 0
+
F = 2 * (1 * 1 - 1) = 0
 
t = ceil(1 * 1 / 1) = 1
 
t = ceil(1 * 1 / 1) = 1
 
So after move, creep will not get any fatigue and it will be able to make next move in the next tick. Time between moves is 1 tick.
 
So after move, creep will not get any fatigue and it will be able to make next move in the next tick. Time between moves is 1 tick.
   
 
Another example: creep has 1 MOVE part and 2 ATTACK parts, stepping into plain:
 
Another example: creep has 1 MOVE part and 2 ATTACK parts, stepping into plain:
F = 2 * 2 - 2 * 1 = 2
+
F = 2 * (2 * 1 - 1) = 2
 
t = ceil(1 * 2 / 1) = 2
 
t = ceil(1 * 2 / 1) = 2
 
After move, creep will get 2 fatigue. Creep will not be able to move in the next tick. But in the next next tick fatigue will drop to zero and creep will be able to move. Time between moves is 2 ticks.
 
After move, creep will get 2 fatigue. Creep will not be able to move in the next tick. But in the next next tick fatigue will drop to zero and creep will be able to move. Time between moves is 2 ticks.
Line 107: Line 110:
 
W = 2 + 3 = 5 (CARRY with 0 energy does not count as weight)
 
W = 2 + 3 = 5 (CARRY with 0 energy does not count as weight)
 
M = 3
 
M = 3
F = 5 * 10 - 2 * 3 = 44
+
F = 2 * (5 * 5 - 3) = 44
 
t = ceil(5 * 5 / 3) = 9
 
t = ceil(5 * 5 / 3) = 9
 
After move, creep will get 44 fatigue, which then with every tick will be decreased by 2*M=6. During the following 8 ticks creep will not be able to move, but it could move at 9th tick when fatigue value reaches zero. During these 9 ticks the creep will have the following values of fatigue: 44,38,32,26,20,14,8,2,0.
 
After move, creep will get 44 fatigue, which then with every tick will be decreased by 2*M=6. During the following 8 ticks creep will not be able to move, but it could move at 9th tick when fatigue value reaches zero. During these 9 ticks the creep will have the following values of fatigue: 44,38,32,26,20,14,8,2,0.
Line 117: Line 120:
 
Creeps can construct structures on [[Construction site|construction sites]], at a rate of 5 points/tick, costing 1 energy/point, per ''WORK'' module. If a creep does not have any ''CARRY'' body parts, it cannot provide the necessary energy to build the structure.
 
Creeps can construct structures on [[Construction site|construction sites]], at a rate of 5 points/tick, costing 1 energy/point, per ''WORK'' module. If a creep does not have any ''CARRY'' body parts, it cannot provide the necessary energy to build the structure.
 
===Repair===
 
===Repair===
Repairing is done to target damaged structures. A creep can restore 20 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.
+
Repairing is done to target damaged structures. A creep can restore 100 points/tick to a target structure, spending 0.01 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 ==
 
== API ==
   
 
=== Methods ===
 
=== Methods ===
*attack(target)
+
*[[attack]](target)
* build(target)
+
* [[build]](target)
  +
* [[cancelOrder]](methodName)
* claimController(target)
+
* [[claimController]](target)
* dropEnergy([amount])
+
* [[dropEnergy]]([amount])
 
* getActiveBodyParts(type)
 
* getActiveBodyParts(type)
* harvest(target)
+
* [[harvest]](target)
* heal(target)
+
* [[heal]](target)
* move(direction)
+
* [[move]](direction)
  +
* [[moveByPath]](path)
* moveTo(x,y)
 
* moveTo(target, [opts])
+
* [[moveTo]](x,y)
* pickup(target)
+
* [[moveTo]](target, [opts])
  +
* [[notifyWhenAttacked]](enabled)
* rangedAttack(target)
 
* rangedHeal(target)
+
* [[pickup]](target)
 
* [[rangedAttack]](target)
* rangedMassAttack()
 
* repair(target)
+
* [[rangedHeal]](target)
 
* [[rangedMassAttack]]()
* say(message)
 
  +
* [[repair]](target)
* suicide()
 
 
* [[say]](message)
* transferEnergy(target, [amount])
 
 
* [[suicide]]()
* unclaimController(target)
 
* upgradeController(target)
+
* [[transferEnergy]](target, [amount])
 
* [[unclaimController]](target)
  +
* [[upgradeController]](target)
   
 
=== Properties ===
 
=== Properties ===
Line 153: Line 159:
 
* spawning
 
* spawning
 
* body
 
* body
* energy
+
* store
* energyCapacity
 
 
* hits
 
* hits
 
* hitsMax
 
* hitsMax
 
* ticksToLive
 
* ticksToLive
 
* fatigue
 
* fatigue
  +
* effects
   
 
== References ==
 
== References ==
* Screeps creep api http://screeps.com/docs/Creep.php
+
* Screeps creep api https://docs.screeps.com/api/#Creep
* Game concepts http://screeps.com/docs/concepts.php
 
 
[[Category:Entities]]
 
[[Category:Entities]]
 
[[Category:Objects]]
 
[[Category:Objects]]

Revision as of 02:51, 20 August 2020

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 fifty 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 2/tick. See movement.
WORK 100 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 1 energy/point. See building Costs.
Repairs a target structure. Repairs a structure for 100 hits/tick. Consumes 0.01 energy/hit repaired, rounded up to the nearest whole number.
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 10 damage/tick. Long-ranged attack (1 to 3 tiles).
HEAL 250 Heals a target creep. Restores 12 hit points/tick at short range (1 tile) or 4 hits/tick at a distance (up to 3 tiles).
TOUGH 10 No effect other than the 100 hit points all body parts add. This provides a cheap way to add hit points to a creep.
CLAIM 600

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

See http://support.screeps.com/hc/en-us/articles/203137792-Simultaneous-execution-of-creep-actions for more information.

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 or rangedHeal
  6. move
  7. suicide

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

Movement

Restrictions

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

  • A creep having fatigue will not move until its fatigue reaches 0
  • Creep cannot walk into a wall, a structure (unless this is its own ramparts or a container), or into another creep (unless the other creep moves to another tile during the same tick)
  • You can only control your own creeps. You cannot control creeps of other players.
  • Creeps must have at least one active MOVE body part to be able to move. Creep cannot move, if it was spawned without MOVE body parts, or if its all MOVE body parts were destroyed by enemy.

When moving

  • Creep's speed cannot be more than 1 per tick

Fatigue

Depending on proportion of number of MOVE body parts to other body parts which a creep has, and also on type of terrain the creep is stepping into, the creep might acquire non-zero fatigue. This would prevent the creep from making any further movements, until fatigue value drops to zero.

As a rule of thumb for the number of MOVE body parts to reach the maximum speed: a creep needs half the number of non-MOVE body parts travelling on road, the same number of non-MOVE body parts travelling on plain and 5 times the number of non-MOVE body parts travelling on swamp.

The initial fatigue value, which is acquired after move, could be calculated using the following formula:

F = 2 * (W * K - M)

Where:
    F = initial fatigue value
    W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
    K = terrain factor (0.5x for road, 1x for plain, 5x for swamp)
    M = number of MOVE parts

After that, with every game tick creep's fatigue is reduced by 2*M, until its value reaches zero. Creep can make next move at the same moment when its fatigue value has reached zero.

Minimum time between moves could be calculated using the following formula:

t = ceil(K * W / M)

Where:
    t = time (game ticks)
    K = terrain factor (0.5x for road, 1x for plain, 5x for swamp)
    W = creep weight (Number of body parts, excluding MOVE and empty CARRY parts)
    M = number of MOVE parts

For example, when creep has 1 MOVE part and 1 WORK part, when stepping into plain:

F = 2 * (1 * 1 - 1) = 0
t = ceil(1 * 1 / 1) = 1

So after move, creep will not get any fatigue and it will be able to make next move in the next tick. Time between moves is 1 tick.

Another example: creep has 1 MOVE part and 2 ATTACK parts, stepping into plain:

F = 2 * (2 * 1 - 1) = 2
t = ceil(1 * 2 / 1) = 2

After move, creep will get 2 fatigue. Creep will not be able to move in the next tick. But in the next next tick fatigue will drop to zero and creep will be able to move. Time between moves is 2 ticks.

Another example: creep has 3 MOVE parts, 2 WORK parts, 3 ATTACK parts, 1 CARRY part, 0 energy, stepping into swamp:

W = 2 + 3 = 5 (CARRY with 0 energy does not count as weight)
M = 3
F = 2 * (5 * 5 - 3) = 44
t = ceil(5 * 5 / 3) = 9

After move, creep will get 44 fatigue, which then with every tick will be decreased by 2*M=6. During the following 8 ticks creep will not be able to move, but it could move at 9th tick when fatigue value reaches zero. During these 9 ticks the creep will have the following values of fatigue: 44,38,32,26,20,14,8,2,0.

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/point, 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 100 points/tick to a target structure, spending 0.01 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

Properties

  • id
  • name
  • owner
  • room
  • pos
  • memory
  • my
  • spawning
  • body
  • store
  • hits
  • hitsMax
  • ticksToLive
  • fatigue
  • effects

References