Jump to content

Recommended Posts

I've been trying to make a script that will transfer the equipment of nearby dead soldiers into vehicles, however I can't quiet seem to wrap my head around it. Theres been a couple of old threads and scripts on the subject that seem to rely on now nonexistent functions. I basically want the script to detect bodies in a 150m radius around the vehicle, grab the inventories and throw them into a truck then delete the bodies.

If anybody has ideas or can point me in the right direction it will be immensely helpful

Share this post


Link to post
Share on other sites
Spoiler


//Test Body contents
//[["arifle_MX_F","muzzle_snds_H_snd_F","acc_pointer_IR","optic_Aco",["30Rnd_65x39_caseless_mag",30],[],"bipod_02_F_hex"],["launch_I_Titan_eaf_F","","","",["Titan_AA",1],[],""],["hgun_Pistol_heavy_01_F","muzzle_snds_acp","acc_flashlight_pistol","optic_MRD",["11Rnd_45ACP_Mag",11],[],""],["U_B_CombatUniform_mcam",[["FirstAidKit",1],["30Rnd_65x39_caseless_mag",2,30],["Chemlight_green",1,1],["11Rnd_45ACP_Mag",1,11]]],["V_PlateCarrier1_rgr",[["FirstAidKit",1],["30Rnd_65x39_caseless_mag",3,30],["SmokeShell",1,1],["SmokeShellGreen",1,1],["Chemlight_green",1,1],["HandGrenade",2,1],["11Rnd_45ACP_Mag",2,11],["APERSBoundingMine_Range_Mag",1,1]]],["B_AssaultPack_blk",[["FirstAidKit",1],["30Rnd_65x39_caseless_mag",1,30],["Chemlight_blue",1,1],["O_IR_Grenade",1,1],["APERSBoundingMine_Range_Mag",1,1]]],"H_HelmetB","G_Bandanna_oli",["Laserdesignator_02_ghex_F","","","",[],[],""],["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]]

TAG_fnc_clearBodies = {
	params[
		[ "_vehicle", vehicle player, [ objNull ] ],
		[ "_radius", 150, [ 0 ] ],
		[ "_disassemble", false, [ false ] ],
		[ "_clearCargo", false, [ false ] ]
	];

	//Needs better check to make sure object has a cargo space
	if ( _vehicle == player ) exitWith {
		"Error: Vehicle( param 0 ) must be a vehicle with cargo space" call BIS_fnc_error;
	};

	if ( _clearCargo ) then {
		clearItemCargoGlobal _vehicle;
		clearWeaponCargoGlobal _vehicle;
		clearMagazineCargoGlobal _vehicle;
		clearBackpackCargoGlobal _vehicle;
	};

	_doneHolders = [];

	{
		getUnitLoadout _x params[ "_primaryDetails", "_secondaryDetails", "_handGunDetails", "_uniformDetails", "_vestDetails", "_backpackDetails", "_headgear", "_goggles", "_binocularDetails", "_linkedItems" ];
		//Dropped weapons
		_holders = _x nearObjects[ "weaponHolderSimulated", 2 ];

		_holderWeapons = [];
		{
			if !( _x in _doneHolders ) then {
				_doneHolders pushBack _x;
				_holderWeapons append ( weaponsItems _x );
			}
		}forEach _holders;

		_fnc_disWeapon = {
			params[ "_cont", "_weaponDetails", "_cnt" ];
			_weaponDetails params[ "_weapon", "_muzzle", "_pointer", "_optic", "_magDetails", "_secMagDetails", "_bipod" ];

			_weaponBase = _weapon call BIS_fnc_baseWeapon;
			_cont addWeaponWithAttachmentsCargoGlobal[ [ _weaponBase, "", "", "", [], [], ""], _cnt ];

			{
				if !( _x == "" ) then {
					_cont addItemCargoGlobal[ _x, _cnt ];
				}
			}forEach[ _pointer, _muzzle, _optic, _bipod ];

			{
				_x params[ "_curMag", "_curMagAmmoCnt" ];
				if !( _curMag == "" ) then {
					_cont addMagazineAmmoCargo[ _curMag, _cnt, _curMagAmmoCnt ];
				};
			}forEach[ _magDetails, _secMagDetails ];
		};

		//Weapons
		{
			_x params[ "_weapon" ];

			if !( _weapon == "" ) then {
				if ( _disassemble ) then {
					[ _vehicle, _x, 1 ] call _fnc_disWeapon;
				}else{
					_vehicle addWeaponWithAttachmentsCargoGlobal[ _x, 1 ];
				};
			}
		}forEach ( _holderWeapons + [ _primaryDetails, _secondaryDetails, _handGunDetails, _binocularDetails ] );

		//Containers
		{
			_x params[ "_item", "_contItems" ];

			if !( _item == "" ) then {
				_every = everyContainer _vehicle;
				if ( _item call BIS_fnc_itemType select 1 == "backpack" ) then {
					_vehicle addBackpackCargoGlobal[ _item, 1 ];
				}else{
					_vehicle addItemCargoGlobal[ _item, 1 ];
				};

				_addedContainer = ( everyContainer _vehicle - _every ) select 0 select 1;
				clearItemCargoGlobal _addedContainer;
				clearWeaponCargoGlobal _addedContainer;
				clearMagazineCargoGlobal _addedContainer;
				clearBackpackCargoGlobal _addedContainer;

				if ( _disassemble ) then {
					_addedContainer = _vehicle;
				};

				{
					_x params[ "_item", "_cnt", "_ammoCnt" ];

					if ( _item isEqualType [] ) then {
						_weaponDetails = +_item;
						_item = _item select 0;
					};

					switch ( toLowerANSI ( _x call BIS_fnc_itemType select 0 )) do {
						case ( "weapon" ) : {
							if ( _disassemble ) then {
								[ _addedContainer, _weaponDetails, _cnt ] call _fnc_disWeapon;
							}else{
								_addedContainer addWeaponWithAttachmentsCargoGlobal[ _weaponDetails, _cnt ];
							};
						};
						case ( "mine" );
						case ( "magazine" ) : {
							_addedContainer addMagazineAmmoCargo[ _item, _cnt, _ammoCnt ];
						};
						default {
							_addedContainer addItemCargoGlobal[ _item, _cnt ];
						};
					};
				}forEach _contItems;
			};
		}forEach[ _uniformDetails, _vestDetails, _backpackDetails ];

		//Other
		{
			if !( _x == "" ) then {
				_vehicle addItemCargoGlobal[ _x, 1 ];
			}
		}forEach( _linkedItems + [ _headgear, _goggles ] );

		//Remove Body and Group
		_group = group _x;
		deleteVehicle _x;
		if ( count units _group == 0 ) then {
			deleteGroup _group;
		};

	}forEach ( getPosATL _vehicle nearObjects[ "CAManBase", _radius ] select{ !alive _x } );
};


//[
//	vehicle to store items in,
//	radius to search, optional( default 150m )
//	whether to dissemble every thing, optional( default false )
//	whether to clear vehicles current contents first, optional( default false )
//] call TAG_fnc_clearBodies;

//There is no checking for if the vehicles inventory becomes full

//A test Hunter called car
[ car, 30, true, true ] call TAG_fnc_clearBodies;

 

Needs thoroughly testing

  • Like 2

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

×