Skip to content

CEngine

GeckoN edited this page Jan 31, 2017 · 9 revisions

The CEngine class contains game state that is shared between the engine and the game.

A single global instance exists with the following declaration:

const CEngine g_Engine;

The global trace variables can be retrieved as a TraceResult using g_Utility.GetGlobalTrace(). This trace is what the engine is using during physics operations. If you are writing Touch or Blocked functions and require this information, you can retrieve it using either g_Engine or GetGlobalTrace.

Note: you cannot modify the engine's instance of this data. All of the CEngine variables are copies of the actual data.

Note: the global instance for this class is currently marked const, but has configuration variables in it. Until this is fixed, you cannot use them. Bug report

Note: the force_retouch variable is currently missing from the API. Bug report

Variables

| Variable | Description | | --- | --- | --- | | time | The current map time. Starts at 1.0f on map spawn, increases in real time. If the game is paused, this is also paused. | | frametime | Time between 2 frames. This can be used to increase variables at a rate equal to the passage of time, e.g. flTimeSpent += g_Engine.frametime. | | force_retouch | If set to a value > 0, forces all non-moving entities to touch entities they are currently touching, resulting in Touch being called for all involved entities. This value is equal to the number of frames to perform forced retouching. It is decremented each frame by the engine until is becomes 0. Avoid incrementing it with arbitrary values. Do not set this to a value smaller than 0. Currently missing from the API. | | mapname | Name of the current map. This is the name of the file, without the path or extension. This may not match the case of the actual filename if the command used to change to this map had a different case in the name. | | startspot | Start location in the map. Used as a landmark when loading a saved game. | | deathmatch | Acts as a boolean value indicating whether the deathmatch cvar is non-zero or not. | | coop | Acts as a boolean value indicating whether the coop cvar is non-zero or not. | | teamplay | Acts as a boolean value indicating whether the teamplay cvar is non-zero or not. | | serverflags | Flags that the server can set that are saved/restored. | | found_secrets | Obsolete variable used to track the number of secrets that have been found. Has no known effect on the game's behavior. | | v_forward | Forward vector set by CEngineFuncs::MakeVectors. | | v_up | Up vector set by CEngineFuncs::MakeVectors. | | v_right | Right vector set by CEngineFuncs::MakeVectors. | | trace_allsolid | Global trace allsolid flag. | | trace_startsolid | Global trace start solid flag. | | trace_fraction | Global trace fraction. | | trace_endpos | Global trace end position. | | trace_plane_normal | Global trace plane normal. | | trace_plane_dist | Global trace plane distance. | | trace_ent | Global trace hit entity. | | trace_inopen | Global trace in open flag. | | trace_inwater | Global trace in water flag. | | trace_hitgroup | Global trace hit group. | | trace_flags | Global trace flags. | | msg_entity | Message entity. Whether this is still in use or not is unknown. | | cdAudioTrack | If set, plays the set CD audio track. (May not work) | | maxClients | Maximum number of connected clients. Corresponds to the maxplayers cvar value on server start. | | maxEntities | Maximum number of entities that can exist at the same time. Includes the world and clients. |

Clone this wiki locally