Mr. Bildo
3rd Oct 06, 5:19 PM
(Note: this HOWTO assumes you are using Corsix's Mod Studio, if you don't know what that is, stop reading this and find out.)
One of the cool features of CoH's is the ability to deform the terrain. This makes for a very dynamic battlefield, because the craters left behind from various explosions can provide new cover for your troops.
I've found that editing the deformation effect is pretty easy and very flexible.
First off, most (if not all) deformation stems from the explosion effect of a projectile. In game terms, this means anything from an artillery shell to a hand grenade. There is a lot to projectiles in general and too much detail here would be out of the scope of this HOWTO.
Projectiles are entities stored in attrib\ebps\projectile\. They are not broken down by race here, but some are prefixed with allied_ or axis_.
If you don't know what weapon shoots what projectile, here is where to look: attrib\weapon\(race)\(etc)\*.rgd. Let's look at attrib\weapon\allies\ballistic_weapon\mortar\m2_60mm_mortar.rgd as an example. One of the children of the weapon_bag table is projectile. You will notice that it is referencing ebps\projectile\m2_60mm_mortar_round.lua. You will find that some weapons may share the same projectile, so keep in mind that changing values of the projectile will affect both weapons. Note: not all weapons have a projectile.
Once you have found the projectile you want to edit (we'll stick with the m2_60mm_mortar_round) you'll want to navigate to \explosion_ext\terrain_hit in the GameData table. You will see a half dozen or so properties here. You can reference my lau guide below for more details on each one.
The properties we are most concerned with are the deformation table, radius_max and radius_min.
The deformation table has a number of properties as well (again, reference below). The one we are most concerned with here is the deform_decal_file property. For our mortar example, the value is mortar_crater. In short, this property is asking us what decal we want to use to generate the "look" of our deformation or crater. What we are actually referencing here is a graphics file (tga) in the game data. You can view these files by navigating to data\simulation\deformdata\. Here you will see a few existing .tga files. Let's extract mortar_crater.tga and look at it in an image editor. You should see a greyscale image of what looks like a hole. Most people will recognize this as a heightmap (http://en.wikipedia.org/wiki/Heightmap). Basically, grey represents "the ground", lighter colors are raised portions and darker colors are lowered portions (i.e. the crater). This image is what is used to create the deformation in the game!
So if we wanted to change the deformation for our mortar projectile, all we have to do is change the value of deform_decal_file to a new image. You can try this with the existing images or create your own. There are a number of heightmap editors available on the internet. This is the one I use (http://hme.sourceforge.net/).
In order to scale the deformation properly (and add some randomness) you will want to take note of the settings in radius_min and radius_max. Also, vertical_scale under deformation.
One more note of caution: be mindful of the value in chance_splat_only. This is a value between 0 and 1 which determines if a deformation occurs or just a decal is displayed. If it is set to 1 (which is the case in the mortar example) a deformation will never occur!
SDK/LUA notes:
-- terrain_hit
\terrain_hit[chance_splat_only] = 0 to 1 -- the chance that only a decal will be drawn and no deformation will occur. 1 = no deformation 0 = always deformation
\terrain_hit[cover_type] = a value of attrib\type_cover -- determines what type of cover is created by the deformation. Keep in mind that the size of the hole doesn't matter, only this value.
\terrain_hit[radius_min]
\terrain_hit[radius_max] = the min/max scaled size of the deformation.
\terrain_hit[splat_only_splats]
\terrain_hit[splat_only_splats_seconds] = relate to the decal of the explosion and is out of the scope of this HOWTO.
--\terrain_hit\deformation
\deformation[deform_decal_file] = the name of the file (minus the .tga) to use as the heightmap for this deformation. Stored in data\simulation\deformdata\.
\deformation[deform_type] = a value of attrib\type_deform -- this determines how the deformation compounds with other bounding deformations.
\deformation[limited] = ?? NOT SURE ??
\deformation[random_rotation] = a bool value that determines if the deformation is rotated when formed.
\deformation[rotation] = ?? I this obviously relates to random_rotation, but I'm not sure what the min/max values are.
\deformation[splat_list] = not in the scope of this HOWTO.
\deformation[vertical_scale] = the depth of the deformation. This number is generally specified in the thousandths (.001).
Please let me know of any errors or omissions. Like most of us at this point, a lot of this comes from experimentation.
--Mr. Bildo
One of the cool features of CoH's is the ability to deform the terrain. This makes for a very dynamic battlefield, because the craters left behind from various explosions can provide new cover for your troops.
I've found that editing the deformation effect is pretty easy and very flexible.
First off, most (if not all) deformation stems from the explosion effect of a projectile. In game terms, this means anything from an artillery shell to a hand grenade. There is a lot to projectiles in general and too much detail here would be out of the scope of this HOWTO.
Projectiles are entities stored in attrib\ebps\projectile\. They are not broken down by race here, but some are prefixed with allied_ or axis_.
If you don't know what weapon shoots what projectile, here is where to look: attrib\weapon\(race)\(etc)\*.rgd. Let's look at attrib\weapon\allies\ballistic_weapon\mortar\m2_60mm_mortar.rgd as an example. One of the children of the weapon_bag table is projectile. You will notice that it is referencing ebps\projectile\m2_60mm_mortar_round.lua. You will find that some weapons may share the same projectile, so keep in mind that changing values of the projectile will affect both weapons. Note: not all weapons have a projectile.
Once you have found the projectile you want to edit (we'll stick with the m2_60mm_mortar_round) you'll want to navigate to \explosion_ext\terrain_hit in the GameData table. You will see a half dozen or so properties here. You can reference my lau guide below for more details on each one.
The properties we are most concerned with are the deformation table, radius_max and radius_min.
The deformation table has a number of properties as well (again, reference below). The one we are most concerned with here is the deform_decal_file property. For our mortar example, the value is mortar_crater. In short, this property is asking us what decal we want to use to generate the "look" of our deformation or crater. What we are actually referencing here is a graphics file (tga) in the game data. You can view these files by navigating to data\simulation\deformdata\. Here you will see a few existing .tga files. Let's extract mortar_crater.tga and look at it in an image editor. You should see a greyscale image of what looks like a hole. Most people will recognize this as a heightmap (http://en.wikipedia.org/wiki/Heightmap). Basically, grey represents "the ground", lighter colors are raised portions and darker colors are lowered portions (i.e. the crater). This image is what is used to create the deformation in the game!
So if we wanted to change the deformation for our mortar projectile, all we have to do is change the value of deform_decal_file to a new image. You can try this with the existing images or create your own. There are a number of heightmap editors available on the internet. This is the one I use (http://hme.sourceforge.net/).
In order to scale the deformation properly (and add some randomness) you will want to take note of the settings in radius_min and radius_max. Also, vertical_scale under deformation.
One more note of caution: be mindful of the value in chance_splat_only. This is a value between 0 and 1 which determines if a deformation occurs or just a decal is displayed. If it is set to 1 (which is the case in the mortar example) a deformation will never occur!
SDK/LUA notes:
-- terrain_hit
\terrain_hit[chance_splat_only] = 0 to 1 -- the chance that only a decal will be drawn and no deformation will occur. 1 = no deformation 0 = always deformation
\terrain_hit[cover_type] = a value of attrib\type_cover -- determines what type of cover is created by the deformation. Keep in mind that the size of the hole doesn't matter, only this value.
\terrain_hit[radius_min]
\terrain_hit[radius_max] = the min/max scaled size of the deformation.
\terrain_hit[splat_only_splats]
\terrain_hit[splat_only_splats_seconds] = relate to the decal of the explosion and is out of the scope of this HOWTO.
--\terrain_hit\deformation
\deformation[deform_decal_file] = the name of the file (minus the .tga) to use as the heightmap for this deformation. Stored in data\simulation\deformdata\.
\deformation[deform_type] = a value of attrib\type_deform -- this determines how the deformation compounds with other bounding deformations.
\deformation[limited] = ?? NOT SURE ??
\deformation[random_rotation] = a bool value that determines if the deformation is rotated when formed.
\deformation[rotation] = ?? I this obviously relates to random_rotation, but I'm not sure what the min/max values are.
\deformation[splat_list] = not in the scope of this HOWTO.
\deformation[vertical_scale] = the depth of the deformation. This number is generally specified in the thousandths (.001).
Please let me know of any errors or omissions. Like most of us at this point, a lot of this comes from experimentation.
--Mr. Bildo