Tutorial: Add custom gibs to your model

From Empires Wiki
Jump to navigation Jump to search

To add gibs you need to know some details: Gibs spawn after a model reaches 0 health. Your model needs healthpoints > 0 and it must be vunerable to weapons. To set the health of a model and modify weapondamage use the $keyvalues directive. By adding $collisiontext you can use custom gibs. Have a look at this example. The 4 gibs are created from the original model called cactus1.mdl and fit exactly together. Place cactus1.mdl on the map as prop_physics or prop_dynamic.

I created the model and the gibs and saved them as SMD:

cactus1_LOD0.smd
cactus1_LOD1.smd
cactus1_phys.smd
cactus1_gib0.smd
cactus1_gib1.smd
cactus1_gib2.smd
cactus1_gib3.smd

This is the .qc code for the gibs.

$modelname "common\props_foliage\misc\cacti\cactus1_gib#.mdl"
$model "cactus1_gib0" "cactus1_gib#.smd"
$keyvalues 
{ 
"prop_data" 
{ 
"base" "Flesh.Tiny" 
"health" "1"
} 
}
$cdmaterials "\common\nature\"
$surfaceprop "watermelon"
$scale 1
$sequence	idle	"idle.smd"
$collisionmodel "cactus1_gib#.smd" {
$mass 0.1
}

I replaced the # with the numbers (0-3) and got 4 models named as followed (by compiling them, see:Tutorial: Create your own models) :

cactus1_gib0.mdl
cactus1_gib1.mdl
cactus1_gib2.mdl
cactus1_gib3.mdl

Compile this model last. The important commands are $keyvalues (and prop_data) and $collisiontext.

This is the .qc code for the parent model:

$modelname "common\props_foliage\misc\cacti\cactus1.mdl"
$model "cactus1_LOD0" "cactus1_LOD0.smd"
$lod 100
{
 replacemodel "cactus1_LOD0" "cactus1_LOD1.smd"
}
$keyvalues
{ 
"prop_data"
{ 
"base" "Flesh.Tiny" 
"health" "10"
"dmg.club" "5"
"physicsmode" "1"
"allowstatic" "1"
"multiplayer_break" "both"
"physdamagescale" "5"
} 
fire_interactions
{
explosive_resist   "no" 	// Clamp blast damage so that the prop ignites instead of breaking.
flammable          "yes" 	// Can be ignited by fire and explosions.
}
}
$cdmaterials "\common\nature\"
$surfaceprop "watermelon"
$scale 1
$sequence	idle	"idle.smd"
$collisiontext
{ 
break { "model" "\common\props_foliage\cactus1_gib0.mdl" "health" "1" "fadetime" "10"}
break { "model" "\common\props_foliage\cactus1_gib1.mdl" "health" "1" "fadetime" "5"}
break { "model" "\common\props_foliage\cactus1_gib2.mdl" "health" "1" "fadetime" "5"}
break { "model" "\common\props_foliage\cactus1_gib3.mdl" "health" "1" "fadetime" "10"}
}
$collisionmodel "cactus1_phys.smd" 
{
$concave
$mass 5.0
$inertia 1.00
$damping 0.00
$rotdamping 0.00
$masscenter 0 0 -10
}

usage: break { "model" "<path>" options}

<path> path to the gib

options:

"health" "1" override the gibs health (set to 1)
"fadetime" "10" gib disapears after 10 seconds


usage: prop_data

Note: Make sure that the base value of "prop_data" is equal in all models.

Links: