The way it works is that when the ship dies, it spawns a series of entities by script which in this example taken from Xeptatl's Sword are called 'flash1'. 'flash1' has an AI attached to it which triggers and times its explosion, and also has its own shipscript which spawns more smaller explosions called 'flash2', which in turn do the same, spawning and detonating 'flash3'.
For a three-stage cascade explosion suitable for large (1km+ diameter) objects:-
Step One)
You will need to add the elements of the explosion to the shipdata.plist. For a three-stage explosion you will need three models, large, medium and small. You can use anything for these - I used asteroids, boulders and splinters in Xeptatl's Sword. In shipdata I call them flash1, flash2 and flash3.
Code: Select all
"flash1" =
{
ai_type = "explosion1_debrisAI.plist";
"counts_as_kill" = no;
debris_role = "flash2";
model = "your chosen big model";
name = "Debris";
roles = "flash1";
"scan_class" = "CLASS_NO_DRAW";
script = "explosion2_script.js";
likely_cargo = 0;
};
"flash2" =
{
ai_type = "explosion2_debrisAI.plist";
"counts_as_kill" = no;
debris_role = "flash3";
model = "your chosen medium model";
name = "Debris";
roles = "flash2";
"scan_class" = "CLASS_NO_DRAW";
script = "explosion3_script.js";
likely_cargo = 0;
};
"flash3" =
{
ai_type = "explosion2_debrisAI.plist";
"counts_as_kill" = no;
model = "your chosen small model";
name = "Debris";
roles = "flash3";
"scan_class" = "CLASS_NO_DRAW";
};
The 'exploding' ship will need a shipscript. This code can be added to an existing shipscript and handles the death-event.
Code: Select all
// Standard attributes
this.name = "explosion1_script";
this.author = "Smivs";
this.copyright = "(C) Smivs"
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0"
this.version = "1.0";
this.description = "Script to spawn debris as first part of a sequential explosion."
this.shipDied = function ()
{
system.addShips("flash1", 10, this.ship.position, 400);
};
Step 3)
You will notice that 'flash1' will then explode after a 0.2 second pause using its AI which I call 'explosion1_debrisAI.plist'
Code: Select all
{
GLOBAL =
{
ENTER = ("pauseAI: 0.2");
UPDATE = ("setStateTo: DETONATE");
};
DETONATE =
{
ENTER = (becomeExplosion);
};
}
Code: Select all
// Standard attributes
this.name = "explosion2_script";
this.author = "Smivs";
this.copyright = "(C) Smivs"
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0"
this.version = "1.0";
this.description = "Second script to generate sequential explosions."
this.shipDied = function ()
{
system.addShips("flash2", 15, this.ship.position, 400);
system.addShips("alloy", 3, this.ship.position, 400);
};
This is really a repeat of the previous step, only generating the small, final explosion elements.
When 'flash2's are spawned, they too have their own AI (explosion2_debrisAI.plist)
Code: Select all
{
GLOBAL =
{
ENTER = ("randomPauseAI: 1.0 3.5");
UPDATE = ("setStateTo: DETONATE");
};
DETONATE =
{
ENTER = (becomeExplosion);
};
}
Code: Select all
// Standard attributes
this.name = "explosion3_script";
this.author = "Smivs";
this.copyright = "(C) Smivs"
this.licence = "Creative Commons Attribution - Non-Commercial - Share Alike 3.0"
this.version = "1.0";
this.description = "Third script to generate sequential explosions."
this.shipDied = function ()
{
system.addShips("flash3", 10, this.ship.position, 400);
};
So when your ship dies, 10 large entities are spawned which explode after 0.2 seconds. Each one of these then spawns 15 medium-size entities which explode between 1 and 3.5 seconds later, and three alloys. Each of these medium-size entities then spawn 10 small entities when they explode, and these will then explode after between 1 and 3.5 seconds.
The total explosion therefore involves less than 200 entities (which shouldn't put too much strain on the graphics) and lasts for up to seven seconds.
As I mentioned this cascade explosion is only suitable for huge objects. By using stages 2 and 3 only with suitable numbers of entities, explosions suitable for more regular sized ships are achievable. For examples see the enhanced death effects in Smivs'Shipset where the entities are called 'smivs-deathblast' rather then 'flash1' etc. Also in Smivs'Shipset you will see that the 'debris' has a flasher (in shipdata) and a special texture (in the 'Textures' folder and specified in the 'materials' section of shipdata). These give the 'fiery wreckage' effect.
You are welcome to plunder this stuff - it's all creative-commons licenced - so just give me a mention if you use it.
My Ambush at Intiso video shows some of the smaller explosions...for the really big ones you'll have to do the Xeptatl's Sword mission - no spoilers here
Edited to correct incomplete information (see posts below).