Difference between revisions of "CEngine"

From Sven Co-op
Jump to navigation Jump to search
m
m
 
Line 3: Line 3:
 
A single global instance exists with the following declaration:
 
A single global instance exists with the following declaration:
  
<nowiki>const CEngine g_Engine;</nowiki>
+
<code>const CEngine g_Engine;</code>
  
 
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 from g_Engine "trace_" member variables or using the GetGlobalTrace TraceResult object.
 
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 from g_Engine "trace_" member variables or using the GetGlobalTrace TraceResult object.
Line 14: Line 14:
 
! style="text-align:center;" | Description
 
! style="text-align:center;" | Description
 
|-
 
|-
| time
+
| <code>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.
 
| 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
+
| <code>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.
 
| 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
+
| <code>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.
 
| 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.
 
|-
 
|-
| mapname
+
| <code>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.
 
| 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
+
| <code>startspot
 
| Start location in the map. Used as a landmark when loading a saved game.
 
| Start location in the map. Used as a landmark when loading a saved game.
 
|-
 
|-
| deathmatch
+
| <code>deathmatch
 
| Acts as a boolean value indicating whether the deathmatch cvar is non-zero or not.
 
| Acts as a boolean value indicating whether the deathmatch cvar is non-zero or not.
 
|-
 
|-
| coop
+
| <code>coop
 
| Acts as a boolean value indicating whether the coop cvar is non-zero or not.
 
| Acts as a boolean value indicating whether the coop cvar is non-zero or not.
 
|-
 
|-
| teamplay
+
| <code>teamplay
 
| Acts as a boolean value indicating whether the teamplay cvar is non-zero or not.
 
| Acts as a boolean value indicating whether the teamplay cvar is non-zero or not.
 
|-
 
|-
| serverflags
+
| <code>serverflags
 
| Flags that the server can set that are saved/restored.
 
| Flags that the server can set that are saved/restored.
 
|-
 
|-
| found_secrets
+
| <code>found_secrets
 
| Obsolete variable used to track the number of secrets that have been found. Has no known effect on the game's behavior.
 
| Obsolete variable used to track the number of secrets that have been found. Has no known effect on the game's behavior.
 
|-
 
|-
| v_forward
+
| <code>v_forward
 
| Forward vector set by CEngineFuncs::MakeVectors.
 
| Forward vector set by CEngineFuncs::MakeVectors.
 
|-
 
|-
| v_up
+
| <code>v_up
 
| Up vector set by CEngineFuncs::MakeVectors.
 
| Up vector set by CEngineFuncs::MakeVectors.
 
|-
 
|-
| v_right
+
| <code>v_right
 
| Right vector set by CEngineFuncs::MakeVectors.
 
| Right vector set by CEngineFuncs::MakeVectors.
 
|-
 
|-
| trace_allsolid
+
| <code>trace_allsolid
 
| Global trace allsolid flag.
 
| Global trace allsolid flag.
 
|-
 
|-
| trace_startsolid
+
| <code>trace_startsolid
 
| Global trace start solid flag.
 
| Global trace start solid flag.
 
|-
 
|-
| trace_fraction
+
| <code>trace_fraction
 
| Global trace fraction.
 
| Global trace fraction.
 
|-
 
|-
| trace_endpos
+
| <code>trace_endpos
 
| Global trace end position.
 
| Global trace end position.
 
|-
 
|-
| trace_plane_normal
+
| <code>trace_plane_normal
 
| Global trace plane normal.
 
| Global trace plane normal.
 
|-
 
|-
| trace_plane_dist
+
| <code>trace_plane_dist
 
| Global trace plane distance.
 
| Global trace plane distance.
 
|-
 
|-
| trace_ent
+
| <code>trace_ent
 
| Global trace hit entity.
 
| Global trace hit entity.
 
|-
 
|-
| trace_inopen
+
| <code>trace_inopen
 
| Global trace in open flag.
 
| Global trace in open flag.
 
|-
 
|-
| trace_inwater
+
| <code>trace_inwater
 
| Global trace in water flag.
 
| Global trace in water flag.
 
|-
 
|-
| trace_hitgroup
+
| <code>trace_hitgroup
 
| Global trace hit group.
 
| Global trace hit group.
 
|-
 
|-
| trace_flags
+
| <code>trace_flags
 
| Global trace flags.
 
| Global trace flags.
 
|-
 
|-
| msg_entity
+
| <code>msg_entity
 
| Message entity. Whether this is still in use or not is unknown.
 
| Message entity. Whether this is still in use or not is unknown.
 
|-
 
|-
| cdAudioTrack
+
| <code>cdAudioTrack
 
| If set, plays the set CD audio track. (May not work)
 
| If set, plays the set CD audio track. (May not work)
 
|-
 
|-
| maxClients
+
| <code>maxClients
 
| Maximum number of connected clients. Corresponds to the maxplayers cvar value on server start.
 
| Maximum number of connected clients. Corresponds to the maxplayers cvar value on server start.
 
|-
 
|-
| maxEntities
+
| <code>maxEntities
 
| Maximum number of entities that can exist at the same time. Includes the world and clients.
 
| Maximum number of entities that can exist at the same time. Includes the world and clients.
 
|}
 
|}
  
 
[[Category:Scripting]]
 
[[Category:Scripting]]

Latest revision as of 19:48, 14 February 2025

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 from g_Engine "trace_" member variables or using the GetGlobalTrace TraceResult object.

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

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