ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:zdoom

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
functions:zdoom [2016/08/10 13:06] – [RestoreActivator] korshunfunctions:zdoom [2016/09/13 17:05] – [ChangeActorFlag] korshun
Line 5: Line 5:
 ''int MAX_PLAYERS'' -- maximum amount of players in Zandronum multiplayer. ''int MAX_PLAYERS'' -- maximum amount of players in Zandronum multiplayer.
  
-===== Engine information ===== 
- 
-==== IsZandronum ==== 
-''bool IsZandronum()'' 
- 
-Returns true if the mod is being played in Zandronum. 
- 
-**Example** 
- 
-    if (IsZandronum()) 
-        // Use workarounds 
-    else 
-        // Use ZDoom 2.7.1 features 
-         
 ===== CVar functions ===== ===== CVar functions =====
  
Line 34: Line 20:
 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. 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.
  
 +===== Internationalization =====
 +
 +==== lang ====
 +''str lang(str id)''
 +
 +Returns a translated string from [[zdoom>LANGUAGE]]. Shorthand for ''StrParam(l:id)''.
 +
 +===== Functions for mappers =====
 +
 +==== SyncSpeed ====
 +''function int SyncSpeed(int newdistance, int syncdistance, int syncspd)''
 +
 +[[zdoom>Syncspeed]]
 +
 +FIXME Needs proper documentation FIXME
  
 ===== Video settings information ===== ===== Video settings information =====
Line 43: Line 44:
  
 Returns the aspect ratio of the current resolution as a fixed-point number. Returns the aspect ratio of the current resolution as a fixed-point number.
- 
-==== IsOpenGL ==== 
-''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. 
- 
-<note important>This function may return an incorrect value in the following cases: 
-  * ''vid_renderer'' or ''gl_nogl'' changed mid-game. 
-  * A config from GZDoom or Zandronum used in ZDoom and having ''vid_renderer'' != 0. 
-</note> 
  
 ==== ScreenHeight ==== ==== ScreenHeight ====
Line 79: Line 68:
 ''void ClearHudMessage(int id)'' ''void ClearHudMessage(int id)''
  
-Clears the HudMessage with the given id. A shorthand for ''HudMessage(s:""; HUDMSG_PLAIN, id, 0, 0, 0, 0, 0)''.+Clears the HudMessage with the given id for the activator. A shorthand for ''HudMessage(s:""; HUDMSG_PLAIN, id, 0, 0, 0, 0, 0)''
 + 
 +==== ClearHudMessageBold ==== 
 +''void ClearHudMessageBold(int id)'' 
 + 
 +Clears the HudMessage with the given id for all players (serverside) or the client (clientside). A shorthand for ''HudMessageBold(s:""; HUDMSG_PLAIN, id, 0, 0, 0, 0, 0)''.
  
 ===== Inventory functions ===== ===== Inventory functions =====
Line 134: Line 128:
 Same as ToggleInventory, but affects the given actor instead of the activator. Same as ToggleInventory, but affects the given actor instead of the activator.
  
-===== Player information functions =====+===== Actor property shorthands =====
  
-==== PlayerName ==== +Not only are these shorter than ''[Get/Set]ActorProperty(tid, APROP_SOMETHING)'', but the setters also don't set the value if it's the same, saving bandwidth when used serverside.
-''str PlayerName(int player)''+
  
-Returns the name of the specified player. A shorthand for ''StrParam(n:player+1)''.+There are shorthands for the following properties: 
 +  * Health 
 +  * SpawnHealth 
 +  * Speed
  
-==== PlayerIsConnected ==== +==== GetActor<Property> ==== 
-''bool PlayerIsConnected(int player)''+''int GetActor<Property>(int tid)''
  
-Returns true if the specified player is connected to the server.+Returns the <Property> of the actor.
  
-==== BotCount ==== +==== SetActor<Property> ==== 
-''int BotCount()''+''int SetActor<Property>(int tid, int value)''
  
-Returns the amount of ZDoom bots present on the server.+Sets the <Property> of the actor if the new value is not the same as the current valueThis saves bandwidth when used serverside, allowing you to write the code like this:
  
-==== ClientCount ==== +<code> 
-''int ClientCount()''+while (true) 
 +
 +    SetActorSpeed(tid, SomeValue()); 
 +    Delay(1); 
 +
 +</code>
  
-Returns the amount of clients connected to the server (including bots).+without wasting any bandwidth.
  
-==== SpectatorCount ==== +===== Actor functions =====
-''int SpectatorCount()''+
  
-Returns the amount of spectators connected to the server.+==== ChangeFlag ==== 
 +''void ChangeFlag(str flagname, bool value)''
  
-==== PickRandomPlayer ==== +Adds or removes a flag from the activator. This is a Zandronum replacement for [[zdoom>SetActorFlag]].
-''int PickRandomPlayer()''+
  
-Returns the player number of a random player out of those who are in game.+**Example** 
 +<code> 
 +ChangeFlag("SHOOTABLE", false); 
 +</code>
  
-==== PickRandomSpectator ==== +<note>To use this function, you need to add ''decorate/changeflag.txt'' to your decorate.</note> 
-''int PickRandomSpectator()''+==== ChangeActorFlag ==== 
 +''void ChangeActorFlag(int tid, str flagname, bool value)''
  
-Returns the player number of random spectator.+Adds or removes a flag from the specified actor. This is Zandronum replacement for [[zdoom>SetActorFlag]].
  
-==== PickRandomBot ==== +**Example**
-''int PickRandomBot()''+
  
-Returns the player number of a random ZDoom bot.+<code> 
 +ChangeActorFlag(tid, "SHOOTABLE", false); 
 +</code>
  
-===== Actor utility functions =====+<note>To use this function, you need to add ''decorate/changeflag.txt'' to your decorate.</note>
  
 ==== ActorPlayerNumber ==== ==== ActorPlayerNumber ====
Line 207: Line 212:
  
 Returns true if the given actor is alive. Returns true if the given actor is alive.
 +
 +
 +==== HasRoom ====
 +''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.
 +
 +==== LookAtPoint ====
 +''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.
 +
 +==== LookAt ====
 +''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.
  
  
Line 232: Line 253:
  
 Returns the current speed of actor, ignoring the Z dimension. Returns the current speed of actor, ignoring the Z dimension.
- 
-===== Actor utility functions ===== 
- 
-==== HasRoom ==== 
-''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. 
- 
-==== LookAtPoint ==== 
-''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. 
- 
-==== LookAt ==== 
-''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. 
  
 ===== Activator swapping ===== ===== Activator swapping =====
Line 294: Line 298:
  
 <note tip>The example function is already in ACSUtils: ''[[functions:zdoom#actorplayernumber|ActorPlayerNumber]]''.</note> <note tip>The example function is already in ACSUtils: ''[[functions:zdoom#actorplayernumber|ActorPlayerNumber]]''.</note>
-===== Internationalization ===== 
  
-==== lang ==== +===== Player information functions =====
-''str lang(str id)''+
  
-Returns a translated string from [[zdoom>LANGUAGE]]. Shorthand for ''StrParam(l:id)''.+==== PlayerName ==== 
 +''str PlayerName(int player)''
  
 +Returns the name of the specified player. A shorthand for ''StrParam(n:player+1)''.
  
-===== Multiplayer functions =====+==== PlayerIsConnected ==== 
 +''bool PlayerIsConnected(int player)''
  
-==== IsServer ==== +Returns true if the specified player is connected to the server.
-''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.+==== BotCount ==== 
 +''int BotCount()''
  
-==== IsClient ==== +Returns the amount of ZDoom bots present on the server.
-''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.+==== ClientCount ==== 
 +''int ClientCount()''
  
-<note tip>A player is considered **both a server and a client** in a non-network game (including singleplayer games and multiplayer emulation).</note>+Returns the amount of clients connected to the server (including bots).
  
-**Example**+==== SpectatorCount ==== 
 +''int SpectatorCount()''
  
-<code> +Returns the amount of spectators connected to the server.
-// This code will work both in true multiplayer and in singleplayer. +
-if (IsServer()) +
-    DoServersideStuff(); +
-     +
-if (IsClient()) +
-    DoClientsideStuff(); +
-</code>+
  
-===== Actor property shorthands =====+==== PickRandomPlayer ==== 
 +''int PickRandomPlayer()''
  
-Not only are these shorter than ''[Get/Set]ActorProperty(tid, APROP_SOMETHING)'', but the setters also don't set the value if it's the same, saving bandwidth when used serverside.+Returns the player number of a random player out of those who are in game.
  
-There are shorthands for the following properties: +==== PickRandomSpectator ==== 
-  * Health +''int PickRandomSpectator()''
-  * SpawnHealth +
-  * Speed+
  
-==== GetActor<Property> ==== +Returns the player number of a random spectator.
-''int GetActor<Property>(int tid)''+
  
-Returns the <Property> of the actor.+==== PickRandomBot ==== 
 +''int PickRandomBot()''
  
-==== SetActor<Property> ==== +Returns the player number of a random ZDoom bot.
-''int SetActor<Property>(int tid, int value)''+
  
-Sets the <Property> of the actor if the new value is not the same as the current value. This saves bandwidth when used serverside, allowing you to write the code like this: 
  
-<code> 
-while (true) 
-{ 
-    SetActorSpeed(tid, SomeValue()); 
-    Delay(1); 
-} 
-</code> 
- 
-without wasting any bandwidth.