Skip to content

Game UI and basic scripting

Warren Earle edited this page Jun 21, 2016 · 30 revisions

Game UI and basic scripting

The game world consists of multiple playing fields and a single playingfield is called a "room". In the real game, rooms are connected to each other with exits, but in the simulation mode only one room is available to you.

The game world consists of interconnected rooms. A room is a closed space 50x50 cells in size. It may have 1-4 exits to other rooms. A number of rooms in the world is limited, but increases as new players join the game. So the single game world is really huge and constantly expanding, like the Universe itself.

Game World Map

Each room landscape is unique. The view of each room is generated procedurally and consists of three types of surface:

Plain land – simple ground with a movement cost of 2. Swamps increase a movement cost to 10. Walls block movement of all creeps. You can customize the room landscape with the help of the following facilities:

Roads decrease a movement cost to 1. Roads deteriorate due to movement and require repair. Constructed walls can be created by players. Unlike natural walls, they may be attacked and destroyed by creeps. Ramparts are your defenses. Only your creeps may move inside your ramparts. Besides, a creep inside a rampart cell cannot be attacked until the rampart is destroyed (though it can attack others). Ramparts deteriorate with each game cycle and require repair. In the beginning of the game, you are free to choose the place for your new colony in one of the free rooms inside the zone of the game world available for settlement. After your first spawn is set up, your room will be blocked by walls defending from outside attacks for 3 days. Use this time to create good defenses, or any player will be able to destroy your colony! You can lift this blockade earlier than 3 days – just destroy these walls yourself. The object in the center of the screen is your first spawn, your colony center.

screeps User Interface

You play by writing code in the panel in the bottom of the screen.

Click the "Console" tab.

You can enter your code in this field. It will run once.

Type anything in this field and press Enter.

Your command returns a response (or execution error) in the console below.

For example this command :- "\n\n\n\n\n\n\n\n\n\n\n" sends 11 line feeds to console

All output is duplicated into your browser console (Ctrl+Shift+J) where you can expand objects for debugging purposes. You can open and close the bottom panel by pressing Alt+Enter.

Console image

The spawn: your colony center

Colony Centre

Energy sources are the main game resource. They can be harvested by worker creeps. The amount of energy in a source is limited, but resumes once in 5 minutes.

Spawns are your colony centers. They can accumulate mined energy and use it to create your units. There may be no more than 3 spawns in a room. Hence, by bulding 3 spawns in a room you actually conquer it. You can have multiple spawns totally in all your rooms though.

A spawn itself can build only basic units. In order to build more complex ones, you have to construct one or more spawn extensions.

You build (spawn) units called creeps the same way as in other strategy games, but with one exception: you construct the "body" of a new creep out of 7 available body part types, the resulting body being a sequence up to 50 parts. It allows thousands of creep types and their roles: ordinary workers, huge construction machines able to build or repair a structure within a few cycles, weaselly couriers, heavy capacious trucks, fast and cheap scouts, well-equipped fighters with regeneration ability, etc. It may even be creeps resembling towers or fortresses for mining, defending, or seizing, with very little speed (couple of tiles per minute), but monstrous characteristics. Everything is up to you, your tactics and imagination.

However, remember that any creep has a life cycle of 1500 game ticks (approx. 30-60 minutes depending on the tick duration). Then it "ages" and dies. So you need not just to control existing creeps but set up manufacturing and automatic control of superseding generations of your creeps.

A standard spawn can spawn only regular creeps with the total cost of up to 300 energy units. Spawning more expensive creeps requires a spawn extension in the room. Each extension can contain up to 50 extra energy units that may be spent on creation of a creep.

Your spawn creates new units called "creeps" by its method createCreep. Usage of this method is described in the documentation. Each creep has a name and certain body parts that give it various skills.

You can address your spawn by its name the following way: Game.spawns.Spawn1.

Create a worker creep with the body array [WORK,CARRY,MOVE] and name Harvester1 (the name is important for the tutorial!). You can type the code in the console yourself or copy & paste the hint below.

Game.spawns.Spawn1.createCreep( [WORK, CARRY, MOVE], 'Harvester1' );

Creeps Skills

Possible part types of a creep body:

  • WORK – ability to harvest energy, construct and repair structures, upgrade controllers.
  • MOVE – ability to move.
  • CARRY – ability to transfer energy.
  • ATTACK – ability of short-range attack.
  • RANGED_ATTACK – ability of ranged attack.
  • HEAL – ability to heal others.
  • CLAIM - ability to claim territory control.
  • TOUGH – "empty" part with the sole purpose of defense.

The effectiveness of an ability depends on the amount of parts of a corresponding type. For example, a worker creep with 3 parts of the WORK type will work 3 times as effectively as a creep with only 1 WORK part. The same applies to all the other types and actions.

Movement

Each body part has its own physical weight: the more parts a creep bears, the more difficult it is for it to move. Each body part (except MOVE) generates fatigue points when the creep moves: 1 point per body part on roads, 2 on plain land, 5 on swamp. Each MOVE body part decreases fatigue points by 2 per tick. The creep cannot move when its fatigue is greater than zero.

Thus, to maintain the maximum movement speed of 1 square per tick, a creep needs to have as many MOVE parts as all the other parts of its body combined. In other words, one MOVE part can move one other part one square per tick. If a creep has less MOVE parts, its movement will be proportionally slowed which is seen by the increasing fatigue.

It's worth noting that the CARRY part generates fatigue only when it is filled with resources.

  • Creep [CARRY, WORK, MOVE] will move 1 square per tick if it does not bear energy, and 1 square per 2 ticks if loaded.
  • Creep [TOUGH, ATTACK, ATTACK, MOVE, MOVE, MOVE] will move at maximum speed of 1 square per tick.
  • Creep [TOUGH, ATTACK, ATTACK, MOVE, MOVE] will move 1 square per 2 ticks because of rounding up.

Damage

The total amount of hits a creep has depends of the amount of its body parts – 100 hits per each part. The order in which the parts were specified during the spawning of a creep also has a bearing. Under attack, the first parts to take hits are those specified first. Full damage to a part leads to complete disabling of it – the creep can no longer perform this function.

Game object

You operate the game through the global Game object which is described in detail in the API Reference section. This object lets you access the complete list of your creeps, "review" rooms, pass commands, etc.

var target = Game.spawns.Spawn1;
for(var i in Game.creeps) {
    Game.creeps[i].moveTo(target);
}

No changes in the Game object are passed from tick to tick. Even if you manually change any properties of the object, it will not affect the game state. Changing properties and giving commands are possible only through special methods of game objects.

The Game object is created from scratch and filled with data at each tick. In order to memorize information between game ticks, you can use the Memory object. See the next article for more about it.

Clone this wiki locally