User Tools

Site Tools


script:module:world

This is an old revision of the document!


World (Module)

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

Functions

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.

World.Thing

Base class for mobjs.

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.

type
Thing ID of the dropped item.
force
XY momentum of the dropped item (direction is randomly chosen).
lift
Z momentum of the dropped item. Positive values cause the item to be thrown upward after being spawned.
height
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.
prob
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).

id ( )

Returns the ID number of the thing.

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

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.

Constants

Flags for spawnThing()

MSF_AMBUSH
Spawn thing as deaf.
MSF_Z_CEIL
Spawn thing in the ceiling.
MSF_Z_FLOOR
Spawn thing at the floor.
script/module/world.1577006351.txt.gz · Last modified: 2019-12-22 11:19 by skyjake