Flaming Wreckage! - Possible with scripting?
Moderators: winston, another_commander
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Flaming Wreckage! - Possible with scripting?
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.
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.
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.
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.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
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 Maybe scoop it for alloys?
Never did like the fridge door that comes as standard.
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 Maybe scoop it for alloys?
Never did like the fridge door that comes as standard.
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Fridge door!
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)
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)
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.
At the moment the burning fuel there explodes immediately, but adding a pause into the AI to delay the explosion there is trivial.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Flaming Wreckage! - Possible with scripting?
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?Griff wrote:.... i'm a bit dissapointed by the grey rectangle that gets left behind as debris - i want flaming, twisted 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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
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
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
Would go nicely with my idea of secondary trading via "oobay"...Griff wrote:Fridge door!
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)
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.
- Commander McLane
- ---- 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:
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:
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.
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 = (); };
}
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.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
As mcLane states it the amount of debris related to the sips mass: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 -
Code: Select all
int n_alloys = floor(sqrtf(sqrtf(mass / 25000.0)));
Code: Select all
int n_wreckage = (n_alloys < 3)? n_alloys : 3;
wreckage generation is suppresses when FPS drops below 8.
Total alloy is limittated to 256.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Cmdr Wyvern
- ---- E L I T E ----
- Posts: 1649
- Joined: Tue Apr 11, 2006 1:47 am
- Location: Somewhere in the great starry void
Hmmm... Griff, an idea:
You could try wrapping hot metal shaders onto wreckage objects and the 'fridge door'.
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
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
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.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)
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.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
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..
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
Number 935