Jump to content
bangabob

Loot system (Configurable Loot script)

Recommended Posts

I just found this script and I love the simplicity of it. Been looking for something that just does what it says like this for a while to learn how it's done easier.

 

However, in just testing to make sure I called it right and it's using the altered arrays of the loot I want it to have, I noticed it's spawning a lot of things in the bottom left corner of Altis; the marker I am using for the script isn't even covering that part of the map and there's nothing but ocean out there (not even any ruins under the waves or something like that).It doesn't seem to want to place things down anywhere else but that corner and around Kavala, even though my marker is 15000x15000 and covers the entire landmass.

 

http://i.imgur.com/EcVS7Xu.jpg​<- this is all I end up with after waiting 20 minutes just to make sure it's not just taking a very long time to populate the entire map.

 

It also does not do anything if I run the script from the init.sqf; I have to execute it once I am standing around on the map.

Share this post


Link to post
Share on other sites

How can I make it work with modded weapons?

Get "...spawnLoot.sqf, line 46 [...] Error Undefined variable in expression: _magazineclass"

and "...spawnLoot.sqf, line 35 [...] Error Undefined variable in expression: _magazineclass"

 

Using CUP and RHS

  • Like 1

Share this post


Link to post
Share on other sites

I just found this script and I love the simplicity of it. Been looking for something that just does what it says like this for a while to learn how it's done easier.

 

However, in just testing to make sure I called it right and it's using the altered arrays of the loot I want it to have, I noticed it's spawning a lot of things in the bottom left corner of Altis; the marker I am using for the script isn't even covering that part of the map and there's nothing but ocean out there (not even any ruins under the waves or something like that).It doesn't seem to want to place things down anywhere else but that corner and around Kavala, even though my marker is 15000x15000 and covers the entire landmass.

 

http://i.imgur.com/EcVS7Xu.jpg​<- this is all I end up with after waiting 20 minutes just to make sure it's not just taking a very long time to populate the entire map.

 

It also does not do anything if I run the script from the init.sqf; I have to execute it once I am standing around on the map.

I am having the same exact issue but on Esseker. In singleplayer, it works just fine. If I load it as a multiplayer mission, it craps out on me and will only spawn half or less of the map with loot.

Share this post


Link to post
Share on other sites

How can I make it work with modded weapons?

Get "...spawnLoot.sqf, line 46 [...] Error Undefined variable in expression: _magazineclass"

and "...spawnLoot.sqf, line 35 [...] Error Undefined variable in expression: _magazineclass"

 

Using CUP and RHS

BangaBobThank you for your fantastic and simple script! I only have the same question about modded weapons.

 

Best regards!

Share this post


Link to post
Share on other sites

I'm new to the forums and I can't make my own topic post yet so I figured I'd ask someone who was working on the shop system for Wasteland; I'm currently installing Nato SF and Russian Spetsnaz weapons and Wander Panzer WAP to my Altis Wasteland server but I don't know how to implement them in the shop. (I also have IdentiZee but I don't think I need to edit the server mission to use that?) Anyone think they could explain some mission editing to me? (I have the tools to extract the Wasteland pbo and view/edit its contents, I just don't know how.)

Also, is there any way to add items from these mods to the random loot system of Wasteland?

Share this post


Link to post
Share on other sites

Get "...spawnLoot.sqf, line 46 [...] Error Undefined variable in expression: _magazineclass"

and "...spawnLoot.sqf, line 35 [...] Error Undefined variable in expression: _magazineclass"

 

have the same question about modded weapons.

 

Getting the same issue and i'm only using Apex.

 

 

RWjZBME.png

// Spawn Weapon
 if (_type == 0) 
		then {
	_weapon= weaponsLoot call bis_fnc_selectRandom; 
	
		_magazines = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
		_magazineClass = _magazines call bis_fnc_selectRandom; 

	_holder addWeaponCargoGlobal [_weapon, 1];
	 _holder addMagazineCargoGlobal [_magazineClass, 2];
				};
					
					
// Spawn Magazines
 if (_type == 1) 
		then {
	_weapon= weaponsLoot call bis_fnc_selectRandom; 
		_magazines = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
		_magazineClass = _magazines call bis_fnc_selectRandom; 

	 _holder addMagazineCargoGlobal [_magazineClass, 2];
				};	

Any help would be marvelous! Love this script. 

 

Edit: This error only started occurring after I customized the spawns. I'm wondering if it has to do with weapons and the type of magazines they use? All of the weapons spawning in that I have seen dont have any issues with spawning in with magazines. Perhaps the code is only asking for a limited 'type' of mags associated with those guns but some of them that i've chosen to spawn in have more than what the code is grabbing?

 

Either way, here's a snippet of my LootInit.sqf

// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
weaponsLoot= ["arifle_AKM_F","arifle_AKS_F","srifle_DMR_06_camo_F","SMG_05_base_F","arifle_TRG21_F","hgun_ACPC2_F","hgun_Pistol_01_F","hgun_Rook40_F","hgun_Pistol_heavy_02_F","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag"];
// Set items: Weapon attachments, first-aid, Binoculars
itemsLoot= ["Binocular","ToolKit","FirstAidKit","Medikit","optic_Aco","optic_Holosight","acc_flashlight","optic_MRCO","optic_DMS","bipod_01_F_blk","ItemMap","NVGoggles"];
// Set Clothing: Hats, Helmets
clothesLoot= ["H_HelmetB_paint","H_Booniehat_oli","H_HelmetSpecB_paint1","H_HelmetIA_camo","H_HelmetB_snakeskin","H_Cap_headphones","H_Cap_blk","H_Cap_usblack","H_HelmetCrew_I","H_Shemag_olive","H_Watchcap_blk","H_Watchcap_camo"];
// Set Vests: Any vests
vestsLoot= ["V_Rangemaster_belt","V_BandollierB_rgr","V_Chestrig_rgr","V_HarnessOSpec_brn","V_TacChestrig_oli_F"];
// Set Backpacks: Any packpacks
backpacksLoot= ["B_AssaultPack_rgr","B_Kitbag_rgr","B_TacticalPack_rgr"];

Edit 2: Derp. Re-reading my code i've realized I included some explosives that may be causing an issue. I'll remove those and report back.

 

 

Edit 3: It'd be amazing if there was a way to individually configure the percentages behind what kind of loot spawns in certain areas. There are certain items I want to be more common than others, but I still want loot in general to spawn at a certain rate in the markers I create. 

 

Edit 4: Firstly -- my error has gone away since removing those explosives from my weapons loot list.

 

Secondly -- i'm running into this pesky little issue where certain kinds of gear will take 'precedence' over other loot and even if you have some magazines in a loot pile with a backpack or vest, the backpack or vest will be the only thing that shows up for you in your inventory menu until you drag it onto your character/into his currently equipped backpack. it's by no means game breaking, just a minor nitpick.

Share this post


Link to post
Share on other sites

Getting the same issue and i'm only using Apex.

 

 

RWjZBME.png

// Spawn Weapon
 if (_type == 0) 
		then {
	_weapon= weaponsLoot call bis_fnc_selectRandom; 
	
		_magazines = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
		_magazineClass = _magazines call bis_fnc_selectRandom; 

	_holder addWeaponCargoGlobal [_weapon, 1];
	 _holder addMagazineCargoGlobal [_magazineClass, 2];
				};
					
					
// Spawn Magazines
 if (_type == 1) 
		then {
	_weapon= weaponsLoot call bis_fnc_selectRandom; 
		_magazines = getArray (configFile / "CfgWeapons" / _weapon / "magazines");
		_magazineClass = _magazines call bis_fnc_selectRandom; 

	 _holder addMagazineCargoGlobal [_magazineClass, 2];
				};	

Any help would be marvelous! Love this script. 

 

Edit: This error only started occurring after I customized the spawns. I'm wondering if it has to do with weapons and the type of magazines they use? All of the weapons spawning in that I have seen dont have any issues with spawning in with magazines. Perhaps the code is only asking for a limited 'type' of mags associated with those guns but some of them that i've chosen to spawn in have more than what the code is grabbing?

 

Either way, here's a snippet of my LootInit.sqf

// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
weaponsLoot= ["arifle_AKM_F","arifle_AKS_F","srifle_DMR_06_camo_F","SMG_05_base_F","arifle_TRG21_F","hgun_ACPC2_F","hgun_Pistol_01_F","hgun_Rook40_F","hgun_Pistol_heavy_02_F","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag"];
// Set items: Weapon attachments, first-aid, Binoculars
itemsLoot= ["Binocular","ToolKit","FirstAidKit","Medikit","optic_Aco","optic_Holosight","acc_flashlight","optic_MRCO","optic_DMS","bipod_01_F_blk","ItemMap","NVGoggles"];
// Set Clothing: Hats, Helmets
clothesLoot= ["H_HelmetB_paint","H_Booniehat_oli","H_HelmetSpecB_paint1","H_HelmetIA_camo","H_HelmetB_snakeskin","H_Cap_headphones","H_Cap_blk","H_Cap_usblack","H_HelmetCrew_I","H_Shemag_olive","H_Watchcap_blk","H_Watchcap_camo"];
// Set Vests: Any vests
vestsLoot= ["V_Rangemaster_belt","V_BandollierB_rgr","V_Chestrig_rgr","V_HarnessOSpec_brn","V_TacChestrig_oli_F"];
// Set Backpacks: Any packpacks
backpacksLoot= ["B_AssaultPack_rgr","B_Kitbag_rgr","B_TacticalPack_rgr"];

Edit 2: Derp. Re-reading my code i've realized I included some explosives that may be causing an issue. I'll remove those and report back.

 

 

Edit 3: It'd be amazing if there was a way to individually configure the percentages behind what kind of loot spawns in certain areas. There are certain items I want to be more common than others, but I still want loot in general to spawn at a certain rate in the markers I create. 

 

Edit 4: Firstly -- my error has gone away since removing those explosives from my weapons loot list.

 

Secondly -- i'm running into this pesky little issue where certain kinds of gear will take 'precedence' over other loot and even if you have some magazines in a loot pile with a backpack or vest, the backpack or vest will be the only thing that shows up for you in your inventory menu until you drag it onto your character/into his currently equipped backpack. it's by no means game breaking, just a minor nitpick.

 

"APERSBoundingMine_Range_Mag" and "APERSTripMine_Wire_Mag" will not work if you put them in the weapon array.

Share this post


Link to post
Share on other sites

"APERSBoundingMine_Range_Mag" and "APERSTripMine_Wire_Mag" will not work if you put them in the weapon array.

 

I managed to figure that out, albeit in a non-specific method. I appreciate the clarification.

  • Like 1

Share this post


Link to post
Share on other sites

I managed to figure that out, albeit in a non-specific method. I appreciate the clarification.

 

If you change spawnLoot to this, it will work:

if (isServer) then {
	params ["_pos", "_showLoot"];

	private _barrel = createVehicle ["Land_BarrelEmpty_F", _pos vectorAdd [0, 0, 0.1], [], 0, "can_Collide"];
	sleep 0.5;
	private _holder = createVehicle ["groundWeaponHolder", getPosATL _barrel, [], 0, "can_Collide"];
	deletevehicle _barrel;
	
	private _type = floor (random 5);
	private _weapon = selectRandom weaponsLoot;
	private _config = [
		"cfgMagazines",
		"cfgWeapons"
		] select (isClass (configFile >> "cfgWeapons" >> _weapon));
	private _magazines = [
		configFile >> _config >> _weapon >> "magazines",
		configFile >> _config >> _weapon
	] select (_config isEqualTo "cfgMagazines");
	_type = [_type, 1] select (_config isEqualTo "cfgMagazines");

	if (_showLoot) then {			
		private _debug = createMarker [ format ["%1", _pos], getPos _holder];
		_debug setMarkerShape "ICON";
		_debug setMarkerType "hd_dot";
		_debug setMarkerColor "ColorRed";
		_debug setMarkerText (format ["%1", _type]);	
	};

	switch _type do {
		case 0: {
			_holder addWeaponCargoGlobal [_weapon, 1];	
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [selectRandom _arr, 2];
			};
		};
		case 1: {
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [
					[
						selectRandom _arr,
						_weapon
					]select (_arr isEqualTo []),
					2
				];
			};
		};
		case 2: {
			_holder addItemCargoGlobal [selectRandom itemsLoot, 1];
			_holder addItemCargoGlobal [selectRandom clothesLoot, 1];
		
		};	
		case 3: {
			_holder addItemCargoGlobal [selectRandom vestsLoot, 1];		
		};	
		case 4: {
			_holder addBackpackCargoGlobal [selectRandom backpacksLoot, 1];	
		};	
		default {};
	};
};

I modified it to check whether or not the elements in the weapons array were valid weapons.

Share this post


Link to post
Share on other sites

If you change spawnLoot to this, it will work:

if (isServer) then {
	params ["_pos", "_showLoot"];

	private _barrel = createVehicle ["Land_BarrelEmpty_F", _pos vectorAdd [0, 0, 0.1], [], 0, "can_Collide"];
	sleep 0.5;
	private _holder = createVehicle ["groundWeaponHolder", getPosATL _barrel, [], 0, "can_Collide"];
	deletevehicle _barrel;
	
	private _type = floor (random 5);
	private _weapon = selectRandom weaponsLoot;
	private _config = [
		"cfgMagazines",
		"cfgWeapons"
		] select (isClass (configFile >> "cfgWeapons" >> _weapon));
	private _magazines = [
		configFile >> _config >> _weapon >> "magazines",
		configFile >> _config >> _weapon
	] select (_config isEqualTo "cfgMagazines");
	_type = [_type, 1] select (_config isEqualTo "cfgMagazines");

	if (_showLoot) then {			
		private _debug = createMarker [ format ["%1", _pos], getPos _holder];
		_debug setMarkerShape "ICON";
		_debug setMarkerType "hd_dot";
		_debug setMarkerColor "ColorRed";
		_debug setMarkerText (format ["%1", _type]);	
	};

	switch _type do {
		case 0: {
			_holder addWeaponCargoGlobal [_weapon, 1];	
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [selectRandom _arr, 2];
			};
		};
		case 1: {
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [
					[
						selectRandom _arr,
						_weapon
					]select (_arr isEqualTo []),
					2
				];
			};
		};
		case 2: {
			_holder addItemCargoGlobal [selectRandom itemsLoot, 1];
			_holder addItemCargoGlobal [selectRandom clothesLoot, 1];
		
		};	
		case 3: {
			_holder addItemCargoGlobal [selectRandom vestsLoot, 1];		
		};	
		case 4: {
			_holder addBackpackCargoGlobal [selectRandom backpacksLoot, 1];	
		};	
		default {};
	};
};

 

I modified it to check whether or not the elements in the weapons array were valid weapons.

 

Impressive. Thank you kindly. I'll tinker with it and see what goodies I can add to the loot spawns in my mission.

 

Inquiry: would it be too considerable a stretch of effort for an individual such as yourself to implement some sort of 'rarity' variable to this loot spawn script somehow? In other words, as the current script stands now, is it structured in such a way as to allow a 'rarity' variable to be implemented without too much hassle?

Share this post


Link to post
Share on other sites

Impressive. Thank you kindly. I'll tinker with it and see what goodies I can add to the loot spawns in my mission.

 

Inquiry: would it be too considerable a stretch of effort for an individual such as yourself to implement some sort of 'rarity' variable to this loot spawn script somehow? In other words, as the current script stands now, is it structured in such a way as to allow a 'rarity' variable to be implemented without too much hassle?

 

a probability for each type and/or for each item within a type?

Share this post


Link to post
Share on other sites

a probability for each type and/or for each item within a type?

 

more for each type, and not necessarily for each item within a type. that sounds like way more work than im willing to ask anyone to embark upon.

Share this post


Link to post
Share on other sites

more for each type, and not necessarily for each item within a type. that sounds like way more work than im willing to ask anyone to embark upon.

Change the following files:

 

LootInit.sqf:

if (isServer) then {
	params ["_mkr"];
	private _exclusionList = ["Land_Pier_F","Land_Pier_small_F","Land_NavigLight","Land_LampHarbour_F"];
	private _pos = markerpos _mkr;
	(getMarkerSize _mkr) params ["_mkrY", "_mkrX"];
	private _distance = [_mkrX, _mkrY] select (_mkrY > _mkrX);
	_mkr setmarkerAlpha 0;


	// Show loot position and type on map (Debugging)
	private _showLoot = true;
	// Set probability of loot spawning 1-100%, [Weapons, Maagzines, Clothes, Vests, Backpacks]
	private _probabilities = [50, 0, 0, 0, 0];
	
	// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
	weaponsLoot = ["arifle_AKM_F","arifle_AKS_F","srifle_DMR_06_camo_F","SMG_05_base_F","arifle_TRG21_F","hgun_ACPC2_F","hgun_Pistol_01_F","hgun_Rook40_F","hgun_Pistol_heavy_02_F","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag"];
	// Set items: Weapon attachments, first-aid, Binoculars
	itemsLoot = ["Binocular","ToolKit","FirstAidKit","Medikit","optic_Aco","optic_Holosight","acc_flashlight","optic_MRCO","optic_DMS","bipod_01_F_blk","ItemMap","NVGoggles"];
	// Set Clothing: Hats, Helmets, Uniforms
	clothesLoot = ["H_HelmetB_paint","H_Booniehat_oli","H_HelmetSpecB_paint1","H_HelmetIA_camo","H_HelmetB_snakeskin","H_Cap_headphones","H_Cap_blk","H_Cap_usblack","H_HelmetCrew_I","H_Shemag_olive","H_Watchcap_blk","H_Watchcap_camo"];
	// Set Vests: Any vests
	vestsLoot = ["V_Rangemaster_belt","V_BandollierB_rgr","V_Chestrig_rgr","V_HarnessOSpec_brn","V_TacChestrig_oli_F"];
	// Set Backpacks: Any packpacks
	backpacksLoot = ["B_AssaultPack_rgr","B_Kitbag_rgr","B_TacticalPack_rgr"];

	// Exclude buildings from loot spawn. Use 'TYPEOF' to find building name
	private _houseList = _pos nearObjects ["House", _distance];
	{
		if (!(typeOf _X in _exclusionList)) then {
			private _bpos = _x buildingpos -1;
			if (count _bpos > 0) then {
				for "_i" from 0 to (count _bpos -1)  do {
					private _type = floor (random 5);
					private _probability = _probabilities select _type;
			
					if (_probability > random 100) then {
						0 = [_bpos select _i, _showLoot, _type] execVM "spawnloot.sqf";
					};	
				};
			};
		};				
	} forEach _houseList;
	
};

spawnLoot.sqf

:

if (isServer) then {
	params ["_pos", "_showLoot", "_type"];

	private _barrel = createVehicle ["Land_BarrelEmpty_F", _pos vectorAdd [0, 0, 0.1], [], 0, "can_Collide"];
	sleep 0.5;
	private _holder = createVehicle ["groundWeaponHolder", getPosATL _barrel, [], 0, "can_Collide"];
	deletevehicle _barrel;
	
	private _weapon = selectRandom weaponsLoot;
	private _config = [
		"cfgMagazines",
		"cfgWeapons"
		] select (isClass (configFile >> "cfgWeapons" >> _weapon));
		
	private _magazines = [
		configFile >> _config >> _weapon >> "magazines",
		configFile >> _config >> _weapon
	] select (_config isEqualTo "cfgMagazines");
	
	_type = [_type, 1] select (_config isEqualTo "cfgMagazines");

	if (_showLoot) then {			
		private _debug = createMarker [ format ["%1", _pos], getPos _holder];
		_debug setMarkerShape "ICON";
		_debug setMarkerType "hd_dot";
		_debug setMarkerColor "ColorRed";
		_debug setMarkerText (format ["%1", _type]);	
	};

	switch _type do {
		case 0: {
			_holder addWeaponCargoGlobal [_weapon, 1];	
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [selectRandom _arr, 2];
			};
		};
		case 1: {
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [
					[
						selectRandom _arr,
						_weapon
					]select (_arr isEqualTo []),
					2
				];
			};
		};
		case 2: {
			_holder addItemCargoGlobal [selectRandom itemsLoot, 1];
			_holder addItemCargoGlobal [selectRandom clothesLoot, 1];
		
		};	
		case 3: {
			_holder addItemCargoGlobal [selectRandom vestsLoot, 1];		
		};	
		case 4: {
			_holder addBackpackCargoGlobal [selectRandom backpacksLoot, 1];	
		};	
		default {};
	};
};

To change probabilities change the numbers in the _probabilities array.

 

Ideally this could be improved by defining the probabilities and item arrays outside of the script such that they aren't pointlessly redefined upon each execution.

Share this post


Link to post
Share on other sites

Change the following files:

 

 

LootInit.sqf:

if (isServer) then {
	params ["_mkr"];
	private _exclusionList = ["Land_Pier_F","Land_Pier_small_F","Land_NavigLight","Land_LampHarbour_F"];
	private _pos = markerpos _mkr;
	(getMarkerSize _mkr) params ["_mkrY", "_mkrX"];
	private _distance = [_mkrX, _mkrY] select (_mkrY > _mkrX);
	_mkr setmarkerAlpha 0;


	// Show loot position and type on map (Debugging)
	private _showLoot = true;
	// Set probability of loot spawning 1-100%, [Weapons, Maagzines, Clothes, Vests, Backpacks]
	private _probabilities = [50, 0, 0, 0, 0];
	
	// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
	weaponsLoot = ["arifle_AKM_F","arifle_AKS_F","srifle_DMR_06_camo_F","SMG_05_base_F","arifle_TRG21_F","hgun_ACPC2_F","hgun_Pistol_01_F","hgun_Rook40_F","hgun_Pistol_heavy_02_F","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag"];
	// Set items: Weapon attachments, first-aid, Binoculars
	itemsLoot = ["Binocular","ToolKit","FirstAidKit","Medikit","optic_Aco","optic_Holosight","acc_flashlight","optic_MRCO","optic_DMS","bipod_01_F_blk","ItemMap","NVGoggles"];
	// Set Clothing: Hats, Helmets, Uniforms
	clothesLoot = ["H_HelmetB_paint","H_Booniehat_oli","H_HelmetSpecB_paint1","H_HelmetIA_camo","H_HelmetB_snakeskin","H_Cap_headphones","H_Cap_blk","H_Cap_usblack","H_HelmetCrew_I","H_Shemag_olive","H_Watchcap_blk","H_Watchcap_camo"];
	// Set Vests: Any vests
	vestsLoot = ["V_Rangemaster_belt","V_BandollierB_rgr","V_Chestrig_rgr","V_HarnessOSpec_brn","V_TacChestrig_oli_F"];
	// Set Backpacks: Any packpacks
	backpacksLoot = ["B_AssaultPack_rgr","B_Kitbag_rgr","B_TacticalPack_rgr"];

	// Exclude buildings from loot spawn. Use 'TYPEOF' to find building name
	private _houseList = _pos nearObjects ["House", _distance];
	{
		if (!(typeOf _X in _exclusionList)) then {
			private _bpos = _x buildingpos -1;
			if (count _bpos > 0) then {
				for "_i" from 0 to (count _bpos -1)  do {
					private _type = floor (random 5);
					private _probability = _probabilities select _type;
			
					if (_probability > random 100) then {
						0 = [_bpos select _i, _showLoot, _type] execVM "spawnloot.sqf";
					};	
				};
			};
		};				
	} forEach _houseList;
	
};

spawnLoot.sqf

:

if (isServer) then {
	params ["_pos", "_showLoot", "_type"];

	private _barrel = createVehicle ["Land_BarrelEmpty_F", _pos vectorAdd [0, 0, 0.1], [], 0, "can_Collide"];
	sleep 0.5;
	private _holder = createVehicle ["groundWeaponHolder", getPosATL _barrel, [], 0, "can_Collide"];
	deletevehicle _barrel;
	
	private _weapon = selectRandom weaponsLoot;
	private _config = [
		"cfgMagazines",
		"cfgWeapons"
		] select (isClass (configFile >> "cfgWeapons" >> _weapon));
		
	private _magazines = [
		configFile >> _config >> _weapon >> "magazines",
		configFile >> _config >> _weapon
	] select (_config isEqualTo "cfgMagazines");
	
	_type = [_type, 1] select (_config isEqualTo "cfgMagazines");

	if (_showLoot) then {			
		private _debug = createMarker [ format ["%1", _pos], getPos _holder];
		_debug setMarkerShape "ICON";
		_debug setMarkerType "hd_dot";
		_debug setMarkerColor "ColorRed";
		_debug setMarkerText (format ["%1", _type]);	
	};

	switch _type do {
		case 0: {
			_holder addWeaponCargoGlobal [_weapon, 1];	
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [selectRandom _arr, 2];
			};
		};
		case 1: {
			if (isClass _magazines) then {
				private _arr = getArray _magazines;
				_holder addMagazineCargoGlobal [
					[
						selectRandom _arr,
						_weapon
					]select (_arr isEqualTo []),
					2
				];
			};
		};
		case 2: {
			_holder addItemCargoGlobal [selectRandom itemsLoot, 1];
			_holder addItemCargoGlobal [selectRandom clothesLoot, 1];
		
		};	
		case 3: {
			_holder addItemCargoGlobal [selectRandom vestsLoot, 1];		
		};	
		case 4: {
			_holder addBackpackCargoGlobal [selectRandom backpacksLoot, 1];	
		};	
		default {};
	};
};

 

To change probabilities change the numbers in the _probabilities array.

 

Ideally this could be improved by defining the probabilities and item arrays outside of the script such that they aren't pointlessly redefined upon each execution.

 

You're top notch, sir. I got pulled away for a minute but i'll put this to the test here very shortly and report back with my findings. Once again, many thanks for your help so far.

Share this post


Link to post
Share on other sites

@hallyg:

 

I've tested a bit and seem to have run into the misfortune of no magazines spawning for weapons whatsoever. Neither with the weapons themselves nor on their own.

 

Edit: I am, however, experiencing quite a lot of mines in the loot now. Ironically

Share this post


Link to post
Share on other sites

@hallyg:

 

I've tested a bit and seem to have run into the misfortune of no magazines spawning for weapons whatsoever. Neither with the weapons themselves nor on their own.

 

Edit: I am, however, experiencing quite a lot of mines in the loot now. Ironically

That's odd. Weapons seem to be spawning with magazines for me:

I did change the following lines, assuming the original classnames are correct, to:

		case 0: {
			_holder addWeaponCargoGlobal [_weapon, 1];	
			private _arr = getArray _magazines;
			_holder addMagazineCargoGlobal [selectRandom _arr, 2];
		};
		case 1: {
			private _arr = getArray _magazines;
			_holder addMagazineCargoGlobal [
				[
					selectRandom _arr,
					_weapon
				] select (_arr isEqualTo []),
				2
			];
		};

Share this post


Link to post
Share on other sites

I just added all relevant magazine classnames to my 'weapons' array. I'm going to give it a quick spin and see how it works out. Then i'll return to give your updated bit a whirl.

// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
	weaponsLoot = ["arifle_AKM_F","arifle_AKS_F","srifle_DMR_06_camo_F","SMG_05_base_F","arifle_TRG21_F","hgun_ACPC2_F","hgun_Rook40_F","hgun_Pistol_heavy_02_F","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag","30Rnd_762x39_Mag_F","30Rnd_545x39_Mag_F","30Rnd_9x21_Mag_SMG_02","20Rnd_762x51_Mag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag_Tracer_Red","16Rnd_9x21_Mag","6Rnd_45ACP_Cylinder","9Rnd_45ACP_Mag",];

Share this post


Link to post
Share on other sites

 

I just added all relevant magazine classnames to my 'weapons' array. I'm going to give it a quick spin and see how it works out. Then i'll return to give your updated bit a whirl.

// Set Weapon loot: Primary weapons, secondary weapons, Sidearms.
	weaponsLoot = ["arifle_AKM_F","arifle_AKS_F","srifle_DMR_06_camo_F","SMG_05_base_F","arifle_TRG21_F","hgun_ACPC2_F","hgun_Rook40_F","hgun_Pistol_heavy_02_F","APERSBoundingMine_Range_Mag","APERSTripMine_Wire_Mag","30Rnd_762x39_Mag_F","30Rnd_545x39_Mag_F","30Rnd_9x21_Mag_SMG_02","20Rnd_762x51_Mag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag_Tracer_Red","16Rnd_9x21_Mag","6Rnd_45ACP_Cylinder","9Rnd_45ACP_Mag",];

With the script you don't need to add your magazines to the array, it automatically takes the weapon's compatible magazines from the config. The only reason why I changed it was so you could put explosives in the array and they would still spawn- as far as I know explosives don't have a weapon which they originate from- because explosives items (until they are placed) are registered as magazines by the game and as such don't have a cfgWeapons class.

Share this post


Link to post
Share on other sites

With the script you don't need to add your magazines to the array, it automatically takes the weapon's compatible magazines from the config. The only reason why I changed it was so you could put explosives in the array and they would still spawn- as far as I know explosives don't have a weapon which they originate from- because explosives items (until they are placed) are registered as magazines by the game and as such don't have a cfgWeapons class.

 

Right right.

 

Just tested out my method -- shoddy at best :P Got a bunch of magazines spawning in, but hardly any weapons!

 

Going to try out your updated bit now. Will return in a moment.

Share this post


Link to post
Share on other sites

@hallyg:

 

Update -- rolled back my previous method, implemented yours -- seems to be working like a charm! Very happy about this whole process thus far. All that's really left to do is a bit of tweaking percentages.

 

My next big step is hunting down some sort of hunger/thirst script and implementing the related items (water bottles, canned food, etc.) into the loot system.

 

Disclaimer: i'm not designing a DayZ or Tanoa Life mission. Making a co-op mission for myself and a small group of friends.

 

Please don't hate me

  • Like 1

Share this post


Link to post
Share on other sites

Try the heroes survive mod - should do what you want   :)

 

You and hallyg both -- top gents! :D

Share this post


Link to post
Share on other sites

Having probs getting this to work via multiple triggers on Altis.I setup 3 triggers[3,000x4000 meters] encompassing  only areas of Altis gameplay will take place. Ingame inside first trigger loot spawns but by the time I make it to the 2nd trigger the spawns stop?I've tried using just one trigger that covers most of Altis yet loot spawns only in one area.(Kavala)

Share this post


Link to post
Share on other sites

I'm realllly trying to find a way to have different markers for different loot probabilities.  Nothing I seem to do can change where the loot will spawn. mkr and mkr2.  Any hits on where I need to change the lootint to recognize a second marker?

Or rather, separate trigger calling a second loot script that only spawns items in mkr2 (maker 2)? 

 

 

Edit: I got that to work...funny...setting the trigger to _null = mkr2 finally worked..... some reason.... unknown

BUT NOW the scripts don't stop running after I leave the spawn area. 

Edited by zigeris
Double posting avoidance

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

×