Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: mjn.mixael on May 17, 2012, 11:33:29 am

Title: Conditions For Ship Debris (Or Lack Thereof)
Post by: mjn.mixael on May 17, 2012, 11:33:29 am
So, I've been working with Admiral MS on his fantastic shipsave script to iron out some bugs. One thing that stands out is how the script destroys ships if necessary. The script will move the ship far away and use self-destruct (which we might change to ship-vaporize).

However, in cases like this we were thinking how it would be helpful to have a way to tell FSO when to not create debris or debris shards at all. Because this script has the potential to do a lot of things all at once, we are trying to minimize the amount of work FSO has to to during that time. (We use ship-vanish if the ship doesn't need to register as destroyed or departed.)

I was talking with Goober and a few ideas came out that I thought were worth discussing. What are the thoughts on...

1: Doing a distance check and if the destroyed ship is so far from the player/camera to not create the debris?

2: Adding an optional flag to self-destruct (or ship-vaporize) to not create debris or debris shards?
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: The E on May 17, 2012, 11:45:46 am
I like the second idea more. Even far-off debris may have an impact on the battlefield; Sathanases that have been blown up should register.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Dragon on May 17, 2012, 11:51:55 am
I also like the second idea. It could also be used whenever there's a story or balance related reason for ship not leaving debris. In general, it seems both very practical and a better solution performance-wise.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: FreeSpaceFreak on May 21, 2012, 01:29:56 pm
Doesn't the "vaporize on death" (or something) flag already kinda do that? IIRC, it makes the ship just disappear on destruction, no explosions or debris. So basically, you'd just have the script set the 'vaporize on death' flag on (not sure if that's possible mid-mission?) and then selfdestruct.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on May 21, 2012, 01:59:06 pm
I'm pretty sure LUA scripting can't access most of the settings in the ship editor and these are usually unchangeable in-mission. So obviously I don't want a ship to have a vaporize flag when it's somwhere in the mission and may explode. It's even a problem to blow up a ship with LUA scripting and have the game register it as destroyed without the self-destruct sexp - ship:kill(ship) fails to do that despite its description telling me it should and setting hull to 0 hitpoints left doesn't kill it.
So to me the best solution seems to be self-destruct with an additional flag especially cause it can be used in Fred as well.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Valathil on May 21, 2012, 02:10:01 pm
or fixing the lua function
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on May 21, 2012, 02:58:11 pm
Vaporized ships don't "just disappear".  They still go through a (shorter) death roll, they still have explosions, and they still create debris.  It's just tiny shards instead of chunks.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Cyborg17 on May 21, 2012, 06:04:58 pm
I'm pretty sure LUA scripting can't access most of the settings in the ship editor and these are usually unchangeable in-mission. So obviously I don't want a ship to have a vaporize flag when it's somwhere in the mission and may explode. It's even a problem to blow up a ship with LUA scripting and have the game register it as destroyed without the self-destruct sexp - ship:kill(ship) fails to do that despite its description telling me it should and setting hull to 0 hitpoints left doesn't kill it.
So to me the best solution seems to be self-destruct with an additional flag especially cause it can be used in Fred as well.

Guardian until the right moment?
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on May 24, 2012, 12:51:54 am
Guardian until the right moment?
I have no idea why and where guardian should help.

There are some other uses for a no-debris flag as well besides the script and considering that vaporize still creates debris I think its a good idea to add this function.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Cyborg17 on May 24, 2012, 01:08:35 am
I have no idea why and where guardian should help.

It sounded you were trying to get around a ship exploding at the wrong time when you said:

Quote
So obviously I don't want a ship to have a vaporize flag when it's somwhere in the mission and may explode.

I think I just misunderstood.  NVM
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: mjn.mixael on July 30, 2012, 10:20:57 am
 :bump:

Can I make this an official request? I could really use the ability to have an optional flag with self-destruct or ship-vaporize (doesn't matter which one) to not create ship debris or explosion effects at all. Just make the ship disappear and count it as destroyed.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on July 30, 2012, 12:51:07 pm
Along with that, I have discovered that Scroll needs a way to turn off subsystems without "destroying" them (playing the explosion and sound effect).
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: mjn.mixael on July 30, 2012, 01:01:24 pm
you mean like to make the modelled subsystem disappear with out going boom?
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on July 30, 2012, 02:27:36 pm
Yep.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on August 09, 2012, 05:56:15 pm
So here is my version of a no-debris shipflag including a sexp to set it and the code changes to fast forward through destruction so it looks like ship vanish.

Feedback is very much appreciated cause this is my first time changing some code that is actually relevant for the whole game. The names of the variables and functions might be misleading as well so if they should be changed tell me.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on August 09, 2012, 11:32:54 pm
That's a good effort, but I really don't think a flag is appropriate for this.  Ship-vanish isn't implemented using a flag, for example.  It would be better, and simpler, to just make this a sexp in the vein of self-destruct, maybe called "destruct-no-debris".  Instead of fast-forwarding through the destruction code, it would be better to just call the remove-ship-from-mission code and set the mission log entry.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on August 10, 2012, 06:05:48 am
My first idea how to do this was to copy the ship-vanish SEXP, rename it and add the mission log entries.
Why I wanted to do it different is I wanted to get it to work in multiplayer and I thought that someone might want to use that option on ships that have been regularly destroyed during gameplay.

If it is unlikely that my first patch gets accepted, here is another patch for a new SEXP called ship-vanish-destroyed to do the job (ship_vanish_destroyed.patch). It has the same disadvantages of ship-vanish like vanishing all docked ships, removing the dots in the wingmen status hud gauge and not working in multiplayer. That's the reason the sexp should be named ship-vanish-xxx.

During testing I got an assertion related to builtin-messages and I was able to reproduce it even with the normal ship-vanish sexp under the same conditions. I made an additional patch to fix that (ship_vanish.patch).

[attachment removed and sold on the black market]
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: mjn.mixael on August 10, 2012, 08:09:47 am
the second patch won't work because it does things like remove the wingman dots instead of marking destroyed. the flag was better.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on August 10, 2012, 09:14:58 am
Are you often on IRC, Admiral MS?  We could work through an implementation on Saturday.
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on August 10, 2012, 09:37:21 am
Whenever I'm at home, IRC is usually running. Saturday could be fine depending on your time-zone (I am in CET) and when you do have time. My nickname is "Ams".
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on August 17, 2012, 04:49:55 pm
Made a new patch that adds destroy-instantly and destroy-subsys-instantly sexps to destroy things without sound and explosion effect. Again I'm open for feedback if someone can review my patch.

[attachment removed and sold on the black market]
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on August 19, 2012, 04:04:04 am
I've only skimmed it so far, but I don't like the idea of copying do_subobj_destroyed_stuff, especially since it's a big function.  Can you instead modify do_subobj_destroyed_stuff with a no_explosion parameter, and just skip the things associated with the special effects?
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Admiral MS on August 21, 2012, 03:28:45 pm
Can you instead modify do_subobj_destroyed_stuff with a no_explosion parameter, and just skip the things associated with the special effects?

Did that, the new patch is attached to my post.

[attachment removed and sold on the black market]
Title: Re: Conditions For Ship Debris (Or Lack Thereof)
Post by: Goober5000 on August 26, 2012, 09:49:07 pm
Well done. :yes:  I just did a code review and a playtest, and it passed with flying colors. :)

Committed in r9145.