User Tools

Site Tools


This is an old revision of the document!

World (Module)

Native module that provides bindings to objects in the game world.


consolePlayer ( )

Returns an object representing the console player (App.Player).

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:

  • [350, -1000] would place the new thing on the floor at X=350, Y=-1000.
  • [350, -1000, 50] would place the new thing at X=350, Y=-1000, Z=50.

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])

attack ( damage : Number, missileId : Number )

(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.

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.

Thing ID of the dropped item.
XY momentum of the dropped item (direction is randomly chosen).
Z momentum of the dropped item. Positive values cause the item to be thrown upward after being spawned.
Spawn position Z offset. The default value 0.5 causes the item to be spawn at the middle of the dropper thing. 1.0 would spawn the item at the top of the dropper.
Chance of dropping. The default 1.0 means 100% certainty.

Returns the dropped thing as a World.Thing, or None.

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 the 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.

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.

type ( )

Returns the internal type number of the thing. This is an element index number in the Defs.things.order array.


Flags for spawnThing()

Spawn thing as deaf.
Spawn thing in the ceiling.
Spawn thing at the floor.
script/module/world.1577006925.txt.gz · Last modified: 2019-12-22 11:28 by skyjake