CBaseEntity

The base class for all entities.
== Keyvalue handling ==
Each entity is stored in map file as bunch keyvalues. When an entity is being spawned all its keyvalues are handled using CBaseEntity::KeyValue method (subclasses can override this method and add new special keys). Each key and its value is passed to this function and are processed as follows:
:
=== Keyfields ===
== Inputs ==
Inputs are defined in datadesc either as DEFINE_INPUT or DEFINE_INPUTFUNC. They are handled by CBaseEntity::AcceptInput method which is usually called from the event queue.
=== Input keys ===
Inputs keys are defined using DEFINE_INPUT and can be used as both inputs and keyvalues alike. When an input that needs to just change some single property is needed, this is a quick way to define it. (handled here when used as input). The command does not auto-complete these when writing in console.
=== Input functions ===
Regular inputs are defined using DEFINE_INPUTFUNC and are linked to some function. 
:Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
==== Only in ====
==== Since and also in ====
== Outputs ==
All outputs are derived from CBaseEntityOutput. Each output is internally an object that contains a list of actions which will all be fired when given output is fired. Output being fired means that the output's FireOutput method was called. The method is called from individual entities' code at appropriate times. Some outputs also store a value and each time this values is changed the output is also fired. (e.g. OutValue of which is COutputFloat)
Adding an action to the output is done via keyvalues i.e. CBaseEntity::KeyValue method needs to be called with key being the associated output name and the value being the action that has the following format (parsed here)
 <target>,<input name>,<paramater override>,<delay>,<refire count>
* target - see targetname. !caller, !self, !activator targets depend on how the output is fired in the given entity's code
* input name - input fired to the target (if unspecified then "Use" input is chosen)
* paramater override - called override because outputs that have a value will automatically set this if left empty
* delay - delay of the given action
* refire count - how many times can this output fire, 0 or -1 means infinite
Vscript also provides direct way to add/remove actions to an output using `CScriptEntityOutputs`.
* Left 4 Dead 2/Scripting/Script Functions#CScriptEntityOutputs
* Team Fortress 2/Scripting/Script Functions#CScriptEntityOutputs
* Alien Swarm: Reactive Drop/Scripting/Script Functions#CScriptEntityOutputs (also supports GetValue while others don't)
* COutputEvent is a type of output that has no value
== Other fields ==
=== Keyless fields ===
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
 		
=== Array fields ===
 		
=== Tables ===
==== m_Collision (CCollisionProperty) ==== 
 		
 		
 		
 		
 		
 		
 		
 		
 		
 	
 		
===== Removed since =====
 		
 		
 		
 		
==== m_Network (CServerNetworkProperty) ====
==== m_Glow (CGlowProperty) ====
=== IPhysicsObject pointer === 
=== CUtlVector type ===
=== DEFINE_CUSTOM_FIELD ===
=== Function fields ===
=== Functions ===
* SUB_Remove - // Convenient way to delay removing oneself
* SUB_DoNothing - // Convenient way to explicitly do nothing (passed to functions that require a method)
* SUB_StartFadeOut - // fade out - slowly fades a entity out, then removes it. 
* SUB_StartFadeOutInstant 
* SUB_FadeOut - // Purpose: Fade out slowly
* SUB_Vanish - // Purpose: Vanish when players aren't looking
* SUB_CallUseToggle
==== Think functions ====
===== ScriptThink =====
Handles vscript thinkfunction.
It works by trying to call a vscript function named in the current entity's script scope. If no function of that name exists ScriptThink ends. If such function is found, it's executed and its return value will be used as a delay for the next time ScriptThink should be called. If no return value was given (either the function ended in error or it was just not provided) then sv_script_think_interval cvar is used as the delay (default value 0.1).
ScriptThink is in code used as context think and it's activated by the presence of thinkfunction keyvalue with non-empty string (vscripts ↑ keyvalue also must be non-empty) when the entity is being spawned or by using vscript function AddThinkToEnt.
===== ShadowCastDistThink =====
===== FrictionRevertThink ===== 
== Server class (DT_BaseEntity) ==
Variables optimized for network traffic are called SendProps . See individual netprop dumps for details on send bits and flags.
Only SendProps that are not part of datadesc table (i.e. described higher) are to be described in this section.
 
 
 
 
 
 
 
 
 
* 
* 
* 
* 
* 
* 
* 
* 
* [4] 
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
=== predictable_id (DT_PredictableId) ===
		
		
 
=== m_Glow (DT_GlowProperty) - ===
 
 
 
 
* 		
=== AnimTimeMustBeFirst	(DT_AnimTimeMustBeFirst) ===
* 		
=== m_Collision	(DT_CollisionProperty) ===
* 		
* 		
* 		
* 		
* 		
* 		
* 		
* 		
 
* 		
* 
* 
* 
* 
== Entity debugging ==
Changing m_debugOverlays shows various debug overlays when mode is active.
=== ent_text ===
* GetDebugName() - for entities returns if not empty otherwise 
* entindex() - returns entity index (the index is 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 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 we have vphysics object () associated with us and it's also asleep the color will be darker green. Drawn by 
CBaseEntity::DrawAbsBoxOverlay
=== ent_pivot ===
If we are an edict draws pivot 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 ==
* List of datamap and netprop dumps
* CBaseAnimating
* Template:KV BaseEntity/doc/Uncovered Keyvalues
Category:Programming