Jump to content

[RELEASE] Really Random Loadouts


Recommended Posts

This mod will give your players random loadouts as a new spawn, or after death. What makes this different from the other random loadout scripts? The only other loadout scripts I've found really just give a random custom loadout. They choose from a group of loadouts and gives a player that. This mod can randomize every item in a player's inventory. So, let's get started!

 

First, I'd like to thank itsatrap and Defent for helping me work out how to give ammo to the weapons. Thank you to Gr8 for showing me a better way to make this more organized!

 

Everything is done in your init.sqf. You should already know how to get to it and edit it.

 

In init.sqf, find this code:

EpochEvents = [["any","any","any","any",30,"crash_spawner"],["any","any","any","any",0,"crash_spawner"],["any","any","any","any",15,"supply_drop"]];

Directly above that, put this code:

execVM "custom\loadout\loadout.sqf";

Next, make a folder called custom\loadout and make a file called loadout.sqf with the below code in it:

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))
};

_primary = ["M16A2","M16A4","M4A1","Sa58P_EP1","Sa58V_EP1","AKS_74_U","AK_47_M","AK_74","FN_FAL","Winchester1866","MR43","M1014","LeeEnfield","Saiga12K","huntingrifle"] call loadout_fnc_selectRandom;
_secondary = ["glock17_EP1","Colt1911","M9","Makarov","revolver_EP1"] call loadout_fnc_selectRandom;
_ammo = _primary call find_suitable_ammunition;
_ammos = _secondary call find_suitable_ammunition;
_food = ["FoodBioMeat","FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodCanUnlabeled","FoodMRE","FoodNutmix","FoodPistachio","FoodSteakCooked"] call loadout_fnc_selectRandom;
_drink = ["ItemSodaCoke","ItemSodaMdew","ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaRbull","ItemWaterbottle"] call loadout_fnc_selectRandom;
_backpack = ["DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch"] call loadout_fnc_selectRandom;

DefaultMagazines = ["ItemBandage","ItemMorphine","ItemPainkiller",_ammo,_ammos,_food,_drink]; 
DefaultWeapons = ["ItemMap",_primary,_secondary]; 
DefaultBackpack = _backpack; 
DefaultBackpackWeapon = "";
DZE_defaultSkin = [["Skin_Camo1_DZ","Skin_Rocket_DZ","Skin_Soldier1_DZ","Skin_FR_OHara_DZ","Skin_FR_Rodriguez_DZ","Skin_Graves_Light_DZ","Skin_CZ_Special_Forces_GL_DES_EP1_DZ"],["Skin_SurvivorW2_DZ","Skin_SurvivorW3_DZ","Skin_SurvivorWcombat_DZ","Skin_SurvivorWdesert_DZ","Skin_SurvivorWurban_DZ","Skin_SurvivorWpink_DZ"]];

Explanation of the settings:

 

_primary and _secondary are lists of primary and secondary weapons that a player can spawn with. Adjust this as you see fit.

_food, _drink, and _backpack are lists of food, drink and backpacks that a player can spawn with. Again, adjust to your needs.

 

DefaultMagazines is the list of items in the player's magazine slots. This includes the food, drink and ammo for the primary and secondary weapons. In the above code, only one magazine for each is given to a player. To give multiple magazines, add more _ammo (primary ammo) and _ammos (secondary ammo). For example, the below code will give a player three magazines for the primary weapon and two magazines for the secondary weapon:

DefaultMagazines = ["ItemBandage","ItemMorphine","ItemPainkiller",_ammo,_ammo,_ammo,_ammos,_ammos,_food,_drink];

You can also add more _food and _drink entries to give multiple food and drink items. Using the above examples, you could also give random medical supplies and toolbelt items. Just create a _medical line or _toolbelt line and make an array of medical items or toolbelt items, inserting _medical or _toolbelt into the DefaultMagazines line.

 

Please let me know if you have any questions!

Link to comment
Share on other sites

I don't quite understand. Can you elaborate?

 

It doesnt make much of a difference, but it makes things organized and very easy to edit

------------------

 

In init.sqf, find this code:

EpochEvents = [["any","any","any","any",30,"crash_spawner"],["any","any","any","any",0,"crash_spawner"],["any","any","any","any",15,"supply_drop"]];

Directly above that, put this code:

execVM "custom\loadouts.sqf";

Make loadouts.sqf in your custom folder in your mission PBO

 

Add this in your loadouts.sqf

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))
};

_primary = ["M16A2","M16A4","M4A1","Sa58P_EP1","Sa58V_EP1","AKS_74_U","AK_47_M","AK_74","FN_FAL","Winchester1866","MR43","M1014","LeeEnfield","Saiga12K","huntingrifle"] call loadout_fnc_selectRandom;
_secondary = ["glock17_EP1","Colt1911","M9","Makarov","revolver_EP1"] call loadout_fnc_selectRandom;
_ammo = _primary call find_suitable_ammunition;
_ammos = _secondary call find_suitable_ammunition;
_food = ["FoodBioMeat","FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodCanUnlabeled","FoodMRE","FoodNutmix","FoodPistachio","FoodSteakCooked"] call loadout_fnc_selectRandom;
_drink = ["ItemSodaCoke","ItemSodaMdew","ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaRbull","ItemWaterbottle"] call loadout_fnc_selectRandom;
_backpack = ["DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch"] call loadout_fnc_selectRandom;

DefaultMagazines = ["ItemBandage","ItemMorphine","ItemPainkiller",_ammo,_ammos,_food,_drink]; 
DefaultWeapons = ["ItemMap",_primary,_secondary]; 
DefaultBackpack = _backpack; 
DefaultBackpackWeapon = "";
DZE_defaultSkin = [["Skin_Camo1_DZ","Skin_Rocket_DZ","Skin_Soldier1_DZ","Skin_FR_OHara_DZ","Skin_FR_Rodriguez_DZ","Skin_Graves_Light_DZ","Skin_CZ_Special_Forces_GL_DES_EP1_DZ"],["Skin_SurvivorW2_DZ","Skin_SurvivorW3_DZ","Skin_SurvivorWcombat_DZ","Skin_SurvivorWdesert_DZ","Skin_SurvivorWurban_DZ","Skin_SurvivorWpink_DZ"]];
Link to comment
Share on other sites

Also why did you choose to make another function if you can use BIS_fnc_selectRandom

 

Like So :

_primary = ["M16A2","M16A4","M4A1","Sa58P_EP1","Sa58V_EP1","AKS_74_U","AK_47_M","AK_74","FN_FAL","Winchester1866","MR43","M1014","LeeEnfield","Saiga12K","huntingrifle"] call BIS_fnc_selectRandom;
_possibleMags = getArray (configfile >> "cfgWeapons" >> _primary >> "magazines");
_ammo = _possibleMags select 0;
Link to comment
Share on other sites

Might be a bit late for this bit of a suggestion... but instead of modifying this in the mission.. why not edit the playerlogin.sqf  and call from the configs to truly be random, and not use these arrays?  Then you can make 1 array that blacklists specific weapons and you can even make strings to blacklist things like ACOG or AIM so that no weapon with that in its name will be given. Thats what we do on my overwatch server.  Just food for thought!

Link to comment
Share on other sites

Might be a bit late for this bit of a suggestion... but instead of modifying this in the mission.. why not edit the playerlogin.sqf  and call from the configs to truly be random, and not use these arrays?  Then you can make 1 array that blacklists specific weapons and you can even make strings to blacklist things like ACOG or AIM so that no weapon with that in its name will be given. Thats what we do on my overwatch server.  Just food for thought!

 

snip

Link to comment
Share on other sites

Might be a bit late for this bit of a suggestion... but instead of modifying this in the mission.. why not edit the playerlogin.sqf  and call from the configs to truly be random, and not use these arrays?  Then you can make 1 array that blacklists specific weapons and you can even make strings to blacklist things like ACOG or AIM so that no weapon with that in its name will be given. Thats what we do on my overwatch server.  Just food for thought!

 

For my purposes, it's easier to list the weapons that can be given to a new spawn. There would be so many weapons to exclude from a new spawn, it would be ridiculous. I also would rather edit a single line in the init.sqf and upload a custom .sqf to another folder rather than make changes to core Epoch files.

Link to comment
Share on other sites

For my purposes, it's easier to list the weapons that can be given to a new spawn. There would be so many weapons to exclude from a new spawn, it would be ridiculous. I also would rather edit a single line in the init.sqf and upload a custom .sqf to another folder rather than make changes to core Epoch files.

yea fair enough, I suppose it would cause more issues when epoch is updated. I dont really have to worry about it with overwatch.

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...

Is there anyone who can tell me how to make each item (_medical, _drink, _food, etc) have a random chance, like between .1 and 1 so maybe the person might not even receive that type of item?

 

thanks in advance. ;-)

Link to comment
Share on other sites

Is there anyone who can tell me how to make each item (_medical, _drink, _food, etc) have a random chance, like between .1 and 1 so maybe the person might not even receive that type of item?

 

thanks in advance. ;-)

Bump

Link to comment
Share on other sites

What about if we want some players spawn with a specific loadout and the rest random?

 

I had the same thought, got it working and will post my version in couple minutes.

 

Edit: here we go. Do note that this gives random skins to people in admin etc lists. I dont mind and I'm not fixing it.

 

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))
};

_primary = ["M16A2","M16A4","M4A1","Sa58P_EP1","Sa58V_EP1","AKS_74_U","AK_47_M","AK_74","FN_FAL","Winchester1866","MR43","M1014","LeeEnfield","Saiga12K","huntingrifle"] call loadout_fnc_selectRandom;
_secondary = ["glock17_EP1","Colt1911","M9","Makarov","revolver_EP1"] call loadout_fnc_selectRandom;
_ammo = _primary call find_suitable_ammunition;
_ammos = _secondary call find_suitable_ammunition;
_food = ["FoodBioMeat","FoodCanBakedBeans","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodCanUnlabeled","FoodMRE","FoodNutmix","FoodPistachio","FoodSteakCooked"] call loadout_fnc_selectRandom;
_drink = ["ItemSodaCoke","ItemSodaMdew","ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaRbull","ItemWaterbottle"] call loadout_fnc_selectRandom;
_backpack = ["DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch"] call loadout_fnc_selectRandom;

DefaultMagazines = ["ItemBandage","ItemMorphine","ItemPainkiller",_ammo,_ammos,_food,_drink];
DefaultWeapons = ["ItemMap",_primary,_secondary];
DefaultBackpack = _backpack;
DefaultBackpackWeapon = "";
DZE_defaultSkin = [["Skin_Camo1_DZ","Skin_Rocket_DZ","Skin_Soldier1_DZ","Skin_FR_OHara_DZ","Skin_FR_Rodriguez_DZ","Skin_Graves_Light_DZ","Skin_CZ_Special_Forces_GL_DES_EP1_DZ"],["Skin_SurvivorW2_DZ","Skin_SurvivorW3_DZ","Skin_SurvivorWcombat_DZ","Skin_SurvivorWdesert_DZ","Skin_SurvivorWurban_DZ","Skin_SurvivorWpink_DZ"]];

//Default Loadout
//DefaultMagazines = ["ItemBandage","17Rnd_9x19_glock17","ItemPainkiller"];
//DefaultWeapons = ["glock17_EP1","ItemFlashlight"];
//DefaultBackpack = "";
//DefaultBackpackWeapon = "";

//Admin Loadout
if ((getPlayerUID player) in ["PUID","PUID"]) then {
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemMorphine","ItemPainkiller","ItemBloodbag","ItemWaterbottleBoiled","FoodSteakCooked","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","Skin_Priest_DZ"];
DefaultWeapons = ["RH_m9csd","RH_m1sacog","Binocular_Vector","NVGoggles","ItemMap","ItemCompass","ItemGPS","ItemWatch","ItemKnife","Itemtoolbox","ItemCrowbar","Itemetool","ItemHatchet"];
DefaultBackpack = "DZ_LargeGunBag_EP1";
DefaultBackpackItems = ["ItemBandage","ItemBandage","ItemMorphine","ItemMorphine","ItemPainkiller","ItemPainkiller","ItemBloodbag","ItemBloodbag","ItemWaterbottleBoiled","FoodSteakCooked","ItemWaterbottleBoiled","FoodSteakCooked","Skin_Graves_Light_DZ","Skin_Sniper1_DZ"];
};

//Moderator Loadout
if ((getPlayerUID player) in ["PUID","PUID"]) then {
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemMorphine","ItemPainkiller","ItemBloodbag","ItemWaterbottleBoiled","FoodSteakCooked","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","Skin_Priest_DZ"];
DefaultWeapons = ["RH_m9csd","RH_m1sacog","Binocular_Vector","NVGoggles","ItemMap","ItemCompass","ItemGPS","ItemWatch","ItemKnife","Itemtoolbox","ItemCrowbar","Itemetool","ItemHatchet"];
DefaultBackpack = "DZ_LargeGunBag_EP1";
DefaultBackpackItems = ["ItemBandage","ItemBandage","ItemMorphine","ItemMorphine","ItemPainkiller","ItemPainkiller","ItemBloodbag","ItemBloodbag","ItemWaterbottleBoiled","FoodSteakCooked","ItemWaterbottleBoiled","FoodSteakCooked","Skin_Graves_Light_DZ","Skin_Sniper1_DZ"];
};

//Pro-Donator Loadout
if ((getPlayerUID player) in ["PUID","PUID"]) then {
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","15Rnd_9x19_M9SD","15Rnd_9x19_M9SD","ItemMorphine","ItemPainkiller","ItemBloodbag","ItemWaterbottleBoiled","ItemWaterbottleBoiled","FoodSteakCooked","8Rnd_B_Beneli_Pellets","8Rnd_B_Beneli_Pellets","8Rnd_B_Beneli_74Slug","ItemGoldBar10oz"];
DefaultWeapons = ["M9SD","Remington870_lamp","Binocular","ItemMap","ItemCompass","ItemFlashlightRed","ItemKnife","ItemMatchbox","ItemHatchet"];
DefaultBackpack = "DZ_GunBag_EP1";
DefaultBackpackWeapon = "";
};

//Donator Loadout
if ((getPlayerUID player) in ["PUID","PUID"]) then {
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","ItemMorphine","ItemPainkiller","ItemGoldBar","15Rnd_W1866_Slug","15Rnd_W1866_Slug"];
DefaultWeapons = ["glock17_EP1","Winchester1866","ItemMap","ItemFlashlightRed","ItemHatchet"];
DefaultBackpack = "DZ_ALICE_Pack_EP1";
DefaultBackpackWeapon = "";
};

I dont take credit. Random loadouts part by BetterDeadThanZed and the rest is credited to... damnit cant remember who whipped it up.

Link to comment
Share on other sites

Can someone make it possible to add a random chance to each item array separately? i would like to put a different percentage rate on each array that I make so that a player may or may not receive an item from that particular array.

 

Thanks in advance!! ;-)

Link to comment
Share on other sites

Can someone make it possible to add a random chance to each item array separately? i would like to put a different percentage rate on each array that I make so that a player may or may not receive an item from that particular array.

 

Thanks in advance!! ;-)

Bump

Link to comment
Share on other sites

  • 1 month later...

very nice script here is my advance version of this

 

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))
};

_primary = ["M16A2","bizon_silenced","UZI_SD_EP1","M16A4","M4A1","Sa58P_EP1","Sa58V_EP1","AKS_74_U","AK_47_M","AK_74","FN_FAL","Winchester1866","Winchester1866","Winchester1866","Winchester1866","MR43","M1014","LeeEnfield","Saiga12K","huntingrifle","MP5A5","Bizon","UZI_EP1","Crossbow_DZ","Crossbow_DZ","Crossbow_DZ","Crossbow_DZ","Remington870_lamp","LeeEnfield","LeeEnfield"] call loadout_fnc_selectRandom;

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

_tools = ["ItemCompass","Binocular","Binocular_Vector","ItemEtool","ItemFlashlight","ItemFlashlightRed","ItemGPS","ItemHatchet_DZE","ItemKnife","ItemMap","ItemMatchbox_DZE","ItemToolbox","ItemWatch","NVGoggles","ItemCrowbar","ItemMachete","ItemFishingPole","Binocular","Binocular","ItemWatch","ItemKnife","ItemKnife","ItemToolbox","ItemToolbox","ItemCompass","ItemCompass"]  call loadout_fnc_selectRandom;

_medical = ["ItemAntibiotic","ItemBandage","ItemBloodbag","ItemEpinephrine","ItemHeatPack","ItemMorphine","ItemPainkiller","ItemMorphine","ItemPainkiller","ItemPainkiller","ItemPainkiller","ItemBandage","ItemBandage","ItemBandage"] call loadout_fnc_selectRandom;

_ammo = _primary call find_suitable_ammunition;

_ammos = _secondary call find_suitable_ammunition;

_food = ["FoodBioMeat","FoodCanBakedBeans","FoodCanTylers","FoodCanDerpy","FoodCanHerpy","FoodCanFraggleos","FoodCanDemon","FoodCanCurgon","FoodCanCorn","FoodCanBoneboy","FoodCanBadguy","FoodCanFrankBeans","FoodCanPasta","FoodCanSardines","FoodCanUnlabeled","FoodMRE","FoodNutmix","FoodPistachio","FoodSteakCooked"] call loadout_fnc_selectRandom;

_drink = ["ItemSodaCoke","ItemSodaMdew","ItemSodaSmasht","ItemSodaDrwaste","ItemSodaLemonade","ItemSodaLvg","ItemSodaMzly","ItemSodaRabbit","ItemSodaOrangeSherbet","ItemSodaPepsi","ItemSodaRbull","ItemWaterbottle"] call loadout_fnc_selectRandom;

_backpack = ["DZ_Patrol_Pack_EP1","DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch"] call loadout_fnc_selectRandom;

DefaultMagazines = [_medical,_ammo,_ammos,_food,_drink];
DefaultWeapons = ["ItemRadio",_primary,_secondary,_tools];
DefaultBackpack = _backpack;
DefaultBackpackWeapon = "";
DZE_defaultSkin = [["Skin_Camo1_DZ","Skin_Rocket_DZ","Skin_Soldier1_DZ","Skin_GUE_Commander_DZ","Skin_FR_OHara_DZ","Skin_FR_Rodriguez_DZ","Skin_Graves_Light_DZ","Skin_Soldier_Bodyguard_AA12_PMC_DZ","Skin_Soldier_Sniper_PMC_DZ","Skin_CZ_Special_Forces_GL_DES_EP1_DZ","Skin_Rocker4_DZ","Skin_Rocker2_DZ","Skin_Rocker1_DZ","Skin_Rocker3_DZ","Skin_Functionary1_EP1_DZ","Skin_Pilot_EP1_DZ","Skin_Haris_Press_EP1_DZ","Skin_Priest_DZ","Skin_RU_Policeman_DZ"],["Skin_SurvivorW2_DZ","Skin_SurvivorW3_DZ","Skin_SurvivorWcombat_DZ","Skin_SurvivorWdesert_DZ","Skin_SurvivorWurban_DZ","Skin_SurvivorWpink_DZ"]];

Edited by Midoc
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
  • Advertisement
  • Discord

×
×
  • Create New...