Difference between revisions of "Prop ragdoll"

From Valve Developer Community
Jump to: navigation, search
(Added GMOD keyvalues)
(Added information on entity ragdolling and how they become prop_ragdolls)
Line 4: Line 4:
  
 
{{base_point|prop_ragdoll}} It is a [[VPhysics]] [[Wikipedia:Ragdoll physics|ragdoll]]. Ragdolls are collections of physics objects constrained together to simulate a jointed object like a dead body. They are very [[expensive]] to simulate.
 
{{base_point|prop_ragdoll}} It is a [[VPhysics]] [[Wikipedia:Ragdoll physics|ragdoll]]. Ragdolls are collections of physics objects constrained together to simulate a jointed object like a dead body. They are very [[expensive]] to simulate.
 +
 +
{{warning|This entity generates server-side ragdolls, which collide with everything but produce very large amounts of network traffic. Use in single-player only!}}
  
 
{{bug|In [[Portal 2]], ragdolls cannot pass through portals.}}
 
{{bug|In [[Portal 2]], ragdolls cannot pass through portals.}}
{{todo|Check to see if it works in the original [[Portal]].}}
+
:: {{todo|Check to see if it works in the original [[Portal]].}}
{{warning|This entity generates server-side ragdolls, which collide with everything but produce very large amounts of network traffic. Use in single-player only!}}
+
 
 +
{{altnames|name1=physics_prop_ragdoll}}
 +
 
 +
{{code class|CRagdollProp|physics_prop_ragdoll.cpp}}
  
 
See also [[Prop Types Overview]].
 
See also [[Prop Types Overview]].
 +
 +
==Death ragdolls/ragdoll transformation==
 +
 +
When a NPC/player dies or an entity receives the <code>BecomeRagdoll</code> input, it normally creates a '''client-side''' ragdoll and copies most of its animation and visual data to it. Unlike server-side prop_ragdolls, these client-side ragdolls are handled completely on a per-client basis and are ''much'' cheaper and simpler than their server-side counterparts, at the expense of being virtually nonexistent on the server, being inconsistent across client perspectives, and only colliding with entities that have physics objects on the client (e.g. {{ent|worldspawn}}).
 +
 +
However, a NPC will become a server-side ragdoll while it's under any of the following conditions:
 +
* The NPC is inside the volume of a [[trigger_serverragdoll]]
 +
* The NPC is killed by a vehicle in singleplayer
 +
* The [[weapon_physcannon|gravity gun]] is supercharged
 +
* The NPC dies on fire while in [[env_global|Alyx darkness mode]]
 +
* The NPC is a vital ally (e.g. {{ent|npc_alyx}})
 +
These server-side death ragdolls will collide with physics objects and beyond, like any prop_ragdoll, but they are marked as debris and do not collide with each other. They do not collide with ''themselves'' either, unlike client-side ragdolls. This is believed to be intentional behavior to reduce performance/networking costs.
 +
{{note|Most of this list ''theoretically'' applies to players as well, although that hasn't been tested.}}
 +
 +
{{warning|While most of the relevant animation/visual data is copied to ragdolls, some fields, like fade distances, are not transferred.}}
 +
: {{code|This can be modified at <code>CBaseAnimating::CopyAnimationDataFrom()</code> in <code>baseanimating.cpp</code> for server-side ragdolls and <code>C_BaseAnimating::CreateRagdollCopy()</code> in <code>c_baseanimating.cpp</code> for client-side ragdolls.}}
  
 
==Keyvalues==
 
==Keyvalues==

Revision as of 18:18, 20 September 2019

For details on creating a ragdoll, see $collisionjoints.
prop_ragdoll can interact with dynamic objects, unlike death ragdolls.


prop_ragdoll is a point entity available in all Source games. It is a VPhysics ragdoll. Ragdolls are collections of physics objects constrained together to simulate a jointed object like a dead body. They are very expensive to simulate.

Warning: This entity generates server-side ragdolls, which collide with everything but produce very large amounts of network traffic. Use in single-player only!

Bug: In Portal 2, ragdolls cannot pass through portals.
To do: Check to see if it works in the original Portal.
This entity is also tied to physics_prop_ragdoll.

In code, it is represented by class CRagdollProp, defined in physics_prop_ragdoll.cpp.

See also Prop Types Overview.

Death ragdolls/ragdoll transformation

When a NPC/player dies or an entity receives the BecomeRagdoll input, it normally creates a client-side ragdoll and copies most of its animation and visual data to it. Unlike server-side prop_ragdolls, these client-side ragdolls are handled completely on a per-client basis and are much cheaper and simpler than their server-side counterparts, at the expense of being virtually nonexistent on the server, being inconsistent across client perspectives, and only colliding with entities that have physics objects on the client (e.g. worldspawn).

However, a NPC will become a server-side ragdoll while it's under any of the following conditions:

These server-side death ragdolls will collide with physics objects and beyond, like any prop_ragdoll, but they are marked as debris and do not collide with each other. They do not collide with themselves either, unlike client-side ragdolls. This is believed to be intentional behavior to reduce performance/networking costs.

Note:Most of this list theoretically applies to players as well, although that hasn't been tested.

Warning: While most of the relevant animation/visual data is copied to ragdolls, some fields, like fade distances, are not transferred.

Code:This can be modified at CBaseAnimating::CopyAnimationDataFrom() in baseanimating.cpp for server-side ragdolls and C_BaseAnimating::CreateRagdollCopy() in c_baseanimating.cpp for client-side ragdolls.

Keyvalues

sequence <integer> !FGD
The ragdoll will be moved to the first frame of this animation before VPhysics takes over.
Bug: Doesn't function.
body <integer> !FGD
Specifies which body group should be used.
Override Animation <string>
Filled in by the engine via wc_update_entity. Do not edit by hand except to clear.

DXLevelChoice:

Minimum DX Level (mindxlevel) <choices>
The entity will not exist if the engine is running outside the given range of DirectX Versions. Replaced by SystemLevelChoice from <Left 4 Dead> Left 4 Dead onwards.
Warning: If these are used, the object may break when the user switches their DirectX settings.
Maximum DX Level (maxdxlevel) <choices>

SystemLevelChoice:

Minimum CPU Level (mincpulevel) <choices> (New with Left 4 Dead)
A user with a CPU level lower than this will not see this object rendered in-game. CPU levels are determined by the Effect detail setting.
Maximum CPU Level (maxcpulevel) <choices> (New with Left 4 Dead)
  • 0: Default
  • 1: Low
  • 2: Medium
  • 3: High
Minimum GPU Level (mingpulevel) <choices> (New with Left 4 Dead)
A user with a GPU level lower than this will not see this object rendered in-game. GPU levels are determined by the Shader detail setting.
Maximum GPU Level (maxgpulevel) <choices> (New with Left 4 Dead)
  • 0: Default
  • 1: Very low
  • 2: Low
  • 3: Medium
  • 4: High

Studiomodel:

World Model (model) <string>
The model this entity should appear as. 128-character limit.
Skin (skin) <integer>
Some models have multiple skins. This value selects from the index, starting with 0.
Tip:Hammer's model browser automatically updates this value if you use it to view different skins.
Model Scale (modelscale) <float> (New with Team Fortress 2)
A multiplier for the size of the model.

Shadow:

Disable shadows (disableshadows) <boolean>
Prevent the entity from creating cheap render-to-texture shadows. Does not affect shadow mapping.
Disable ShadowDepth (disableshadowdepth) <boolean> (New with Portal 2)
Used to disable rendering into shadow depth (for projected textures) for this entity.
Projected Texture Cache (shadowdepthnocache) <choices> (New with Portal 2)
Used to hint projected texture system whether it is sufficient to cache shadow volume of this entity or to force render it every frame instead.
  • 0 : Default
  • 1 : No cache - render every frame
  • 2 : Cache it - render only once
Disable flashlight (disableflashlight) <boolean> (New with Portal 2)
Used to disable projected texture lighting and shadows on this entity.

Angles:

Pitch Yaw Roll (Y Z X) <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.

BaseFadeProp:

Start Fade Dist (fademindist) <float>
Distance at which the prop starts to fade.
End Fade Dist (fademaxdist) <float>
Max fade distance at which the prop is visible.
  • If start fade is <0, the prop will disappear instantly when end fade is hit.
  • If end fade is <0, the prop won't disappear at all. (This is the default behaviour.)
The values will scale appropriately if the prop is in a 3D Skybox.
Fade Scale (fadescale) <float>
If you specify so in worldspawn, or if the engine is running below DirectX 8 (DX7 in Ep1), props will fade out even if the fade distances above aren't specified. This value gives you some control over when this happens: numbers smaller than 1 cause the prop 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 the QC command $noforcedfade.

Targetname:

Name <string>
The targetname that other entities refer to this entity by.
Entity Scripts <scriptlist> (New with Left 4 Dead 2)
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.
Script think function <string> (New with Left 4 Dead 2)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (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:Try to avoid expensive operations in this function, as it may cause performance problems.

GMODSandbox:

Allow Physics Gun (gmod_allowphysgun) <boolean> (Only in Garry's Mod)
If set, players cannot use Physics Gun on this entity.
Sandbox Tool Whitelist (gmod_allowtools) <string> (Only in Garry's Mod)
If set, only given tools can be used on this entity. You need to supply the tool class names, the names of the .lua files of those tools. This also includes the context menu properties!

Flags

  • 4 : Debris - Don't collide with the player or other debris
  • 8192 : Allow Dissolve
  • 16384 : Motion Disabled
  • 32768 : Allow stretch
  • 65536 : Start asleep

Inputs

StartRagdollBoogie
Begins ragdoll boogie effect. Parameter override = number of seconds to boogie.
EnableMotion, DisableMotion
Enable/disable physics simulation.
FadeAndRemove  (New with Half-Life 2: Episode Two / Source 2007)
Fade out then remove (kill) self. Parameter override = duration of fade.
Ignite  !FGD
Set on fire.
SetBodyGroup  !FGD
Change the current body group.

RenderFields:

Alpha  <integer>
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.
Color  <color255>
Sets an RGB color for the entity.

Studiomodel:

Skin <int>
Changes the model's skin to the specified number.
SetBodyGroup <int>
Set the model's body group.
EnableShadow
DisableShadow
Control the model's cheap render-to-texture shadow.
AlternativeSorting <bool>
Uses an alternative method for telling which objects are in front of others. Use if this object draws incorrectly when seen through transparent things.
SetModelScale  <float> (New with Team Fortress 2)
Sets the model scaling factor

Targetname:

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 than Kill.
AddOutput  <string>
Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
Format: <key> <value>
Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.
This input is not included in Valve's FGDs.
RunScriptFile  <script> (New with Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode  <string> (New with Left 4 Dead 2)
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 <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction  <string> (New with Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin  <coordinates> (New with Alien Swarm) !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.
SetLocalAngles  <angles> (New with Alien Swarm) !FGD
Set this entity's angles.

Outputs

Targetname:

OnUser1 to OnUser4
These Outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (Only in the Left 4 Dead series)
This Output fires when the entity is killed and removed from the game.