Jump to content
Sign in to follow this  
ante185

Help with random weapons script required

Recommended Posts

/*
File: randomize_equipment.sqf
Author: pettka, modified for a different purpose by "ante"

Description:
Randomizes a headgear form _headgear array and puts it to civilian's headgear slot upon startup of mission.
_rnd1 is used to have some civilians without any headgear
_rnd2 is used to determine particular headgear from array


Parameter(s):
None

Returns:
Nothing
*/
_magazines = magazines _this;
_items = items _this; // Medkits, ToolKits etc.
_assitems = assignedItems _this; // NVG's, GPS etc.

/* massia's weapons */
if (isClass(configFile >> "CfgPatches" >> "mas_weapons")) then { 
		_weaponlist = ["arifle_mas_akm", "arifle_mas_m70", "arifle_mas_aks74u", "arifle_mas_m70ab",
		"srifle_mas_m91_l", "arifle_mas_mk16_l", "srifle_mas_m16", "srifle_mas_fal", "srifle_mas_sr25", "LMG_mas_m72_F", "arifle_mas_bizon", "arifle_mas_mp5",
		"arifle_mas_hk416c", "arifle_mas_hk416"]
} else { 
		_weaponlist = ["arifle_mx_f", "arifle_Katiba_F", "arifle_MXC_F", "arifle_Katiba_C_F",  "srifle_DMR_01_F", "arifle_MXM_F", "arifle_SDAR_F", "arifle_TRG20_F",
		 "arifle_TRG21_F", "LMG_Zafir_F", "SMG_02_F", "hgun_PDW2000_snds_F", "arifle_Mk20C_plain_F", "arifle_Mk20_F"] 
};
_headCount = count _weaponlist;

if (isServer) then {
BIS_randomSeed1 = [];
BIS_randomSeed2 = [];
_rnd1 = floor random 3;	
_this setVariable ["BIS_randomSeed1", _rnd1, TRUE];
_rnd2 = floor random _headCount;
_this setVariable ["BIS_randomSeed2", _rnd2, TRUE];
};

waitUntil {!(isNil {_this getVariable "BIS_randomSeed1"})};
waitUntil {!(isNil {_this getVariable "BIS_randomSeed2"})};
_randomSeed1 = _this getVariable "BIS_randomSeed1";
_randomSeed2 = _this getVariable "BIS_randomSeed2";

_getweapon = (_weaponlist select _randomSeed2);

sleep 1;
/* massia's weapons' mags */
if (isClass(configFile >> "CfgPatches" >> "mas_weapons")) then { switch (_getweapon) do {
   case "arifle_mas_akm": {_this addmagazines ["30Rnd_mas_762x39_T_mag", 6]};
   case "arifle_mas_m70ab": {_this addmagazines ["30Rnd_mas_762x39_mag",6]};
   case "arifle_mas_aks74u": {_this addmagazines ["30Rnd_mas_545x39_mag",6]};
   case "arifle_mas_m70ab": {_this addmagazines ["30Rnd_mas_762x39_mag",6]};
   case "arifle_mas_mk16_l": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "srifle_mas_m91_l": {_this addmagazines ["10Rnd_mas_762x54_T_mag",6]};
   case "arifle_mas_m16": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "arifle_mas_fal": {_this addmagazines ["20Rnd_762x51_Mag",6]};
   case "srifle_mas_sr25": {_this addmagazines ["20Rnd_762x51_Mag",6]};
   case "LMG_mas_m72_F": {_this addmagazines ["100Rnd_mas_762x39_T_mag",6]};
   case "arifle_mas_bizon": {_this addmagazines ["64Rnd_mas_9x18_mag",6]};
   case "arifle_mas_mp5": {_this addmagazines ["30Rnd_9x21_Mag",6]};
   case "arifle_mas_hk416c": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "arifle_mas_hk416": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
};
} else {
switch (_getweapon) do {
   case "arifle_mx_f": {_this addmagazines ["30Rnd_65x39_caseless_mag", 6]};
   case "arifle_Katiba_F": {_this addmagazines ["30Rnd_65x39_caseless_green",6]};
   case "arifle_MXC_F": {_this addmagazines ["30Rnd_65x39_caseless_mag",6]};
   case "arifle_Katiba_C_F": {_this addmagazines ["30Rnd_65x39_caseless_green",6]};
   case "arifle_MXM_F": {_this addmagazines ["30Rnd_65x39_caseless_mag",6]};
   case "srifle_DMR_01_F": {_this addmagazines ["10Rnd_762x51_Mag",6]};
   case "arifle_SDAR_F": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "arifle_TRG20_F": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "arifle_TRG21_F": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "LMG_Zafir_F": {_this addmagazines ["150Rnd_762x51_Box",6]};
   case "SMG_02_F": {_this addmagazines ["30Rnd_9x21_Mag",6]};
   case "hgun_PDW2000_snds_F": {_this addmagazines ["30Rnd_9x21_Mag",6]};
   case "arifle_Mk20C_plain_F": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
   case "arifle_Mk20_F": {_this addmagazines ["30Rnd_556x45_Stanag",6]};
};
};

if (true) then {
_this addweapon (_getweapon);
};

Im trying to make this script here compatible with mas' weapons, and i'd like to know how to set it up so i can have multiple addons?

Share this post


Link to post
Share on other sites

shit, i think i might've posted this in the wrong area maybe?

Share this post


Link to post
Share on other sites

You can make this script shrink enormously when using BIS_fnc_addWeapon. With that you don't need to add all those magazines.

But adding weapons from other addons should be easy. All you have to do is define _weaponlist with the vanilla weapons first and then add if (whateveraddonpresent) then {_weaponlist = []}; for all the addons you want to use. If you want to have addon weapons from multiple addons, just define them like this:

if (whateveraddonpresent) then {_weaponlistfromAddon1 = []; _weaponlist = _weaponlist+_weaponlistfromAddon1};

/*
   File: randomize_equipment.sqf
   Author: pettka, modified for a different purpose by "ante"

   Description:
   Randomizes a headgear form _headgear array and puts it to civilian's headgear slot upon startup of mission.
   _rnd1 is used to have some civilians without any headgear
   _rnd2 is used to determine particular headgear from array


   Parameter(s):
   None

   Returns:
   Nothing
*/

_weaponlist = ["arifle_mx_f", "arifle_Katiba_F", "arifle_MXC_F", "arifle_Katiba_C_F",  "srifle_DMR_01_F", "arifle_MXM_F", "arifle_SDAR_F", "arifle_TRG20_F",
            "arifle_TRG21_F", "LMG_Zafir_F", "SMG_02_F", "hgun_PDW2000_snds_F", "arifle_Mk20C_plain_F", "arifle_Mk20_F"];

/* massia's weapons */
if (isClass(configFile >> "CfgPatches" >> "mas_weapons")) then { 
           _weaponlistMassi = ["arifle_mas_akm", "arifle_mas_m70", "arifle_mas_aks74u", "arifle_mas_m70ab",
           "srifle_mas_m91_l", "arifle_mas_mk16_l", "srifle_mas_m16", "srifle_mas_fal", "srifle_mas_sr25", "LMG_mas_m72_F", "arifle_mas_bizon", "arifle_mas_mp5",
           "arifle_mas_hk416c", "arifle_mas_hk416"];
		_weaponlist = _weaponlistMassi+_weaponlist;
};
/*
//other addon
if (isClass(configFile >> "CfgPatches" >> "other addon")) then { 
           _weaponlistOtherAddon = [];
		_weaponlist = _weaponlistOtherAddon+_weaponlist;
};
*/

_headCount = count _weaponlist;

if (isServer) then {
   BIS_randomSeed1 = [];
   BIS_randomSeed2 = [];
   _rnd1 = floor random 3;    
   _this setVariable ["BIS_randomSeed1", _rnd1, TRUE];
   _rnd2 = floor random _headCount;
   _this setVariable ["BIS_randomSeed2", _rnd2, TRUE];
};

waitUntil {!(isNil {_this getVariable "BIS_randomSeed1"})};
waitUntil {!(isNil {_this getVariable "BIS_randomSeed2"})};
_randomSeed1 = _this getVariable "BIS_randomSeed1";
_randomSeed2 = _this getVariable "BIS_randomSeed2";

_getweapon = (_weaponlist select _randomSeed2);

if (true) then {
   [_this,_getweapon,6] call BIS_fnc_addWeapon;
};  

Edited by Belbo

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
Sign in to follow this  

×