Author Topic: HUD Gauge question  (Read 954 times)

0 Members and 1 Guest are viewing this topic.

Everyone is familiar with Diaspora.  I'm working on a mod to make fuel a limited resource for the player ship.  I've already got a SEXP method of doing this and I created two custom gauges that will display the word FUEL: and then have the count down below it in four digits.  It's checking the throttle position and subtracting that from a variable every second.

So depending on throttle speed you burn fuel at a different rate, up to 100 units/second at full throttle.  That's simple math at that point to determine how much fuel you want the ship to have and set the variable at the appropriate amount.

 It works well so far, but I really want to use a HUD gauge to represent the fuel quantity.  I had something like the afterburner fuel bar in mind just on the opposite side to balance out the HUD, and the two primary consumables fuel and ammo would be next to each other.

I don't know how to get a custom gauge to use a graphic and display that on the HUD.  Any help would be appreciated.

I figured out how to do this with some PNG's, and EFF and SEXP's and table edits.

Set up a new custom gauge in your FuelGauge-hdg.tbm, set it to use a custom graphic such as col_miscbargauge_fuel.

Now have an EFF file with say eleven frames if you want to keep it simple.  Make 11 PNG files with the same name col_miscbargauge_fuel_0000.png through 0010.png and edit the graphic to reduce your fuel by 10% each time.

Then you can use the variables that were set up earlier in a mission to read FuelQuantity and have it display a graphic each time a <= value is reached using the SEXP set-hud-frame.

In this way, as the variable is reduced once it reaches each threshold a new frame is displayed until the variable reaches <=0 which displays the 11th frame, out of fuel.  If you want it more complex, add more frames to the EFF and create more PNG's.

In my test example I had the FuelQuantity variable set at 30000 which at 100% throttle is 300 seconds or five minutes worth of fuel.  In the one SEXP I'm reducing the variable by the throttle setting so this will vary fuel consumption based on your throttle setting/speed.  Then there is a When SEXP checking for every 10% drop and changing the graphic to the next frame.  This simulates the fuel bar dropping.  You also have a readout of actual fuel quantity divvied by 100 that you can place wherever you like on the hud.  I have it below the fuel bar.

And lastly, what happens when you run out of fuel.  Force Glide, Player use AI, set goal playdead, show a message you're out fuel, kill glow points and thrusters, then after a delay, end mission fade out ect.

[attachment stolen by Russian hackers]

And what it can look like.

[attachment stolen by Russian hackers]


Offline niffiwan

  • 211
  • Eluder Class
nice work!  :yes:

Just FYI, if you don't like all the loose EFF files hanging around, you could convert them to an APNG and just have a single file.
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
Debian Packages (testing/unstable): Freespace2 | wxLauncher
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

I presume that's an animated PNG?  So you're saying I could convert the loose PNG files into a single APNG?  It would of course have the frames, and the SEXP will call the correct frame?  How would I go about converting them to an ANPG?  I own Photoshop and I use frequently.

*EDIT Never mind, clicked your link.

Thank you very much!
« Last Edit: March 03, 2017, 10:49:38 pm by Nightstorm »