CBaseEntity: Difference between revisions
Gameplayer (talk | contribs) No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{LanguageBar}} | {{LanguageBar}} | ||
{{ | {{TabsBar|main=gs|base=CBaseEntity}} | ||
{{cleanup|stuff, terminology?, sections}} | |||
{{CD|CBaseEntity|base=IServerEntity|nolink=1|file1=[https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/baseentity.cpp baseentity.cpp]}} | {{CD|CBaseEntity|base=IServerEntity|nolink=1|file1=[https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/baseentity.cpp baseentity.cpp]}} | ||
{{toc-right}} | {{toc-right}} | ||
Line 7: | Line 8: | ||
{{important|Following Keyvalues / Inputs / Outputs are available for all entities that inherit this class, but may be overridden by game code.}} | {{important|Following Keyvalues / Inputs / Outputs are available for all entities that inherit this class, but may be overridden by game code.}} | ||
== | == Fields == | ||
{{ | {{DEFINE_FIELD|m_iName|FIELD_STRING|Name other entities use to refer to this entity}} <!-- (Save)(4 Bytes) --> | ||
{{DEFINE_FIELD|m_vecOrigin|FIELD_VECTOR|Relative to parent{{confirm}} }} <!-- (Save)(12 Bytes) --> | |||
{{ | {{DEFINE_FIELD|m_vecAbsOrigin|FIELD_POSITION_VECTOR}} <!-- (Save)(12 Bytes) --> | ||
{{DEFINE_FIELD|m_vecAbsVelocity|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | |||
{{ | |||
{{ | |||
{{ | |||
{{DEFINE_FIELD|m_angRotation|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | |||
{{ | {{DEFINE_FIELD|m_angAbsRotation|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | ||
{{DEFINE_FIELD|m_fFlags|FIELD_INTEGER}} <!-- (Save)(4 Bytes) --> | |||
{{ | {{DEFINE_FIELD|m_iEFlags|FIELD_INTEGER}} <!-- (Save)(4 Bytes) --> | ||
{{DEFINE_FIELD|m_debugOverlays|FIELD_INTEGER|Set by commands like {{cmd|ent_text}}, {{cmd|ent_bbox}}}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_flPrevAnimTime|FIELD_TIME}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_flAnimTime|FIELD_TIME}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|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}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|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}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_MoveCollide|FIELD_CHARACTER}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_flElasticity|FIELD_FLOAT}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|touchStamp|FIELD_INTEGER}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_flDesiredShadowCastDistance|FIELD_FLOAT}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_flGroundChangeTime|FIELD_TIME}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_nWaterType|FIELD_CHARACTER}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_pBlocker|FIELD_EHANDLE}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_flVPhysicsUpdateLocalTime|FIELD_FLOAT}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_flMoveDoneTime|FIELD_FLOAT}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_bAlternateSorting|FIELD_BOOLEAN}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_flSimulationTime|FIELD_TIME}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_nLastThinkTick|FIELD_TICK}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_nSimulationTick|FIELD_TICK}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_bSimulatedEveryTick|FIELD_BOOLEAN}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_bAnimatedEveryTick|FIELD_BOOLEAN}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_nTransmitStateOwnedCounter|FIELD_CHARACTER}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_flNavIgnoreUntilTime|FIELD_TIME}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_pParent|FIELD_EHANDLE}} <!-- (Global|Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_iParentAttachment|FIELD_CHARACTER}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_hMoveParent|FIELD_EHANDLE}} <!-- (Global|Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_hMoveChild|FIELD_EHANDLE}} <!-- (Global|Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_hMovePeer|FIELD_EHANDLE}} <!-- (Global|Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_hDamageFilter|FIELD_EHANDLE}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_hOwnerEntity|FIELD_EHANDLE}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_hEffectEntity|FIELD_EHANDLE}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_hGroundEntity|FIELD_EHANDLE}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_pfnThink|FIELD_FUNCTION}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_pfnTouch|FIELD_FUNCTION}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_pfnUse|FIELD_FUNCTION}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_pfnBlocked|FIELD_FUNCTION}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_pfnMoveDone|FIELD_FUNCTION}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_bForcePurgeFixedupStrings {{in|{{tf2}}{{portal2}}}}|FIELD_BOOLEAN}} | |||
{{DEFINE_FIELD|m_flCreateTime {{in|{{l4ds}}{{as}}}}|FIELD? 4Bytes}} | |||
{{DEFINE_FIELD|m_bClientSideRagdoll {{l4d|since}}|FIELD_BOOLEAN}} | |||
{{DEFINE_FIELD|m_iszScriptId {{l4d2|since}}{{tf2|also}}|FIELD_STRING}} | |||
==== Only {{l4d2|4}} ==== | |||
{{DEFINE_FIELD|m_hScriptUseTarget|FIELD_EHANDLE}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_PreStasisMoveType|FIELD_INTEGER}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_bIsInStasis|FIELD_BOOLEAN}} <!-- (Save)(1 Bytes) --> | |||
==== Only {{Portal 2|4}} ==== | |||
{{DEFINE_FIELD|m_iSignifierName|FIELD? 4bytes|}} | |||
{{DEFINE_FIELD|m_iObjectCapsCache|FIELD? 4bytes|}} | |||
=== Array fields === | |||
{{DEFINE_ARRAY|m_rgflCoordinateFrame|FIELD_FLOAT|12}} <!-- (Save)(48 Bytes) --> | |||
==== Only {{tf2|4}} ==== | |||
{{DEFINE_ARRAY|m_nModelIndexOverrides|FIELD_INTEGER|4}} | |||
=== Keyfield since {{as|4}} and in {{tf2|4}} === | |||
{{note|Key attached since {{as}} and also in {{tf2}}}} | |||
{{DEFINE_KEYFIELD|m_iTeamNum|FIELD_INTEGER|teamnumber}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_KEYFIELD|m_CollisionGroup|FIELD_INTEGER|CollisionGroup}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_KEYFIELD|m_MoveType|FIELD_CHARACTER|MoveType}} <!-- (Save)(1 Bytes) --> | |||
=== Keyfields === | |||
{{todo|most explained at [[Generic Keyvalues, Inputs and Outputs]], should add only more advanced information that wouldn't fit there?}} | |||
{{DEFINE_KEYFIELD|m_iClassname|FIELD_STRING|classname}} | |||
{{DEFINE_KEYFIELD|m_iGlobalname|FIELD_STRING|globalname}} | |||
{{DEFINE_KEYFIELD|m_iParent|FIELD_STRING|parentname}} | |||
{{DEFINE_KEYFIELD|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 {{cmd|ent_keyvalue}} command). Entities spawned in run-time don't have a Hammer ID.}} | |||
{{DEFINE_KEYFIELD|m_flSpeed|FIELD_FLOAT|speed}} | |||
{{DEFINE_KEYFIELD|m_nRenderFX|FIELD_CHARACTER|renderfx}} | |||
{{DEFINE_KEYFIELD|m_nRenderMode|FIELD_CHARACTER|rendermode}} | |||
{{DEFINE_KEYFIELD|m_nNextThinkTick|FIELD_TICK|nextthink|Amount of time before the entity [[Thinking|thinks]] again.}} | |||
{{DEFINE_KEYFIELD|m_fEffects|FIELD_INTEGER|effects}} | |||
{{DEFINE_KEYFIELD|m_clrRender|FIELD_COLOR32|rendercolor}} | |||
{{DEFINE_KEYFIELD|m_nModelIndex|FIELD_SHORT|modelindex|Given the number index from dumping the <code>cl_precacheinfo modelprecache</code> 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.}}}} | |||
{{DEFINE_KEYFIELD|m_iszResponseContext|FIELD_STRING|ResponseContext|Pre-defined response system contexts; Format is <code>[key]:[value],[key]:[value],...</code>and so on. {{Tip|Can also be [[filter_activator_context|filtered for or against!]]}}}} | |||
{{DEFINE_KEYFIELD|m_iMaxHealth|FIELD_INTEGER|max_health}} | |||
{{DEFINE_KEYFIELD|m_iHealth|FIELD_INTEGER|health}} | |||
{{DEFINE_KEYFIELD|m_target|FIELD_STRING|target}} | |||
{{DEFINE_KEYFIELD|m_iszDamageFilterName|FIELD_STRING|damagefilter}} | |||
{{DEFINE_KEYFIELD|m_flShadowCastDistance|FIELD_FLOAT|shadowcastdist}} | |||
{{DEFINE_KEYFIELD|m_ModelName|FIELD_MODELNAME|model|In-game representation of the entity to display}} | |||
{{DEFINE_KEYFIELD|m_vecBaseVelocity|FIELD_VECTOR|basevelocity}} | |||
{{DEFINE_KEYFIELD|m_vecAngVelocity|FIELD_VECTOR|avelocity}} | |||
{{DEFINE_KEYFIELD|m_nWaterLevel|FIELD_CHARACTER|waterlevel}} | |||
{{DEFINE_KEYFIELD|m_flGravity|FIELD_FLOAT|gravity}} | |||
{{DEFINE_KEYFIELD|m_flFriction|FIELD_FLOAT|friction}} | |||
{{DEFINE_KEYFIELD|m_flLocalTime|FIELD_FLOAT|ltime|The local time of the entity, independent of the global clock. Used mainly for physics calculations.}} | |||
{{DEFINE_KEYFIELD|m_vecVelocity|FIELD_VECTOR|velocity}} | |||
{{DEFINE_KEYFIELD|m_iTextureFrameIndex|FIELD_CHARACTER|texframeindex|The initial frame number for all animated textures on this entity.}} | |||
{{DEFINE_KEYFIELD|m_spawnflags|FIELD_INTEGER|spawnflags|Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.}} | |||
{{DEFINE_KEYFIELD|m_vecViewOffset|FIELD_VECTOR|view_ofs}} | |||
==== Only in {{l4d2|4}} ==== | |||
{{DEFINE_KEYFIELD|m_bDisableX360|FIELD_BOOLEAN|disableX360}} | |||
{{DEFINE_KEYFIELD|m_bGlowBackfaceMult|FIELD? 4bytes|glowbackfacemult}} | |||
==== {{l4d2|4}}, {{as|4}}, {{portal2|4}} ==== | |||
{{DEFINE_KEYFIELD|m_AIAddOn|FIELD? 4bytes|addon}} | |||
{{DEFINE_KEYFIELD|m_bLagCompensate|FIELD_BOOLEAN|LagCompensate}} | |||
==== Since {{l4d2|4}} and also in {{tf2|4}} ==== | |||
{{DEFINE_KEYFIELD|m_iszVScripts|FIELD_STRING|vscripts}} | |||
{{DEFINE_KEYFIELD|m_iszScriptThinkFunction|FIELD_STRING|thinkfunction}} | |||
==== Since {{l4d|4}} ==== | |||
{{DEFINE_KEYFIELD|m_nMinCPULevel|FIELD_CHARACTER|mincpulevel}} | |||
{{DEFINE_KEYFIELD|m_nMaxCPULevel|FIELD_CHARACTER|maxcpulevel}} | |||
{{DEFINE_KEYFIELD|m_nMinGPULevel|FIELD_CHARACTER|mingpulevel}} | |||
{{DEFINE_KEYFIELD|m_nMaxGPULevel|FIELD_CHARACTER|maxgpulevel}} | |||
{{DEFINE_KEYFIELD|m_flFadeScale|FIELD_FLOAT|fadescale}} | |||
=== Tables === | |||
{{note|Accessed in vscript like <code>m_Collision.m_vecMins</code>}} | |||
==== m_Collision (CCollisionProperty) ==== <!-- Sub-Class Table (1 Deep): m_Collision - CCollisionProperty --> | |||
{{DEFINE_FIELD|m_vecMins|FIELD_VECTOR}} <!-- (Global|Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_vecMaxs|FIELD_VECTOR}} <!-- (Global|Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_usSolidFlags|FIELD_SHORT}} <!-- (Save)(2 Bytes) --> | |||
{{DEFINE_FIELD|m_nSurroundType|FIELD_CHARACTER}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_flRadius|FIELD_FLOAT}} <!-- (Save)(4 Bytes) --> | |||
{{DEFINE_FIELD|m_triggerBloat|FIELD_CHARACTER}} <!-- (Save)(1 Bytes) --> | |||
{{DEFINE_FIELD|m_vecSpecifiedSurroundingMins|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_vecSpecifiedSurroundingMaxs|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_vecSurroundingMins|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_vecSurroundingMaxs|FIELD_VECTOR}} <!-- (Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_bUniformTriggerBloat {{tf2|only}}|FIELD_BOOLEAN}} <!-- (Save)(1 Bytes) (only tf2) --> | |||
{{DEFINE_KEYFIELD|m_nSolidType|FIELD_CHARACTER|solid}} <!-- (Save|Key)(1 Bytes) - solid --> | |||
===== Removed since {{l4d|4}} ===== | |||
{{DEFINE_FIELD|m_vecMinsPreScaled|FIELD_VECTOR}} <!-- (Global|Save)(12 Bytes) --> | |||
{{DEFINE_FIELD|m_vecMaxsPreScaled|FIELD_VECTOR}} <!-- (Global|Save)(12 Bytes)--> | |||
{{DEFINE_FIELD|m_vecSpecifiedSurroundingMinsPreScaled|FIELD_VECTOR}} <!-- (Save)(12 Bytes)--> | |||
{{DEFINE_FIELD|m_vecSpecifiedSurroundingMaxsPreScaled|FIELD_VECTOR}} <!-- (Save)(12 Bytes)--> | |||
==== m_Network (CServerNetworkProperty) ==== | |||
{{DEFINE_FIELD|m_hParent|FIELD_EHANDLE}} | |||
==== Only {{l4d2|4}} - m_Glow (CGlowProperty) ==== | |||
{{DEFINE_FIELD|m_iGlowType|FIELD_INTEGER}} | |||
=== Input keys === | |||
{{DEFINE_INPUT|m_iInitialTeamNum|FIELD_INTEGER|TeamNum}} | |||
==== Since {{l4d|4}} ==== | |||
{{DEFINE_INPUT|m_fadeMinDist|FIELD_INTEGER|fademindist}} | |||
{{DEFINE_INPUT|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}} | |||
{{DEFINE_INPUTFUNC|FIELD_INTEGER|SetTeam|InputSetTeam|}} | |||
{{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|KillHierarchy|[https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/server/baseentity.cpp#L4127 InputKillHierarchy]|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|Use|InputUse|}} | |||
{{DEFINE_INPUTFUNC|FIELD_INTEGER|Alpha|InputAlpha|}} | |||
{{DEFINE_INPUTFUNC|FIELD_BOOLEAN|AlternativeSorting|InputAlternativeSorting|}} | |||
{{DEFINE_INPUTFUNC|FIELD_COLOR32|Color|InputColor|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParent|InputSetParent|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParentAttachment|InputSetParentAttachment|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|SetParentAttachmentMaintainOffset|InputSetParentAttachmentMaintainOffset|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|ClearParent|InputClearParent|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|SetDamageFilter|InputSetDamageFilter|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDamageForces|InputEnableDamageForces|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDamageForces|InputDisableDamageForces|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|DispatchEffect {{l4d|removed}}|InputDispatchEffect|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|DispatchResponse|InputDispatchResponse|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|AddContext|InputAddContext|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|RemoveContext|InputRemoveContext|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|ClearContext|InputClearContext|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableShadow|InputDisableShadow|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableShadow|InputEnableShadow|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|AddOutput|InputAddOutput|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser1|InputFireUser1|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser2|InputFireUser2|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser3|InputFireUser3|}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|FireUser4|InputFireUser4|}} | |||
==== In {{portal 2|4|}} ==== | |||
{{DEFINE_INPUTFUNC|FIELD_VECTOR|SetLocalOrigin|InputSetLocalOrigin|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VECTOR|SetLocalAngles|InputSetLocalAngles|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDraw|InputDisableDraw|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDraw|InputEnableDraw|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableReceivingFlashlight|InputDisableReceivingFlashlight|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableReceivingFlashlight|InputEnableReceivingFlashlight|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|DisableDrawInFastReflection|InputDisableDrawInFastReflection|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|EnableDrawInFastReflection|InputEnableDrawInFastReflection|}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|RemovePaint|InputRemovePaint|}} | |||
==== Since {{l4d2|4}} and also in {{tf2|4}} ==== | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|RunScriptFile|InputRunScriptFile}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|RunScriptCode|InputRunScript}} | |||
{{DEFINE_INPUTFUNC|FIELD_STRING|CallScriptFunction|InputCallScriptFunction}} | |||
{{DEFINE_INPUTFUNC|FIELD_VOID|TerminateScriptScope|InputTerminateScriptScope {{tf2|only}}}} | |||
=== Keyvalues === | |||
{{note|Keys defined in [https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/shared/baseentity_shared.cpp#L320 CBaseEntity::KeyValue], this is where keyvalue handling starts unless overriden in subclass}} | |||
<!-- {{KV|#<anything>|intn=0|any|{{code|<nowiki>#</nowiki>}} is striped and rest is processed as <anything> keyvalue, (ex. #targetname same as targetname) }} --> | |||
{{KV|rendercolor / rendercolor32|intn=0|color|Converts rgb string into a single integer and sets m_clrRender}} | |||
{{KV|renderamt|intn=0|int|Sets alpha portion of m_clrRender (last 8 bits)}} | |||
{{KV|disableshadows|intn=0|boolean|If non 0 adds [[EF_NOSHADOW]] flag to m_fEffects}} | |||
{{KV|mins / maxs|intn=0|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}} | |||
{{KV|disablereceiveshadows|intn=0|boolean|If non 0 adds [[EF_NORECEIVESHADOW]] flag to m_fEffects}} | |||
{{KV|nodamageforces|intn=0|boolean|If non 0 adds [[EFL_NO_DAMAGE_FORCES]] flag to m_iEFlags}} | |||
{{KV|angle|intn=0|float|Supposed to be single value seting yaw but due to mistake in code causes infinite recursion and crashes the game}} | |||
{{KV|angles|intn=0|angle|Sets angles (has parenting related checks{{elaborate}}) }} | |||
{{KV|origin|intn=0|vector|Sets origin (has parenting related checks{{elaborate}})}} | |||
{{KV|targetname|intn=0|string|Sets m_iName (calls AllocPooledString to put/get it in/from game string table)}} | |||
{{KV|<anything else>|intn=0|any|Tries finding the key among keyfields and set appropriate field}} | |||
=== Outputs === | |||
{{O|OnUser1 / OnUser4|Fired as response to FireUser1 / FireUser4 }} <!-- m_OnUser1 - m_OnUser4 --> | |||
{{O|OnKilled|Fired when }} | |||
=== DEFINE_PHYSPTR === | |||
{{DEFINE_FIELD|m_pPhysicsObject|FIELD?}} | |||
=== DEFINE_UTLVECTOR === | |||
{{DEFINE_FIELD|m_ResponseContexts|FIELD?}} | |||
=== DEFINE_CUSTOM_FIELD === | |||
{{DEFINE_FIELD|m_aThinkFunctions|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 | |||
* {{tf2}}{{l4d2|since}} - [https://github.com/ReactiveDrop/reactivedrop_public_src/blob/0b3a6dcd74dce45e35ca6c0d823fd19ccc610b91/src/game/server/baseentity.cpp#L7421 ScriptThink] - handles vscript thinkfunction | |||
* {{l4ds}}{{asw}} - FrictionRevertThink | |||
== Programming related == | == Programming related == | ||
To get the class name of an entity, use | To get the class name of an entity, use | ||
Line 75: | Line 319: | ||
* [[CBaseAnimating]] | * [[CBaseAnimating]] | ||
* [[Template:KV BaseEntity/doc/Uncovered Keyvalues]] | * [[Template:KV BaseEntity/doc/Uncovered Keyvalues]] | ||
{{See also netprops}} | |||
[[Category:Programming]] | [[Category:Programming]] |
Revision as of 17:47, 26 September 2024

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

Fields
m_iName <FIELD_STRING>
- Name other entities use to refer to this entity
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>
m_pfnThink <FIELD_FUNCTION>
m_pfnTouch <FIELD_FUNCTION>
m_pfnUse <FIELD_FUNCTION>
m_pfnBlocked <FIELD_FUNCTION>
m_pfnMoveDone <FIELD_FUNCTION>
<span id="m_bForcePurgeFixedupStrings (in )">m_bForcePurgeFixedupStrings (in
) <FIELD_BOOLEAN>
<span id="m_flCreateTime (in )">m_flCreateTime (in
) <FIELD? 4Bytes>
<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>
Only
Team Fortress 2
m_nModelIndexOverrides[4] <FIELD_INTEGER>
Keyfield since
Alien Swarm and in
Team Fortress 2
m_iTeamNum <FIELD_INTEGER> (teamnumber)
m_CollisionGroup <FIELD_INTEGER> (CollisionGroup)
m_MoveType <FIELD_CHARACTER> (MoveType)
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)
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
EnableDrawInFastReflection <FIELD_VOID> linked function: InputEnableDrawInFastReflection
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
DEFINE_PHYSPTR
m_pPhysicsObject <FIELD?>
DEFINE_UTLVECTOR
m_ResponseContexts <FIELD?>
DEFINE_CUSTOM_FIELD
m_aThinkFunctions <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.