Jump to content

[RELEASE] Really Random Loadouts


Recommended Posts

BetterDeadThanZed, 

Can you explain this portion is more detail for the folks that have no clue but are trying to learn? like me :D

sorta figured it out below.  Can someone verify if it is correct or not? thanks!

 

find_suitable_ammunition = {

private["_weapon","_result","_ammoArray"];

_result = false;
_weapon = _this;
_ammoArray = getArray (configFile >> "cfgWeapons" >> _weapon >> "magazines");

if (count _ammoArray > 0) then {
_result = _ammoArray select 0;
};

_result

};

loadout_fnc_selectRandom = {
_this select (floor random (count _this)) // floor gives equal distribution of numbers randomly
_this select (floor random (count _primary)) // this is what it sees counts the # inside the array then returning a result to _this
};

UPDATE: I figured this out (to an extent).   loadout_fnc_selectRandom is a custom made function. find_suitable_ammunition is used to sort out the list called by loadout_fnc_SelectRandom (randomly). Since you can't call BIS_fnc_Random before the compiles you have to define your own custom function.   

_primary = ["M16A2","M16A4","M4A1","Sa58P_EP1","Sa58V_EP1","AKS_74_U","AK_47_M","AK_74","FN_FAL","Winchester1866"]; call loadout_fnc_selectRandom;

calls the custom function which adds up the total # inside _primary array, returns a value (10 in my above example - 10 weapons are defined). floor random will generate one random number (lets say picks #3 "M4A1") this will be passed to _this.  

_secondary = ["glock17_EP1","Colt1911","M9","Makarov","revolver_EP1"] call loadout_fnc_selectRandom;

this does the same assigning one of the defined secondary weapons to the array called _secondary. 

_ammo = _primary call find_suitable_ammunition;   // takes the selected weapon picked from loadout_fnc_selectRandom passed it to find_suitable returns mag to _ammo
_ammos = _secondary call find_suitable_ammunition; // does the same for _secondary

this will get the appropriate ammo selection for the weapon selected for _primary.  it passes ["M4A1"] to _ammoArray = getArray (configfile >> "cfgWeapons" >> _weapon >> "magazines"); now this part I just assume is is finding the named weapon and locating its proper magazine and dumping into another array. Then we are dumping that array into _ammoArray.  

NOTE: After researching I found that if the muzzle types like GL (Grenade Launchers) might prove this to be an issue? GetArray (configfile emphasis on configfile.  Since I am assuming it pulls any class names from this file. I found this blurp: "Contains the game configs as they exist in memory when the game is running" .

Have to assume that   "cfgWeapons" >> _weapon >> "magazines");  is a pre-defined search (built-into-ArmA)  that finds (M4A1) >> then its magazine class name that is associated with that weapon?

	if (count _ammoArray > 0) then {
		_result = _ammoArray select 0;
	};

	_result

if (  "30Rnd_556x45_Stanag" > 0) then { _result = _ammoArray select 0; then passes this to _result?.  Count would be #3 in my example.  The "30Rnd_556x45_Stanag" is one of the acceptable magazines for "M4A1" the whole part IF (count _ammoArray > 0) then { stumps me...  maybe because its 3am.  Can anyone expand on this whole theory I just attempted to unfold?

Edited by Just_R
trying to wrap my brain around this
Link to comment
Share on other sites

All that code is doing is finding proper ammo for whatever weapon is selected. That code was provided to me from someone else (can't remember specifically who it was). It checks to see what weapon it's spawning, then checks the config files for the proper ammo for that weapon.

Ok so you can have this called before any arrays are defined? I am use to top-down programming meaning you have to define the array or variable then  you can do magic like this.  So basically it will see the M16A2 lets say in _primary and then select stang round without you having define it, lets say in a separate array? I will have to research out how this works. 

See my ABOVE post

Edited by Just_R
Link to comment
Share on other sites

BetterDeadThenZed.. hats up to you.. awesome little script..

 

Just wanted to Post my Edited Version for people in case they decide they wanted to use it as well. I took some of the weapons out but people can add them back and many more.

 

/// Code Written By BetterDeadThenZed - Special Thanks Too Him. - Edits By DizzY DizzAsteR - LostandCrazyGamerZ

///-----------------------Start of ammo Select for weapon DO NOT EDIT----------------------------///////////

// Allows the Ammo to be selected to the proper weapon in the Array - DO NOT EDIT
find_suitable_ammunition = {

	private["_weapon","_result","_ammoArray"];

	_result 	= false;
	_weapon 	= _this;
	_ammoArray 	= getArray (configFile >> "cfgWeapons" >> _weapon >> "magazines");

	if (count _ammoArray > 0) then {
		_result = _ammoArray select 0;
	};

	_result

};
///-----------------------END-----------------------------------------------------------///


loadout_fnc_selectRandom = {
    _this select (floor random (count _this))
};

//Loadout Config --- Edits go in here ---////

// Main Weapon
_primary = ["Winchester1866","M1014","LeeEnfield","huntingrifle","Remington870_lamp"] call loadout_fnc_selectRandom;
// Secondary Weapon
_secondary = ["glock17_EP1","Colt1911","M9","Makarov","revolver_EP1"] call loadout_fnc_selectRandom;
// Main Weapon Ammo
_ammo = _primary call find_suitable_ammunition;
// Secondary Weapon Ammo
_ammos = _secondary call find_suitable_ammunition;
// Array of Food
_food = ["FoodbaconCooked","FoodbeefCooked","FoodCanBadGuy","FoodCanBakedBeans","FoodCanBoneboy","FoodCanCorn","FoodCanCurgon","FoodCanDemon","FoodCanFraggleos","FoodCanFrankBeans","FoodCanGriff",
"FoodCanHerpy","FoodCanOrlok","FoodCanPasta","FoodCanPowell","FoodCanSardines","FoodCanTylers","FoodchickenCooked","FoodMRE","FoodmuttonCooked","FoodNutmix","FoodPistachio","FoodrabbitCooked","ItemSeaBassCooked"] call loadout_fnc_selectRandom;
// Array of Drink
_drink = ["ItemSodaCoke","ItemSodaMdew","ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaRbull","ItemWaterbottle","ItemSodaR4z0r"] call loadout_fnc_selectRandom;
// Array of Medical Supplies Given
_med1 = ["ItemAntibiotic","ItemBandage","ItemBloodbag","ItemEpinephrine"] call loadout_fnc_selectRandom;
_med2 = ["ItemAntibiotic","ItemBandage","ItemBloodbag","ItemEpinephrine"] call loadout_fnc_selectRandom;
_med3 = ["ItemAntibiotic","ItemBandage","ItemBloodbag","ItemEpinephrine"] call loadout_fnc_selectRandom;
// Array Of Tools
_tool = ["ItemCompass","ItemCrowbar","ItemEtool","ItemFishingPole","ItemFlashlight","ItemFlashlightRed","ItemGPS","ItemHatchet_DZE","ItemHeatPack","ItemKnife",
"ItemMachete","ItemMatchbox_DZE","ItemMorphine","ItemPainkiller","ItemToolbox","ItemWatch","NVGoggles"] call loadout_fnc_selectRandom;
_tool2 = ["ItemCompass","ItemCrowbar","ItemEtool","ItemFishingPole","ItemFlashlight","ItemFlashlightRed","ItemGPS","ItemHatchet_DZE","ItemHeatPack","ItemKnife",
"ItemMachete","ItemMatchbox_DZE","ItemMorphine","ItemPainkiller","ItemToolbox","ItemWatch","NVGoggles"] call loadout_fnc_selectRandom;

// Actual Default Load-out Used

DefaultMagazines = [_ammo,_ammos,_food,_drink]; 
DefaultWeapons = ["ItemRadio","ItemMap",_primary,_secondary]; 
DefaultBackpack = "DZ_TK_Assault_Pack_EP1"; 
DefaultBackpackItems = [_med1,_med2,_med3,_tool,_tool2];













 

Edited by lostandcrazy34
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...