OK, first of all put the xmodel prop_mortar_static into your map and make it a script_model: You'll see from the screenies the targetnames I have given these objects - If you do the same, then the code at the bottom will work for your map as well.
Now put the xmodel prop_mortar_ammunition into your map, make it a script_model and you'll need to rotate it so it fits snugly inside the barrel of the mortar:
Now create a tigger use for the mortar:
Now for the crater. Create a terrain patch, make it a script_brushmodel and use the paint height feature of the patch editor to create a hole in your terrain.
Duplicate the crater brush you just created, apply a crater decal to it and fit it over the crater. Make sure you change the targetname of this script_brushmodel in the entity editor:
Now create a script_origin and place it in the bottom of the crater:
Finally, cover it the crater over with some terrain. Create a terrain patch, make it a script_brushmodel and make sure you fit the patch over the crater by bonding the vertices of the patch to the surrounding terrain:
Then use this code:
// By {FKR}KillerKlown
main()
{
//Set up the effects
level._effect["large_snow_explode1"] = loadfx("fx/explosions/large_snow_explode1.efx");
level._effect["mortar_flash"] = loadfx("fx/muzzleflashes/mortar_flash.efx");
//Hide the axis mortar in the launcher
axismortar = getent("axismortar","targetname");
axismortar hide();
//set the allied terrain
alliedcrater1 = getent ("alliedcrater1","targetname");
alliedcrater2 = getent ("alliedcrater2","targetname");
alliedcrater1 hide();
alliedcrater2 hide();
level.axisMortarFiring = false; // Axis mortar not being fired
level.axisMortarFired = false; // Flag to state if mortar previously fired
thread mortar_axis_start();
}
mortar_axis_start()
{
axistrig = getent("axismortartrigger","targetname");
while (1)
{
axistrig waittill ("trigger");
if (!level.axisMortarFiring)
thread mortar_axis_fire();
}
}
mortar_axis_fire()
{
level.axisMortarFiring = true;
iprintlnBold("Axis mortar launched");
axismortarmodel = getent("axismortarmodel","targetname");
axismortar = getent("axismortar","targetname");
axorigin = axismortarmodel getorigin();
mortorigin = axismortar getorigin();
//Effects for the mortar
axismortarmodel playsound ("mortar_load");
wait 0.5;
axismortarmodel playsound ("mortar_launch");
playfx(level._effect["mortar_flash"], axorigin);
// Launch the mortar into the air, hide it and return to origin
axismortar show();
axismortar moveto ((1975, -1808, 1500),1);
axismortar waittill ("movedone");
axismortar hide();
axismortar moveto ((mortorigin),1);
axismortar waittill ("movedone");
wait 1;
//Get the origin of the crater
alliedcraterorigin = getent("alliedcraterorigin","targetname");
alliedexplosion = alliedcraterorigin getorigin();
alliedcraterorigin playsound("incoming_mortar");
wait 2;
alliedcraterorigin playsound("explosion_ground");
playfx(level._effect["large_snow_explode1"], alliedexplosion);
// Radius damage to kill players in the area (origin, range, maxdistance, mindistance)
radiusDamage(alliedexplosion, 4000, 8000, 1000);
earthquake(0.3, 3, alliedexplosion, 5000);
if (level.axisMortarFired == false)
{
alliedcrater1 = getent("alliedcrater1","targetname");
alliedcrater2 = getent("alliedcrater2","targetname");
alliednocrater = getent ("alliednocrater","targetname");
alliednocrater delete();
alliedcrater1 show();
alliedcrater2 show();
level.axisMortarFired = true;
}
// Wait one minute until it can be fired again
wait 60;
level.axisMortarFiring = false;
}