Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Legate Damar on July 15, 2012, 10:23:49 pm

Title: Shield status
Post by: Legate Damar on July 15, 2012, 10:23:49 pm
I don't know if this requires modifying the code or not, but could there be a way to display the percentage of shields on a ship when you target it, or the percentage of your own shield strength? This would be very useful in certain circumstances.
Title: Re: Shield status
Post by: mjn.mixael on July 15, 2012, 10:26:54 pm
You can do this with sexps and custom hud gauges
Title: Re: Shield status
Post by: Nuke on July 15, 2012, 10:31:28 pm
or scripting for that matter (this gives you better rendering options, and less hud integration though).
Title: Re: Shield status
Post by: Legate Damar on July 15, 2012, 10:46:27 pm
You can do this with sexps and custom hud gauges

Is there a tutorial for this?

Also would it be possible for the SCP team to make it a standard feature that's active by default?
Title: Re: Shield status
Post by: mjn.mixael on July 15, 2012, 11:05:38 pm
I highly doubt SCP will make this a "standard feature that's active by default" simply because it's pretty simple to do with the existing tools.
Title: Re: Shield status
Post by: Legate Damar on July 15, 2012, 11:19:10 pm
Well I've never seen it done in any mod I've played...
Title: Re: Shield status
Post by: mjn.mixael on July 15, 2012, 11:59:32 pm
That only means that no one else has needed or wanted to do it. It doesn't mean it's not doable.
Title: Re: Shield status
Post by: Legate Damar on July 16, 2012, 12:11:29 am
Well my point was that without an example to look at I wouldn't know where to start.
Title: Re: Shield status
Post by: MatthTheGeek on July 16, 2012, 12:34:17 am
If you want us to make your mod for you...
Title: Re: Shield status
Post by: mjn.mixael on July 16, 2012, 12:36:08 am
It's probably a good time to open up FRED, explore the events and sexps, and try some things out.

With SEXPs, a little guesswork should get you in the ballpark. You want to display the shields left for the ship targeted as a percentage. So, you need to capture which ship is being targeted and you need to capture it's shield status. Capturing the shield status of a ship and saving that to a variable is super easy. Anyone moderately familiar with FRED should be able to do that. However, capturing the shield status of the ship being targeted is a bit more difficult. I'll give you a hint, though. When-Argument is probably the best way to do it. I know there are tutorials on the FREDing board or on the Wiki about when-argument sexps.

Get that figured out and you'll end up with the shield percentage of the targeted ship as a variable. Use a trigger count to set the variable every frame. To display it, simply convert the variable to a string (there's a SEXP for that), and display it with a custom HUD gauge by using HUD-set-text. There are a few mods out that use custom HUD gauges (BtA Demo, JAD 2.21).. look at one of those to figure out how that works.

Scripting will be the more universal method, but I don't know enough LUA to help you there.
Title: Re: Shield status
Post by: Legate Damar on July 16, 2012, 01:11:06 am
Thank you.
Title: Re: Shield status
Post by: zookeeper on July 16, 2012, 02:03:01 am
the percentage of shields on a ship when you target it

I don't even know what it he wants here, considering that the HUD already displays information about the enemy's shields in at least 3 different ways, but apparently it's clear to everyone else. :doubt:
Title: Re: Shield status
Post by: MatthTheGeek on July 16, 2012, 02:19:54 am
He wants to show the numerical percentage value of remaining shields. Like, with figures and stuff.
Title: Re: Shield status
Post by: zookeeper on July 16, 2012, 02:21:11 am
He wants to show the numerical percentage value of remaining shields. Like, with figures and stuff.

But that's already shown underneath the reticle, is it not?
Title: Re: Shield status
Post by: MatthTheGeek on July 16, 2012, 02:23:03 am
Nope, that's the percentage of hull remaining. The shield info is just the 4 things around it, which is a purely visual info and not a numerical one.
Title: Re: Shield status
Post by: zookeeper on July 16, 2012, 03:21:32 am
Nope, that's the percentage of hull remaining. The shield info is just the 4 things around it, which is a purely visual info and not a numerical one.

Right. Got it. :D
Title: Re: Shield status
Post by: assasing123 on July 16, 2012, 02:55:36 pm
can this modified to show the % shield left of your own ship shields per shield bank? given a ship has 4 shield banks, to know how much shields do it has left on each one of the banks? and what about absolute readouts?
Title: Re: Shield status
Post by: MatthTheGeek on July 16, 2012, 03:14:56 pm
Yes it can :
You can do this with sexps and custom hud gauges
Title: Re: Shield status
Post by: Legate Damar on July 16, 2012, 04:25:45 pm
I'm having a bit of trouble implementing this. Can I do it all in FRED or do I need to mess with the hud_gauges.tbl?
Title: Re: Shield status
Post by: TwentyPercentCooler on July 16, 2012, 04:53:55 pm
Didn't the old Freespace 1 alpha version have a percentage-based shield system display on the HUD? I seem to remember that it did. If so, I would suggest getting your hands on that mission and picking it apart to see how they did it. Might help a bit.
Title: Re: Shield status
Post by: Droid803 on July 16, 2012, 05:16:07 pm
I'm having a bit of trouble implementing this. Can I do it all in FRED or do I need to mess with the hud_gauges.tbl?

You need hud_gauges.tbl
Title: Re: Shield status
Post by: mjn.mixael on July 16, 2012, 05:56:55 pm
Didn't the old Freespace 1 alpha version have a percentage-based shield system display on the HUD? I seem to remember that it did. If so, I would suggest getting your hands on that mission and picking it apart to see how they did it. Might help a bit.

I highly doubt that was done in FS1 Alpha with sexps. It was probably a code chunk that was later removed or changed.
Title: Re: Shield status
Post by: Legate Damar on July 16, 2012, 06:09:09 pm
I'm having a bit of trouble implementing this. Can I do it all in FRED or do I need to mess with the hud_gauges.tbl?

You need hud_gauges.tbl

Eh... :doubt:

I'll fiddle around with it later and figure it out.
Title: Re: Shield status
Post by: IronBeer on July 16, 2012, 06:13:36 pm
Just to chime in with a sort of general FREDding statement: learning how to do conditionals in FRED will be like becoming a FRED Super-Saiyan. I kid you not; the things you can do with conditionals are a helluva lot stronger and elegant than any other comparable solution. In my work for BtA, Mjn helped me learn how to use conditionals, and already the things I can do with SEXPs are much more complex than anything I previously thought possible.

Gauges, however, are still kind of arcane. Maybe try popping onto the IRC channel for some "live" help.
Title: Re: Shield status
Post by: Droid803 on July 16, 2012, 06:17:10 pm
Gauges are not arcane if you just want to display a string from a variable or something, it's actually rather straightforward.
Hardest part is figuring out where to place the goddamn thing.