User Guide
Quick Reference
Modding
Development
User Guide
Quick Reference
Modding
Development
Native module that provides bindings to objects in the game world.
listThings ( thingId : Text )
Searches the map for all things of type thingId and returns an array of World.Thing references.
spawnThing ( type : Text, pos : Array, angle : Number = None, flags : Number = 0 )
Spawns a new thing at the specified coordinates pos. The type must be an existing Thing ID, for example “POSSESSED”.
The pos can be specified either in 2D or 3D:
Note that positions of existing things can be queried with Thing.pos()
.
angle is the compass direction where the new thing will be facing (degrees). If None, a random direction is chosen.
flags is for spawn flags. See the World.MSF constants.
Base class for mobjs.
addMom ( momentum : Array )
Modifies the momentum of the thing by adding the 3D vector momentum. For example, this would throw the thing up in the air a bit:
self.addMom([0, 0, 10])
angle ( )
(Availability: added in 2.3.2)
Returns the angle of the thing: 0 = East, 90 = North, 180 = West, 270 = South.
attack ( damage : Number, missileId : Text )
(Availability: 2.2, only in Heretic.)
Starts the attack action of an enemy by calling the native function P_Attack()
. If the current target of the enemy is in the melee range, damage points of damage will be dealt. Otherwise, a missile is spawned. missileId must be a valid Thing ID.
changeFlags ( index : Number, flags : Number, doSet : Number )
Changes thing flags. Each thing has three 32-bit integers for storing flags: index is 1, 2 or 3, for flags
, flags2
and flags3
. flags is a bitmask specifying which flags are being changed. If doSet evaluates to True, the flags will be set. Otherwise they will be unset.
dropItem ( type : Text, force : Number = 1.0, lift : Number = 0.0, height : Number = 0.5, prob : Number = 1.0 )
Spawns an item at the position of the self thing.
Returns the dropped thing as a World.Thing, or None.
flags ( index : Number )
Returns thing flags. Each thing has three 32-bit integers for storing flags: index is 1, 2 or 3, for flags
, flags2
and flags3
.
health ( )
Returns the remaining hit points of the thing (as a Number).
height ( )
Returns the current height of the thing.
id ( )
Returns the ID number of the thing.
info ( )
Returns the definition of the thing.
mom ( )
Returns the 3D momentum of the thing as an array (XYZ).
player ( )
If the thing belongs to a player, returns an object representing that player (see App.Player). Otherwise returns None
.
pos ( )
Returns the 3D position of the thing as an array (XYZ). This position is at the bottom center of the thing's bounding box.
One can add Thing.height()
to the returned Z coordinate to get the top of the thing's bounding box.
recoil ( force : Number )
Pushes the thing backwards by force units. For example, the Heretic Phoenix Rod uses a recoil of 4 units. The current direction of the thing determines which direction the recoil is applied.
setAngle ( degrees : Number )
(Availability: added in 2.3.2)
Changes the angle of the thing to degrees. 0 = East, 90 = North, 180 = West, 270 = South.
setNoBlocking ( )
Unsets the MF_SOLID (0x2) flag.
spawnMissile ( id : Text, angle : Number = None, momz : Number = 0.0 )
Spawns a missile originating from the thing.
id is the Thing definition ID of the spawned missile.
The angle is a compass direction (0…360, degrees). 0 = East, 90 = North, etc. If its value is set, the missile will use this compass direction instead of being aimed at the thing's current target object. Setting this is useful if spawning multiple missiles going in multiple directions, e.g., with 45 degree increments. A for loop could be used in the script for this purpose.
momz is the vertical momentum of the missile, so this can give it a slope going up or down, but on the XY plane the speed will always be the same regardless.
startSound ( id : Text, volume : Number = 1.0 )
Starts playing a sound using the thing as the emitter. By default, the volume is at maximum (1.0). There must be a Sound definition with a matching id.
target ( )
Returns a reference to the thing's target, or None.
tracer ( )
Returns a reference to the tracer thing, or None. This is typically used for homing missiles.
type ( )
Returns the internal type number of the thing. This is an element index number in the Defs.things.order array.
Note that the Thing definition ID (a text string) can be queried by Thing.info().id
.