Aliens

You can access the list of aliens through the array game.aliens

You can also find an alien with a specific id using game.findAlien(id), which returns an object representing the matched alien or null (if no aliens are matching the provided id)

Creation

To create an alien, use game.addAlien({ options })

List of accepted options:

(Note: Server will respond with Incorrect data when at least one input property value is improper)

OptionDescriptionDefault value (if omitted)
xX coordinate0
yY coordinate0
vxVelocity vector X component0
vyVelocity vector Y component0
codeType of alien must be an integer in range [10-20]10
levelLevel of the alien, in range [0-X] where X depends on the alien type0
pointsThe number of points you earn when you kill this alienNone
crystal_dropThe crystal amount to be dropped when this alien is killedNone
weapon_dropThe code of a collectible weapon to be dropped by this alien when killedNone

Here is the list of supported codes:

CodeAlien name
10Chicken
11Crab
12Fortress
13Caterpillar
14Candlestick
15Hirsute
16Piranha
17Pointu
18Fork
19Saucer
20Final Boss

A new Alien object is immediately added to game.aliens; however, it cannot be used before it has been assigned an id (natural number, a.k.a non-negative integer) by the server.

Limits

You can only have 300 alive aliens (including aliens generated by the game mode) at any time in your game

The server will respond with Too many aliens for each alien passing the limit

Accessible fields

For each alien object in game.aliens, You have access to the same properties as the available ones when you add aliens, plus some additional properties:

OptionDescription
gamePoints to the global game object
ida unique identifier for the alien

Configuration

Once an alien is live and has an assigned id, you can set options to it. For example:

> game.aliens[0].set({x:0,y:0});
> █

Will move the first alien in the list to the center of the map

Accepted options when using alien.set:

OptionDescriptionServer response error message (if improper)
xX coordinateWrong coordinate
yY coordinateWrong coordinate
vxVelocity vector X componentWrong coordinate
vyVelocity vector Y componentWrong coordinate
shieldShieldWrong shield value
regenShield regenWrong regen value
damageLaser damageWrong damage value
laser_speedLaser speedWrong damage value
rateFiring rateWrong rate value
killSet kill: (any "truthy" value, e.g: true) to destroy the alienNo violation