Jump to content

Recommended Posts

This little script for the mission file let you decide how long vehicles will be able to drive with one full fuel tank and how long a vehicle can let his engine on while standing till one fuel tank is depleted.

 

You can download the rar file, extract it and put the scripts folder in your missionfile.

If you don't have a initPlayerLocal.sqf, just put the one provided in. If you already have a initPlayerLocal.sqf, then copy the content from the provided one to yours.

 

You can adjust the values in the kp_fuel_consumption.sqf

 

The script adjust the depletion every second on the machine of the driver or last driver if there is no new driver.
 

Changelog:

08.02.2017

  • Differs between "standing", "normal speed" and "turbo"
  • "turbo" -> If you use "Shift+W" to increase the speed above the speed you could reach with only "W" for acceleration
  • Moved from init.sqf to initPlayerLocal.sqf
  • Configuration moved inside the sqf instead of parameters at execVM

 

Spoiler

 


/*
kp_fuel_consumption.sqf
Author: Wyqer
Website: www.killahpotatoes.de
Date: 2017-02-02

Description:
This script handles the fuel consumption of vehicles, so that refueling will be necessary more often.

Parameters:
_this select 0 - OBJECT - Vehicle

Method:
execVM

Example for initPlayerLocal.sqf:
player addEventHandler ["GetInMan", {[ _this select 2] execVM "scripts\kp_fuel_consumption.sqf";}];
*/

private ["_kp_neutral_consumption","_kp_normal_consumption","_kp_max_consumption"];

/*
CONFIG
*/
// Time in Minutes till a full tank depletes when the vehicle is standing with running engine
_kp_neutral_consumption = 180;
// Time in Minutes till a full tank depletes when the vehicle is driving
_kp_normal_consumption = 60;
// Time in Minutes till a full tank depletes when the vehicle is driving at max speed
_kp_max_consumption = 40;

/*
DO NOT EDIT BELOW
*/

if (isNil "kp_fuel_consumption_vehicles") then {
	kp_fuel_consumption_vehicles = [];
};

if (!((_this select 0) in kp_fuel_consumption_vehicles)) then {
	kp_fuel_consumption_vehicles pushBack (_this select 0);
	while {local (_this select 0)} do {
		if (isEngineOn (_this select 0)) then {
			if (speed (_this select 0) > 5) then {
				if (speed (_this select 0) > (getNumber (configFile >> "CfgVehicles" >> typeOf (_this select 0) >> "maxSpeed") * 0.9)) then {
					(_this select 0) setFuel (fuel (_this select 0) - (1 / (_kp_max_consumption * 60)));
				} else {
					(_this select 0) setFuel (fuel (_this select 0) - (1 / (_kp_normal_consumption * 60)));
				};
			} else {
				(_this select 0) setFuel (fuel (_this select 0) - (1 / (_kp_neutral_consumption * 60)));
			};
		};
		uiSleep 1;
	};
	kp_fuel_consumption_vehicles deleteAt (kp_fuel_consumption_vehicles find (_this select 0));
};

 

 

 

 

 

Download via our community website

  • Like 7

Share this post


Link to post
Share on other sites

this is a pretty interesting subject.

It'd be kind of cool if you could modify this for cargo weight and such.

maybe adjust the speed threshold? 5 seems kind of low

Share this post


Link to post
Share on other sites

At the moment the threshold of 5 is only to check if someone is driving or standing with the vehicle.

 

But I've already thought about include the count of passengers or weight to the calculation with a multiplier.

Also some kind of "full speed" status where it consumes also something more per tick.

Share this post


Link to post
Share on other sites

Great idea so far. Tom_48_97 from BIS wrote his version based on speed variables. I think adding some of that into yours might help. http://tom4897.info/blog/2014/06/arma-3-scripting-increase-fuel-consumption/

 

Then maybe change to add some classnames  I could never get this one to work. It has to be exec on the client side.  I do like the acceleration parts. Easy enough to add weight cargo.

if !(_vh isKindOf "Wheeled_APC" || _vh isKindOf "Car" || _vh isKindOf "TANK" || _vh isKindOf "MRAP_01_base_F" || _vh isKindOf "B_MBT_01_base_F" || _vh isKindOf "B_APC_Wheeled_01_cannon_F" || _vh isKindOf "A3_Soft_F_Crusher_UGV" || _vh isKindOf "A3_Armor_F_EPC_MBT_01" || _vh isKindOf "B_MBT_01_TUSK_F" || _vh isKindOf "Truck_F" || _vh isKindOf "Car_F") Then {
                     if (speed _vh > 5 && speed _vh < 50) then {
                        _vh setFuel ((fuel _vh) - (tm4_prom_spotrebaPaliva select 1));
                     };
                     if (speed _vh > 50 && speed _vh < 120) then {
                        _vh setFuel ((fuel _vh) - (tm4_prom_spotrebaPaliva select 2));
                     };
                     if (speed _vh > 120) then {
                        _vh setFuel ((fuel _vh) - (tm4_prom_spotrebaPaliva select 3));
                     };
                     sleep .20;

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hey @breech99,

thanks for your reply and as I read it I've done some modifications this morning.

 

First an explanation of which thought I followed with this script:

My goal is not to have a "realistic" fuel consumption depending on hp, engine volume, rpm, etc. for each individual vehicle.

It is more the thought of the logistics to operate a vehicle. So the time you can drive is intended (at the moment) for every vehicle the same. But what differs is the amount of fuel it consumes. Relative consumption is always the same for each vehicle, but the amount in litres to refuel the vehicle differs on the fueltank size.

So to operate a Truck it consumes more litres from your resupply truck than operating a quadbike.

 

Now to the modification I made:

Settings are now in the sqf and not via parameters for the execVM.

Added the "max" consumption value for driving at 90% or above of the max speed of a vehicle.

Moved from init.sqf to initPlayerLocal.sqf

 

Example for a HEMTT:

Max speed for a HEMTT in cfgVehicles is 80 km/h.

If you drive the HEMTT with only "W" you reach about 70 km/h on a flat street -> normal consumption

If you use "Shift+W" you reach the max speed if 80 km/h -> max consumption as you increase speed above the normal value.

 

I've done some testings with different cars and mostly the maxSpeed - 10% is near the "only W" speed, so the max consumption fires only if you drive with "turbo".

It's a pitty that I haven't found a "normalMaxSpeed" value or something in the cfgVehicles which would return the maximum "only W" speed of a vehicle. Maybe I've missed that, so I would be thankful for any hint on this.

  • Like 2

Share this post


Link to post
Share on other sites
5 hours ago, Wyqer said:

Hey @breech99,

thanks for your reply and as I read it I've done some modifications this morning.

 

First an explanation of which thought I followed with this script:

My goal is not to have a "realistic" fuel consumption depending on hp, engine volume, rpm, etc. for each individual vehicle.

It is more the thought of the logistics to operate a vehicle. So the time you can drive is intended (at the moment) for every vehicle the same. But what differs is the amount of fuel it consumes. Relative consumption is always the same for each vehicle, but the amount in litres to refuel the vehicle differs on the fueltank size.

So to operate a Truck it consumes more litres from your resupply truck than operating a quadbike.

 

Now to the modification I made:

Settings are now in the sqf and not via parameters for the execVM.

Added the "max" consumption value for driving at 90% or above of the max speed of a vehicle.

Moved from init.sqf to initPlayerLocal.sqf

 

Example for a HEMTT:

Max speed for a HEMTT in cfgVehicles is 80 km/h.

If you drive the HEMTT with only "W" you reach about 70 km/h on a flat street -> normal consumption

If you use "Shift+W" you reach the max speed if 80 km/h -> max consumption as you increase speed above the normal value.

 

I've done some testings with different cars and mostly the maxSpeed - 10% is near the "only W" speed, so the max consumption fires only if you drive with "turbo".

It's a pitty that I haven't found a "normalMaxSpeed" value or something in the cfgVehicles which would return the maximum "only W" speed of a vehicle. Maybe I've missed that, so I would be thankful for any hint on this.

Very cool, I still think this is pretty cool.

Especially since anything written for things like fuel consumption beforehand is now either obsolete 

or broken.

 

  • Like 1

Share this post


Link to post
Share on other sites

To be honest, I've not looked really for a script before I wrote this one, so I don't know if there are maybe already better scripts or something. I like it to do these things myself, because this also trains in the sqf language and understanding.

 

I'll have a look tomorrow morning to another modification. Counting the passengers and adjust the consumption on that with a small multiplier.

Tried today already something with the getMass function, but well.... the items in the vehicle inventory and also crates in the ACE vehicle cargo don't have a physX Mass, so they're not added to the vehicle mass if loaded in.

If I miss something there, I'll would be thankful for any hint (yes, a hint... not a "here is a script for that", because I want to learn and not to copy) :)

  • Like 2

Share this post


Link to post
Share on other sites

Understandable.

Tricky tricky when it comes to finding things outside of ammo,backpacks,weapons,etc.

Crates even? That'll be weird. Especially since there is no real documentation for ACE and their cargo system to be scripted with the mission.

I know very possible to do just the weapons,items,ammo, etc.

ideas?

Share this post


Link to post
Share on other sites

 

That's totally awesome Wyqer. I like your ideas.  Something simple and that makes fuel consumption at least doubled. I read that the compressed scale of all of the game's islands are about one third to half scale in size. I think you are on the right track. Gives purpose for having fuel trucks and the battlefield commanders have to think about how they are going to deploy vehicles like tanks which think in terms of gallons per mile and not miles per gallon.  Large trucks have tons of fuel but it's nice to see the need to refuel. Arma2 I remember having to refuel a lot but in Arma3, I'm not seeing the need anymore. This is a fun feature to add.

Share this post


Link to post
Share on other sites

I agree with you Wyqer that it's not intended to simulate the real life consumption but more to relate the use of gas with gaming on the unrealistic map sizes average 20x20km to make the players feel that gas is a vital element of the battle force.

Share this post


Link to post
Share on other sites
On February 8, 2017 at 11:07 AM, breech99 said:

 

That's totally awesome Wyqer. I like your ideas.  Something simple and that makes fuel consumption at least doubled. I read that the compressed scale of all of the game's islands are about one third to half scale in size. I think you are on the right track. Gives purpose for having fuel trucks and the battlefield commanders have to think about how they are going to deploy vehicles like tanks which think in terms of gallons per mile and not miles per gallon.  Large trucks have tons of fuel but it's nice to see the need to refuel. Arma2 I remember having to refuel a lot but in Arma3, I'm not seeing the need anymore. This is a fun feature to add.

agreed! 

Share this post


Link to post
Share on other sites

thumbs up from me, too.

this is what arma 3 needs. why all these operational gas stations on map, and no one uses them, because their fuel tank never get empty while playing a mission.

Share this post


Link to post
Share on other sites

Very nice script. I second madpat3, this needs to be in vanilla Arma 3 as vehicles have always full fuel.

Share this post


Link to post
Share on other sites

Spectacular script, me and my friends, in all our missions!
Is it possible to cancel it in a particular vehicle? In UAVs it consumes much faster than other vehicles.

I Tried:

if ((_this select 0) isKindOf "UAV_01_base_F") exitWith {};


did not work, I do not have much experience in .sqf = [

Share this post


Link to post
Share on other sites

Don't even know the script you've mentioned.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×