PDA

View Full Version : How to make a projectile spawn another (Kingdoms)



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

alpaca
09-20-2007, 18:49
Hmm so what does the exploding ammo in the original game use?

HuffingJenkem
09-20-2007, 20:01
Just a straightforward explosion, with a chance of killing anyone within a set radius.

alpaca
09-21-2007, 16:52
So could we kind of trigger on the ammo hitting the ground? It'd be cool to have something like shrapnel.
Will the ammo explode automatically on the ground?

HuffingJenkem
09-21-2007, 18:59
Should be possible - define an area effect in descr_projectiles.txt and then set the area effect up as a spawning area effect.

alpaca
09-21-2007, 19:23
Yeah I may do that some time :laugh4:

Ashdnazg
10-08-2007, 15:57
I suppose Canister can be done by making it explode after 0 or so seconds, and throw a nice amount of musket balls.

Marcus Orentius
10-09-2007, 21:11
Yeah, but judging by the mangonel explosion, it seems to go all directions, so you would end up killing your own troops.

Ashdnazg
10-10-2007, 20:53
I believe that's why the scatter angle and preserve_momentum exist :)

Shadow_Wolf33
02-07-2008, 03:32
Does the projectiles spawning other projectiles only work with artillery? I'm trying to create a scattergun type effect with muskets, but it isn't working. I've even tried changing the musket to ribault shot in case it had something to do with ammo type. Any chance for this to work?

Furious Mental
02-07-2008, 04:48
Yeah just change the entry for the musket_shot projectile the same as you would change an entry for an artillery shot. Of course, you would want the effect to create a smaller number of projectiles.

Shadow_Wolf33
02-07-2008, 05:02
Yeah just change the entry for the musket_shot projectile the same as you would change an entry for an artillery shot. Of course, you would want the effect to create a smaller number of projectiles.

I tried doing that, I more or less followed the steps outlined by the OP (even the cow_carcass!), modifying it as needed to suit the musket_shot type. Would it make a difference that I'm trying to do it in the americas expansion? Would that type of effect be disabled for mods that don't use the mangonel normally? :wall:

PBI
02-11-2008, 14:52
Will this work for vanilla or does it only work in Kingdoms? I tried setting up grapeshot but the cannonballs just disappear, they don't spawn anything.

wolfslair
02-15-2008, 12:07
I tried doing that, I more or less followed the steps outlined by the OP (even the cow_carcass!), modifying it as needed to suit the musket_shot type. Would it make a difference that I'm trying to do it in the americas expansion? Would that type of effect be disabled for mods that don't use the mangonel normally? :wall:


I believe this only works for Kingdoms because it is hardcoded in Kingdoms.exe. Please correct me if I'm wrong on this.

It should work in any Kingdoms mods as long as you have all the .cas files and everything done properly in descr_proj and all the relevant effects files.

For example,you could make an exploding beehive grenade with a shrapnel effect that would randomly hit different members of a group within a certain radius, instead of just an area effect that would effect every single unit in the area radius.

Personally I want to see if I can create an exploding shell for basilisks and cannon, etc that will emit a damaging shrapnel.cas beyond the cannon ball's usual damage radius, and have a sound.evt attached to it.

I'm already working on a bullet effects set that if I finish it and make available for release, should be able to be added to just about any mtw2 mod.

PBI
02-18-2008, 01:09
I see.

Yes, just tried this with the Retrofit mod (which runs from kingdoms.exe) and it works fine. Thanks for the help.

Tchouk
04-24-2008, 10:28
Lots of possibilities here, thanks!