Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Reprobator on March 10, 2011, 08:59:09 am

Title: Vital flag for subsystem
Post by: Reprobator on March 10, 2011, 08:59:09 am
Hi,
I was wondering if there was a possibility to add a feature to subsystems, like a "vital explodes' and a "vital play dead" flag that would explodes or disable the whole parent ship when the subsystem is destroyed for example :

"Vital play dead" case :
I shoot a fighter , i target and destroyed it's 'cockpit' subsystem, as i have a "vital playdead" flag on the ship's subsystem  table well the pilots is killed so the IA does not move anymore (or continue on it's last vector/speed) if it's the player who was shot on its subsystem well he receive a game over.

"Vital explodes" case :
On a cap ship i have a "nuclear power plant" subsystem (that's just an example uh) and i want that when someone shoot that subsystem the entire capship goes to boom regardless it's remaining hitpoint.

I realize that it could be achieve in Fred via sexp , but having to do it for everyship and every mission would be quite... heavy.

I hope I've explain my self well  ;7
Title: Re: Vital flag for subsystem
Post by: General Battuta on March 10, 2011, 09:11:30 am
You could do this in FRED with just one event, you know.  :nervous: I mean I know you know it can be done in FRED, you said that, but you don't even have to have a separate event for each ship.
Title: Re: Vital flag for subsystem
Post by: Reprobator on March 10, 2011, 09:21:38 am
oh right then , my request is already out of date .
Title: Re: Vital flag for subsystem
Post by: General Battuta on March 10, 2011, 09:26:48 am
Your setup would be

when-argument
any-of
(a list of every ship you want to blow up when subsystem Reactor is destroyed)

subsystem-destroyed-delay
<argument> - this argument should go wherever the SEXP would normally take a ship name
0
Reactor

self-destruct (or sabotage-subsystem, hull, 100)
<argument>

invalidate-argument

Set trigger count to the number of ships that could possibly blow up this way.
Title: Re: Vital flag for subsystem
Post by: headdie on March 10, 2011, 09:29:38 am
notes taken and saved, thanks Battuta
Title: Re: Vital flag for subsystem
Post by: Reprobator on March 10, 2011, 09:31:42 am
Thank you very much, i'm gonna try it.
Title: Re: Vital flag for subsystem
Post by: Sushi on March 10, 2011, 09:33:57 am
Your setup would be

when-argument
any-of
(a list of every ship you want to blow up when subsystem Reactor is destroyed)

subsystem-destroyed-delay
<argument> - this argument should go wherever the SEXP would normally take a ship name
0
Reactor

self-destruct (or sabotage-subsystem, hull, 100)
<argument>

invalidate-argument

Set trigger count to the number of ships that could possibly blow up this way.

TIL a valuable FREDding trick.  :yes:
Title: Re: Vital flag for subsystem
Post by: zookeeper on March 10, 2011, 10:06:44 am
Now, this is almost entirely off-topic, but wouldn't it be great if a mod could define global mission events which would automatically get inserted into every mission played using that mod? :nervous: SEXP implementations of mod-wide gameplay mechanic changes like this might work great otherwise, but it's really unwieldy to copypaste the event into every mission you'll ever have in your mod.
Title: Re: Vital flag for subsystem
Post by: Dragon on March 10, 2011, 10:09:09 am
You may use a template.
Just make a mission with every event you want to be used everywhere and import these events into each mission you make.
Title: Re: Vital flag for subsystem
Post by: zookeeper on March 10, 2011, 10:15:36 am
You may use a template.
Just make a mission with every event you want to be used everywhere and import these events into each mission you make.

And what do you do when you need to fix or change something in that event, or add a new one, as you'd inevitably need to do?
Title: Re: Vital flag for subsystem
Post by: Dragon on March 10, 2011, 10:17:13 am
You'd have to do this manually, so it'd be good to test the template and make sure it contains everything you want.
Alternatively, use scripting.
Title: Re: Vital flag for subsystem
Post by: zookeeper on March 10, 2011, 10:30:49 am
You'd have to do this manually, so it'd be good to test the template and make sure it contains everything you want.
Alternatively, use scripting.

Well... I guess that means you think it's a good idea then. Scripting is a whole new skillset to learn and it can't really do but a small part of what SEXPs can do.
Title: Re: Vital flag for subsystem
Post by: Iss Mneur on March 10, 2011, 02:37:42 pm
You'd have to do this manually, so it'd be good to test the template and make sure it contains everything you want.
Alternatively, use scripting.

Well... I guess that means you think it's a good idea then. Scripting is a whole new skillset to learn and it can't really do but a small part of what SEXPs can do.
Scripting can to everything that SEXPs can do, by virtue of scripting able to call arbitrary SEXPs.  Unfortunately I don't recall the name of the function right now.
Title: Re: Vital flag for subsystem
Post by: zookeeper on March 10, 2011, 03:30:13 pm
Well... I guess that means you think it's a good idea then. Scripting is a whole new skillset to learn and it can't really do but a small part of what SEXPs can do.
Scripting can to everything that SEXPs can do, by virtue of scripting able to call arbitrary SEXPs.  Unfortunately I don't recall the name of the function right now.

I guess I should have said events, not SEXPs: scripts can't create mission events, and I'm not entirely sure if scripts can perfectly simulate event trigger conditionals by running mn.evaluateSEXP every frame. If they can, then yes, you're right. At that point you'd only need to figure out the undocumented and messy syntax for doing that.
Title: Re: Vital flag for subsystem
Post by: karajorma on March 10, 2011, 05:15:03 pm
You'd have to do this manually, so it'd be good to test the template and make sure it contains everything you want.

However if you're sensible and make sure your templated sections are always in the same part of the mission file you could use something like winmerge (http://winmerge.org/) to make copying them over easier.
Title: Re: Vital flag for subsystem
Post by: zookeeper on March 11, 2011, 01:18:37 am
It should also be pretty simple to write a Lua script which goes and automatically adds the contents of a pre-defined file to missions/*.fs2 when the game starts (meaning you'd never have to copy the events around manually), but somehow I think people might not be comfortable with the risk of something going wrong.
Title: Re: Vital flag for subsystem
Post by: Tomo on March 12, 2011, 05:20:21 am
This thread has got me thinking that some kind of "Include Mission Chunk" option would be useful.

Not sure whether that ought to be FRED-side or on mission load - both have advantages and disadvantages.