From 388a3bc95d5f927bbea2b9759c6d0eafb174c3a1 Mon Sep 17 00:00:00 2001 From: Chris Cardozo Date: Mon, 16 Nov 2020 13:31:00 -0500 Subject: [PATCH] Streamline coding Build 235 --- .../GMS_fnc_selecctChanceParatroops.sqf | 12 +-- .../Missions/GMS_fnc_selectAIBackpacks.sqf | 12 +-- .../Missions/GMS_fnc_selectAIHeadgear.sqf | 12 +-- .../Missions/GMS_fnc_selectAILoadout.sqf | 12 +-- .../Missions/GMS_fnc_selectAISidearms.sqf | 12 +-- .../Missions/GMS_fnc_selectAIUniforms.sqf | 12 +-- .../Missions/GMS_fnc_selectAIVests.sqf | 12 +-- .../GMS_fnc_selectChanceHeliPatrol.sqf | 12 +-- .../Missions/GMS_fnc_selectMissionHelis.sqf | 12 +-- .../GMS_fnc_selectNumberAirPatrols.sqf | 12 +-- .../GMS_fnc_selectNumberParatroops.sqf | 12 +-- .../GMS_fnc_selectVehicleCrewCount.sqf | 10 +-- .../Compiles/Units/GMS_fnc_spawnUnit.sqf | 84 ++++++++----------- .../custom_server/Compiles/blck_variables.sqf | 4 + 14 files changed, 63 insertions(+), 167 deletions(-) diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selecctChanceParatroops.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selecctChanceParatroops.sqf index 4346e4e..6c03ce8 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selecctChanceParatroops.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selecctChanceParatroops.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_chancePara"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_chancePara = blck_chanceParaBlue}; - case "red": {_chancePara = blck_chanceParaRed}; - case "green": {_chancePara = blck_chanceParaGreen}; - case "orange": {_chancePara = blck_chanceParaOrange}; - default {_chancePara = blck_chanceParaRed}; -}; -_chancePara \ No newline at end of file +private _chancePara = missionNamespace getVariable[format["blck_chancePara%1",_aiDifficultyLevel],0]; +_chancePara diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIBackpacks.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIBackpacks.sqf index ac4493b..5928ae5 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIBackpacks.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIBackpacks.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_backpacks"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_backpacks = blck_backpacks_blue}; - case "red": {_backpacks = blck_backpacks_red}; - case "green": {_backpacks = blck_backpacks_green}; - case "orange": {_backpacks = blck_backpacks_orange}; - default {_backpacks = blck_backpacks}; -}; -_backpacks \ No newline at end of file +private _backpacks = missionNamespace getVariable[format["blck_backpacks_%1",_aiDifficultyLevel],[]]; +_backpacks diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIHeadgear.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIHeadgear.sqf index 8f9b638..60ce6eb 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIHeadgear.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIHeadgear.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_headgear"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_headGear = blck_headgear_blue}; - case "red": {_headGear = blck_headgear_red}; - case "green": {_headGear = blck_headgear_green}; - case "orange": {_headGear = blck_headgear_orange}; - default {_headGear = blck_headgear}; -}; -_headgear \ No newline at end of file +private _headgear = missionNamespace getVariable [format["blck_headgear_%1",_aiDifficultyLevel],[]]; +_headgear diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAILoadout.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAILoadout.sqf index db0f795..3650618 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAILoadout.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAILoadout.sqf @@ -16,14 +16,6 @@ */ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; -private["_weaponList","_missionColor"]; - -_missionColor = _this select 0; -switch (_missionColor) do { - case "blue": {_weaponList = blck_WeaponList_Blue;}; - case "red": {_weaponList = blck_WeaponList_Red;}; - case "green": {_weaponList = blck_WeaponList_Green;}; - case "orange": {_weaponList = blck_WeaponList_Orange;}; - default {_weaponList = blck_WeaponList_Blue;}; -}; +params["_missionColor"]; +private _weaponList = missionNamespace getVariable [format["blck_WeaponList_%1",_missionColor],[]]; _weaponList diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAISidearms.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAISidearms.sqf index 09b8360..e3f4aa7 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAISidearms.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAISidearms.sqf @@ -13,13 +13,5 @@ params["_aiDifficultyLevel"]; //[["_aiDifficultyLevel",selectRandom["Red","Green"]]]; -private["_sideArms"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_sideArms = blck_Pistols_blue}; - case "red": {_sideArms = blck_Pistols_red}; - case "green": {_sideArms = blck_Pistols_green}; - case "orange": {_sideArms = blck_Pistols_orange}; - default {_sideArms = blck_Pistols}; -}; -_sideArms \ No newline at end of file +private _sideArms = missionNamespace getVariable[format["blck_Pistols_%1",_aiDifficultyLevel],[]]; +_sideArms diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIUniforms.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIUniforms.sqf index e2e4ee6..e7773a2 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIUniforms.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIUniforms.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_uniforms"]; - switch (toLower (_aiDifficultyLevel)) do - { - case "blue": {_uniforms = blck_SkinList_blue}; - case "red": {_uniforms = blck_SkinList_red}; - case "green": {_uniforms = blck_SkinList_green}; - case "orange": {_uniforms = blck_SkinList_orange}; - default {_uniforms = blck_SkinList}; - }; -_uniforms \ No newline at end of file +private _uniforms = missionNamespace getVariable [format["blck_SkinList_%1",_aiDifficultyLevel],[]]; +_uniforms diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIVests.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIVests.sqf index 5c25fd9..7a61425 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIVests.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectAIVests.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_vests"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_vests = blck_vests_blue}; - case "red": {_vests = blck_vests_red}; - case "green": {_vests = blck_vests_green}; - case "orange": {_vests = blck_vests_orange}; - default {_vests = blck_vests}; -}; -_vests \ No newline at end of file +private _vests = missionNamespace getVariable [format["blck_vests_%1",_aiDifficultyLevel],[]]; +_vests diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectChanceHeliPatrol.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectChanceHeliPatrol.sqf index f0363fa..e760b9d 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectChanceHeliPatrol.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectChanceHeliPatrol.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_chanceHeliPatrol"]; - switch (toLower(_aiDifficultyLevel)) do - { - case "blue": {_chanceHeliPatrol = blck_chanceHeliPatrolBlue}; - case "red": {_chanceHeliPatrol = blck_chanceHeliPatrolRed}; - case "green": {_chanceHeliPatrol = blck_chanceHeliPatrolGreen}; - case "orange": {_chanceHeliPatrol = blck_chanceHeliPatrolOrange}; - default {_chanceHeliPatrol = 0}; - }; -_chanceHeliPatrol \ No newline at end of file +private _chanceHeliPatrol = missionNamespace getVariable[format["blck_chanceHeliPatrol%1",_aiDifficultyLevel],[]]; +_chanceHeliPatrol diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectMissionHelis.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectMissionHelis.sqf index 637f3e6..5c6f404 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectMissionHelis.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectMissionHelis.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_missionHelis"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_missionHelis = blck_patrolHelisBlue}; - case "red": {_missionHelis = blck_patrolHelisRed}; - case "green": {_missionHelis = blck_patrolHelisGreen}; - case "orange": {_missionHelis = blck_patrolHelisOrange}; - default {_missionHelis = blck_patrolHelisBlue}; -}; -_missionHelis \ No newline at end of file +private _missionHelis = missionNamespace getVariable[format["blck_patrolHelis%1",_aiDifficultyLevel],[]]; +_missionHelis diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberAirPatrols.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberAirPatrols.sqf index 62434ef..54a76cd 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberAirPatrols.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberAirPatrols.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_noChoppers"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_noChoppers = blck_noPatrolHelisBlue}; - case "red": {_noChoppers = blck_noPatrolHelisRed}; - case "green": {_noChoppers = blck_noPatrolHelisGreen}; - case "orange": {_noChoppers = blck_noPatrolHelisOrange}; - default {_noChoppers = 0}; -}; -_noChoppers \ No newline at end of file +private _noChoppers = missionNamespace getVariable [format["blck_noPatrolHelis%1",_aiDifficultyLevel],0]; +_noChoppers diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberParatroops.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberParatroops.sqf index 7ca0530..40a6d12 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberParatroops.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectNumberParatroops.sqf @@ -12,13 +12,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_aiDifficultyLevel"]; -private["_noPara"]; -switch (toLower (_aiDifficultyLevel)) do -{ - case "blue": {_noPara = blck_noParaBlue}; - case "red": {_noPara = blck_noParaRed}; - case "green": {_noPara = blck_noParaGreen}; - case "orange": {_noPara = blck_noParaOrange}; - default {_noPara = 0}; -}; -_noPara \ No newline at end of file +private _noPara = missionNamespace getVariable [format["blck_noPara%1",_aiDifficultyLevel],0]; +_noPara diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectVehicleCrewCount.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectVehicleCrewCount.sqf index a34351b..d7d258b 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectVehicleCrewCount.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_selectVehicleCrewCount.sqf @@ -11,13 +11,5 @@ #include "\q\addons\custom_server\Configs\blck_defines.hpp"; params["_diff"]; -private ["_count"]; -switch (toLower(_diff)) do -{ - case "blue": {_count = blck_vehCrew_blue}; - case "red": {_count = blck_vehCrew_red}; - case "green": {_count = blck_vehCrew_green}; - case "orange": {_count = blck_vehCrew_orange}; -}; - +private _count = missionNamespace getVariable [format["blck_vehCrew_%1",_diff],0]; _count diff --git a/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnUnit.sqf b/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnUnit.sqf index b0f7865..f2e7e65 100644 --- a/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnUnit.sqf +++ b/@GMS/addons/custom_server/Compiles/Units/GMS_fnc_spawnUnit.sqf @@ -70,31 +70,23 @@ _unit allowDammage true; _unit setBehaviour "COMBAT"; _unit setunitpos "AUTO"; -_unit forceAddUniform (selectRandom _uniforms); -if !(_headGear isEqualTo []) then -{ - _unit addHeadgear (selectRandom _headGear); +if !(_uniforms isEqualTo []) then {_unit forceAddUniform (selectRandom _uniforms)}; +if !(_headGear isEqualTo []) then {_unit addHeadgear (selectRandom _headGear)}; +if !(_vests isEqualTo []) then {_unit addVest (selectRandom _vests)}; +if (_weaponList isEqualTo []) then { + _weap = selectRandom _weaponList; + _unit addWeaponGlobal _weap; + _ammoChoices = getArray (configFile >> "CfgWeapons" >> _weap >> "magazines"); + _unit addMagazines[selectRandom _ammochoices,3]; + if (random 1 < blck_chanceMuzzle) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 101] call BIS_fnc_compatibleItems))}; // muzzles + if (random 1 < blck_chanceOptics) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 201] call BIS_fnc_compatibleItems))}; // optics + if (random 1 < blck_chancePointer) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 301] call BIS_fnc_compatibleItems))}; // pointers + if (random 1 < blck_chanceUnderbarrel) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 302] call BIS_fnc_compatibleItems))}; // underbarrel + if ((count(getArray (configFile >> "cfgWeapons" >> _weap >> "muzzles"))) > 1) then + { + _unit addMagazine "1Rnd_HE_Grenade_shell"; + }; }; -if !(_vests isEqualTo []) then -{ - _unit addVest (selectRandom _vests); -}; - -if (_weaponList isEqualTo []) then {_weaponList = call blck_fnc_selectAILoadout}; -_weap = selectRandom _weaponList; -_unit addWeaponGlobal _weap; -_ammoChoices = getArray (configFile >> "CfgWeapons" >> _weap >> "magazines"); -_unit addMagazines[selectRandom _ammochoices,3]; - -if (random 1 < blck_chanceMuzzle) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 101] call BIS_fnc_compatibleItems))}; // muzzles -if (random 1 < blck_chanceOptics) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 201] call BIS_fnc_compatibleItems))}; // optics -if (random 1 < blck_chancePointer) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 301] call BIS_fnc_compatibleItems))}; // pointers -if (random 1 < blck_chanceUnderbarrel) then {_unit addPrimaryWeaponItem (selectRandom ([_weap, 302] call BIS_fnc_compatibleItems))}; // underbarrel -if ((count(getArray (configFile >> "cfgWeapons" >> _weap >> "muzzles"))) > 1) then -{ - _unit addMagazine "1Rnd_HE_Grenade_shell"; -}; - if !(_sideArms isEqualTo []) then { _weap = selectRandom _sideArms; @@ -102,17 +94,21 @@ if !(_sideArms isEqualTo []) then _ammoChoices = getArray (configFile >> "CfgWeapons" >> _weap >> "magazines"); _unit addMagazines [selectRandom _ammoChoices, 2]; }; -for "_i" from 1 to (1+floor(random(4))) do +if !(blck_ConsumableItems isEqualTo []) then { - _unit addItem (selectRandom blck_ConsumableItems); + for "_i" from 1 to (1+floor(random(4))) do + { + _unit addItem (selectRandom blck_ConsumableItems); + }; }; - -// Add First Aid or Grenade 50% of the time -if (round(random 10) <= 5) then +if !(blck_specialItems isEqualTo []) then { - _unit addItem selectRandom blck_specialItems; + // Add First Aid or Grenade 50% of the time + if (round(random 10) <= 5) then + { + _unit addItem selectRandom blck_specialItems; + }; }; - if !(_backpacks isEqualTo []) then { if (_Launcher isEqualTo "none") then @@ -132,18 +128,18 @@ if !(_backpacks isEqualTo []) then _roundsAdded pushBack _lr; _unit addItemToBackpack _lr; }; - _unit setVariable["Launcher",[_launcher,_roundsAdded],true]; + _unit setVariable["Launcher",[_launcher,_roundsAdded]]; }; }; if(sunOrMoon < 0.2 && blck_useNVG)then { _unit addWeapon selectRandom blck_NVG; - _unit setVariable ["hasNVG", true,true]; + _unit setVariable ["hasNVG", true]; } else { - _unit setVariable ["hasNVG", false,true]; + _unit setVariable ["hasNVG", false]; }; _unit addWeapon selectRandomWeighted["",4,"Binocular",3,"Rangefinder",1]; @@ -153,20 +149,12 @@ _unit addEventHandler ["Reloaded", {_this call blck_EH_unitWeaponReloaded;}]; _unit addMPEventHandler ["MPKilled", {[(_this select 0), (_this select 1)] call blck_EH_AIKilled;}]; _unit addMPEventHandler ["MPHit",{[_this] call blck_EH_AIHit;}]; -switch (_skillLevel) do -{ - case "blue": {_index = 0;_aiSkills = blck_SkillsBlue;}; - case "red": {_index = 1;_aiSkills = blck_SkillsRed;}; - case "green": {_index = 2;_aiSkills = blck_SkillsGreen;}; - case "orange": {_index = 3;_aiSkills = blck_SkillsOrange;}; - default {_index = 0;_aiSkills = blck_SkillsBlue;}; -}; - -[_unit,_aiSkills] call blck_fnc_setSkill; -_unit setVariable ["alertDist",blck_AIAlertDistance select _index,true]; -_unit setVariable ["intelligence",blck_AIIntelligence select _index,true]; -_unit setVariable ["GMS_AI",true,true]; - +[_unit, missionNamespace getVariable[format["blck_Skills%1",_skillLevel],blck_SkillsRed]] call blck_fnc_setSkill; +_index = missionNamespace getVariable[format["blck_skillsIndex_%1",_skillLevel],1]; +_unit setVariable ["alertDist",blck_AIAlertDistance select _index]; +_unit setVariable ["intelligence",blck_AIIntelligence select _index]; +_unit setVariable ["GMS_AI",true]; +//diag_log format["_spawnUnit: _index = %1 | _aiSkills = %2",_index,_aiSkills]; _unit diff --git a/@GMS/addons/custom_server/Compiles/blck_variables.sqf b/@GMS/addons/custom_server/Compiles/blck_variables.sqf index a129c60..16ad54d 100644 --- a/@GMS/addons/custom_server/Compiles/blck_variables.sqf +++ b/@GMS/addons/custom_server/Compiles/blck_variables.sqf @@ -57,6 +57,10 @@ blck_activeMonitorThreads = 0; blck_validEndStates = ["allUnitsKilled", "playerNear", "allKilledOrPlayerNear","assetSecured"]; blck_validLootSpawnTimings = ["atMissionSpawnGround","atMissionSpawnAir","atMissionEndGround","atMissionEndAir"]; blck_validLootLoadTimings = ["atMissionCompletion", "atMissionSpawn"]; +blck_skillsIndex_Blue = 0; +blck_skillsIndex_Red = 1; +blck_skillsIndex_Green = 2; +blck_skillsIndex_Orange = 3; if (blck_debugOn) then {diag_log "[blckeagls] Variables Loaded"};