Jump to content

Repair & Rearming script


Halvhjearne

Recommended Posts

On 9/8/2019 at 6:33 PM, Grahame said:

I use it because I have never had time to add all the CUP vehicles into the configs tbh @He-Man :ph34r:

@Grahame
You can use this script to find all Vehicles on the map with weapons, but not currently in the default Epoch ServicePoint.
This Script will give you the needed config entries for cfgServicePoint.cfg but you have to sort it a bit and change the price from 999999 to what you want.
 

_allveh = allmissionobjects "landvehicle" + allmissionobjects "ship" + allmissionobjects "Air";
NewVehiclesAndAmmo = [];
_AlreadyFound = [];
_AmmoConfig = (missionconfigfile >> "CfgServicePoint" >> "VehiclesAndAmmo");
_VehiclesWithAmmo = ("true" configClasses _AmmoConfig) apply {configname _x};
_VehiclesWithAmmo = _VehiclesWithAmmo + ((getarray (missionconfigfile >> "CfgServicePoint" >> "VehiclesAndAmmo")) apply {_x select 0});
{
	_type = typeof _x;
	{
		if ((tolower _type) == (tolower _x)) exitwith {
			_AlreadyFound pushback _type;
		};
	} foreach _VehiclesWithAmmo;
	if !(_type in _AlreadyFound) then {
		_AlreadyFound pushback _type;
		_magsturrets = (magazinesAllTurrets _x);
		if !(_magsturrets isequalto []) then {
			_entry = [_type,[]];
			_tmp = [];
			_cnts = [];
			{
				_find = -1;
				_curmagturret = _x;
				{
					if (str _curmagturret isEqualTo str _x) exitwith {
						_find = _foreachindex;
					};
				} foreach _tmp;
				if (_find == -1) then {
					_tmp pushback _x;
					_cnts pushback 1;
				}
				else {
					_cnts set [_find, (_cnts select _find) + 1];
				};
			} foreach _magsturrets;
			{
				(_entry select 1) pushback [];
				(_entry select 1 select _foreachindex) pushback (_x select 0);
				(_entry select 1 select _foreachindex) pushback (_x select 1);
				(_entry select 1 select _foreachindex) pushback (_cnts select _foreachindex);
				(_entry select 1 select _foreachindex) pushback 999999;
				(_entry select 1 select _foreachindex) pushback (_x select 2);
			} foreach _tmp;
			NewVehiclesAndAmmo pushback _entry;
		};
	};
} foreach _allveh;

 

Edit: I have changed the Script, so it is compatible to Epoch 1.3.1 and also the upcoming Epoch 1.3.2.

 

The Output is an Array like this:

[["B_G_Offroad_01_armed_EPOCH",[["100Rnd_127x99_mag_Tracer_Yellow",[0],4,999999,100]]],["B_HMG_01_high_F",[["FakeWeapon",[-1],1,999999,1],["100Rnd_127x99_mag_Tracer_Red",[0],4,999999,100]]],["O_UAV_01_F",[["Laserbatteries",[0],1,999999,1]]]]

 

Add some linebreaks and tabs for a better overview like this:

[
	[
		"B_G_Offroad_01_armed_EPOCH",
		[
			["100Rnd_127x99_mag_Tracer_Yellow",[0],4,999999,100]
		]
	],
	[
		"B_HMG_01_high_F",
		[
			["FakeWeapon",[-1],1,999999,1],
			["100Rnd_127x99_mag_Tracer_Red",[0],4,999999,100]
		]
	],
	[
		"O_UAV_01_F",
		[
			["Laserbatteries",[0],1,999999,1]
		]
	]
]

 

Replace the 999999 by the price for this kind of magazine, like you want.

Then you should be able to add the Vehicles to the cfgServicePoint. Do not copy / paste it, but add new entries with the same syntax like others already in the cfg

Link to comment
Share on other sites

2 hours ago, Sneer said:

Where would I put this script? and what does "you have to replace the [] by {} " mean?

@Sneer
I have changed the script, so it can also be used in Editor.
- Run you Epoch Mission file in Editor
- Place all Vehicles you want to configure for the ServicePoint
- Run this Script in console
- Read out the Variable "NewVehiclesAndAmmo"
- Paste the array you get from the variable into an empty file
- Replace all [ by {
- Replace all ] by }
- Replace all 999999 by the price you want for the Ammo
- Add it to cfgservicepoint

 

Sure, you have to add some line breaks, to make it a bit easier to get an overview. But in general, you get a final config (with the above changes)

Link to comment
Share on other sites

11 minutes ago, He-Man said:

@Sneer
I have changed the script, so it can also be used in Editor.
- Run you Epoch Mission file in Editor
- Place all Vehicles you want to configure for the ServicePoint
- Run this Script in console
- Read out the Variable "NewVehiclesAndAmmo"
- Paste the array you get from the variable into an empty file
- Replace all [ by {
- Replace all ] by }
- Replace all 999999 by the price you want for the Ammo
- Add it to cfgservicepoint

 

Sure, you have to add some line breaks, to make it a bit easier to get an overview. But in general, you get a final config (with the above changes)

 

Thank you! I'll try it out tonight.

 

Link to comment
Share on other sites

@Sneer
I had to rework the script again and added some more infos.
The "old" variant has added turrets with more than 1 count of mags multiple. So I have added a merge for it.
Now it also works with the stable and experimental branch (I had to change the config for cfgServicePoint).
If there are questions, we can also discuss it in Discord. Would be a bit easier and faster than in a forum.

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...