Posts: 3,934
Threads: 353
Joined: Jan 2010
Reputation:
0
I'm revamping my old vehicle system, the fuel system is one of my top priorities to make a lot more realistic, by adding consumption, and capacity for each vehicle type.
How would I go about doing something like this? The maths, formulas or whatever you'd have to use.
Thanks.
Posts: 515
Threads: 5
Joined: Jun 2007
Reputation:
0
I would create an array which holds the consumption (km/liter or mi/gallon) for each vehicletype (e.a. motorbikes, small cars, streetcars, performancecars, trucks, small/large planes, et cetra);
Posts: 3,934
Threads: 353
Joined: Jan 2010
Reputation:
0
Yeah, I already have that, holding both MPG & Capacity, I'd like to know how I would actually go about making it work, the array is in order of the vehicle ids.
Posts: 1,241
Threads: 67
Joined: Dec 2013
Create a function which will count kilometers or meters the vehicle did pass, After that, You can set the fuel improvement, Let's say if vehicle go more than 50 kilometers NoFuel = 1; I did use something like that in past.
Posts: 3,934
Threads: 353
Joined: Jan 2010
Reputation:
0
Ah, so for example, the the Landstalkers MPG is 25 & the capacity is 70. When the vehicle goes past 25 kilometers, i'd take 1 away from the fuel variable?
Posts: 1,241
Threads: 67
Joined: Dec 2013
Well that's a suggestion but yes it work like that.
Or you can create a timer which will run after the player did pass some time you choose in vehicle and when the timer runs it will take from the vehicle an ammont of fuel.
Posts: 515
Threads: 5
Joined: Jun 2007
Reputation:
0
The x, y, z are created right in that timer (its used for GetVehiclePos to get the current position) and the lastx, lasty, lastZ are stored in the VehicleInfo-array/enum:
[VehicleInfo][VehicleID][LastX]
Posts: 3,934
Threads: 353
Joined: Jan 2010
Reputation:
0
Ah, right! So it's pretty much where the person parked the vehicle?