Page 1 of 9

Flaming Wreckage! - Possible with scripting?

Posted: Mon Jan 26, 2009 8:23 pm
by Griff
In JScript can we spawn random objects at the exact point a ship explodes and make these objects fly off at fairly high speed in random directions for a short time (10 seconds or so) and then remove them cleanly from the game (ie without generating wormholes or using the landonplanet command which if i remember correctly causes shuttles to launch from the main planet or something?)

I thought i might have a go at beefing up the old glowing alloys oxp into more of a flaming wreakage oxp, i've recently been having a lot of fun zapping ships in Oolite and although the explosion cloud and odd bit of hull that flys off is really nice i'm a bit dissapointed by the grey rectangle that gets left behind as debris - i want flaming, twisted wreckage!

I tried something like this before with the griff_boa but it just looked awful, i was spawing big chunks of ruined ship in the boa's death_actions and what would happen is that when the boa exploded, the chunks of hull popped into existence in a small cloud in the general area of where the explosion happened and just hung there in space - it didn't really look that good so i shelved the idea.

Posted: Mon Jan 26, 2009 9:35 pm
by Thargoid
Yes, it's possible.

this.ship.position tells you where the ship is, so you use that as the required location by noting it as a variable in the script then using that place to add your wreckage (system.legacy_addShipsAtPrecisely is your command there). You can remove the wreckage either using this.ship.remove() or this.ship.explode() depending on whether you want it to just vanish or to blow up (remove is new in 1.72). You can use either the wreckage's AI or a script timer to give it a small lifetime before it goes bang/vanishes. AI is probably better in this case, as you can then use it also to do the flying away.

If you want an example, have a look at the Hawksbill tanker in Aquatics (but use the 1.04 version, the 1.03 version had a script bug which caused it to not spawn the burning fuel). That does it slightly differently (it's a 1.71.2 script) but may fit your bill.

Posted: Mon Jan 26, 2009 10:00 pm
by ZygoUgo
I always wanted a much larger secondary flash, as if the first is the Ka-, the secondary the -BOOM.
The reason I'm mentioning this (other than it being a childish urge to see bigger bangs), is that it would hide anything that was suddenly spawned from just appearing out of nowhere.
I must say I like the flashes in Oolite, they seem far more likely than the Hollywood balls of fire you get in every other game (What oxygen!?). Flaming wreckage would be good though, maybe it only disapears if it goes out of scanner range so it appears completely solid. That way if you get a slow bit you can admire its twisty burning beauty :D Maybe scoop it for alloys?
Never did like the fridge door that comes as standard.

Posted: Mon Jan 26, 2009 10:18 pm
by Griff
Fridge door! :lol:
Thanks Thargoid for the script advice, i'll have to get my thinking cap on and let it warm up for a few days before i attempt to understand it all though!
Yeah, the plan is to make lots of small odd bits of hull plating, probably only a few polygons each, clip mapped and glow mapped to make them crinkly and molten looking at the edges ( Ahruman wrote a great example shader ages ago that make a fab cooling metal effect, that will be perfect for this), and make them spin off into the void for a few seconds before removing them. I'll also make some bigger scoopable pieces, it will be a cool use for normals maps to make them appear all dented and beaten-up. I wonder if Ahrumans recent animated camoflage shader could be used to make flames or 'weird space engine glowy stuff' appear to crawl along the surface of the debris? (or maybe animated clipmapped polygons to generate that sparky lightning stuff that Mad scientists have in their labs)

Posted: Mon Jan 26, 2009 10:21 pm
by Thargoid
I'd be happy to help with the scripting if you want to do it, it's quite simple. Have a look at the Hawksbill and see if that's the kind of thing you want.

At the moment the burning fuel there explodes immediately, but adding a pause into the AI to delay the explosion there is trivial.

Posted: Mon Jan 26, 2009 10:24 pm
by Griff
That's really good of you! I'll get busy making some objects and looking at your scripts and i'll fire off a Thargoid shaped distress flare if i get into problems with the scripting (this will most likely happen)

Posted: Mon Jan 26, 2009 10:26 pm
by tomsk
ZygoUgo wrote:
That way if you get a slow bit you can admire its twisty burning beauty ?
I would love to see a flaming Trumble. :twisted:

Re: Flaming Wreckage! - Possible with scripting?

Posted: Mon Jan 26, 2009 10:32 pm
by Eric Walch
Griff wrote:
.... i'm a bit dissapointed by the grey rectangle that gets left behind as debris - i want flaming, twisted wreckage!
You could try to create new wreckage pieces with role "wreckage". This is what is left behind after an explosion. Currently they are all defined grey-brown and there are 5 different shapes in shipData.plist. Maybe experiment with more brighter pieces of wreckage?
The system will take care of the adding and destruction within a second. But maybe flaming colours will look bad here.

In the past I have been experimenting in adding sub-entities in the explosion in an orientation as the original sub-entity but a little more outward from the blast centre. (with JS scripting). I hardly saw any improvement. Probably because the code was already doing the same: On explosion, the main entity is removed and replaced by an explosion, but it also adds all subentities as single entities in the explosion and let them explode also. Placing any entity inside this explosion will almost guarantee it also explodes in the blast.

Posted: Mon Jan 26, 2009 11:16 pm
by Griff
Thanks for the info Eric, the role wreckage sounds perfect - i want a brief shower of tiny glowy bits shooting off excitingly leaving a few larger bits behind - i'm hoping to use glow maps and stuff on them and possibly vertex shaders to make them tumble (although i suppose Oolite can provide its own rotation to the pieces). hmm, i think i'll make a few objects and see how they look in game, and experiment with the roles possibly some scripting for some of the major pieces of wreckage? then cry for help to all you scripting geniuses

Posted: Mon Jan 26, 2009 11:25 pm
by DaddyHoggy
Griff wrote:
Fridge door! :lol:
Thanks Thargoid for the script advice, i'll have to get my thinking cap on and let it warm up for a few days before i attempt to understand it all though!
Yeah, the plan is to make lots of small odd bits of hull plating, probably only a few polygons each, clip mapped and glow mapped to make them crinkly and molten looking at the edges ( Ahruman wrote a great example shader ages ago that make a fab cooling metal effect, that will be perfect for this), and make them spin off into the void for a few seconds before removing them. I'll also make some bigger scoopable pieces, it will be a cool use for normals maps to make them appear all dented and beaten-up. I wonder if Ahrumans recent animated camoflage shader could be used to make flames or 'weird space engine glowy stuff' appear to crawl along the surface of the debris? (or maybe animated clipmapped polygons to generate that sparky lightning stuff that Mad scientists have in their labs)
Would go nicely with my idea of secondary trading via "oobay"...

Posted: Tue Jan 27, 2009 6:09 am
by Commander McLane
Actually you don't need to use JS for it. It's entirely possible from within the AI. Here's an example from Cataclysm 1.2 (WIP):

At a certain point a ship explodes, and I wanted to make it look spectacular. First thing I did was giving it a huge density in shipdata, assuming that this would create more wreckage. This is what you see in the released version. Kind of works, but not always (there is also some random involved in the explosion-business). So I wanted to add more wreckage. I do this by creating a new entity, which is only a clone of the native alloy with a custom role and a custom AI. The trick is the AI, of course. Very simple:

Code: Select all

{
    "BECOME_DEBRIS" = {
        ENTER = ("rollD: 9"); 
        EXIT = (); 
        "ROLL_1" = ("pauseAI: 0.1"); 
        "ROLL_2" = ("pauseAI: 0.2"); 
        "ROLL_3" = ("pauseAI: 0.3"); 
        "ROLL_4" = ("pauseAI: 0.4"); 
        "ROLL_5" = ("pauseAI: 0.4"); 
        "ROLL_6" = ("pauseAI: 0.5"); 
        "ROLL_7" = ("pauseAI: 0.5"); 
        "ROLL_8" = ("pauseAI: 0.6"); 
        "ROLL_9" = ("pauseAI: 0.7"); 
        UPDATE = (becomeExplosion); 
    }; 
    GLOBAL = {ENTER = ("setStateTo: BECOME_DEBRIS"); EXIT = (); UPDATE = (); }; 
}
It just becomes an explosion after a random amount of time. So Oolite's engine is doing all the explosion work for me. No script needed.

The only thing left to do is to spawn: some of these things in the death_actions of the ship I want to go out with a boom. VoilĂ .

Note: As I said before, there is some random involved. For instance, it can happen that in a particular explosion the spawn: produces 0 of my exploding alloys. But if you're planning to make this the way of exploding a ship, I think that's no problem. Nobody would expect each individual of a certain ship type to blow up in the same way.

And of course you can improve the effect by replacing my alloy-clone with something that glows for those fraction of a second it exists. And of course you can adjust the delay times in the AI. In principle, a shrapnell from the original explosion could fly through half the system before exploding five minutes or so later. Although it wouldn't make that much sense.

Posted: Tue Jan 27, 2009 9:10 am
by Eric Walch
Griff wrote:
Thanks for the info Eric, the role wreckage sounds perfect - i want a brief shower of tiny glowy bits shooting off excitingly leaving a few larger bits behind -
As mcLane states it the amount of debris related to the sips mass:

Code: Select all

int n_alloys = floor(sqrtf(sqrtf(mass / 25000.0)));
For n_alloys the system uses things with role "alloy" to add into the explosion. Besides this alloy it uses wreckage:

Code: Select all

int n_wreckage = (n_alloys < 3)? n_alloys : 3;
Or in plain english: Put just as many wreckage to the system as alloys, but with a maximum of 3 pieces. This wreckage is than manipulated. It is resized to mach the ships size and its energy is altered to let it burn for 0.25s -> 1.25s. So for wreckage the original maxEnergy or size does not matter.
wreckage generation is suppresses when FPS drops below 8.
Total alloy is limittated to 256.

Posted: Tue Jan 27, 2009 3:58 pm
by Cmdr Wyvern
Hmmm... Griff, an idea:

You could try wrapping hot metal shaders onto wreckage objects and the 'fridge door'.

Posted: Tue Jan 27, 2009 10:28 pm
by Thargoid
Griff wrote:
That's really good of you! I'll get busy making some objects and looking at your scripts and i'll fire off a Thargoid shaped distress flare if i get into problems with the scripting (this will most likely happen)
Just to save the effort and let more beautiful graphics flow, have a look at the ship in the OXP link I've PM'd you. It's also via death_action rather than scripting, as there seems to be a glitch there that I wasn't expecting (this.shipDied seems to be getting recurrently called when the ship dies for those interested) - I'm going to look into that a bit more tomorrow for my own interest.

But let me know if the example is more what you were thinking of. It's a nice juicy explosion plus some bits that fly off and then explode, and a single mangled chunk that survives and remains stationary but tumbling (although it'd be simple to make it move if desired).

The randomness of the explosions is along the same lines as McLane's above and the Hawksbill explosions that I mentioned before.

Posted: Wed Jan 28, 2009 5:44 pm
by Frame
Thats real funny, i already got that going for that ship I showed in the screenshots some time ago. I also showed a picture of it in

I did however al ready have the ship broken up into 4 parts
used a random math selector to decide on how many parts to spawn
when the ship died...

you can see a picture of it here in this thread.. well there are 3...

https://bb.oolite.space/viewtopic.ph ... &start=405

I quote from that thread

"The model it self is broken down into 1 main model and 3 Subentities, which i decieded to use for wrecks. that are spawned when the ship dies..