Flaming Wreckage! - Possible with scripting?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2475
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Flaming Wreckage! - Possible with scripting?

Post 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.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post 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.
User avatar
ZygoUgo
---- E L I T E ----
---- E L I T E ----
Posts: 406
Joined: Mon Nov 17, 2008 4:15 pm
Location: Blighty

Post 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.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2475
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post 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)
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post 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.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2475
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post 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)
User avatar
tomsk
Dangerous
Dangerous
Posts: 66
Joined: Sun Jan 11, 2009 12:21 pm
Location: under my Cobra's hood...

Post 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:
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Flaming Wreckage! - Possible with scripting?

Post 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.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2475
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post 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
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8501
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post 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"...
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post 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.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post 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.
User avatar
Cmdr Wyvern
---- E L I T E ----
---- E L I T E ----
Posts: 1649
Joined: Tue Apr 11, 2006 1:47 am
Location: Somewhere in the great starry void

Post by Cmdr Wyvern »

Hmmm... Griff, an idea:

You could try wrapping hot metal shaders onto wreckage objects and the 'fridge door'.
Running Oolite buttery smooth & rock stable w/ tons of eyecandy oxps on:
ASUS Prime X370-A
Ryzen 5 1500X
16GB DDR4 3200MHZ
128GB NVMe M.2 SSD (Boot drive)
1TB Hybrid HDD (For software and games)
EVGA GTX-1070 SC
1080P Samsung large screen monitor
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post 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.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post 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..
Bounty Scanner
Number 935
Post Reply