func_train
func_train is a brush entity available in all
Source games.
Entity Description
It is a leftover from Quake that ping-pongs between the start and end of a series of path_corners. It was mostly replaced by func_tracktrain in
GoldSrc, but was still used for looping auto-scrolling backgrounds. In Source, the introduction of parenting has rendered this method obsolete. However, the entity is still functional.
func_tracktrain is, making it a good alternative for fast-moving objects.Default.Null with a volume of 0 to play no sound.KeyValues
- Spawn path_corner
(target)<targetname> - The name of the first path_corner in the train's path. The train will spawn at this path_corner.
- Speed
(speed)<float> - Speed at which the train moves.
- Movement Sound
(noise1)<string> - The sound to play when the train moves.
- Stop Sound
(noise2)<string> - The sound to play when the train stops moving.
- Sound Volume (0-10)
(volume)<float> - Volume of the sounds emitted when moving and stopping.
- Crush Damage
(dmg)<float> - Amount of damage to deal to entities blocking the train.
Base:
- Collisions
(solid)<choices> - Method of collision for this entity.
- 0: None
- 1: BSP (QPhysics) !FGD
Bug:In
, if an entity using QPhysics collisions is hit by Gel, the game will crash! - 2: Bounding Box
- 3: Oriented Bounding Box (Use for runtime spawned brush entities meant to be rotated) !FGD
- 4: Oriented Bounding Box but constrained to Yaw only !FGD
- 5: Custom/Test (Usually no collision with anything) !FGD
- 6: VPhysics
- Parent
(parentname)<targetname> - Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (
parentname [targetname],[attachment])
Tip:Entities transition to the next map with their parents
Tip:phys_constraintcan be used as a workaround if parenting fails.
- Origin (X Y Z)
(origin)<coordinates> - The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Note:Hammer does not move the entities accordingly only in the editor.
- Pitch Yaw Roll (X Y Z)
(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.
- Classname
(classname)<string> !FGD - Determines the characteristics of the entity before it spawns.
Note:Changing this on runtime still has use, like making matching an entry in S_PreserveEnts will persist the entity on new rounds!
- Flags
(spawnflags)<integer> !FGD - Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
- Effects
(effects)<integer> !FGD - Combination of effect flags to use.
- Entity Scripts
(vscripts)<scriptlist> (in all games since
) (also in
) - 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> (in all games since
) (also in
) - 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.
- Lag Compensation
(LagCompensate)<boolean> (in all games since
) !FGD - Set to Yes to lag compensate this entity. Should be used very sparingly!
- Is Automatic-Aim Target
(is_autoaim_target)<boolean> (in all games since
) !FGD - If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.
RenderFields:
- Render Mode
(rendermode)<choices> - Set a non-standard rendering mode on this entity.
- 0: Normal
- 1: Color
- 2: Texture
- 3: Glow
- 4: Solid/Alphatest
- 5: Additive
- 6: Removed, does nothing
- 7: Additive Fractional Frame
- 8: Alpha Add
- 9: World Space Glow
- 10: Don't Render
- Render FX / Transparency (0 - 255)
(renderamt)<integer> - Transparency amount, requires a Render Mode other than Normal. 0 is invisible, 255 is fully visible.
- Render Color (R G B)
(rendercolor)<color255> - Color tint.
- Disable Receiving Shadows
(disablereceiveshadows)<boolean> - Prevent the entity from receiving shadows on itself.
- Render FX
(renderfx)<choices> - Various somewhat legacy alpha effects.
- 0: None
- 1: Slow Pulse (varies alpha by ±16 over a period of 1.5 s)
- 2: Fast Pulse (varies alpha by ±16 over a period of 0.4 s)
- 3: Slow Wide Pulse (varies alpha by ±64 over a period of 1.5 s)
- 4: Fast Wide Pulse (varies alpha by ±64 over a period of 0.4 s)
- 5: Slow Fade Away (decreases alpha by -1 per frame/(in all games since
) Fades out over 4 s) - 6: Fast Fade Away (decreases alpha by -4 per frame/(in all games since
) Fades out over 1 s) - 7: Slow Become Solid (increases alpha by +1 per frame/(in all games since
) Fades in over 4 s) - 8: Fast Become Solid (increases alpha by +4 per frame/(in all games since
) Fades in over 1 s) - 9: Slow Strobe (transparent 0.8 s, visible 0.8 s, repeat)
- 10: Fast Strobe (transparent 0.2 s, visible 0.2 s, repeat)
- 11: Faster Strobe (transparent 0.09 s, visible 0.09 s, repeat)
- 12: Slow Flicker (transparent 0.18 s, visible 1.5 s, repeat)
- 13: Fast Flicker (transparent 0.14 s, visible 0.2 s, repeat)
- 14: Constant Glow ("NoDissipation;" purpose uncertain—for sprites?) (not in
) - 15: Distort (causes unnatural flickering and position shifting)/(in all games since
) Fade Out (instant; not very useful outside of code) - 16: Hologram (Distort + "distance fade")/(in all games since
) Fade In (instant; not very useful outside of code) - 17: Scale Up ("Explode"/"scale up really big!" causes wild stretching of model parts) (in
)/Fade Wider Pulse (varies alpha by ±255 over a period over a period of 0.26 s) (in all games since
)
Confirm:which branches/games is it available in, and where does it do what? - 18: Glow Shell (purpose unclear) (in all games since
) (not in
)
Confirm:what does this do? and which games is it in? - 19: Clamp Minimum Scale ("keep this sprite from getting very small (SPRITES only!)") (not in
) - 20: Environmental Rain ("for environmental rendermode, make rain") (in
) (not in
)
Confirm:which games? may be nonfunctional. - 21: Environmental Snow ("for environmental rendermode, make snow") (in
) (not in
)
Confirm:which games? may be nonfunctional. - 22: Spotlight FX ("TEST CODE for experimental spotlight") (in
) (not in
) - 23: Ragdoll ("HACKHACK: TEST CODE for signalling death of a ragdoll character;" ragdolls an entity but doesn't kill it) (in
) (not in
)
Confirm:which games? may be nonfunctional? - 24: Fade Wider Pulse (varies alpha by ±255 over a period over a period of 0.26 s) (in
) (not in
) - 25:
kRenderFXMax/Fade Near (removed since
) (not in
)
Todo: what does this do? may be nonfunctional
Flags
- [
8] : Non-solid
Inputs
Base:
AddContext<string>- Adds to the entity's list of response contexts. See Context.
AddOutput<string>- 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:
// 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 the movement hierarchy, leaving it free to move independently.
FireUser1toFireUser4- Fires the respective
OnUseroutputs; 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 thanKillinput.
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.
DispatchResponse<string> !FGD- Dispatches a response to the entity. See Response and Concept.
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.
Bug:In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.
Fix:Remove the string argument manually with a text editor.
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 receving 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.
RenderFields:
Alpha<integer 0–255>- Sets the entity's transparency to a number from 0 (invisible) to 255 (fully visible). Requires the entity to have its
rendermodeset to a number other than0.
Color<color255>- Sets an RGB color for the entity.
Toggle- Toggle movement
Start- Start movement
Stop- Stop movement
Outputs
Base:
OnUser1toOnUser4- These outputs each fire in response to the firing of the like-numbered
FireUser1toFireUser4Input; see User Inputs and Outputs. OnKilled(only in
)- This output fires when the entity is killed and removed from the game.
FGD Code
@SolidClass base(Targetname, Origin, RenderFields) line(255 255 0, targetname, target) = func_train: "An old entity leftover from Quake. It follows a series of path_corner entities." [ spawnflags(flags) = [ 8 : "Non-solid" : 0 ] target(target_destination) : "Spawn path_corner" : : "The name of the first path_corner in the train's path. The train will spawn at this path_corner." speed(float) : "Speed" : "50" : "Speed at which the train moves." noise1(sound) : "Movement Sound" : "Default.Null" : "The sound to play when the train moves. This must be specified, but can be set to 'Default.Null' to play no sound." noise2(sound) : "Stop Sound" : "Default.Null" : "The sound to play when the train stops moving. This must be specified, but can be set to 'Default.Null' to play no sound." volume(float) : "Sound volume (0-10)" : "10" : "Volume of the sounds emitted when moving and stopping." dmg(float) : "Crush Damage" : "0" : "Amount of damage to deal to entities blocking the train." // Inputs input Toggle(void) : "Toggle movement" input Start(void) : "Start movement" input Stop(void) : "Stop movement" ]