Jump to content
Sign in to follow this  
Bon

automated equipment retrieval, universal crate filler

Recommended Posts

The following code

  1. parses the config file for ammo boxes known by the executing machine,
  2. retrieves the content of each of it and gathers it in a list,
  3. copies the resulting list to the clipboard.

// by Bon_Inf*

_weapons = [];
_magazines = [];

for "_i" from 0 to (count (configFile >> "CfgVehicles") - 1) do {

_current = (configFile >> "CfgVehicles") select _i;
if(isClass _current) then {
	_class = configname _current;
	_vehicleclass = getText (configFile >> "CfgVehicles" >> _class >> "vehicleClass");

	if(_vehicleclass == "Ammo") then {

		_box = _class createVehicle [0,0,0];

		_weapons = (_weapons - (getWeaponCargo _box select 0)) + (getWeaponCargo _box select 0);
		_magazines = (_magazines - (getMagazineCargo _box select 0)) + (getMagazineCargo _box select 0);

		deleteVehicle _box;
	};
};
};

copyToClipboard str [_weapons,_magazines];
hint "done";

Assuming there is for each weapon and magazine class at least one box which contains this class, this piece of code saves you lots of time gathering all equipment the game offers.

The following script, executed from within the initline of an ammobox, is a fully automated ammobox filler, which makes use of the above equipment retrieval:

// by Bon_Inf*

_cache = _this select 0;

_weapons = [];
_magazines = [];



for "_i" from 0 to (count (configFile >> "CfgVehicles") - 1) do {

_current = (configFile >> "CfgVehicles") select _i;
if(isClass _current) then {
	_class = configname _current;
	_vehicleclass = getText (configFile >> "CfgVehicles" >> _class >> "vehicleClass");

	if(_vehicleclass == "Ammo") then {

		_box = _class createVehicle [0,0,0];

		_weapons = (_weapons - (getWeaponCargo _box select 0)) + (getWeaponCargo _box select 0);
		_magazines = (_magazines - (getMagazineCargo _box select 0)) + (getMagazineCargo _box select 0);

		deleteVehicle _box;
	};
};
};








_weaponcapacity = 0 max getNumber (configFile >> "CfgVehicles" >> typeOf _cache >> "transportMaxWeapons") - 100;
_magazinecapacity = 0 max getNumber (configFile >> "CfgVehicles" >> typeOf _cache >> "transportMaxMagazines") - 100;


while {alive _cache} do {

{deleteVehicle _x} foreach nearestObjects [position _cache,["WeaponHolder"],50];

clearMagazineCargo _cache;
clearWeaponCargo _cache;

{
	_cache addWeaponCargo [_x, floor(_weaponcapacity / (count _weapons))];
} foreach _weapons;

{
	_cache addMagazineCargo [_x, floor(_magazinecapacity / (count _magazines))];
} foreach _magazines;


// restock time.
sleep 1800;
}; 

Notes:

  • The script uses the commands getWeaponCargo and getMagazineCargo, which were firstly introduced in patch 1.54 for Operation Arrowhead.
  • In case the ammocrate filler is executed locally on each machine, and there are players running the game with additional weapons (i.e. 3rd party addons) the script results (hence, the respective crate content) differ from player to player, what, of course, would be a problem. So I recommend not to use the crate filler script in Multiplayer unless the server settings forbid any 3rd party addons providing additional equipment or the script is executed only on the server machine.

hf.

Edited by Bon

Share this post


Link to post
Share on other sites

Sadly i suck at creating dialogues, because instead of the nth ammobox filler script, i would like to see something like this:

Instead of the regular gear dialogue, a custom dialogue opens, listing all avaliable weapons and items (gathered from configs with the above method), sorted by type (Rifles, Launchers, Items and so on) and by picking a weapon it shows me a list with magazines that can be used with the picked weapon.

No more overfilling ammoboxes, no more not enough magazines for a particular weapon. Just place the box and you're good to go.

If someone could script this, i could turn it into an addon.

@Bon

sorry for hijacking your thread a little, appreciate the work you've done and surely don't want to criticize you and/or your work. Just placing an idea which i'm not able to realize myself.

Keep your work up, mate.

Share this post


Link to post
Share on other sites

That's actually a good idea, and not that difficult to implement.

Problem would be to handle the slot system tho.

However, in case someone releases such script, the WORST thing to do would be to turn it into an addon :936:

Share this post


Link to post
Share on other sites
That's actually a good idea, and not that difficult to implement.

Problem would be to handle the slot system tho.

However, in case someone releases such script, the WORST thing to do would be to turn it into an addon :936:

Not if it is a new ammobox object that has to be placed. I'm not speaking about replacing default ammoboxes or their system. So it is a object that has to be actively placed by mission creator.

Also several restictions can be implemented which could be activated/deactivated by missionmaker.

Maybe limiting weapons by their cost, not allowing expensive weapons (like Javelins) but RPG's.....well, there are ways, one just have to know and implement them.

However, i understand your main concern and i agree fully with it.

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
Sign in to follow this  

×