Prop data: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
Line 116: Line 116:


== physgun_interactions ==
== physgun_interactions ==
In addition to enforcing prop consistency, the prop data system can be used to turn on several discrete physics interactions for a prop. These are done by embedding KeyValue sections in the prop data section. HL2 provides interactions with the [[weapon_physcannon|physcannon]], and interactions with fire. These interactions are set by placing the following snippet into your <code>$keyvalues</code> section, in the following format:
The physgun_interactions $keyvalues set affects how props are handled, etc by the [[weapon_physcannon|physcannon]]. Note that they are not part of the prop_data block : example QC syntax:


  $keyvalues
  [[$keyvalues]] {
{
    physgun_interactions {
physgun_interactions
      preferred_carryangles "0 0 0"
{
      onworldimpact "stick"
key "value"
      onfirstimpact "break"
...
      onfirstimpact "paintsplat"
}
    // onfirstimpact "impale"
    // onlaunch "spin_none"
      onlaunch "spin_zaxis"
      onbreak "explode_fire"
      damage "none"
    }
  }
  }


The keys & their appropriate values are as follows:
;preferred_carryangles <[[angles]]>
:Sets the angles, relative to the player's orientation, at which the prop will be held when carried.
* This is used, for example, with the sawblades and propellers in [[Ravenholm]], as well as the turret NPCs in [[Nova Prospekt]].


;preferred_carryangles
;onworldimpact <choices>
:Sets the angles, relative to the player's orientation, at which the prop will be held when carried. This is used with, for example, the sawblades and propellers in [[Ravenholm]], as well as the turret NPCs in [[Nova Prospekt]].
: Example:
physgun_interactions
{
preferred_carryangles "0 0 0"
}
;onworldimpact
: <choices>
:{|
:{|
! Literal Value || Description
! Literal Value || Description
|-
|-
| stick || This prop will embed itself into the [[world]] if it hits it after being launched by the physcannon.
| stick || Prop will embed itself into the world if it hits it after being launched.
|}
|}
;onfirstimpact
;onfirstimpact <choices>  
: <choices> The behavior of this prop when it's launched by the physcannon and collides with something for the first time. Should be one of the following:
:{|
:{|
! Literal Value || Description
! Literal Value || Description
|-
|-
| break || This prop should always break on colliding with anything after being launched.
| break || Prop should always break on colliding with anything after being launched.
|-
|-
| paintsplat || This prop should apply paint decals to the first thing it collides with after being launched.
| paintsplat || Prop applies paint decals to the first thing it hits after being launched.
|-
|-
| impale || This prop should impale whatever it first collides with after being launched. Not used in HL2, and hence unsupported at this time.
| impale || Prop impales whatever it first collides with after being launched. Not used in HL2, and hence unsupported at this time.
|}
|}
;onlaunch
;onlaunch <choices>  
: <choices> The behavior of this prop when it's launched by the physcannon. Should be one of the following:
:{|
:{|
! Literal Value || Description
! Literal Value || Description
|-
|-
| spin_none || This prop shouldn't spin when launched by the physcannon. By default, the physcannon applies random angular velocity to objects it launches. Use this to prevent that.
| spin_none || Prop does not spin when launched. By default, the physgun applies random angular velocity to objects it launches.
|-
|-
| spin_zaxis || This prop should spin around the Z axis when launched by the physcannon.
| spin_zaxis || Prop should spin around the Z axis when launched by the physcannon.
|}
|}
;onbreak
;onbreak <choices>
: <choices>
:{|
:{|
! Literal Value || Description
! Literal Value || Description
|-
|-
| explode_fire || This prop should ignite nearby enemies when it explodes on breaking.
| explode_fire || Prop ignites nearby enemies when it explodes on breaking.
|}
|}
;damage
;damage <choices>
: <choices>
:{|
:{|
! Literal Value || Description
! Literal Value || Description
|-
|-
| none || This prop shouldn't move in response to damage. It will still take damage if the other prop data entries specify so, but it won't move due to the damage impact.
| none || Prop does not move when 'attacked' with the physgun. It may still take damage, but it won't move due to the impact.
|}
|}



Revision as of 18:58, 31 March 2008

The purpose of the Prop Data system is to ensure that the interactive behavior of prop models stays consistent across all the levels in your game / mod. The three core prop entities (prop_static, prop_dynamic, and prop_physics) all use the prop data system to load game-related data from the model they're set to use. This article will explain the data stored inside the Prop Data section of models, and how you can edit it in your mod.

Core data file

The Prop Data system stores data in a hierarchy. The base prop data classes are laid out inside the mod\scripts\propdata.txt file. Wherever possible, models use one of these classes instead of defining their own class. This way, large tweaks can be applied to the entire set of prop models without having to rebuild any content (for instance, in response to Half-Life 2 playtests, Valve tweaked the overall amount of health for all wooden objects in the game several times).

The propdata.txt format is a KeyValue formatted data file, where each entry matches the following format:

<material_type>.<size_description> // Suggested format; you can actually call it anything you like (but avoid spaces)
{
	key	"value x or y" // If there is a space or tab character within a key or value, you need quote marks around it
	(...)
}

The keys and their appropriate values are as follows:

base
<string> Should be the name of another prop data class defined in the propdata.txt file. If specified, this prop data class will derive all of its data from the base class. Further keys in this class will override the base class keys.
blockLOS
<boolean> Used to override whether this prop should block NPC's Line-Of-Sight. If unspecified, the prop will decide whether it blocks NPC sight based on its size. Use this to enforce a desired sight blocking behavior.
AIWalkable
<boolean> Used to set whether AI should consider this prop as a floor candidate.
health
<integer> The amount of damage this prop should take before breaking. If left out, or set to "0", this prop will not take damage and never break.
damage_table
<string> Damage tables are defined in code (physics_impact_damage.cpp). The stock tables are player, player_vehicle, npc and glass. glass is used for extremely fragile objects that will break just by being dropped, while the others have more subtle qualities.
Tip.pngTip:To remove a damage table from a prop, input damage_table "" (two quote marks).
dmg.bullets
<float> Modifies damage done by bullets to this prop. By default, this is set to "1.0".
dmg.club
<float> Modifies damage done by clubs to this prop. By default, this is set to "1.0".
dmg.explosive
<float> Modified damage done by explosives to this prop. By default, this is set to "1.0".
Use damage modifiers to reflect differences between the amount of damage that an object takes from different damage types. Don't use them to reflect overall damage strength. i.e. Stone is resilient to everything. To reflect this, increase the health of all stone objects, don't set the damage modifiers lower.
explosive_damage
<float> The amount of explosive damage done by this prop when it breaks.
explosive_radius
<float> The radius of the explosion caused by this prop when it breaks.
If these two fields are specified for a prop, then the prop will create an explosion with the specified values when it breaks.
breakable_model
<string> The set of generic gibs this prop should break into. Only necessary if the prop doesn't have custom gibs. The string should be the name of an entry in the generic breakable section, which is also defined in the propdata.txt file. See the Breakables section below.
breakable_skin
<integer> The skin to use on the generic breakable models.
breakable_count
<integer> The number of generic breakable gibs to break into. Required for gibs to appear.
allowstatic
<boolean> An override to allow this prop to be static as well as physically simulated. In general, this should not be used.

In addition, the following keys are used for multiplayer props:

physicsmode
<choices> Sets the physics mode used by the prop. Should be set to one of the following:
Number Name Description
1 Solid, Server-side Solid, pushes the player away.
2 Non-Solid, Server-side Non-solid, but gets pushed away by the player.
3 Non-Solid, Client-side Non-solid, clientside simulated only.
multiplayer_break
<choices> Sets the method by which the multiplayer prop breaks. Should be set to one of the following:
Literal Value Description
both Creates gibs on both the server and the client.
server Only creates gibs on the server.
client Only creates gibs on the client. This is the default behavior.

Setting up a prop model

Once you've built your prop model, you need to setup the prop data that should be enforced. Prop data is embedded into the $keyvalues section of the model's .QC file. First, you need to decide how the prop should be simulated.

In HL2, Valve tried to follow these general rules:

  • If it's going to attach to, or act as a support for a non moving thing, it should be static.
  • If it generates light, it should be static.
  • If it's really big and the player can't possibly move it, it should be static.
  • Otherwise, it should be physically simulated.

If you want your prop to be static, then you're done. Any model without a prop data section in its $keyvalues section will be forced to be static. If a level designer places it as a prop_physics entity, it will be removed and a warning will be displayed.

If you want your prop to be physically simulated, then you need to add the $keyvalues section to the model's .QC file. If there is no existing $keyvalues section in the .QC, add the whole chunk. Otherwise just add the "prop_data" section at the end of the existing $keyvalues section. An example $keyvalues entry would be something like this:

$keyvalues
{
	prop_data
	{
		base			Wooden.Small
		dmg.bullets		0
		explosive_damage	100
		explosive_radius	100
	}
}

This example prop data entry tells the prop to derive all of its data from the base "Wooden.Small" entry in the propdata.txt file. It then overrides several variables, which make the prop immune to bullet damage and creates an explosion when it breaks. To find the base prop class to derive from for your prop, open up the mod/scripts/propdata.txt file and find the entry that best matches the prop you've built. Make sure you choose a "<material>.<size>" entry, not the "<material>.Base" entry that simply sets damage modifiers for the material type.

Tip.pngTip:You don't need to override anything at all if you don't want to. Just use base and you've got a working physics prop.

When building props, you can help your game / mod to be consistent by following these tips:

  • Don't override health levels in all your props. Instead, use the base prop classes and let them set the health. This way you won't have one chair that takes twice as much health as every other chair.
  • Whenever possible, avoid mixing material types inside the same prop. i.e. don't make half-metal, half-wood props.
  • Follow the HL2 rules unless you have good reason to change them: metal & plastic are invulnerable. Everything else breaks.
  • Avoid collecting multiple objects into the same prop, especially if we individually simulate identical looking objects elsewhere.
  • Avoid moving parts & materials we don't simulate, i.e. don't hang coats from a coat rack.

Breakables

The prop data system also handles generic breakable gibs. Generic gibs are used for any breakable object that doesn't have custom gibs. In general custom gibs are far superior to generic ones, but of course, there's a limit to how many custom gibs you can fit into memory.

There are three prop_data KVs that apply here:

breakable_model
Defines the set of generic gib models to use
breakable_count
By default Source will attempt to fit a sensible number of generic gib models within the volume of the breaking object, based upon their (and its) size. This allows you to hard-code a number yourself.
breakable_skin
Allows you to specify a skin to use on the gib models, which is useful for matching the original prop's material.

Most of the breakable prop data base classes already define the breakable models they use, and the derived <material_type>.<size_description> classes define the amount.

The generic gib sets themselves are defined at the bottom of mod/scripts/propdata.txt:

BreakableModels
{
	GenericGibSetName
	{
		models\gibmodel1	1 // Smallest gib model
		models\gibmodel2	1
		(...)
		models\gibmodel<n>	1 // Largest gib model
	}

physgun_interactions

The physgun_interactions $keyvalues set affects how props are handled, etc by the physcannon. Note that they are not part of the prop_data block : example QC syntax:

$keyvalues {
   physgun_interactions {
      preferred_carryangles 	"0 0 0" 	
      onworldimpact 		"stick"		
      onfirstimpact 		"break" 		
      onfirstimpact 		"paintsplat" 	
   // onfirstimpact 		"impale" 		
   // onlaunch 			"spin_none" 		
      onlaunch 			"spin_zaxis" 		
      onbreak 			"explode_fire" 		
      damage 			"none" 			
   }
}
preferred_carryangles <angles>
Sets the angles, relative to the player's orientation, at which the prop will be held when carried.
  • This is used, for example, with the sawblades and propellers in Ravenholm, as well as the turret NPCs in Nova Prospekt.
onworldimpact <choices>
Literal Value Description
stick Prop will embed itself into the world if it hits it after being launched.
onfirstimpact <choices>
Literal Value Description
break Prop should always break on colliding with anything after being launched.
paintsplat Prop applies paint decals to the first thing it hits after being launched.
impale Prop impales whatever it first collides with after being launched. Not used in HL2, and hence unsupported at this time.
onlaunch <choices>
Literal Value Description
spin_none Prop does not spin when launched. By default, the physgun applies random angular velocity to objects it launches.
spin_zaxis Prop should spin around the Z axis when launched by the physcannon.
onbreak <choices>
Literal Value Description
explode_fire Prop ignites nearby enemies when it explodes on breaking.
damage <choices>
Literal Value Description
none Prop does not move when 'attacked' with the physgun. It may still take damage, but it won't move due to the impact.

fire_interactions

This is a sub-KV set that defines flammability.

prop_data
{
	fire_interactions
	{
		key	"value"
		(...)
	}
}

The keys and their appropriate values are as follows:

ignite
<choices>
Literal Value Description
halfhealth This prop will ignite itself when its health falls below half its starting health.
explosive_resist
<choices>
Literal Value Description
yes This sets a special behavior on the prop that reduces blast damage it takes. If the prop is about to take blast damage that would kill it, it will reduce the damage enough to not die, and then ignite itself instead.
flammable
<choices>
Literal Value Description
yes This prop can be ignited by ignition damage (such as nearby fires & props marked with the "explode_fire" physcannon interaction. This was unused in HL2, and hence unsupported as this time.

Prototyping

When working on prototypes, or when you don't have modellers handy, it's useful to be able to work around the prop data system's enforcement. To do this, use the prop_physics_override and prop_dynamic_override entities instead of prop_physics and prop_dynamic. A prop_physics_override entity will not remove itself if it is assigned a model that wants to be static (i.e. has no "propdata" entry in its $keyvalues .QC section). It will also let the level designer to set a "health" on it.

The override entities allow you to temporarily use models incorrectly while prototyping, or waiting for a modeller to finish up a new model that has the properties you desire. It is highly recommended that you use Hammer's Entity Report feature to check each of your maps to ensure you have no override entities left when you ship them. Otherwise you may be shipping physics inconsistencies, and players are extremely quick to notice them (the orange bucket won't move when I shoot it on this level, but it did on the previous one).

See also

Template:Otherlang:en Template:Otherlang:en:jp