Module alien
Alien related variables and functions
Functions
remove () | Removes the alien from the map. |
Fields
exists | Whether or not the alien exists in the level. |
x | The absolute x-position of the alien. |
y | The absolute y-position of the alien. |
minX | The lowest x-position the alien can try to randomly move to. |
maxX | The highest x-position past the alien can try to randomly move to. |
minY | The lowest y-position the alien can try to randomly move to. |
maxY | The highest y-position the alien can try to randomly move to. |
alienspeed | A multiplier applied to the alien's movement speed. |
alienvelx | The alien's current horizontal velocity, measured in pixels per second. |
alienvely | The alien's current vertical velocity, measured in pixels per second. |
alienmaxvel | The maximum possible speed of the alien along each axis, measured in pixels per second. |
alienmaxaccel | The maximum amount of random acceleration that can be applied to each axis of the alien's velocity each tick. |
aimangle | The initial rotation, in degrees, of the alien's next bullet. |
aimanglerandomness | A multiplier that controls by how many degrees aimangle can change whenever ammo hits 0. |
ammo | How many ticks of shooting remain. |
maxammo | The maximum ammo the alien can reload to. |
minammo | The minimum ammo the alien can reload to. |
ammothreshold | The ammo threshold for the alien's shooting. |
accel | The acceleration of the alien's next bullet (the amount of speed added per tick). |
damage | The amount of damage the alien's next bullet will deal. |
explode | Whether or not the alien's next bullet will be destroyed on impact. |
knockback | The strength of the knockback the alien's next bullet will deal. |
maxvel | The maxmimum velocity of the alien's next bullet in pixels per tick. |
range | The maximum lifetime of the alien's next bullet in ticks before they are deleted. |
recovery | The time in milliseconds a hurt player will spend recovering from the alien's next bullet's damage. |
reload | The delay in ticks after firing a bullet before the alien can fire another. |
speed | The speed of the alien's next bullet in pixels per tick. |
rotationspeed | The rotation speed of the alien's next bullet in degrees per tick. |
rotationrandomness | A multiplier applied every tick to the alien's next bullet's random rotation. |
Functions
- remove ()
- Removes the alien from the map. Sets the exists field to false.
Fields
- exists
- Whether or not the alien exists in the level. Calling remove sets this to false. Read-only.
- x
- The absolute x-position of the alien.
- y
- The absolute y-position of the alien.
- minX
- The lowest x-position the alien can try to randomly move to.
- maxX
- The highest x-position past the alien can try to randomly move to.
- minY
- The lowest y-position the alien can try to randomly move to.
- maxY
- The highest y-position the alien can try to randomly move to.
- alienspeed
- A multiplier applied to the alien's movement speed. By default 1
- alienvelx
- The alien's current horizontal velocity, measured in pixels per second.
- alienvely
- The alien's current vertical velocity, measured in pixels per second.
- alienmaxvel
- The maximum possible speed of the alien along each axis, measured in pixels per second. By default 10
- alienmaxaccel
- The maximum amount of random acceleration that can be applied to each axis of the alien's velocity each tick. By default 0.5
- aimangle
- The initial rotation, in degrees, of the alien's next bullet. This is set to a random angle whenever the alien's ammo reaches 0.
- aimanglerandomness
- A multiplier that controls by how many degrees aimangle can change whenever ammo hits 0. Default value 1 means full range (180 degrees), 0.5 means half range (90 degrees), 0 means aimangle is locked, etc.
- ammo
- How many ticks of shooting remain. This number decreases by 1 every tick regardless of if the alien fires a bullet during that tick or not. By default, the alien will spawn with maxammo ammo.
- maxammo
- The maximum ammo the alien can reload to. Upon reaching 0 ammo, the alien will reload a random amount of ammo between minammo and maxammo. By default 200
- minammo
- The minimum ammo the alien can reload to. Upon reaching 0 ammo, the alien will reload a random amount of ammo between minammo and maxammo. By default 25% of maxammo
- ammothreshold
-
The ammo threshold for the alien's shooting. The alien's ammo must be below this amount (and above 0) for any bullets to be spawned.
By default 75% of maxammo
Usage:
-- Creates an alien that fires one bullet every 2 ticks without ever pausing its shooting, and very rarely changes its aim direction. local myAlien = game.level.newAlien(1, os.time(), toobject{ reload = 2, -- Fire every 2 ticks maxammo = 4000, -- Start with 4000 ammo ammothreshold = 5000 -- Enable shooting when ammo is below 5000 (which is always the case, since the max is 4000) })
- accel
- The acceleration of the alien's next bullet (the amount of speed added per tick). By default 1
- damage
- The amount of damage the alien's next bullet will deal. By default 1
- explode
- Whether or not the alien's next bullet will be destroyed on impact. By default true
- knockback
- The strength of the knockback the alien's next bullet will deal. By default 1
- maxvel
- The maxmimum velocity of the alien's next bullet in pixels per tick. By default 20.5
- range
- The maximum lifetime of the alien's next bullet in ticks before they are deleted. By default 100
- recovery
- The time in milliseconds a hurt player will spend recovering from the alien's next bullet's damage. By default 2500
- reload
- The delay in ticks after firing a bullet before the alien can fire another. Setting this to 0 will disable the alien's shooting. By default 5
- speed
- The speed of the alien's next bullet in pixels per tick. By default 14.5
- rotationspeed
- The rotation speed of the alien's next bullet in degrees per tick. By default 0
- rotationrandomness
- A multiplier applied every tick to the alien's next bullet's random rotation. By default 1