This is an old revision of the document!
int MAX_PLAYERS
– maximum amount of players in Zandronum multiplayer.
bool IsZandronum()
Returns true if the mod is being played in Zandronum.
Example
if (IsZandronum()) // Use workarounds else // Use ZDoom 2.7.1 features
fixed GetCVarFixed(str name)
Returns the value of the fixed-point CVar with the given name, or 0 if the cvar does not exist or is not a fixed-point number.
fixed GetCVarPercentage(str name)
Returns the value of the given integer CVar divided by 100. If the integer value of the CVar could not be retrieved, returns 0. This is useful for CVars that are percentages.
These functions can be used to find out the player's video settings.
fixed AspectRatio()
Returns the aspect ratio of the current resolution as a fixed-point number.
bool IsOpenGL()
Returns true if the OpenGL renderer is being used at the moment, false if software.
When used serverside, this function always returns true and emits a ProgramError.
vid_renderer
or gl_nogl
changed mid-game.vid_renderer
!= 0.
int ScreenHeight()
Returns the current vertical resolution in pixels.
int ScreenWidth()
Returns the current horizontal resolution in pixels.
bool StatusBarShown()
Returns true if the status bar is currently shown.
See also: hudlib.
void ClearHudMessage(int id)
Clears the HudMessage with the given id. A shorthand for HudMessage(s:“”; HUDMSG_PLAIN, id, 0, 0, 0, 0, 0)
.
void SetInventory(str item, int amount)
Sets the amount of items of the given type in the activator's inventory to amount.
Example
SetInventory("Shells", 8); // The player will now have exactly 8 shells. SetInventory("IsReloading", 0); // Set the "IsReloading" flag to 0.
void SetActorInventory(int tid, str item, int amount)
Same as SetInventory, but affects the given actor instead of the activator.
void GiveMaxInventory(str item)
Gives the activator the maximum amount of items of the given type it can carry.
void GiveMaxActorInventory(int tid, str item)
Same as GiveMaxInventory, but affects the given actor instead of the activator.
void TakeAllInventory(str item);
Takes away all items of the given type from the activator's inventory.
void TakeAllActorInventory(int tid, str item)
Same as TakeAllInventory, but affects the given actor instead of the activator.
void ToggleInventory(str item)
If the activator has at least one item, takes them all away. If he has none, gives one item.
Example
ToggleInventory("IsReloading");
void ToggleActorInventory(int tid, str item)
Same as ToggleInventory, but affects the given actor instead of the activator.
str PlayerName(int player)
Returns the name of the specified player. A shorthand for StrParam(n:player+1)
.
bool PlayerIsConnected(int player)
Returns true if the specified player is connected to the server.
int BotCount()
Returns the amount of ZDoom bots present on the server.
int ClientCount()
Returns the amount of clients connected to the server (including bots).
int SpectatorCount()
Returns the amount of spectators connected to the server.
int PickRandomPlayer()
Returns the player number of a random player out of those who are in game.
int PickRandomSpectator()
Returns the player number of a random spectator.
int PickRandomBot()
Returns the player number of a random ZDoom bot.
int ActorPlayerNumber(int tid)
Returns the player number of the given actor, or -1 if the actor is not a player.
bool ActorIsPlayer(int tid)
Returns true if the given actor is a player.
str ActivatorName()
Returns the activator's actor class name, or player name if the activator is a player. Shorthand for StrParam(n:0)
.
str GetActorName(int tid)
Returns the actor's class name, or player name if the actor is a player.
bool IsAlive()
Returns true if the activator is alive.
bool ActorIsAlive(int tid)
Returns true if the given actor is alive.
These functions can save you some typing when doing math on actors.
fixed ActorDistance(int tid1, int tid2)
Returns the distance between two actors.
fixed ActorDistance2D(int tid1, int tid2)
Returns the distance between two actors, ignoring the Z dimension.
fixed GetActorCurrentSpeed(int tid)
Returns the current speed of actor.
fixed GetActorCurrentSpeed2D(int tid)
Returns the current speed of actor, ignoring the Z dimension.
bool HasRoom(str classname, fixed x, fixed y, fixed z)
Returns true if an actor of the given class has enough room to occupy the specified point.
void LookAtPoint(int tid, fixed x, fixed y, fixed z)
Rotates the actor so that it looks at the specified point, taking the actor's view height into account.
void LookAt(int camera, int target)
Rotates the “camera” actor so that it looks at the specified “target” actor, taking into account the view height of both actors.
Some ZDoom functions only work on the activator. To convert them to functions that can take any tid, use this pair of functions:
int, int SwapActivator(int tid)
Temporarily makes the given actor the activator of the script and returns two values, allowing you to restore the previous activator.
void RestoreActivator(int a, int b)
Restores the activator from the two values returned by SwapActivator
.
SwapActivator
changes the current activator's tid, do not allow any delay between SwapActivator
and RestoreActivator
if you don't want tid problems!
Example
PlayerNumber can only return the activator's player number. Here's how it's converted to work on an arbitrary tid:
function int ActorPlayerNumber(int tid) { // Swap the activator and save two numbers to restore it later. SwapActivator(tid); int a = r1; int b = r2; // Retrieve the result of the activator-only function. int result = PlayerNumber(); // Restore the previous activator using the two saved numbers. RestoreActivator(a, b); // Return the saved result of the activator-only function. return result; }
str lang(str id)
Returns a translated string from LANGUAGE. Shorthand for StrParam(l:id)
.
bool IsServer()
Returns true if the script is running on a server or in a non-network game. Use this function to check whether server logic needs to be run.
bool IsClient()
Returns true if the script is running on a client or in a non-network game. Use this function to check whether client logic needs to be run.
Example
// This code will work both in true multiplayer and in singleplayer. if (IsServer()) DoServersideStuff(); if (IsClient()) DoClientsideStuff();