HuffingJenkem
09-19-2007, 19:02
One of the changes in kingdoms allows projectiles to spawn other projectiles - this is used by the mangonel and bombards (for grapeshot). The possibilities of this are huge - blunderbusses, grapeshot, mortars and exploding shells that actually use shrapnel, cluster bombs (for a steampunk mod perhaps), firebreathing monsters and the exploding cow fountain I made while I was playing around with the files. In this post I'll be looking at how the mangonel works, as this provides a fairly good example.
1. Unpack the Crusades or Teutonic campaign.
2. Open export_descr_unit.ext and search for the mangonel.
You'll see the following line of text:
stat_sec 65, 3, mangonel_shot, 250, 10, siege_missile, artillery_gunpowder, blunt, none, 26, 1
The bolded text indicates the name of the projectile.
2. Open descr_projectile.txt from the unpacked files and search for "mangonel_shot". Look for the following lines of text
; self_explode <prob> <min sec> <max sec> [<area effect>]
self_explode 0.8 1.0 5.5 air_burst_test
These are used to determine the parameters for a projectile exploding before hitting a target, which is necessary for spawning other projectiles. The stats for the mangonel indicate that it has an 80% chance of exploding, between 1 and 5.5 seconds after launch, and that it will use the air_burst_test area effect.
3. Open descr_area_effects.xml and search for air_burst_test. You'll see something like this:
<name>air_burst_test</name>
<type>projectile</type>
<effect>air_burst_impact_wall_explosion_culvern_set</effect>
<explosion_force_min>1.0</explosion_force_min>
<explosion_force_max>10.0</explosion_force_max>
<projectile_type>cow_carcass</projectile_type>
<!-- Do new projectiles have same velocity as parent (true/false) -->
<preserve_momentum>true</preserve_momentum>
<!-- Direction projectiles are fired by the explosion (forward, backward, up or down) -->
<direction>forward</direction>
<!-- max deviation of projectiles from direction -->
<scatter_angle>45</scatter_angle>
<projectile_number>10</projectile_number>
</area_effect>
<name> is self explanatory
<type> indicates that it's a projectile. As far as I can see the options here are projectile, fire, nausea (stat debuff, I think. It's what cows use), holy (morale buff, as used by giant crosses) and explosion.
<effect> is the effect to play when the area effect is started.
<explosion_force_min> and <explosion_force_max> indicate the min and max distances the explosion will throw the spawned projectiles. Experimenting with shrapnel and cows, the projectile itself seems to be a factor in distance, as well as the force.
<projectile_type> - determines what type of projectile is spawned. Your file will have a different entry here, because you probably don't find exploding cows as funny as I do.
<preserve_momentum> - indicates whether the spawned projectiles will inherit the trajectory of the parent projectile.
<direction> - which direction do you want the projectiles to spawn in. Heavily influenced by <preserve_momentum>, so be sure to turn that off if you want the projectiles to go straight up or down.
<scatter_angle> - This determines the maximum deviation from <direction>. Measured in degrees, and applies equally to all 3 axes, thus 180 will get you a spherical explosion.
<projectile_number> - Bit obvious really, number of projectiles to be spawned.
So, to set up something like grapeshot:
1. Set the cannon projectile to explode with a probability of 1, 0.1 seconds after launch
2. Create an area effect entry.
3. Spawn x number of musket bullets, with a forward direction and a scatter of around 10
A cluster bomb:
1. Mangonel, increase the explosion min time
2. Area effect to spawn x exploding cannonballs downwards with preserve momentum off
1. Unpack the Crusades or Teutonic campaign.
2. Open export_descr_unit.ext and search for the mangonel.
You'll see the following line of text:
stat_sec 65, 3, mangonel_shot, 250, 10, siege_missile, artillery_gunpowder, blunt, none, 26, 1
The bolded text indicates the name of the projectile.
2. Open descr_projectile.txt from the unpacked files and search for "mangonel_shot". Look for the following lines of text
; self_explode <prob> <min sec> <max sec> [<area effect>]
self_explode 0.8 1.0 5.5 air_burst_test
These are used to determine the parameters for a projectile exploding before hitting a target, which is necessary for spawning other projectiles. The stats for the mangonel indicate that it has an 80% chance of exploding, between 1 and 5.5 seconds after launch, and that it will use the air_burst_test area effect.
3. Open descr_area_effects.xml and search for air_burst_test. You'll see something like this:
<name>air_burst_test</name>
<type>projectile</type>
<effect>air_burst_impact_wall_explosion_culvern_set</effect>
<explosion_force_min>1.0</explosion_force_min>
<explosion_force_max>10.0</explosion_force_max>
<projectile_type>cow_carcass</projectile_type>
<!-- Do new projectiles have same velocity as parent (true/false) -->
<preserve_momentum>true</preserve_momentum>
<!-- Direction projectiles are fired by the explosion (forward, backward, up or down) -->
<direction>forward</direction>
<!-- max deviation of projectiles from direction -->
<scatter_angle>45</scatter_angle>
<projectile_number>10</projectile_number>
</area_effect>
<name> is self explanatory
<type> indicates that it's a projectile. As far as I can see the options here are projectile, fire, nausea (stat debuff, I think. It's what cows use), holy (morale buff, as used by giant crosses) and explosion.
<effect> is the effect to play when the area effect is started.
<explosion_force_min> and <explosion_force_max> indicate the min and max distances the explosion will throw the spawned projectiles. Experimenting with shrapnel and cows, the projectile itself seems to be a factor in distance, as well as the force.
<projectile_type> - determines what type of projectile is spawned. Your file will have a different entry here, because you probably don't find exploding cows as funny as I do.
<preserve_momentum> - indicates whether the spawned projectiles will inherit the trajectory of the parent projectile.
<direction> - which direction do you want the projectiles to spawn in. Heavily influenced by <preserve_momentum>, so be sure to turn that off if you want the projectiles to go straight up or down.
<scatter_angle> - This determines the maximum deviation from <direction>. Measured in degrees, and applies equally to all 3 axes, thus 180 will get you a spherical explosion.
<projectile_number> - Bit obvious really, number of projectiles to be spawned.
So, to set up something like grapeshot:
1. Set the cannon projectile to explode with a probability of 1, 0.1 seconds after launch
2. Create an area effect entry.
3. Spawn x number of musket bullets, with a forward direction and a scatter of around 10
A cluster bomb:
1. Mangonel, increase the explosion min time
2. Area effect to spawn x exploding cannonballs downwards with preserve momentum off