CBaseEntity: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 236: Line 236:
{{todo| sdk13mp links, these are well explained at [[Generic Keyvalues, Inputs and Outputs]], should probably add only more advanced information that wouldn't fit there}}
{{todo| sdk13mp links, these are well explained at [[Generic Keyvalues, Inputs and Outputs]], should probably add only more advanced information that wouldn't fit there}}


{{DEFINE_INPUTFUNC|FIELD_INTEGER|SetTeam|InputSetTeam|}}
{{DEFINE_INPUTFUNC|FIELD_INTEGER|SetTeam|InputSetTeam|Changes this entity's team.}}


{{DEFINE_INPUTFUNC|FIELD_VOID|Kill|[https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/server/baseentity.cpp#L4114 InputKill]|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|Kill|[https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/server/baseentity.cpp#L4114 InputKill]|Removes this entity and any entities parented to it from the world.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|KillHierarchy|[https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/server/baseentity.cpp#L4127 InputKillHierarchy]|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|KillHierarchy|[https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/server/baseentity.cpp#L4127 InputKillHierarchy]|Functions the same as <code>Kill</code>, although this entity and any entities parented to it are killed on the same frame, being marginally faster than<code>Kill</code>input.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|Use|InputUse|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|Use|InputUse|Same as a player invoking [[+use]]}}
{{DEFINE_INPUTFUNC|FIELD_INTEGER|Alpha|InputAlpha|}}
{{DEFINE_INPUTFUNC|FIELD_INTEGER|Alpha|InputAlpha|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 <tt>0</tt>.}}
{{DEFINE_INPUTFUNC|FIELD_BOOLEAN|AlternativeSorting|InputAlternativeSorting|}}
{{DEFINE_INPUTFUNC|FIELD_BOOLEAN|AlternativeSorting|InputAlternativeSorting|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.}}
{{DEFINE_INPUTFUNC|FIELD_COLOR32|Color|InputColor|}}
{{DEFINE_INPUTFUNC|FIELD_COLOR32|Color|InputColor|Sets an RGB color for the entity.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParent|InputSetParent|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParent|InputSetParent|Move with specified entity.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParentAttachment|InputSetParentAttachment|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParentAttachment|InputSetParentAttachment|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.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParentAttachmentMaintainOffset|InputSetParentAttachmentMaintainOffset|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParentAttachmentMaintainOffset|InputSetParentAttachmentMaintainOffset|As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|ClearParent|InputClearParent|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|ClearParent|InputClearParent|Removes this entity from the movement hierarchy, leaving it free to move independently.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetDamageFilter|InputSetDamageFilter|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|SetDamageFilter|InputSetDamageFilter|Sets a [[filter]] for this entity for when it receives damage.}}


{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDamageForces|InputEnableDamageForces|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDamageForces|InputEnableDamageForces|Allows the entity to be pushed by damage done to it (usually force amount correlates with the damage done).}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDamageForces|InputDisableDamageForces|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDamageForces|InputDisableDamageForces|Prevents the entity from being pushed by damage done to it.}}


{{DEFINE_INPUTFUNC|FIELD_STRING|DispatchEffect {{l4d|removed}}|InputDispatchEffect|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|DispatchEffect {{l4d|removed}}|InputDispatchEffect|Dispatches a special effect from the entity's origin; See also [[List of Client Effects]]. Replaced by the [[particle]] system since {{l4d}}.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|DispatchResponse|InputDispatchResponse|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|DispatchResponse|InputDispatchResponse|Dispatches a response to the entity. See [[Response]] and [[Concept]].}}


{{DEFINE_INPUTFUNC|FIELD_STRING|AddContext|InputAddContext|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|AddContext|InputAddContext|Adds to the entity's list of [[Response System|response contexts]]. See [[Context|Context]].}}
{{DEFINE_INPUTFUNC|FIELD_STRING|RemoveContext|InputRemoveContext|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|RemoveContext|InputRemoveContext|Remove a context from this entity's list. The name should match the key of an existing context.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|ClearContext|InputClearContext|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|ClearContext|InputClearContext|Removes all contexts from this entity's list.}}


{{DEFINE_INPUTFUNC|FIELD_VOID|DisableShadow|InputDisableShadow|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableShadow|InputDisableShadow|Turn [[Lighting#Dynamic_shadows|dynamic shadows]] off for this entity. Identical to applying &thinsp;{{ent|EF_NOSHADOW}}.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableShadow|InputEnableShadow|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableShadow|InputEnableShadow|Turn dynamic shadows on for this entity.}}


{{DEFINE_INPUTFUNC|FIELD_STRING|AddOutput|InputAddOutput|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|AddOutput|InputAddOutput|Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:{{Expand|<syntaxhighlight lang="PowerShell">
// 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"
</syntaxhighlight>| Syntax<nowiki>:</nowiki>}}}}


{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser1|InputFireUser1|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser1|InputFireUser1|}}
Line 269: Line 280:
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser3|InputFireUser3|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser3|InputFireUser3|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser4|InputFireUser4|}}
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser4|InputFireUser4|}}
:Fires the respective<code>OnUser</code>outputs; see [[User Inputs and Outputs]].


==== In {{portal 2|4|}} ====
==== In {{portal 2|4|}} ====
{{DEFINE_INPUTFUNC|FIELD_VECTOR|SetLocalOrigin|InputSetLocalOrigin|}}
{{DEFINE_INPUTFUNC|FIELD_VECTOR|SetLocalOrigin|InputSetLocalOrigin|Set this entity's origin in the map.}}
{{DEFINE_INPUTFUNC|FIELD_VECTOR|SetLocalAngles|InputSetLocalAngles|}}
{{DEFINE_INPUTFUNC|FIELD_VECTOR|SetLocalAngles|InputSetLocalAngles|Set this entity's angles in the map.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDraw|InputDisableDraw|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDraw|InputDisableDraw|Applies EF_NODRAW to the entity. Note that this is different than Render Mode 10.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDraw|InputEnableDraw|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDraw|InputEnableDraw|Removes EF_NODRAW from the entity.}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableReceivingFlashlight|InputDisableReceivingFlashlight|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableReceivingFlashlight|InputDisableReceivingFlashlight|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableReceivingFlashlight|InputEnableReceivingFlashlight|}}
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableReceivingFlashlight|InputEnableReceivingFlashlight|}}
Line 282: Line 294:


==== Since {{l4d2|4}} and also in {{tf2|4}} ====
==== Since {{l4d2|4}} and also in {{tf2|4}} ====
{{DEFINE_INPUTFUNC|FIELD_STRING|RunScriptFile|InputRunScriptFile}}
{{DEFINE_INPUTFUNC|FIELD_STRING|RunScriptFile|InputRunScriptFile|Execute a [[VScript]] file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|RunScriptCode|InputRunScript}}
{{DEFINE_INPUTFUNC|FIELD_STRING|RunScriptCode|InputRunScript|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.}}
{{DEFINE_INPUTFUNC|FIELD_STRING|CallScriptFunction|InputCallScriptFunction}}
{{DEFINE_INPUTFUNC|FIELD_STRING|CallScriptFunction|InputCallScriptFunction|Calls a VScript function defined in the scope of the receiving entity.}}


{{DEFINE_INPUTFUNC|FIELD_VOID|TerminateScriptScope|InputTerminateScriptScope {{tf2|only}}}}
{{DEFINE_INPUTFUNC|FIELD_VOID|TerminateScriptScope|InputTerminateScriptScope {{tf2|only}}|Destroys the script scope of the receiving entity.}}





Revision as of 08:44, 27 September 2024

English (en)中文 (zh)Translate (Translate)
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
stuff, terminology?, sections
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
C++ Class hierarchy
CBaseEntity
IServerEntity
IServerUnknown
IHandleEntity
C++ baseentity.cpp

The base class for all entities.

Icon-Important.pngImportant:The following Keyvalues / Inputs / Outputs and other properties are available for all entities that inherit this class, but may be overridden by game code.

Keyvalues / Inputs / Outputs

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>

Set by commands like ent_text, ent_bbox, see Entity debugging ↓

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_flNavIgnoreUntilTime <FIELD_TIME>


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 Team Fortress 2Portal 2)">m_bForcePurgeFixedupStrings (in Team Fortress 2Portal 2) <FIELD_BOOLEAN>


<span id="m_flCreateTime (in Left 4 Dead seriesLeft 4 Dead seriesAlien Swarm)">m_flCreateTime (in Left 4 Dead seriesLeft 4 Dead seriesAlien Swarm) <FIELD_TIME>


<span id="m_bClientSideRagdoll (in all games since Left 4 Dead)">m_bClientSideRagdoll (in all games since Left 4 Dead) <FIELD_BOOLEAN>


<span id="m_iszScriptId (in all games since Left 4 Dead 2)(also in Team Fortress 2)">m_iszScriptId (in all games since Left 4 Dead 2)(also in Team Fortress 2) <FIELD_STRING>


Only Left 4 Dead 2 Left 4 Dead 2

m_hScriptUseTarget <FIELD_EHANDLE>

m_PreStasisMoveType <FIELD_INTEGER>

m_bIsInStasis <FIELD_BOOLEAN>


Only Portal 2 Portal 2

m_iSignifierName <FIELD? 4bytes>

m_iObjectCapsCache <FIELD? 4bytes>


Array fields

m_rgflCoordinateFrame[12] <FIELD_FLOAT>


<span id="(only in Team Fortress 2) m_nModelIndexOverrides>(only in Team Fortress 2) m_nModelIndexOverrides[4] <FIELD_INTEGER>


Tables

Note.pngNote:Accessed in vscript like 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>

Radius of a sphere around our AABB
Todo: see this image and describe with better wording

m_triggerBloat <FIELD_CHARACTER>

If m_usSolidFlags has FSOLID_USE_TRIGGER_BOUNDS this value is added to mins/maxs (for z axis only only maxs are modified and with half the value). (ent_bbox show this bloat with cyan lines) See CCollisionProperty::WorldSpaceTriggerBounds

m_vecSpecifiedSurroundingMins <FIELD_VECTOR>

m_vecSpecifiedSurroundingMaxs <FIELD_VECTOR>

m_vecSurroundingMins <FIELD_VECTOR>

m_vecSurroundingMaxs <FIELD_VECTOR>

<span id="m_bUniformTriggerBloat (only in Team Fortress 2)">m_bUniformTriggerBloat (only in Team Fortress 2) <FIELD_BOOLEAN>

m_nSolidType <FIELD_CHARACTER> (solid)


Removed since Left 4 Dead 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 Left 4 Dead 2 - m_Glow (CGlowProperty)

m_iGlowType <FIELD_INTEGER>


Keyfield since Alien Swarm Alien Swarm and also in Team Fortress 2 Team Fortress 2

Note.pngNote:These were give a key 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.
Groups
  • 0: None
  • 1: Debris, collides only with the world and static props
  • 2: Debris, with trigger interaction
  • 3: Interactive Debris, doesn't collide with other debris
  • 4: Interactive, collides with everything except debris
  • 5: Player
  • 6: Breakable Glass
  • 7: Vehicle
  • 8: Player Movement
  • 9: In-Vehicle
  • 10: Weapon
  • 11: Vehicle Clip
  • 12: Projectile
  • 13: Door blocker, not permitted to go near doors
  • 14: Passable Door
  • 15: Dissolving
  • 16: Pushaway
  • 17: NPC Actor, NPCs ignore the player
  • 18: NPC Scripted, NPCs do not collide with each other

m_MoveType <FIELD_CHARACTER> (MoveType)

Sets a movetype for this entity, which changes its movement behavior.
Move Types
  • 0: None, don't move
  • 1: Isometric
  • 2: Walk, player only, moving on ground
  • 3: NPC, movement
  • 4: Fly, no gravity
  • 5: Fly, with gravity
  • 6: Physics
  • 7: Push
  • 8: Noclip
  • 9: Ladder, for players on ladders
  • 10: Spectator
  • 11: Custom

Keyfields

Todo: most explained at Generic Keyvalues, Inputs and Outputs, should add only more advanced information that wouldn't fit there?

m_iClassname <FIELD_STRING> (classname)

m_iGlobalname <FIELD_STRING> (globalname)

When the player transitions to a new map, entities in the new map with matching globalnames will have their previous map's states copied over to it.

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)

Combination of effect flags to use.

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.pngWarning: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.pngTip:Can also be filtered for or against!

m_iMaxHealth <FIELD_INTEGER> (max_health)

Health cannot exceed this value. This keyvalue applies to only specific entities.

m_iHealth <FIELD_INTEGER> (health)

Current health of an entity. This keyvalue applies to only specific entities.

m_target <FIELD_STRING> (target)

m_iszDamageFilterName <FIELD_STRING> (damagefilter)

Name of a filter that controls which entities can damage this entity.

m_flShadowCastDistance <FIELD_FLOAT> (shadowcastdist)

Sets how far the entity casts dynamic shadows. 0 means default distance from the shadow_control entity.

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)

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 Left 4 Dead 2

m_bDisableX360 <FIELD_BOOLEAN> (disableX360)

If this entity should automatically be given the 'Disable' input on the Xbox 360 version of Source.

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.
Todo: more testing what this does

Left 4 Dead 2 Left 4 Dead 2, Alien Swarm Alien Swarm, Portal 2 Portal 2

m_AIAddOn <FIELD? 4bytes> (addon)

m_bLagCompensate <FIELD_BOOLEAN> (LagCompensate)


Since Left 4 Dead 2 Left 4 Dead 2 and also in Team Fortress 2 Team Fortress 2

m_iszVScripts <FIELD_STRING> (vscripts)

m_iszScriptThinkFunction <FIELD_STRING> (thinkfunction)


Since Left 4 Dead 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)


Input keys

m_iInitialTeamNum <FIELD_INTEGER> (TeamNum)


Since Left 4 Dead Left 4 Dead

m_fadeMinDist <FIELD_INTEGER> (fademindist)

m_fadeMaxDist <FIELD_INTEGER> (fademaxdist)


Input functions

Todo:  sdk13mp links, these are well explained at Generic Keyvalues, Inputs and Outputs, should probably add only more advanced information that wouldn't fit there

SetTeam <FIELD_INTEGER> linked function: InputSetTeam

Changes this entity's team.

Kill <FIELD_VOID> linked function: InputKill

Removes this entity and any entities parented to it from the world.

KillHierarchy <FIELD_VOID> linked function: InputKillHierarchy

Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.

Use <FIELD_VOID> linked function: InputUse

Same as a player invoking +use

Alpha <FIELD_INTEGER> linked function: InputAlpha

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 <FIELD_BOOLEAN> linked function: InputAlternativeSorting

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 <FIELD_COLOR32> linked function: InputColor

Sets an RGB color for the entity.

SetParent <FIELD_STRING> linked function: InputSetParent

Move with specified entity.

SetParentAttachment <FIELD_STRING> linked function: InputSetParentAttachment

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 <FIELD_STRING> linked function: InputSetParentAttachmentMaintainOffset

As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.

ClearParent <FIELD_VOID> linked function: InputClearParent

Removes this entity from the movement hierarchy, leaving it free to move independently.

SetDamageFilter <FIELD_STRING> linked function: InputSetDamageFilter

Sets a filter for this entity for when it receives damage.

EnableDamageForces <FIELD_VOID> linked function: InputEnableDamageForces

Allows the entity to be pushed by damage done to it (usually force amount correlates with the damage done).

DisableDamageForces <FIELD_VOID> linked function: InputDisableDamageForces

Prevents the entity from being pushed by damage done to it.

DispatchEffect (removed since Left 4 Dead) <FIELD_STRING> linked function: InputDispatchEffect

Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since Left 4 Dead.

DispatchResponse <FIELD_STRING> linked function: InputDispatchResponse

Dispatches a response to the entity. See Response and Concept.

AddContext <FIELD_STRING> linked function: InputAddContext

Adds to the entity's list of response contexts. See Context.

RemoveContext <FIELD_STRING> linked function: InputRemoveContext

Remove a context from this entity's list. The name should match the key of an existing context.

ClearContext <FIELD_STRING> linked function: InputClearContext

Removes all contexts from this entity's list.

DisableShadow <FIELD_VOID> linked function: InputDisableShadow

Turn dynamic shadows off for this entity. Identical to applying  EF_NOSHADOW.

EnableShadow <FIELD_VOID> linked function: InputEnableShadow

Turn dynamic shadows on for this entity.

AddOutput <FIELD_STRING> linked function: InputAddOutput

Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed: {| class="mw-collapsible mw-collapsed" style="background:rgba(0,0,0,0.05) ;float:no;margin-bottom:1em;margin-left:0;padding-right:0.5em;border:1px solid rgba(255,255,255,0.1); border-left:solid 1px #8bb9e0; padding-left:1em;"

|+ style="text-align:left; white-space:nowrap; font-weight:bold; color:#ddd; " |

|

// 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"

|}

FireUser1 <FIELD_STRING> linked function: InputFireUser1

FireUser2 <FIELD_STRING> linked function: InputFireUser2

FireUser3 <FIELD_STRING> linked function: InputFireUser3

FireUser4 <FIELD_STRING> linked function: InputFireUser4

Fires the respectiveOnUseroutputs; see User Inputs and Outputs.

In Portal 2 Portal 2

SetLocalOrigin <FIELD_VECTOR> linked function: InputSetLocalOrigin

Set this entity's origin in the map.

SetLocalAngles <FIELD_VECTOR> linked function: InputSetLocalAngles

Set this entity's angles in the map.

DisableDraw <FIELD_VOID> linked function: InputDisableDraw

Applies EF_NODRAW to the entity. Note that this is different than Render Mode 10.

EnableDraw <FIELD_VOID> linked function: InputEnableDraw

Removes EF_NODRAW from the entity.

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 Left 4 Dead 2 and also in Team Fortress 2 Team Fortress 2

RunScriptFile <FIELD_STRING> linked function: InputRunScriptFile

Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.

RunScriptCode <FIELD_STRING> linked function: InputRunScript

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 <FIELD_STRING> linked function: InputCallScriptFunction

Calls a VScript function defined in the scope of the receiving entity.

TerminateScriptScope <FIELD_VOID> linked function: InputTerminateScriptScope (only in Team Fortress 2)

Destroys the script scope of the receiving entity.


Keyvalues

Note.pngNote:Keys defined in CBaseEntity::KeyValue, this is where keyvalue handling starts unless overriden in subclass
rendercolor / rendercolor32 <color>
Converts rgb string into a single integer and sets first 24 bits of 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>


Todo: explain why are they defined like this (DEFINE_FUNCTION)
  • SUB_Remove
  • SUB_DoNothing
  • SUB_StartFadeOut
  • SUB_StartFadeOutInstant
  • SUB_FadeOut
  • SUB_Vanish
  • SUB_CallUseToggle

Think functions

  • ShadowCastDistThink
  • Team Fortress 2(in all games since Left 4 Dead 2) - ScriptThink - handles vscript thinkfunction
  • Left 4 Dead seriesLeft 4 Dead seriesAlien Swarm - FrictionRevertThink

Entity debugging

Changing m_debugOverlays shows various debug overlays when developer mode is active.


OVERLAY_TEXT_BIT : [1]
Added by ent_text
OVERLAY_NAME_BIT : [2]
Added by ent_name
OVERLAY_BBOX_BIT : [4]
Added by ent_bbox (bounding box overlay for this entity)
OVERLAY_PIVOT_BIT : [8]
Added by ent_pivot (show pivot for this entity)
OVERLAY_MESSAGE_BIT : [16]
Added by ent_messages (show messages for this entity)
OVERLAY_ABSBOX_BIT : [32]
Added by ent_absbox (show abs bounding box overlay)
OVERLAY_RBOX_BIT : [64]
Added by ent_rbox
OVERLAY_SHOW_BLOCKSLOS : [128]
See ai_debug_los (show entities that block NPC LOS)
OVERLAY_ATTACHMENTS_BIT : [256]
Added by ent_attachments (show attachment points)
OVERLAY_AUTOAIM_BIT : [512]
Added by ent_autoaim (Display autoaim radius)
OVERLAY_VIEWOFFSET : [1073741824]
Added by ent_viewoffset (show view offset)

ent_text

Note.pngNote:Using ent_text on an entity adds OVERLAY_TEXT_BIT to m_debugOverlays and if dev mode is active those overlays will be drawn
  • GetDebugName() - for entities returns m_iName if not empty otherwise m_iClassname
  • entindex() - returns entity index (0 if entity is derived from CServerOnlyEntity
(<entindex()>) Name: <GetDebugName()> (<m_iClassname>)
GLOBALNAME: m_iGlobalname <!-- if m_iGlobalname not empty then this line is present -->
Position: <%0.1f, %0.1f, %0.1f, m_vecAbsOrigin.x, m_vecAbsOrigin.y, m_vecAbsOrigin.z>
Model:<m_ModelName> <!-- if m_ModelName not empty or this entity is derived from CBaseAnimating then this line is present -->
DAMAGE FILTER:<m_hDamageFilter->GetDebugName()> <!-- if m_hDamageFilter is not null then this line is present and its debug name is shown -->

ent_viewoffset

Draws red cross at EyePosition(). Eye position is m_vecAbsOrigin + m_vecViewOffset

NDebugOverlay::Cross3D( EyePosition(), 16, 255, 0, 0, true, 0.05f )

ent_name

Show just the debug name (GetDebugName())

ent_bbox

Orange color. Draws bounding box via if we are an edict (not derived from CServerOnlyEntity) CBaseEntity::DrawBBoxOverlay

ent_absbox

Green color. Draws absolute bounding box if we are not an edict. (If non sleeping vphysics object the color is brighter green) CBaseEntity::DrawBBoxOverlay

ent_pivot

If we are an edict draws pivote at m_vecAbsOrigin with rotation of GetAbsAngles()

NDebugOverlay::Axis( GetAbsOrigin(), GetAbsAngles(), 20, true, 0 );

ent_rbox

DrawRBoxOverlay() - draws nothing, assuming rbox stands for render box it makes sense because render boxes would be client side thing and those can be shown by r_drawrenderboxes or cl_ent_rbox

Programming related

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.

See Also