Home   Help Search Login Register  

Author Topic: Fuelgauge for all vehicles  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

hermano

  • Guest
Fuelgauge for all vehicles
« on: 29 Jun 2005, 18:12:59 »
Today I ran out of fuel as there is no fuel gauge for the cars in Operation Flashpoint. I decided this was the last time and wrote a little script that will display a fuel gauge graphic according to the fuel status to the player if he is the driver of a vehicle. I don't expect any problems, it seems to run smooth.
Here's a little sample mission, would be nice if somebody had a look.
h

Offline Pilot

  • Contributing Member
  • **
Re:Fuelgauge for all vehicles
« Reply #1 on: 29 Jun 2005, 22:30:02 »
I thought OFP had a fuel guage for vehicles in the upper left hand corner.  I never noticed they didn't ::)  This guage is pretty good, although I do have two suggestions:
1: If possible, make the fuel guage stay up indefinately if the player is in the vehicle.  It is kind of strange to see it fade out as I'm driving.

2: Right now the guage reads 5 positions.  While I know more positions would mean more pics, I suggest you add 2-4 more positions in.

Other than that, good work!

-Student Pilot

hermano

  • Guest
Re:Fuelgauge for all vehicles
« Reply #2 on: 30 Jun 2005, 15:04:04 »
Thanks for having a look, Student Pilot!
I cannot see a fuel status bar for most vehicles, I don't think there's anything special in my ofp installiation, so I supposed that would be true for anybody else. I should check the cadet mode, maybe it will be displayed then?
I had another look how the standard  fuel (and ammo bars etc.) are done, it seems bis used another mode unlike cutrsc and dialogues, yet I could not figure out how to use that. Right now I use cutrsc since dialogues interrupt the user input, cutrsc images fade in and will stay for only for a specified time. I would like to find a way to use the original bis resources, ammo cargo, fuel cargo and repair cargo could be displayed then too. If not then I will change the gauge according to your suggestions, thanks again.
h

Offline Pilot

  • Contributing Member
  • **
Re:Fuelgauge for all vehicles
« Reply #3 on: 30 Jun 2005, 15:29:17 »
Quote
I cannot see a fuel status bar for most vehicles,
Neither can I.  I don't think the "car" class of vehicles has the fuel and armor guage.

Quote
Right now I use cutrsc since dialogues interrupt the user input, cutrsc images fade in and will stay for only for a specified time.
You can make them stay up for a very long time, just change the duration value to a larger value, ex:
Code: [Select]
duration=99999;or some other ridiculously high number.

Quote
I would like to find a way to use the original bis resources, ammo cargo, fuel cargo and repair cargo could be displayed then too.
Yes, that would be the best thing if possible.  However, AFAIK, the BIS bar-guages are hard-coded into the engine and aren't accessible by scripters.  Someone correct me if I am wrong.

-Student Pilot

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Fuelgauge for all vehicles
« Reply #4 on: 03 Jul 2005, 00:00:49 »
The BIS gauges must be added via a unit's config. It would be possible to have them for cars (or people for that matter), but you would need to make a new addon, or else edit the main config.

I actually like how the cutresources fade away. Since they only have limited positions, it would look funky if it stayed up all the time, and "jumped" positions every so often. That said, it would be nice to have as many gauge positions as possible.


Looking inside the script, I'm a little confused about what the _fuel variable is for. Why cant you just compare _realFuel to fuel? Okay, I think it is so that the gauge only displays when a certain amount of fuel is used, but why not just check to see if the difference between current and last fuel is above a certain amount?

I also see a bug in the script. The second @ condition doesn't seem to care if the player leaves his vehicle. It seemed to work fine in-game, but it looks fishy...

I'd suggest running this script via a "getin" eventhandler, added to each vehicle. That way, the script only runs when the player gets into a vehicle.

Looks good though. :)

HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

hermano

  • Guest
Re:Fuelgauge for all vehicles
« Reply #5 on: 04 Jul 2005, 16:40:30 »
Thanks Student, Barron.

Quote
You can make them stay up for a very long time, just change the duration value to a larger value, ex:
Code:
duration=99999;
or some other ridiculously high number.
Yeah, I was thinking about that, also the fade could be very short. I suppose you can make it fade away by calling another (empty) cutrsc.

Quote
The BIS gauges must be added via a unit's config. It would be possible to have them for cars (or people for that matter), but you would need to make a new addon, or else edit the main config.
I wanted to avoid that, a changed main config would collide with other mods afaik.

Quote
I actually like how the cutresources fade away. Since they only have limited positions, it would look funky if it stayed up all the time, and "jumped" positions every so often. That said, it would be nice to have as many gauge positions as possible.
Well, I think adding 4 more position for a total of 9 should be sufficient.

Quote
Looking inside the script, I'm a little confused about what the _fuel variable is for. Why cant you just compare _realFuel to fuel? Okay, I think it is so that the gauge only displays when a certain amount of fuel is used, but why not just check to see if the difference between current and last fuel is above a certain amount?

I also see a bug in the script. The second @ condition doesn't seem to care if the player leaves his vehicle. It seemed to work fine in-game, but it looks fishy...

I'd suggest running this script via a "getin" eventhandler, added to each vehicle. That way, the script only runs when the player gets into a vehicle.
Sorry, I already changed the script. But if I remember right the second @ condition shouldn't cause a problem since there's a goto to the first @ condition (waiting for the player to be in a vehicle).
I decided to use the method using modulo and needed the _fuel variable (at least in an early state of development), checking if the fuel has changed to a amount would work also (@abs(fuel-_realfuel)>0.2). I don't think there is a huge difference in processor time. I think I'll change that.
I also should use the getin eventhandler to start the script as you suggested.

h