CBaseEntity: Difference between revisions
(→Fields) |
(→Fields) |
||
Line 198: | Line 198: | ||
== Fields == | == Fields == | ||
{{DEFINE_FIELD|m_iName|FIELD_STRING|Name other entities use to refer to this entity | {{DEFINE_FIELD|m_iName|FIELD_STRING|Name other entities use to refer to this entity (vscript GetName() returns this) }} | ||
{{DEFINE_FIELD|m_vecOrigin|FIELD_VECTOR|Relative to parent{{confirm}} }} <!-- (Save)(12 Bytes) --> | {{DEFINE_FIELD|m_vecOrigin|FIELD_VECTOR|Relative to parent{{confirm}} }} <!-- (Save)(12 Bytes) --> |
Revision as of 05:38, 27 September 2024

![]() |
---|
CBaseEntity |
![]() |
The base class for all entities.

Descriptions of in-game accessible Keyvalues / Inputs / Outputs
Since
|
|
- Move Type (MoveType) <choices> !FGD
- Sets a movetype for this entity, which changes its movement behavior.
|
- Team number (teamnumber) <integer>
Only in
Left 4 Dead 2
- Disable for Xbox 360 (disableX360) <boolean> !FGD
- If this entity should automatically be given the 'Disable' input on the Xbox 360 version of Source.
- Glow Backface Multiple (glowbackfacemult) <float> !FGD
- If this object has a glow effect, multiply the effect by this much on the sides of the object that are facing away from the viewer.
Only in
Left 4 Dead 2,
Alien Swarm,
Portal 2
- Addon (addon)
- Lag Compensation (LagCompensate) <boolean> !FGD
- Set to Yes to lag compensate this entity. Should be used very sparingly!
Since
Left 4 Dead 2, also in
Team Fortress 2
- Entity Scripts (vscripts) <scriptlist>
- Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions. Scripts executed on the worldspawn entity will be placed in root scope.
- Think function (thinkfunction) <string>
- Name of the function within this entity's script that'll be called automatically every 100 milliseconds, or a user-defined interval if the function returns a number. Avoid expensive operations in this function, as it may cause performance problems.
Since
Left 4 Dead
- Fade Scale (fadescale) <float>
- If specified in the worldspawn, or if the engine is running below DirectX 8, entities will fade out even if the fade distances above aren't specified. This value gives more control over when this happens: numbers smaller than 1 cause the entity to fade out at further distances, and greater than 1 cause it to fade out at closer distances. Using 0 turns off the forced fade altogether. See also $noforcedfade.
- Minimum / Maximum Effect Details Level (mincpulevel / maxcpulevel) <choices> !FGD
- Don't render for players with Effect Details levels that exceed the minimum or maximum.
|
- Minimum / Maximum Shader Details Level (mingpulevel / maxgpulevel) <choices> !FGD
- Don't render for players with Shader Details levels that exceed the minimum or maximum.
|
- FX Amount/Transparency (0–255) (renderamt) <integer>
- Transparency amount, requires a Render Mode other than Normal. 0 is invisible, 255 is fully visible.
- Disable Shadows (disableshadows) <boolean>
- Prevent the entity from creating cheap render-to-texture shadows. Does not affect shadow mapping.
- Disable Receiving Shadows (disablereceiveshadows) <boolean>
- Prevent the entity from receiving shadows on itself.
- No damage forces (nodamageforces) <boolean>
- Pitch Yaw Roll (Y Z X) (angles) <angle>
- This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note:This works on brush entities, although Hammer doesn't show the new angles.
- Angle (angle) !FGD
- Origin (X Y Z) (origin) <coordinates>
- The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Bug:Hammer does not move point entities accordingly in the editor. [todo tested in ?]
- Name (targetname) <string>
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.
|
// Format of changing KeyValues: "AddOutput [key] [value]"
//// Raw text:
"OnUser1" "!self,AddOutput,targetname new_name"
// Format of adding an Output: "AddOutput {targetname}:{inputname}:{parameter}:{delay}:{max times to fire, -1 means infinite}"
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:SetParent:!activator:0.0:-1"
// Arguments can be left blank, but the empty blank should still be contained.
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:ClearParent::0.0:-1"
|
- ClearContext
- Removes all contexts from this entity's list.
- ClearParent
- Removes this entity from the movement hierarchy, leaving it free to move independently.
- FireUser1 to FireUser4
- Fires the respective
OnUser
outputs; see User Inputs and Outputs.
- Kill
- Removes this entity and any entities parented to it from the world.
- KillHierarchy
- Functions the same as
Kill
, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKill
input.
- RemoveContext <string >
- Remove a context from this entity's list. The name should match the key of an existing context.
- SetParent <string >
- Move with this entity. See Entity Hierarchy (parenting).
- SetParentAttachment <string >
- Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
- SetParentAttachmentMaintainOffset <string >
- As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
- DispatchEffect <string > (removed since
) !FGD
- Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since
.
- RunScriptFile <script > (in all games since
) (also in
)
- Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
- RunScriptCode <string > (in all games since
) (also in
)
- Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
- CallScriptFunction <string > (in all games since
) (also in
) !FGD
- Calls a VScript function defined in the scope of the receiving entity.
- TerminateScriptScope (only in
) !FGD
- Destroys the script scope of the receiving entity.
- SetLocalOrigin <coordinates> (in all games since
) !FGD
- Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
- Alpha <integer >
- Sets the entity's transparency to a number from 0 (invisible) to 255 (fully visible). Requires the entity to have its Render Mode (rendermode) set to a number other than 0.
- AlternativeSorting <boolean >
- Swaps the rendering order of the entity. Used to attempt to fix sorting problems when rendering, for example an object rendering in front of translucent materials.
- Color <color255 >
- Sets an RGB color for the entity.
- SetDamageFilter <targetname >
- Sets a filter for this entity for when it receives damage.
- EnableDamageForces
- Allows the entity to be pushed by damage done to it (usually force amount correlates with the damage done).
- DisableDamageForces
- Prevents the entity from being pushed by damage done to it.
- DisableShadow
- Turn dynamic shadows off for this entity. Identical to applying EF_NOSHADOW.
- EnableShadow
- Turn dynamic shadows on for this entity.
Only in
Portal 2
- DisableDrawInFastReflection
- Turns off rendering of this entity in reflections when using
$reflectonlymarkedentities
in water material.
- EnableDrawInFastReflection
- Turn on rendering of this entity in reflections when using
$reflectonlymarkedentities
in water material.
- SetLocalOrigin <string >
- Set this entity's origin in the map.
- SetLocalAngles <string >
- Set this entity's angles in the map.
- EnableDraw
- Removes EF_NODRAW from the entity.
- DisableDraw
- Applies EF_NODRAW to the entity. Note that this is different than Render Mode 10.
- RemovePaint
|}
Outputs
- OnUser1 to OnUser4
- Fired as response to FireUser1 / FireUser4.
- OnKilled
- Fired when entity is killed.
Fields
m_iName <FIELD_STRING>
- Name other entities use to refer to this entity (vscript GetName() returns this)
m_vecOrigin <FIELD_VECTOR>
- Relative to parent[confirm]
m_vecAbsOrigin <FIELD_POSITION_VECTOR>
m_vecAbsVelocity <FIELD_VECTOR>
m_angRotation <FIELD_VECTOR>
m_angAbsRotation <FIELD_VECTOR>
m_fFlags <FIELD_INTEGER>
m_iEFlags <FIELD_INTEGER>
m_debugOverlays <FIELD_INTEGER>
m_flPrevAnimTime <FIELD_TIME>
m_flAnimTime <FIELD_TIME>
m_lifeState <FIELD_CHARACTER>
- LIFE_ALIVE = 0
- LIFE_DYING = 1 // playing death animation or still falling off of a ledge waiting to hit ground
- LIFE_DEAD = 2 // dead. lying still.
- LIFE_RESPAWNABLE = 3
- LIFE_DISCARDBODY = 4
m_takedamage <FIELD_CHARACTER>
- DAMAGE_NO = 0
- DAMAGE_EVENTS_ONLY = 1 // Call damage functions, but don't modify health
- DAMAGE_YES = 2
- DAMAGE_AIM = 3
m_MoveCollide <FIELD_CHARACTER>
m_flElasticity <FIELD_FLOAT>
touchStamp <FIELD_INTEGER>
m_flDesiredShadowCastDistance <FIELD_FLOAT>
m_flGroundChangeTime <FIELD_TIME>
m_nWaterType <FIELD_CHARACTER>
m_pBlocker <FIELD_EHANDLE>
m_flVPhysicsUpdateLocalTime <FIELD_FLOAT>
m_flMoveDoneTime <FIELD_FLOAT>
m_bAlternateSorting <FIELD_BOOLEAN>
m_flSimulationTime <FIELD_TIME>
m_nLastThinkTick <FIELD_TICK>
m_nSimulationTick <FIELD_TICK>
m_bSimulatedEveryTick <FIELD_BOOLEAN>
m_bAnimatedEveryTick <FIELD_BOOLEAN>
m_nTransmitStateOwnedCounter <FIELD_CHARACTER>
m_pParent <FIELD_EHANDLE>
m_iParentAttachment <FIELD_CHARACTER>
m_hMoveParent <FIELD_EHANDLE>
m_hMoveChild <FIELD_EHANDLE>
m_hMovePeer <FIELD_EHANDLE>
m_hDamageFilter <FIELD_EHANDLE>
m_hOwnerEntity <FIELD_EHANDLE>
m_hEffectEntity <FIELD_EHANDLE>
m_hGroundEntity <FIELD_EHANDLE>
<span id="m_bForcePurgeFixedupStrings (in )">m_bForcePurgeFixedupStrings (in
) <FIELD_BOOLEAN>
<span id="m_flCreateTime (in )">m_flCreateTime (in
) <FIELD_TIME>
<span id="m_bClientSideRagdoll (in all games since )">m_bClientSideRagdoll (in all games since
) <FIELD_BOOLEAN>
<span id="m_iszScriptId (in all games since )(also in
)">m_iszScriptId (in all games since
)(also in
) <FIELD_STRING>
Only
Left 4 Dead 2
m_hScriptUseTarget <FIELD_EHANDLE>
m_PreStasisMoveType <FIELD_INTEGER>
m_bIsInStasis <FIELD_BOOLEAN>
Only
Portal 2
m_iSignifierName <FIELD? 4bytes>
m_iObjectCapsCache <FIELD? 4bytes>
Array fields
m_rgflCoordinateFrame[12] <FIELD_FLOAT>
<span id="(only in ) m_nModelIndexOverrides>(only in
) m_nModelIndexOverrides[4] <FIELD_INTEGER>
Keyfield since
Alien Swarm and also in
Team Fortress 2
m_iTeamNum <FIELD_INTEGER> (teamnumber)
m_CollisionGroup <FIELD_INTEGER> (CollisionGroup)
- Sets a collision group for this entity, which changes its collision behavior.
|
m_MoveType <FIELD_CHARACTER> (MoveType)
- Sets a movetype for this entity, which changes its movement behavior.
|
Keyfields
m_iClassname <FIELD_STRING> (classname)
m_iGlobalname <FIELD_STRING> (globalname)
m_iParent <FIELD_STRING> (parentname)
m_iHammerID <FIELD_INTEGER> (hammerid)
- The entity's unique Hammer ID that's auto-generated on map compiles. Mainly used by plugins or debugging commands (like the ent_keyvalue command). Entities spawned in run-time don't have a Hammer ID.
m_flSpeed <FIELD_FLOAT> (speed)
m_nRenderFX <FIELD_CHARACTER> (renderfx)
m_nRenderMode <FIELD_CHARACTER> (rendermode)
m_nNextThinkTick <FIELD_TICK> (nextthink)
- Amount of time before the entity thinks again.
m_fEffects <FIELD_INTEGER> (effects)
m_clrRender <FIELD_COLOR32> (rendercolor)
m_nModelIndex <FIELD_SHORT> (modelindex)
- Given the number index from dumping the
cl_precacheinfo modelprecache
table, sets entity model to the index.Warning:If an entity has animations that will be played, then the set model also must have its own sequences, else the game crashes.
m_iszResponseContext <FIELD_STRING> (ResponseContext)
- Pre-defined response system contexts; Format is
[key]:[value],[key]:[value],...
and so on.Tip:Can also be filtered for or against!
m_iMaxHealth <FIELD_INTEGER> (max_health)
m_iHealth <FIELD_INTEGER> (health)
m_target <FIELD_STRING> (target)
m_iszDamageFilterName <FIELD_STRING> (damagefilter)
m_flShadowCastDistance <FIELD_FLOAT> (shadowcastdist)
m_ModelName <FIELD_MODELNAME> (model)
- In-game representation of the entity to display
m_vecBaseVelocity <FIELD_VECTOR> (basevelocity)
m_vecAngVelocity <FIELD_VECTOR> (avelocity)
m_nWaterLevel <FIELD_CHARACTER> (waterlevel)
m_flGravity <FIELD_FLOAT> (gravity)
m_flFriction <FIELD_FLOAT> (friction)
m_flLocalTime <FIELD_FLOAT> (ltime)
- The local time of the entity, independent of the global clock. Used mainly for physics calculations.
m_vecVelocity <FIELD_VECTOR> (velocity)
m_iTextureFrameIndex <FIELD_CHARACTER> (texframeindex)
- The initial frame number for all animated textures on this entity.
m_spawnflags <FIELD_INTEGER> (spawnflags)
- Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
m_vecViewOffset <FIELD_VECTOR> (view_ofs)
Only in
Left 4 Dead 2
m_bDisableX360 <FIELD_BOOLEAN> (disableX360)
m_bGlowBackfaceMult <FIELD? 4bytes> (glowbackfacemult)
- If this object has a glow effect, multiply the effect by this much on the sides of the object that are facing away from the viewer.
Left 4 Dead 2,
Alien Swarm,
Portal 2
m_AIAddOn <FIELD? 4bytes> (addon)
m_bLagCompensate <FIELD_BOOLEAN> (LagCompensate)
Since
Left 4 Dead 2 and also in
Team Fortress 2
m_iszVScripts <FIELD_STRING> (vscripts)
m_iszScriptThinkFunction <FIELD_STRING> (thinkfunction)
Since
Left 4 Dead
m_nMinCPULevel <FIELD_CHARACTER> (mincpulevel)
m_nMaxCPULevel <FIELD_CHARACTER> (maxcpulevel)
m_nMinGPULevel <FIELD_CHARACTER> (mingpulevel)
m_nMaxGPULevel <FIELD_CHARACTER> (maxgpulevel)
m_flFadeScale <FIELD_FLOAT> (fadescale)
Tables

m_Collision.m_vecMins
m_Collision (CCollisionProperty)
m_vecMins <FIELD_VECTOR>
m_vecMaxs <FIELD_VECTOR>
m_usSolidFlags <FIELD_SHORT>
m_nSurroundType <FIELD_CHARACTER>
m_flRadius <FIELD_FLOAT>
m_triggerBloat <FIELD_CHARACTER>
m_vecSpecifiedSurroundingMins <FIELD_VECTOR>
m_vecSpecifiedSurroundingMaxs <FIELD_VECTOR>
m_vecSurroundingMins <FIELD_VECTOR>
m_vecSurroundingMaxs <FIELD_VECTOR>
<span id="m_bUniformTriggerBloat (only in )">m_bUniformTriggerBloat (only in
) <FIELD_BOOLEAN>
m_nSolidType <FIELD_CHARACTER> (solid)
Removed since
Left 4 Dead
m_vecMinsPreScaled <FIELD_VECTOR>
m_vecMaxsPreScaled <FIELD_VECTOR>
m_vecSpecifiedSurroundingMinsPreScaled <FIELD_VECTOR>
m_vecSpecifiedSurroundingMaxsPreScaled <FIELD_VECTOR>
m_Network (CServerNetworkProperty)
m_hParent <FIELD_EHANDLE>
Only
Left 4 Dead 2 - m_Glow (CGlowProperty)
m_iGlowType <FIELD_INTEGER>
Input keys
m_iInitialTeamNum <FIELD_INTEGER> (TeamNum)
Since
Left 4 Dead
m_fadeMinDist <FIELD_INTEGER> (fademindist)
m_fadeMaxDist <FIELD_INTEGER> (fademaxdist)
Input functions
SetTeam <FIELD_INTEGER> linked function: InputSetTeam
Kill <FIELD_VOID> linked function: InputKill
KillHierarchy <FIELD_VOID> linked function: InputKillHierarchy
Use <FIELD_VOID> linked function: InputUse
Alpha <FIELD_INTEGER> linked function: InputAlpha
AlternativeSorting <FIELD_BOOLEAN> linked function: InputAlternativeSorting
Color <FIELD_COLOR32> linked function: InputColor
SetParent <FIELD_STRING> linked function: InputSetParent
SetParentAttachment <FIELD_STRING> linked function: InputSetParentAttachment
SetParentAttachmentMaintainOffset <FIELD_STRING> linked function: InputSetParentAttachmentMaintainOffset
ClearParent <FIELD_VOID> linked function: InputClearParent
SetDamageFilter <FIELD_STRING> linked function: InputSetDamageFilter
EnableDamageForces <FIELD_VOID> linked function: InputEnableDamageForces
DisableDamageForces <FIELD_VOID> linked function: InputDisableDamageForces
DispatchEffect (removed since ) <FIELD_STRING> linked function: InputDispatchEffect
DispatchResponse <FIELD_STRING> linked function: InputDispatchResponse
AddContext <FIELD_STRING> linked function: InputAddContext
RemoveContext <FIELD_STRING> linked function: InputRemoveContext
ClearContext <FIELD_STRING> linked function: InputClearContext
DisableShadow <FIELD_VOID> linked function: InputDisableShadow
EnableShadow <FIELD_VOID> linked function: InputEnableShadow
AddOutput <FIELD_STRING> linked function: InputAddOutput
FireUser1 <FIELD_STRING> linked function: InputFireUser1
FireUser2 <FIELD_STRING> linked function: InputFireUser2
FireUser3 <FIELD_STRING> linked function: InputFireUser3
FireUser4 <FIELD_STRING> linked function: InputFireUser4
In
Portal 2
SetLocalOrigin <FIELD_VECTOR> linked function: InputSetLocalOrigin
SetLocalAngles <FIELD_VECTOR> linked function: InputSetLocalAngles
DisableDraw <FIELD_VOID> linked function: InputDisableDraw
EnableDraw <FIELD_VOID> linked function: InputEnableDraw
DisableReceivingFlashlight <FIELD_VOID> linked function: InputDisableReceivingFlashlight
EnableReceivingFlashlight <FIELD_VOID> linked function: InputEnableReceivingFlashlight
DisableDrawInFastReflection <FIELD_VOID> linked function: InputDisableDrawInFastReflection
- Turns off rendering of this entity in reflections when using
$reflectonlymarkedentities
in water material.
EnableDrawInFastReflection <FIELD_VOID> linked function: InputEnableDrawInFastReflection
- Turn on rendering of this entity in reflections when using
$reflectonlymarkedentities
in water material.
RemovePaint <FIELD_VOID> linked function: InputRemovePaint
Since
Left 4 Dead 2 and also in
Team Fortress 2
RunScriptFile <FIELD_STRING> linked function: InputRunScriptFile
- description todo
RunScriptCode <FIELD_STRING> linked function: InputRunScript
- description todo
CallScriptFunction <FIELD_STRING> linked function: InputCallScriptFunction
- description todo
TerminateScriptScope <FIELD_VOID> linked function: InputTerminateScriptScope (only in )
- description todo
Keyvalues

- rendercolor / rendercolor32 <color>
- Converts rgb string into a single integer and sets m_clrRender
- renderamt <integer>
- Sets alpha portion of m_clrRender (last 8 bits)
- disableshadows <boolean>
- If non 0 adds EF_NOSHADOW flag to m_fEffects
- mins / maxs <vector>
- Sets m_Collision.m_vecMins/m_Collision.m_vecMaxs (also model scale related checks if CBaseAnimating) and recalculates m_Collision.m_flRadius if needed
- disablereceiveshadows <boolean>
- If non 0 adds EF_NORECEIVESHADOW flag to m_fEffects
- nodamageforces <boolean>
- If non 0 adds EFL_NO_DAMAGE_FORCES flag to m_iEFlags
- angle <float>
- Supposed to be single value seting yaw but due to mistake in code causes infinite recursion and crashes the game
- angles <angle>
- Sets angles (has parenting related checks[Elaborate?])
- origin <vector>
- Sets origin (has parenting related checks[Elaborate?])
- targetname <string>
- Sets m_iName (calls AllocPooledString to put/get it in/from game string table)
- <anything else> <any>
- Tries finding the key among keyfields and set appropriate field
Outputs
- OnUser1 / OnUser4
- Fired as response to FireUser1 / FireUser4
- OnKilled
- Fired when entity is killed
Other
DEFINE_PHYSPTR
m_pPhysicsObject <FIELD?>
DEFINE_UTLVECTOR
m_ResponseContexts <FIELD_EMBEDDED>
DEFINE_CUSTOM_FIELD
m_aThinkFunctions <FIELD?>
Functions
m_pfnThink <FIELD_FUNCTION>
m_pfnTouch <FIELD_FUNCTION>
m_pfnUse <FIELD_FUNCTION>
m_pfnBlocked <FIELD_FUNCTION>
m_pfnMoveDone <FIELD_FUNCTION>
- SUB_Remove
- SUB_DoNothing
- SUB_StartFadeOut
- SUB_StartFadeOutInstant
- SUB_FadeOut
- SUB_Vanish
- SUB_CallUseToggle
Think functions
- ShadowCastDistThink
(in all games since
) - ScriptThink - handles vscript thinkfunction
- FrictionRevertThink
To get the class name of an entity, use
entity->edict()->GetClassName();
Asserts
Client
Problem:
// Model could not be found
Assert( !"Model could not be found, index is -1" );
Solution:
- Check your model name three times.
- Precache your model on both server and client.