Vehicle Setup

From Mod Wiki

You can set up breakable vehicles by defining models to be detached when they damaged or destroyed.

Detachable Components

Maya Setup

The model in Maya needs every detachable component as a separate object with a unique name.

Detachable Model

The detachable model should be exported to a static model (lwo/obj/ase) with relative orientation to the closest relevant joint. If the model is far away, problems may arise in game with the parts jittering around, to fix them try adding a closer joint.

This model now needs a collision model, as an easy rule we can use a extruded pentagon deformed to roughly match the render model. If it gets too complicated the game will refuse to load it, if this happens try simplifying it.

Setup in Vehicle Script

SimplePart Setup

A simple part needs to be set up in the vehicle script (.vscript). In ETQW, these scripts are kept in the base/vehicles folder. Here is an example, this is the right wing-mirror for the Armadillo:

simplePart {
	"name"				"Right Mirror"
	"surface1"			"m_right_mirror"
	"surface2"			"s_right_mirror"
	"joint"				"base"
	"def_brokenPart"		"part_vehicle_badger_right_mirror"
	"health" 			"10"
}

This definition should be placed within the main vehicle definition.

  • name is for your own reference.
  • surface1 is the first surface of the detachable model which the game detects being hit and hides, in this case it is a render model.
  • surface2 is the second surface the game hides. This is a simplified shadow model which has a different material to the render model and so has to be a separate object in maya. This section is unnecessary if there is no separate shadow model.
  • joint is the joint the static model has been exported relative to.
  • def_brokenPart is referencing the part setup shown below in the Part entityDef section.
  • health is how much health the detachable component has (how much damage it can take before detaching). If this value is set to 0 the component will not detach until the vehicle's total health falls to zero and everything comes off in one go.

Part entityDef

The part entity defines more parameters of the detachable component, including the most important one, the static model it references.

entityDef part_vehicle_badger_right_mirror {
	useTemplate templates/vehicles/destroyedParts <
			"models/vehicles/edf_badger/parts/right_mirror.lwo",
			"0 -200 700",
			"0 0 2",
			"vehicles/misc/debris/glass_small",
			"0.1"
		>
	"climate_skin_key"				"badger"
	"priority"					"0"
}

This is placed straight into the .vscript, it is not enclosed in any other definitions.

The first section of this is referencing a template. This template has the parameters, however the defaults are usually ok.

ModelParm,
VelocityParm 		= "500 0 0",
AngularVelParm 		= "2 4 10",
SoundBounceParm		= "vehicles/misc/debris/metal_medium",
BouncynessParm 		= "0.25",
FrictionParm 		= "0.5",
DensityParm		= "0.01",
TrailParm 		= "effects/vehicles/generic_debris",
LifeTimeParm 		= "10",

The ones you will want to change are the "ModelParm" (to be the static model you exported from Maya) and possibly the "SoundBounceParm" and the "TrailParm".

General Tips

  • Try to avoid making long, thin detachable components as the game has trouble handling them.
  • Physics calculations are very expensive, try and keep the detachable components as simple and few as possible, particularly when (like in ETQW) there is the possibility of a sudden mass death where multiple vehicles could be instantly destroyed!
  • If there are too many detachable components at once the game will remove them! You may end up with the game removing the larger ones.
  • Collision models can cope with polygons with more than 3 sides. The game automatically treats co-planar triangles as one polygon. Less polygons in the collision models is much better!
  • Components with 0 health will appear when the vehicle is totally destroyed, e.g. the vehicle's main hull or parts that cannot be shot off.