Page 1 of 1

How to make BIG explosions

Posted: Sun Jul 01, 2012 2:52 pm
by Smivs
There was a discussion here about bigger, better explosions as feature in Xeptatl's Sword and Smivs'Shipset. This is how to make them. :)

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";
        };
Step2)
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);
};
The number of entities and the spacing will need to be tuned to your ship depending on its size.

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);
	};
}
and its death then spawns 15 'flash2s' via its shipscript (explosion2_script.js), and some alloys to give you lasting debris from the original ship. Remember this is for big ships, and I felt they should leave some debris after their destruction.

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);
};
Step 4)
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);
	};
}
which causes them to explode randomly between one and 3.5 seconds after they are spawned. Their shipscript (explosion3_script.js)

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);
};
then spawns 10x 'flash3's which are the smallest and final element of the cascade. 'flash3' uses the same AI as 'flash2'.

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 :twisted:


Edited to correct incomplete information (see posts below).

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 2:59 pm
by JensAyton
Smivs wrote:
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'.
Please bend to receive one (1) kick in the pants for not calling them “xeptatl_flash1” etc.

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 3:05 pm
by Smivs
Ahruman wrote:
Please bend to receive one (1) kick in the pants for not calling them “xeptatl_flash1” etc.
<Smivs dutifully bends over>

This is a very good point.
Xeptatl's Sword pre-dated many of the discussions on naming conventions I'm afraid. It will be updated one day, honest! :wink:
What Ahruman is saying is that such things should have a unique name ideally relating to the OXP to avoid any possibility of somebody else using the same name, and therefore causing confusion and problems.
For example the more recent example of these (in Smivs'Shipset) are called 'smivs-deathblast', not just 'deathblast' as my original post suggested.
<goes to edit the original post...>

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 3:58 pm
by Commander McLane
Smivs wrote:
Ahruman wrote:
Please bend to receive one (1) kick in the pants for not calling them “xeptatl_flash1” etc.
<Smivs dutifully bends over>

This is a very good point.
Xeptatl's Sword pre-dated many of the discussions on naming conventions I'm afraid.
Must be a really old OXP, then. :wink: Ahruman has consistently insisted on naming conventions with unique names since the summer of 2007 (as is revealed through a search for "unique" on the boards).

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 4:25 pm
by Smivs
Commander McLane wrote:
Smivs wrote:
Ahruman wrote:
Please bend to receive one (1) kick in the pants for not calling them “xeptatl_flash1” etc.
<Smivs dutifully bends over>

This is a very good point.
Xeptatl's Sword pre-dated many of the discussions on naming conventions I'm afraid.
Must be a really old OXP, then. :wink: Ahruman has consistently insisted on naming conventions with unique names since the summer of 2007 (as is revealed through a search for "unique" on the boards).
<Smivs puts on his 'Pedant' hat.>
Xeptatl's Sword pre-dated many of the discussions on naming conventions I'm afraid, and more pertinantly my awareness of this issue. :wink:

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 8:43 pm
by Shipbuilder
Thank for posting this Smivs as I have been thinking of designing some fuel tankers which I would like to go up with a bit of a bang if/when destroyed. :twisted:

Certainly I would want it to be a suicide mission to destroy one at close range.

I was thinking of having a look at the Starjelly oxp you produced and base an explosion on the method used there (Perhaps it is the same method anyway I’ve just not looked yet).

Anyway I have a few things that I need to get finished before I get on to this but it is definitely something that I will look in to in more depth when I come to design the tankers.

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 8:44 pm
by Thargoid
Or alternatively there is the wreckage add-on to Griff's ships (and others if you so desire) that he and I wrote together, and also similar mechanisms appear in a few of my OXPs (for example, shoot a [EliteWiki] Hawksbill fuel tanker and see what happens) :twisted:

Re: How to make BIG explosions

Posted: Sun Jul 01, 2012 9:00 pm
by Smivs
Shipbuilder wrote:
I was thinking of having a look at the Starjelly oxp you produced and base an explosion on the method used there (Perhaps it is the same method anyway I’ve just not looked yet).
Star Jellies are composed of quirium, the same stuff you get in Q-bombs, and your ship's fuel tank... :wink: