Jump to content

[WIP] - Better refueling (Accurate fuel capacity, multiple fuel sources, choose vehicle to refuel, GUI).


Recommended Posts

Epoch Better Refueling.

 

GIThub: Better Refueling.

Dropbox: Better Refueling.

 

Overall status: This is now a work in progress. 

Current Phase being worked on: Phase 1 & 2 [Fuel truck Beta released].

 

Overview

This is a  mod aimed at improving the fuel pump / fuel truck setup in Epoch. 

 

Current release.

  • Realistic fuel capacity for air and sea vehicles (an AH6 is faster to fill than a Blackhawk for example).
  • Faster flood fill for large vehicles from the fuel truck.
  • Refueling 'cycles' depend on capacity from the fuel truck.
  • Choose which vehicle in range to refuel from the fuel truck.
  • Fully configurable via variables.  You can change
    • Flood fill vehicle list (default is realistic vehicles)
    • Vehicle capacities (default is actual vehicles fuel capacities)
    • Fuel Truck fueling litres / cycle (default would be realistic if one cycle = 1 minute - which it does not)
    • Flood fill litres / cycle (default would be realistic if one cycle = 1 minute - which it does not)
    • Fuel truck refuel range.

This project is being done in my own spare time and will be provided to all, free of charge.  Peoples entitlement level is directly relational to the cost :D.

 

I am very happy to have others join me in creating this mod. I firmly believe in pooling resources from the community to make a better end product. If you wish to join me then let me know here or PM me. All contributors will be listed here and in the readme file that will come with the mod download.  Contributors can, of course, remain anonymous if they prefer.

 

Planned features by phase

(current status in []);

 

Phase 1 (should be fairly easy).

  • More realistic fill rates so a car takes less cycles to fill than a heli based on pump rate of fueling truck used or pump [Ready for Beta].
  • Fuel sources can include fuel trucks [Bumped to phase 3 due to a rework of the fuel pump code needed].

Phase 2

  • A menu to choose which vehicle to fuel out of those within range [Ready for Beta].

Phase 3

  • Fuel pumps made available at traders (too rare with the range restrictions otherwise) [Ready for Beta].
  • Fuel Pump can be placed within 5Mtrs/10mtrs (to be tested) for a fuel source or another fuel pump [Waiting for previous stage].
  • One of the fuel pumps needs to be in range of a generator (or power source like running fuel truck) and have a fuel source with fuel [Waiting for previous stage].
  • Fuel pumps will fuel the nearest vehicles within 5 mtrs/10mtrs or fuel barrels and jerry cans [Waiting for previous stage].

Other items for investigation

  • Ability to load fuel barrels in to the fuel pumps inventory as its fuel source.  Would need to keep track of the fuel barrels available fuel [Waiting for previous stage].
  • Ability to allow traders to offer fuel refills at a price [Waiting for previous stage].

 

Install Instructions

 

 

For a new Epoch server with no mods.

 

If you have no other mods installed then just download the dropbox file, extract in to your ARMA2OA\missions\[Map Name]\ folder and edit your missions init.sqf file.

 

Find

call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf";

change to 

call compile preprocessFileLineNumbers "init\variables.sqf";

find

call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";

change to

call compile preprocessFileLineNumbers "init\compiles.sqf";

Install Complete.

 

For a new Epoch server with mods.

 

Requirements from the dayz_code.pbo

 

compiles.sqf

variables.sqf

fn_selfactions.sqf

 

1. Make sure you have custom version of the above files all linked together.

 

Link the compiles from the missions init.sqf

Link the variables and fn_selfactions from the compiles.sqf

 

2. Add the following to your variables.sqf

 

s_player_refuelTop_crtl = -1;
s_player_refuelSub_crtl = -1;
s_player_refuelActionsSub = [];

// Array of fixed and mobile (fuel truck) fuel sources.
DZE_RB_AllFuelSources = ["Land_Ind_TankSmall","Land_fuel_tank_big","Land_fuel_tank_stairs","Land_fuel_tank_stairs_ep1","Land_wagon_tanker","Land_fuelstation","Land_fuelstation_army","land_fuelstation_w","Land_benzina_schnell","KamazRefuel_DZ","UralRefuel_TK_EP1_DZ","MtvrRefuel_DES_EP1_DZ","V3S_Refuel_TK_GUE_EP1_DZ","MtvrRefuel_DZ","KamazRefuel_DZE","UralRefuel_TK_EP1_DZE","MtvrRefuel_DES_EP1_DZE","V3S_Refuel_TK_GUE_EP1_DZE","MtvrRefuel_DZE"];

// Realistic Vehicle capacity array [[classname],[capacity]]
DZE_RB_FuelCapArray = [["AH6X_DZ","MH6J_DZ","AN2_DZ","RBX","RHIB","BAF_Merlin_DZE","C130J_US_EP1","CH_47F_EP1_DZ","CH_47F_EP1_DZE","CH53_DZ","CH53_DZE","Mi17_DZ","Mi17_DZE","Mi17_Civilian_DZ","MV22_DZ","UH1Y_DZ","UH1Y_DZE","MH60S_DZ","UH60M_base_EP1","UH60M_EP1_DZ","MH60S_DZE","UH60M_EP1_DZE"],[242,242,757,23,250,3222,34095,4043,4043,3849,3849,1870,1870,1870,6513,1333,1333,1360,1360,1360,1360,1360]];

// Vehicles that can be flood fill refuelled by a fuel truck)
DZE_RB_floodfill = ["BAF_Merlin_DZE","C130J_US_EP1","CH_47F_EP1_DZ","CH_47F_EP1_DZE","CH53_DZ","CH53_DZE","Mi17_DZ","Mi17_DZE","Mi17_Civilian_DZ","MV22_DZ","UH1Y_DZ","UH1Y_DZE","MH60S_DZ","UH60M_base_EP1","UH60M_EP1_DZ","MH60S_DZE","UH60M_EP1_DZE"];

// Refuelling range
DZE_RefuelRange = 90;

// Fuel truck pump speed
DZE_RB_pumpspeed_truck = 40;

// Fixed fuel pump speed 
DZE_RB_pumpspeed_fixed = 50;

// Flood fill fuel pump speed 
DZE_RB_pumpspeed_flood = 400; 

// Variable to show if fuel trucks can be used as fuel pump fuel sources.
DZE_RB_PumpSourceTruck = false;
DZE_RB_AllowFloodRefuel = True;
DZE_RB_RealisticFuelCapacity =  True;
RefuelCursorTarget = nil;

3. Edit the fn_selfactions.sqf

 

Find start

//Fuel Pump on truck

Find end

// inplace upgrade tool

Replace the whole chunk with 

	//Fuel Pump on truck
	if(_typeOfCursorTarget in DZE_fueltruckarray and alive _cursorTarget) then {	
		RefuelCursorTarget = _cursortarget;
		if (s_player_refuelTop_crtl < 0) then {
			diag_log text"[fn_selfactions] Refuelling top menu not set.";
			// show that fuel truck pump needs power.
			if(isEngineOn _cursorTarget) then {
				if (s_player_refuelsub_crtl < 0) then {
					s_player_refuelTop_crtl = RefuelCursorTarget addAction [format["<t color='#FFCC99'>%1</t>","Refuelling"], "custom\better_fuelling\refuel_vehicle_menu.sqf",[_cursorTarget,true], 0.36, false, true, "",""];
				};
			} else {
				s_player_fuelauto2 = RefuelCursorTarget addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_NEEDPOWER"], "",[], 0.36, false, true, "",""];
			};
		};
	} else {
		cursorTarget removeAction s_player_refuelTop_crtl;
		s_player_refuelTop_crtl = -1;
	};

	// inplace upgrade tool

Find

        s_player_fuelauto2 = -1;

Replace with

	s_player_fuelauto2 = -1;
	
	if !(isNil "RefuelCursorTarget") then{
		if ((count s_player_refuelActionsSub) >= 1) then{
			{
				RefuelCursorTarget removeAction _x;
			} count s_player_refuelActionsSub;
			s_player_refuelActionsSub = [];
			s_player_refuelSub_crtl = -1;
		};
		if (s_player_refuelTop_crtl != -1) then{
			RefuelCursorTarget removeAction s_player_refuelTop_crtl;
			s_player_refuelTop_crtl = -1;
		};
		RefuelCursorTarget = nil;
	};
	

4.  Place the new files in the  ARMA2OA\missions\[Map Name]\custom\better_fuelling folder

 

refuel_cancel.sqf

refuel_Vehicle.sqf

refuel_vehicle_menu.sqf

 

Install Complete.

 

Add the fuel pump to the building supplies traders.

 

1. Amend the  "Add fuel pump to building traders.sql" file in the SQL directory of the download to match what you want to sell the fuel pumps for and which trader to sell from .

 

VALUES
('["fuel_pump_kit",1]',
10,                      // Starting amount of stock
'[1,"ItemSilverBar",1]', // to buy: [costs How many, "what item", amount bought]
'[1,"ItemSilverBar",1]', // to sell: [costs How many, "what item", amount sold]
0,
662,                     // Which trader
'trade_items');          // What menu

2. Run the sql code in the SQL directory using something like MySQL workbench against your database.

 

 

Other contributors to this project.

 

 

Comments, suggestions, desirables all welcome. 

 

RB

Link to comment
Share on other sites

Will try to get the phase 1 done over the next couple of weeks.  Phase 2 should be fairly easy but I have to hard wire the pump rates (possibly via variables) as changing the structure in the vehicle config files (add pumprate and refill rate) would mean players having to download a new version of the mod.

 

Beast solution would be for the Epoch team to add those fields to the classes so they go out with 1.0.5 but whether they will or not is another matter.

 

Don't hold me to any timings though  :D .

 

RB

Link to comment
Share on other sites

Changed to WIP now Plot for life is done.

 

Have been doing some background info gathering and have a list of fuel capacities for the air and sea vehicles.  Also have the fuel pump rate for the Kamaz fuel truck (40l/min) and standing fuel pump (50l/min) so I will use those depending on which pump is being used to fill with.

 

What this means....

Most cars will take 2-3 cycles to fill.

A littlebird will take 5.

An AH-2 biplane will take 15.....

 

Clearly filling a C130 (34,000 litres) with a 50l/min fuel pump will be silly but the Kamaz specs do list a filling station pump rate of 400l/min so for specific vehicles that are likely to be able to take a high rate fuel feed, I will use that pump speed if filled from a fuel truck.  This will affect the following pre-configured.

 

Flood fill enabled vehicles (empty to full cycles).

BAF_Merlin (3,200l): 9

C130J (38,000l): 86 (and 4 fuel trucks)

CH_47 (4,000l): 11

CH53 (3,800l): 10

Mi17 (1,870l): 5

MV22 (6,500l): 16

UH1Y (1,300l): 4

MH60S blackhawk / Seahawk varants (2,760l) : 7

 

This will of course be a double edged sword as hovering above a gas station to refuel will take a long time but on the other hand could present an interesting defense mission.

 

 For using fuel trucks as fuel sources, I will put this in but a generator (not the fuel truck) is needed for power to the fuel pump.  Filling directly from the fuel truck will work as normal though.

 

RB

Link to comment
Share on other sites

You sure about those fuel capacity values?

I have a custom refuel script myself and for most of the vehicles (even air allthough i haven't checked with the C130 yet) the maximum fuel amount lies around 1000 Litres in the config files?

I can be totally wrong here and i haven't checked yet but that is what i had in my head still

Link to comment
Share on other sites

Aaaaand i just read your previous post lol :P

I guess a way to do it would be either a table in database where you set the specific values, but that would require an Arma2NET connection or you create an array where you go and save all the stats and go grab what you need for each vehicle classname when you refuel

Link to comment
Share on other sites

Ideally the fuelcapacity value would be set in the individual class files like they are set in the land vehicle ones (even though they are have wrong values there).  The Class files seem to be a bit all over the place with little consistency so at this point I cannot rely on them.

 

That would have to come from the Epoch team though as the vehicle class file would need an @mod download to get to the clients.

 

So fat the AH6, Ch47 and MH60S all have a default fuel capacity of 1000(presumably litres).  I am overriding with a hard coded array.  Not ideal but unless the class files can be updated, probably the best I can do for now.

 

Current state.

 

Default fuel values are being overwritten if fueling AIR or WATER vehicles to the correct capacities.

 

I now have to rework the calcs for source removal and destination addition as the current ones are not quite right and do not take in to account a partial fill.

 

After that is complete I will take a look at adding a list of available targets with their current fuel and if they can be flood filled for the scroll wheel menu (later hopefully for a gui).

 

Fairly good progress today on it though so I am fairly happy :) .

 

RB

Link to comment
Share on other sites

Only managed to get a little of the logic done last night due to family time requirements.  Will continue on it today.

 

The mechanic I am working on is

  • Get source details.
  • Get destination details.
  • Loop until full / interrupted
    • Check source ability to fuel (available fuel) - (exit if failed).
    • Check destination fuel requirements - (exit if failed).
    • Play animation
    • Check source ability to fuel (available fuel) - (exit if failed).
    • Check destination fuel requirements - (exit if failed).
    • Commit deduction from source
    • Commit addition to destination
  • Next loop if not full / interupted.

The reason for the double check is to make sure refueling is valid before the player needs to wait for the animation to complete and then to verify nothing has changed during the animation (hopefully stop any exploits occuring during the animation) before commiting the change.

 

Due to the extensive expansion of the refueling functionality I will probably produce a small suite of scripts / functions to handle different aspects of the process (A small function to check source and another to check destination etc).  This should cut down on duplicate code and lower the number of lines evaluated for a given refueling workflow.

 

Another addition I will also look at is the ability to add fuel barrels to fuel pumps as a fuel source.  This would allow the creation of a refeulling station with a fuel pump, generator and some fuel barrels.  The fuel barrel volumes would need to be tracked persisitantly.

 

Anyone want to put together a fuel pump readout where people can select the amount fo fuel they wish to add to the vehicle ?.  Think like the fuel pump counter at a gas station that has moving counters (sort of like the combination padlock).  If someone can supply the graphic, I will look to see if I can get it in to the fueling dialogue.  Graphics are not my thing at all so this will need someone elses help if people want to see it.

 

Update: Request for fuelcapacity with correct values to be added to the vehicle class files (AIR/LAND/SEA) logged on GitHub (#1277).

Link to comment
Share on other sites

My first cut of the refueling basic code is done.

 

Included

  • Changing the script structure
    • Check for destination vehicle
    • Get destination vehicle details
    • Get source vehicle details
    • Confirm source has fuel, 
    • Confirm destination needs fuel
    • Set fuel can size per cycle
    • Calculate new fuel for src & dest.
    • Play sound & animation (they are now correctly sync'd)
    • Check fuel levels on src and dest again to make sure they have not changed.
    • Apply fuel level changes to src and dest
    • loop until either src is empty or dest is full.
  • Pre and post animation fuel level checks (to prevent syphoning / two people filling from the same source at the same time while the animation is playing).
  • Fflood fill from fuel truck (fuel can size 400 litres/min for large aircraft).
  • Different fill rates for pumps and fuel truck (50 litres/min & 40 litres/min)
  • Accurate fueltank capacities for AIR and SEA vehicles.

 

No @mod download required.  All changes to mission files only.

 

Will start alpha testing tonight.

 

Planned tests.

 

Fuel truck to destination

  • Fuel truck to heli (new heli capacity value).
  • Fuel truck to car (old capacity value).
  • Fuel truck to boat (new capacity value).
  • Fuel truck to spawned car.

 Fuel pump to destination vehicle

  • Fuel pump to heli (new heli capacity value).
  • Fuel pump to car (old capacity value).
  • Fuel pump to boat (new capacity value).
  • Fuel pump to spawned car.

 Fuel pump to fuel truck

  • Fuel pump to fuel truck

Gas station to destination vehicle

  • Gas station to heli (new heli capacity value).
  • Gas station to car (old capacity value).
  • Gas station to boat (new capacity value).
  • Gas station to spawned car.

Misuse

  • Player 1 fill - Player 2 syphon fuel while player 1 animation.
  • Player 1 fill - player 2 drive destination vehicle away while player 1 animation.
  • Player 1 fill - Player 2 drive fuel truck away while player 1 animation.
  • Player 1 fill - Player 2 fill.

After these are all sucessful (not before the end of the week / weekend at a very rough estimate) I will package it up for download a phase 1 release a.

 

The install will be simple with a couple of changes to the fn_selfactions.sqf file and a new Refueling.sqf file to drop in.

 

RB

Link to comment
Share on other sites

Any chance you can include a menu similar to the traders where you could actually charge people for the refueling?

 

Such as 1L would cost x silver/gold etc... Would of been pretty cool, i know maca has this on his servers but i doubt he will share something like that :)

Link to comment
Share on other sites

Any chance you can include a menu similar to the traders where you could actually charge people for the refueling?

 

Such as 1L would cost x silver/gold etc... Would of been pretty cool, i know maca has this on his servers but i doubt he will share something like that :)

 

Should be faily easy to do, on the face of it.

 

Would just need to work out the mechanic for running the refuelling script after a trader item has been bought with a set of variables (amount of fuel to fill, target vehicle etc).  Needs a bit of thrashing out but will add it for investigation after the core parts are done.

 

I do want to make the script more generic so it can be used many other places and its effects are tailored by the parameters it is passed.  This would be an example of an area that could take advantage of it.

 

Saying that, I spent a couple of hours searching for a missing ")" in the first cut code which is currently unoptimised and at around 320 lines with multiple nested if statements.  Each time I thought I may have found the issue I have to copy the files to the server, start up Epoch Server, login from the Epoch client, unlock the fuel truck, get-in and turn on,  eject, choose the fill option.

 

All very time consuming so please don't expect a quick fix.

Link to comment
Share on other sites

Rimblock use Sandbird's editor for writing code. no need to restart a server, only thing you need to do is press a button. It has full database integration and for your needs you will be able to do everything you need.

Believe me when i tell you it will save you hours and days of frustration

Link to comment
Share on other sites

Rimblock use Sandbird's editor for writing code. no need to restart a server, only thing you need to do is press a button. It has full database integration and for your needs you will be able to do everything you need.

Believe me when i tell you it will save you hours and days of frustration

 

Possibly, the problem is that Arma2Net is not working.  I suspect it may be down to dot net 4.5.1 rather than dot net 4.0 that is required.  Read that is has problems with Win 2012 r2 servers which come with 4.5.1 as default and are not able to downgrade (from what I remember).

 

I found the issue with the missing '')''.  Turns out to compare a variable I believe was a string with a "text" value I need to use if(str(variable) == "text) rather then if (variable == "text").  That is now sorted.  

 

Resolving some undefined variables then, hopefully on to testing basic functionality.

Link to comment
Share on other sites

So I have some more movement.

 

Most of the undefined variables are now sorted.

 

I managed to get the fuel truck to flood fill (400l cycles) my Chinook from 45% full to totally full.

 

What this means.

  • Fuel truck is recognised
  • Chinook is recognised.
  • Chinook is recognised as a flood fill compatible vehicle.
  • Fueling rate per cycle is correctly set.
  • Cycles are updating the fuel amount in both the truck and chinook correctly.
  • Cycles stop when the chinook is full.

Current issues to check or resolve before moving to the next test.

  • Full vehicle message did not have the vehicles name displayed - track variable and fix - fairly easy.
  • Need to confirm the final cycle which required less than 400l actually removes the correct amount from the source (one or two extra debug lines should confirm).

Next test

  • Fill non flood fill compatible heli (AH6)
  • Fill non flood fill land vehicle (SUV)
  • Same tests with source as fuel pump rather than fuel truck.

Hope to have most if not all of these done over the weekend dependant on family commitments.  If all goes well I will start to optimise the code, do another full set of testing and then put a release together for Beta testing. 

 

Interested parties please let me know.

Link to comment
Share on other sites

Bit of an update.

 

In order to make the testing cycle a little faster I have taken out the requirement to turn on the engine of the fuel truck in order to get the fill option.  Doing this has highlighted a bit of a potential exploit.  Not this has not been tested but is most likely possible.

 

I found that although the refueling was working fine in game, it was not saving to the hive between reboots.  I have now tracked down why...

 

Vehicle fuel data is saved to the hive when either all data on the vehicle is saved or the position data (which is included in all data) is saved.  These saves are fires either on vehicle get in / get out or player_sync.

 

Not tested but, this leads me to believe you could use a fuel truck to refuel a vehicle.  After the vehicle is refueled, don't touch the fuel truck (don't get in to turn off the engine, touch the gear or move it at all) but get in the refueled vehicle.  I suspect on server restart, the refueled vehicle will be refueled and the fuel truck will revert back to the original fuel before refueling the other vehicle.  Probably best to try fairly close to a server restart.  

 

If someone can test and report back please it would be very helpful.  If that is the case then I will file a bug report.

 

My script does a forced save to the hive of source vehicle and destination vehicle on exit so will stop this potential exploit.

 

Fuel truck to Chinook is working as desired.  I will start testing with other combinations tomorrow.

Link to comment
Share on other sites

Fuel pumps using fuel trucks as source...

 

So I have added in the ability to build fuel pumps near fuel trucks but doing so poses another new set of choices.

 

Consider the following;

  • A fuel truck and a fuel tank are both in range - Which to link the fuel pump to.  Which to drain the fuel from ?.

For now, the fuel tank gets priority, especially as they never run out of fuel in Epoch.

  • A pump is built next to a fuel truck but the fuel truck is then moved.  

Each time the fuel pump is used, a source for the fuel needs to be validated.  If more than one fuel truck is in range, the nearest will be used.

 

Any other thoughts or suggestions then let me know.  

 

RB

Link to comment
Share on other sites

Ok, it is now listing all vehicles in range and the % remaining in the fuel tank of each vehicle and you can then select which ones you want to fill.  They are also colour coded...

< 80% = Blue

60% -> 79% = Yellow

59 -> 20% = Orange

< 20% = Red

 

2014-05-27_00004_zps934b8310.jpg

 

The fill code needs to be fully tested still but being able to select a vehicle out of those in range and actually knowing how full each vehicle is was something I really wanted for my own server.  Hopefully it will be useful for others too.

Link to comment
Share on other sites

Nope,  need to alpha test it first then will make it available to beta testers.

 

I am currently looking at 2-3 hours a night working on this but there are a fair few combinations to test and real life getting in the way ;) .  As I have just reworked the code to allow selectable vehicles within range rather than just the nearest.  This involves a 2nd level menu script in between the fn_selfactions and the refuel script which I have to make sure is sending the source and destination vehicles (previously the refuel script just works out the nearest valid target).

 

Depending on how it goes and how much time I can spend on it, maybe a week or so.

Link to comment
Share on other sites

Ok, little update.

 

Current progress:

  • The correct source and target are being passed from the submenu script to the main refuel script.
  • The correct logic is being worked out for floodfill, real capacity values, source is a fuel truck or fuel pump etc. 
  • Correct values are going around the refuel loop and filling the vehicle locally (i.e. in the current live version of the world)  

 

Current issues:

  • The code is not exiting when the vehicle is full.  This is almost certianly due to the exit loop statement being in the wrong nested if statement (there are many, sometimes 6 levels deep to account for all the option combinations in this unoptimised code).  I just need to track through the control structures and realign the exit statement with the master loop.  As the loop is not exiting, the fueling is not being saved to the DB which only happens when the script is exited (full vehicle or refueling interrupted) to save DB calls which can introduce lag issues.
  • Other menu options seem to be behaving strangely (Repair / Salvage are not giving sub options, unlock vehicle seems to be getting stuck on the screen and does not change when looking at other vehicles etc).  I have tried to keep the refuel options completely seperate from any other option choices (new parameters etc) so this is a bit strange.  I am hoping it is just an incorrect ")" or "]" somewhere but with fn_selfactions.sqf being around 1,000 lines it is going to be a pain to troubleshoot it.  Personally I think the fn_[whatever]actions.sqf scripts need to be reorganised as they are just getting bigger and bigger.  Maybe rather than having one massive master script that takes a bit of time for the system to trawel though, there could be a small, fast master script and that calls sub scripts to actually run the logic for adding actions for specific items.  Restricting the master script to three levels. Level 1 for determining alive or dead, Level 2 for determining actions for players, vehicles or animals and level 3 being to filter on initial specifics for types of actions and then calling the code for detailed filtering and addaction commands. 

An example would be;

 

1. if alive

1.1 If cursortarget is typeof "man" then

1.1.1 If cursortarget = typeof trader

Call player2traderActions

1.1.2 if cursortarget = injured

Call player2injuredActions

1.2 If cursortarget is typeof "allvehicles" then

1.2.1 If cursortarget = typeof fueltruck

Call player2refuelActions

1.2.2 If cursortarget = locked

Call player2unlockActions

 

etc.

 

The multiple if XXXX and XXXXX or XXXXX and XXXX also force comparison of all elements before determining sucess or failure so breaking it down in to single comparison if statements leads to much more efficent filtering.

 

Another techneque I would have liked to have tried would have been using bitwize calculations to essentially have a single variable act as a set of bit flags for the cursortarget status.

 

e.g.

 

Variable = 100000000

Values for each bit position: 1 = true.

Position 1 = control (presuming number variable type)

Position 2 = alive

Postiion 3 = fuel vehicle

Postiion 4 = damaged vehicle

Postiion 5 = locked vehicle

Postiion 6 = Flying vehicle

Postiion 7 = Unconcious Player

Postiion 8 = Friend

 

Variable = 11111000 = An alive, locked fuel vehicle with some damage.

Variable = 11000011 = An alive unconcious friend.

 

By performing a logical "and" on the variable we can see instantly where multiple states exist in a single opperation.  A logical "and" compares the two bitwize valies and where both have a 1 at the same position, the result for that position will also be a 1 else the result will be a 0.

 

1010

and

1101

equals

1000

 

So if we want to know if there is an alive flying vehicle with damage we would "and" the variable to 11010100 which could result in 11010100 if true.  There are also logical "or", "xor" and "not" operators. 

 

Unfortunately it seems ARMA II does not support bitwize calculations unless anyone knows differently or of a mod / addon implementation that works ?.

 

Enhancements:

  • I think I will put in a refueling range variable you can set depending on how far from the fuel source you want players to be able to refuel.  15m will allow refuelig next to the pump/truck, 30-40m will give refueling for a plot pole area if the source in next to the plot pole.  100m could be used for a refueling trader service maybe.  Anyway, it will be up to the server owner to decide.
Link to comment
Share on other sites

Someone has offered to help look at a GUI to allow vehicle selection for refueling, possibly showing source fuel level and a few other bits of info.  As the underlying mechanism is quite similar, we will also be looking at integrating the salvage and repair lists in to the same gui so an integrated service gui for vehicles really.

 

Hopefully that will cut some code out of the fn_selfactions.sqf and so improve processing speed there a little and make it a bit easier to manage this stuff.

 

I will be doing the code to match with the GUI and get the job done but full GUI credits will be with them.  As they offered by PM I will respect their anonymity for now but they will get full credits on release.

 

If anyone else wants to join in then just let me know here or via PM.  Many hands make light work and all that will help to speed up the release  ;) .

 

RB

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...