This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
functions:zdoom [2016/08/29 00:46] – korshun | functions:zdoom [2017/06/12 18:35] (current) – removed korshun | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ZDoom utilities ====== | ||
- | |||
- | ===== Constants ===== | ||
- | |||
- | '' | ||
- | |||
- | ===== CVar functions ===== | ||
- | |||
- | ==== GetCVarFixed ==== | ||
- | '' | ||
- | |||
- | 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. | ||
- | |||
- | <note important> | ||
- | |||
- | ==== GetCVarPercentage ==== | ||
- | |||
- | '' | ||
- | |||
- | 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 ==== | ||
- | '' | ||
- | |||
- | Returns a translated string from [[zdoom> | ||
- | |||
- | ===== Functions for mappers ===== | ||
- | |||
- | ==== SyncSpeed ==== | ||
- | '' | ||
- | |||
- | [[zdoom> | ||
- | |||
- | FIXME Needs proper documentation FIXME | ||
- | |||
- | ===== Video settings information ===== | ||
- | |||
- | These functions can be used to find out the player' | ||
- | |||
- | ==== AspectRatio ==== | ||
- | '' | ||
- | |||
- | Returns the aspect ratio of the current resolution as a fixed-point number. | ||
- | |||
- | ==== ScreenHeight ==== | ||
- | '' | ||
- | |||
- | Returns the current vertical resolution in pixels. | ||
- | |||
- | ==== ScreenWidth ==== | ||
- | '' | ||
- | |||
- | Returns the current horizontal resolution in pixels. | ||
- | |||
- | ==== StatusBarShown ==== | ||
- | '' | ||
- | |||
- | Returns true if the status bar is currently shown. | ||
- | |||
- | ===== HudMessage functions ===== | ||
- | |||
- | See also: [[hudlib]]. | ||
- | |||
- | |||
- | ==== ClearHudMessage ==== | ||
- | '' | ||
- | |||
- | Clears the HudMessage with the given id for the activator. A shorthand for '' | ||
- | |||
- | ==== ClearHudMessageBold ==== | ||
- | '' | ||
- | |||
- | Clears the HudMessage with the given id for all players (serverside) or the client (clientside). A shorthand for '' | ||
- | |||
- | ===== Inventory functions ===== | ||
- | |||
- | ==== SetInventory ==== | ||
- | '' | ||
- | |||
- | Sets the amount of items of the given type in the activator' | ||
- | |||
- | **Example** | ||
- | |||
- | SetInventory(" | ||
- | SetInventory(" | ||
- | | ||
- | ==== SetActorInventory ==== | ||
- | '' | ||
- | |||
- | Same as SetInventory, | ||
- | |||
- | ==== GiveMaxInventory ==== | ||
- | '' | ||
- | |||
- | Gives the activator the maximum amount of items of the given type it can carry. | ||
- | |||
- | ==== GiveMaxActorInventory ==== | ||
- | '' | ||
- | |||
- | Same as GiveMaxInventory, | ||
- | |||
- | ==== TakeAllInventory ==== | ||
- | '' | ||
- | |||
- | Takes away all items of the given type from the activator' | ||
- | | ||
- | ==== TakeAllActorInventory ==== | ||
- | '' | ||
- | |||
- | Same as TakeAllInventory, | ||
- | |||
- | ==== ToggleInventory ==== | ||
- | '' | ||
- | |||
- | If the activator has at least one **item**, takes them all away. If he has none, gives one **item**. | ||
- | |||
- | **Example** | ||
- | |||
- | < | ||
- | ToggleInventory(" | ||
- | </ | ||
- | |||
- | ==== ToggleActorInventory ==== | ||
- | '' | ||
- | |||
- | Same as ToggleInventory, | ||
- | |||
- | ===== Actor property shorthands ===== | ||
- | |||
- | Not only are these shorter than '' | ||
- | |||
- | There are shorthands for the following properties: | ||
- | * Health | ||
- | * SpawnHealth | ||
- | * Speed | ||
- | |||
- | ==== GetActor< | ||
- | '' | ||
- | |||
- | Returns the < | ||
- | |||
- | ==== SetActor< | ||
- | '' | ||
- | |||
- | Sets the < | ||
- | |||
- | < | ||
- | while (true) | ||
- | { | ||
- | SetActorSpeed(tid, | ||
- | Delay(1); | ||
- | } | ||
- | </ | ||
- | |||
- | without wasting any bandwidth. | ||
- | |||
- | ===== Actor functions ===== | ||
- | |||
- | ==== ChangeFlag ==== | ||
- | '' | ||
- | |||
- | Adds or removes a flag from the activator. | ||
- | |||
- | ==== ChangeActorFlag ==== | ||
- | |||
- | Adds or removes a flag from the specified actor. | ||
- | |||
- | < | ||
- | |||
- | ==== ActorPlayerNumber ==== | ||
- | '' | ||
- | |||
- | Returns the player number of the given actor, or -1 if the actor is not a player. | ||
- | |||
- | ==== ActorIsPlayer ==== | ||
- | '' | ||
- | |||
- | Returns true if the given actor is a player. | ||
- | |||
- | ==== ActivatorName ==== | ||
- | '' | ||
- | |||
- | Returns the activator' | ||
- | |||
- | ==== GetActorName ==== | ||
- | '' | ||
- | |||
- | Returns the actor' | ||
- | |||
- | ==== IsAlive ==== | ||
- | '' | ||
- | |||
- | Returns true if the activator is alive. | ||
- | |||
- | ==== ActorIsAlive ==== | ||
- | '' | ||
- | |||
- | Returns true if the given actor is alive. | ||
- | |||
- | |||
- | ==== HasRoom ==== | ||
- | '' | ||
- | |||
- | Returns true if an actor of the given class has enough room to occupy the specified point. | ||
- | |||
- | ==== LookAtPoint ==== | ||
- | '' | ||
- | |||
- | Rotates the actor so that it looks at the specified point, taking the actor' | ||
- | |||
- | ==== LookAt ==== | ||
- | '' | ||
- | |||
- | Rotates the " | ||
- | |||
- | |||
- | ===== Actor math functions ===== | ||
- | |||
- | These functions can save you some typing when doing math on actors. | ||
- | |||
- | ==== ActorDistance ==== | ||
- | '' | ||
- | |||
- | Returns the distance between two actors. | ||
- | |||
- | ==== ActorDistance2D ==== | ||
- | '' | ||
- | |||
- | Returns the distance between two actors, ignoring the Z dimension. | ||
- | |||
- | ==== GetActorCurrentSpeed ==== | ||
- | '' | ||
- | |||
- | Returns the current speed of actor. | ||
- | |||
- | ==== GetActorCurrentSpeed2D ==== | ||
- | '' | ||
- | |||
- | Returns the current speed of actor, ignoring the Z dimension. | ||
- | |||
- | ===== Activator swapping ===== | ||
- | |||
- | Some ZDoom functions only work on the activator. To convert them to functions that can take any tid, use this pair of functions: | ||
- | |||
- | ==== SwapActivator ==== | ||
- | '' | ||
- | |||
- | Temporarily makes the given actor the activator of the script and returns two values, allowing you to restore the previous activator. | ||
- | |||
- | [[..mulretval|This function returns multiple values.]] | ||
- | |||
- | ==== RestoreActivator ==== | ||
- | '' | ||
- | |||
- | Restores the activator from the two values returned by '' | ||
- | |||
- | <note warning>'' | ||
- | |||
- | <note important> | ||
- | |||
- | **Example** | ||
- | |||
- | [[zdoom> | ||
- | |||
- | < | ||
- | 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, | ||
- | |||
- | // Return the saved result of the activator-only function. | ||
- | return result; | ||
- | } | ||
- | </ | ||
- | |||
- | <note tip>The example function is already in ACSUtils: '' | ||
- | |||
- | ===== Player information functions ===== | ||
- | |||
- | ==== PlayerName ==== | ||
- | '' | ||
- | |||
- | Returns the name of the specified player. A shorthand for '' | ||
- | |||
- | ==== PlayerIsConnected ==== | ||
- | '' | ||
- | |||
- | Returns true if the specified player is connected to the server. | ||
- | |||
- | ==== BotCount ==== | ||
- | '' | ||
- | |||
- | Returns the amount of ZDoom bots present on the server. | ||
- | |||
- | ==== ClientCount ==== | ||
- | '' | ||
- | |||
- | Returns the amount of clients connected to the server (including bots). | ||
- | |||
- | ==== SpectatorCount ==== | ||
- | '' | ||
- | |||
- | Returns the amount of spectators connected to the server. | ||
- | |||
- | ==== PickRandomPlayer ==== | ||
- | '' | ||
- | |||
- | Returns the player number of a random player out of those who are in game. | ||
- | |||
- | ==== PickRandomSpectator ==== | ||
- | '' | ||
- | |||
- | Returns the player number of a random spectator. | ||
- | |||
- | ==== PickRandomBot ==== | ||
- | '' | ||
- | |||
- | Returns the player number of a random ZDoom bot. | ||
- | |||
- | |||