CBaseEntity

From Source Entities
(Redirected from +use)
Jump to navigation Jump to search

CBaseEntity is the code class that every entity in the engine inherits from. That means every entity can do these things listed. See Non-FGD features, cause many of these won't show in default FGDs depending on the entity.

Keyvalues[edit | edit source]

Classname
Classname (classname) <string>
The type of entity this is, like func_door or logic_auto.
The AddOutput input can be used to change this instantly. Most of the time, objects aren't detected through the classname; looking at the code class is easier. Changing the classname can also lead to odd behavior across game saves and round changes.
Targetname
Name (targetname) <target_source>
The name that other entities refer to this entity by. Generally you should avoid naming an entity the same thing as any classname to avoid issues with code that tries searching by targetname and classname. See also: IO events.
Parentname
Parent (parentname) <target_destination>
Specifies a movement parent. An entity with a parent will be forced to maintain its current position relative to the specified entity. Child entities will intersect with other solid objects if they must. Child entities will be forced to transition to the next map if the parent touches a trigger_transition.
An attachment point for this entity to follow can be specified by putting its name after the parent entity's name, separated by a comma. View attachment points ingame with ent_attachments.
Entities which aren't intended to be parented may not function correctly. phys_constraint can be used as an alternative to parenting.
Parented entities will forward Use inputs to their parent unless that entity has its own Use() function which does not call BaseClass::Use() or CBaseEntity::Use().
Global Entity Name (globalname) <string>
Name by which this entity is linked to another entity in a different map. When the player transitions to a new map (or when a new round begins), entities in the new map with globalnames matching entities in the previous will copy the previous entity's state. To do: Describe what this is useful for.
Origin (X Y Z) (origin) <origin>
The point in the world that acts as a sort of center of the entity. Rotating entities typically rotate around their origin. Changing the origin with AddOutput usually results in the entity moving.
Pitch Yaw Roll
Pitch Yaw Roll (Y Z X) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the object's Y axis (looking up or down), yaw is rotation around the object's Z axis (looking left and right), roll is rotation around the object's X axis (similar to a person doing cartwheels).
Note: This keyvalue works on brush entities, although Hammer won't update to show the new angles.
Flags (spawnflags) <flags>
Values under the Flags tab. Toggles features of an entity, its specific number is determined by the combination of flags added. Spawnflags are determined per-entity, none exist in CBaseEntity.
To add flags that aren't in the FGD, turn off SmartEdit and add the associated number into the spawnflags keyvalue. If there are other numbers already there, add to it as a sum.
Effects (Not in FGD) (effects) <int>
Combination of effect flags to use. Works similar to spawnflags.
Hammer ID (Not in FGD) (hammerid) <int>
An ID automatically assigned to this entity by Hammer. Mainly used by debugging commands, such as ent_keyvalue. Hammer calls this keyvalue id though the engine likes to call it hammerid. Entities spawned at run-time are not assigned any Hammer ID.
Render Mode (rendermode) <choices>
A special rendering mode to use on this entity.
Render Amount/Transparency (renderamt) <integer>
Transparency amount, requires a Render Mode (rendermode) other than Normal. 0 is invisible, 255 is fully visible.
Render Color (R G B) (rendercolor) <color255>
Color channel filter to add to this entity's texture(s). Bug: P2.pngCsgo-small.pngBroken for brush entities.
Render FX (renderfx) <choices>
Preset appearance effects. Partially supported in Asw.png, completely non-functional in P2.pngCsgo-small.png. Bug: Sometimes functions incorrectly if changed with AddOutput, but is the only way to change effects other than making multiple versions of the object.
Response Contexts (ResponseContext) <string>
Pre-defined response system contexts for this entity. Mainly for NPC speech, but all entities can use it as a sort of tagging system with filter_activator_context. Format is key:value,key:value,....
Minimum Light (_minlight) <float>
Minimum amount of light to hit this brush. 0 is none, 1 is "fullbright". Useful because the lightmaps will not update as the entity moves.
Shadows (Not in FGD) (vrad_brush_cast_shadows) <choices>
Determines if this entity will cast lightmap shadows. For brush entities only.
  • 0: No shadows
  • 1: Cast shadows
Local Time (Not in FGD) (ltime) <float>
A sort of local time of the entity, independent of the global clock. Used mainly for physics calculations.
To do: What possible uses could this have if changed? Changing this appears to have no effect...
Next Think (Not in FGD) (nextthink) <float>
Amount of time before the entity thinks again. Set to -1 to disable all thinking. Seems like this keyvalue doesn't affect all think functions. Most effective with NPCs and weapons.
Model Index (Not in FGD) (modelindex) <integer>
A number linked to a certain studio model, brush model or material. Use with the listmodels console command. Changing this with the AddOutput input is a doable but not perfectly reliable method of changing models because collision meshes don't update properly, and the object has to finish its current animation or be woken up before the change is visible. The model will also revert back to its original if the player quicksaves and reloads the game.
Speed (speed) <float>
Used mainly on entities that always move a certain speed, like func_door.
Health (health) <integer>
How close to dying the entity is.
Maximum Health (max_health) <integer>
Health cannot exceed this amount.
Damage Filter Name (damagefilter) <filterclass>
When this entity receives damage, it will filter by this entity.
Collisions (solid) <choices>
Method of collision for this entity.
Target (target) <target_destination>
A targeted entity of some sort. Entities use this keyvalue for many different purposes (sometimes they don't use it at all though). In GoldSrc this keyvalue could be used to forward Use inputs to another entity but this seems to not be the same in Source.
Disable Shadows (disableshadows) <boolean>
Adds EF_NOSHADOW to this entity. (Does not cast an _rt_shadows shadow.) RT shadows are not present at all in Csgo-small.png. These shadows are never cast by brush entities.
Disable Receiving Shadows (disablereceiveshadows) <boolean>
Adds EF_NORECEIVESHADOW to this entity. (_rt_shadows shadows don't cast onto entity) Note: RT shadows never apply to model-based entities and do not apply to brush-based ones in L4d.png onward.
Shadow Cast Distance (shadowcastdist) <int>
Sets how far the entity casts _rt_shadows shadows. 0 means default distance from the shadow_control entity.
World Model (model) <string>
3D or 2D object/texture that represents this entity in the world.
For studio models, this is a path to a .mdl.
For brush models, this is automatically done, but the value is * followed by a number.
For sprite models, this is a path to a .spr or .vmt.
Changing this value with the AddOutput input works, but a quicksave and reload must be forced to see the change. The collision mesh won't update though. Changing between the 3 model types usually does not work.
Base Velocity (Not in FGD) (basevelocity) <vector>
Velocity that immediately applies to this entity. This can be set in Hammer and altered at any time with AddOutput. Only works for QPhysics objects, such as players and most NPCs.
Angular Velocity (Not in FGD) (avelocity) <vector>
Angular velocity (spinning) to start with on spawn.
Local Velocity (Not in FGD) (velocity) <vector>
Velocity generated by the entity, can cause strange behavior if changed.
Local Gravity (Not in FGD) (gravity) <float>
A multiplier for gravity that applies to this entity only. Only works for QPhysics objects, such as players and most NPCs. Bug: Cannot be set to 0.0.
Friction (Not in FGD) (friction) <float>
Friction for this entity. No effect has ever been observed.
Water Level (Not in FGD) (waterlevel) <integer>
How submerged this entity is in water. Most entities will not react to this in any way.
Texture Frame (Not in FGD) (texframeindex) <int>
The frame number for any animated textures on this entity.
View Offset (Not in FGD) (view_ofs) <vector>
Some sort of camera position offset. This has only been seen to affect players.
Start Fade Distance (fademindist) <float>
Distance at which the entity starts fading. If less than 0, the entity will disappear instantly when the End Fade Distance is hit. The value will scale appropriately if the entity is in a 3D Skybox.
End Fade Distance (fademaxdist) <float>
Distance at which the entity ends fading. If less than 0, the entity won't disappear at all. The value will scale appropriately if the entity is in a 3D Skybox.
Fade Scale (fadescale) <float>
If specified in the worldspawn, or if the game 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 Bounding Box Size (Not in FGD) (mins) <vector>
Co-ordinates defining the minimum extents (-X -Y -Z) of a brush entity. The bounding box is drawn from this corner to the maximum. Requires Collisions be set to Bounding Box to be used. Can be used to overwrite the collision shape of a brush, although it can only be a cuboid.
Maximum Bounding Box Size (Not in FGD) (maxs) <vector>
Co-ordinates defining the maximum extents (+X +Y +Z) of a brush entity. The bounding box is drawn from this corner to the minimum. Requires Collisions be set to Bounding Box to be used. Can be used to overwrite the collision shape of a brush, although it can only be a cuboid.
Initial Team (TeamNum) <int>
The team that this entity is "on".
Note: If the team of this entity is changed at run-time, this number will not be updated to reflect the change.
ValueDods.pngTf2.pngCss.pngCsgo-small.pngP2.png
-1--Don't careDon't care
0-Any--
1---Team 1[Clarify]
2AlliesRedTerroristTeam 2 (P-Body)
3AxisBlueCounter-TerroristTeam 3 (Atlas)
Minimum DX Level (mindxlevel) to Maximum DX Level (maxdxlevel) <choices> (only available in games before Left 4 Dead)
Very outdated settings. Their functionality seems to no longer be fully intact. Nearly all players will be at the highest setting anyway because DirectX 8 has been obsolete since 2002. This is still in the FGD for Alien Swarm, but it doesn't use it.
Minimum CPU Level (mincpulevel) to Maximum CPU Level (maxcpulevel) <choices> (available in all games since L4d.png)
A user with the "effect detail" setting not in this specific range will not see this object.
  • 0: Default
  • 1: Low
  • 2: Medium
  • 3: High
Minimum GPU Level (mingpulevel) to Maximum GPU Level (maxgpulevel) <choices> (available in all games since L4d.png)
A user with the "shader detail" setting not in this specific range will not see this object. Settings are named differently in different games.
  • 0: Default
  • 1: Very low or Low
  • 2: Low or Medium
  • 3: Medium or High
  • 4: High or Very High
Disable for Xbox 360 (Not in FGD) (disableX360) <bool> (available in all games since L4d2-small.png)
If Yes, disables this entity on the Xbox 360 version of Source.
Entity Scripts (vscripts) <scriptlist> (available in all games since L4d2-small.png)
VScript files the entity should execute after the world has completely loaded and all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Script think function (thinkfunction) <string> (available in all games since L4d2-small.png)
Name of a function in this entity's scripts which will be called automatically ten times a second for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.
Note: Expensive operations in this function can cause performance problems.
Lag Compensation (Not in FGD) (LagCompensate) <boolean> (available in all games since L4d2-small.png)
Make the entity be lag compensated. Should be used very sparingly!
To do: Confirm this actually works.
Team (Not in FGD) (teamnumber) <int> (available in all games since Asw.png)
The team that this entity is "on". These values are different from game to game.
Move Type (Not in FGD) (MoveType) <choices> (available in all games since Asw.png)
Sets a movetype for this entity, which changes its movement behavior.
  • 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
To do: Add a little more info on each type.
Collision Group (CollisionGroup) <choices> (available in all games since Asw.png)
Sets a collision group for this entity, which changes its collision behavior.
  • 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, ignores the player
  • 18: NPC Scripted, NPCs do not collide with each other
Render in Fast Reflections (drawinfastreflection) <boolean> (available in all games since P2.png)
Makes the entity be rendered in reflections from water materials using $reflectonlymarkedentities.
Disable Flashlight (disableflashlight) <boolean> (available in all games since P2.png)
Adds EF_NOFLASHLIGHT to this entity.
Projected Texture Cache (shadowdepthnocache) <choices> (available in all games since P2.png)
Tells projected textures if this object's shadow needs to be updated every frame, or if it's static and the data for it can be cached (thereby saving some resources).
Disable ShadowDepth (disableshadowdepth) <boolean> (available in all games since P2.png)
Supposed to stop this entity from casting a shadow from env_projectedtexture and env_cascade_light, but doesn't. In order to disable these shadows, you need to manually add 2048 to the effects keyvalue with AddOutput.
Is Automatic-Aim Target (Not in FGD) (is_autoaim_target) <bool> (available in all games since Csgo-small.png)
When the entity is under the crosshair for consoles and joystick controllers, make aiming movement slower.
Pending Team (Not in FGD) (pendingteamnumber) <int> (available in all games since Csgo-small.png)
To do: Use uncertain.

Inputs[edit | edit source]

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. To do: Cases where this is needed?
SetParent <target_destination>
Sets Parent.
SetParentAttachment <string>
Teleports this entity to a specific attachment point on its Parent and moves identically to that attachment point.
SetParentAttachmentMaintainOffset <string>
As above, but the entity is not teleported and instead keeps its current position and angles, until the attachment moves.
ClearParent
Sets the Parent keyvalue to be blank, removing this entity from any hierarchy.
AddOutput
AddOutput <string>
Changes a keyvalue or adds an I/O connection on this entity. Not all keyvalues will work with this input as they require special handling.
Keyvalue format: <key> <value>
IO format: <output name> <targetname>:<input name>:<parameter>:<delay>:<fire once>
The parameter can be left blank, but do not omit either : surrounding it or the game will think the delay is the parameter! fire once is whether the IO event can be fired again. Put 0 to allow infinite refires, put 1 to make it only fire once ever.
Alpha <integer>
Sets Render Amount/Transparency (renderamt).
Color <color255>
Sets the Render Color (rendercolor).
SetDamageFilter <target_destination>
Sets Damage Filter Name.
AlternativeSorting <bool>
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.
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.
EnableShadow
Removes EF_NOSHADOW from the entity.
DisableShadow
Adds EF_NOSHADOW from the entity.
DispatchResponse (Not in FGD) <string>
Dispatches a response to the entity. See Response and Concept.
DispatchEffect (Not in FGD) <string> (only available in Hl2.pngCss.pngDods.pngP1.pngTf2.png)
Dispatches a special effect from the entity's origin.
AddContext <string>
Adds to the entity's list of Response Contexts. Format is <key>:<value>.
RemoveContext <string>
Remove a context from this entity's list. The name should match the key of an existing context.
ClearContext
Removes all contexts from this entity's list.
SetTeam <int>
Sets this entity's team that it is a part of.
Use
Use (Not in FGD)
"Uses" the entity in some way. Typically a player sends this input when they press E. Some entities may react differently depending on the "type" of use, determined by the origin of the input. This input can also be sent by not specifying any input at all.
FireUser1 to FireUser4 <string>
Fires the corresponding OnUser output. Bug: These inputs can pass a string parameter, but do nothing with it. If the input is sent from an output that automatically passes a non-string parameter (such as OnLessThan from logic_compare) the input will fail to send because the parameters types are incompatible.
Fix: Place any placeholder text in the parameter box, most easily accomplished by editing the FGD to change the input type from void to string.
RunScriptFile <script> (available in all games since L4d2-small.png)
Executes a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (available in all games since L4d2-small.png)
Executes a VScript function in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Warning: Never try to pass string parameters to a script function with this input. It will minorly corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
Note: In L4d2-small.png, the code is executed in the script scope of the entity that fires the output, not the one receiving the input. Use the CallScriptFunction input to execute in the receiving scope.
CallScriptFunction (Not in FGD) <string> (available in all games since L4d2-small.png)
Executes a VScript function in the scope of the entity receiving the input. Only useful in Left 4 Dead 2 because all other games do this automatically.
EnableDraw  (available in all games since P2.png)
Removes EF_NODRAW from the entity.
DisableDraw  (available in all games since P2.png)
Applies EF_NODRAW to the entity. Note that this is different than Render Mode 10.
EnableReceivingFlashlight  (available in all games since P2.png)
Makes it so that the entity is lit by env_projectedtextures.
DisableReceivingFlashlight  (available in all games since P2.png)
Prevents the entity from being lit by env_projectedtextures. The shadow made by the projected texture will still cast.
EnableDrawInFastReflection  (available in all games since P2.png)
Sets Render in Fast Reflections to true.
DisableDrawInFastReflection  (available in all games since P2.png)
Sets Render in Fast Reflections to false.
SetLocalOrigin (Not in FGD) <origin> (available in all games since P2.png)
Sends this entity to a spot in the map if not parented to anything. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles (Not in FGD) <angle> (available in all games since P2.png)
Sets Pitch Yaw Roll.
RemovePaint  (only available in P2.png)
Removes gel. Only works for brush entities.
Bug: Using this on worldspawn can crash the game.

Outputs[edit | edit source]

OnUser1 to OnUser4
These outputs each fire in response to the firing of the similarly-numbered FireUser inputs.
OnKilled  (only available in L4d.png)
Fires when the entity is Killed and removed from the game.

Notable Member Functions[edit | edit source]

To do: List functions such as Spawn and OnRestore!