Forum Jump :

Author Message


Posts: 28
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-06-24 22:05        
     
As the description says, i have made a script designed to allow the author to put it in a group leaders init, put a number to define what kit, and then have that unit automatically assigned with gurilla/rebel type stuff. So far so good, and i have the script finished, i just dont thinks it's as clean/presentable as it could be, expecially with the if and for statments.
Anyway, heres the code:
_unit = _this select 0;
_type = _this select 1;
AKchoice = true;
_facewearPoss = random 1;
_headgearPoss = random 1;
_balaclavaPoss = random 1;
_machineGunPoss = random 1;
_sniperRiflePoss = random 1;
_launcherPoss = random 1;
_torchPoss = random 1;

_uniform = [
	"U_BG_Guerilla1_1",
	"U_BG_Guerrilla_6_1",
	"U_BG_leader",
	"rhs_chdkz_uniform_2",
	"rhs_chdkz_uniform_3",
	"rhs_chdkz_uniform_4"
] call BIS_fnc_selectRandom;

_grenades = [
	"HandGrenade",
	"HandGrenade",
	"HandGrenade",
	"Chemlight_green",
	"Chemlight_green",
	"MiniGrenade",
	"SmokeShell",
	"SmokeShell",
	"SmokeShell",
	"SmokeShellYellow",
	"Chemlight_red"
];

_magazines = [
	"rhs_30Rnd_545x39_AK",
	"rhs_30Rnd_545x39_AK_no_tracers",
	"rhs_30Rnd_545x39_7N10_AK",
	"rhs_30Rnd_545x39_7N22_AK",
	"rhs_45Rnd_545x39_AK",
	"rhs_45Rnd_545x39_7N10_AK",
	"rhs_45Rnd_545x39_7N22_AK"
];
 
_weapon = [
	"rhs_weap_ak74m",
	"rhs_weap_ak74m_camo",
	"rhs_weap_ak74m_desert",
	"rhs_weap_ak74m_folded",
	"rhs_weap_ak74m_camo_folded",
	"rhs_weap_ak74m_desert_folded",
	"rhs_weap_ak74m_2mag",
	"rhs_weap_ak74m_2mag_camo",
	"rhs_weap_ak105"
] call BIS_fnc_selectRandom;

_weaponMG = [
	"rhs_weap_pkm",
	"rhs_weap_pkp"
] call BIS_fnc_selectRandom;

_weaponDMR = [
	"rhs_weap_svdp",
	"rhs_weap_svdp_wd",
	"rhs_weap_svds"
] call BIS_fnc_selectRandom;

_backpack = [
	"B_AssaultPack_blk",
	"B_AssaultPack_rgr",
	"B_AssaultPack_dgtl",
	"B_FieldPack_khk",
	"B_FieldPack_cbr",
	"B_Kitbag_cbr",
	"B_TacticalPack_blk",
	"B_TacticalPack_oli",
	"rhs_sidor",
	"rhs_assault_umbts"
] call BIS_fnc_selectRandom;
 
_vest = [
	"V_BandollierB_cbr",
	"V_BandollierB_blk",
	"V_BandollierB_oli",
	"V_HarnessOGL_brn",
	"rhs_6sh46",
	"rhs_assault_umbts"
] call BIS_fnc_selectRandom;
 
_bandanna = [
	"G_Bandanna_blk",
	"G_Bandanna_oli",
	"G_Bandanna_beast",
	"G_Bandanna_tan",
	"G_Bandanna_khk",
	"rhs_scarf"
] call BIS_fnc_selectRandom;

_balaclava = [
	"G_Balaclava_oli",
	"G_Balaclava_blk",
	"H_Shemag_olive",
	"H_ShemagOpen_tan",
	"rhs_balaclava1_olive"
] call BIS_fnc_selectRandom;

_headgear = [
	"H_Bandanna_khk",
	"H_Bandanna_mcamo",
	"H_Booniehat_mcamo",
	"H_Booniehat_tan",
	"H_Booniehat_dgtl",
	"H_Cap_blk",
	"H_Cap_oli",
	"H_Hat_brown",
	"rhs_beanie_green",
	"rhs_Booniehat_flora",
	"rhs_Booniehat_marpatd"
] call BIS_fnc_selectRandom;

_helmet = [
	"rhs_6b26_green",
	"rhs_6b27m_green",
	"rhs_6b27m_digi",
	"rhs_6b28_green",
	"rhs_ssh68"
] call BIS_fnc_selectRandom;

 _magazine = _magazines call BIS_fnc_selectRandom;
 
_unit unassignItem "NVGoggles";
_unit removeItem "NVGoggles";
_unit unassignItem "NVGoggles_OPFOR";
_unit removeItem "NVGoggles_OPFOR";
_unit unassignItem "NVGoggles_INDEP";
_unit removeItem "NVGoggles_INDEP";
 
switch (_type) do {
	case 1 : {
		removeAllWeapons _unit;
		removeHeadgear _unit;
		removeGoggles _unit;
		
		if (_facewearPoss > 0.2) then {
			if (_balaclavaPoss < 0.2) then {_unit addGoggles _balaclava} else{_unit addGoggles _bandanna; _unit addHeadgear _headgear};
			};
		};
	case 2 : {
		removeAllWeapons _unit;
		_unit addMagazine _magazine;
		_unit addWeapon _weapon;
		for "_i" from 1 to 2 do {
		_unit addItem (_magazines call BIS_fnc_selectRandom);
		};
	};
	case 3 : {
		removeAllWeapons _unit;
		removeHeadgear _unit;
		removeGoggles _unit;
		_unit addMagazine _magazine;
		_unit addWeapon _weapon;
		_unit addVest _vest;
		for "_i" from 1 to 3 do {
			_unit addItem (_magazines call BIS_fnc_selectRandom);
		};
		
		if (_facewearPoss > 0.2) then {
			if (_balaclavaPoss < 0.2) then {_unit addGoggles _balaclava} else{_unit addGoggles _bandanna; _unit addHeadgear _headgear};
		};
	};
	case 4 : {
		removeAllWeapons _unit;
		removeHeadgear _unit;
		removeGoggles _unit;
		_unit addVest _vest;
		_unit forceAddUniform _uniform;

		if (_sniperRiflePoss < 0.1) then {
				AKchoice = false;
				_unit addMagazine "rhs_10Rnd_762x54mmR_7N1";
				_unit addWeapon _weaponDMR;
				_unit addBackpack _backpack;
				_unit addMagazine (_grenades call BIS_fnc_selectRandom);
				for "_i" from 1 to 3 do {
					_unit addItem "rhs_10Rnd_762x54mmR_7N1";
				};
			}
			else {if (_machineGunPoss < 0.1) then {
						AKchoice = false;
						_unit addMagazine "rhs_100Rnd_762x54mmR";
						_unit addWeapon _weaponMG;
						_unit addBackpack _backpack;
						_unit addMagazine (_grenades call BIS_fnc_selectRandom);
						for "_i" from 1 to 2 do {
							_unit addItem "rhs_100Rnd_762x54mmR";
						};
					} else {if (_launcherPoss < 0.1) then {
					_unit addMagazine "rhs_rpg7_PG7VL_mag";
					_unit addWeapon "rhs_weap_rpg7";
					_unit addBackpack "rhs_rpg_empty";
					_unit addItemToBackpack "rhs_rpg7_PG7VL_mag";
					};
				};
			};
		
		if (_facewearPoss > 0.35) then {
			if (_balaclavaPoss < 0.2) then {_unit addGoggles _balaclava} else{_unit addGoggles _bandanna; _unit addHeadgear _headgear};
		} else {_unit addHeadgear _helmet};
		
		if (AKchoice) then{
			_unit addMagazine _magazine;
			_unit addWeapon _weapon;
			for "_i" from 1 to 3 do {
				_unit addItem (_magazines call BIS_fnc_selectRandom);
			};
		};
		
			if (_torchPoss < 0.2) then{
			_unit addPrimaryWeaponItem "rhs_acc_2dpZenit"; 
			_unit assignItem "rhs_acc_2dpZenit";
			_unit setskill ["spotDistance",(0 + random 0.2)];
			_unit setskill ["spotTime",(0 + random 0.2)];
		};
	
		for "_i" from 1 to 2 do {
			_unit addMagazine (_grenades call BIS_fnc_selectRandom);
		};
	
	};
};


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2016-06-25 09:01        
     
Déjà vu: http://www.armaholic.com/forums.php?m=posts&p=189189ü


Here is a diff: https://www.diffchecker.com/dnuv5g4s


Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage





Tags: Clean Up, Script, Tidy