Power Creeps are immortal "heroes" that are tied to your account and can be respawned in any
PowerSpawn
after death.
You can upgrade their abilities ("powers") up to your account Global Power Level (see
Game.gpl
).
Time to live | 5,000 |
Hits | 1,000 per level |
Capacity | 100 per level |
PowerCreep.create('PowerCreep1', POWER_CLASS.OPERATOR);
A static method to create new Power Creep instance in your account. It will be added in an unspawned state,
use
spawn
method to spawn it in the world.
You need one free Power Level in your account to perform this action.
parameter | type | description |
---|---|---|
name
|
string |
The name of the new power creep. |
className
|
string |
The class of the new power creep, one of the
|
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NAME_EXISTS
|
-3 |
A power creep with the specified name already exists. |
ERR_NOT_ENOUGH_RESOURCES
|
-6 |
You don't have free Power Levels in your account. |
Applied effects, an array of objects with the following properties:
parameter | type | description |
---|---|---|
effect
|
number |
Effect ID of the applied effect. Can be either natural effect ID or Power ID. |
level
optional |
number |
Power level of the applied effect. Absent if the effect is not a Power effect. |
ticksRemaining
|
number |
How many ticks will the effect last. |
An object representing the position of this object in the room.
The link to the Room object. May be undefined in case if an object is a flag or a construction site and is placed in a room that is not visible to you.
This property is deprecated and will be removed soon.
An alias for
Creep.store
.
This property is deprecated and will be removed soon.
An alias for
Creep.store.getCapacity()
.
The power creep's class, one of the
POWER_CLASS
constants.
A timestamp when this creep is marked to be permanently deleted from the account, or undefined otherwise.
The current amount of hit points of the creep.
The maximum amount of hit points of the creep.
A unique object identificator. You can use
Game.getObjectById
method to retrieve an object instance by its
id
.
The power creep's level.
creep.memory.task = 'building';
A shorthand to
Memory.powerCreeps[creep.name]
. You can use it for quick access the creep’s specific memory data object.
Learn more about memory
Whether it is your creep or foe.
Power creep’s name. You can choose the name while creating a new power creep, and it cannot be changed later. This name is a hash key to access the creep via the Game.powerCreeps object.
An object with the creep’s owner info containing the following properties:
if(creep.store[RESOURCE_ENERGY] < creep.store.getCapacity()) {
goHarvest(creep);
}
A
Store
object that contains cargo of this creep.
parameter | type | description |
---|---|---|
username
|
string |
The name of the owner user. |
Available powers, an object with power ID as a key, and the following properties:
parameter | type | description |
---|---|---|
level
|
number |
Current level of the power. |
cooldown
|
number |
Cooldown ticks remaining, or undefined if the power creep is not spawned in the world. |
The text message that the creep was saying at the last tick.
The name of the shard where the power creep is spawned, or undefined.
if(!(Game.powerCreeps['PowerCreep1'].spawnCooldownTime > Date.now())) {
Game.powerCreeps['PowerCreep1'].spawn(powerSpawn);
}
The timestamp when spawning or deleting this creep will become available. Undefined if the power creep is spawned in the world.
The remaining amount of game ticks after which the creep will die and become unspawned. Undefined if the creep is not spawned in the world.
creep.move(LEFT);
creep.cancelOrder('move');
//The creep will not move in this game tick
Cancel the order given during the current game tick.
parameter | type | description |
---|---|---|
methodName
|
string |
The name of a creep's method to be cancelled. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been cancelled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of the creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_FOUND
|
-5 |
The order with the specified name is not found. |
Game.powerCreeps['PowerCreep1'].delete();
Delete the power creep permanently from your account. It should NOT be spawned in the world. The creep is not deleted
immediately, but a 24-hours delete timer is started instead (see
deleteTime
). You can cancel deletion by calling
delete(true)
.
parameter | type | description |
---|---|---|
cancel
|
boolean |
Set this to true to cancel previously scheduled deletion. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of the creep. |
ERR_BUSY
|
-4 |
The power creep is spawned in the world. |
creep.drop(RESOURCE_ENERGY);
// drop all resources
for(const resourceType in creep.carry) {
creep.drop(resourceType);
}
Drop this resource on the ground.
parameter | type | description |
---|---|---|
resourceType
|
string |
One of the
|
amount
optional |
number |
The amount of resource units to be dropped. If omitted, all the available carried amount is used. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_ENOUGH_RESOURCES
|
-6 |
The creep does not have the given amount of energy. |
ERR_INVALID_ARGS
|
-10 |
The resourceType is not a valid
|
Game.powerCreeps['PowerCreep1'].usePower(PWR_GENERATE_OPS);
powerCreep.enableRoom(powerCreep.room.controller);
Enable powers usage in this room. The room controller should be at adjacent tile.
parameter | type | description |
---|---|---|
controller
|
StructureController |
The room controller. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_INVALID_TARGET
|
-7 |
The target is not a controller structure. |
ERR_NOT_IN_RANGE
|
-9 |
The target is too far away. |
creep.move(RIGHT);
const path = creep.pos.findPathTo(Game.flags.Flag1);
if(path.length > 0) {
creep.move(path[0].direction);
}
creep1.move(TOP);
creep1.pull(creep2);
creep2.move(creep1);
Move the creep one square in the specified direction.
parameter | type | description |
---|---|---|
direction
|
Creep |number |
A creep nearby, or one of the following constants:
|
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_IN_RANGE
|
-9 |
The target creep is too far away |
ERR_INVALID_ARGS
|
-10 |
The provided direction is incorrect. |
ERR_TIRED
|
-11 |
The fatigue indicator of the creep is non-zero. |
const path = spawn.room.findPath(spawn, source);
creep.moveByPath(path);
if(!creep.memory.path) {
creep.memory.path = creep.pos.findPathTo(target);
}
creep.moveByPath(creep.memory.path);
Move the creep using the specified predefined path.
parameter | type | description |
---|---|---|
path
|
array|string |
A path value as returned from
|
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_FOUND
|
-5 |
The specified path doesn't match the creep's location. |
ERR_INVALID_ARGS
|
-10 |
|
ERR_TIRED
|
-11 |
The fatigue indicator of the creep is non-zero. |
creep.moveTo(10, 20);
creep.moveTo(Game.flags.Flag1);
creep.moveTo(new RoomPosition(25, 20, 'W10N5'));
creep.moveTo(pos, {reusePath: 50});
// Execute moves by cached paths at first
for(const name in Game.creeps) {
Game.creeps[name].moveTo(target, {noPathFinding: true});
}
// Perform pathfinding only if we have enough CPU
if(Game.cpu.tickLimit - Game.cpu.getUsed() > 20) {
for(const name in Game.creeps) {
Game.creeps[name].moveTo(target);
}
}
Find the optimal path to the target within the same room and move to it. A shorthand to consequent calls of pos.findPathTo() and move() methods. If the target is in another room, then the corresponding exit will be used as a target.
parameter | type | description |
---|---|---|
x
|
number |
X position of the target in the same room. |
y
|
number |
Y position of the target in the same room. |
target
|
object |
Can be a RoomPosition object or any object containing RoomPosition . The position doesn't have to be in the same room with the creep. |
opts
optional |
object |
An object containing additional options:
|
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_NO_PATH
|
-2 |
No path to the target could be found. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_FOUND
|
-5 |
The creep has no memorized path to reuse. |
ERR_INVALID_TARGET
|
-7 |
The target provided is invalid. |
ERR_TIRED
|
-11 |
The fatigue indicator of the creep is non-zero. |
Game.powerCreeps['PC1'].notifyWhenAttacked(true);
Toggle auto notification when the creep is under attack. The notification will be sent to your account email. Turned on by default.
parameter | type | description |
---|---|---|
enabled
|
boolean |
Whether to enable notification or disable. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_INVALID_ARGS
|
-10 |
|
const target = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES);
if(target) {
if(creep.pickup(target) == ERR_NOT_IN_RANGE) {
creep.moveTo(target);
}
}
Pick up an item (a dropped piece of energy). The target has to be at adjacent square to the creep or at the same square.
parameter | type | description |
---|---|---|
target
|
Resource |
The target object to be picked up. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_INVALID_TARGET
|
-7 |
The target is not a valid object to pick up. |
ERR_FULL
|
-8 |
The creep cannot receive any more resource. |
ERR_NOT_IN_RANGE
|
-9 |
The target is too far away. |
Game.powerCreeps['PC1'].rename('PC1X');
Rename the power creep. It must not be spawned in the world.
parameter | type | description |
---|---|---|
name
|
string |
The new name of the power creep. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of the creep. |
ERR_NAME_EXISTS
|
-3 |
A power creep with the specified name already exists. |
ERR_BUSY
|
-4 |
The power creep is spawned in the world. |
let powerBank = Game.getObjectById('XXX');
Game.powerCreeps['PowerCreep1'].renew(powerBank);
Instantly restore time to live to the maximum using a Power Spawn or a Power Bank nearby. It has to be at adjacent tile.
parameter | type | description |
---|---|---|
target
|
StructurePowerBank | StructurePowerSpawn |
The target structure. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_INVALID_TARGET
|
-7 |
The target is not a valid power bank object. |
ERR_NOT_IN_RANGE
|
-9 |
The target is too far away. |
const hostiles = creep.pos.findInRange(FIND_HOSTILE_CREEPS, 10);
if(hostiles.length > 0) {
creep.say('OMG!😨');
creep.moveTo(Game.spawns['Spawn1']);
}
else {
doWork(creep);
}
Display a visual speech balloon above the creep with the specified message. The message will be available for one tick. You can read the last message using the
saying
property. Any valid Unicode characters are allowed, including
emoji
.
parameter | type | description |
---|---|---|
message
|
string |
The message to be displayed. Maximum length is 10 characters. |
public
optional |
boolean |
Set to true to allow other players to see this message. Default is false. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
Game.powerCreeps['PowerCreep1'].spawn(Game.getObjectById('XXX'));
Spawn this power creep in the specified Power Spawn.
parameter | type | description |
---|---|---|
powerSpawn
|
StructurePowerSpawn |
Your Power Spawn structure. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of the creep or the spawn. |
ERR_BUSY
|
-4 |
The power creep is already spawned in the world. |
ERR_INVALID_TARGET
|
-7 |
The specified object is not a Power Spawn. |
ERR_TIRED
|
-11 |
The power creep cannot be spawned because of the cooldown. |
ERR_RCL_NOT_ENOUGH
|
-14 |
Room Controller Level insufficient to use the spawn. |
Kill the power creep immediately. It will not be destroyed permanently, but will become unspawned,
so that you can
spawn
it again.
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
if(creep.transfer(storage, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(storage);
}
// transfer all resources
for(const resourceType in creep.carry) {
creep.transfer(storage, resourceType);
}
Transfer resource from the creep to another object. The target has to be at adjacent square to the creep.
parameter | type | description |
---|---|---|
target
|
Creep , Structure |
The target object. |
resourceType
|
string |
One of the
|
amount
optional |
number |
The amount of resources to be transferred. If omitted, all the available carried amount is used. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_ENOUGH_RESOURCES
|
-6 |
The creep does not have the given amount of resources. |
ERR_INVALID_TARGET
|
-7 |
The target is not a valid object which can contain the specified resource. |
ERR_FULL
|
-8 |
The target cannot receive any more resources. |
ERR_NOT_IN_RANGE
|
-9 |
The target is too far away. |
ERR_INVALID_ARGS
|
-10 |
The resourceType is not one of the
|
Game.powerCreeps['PowerCreep1'].upgrade(PWR_GENERATE_OPS);
Upgrade the creep, adding a new power ability to it or increasing level of the existing power. You need one free Power Level in your account to perform this action.
parameter | type | description |
---|---|---|
power
|
number |
The power ability to upgrade, one of the
|
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of the creep. |
ERR_NOT_ENOUGH_RESOURCES
|
-6 |
You account Power Level is not enough. |
ERR_FULL
|
-8 |
The specified power cannot be upgraded on this creep's level, or the creep reached the maximum level. |
ERR_INVALID_ARGS
|
-10 |
The specified power ID is not valid. |
Game.powerCreeps['PowerCreep1'].usePower(PWR_GENERATE_OPS);
Game.powerCreeps['PowerCreep1'].usePower(PWR_OPERATE_SPAWN, Game.spawns['Spawn1']);
Apply one the creep's powers on the specified target.
You can only use powers in rooms either without a controller, or with a
power-enabled
controller.
Only one power can be used during the same tick, each
usePower
call will override the previous one.
If the target has the same effect of a lower or equal level, it is overridden. If the existing effect level is higher, an error is returned.
parameter | type | description |
---|---|---|
power
|
number |
The power ability to use, one of the
|
target
|
RoomObject |
A target object in the room. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of the creep. |
ERR_BUSY
|
-4 |
The creep is not spawned in the world. |
ERR_NOT_ENOUGH_RESOURCES
|
-6 |
The creep doesn't have enough resources to use the power. |
ERR_INVALID_TARGET
|
-7 |
The specified target is not valid. |
ERR_FULL
|
-8 |
The target has the same active effect of a higher level. |
ERR_NOT_IN_RANGE
|
-9 |
The specified target is too far away. |
ERR_INVALID_ARGS
|
-10 |
Using powers is not enabled on the Room Controller. |
ERR_TIRED
|
-11 |
The power ability is still on cooldown. |
ERR_NO_BODYPART
|
-12 |
The creep doesn't have the specified power ability. |
if(creep.withdraw(storage, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(storage);
}
Withdraw resources from a structure or tombstone. The target has to be at adjacent square to the creep. Multiple creeps can withdraw from the same object in the same tick. Your creeps can withdraw resources from hostile structures/tombstones as well, in case if there is no hostile rampart on top of it.
This method should not be used to transfer resources between creeps. To transfer between creeps, use the
transfer
method on the original creep.
parameter | type | description |
---|---|---|
target
|
Structure , Tombstone |
The target object. |
resourceType
|
string |
One of the
|
amount
optional |
number |
The amount of resources to be transferred. If omitted, all the available amount is used. |
One of the following codes:
constant | value | description |
---|---|---|
OK
|
0 |
The operation has been scheduled successfully. |
ERR_NOT_OWNER
|
-1 |
You are not the owner of this creep, or there is a hostile rampart on top of the target. |
ERR_BUSY
|
-4 |
The power creep is not spawned in the world. |
ERR_NOT_ENOUGH_RESOURCES
|
-6 |
The target does not have the given amount of resources. |
ERR_INVALID_TARGET
|
-7 |
The target is not a valid object which can contain the specified resource. |
ERR_FULL
|
-8 |
The creep's carry is full. |
ERR_NOT_IN_RANGE
|
-9 |
The target is too far away. |
ERR_INVALID_ARGS
|
-10 |
The resourceType is not one of the
|