From df6e8777d117af5fe79ae19c5282387b14a537f1 Mon Sep 17 00:00:00 2001 From: Chris Cardozo Date: Sun, 31 May 2020 07:01:25 -0400 Subject: [PATCH] Small performance improvements: blck_fnc_missionSpawner --- .../Compiles/Groups/GMS_fnc_spawnGroup.sqf | 20 +++++++------------ .../Missions/GMS_fnc_missionSpawner.sqf | 20 +++++++++---------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf b/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf index 02de51c..eff199d 100644 --- a/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf +++ b/@GMS/addons/custom_server/Compiles/Groups/GMS_fnc_spawnGroup.sqf @@ -24,11 +24,7 @@ if (blck_debugLevel > 3) then }; #endif -if !(typeName _group isEqualTo "GROUP") exitWith { - if (_group isEqualTo "Error") exitWith {diag_log format["_fnc_spawnGroup [ERROR]: no parameter was passed for _group"]}; - diag_log format["_fnc_spawnGroup {ERROR]}: parameter %2 of type %1 passed, 'GROUP expected",typeName _group,_group]; -}; -//if (isNull _group) exitWith {diag_log format["ERROR: No valid value _group was passed to blck_fnc_spawnGroup"]}; + if (_weaponList isEqualTo []) then {_weaponList = [_skillLevel] call blck_fnc_selectAILoadout}; if (_sideArms isEqualTo []) then {_sideArms = [_skillLevel] call blck_fnc_selectAISidearms}; if (_uniforms isEqualTo []) then {_uniforms = [_skillLevel] call blck_fnc_selectAIUniforms}; @@ -46,9 +42,7 @@ if !(isNull _group) then }; //Spawns the correct number of AI Groups, each with the correct number of units - //Counter variable - _i = 0; - while {_i < _numbertospawn} do + for "_i" from 1 to _numbertospawn do { _i = _i + 1; if (blck_useLaunchers && _i <= blck_launchersPerGroup) then @@ -58,17 +52,17 @@ if !(isNull _group) then _launcherType = "none"; }; private _unitPos = [_pos,3,6] call blck_fnc_findRandomLocationWithinCircle; - //params["_pos","_aiGroup",_skillLevel,_uniforms, _headGear,_vests,_backpacks,_Launcher,_weaponList,_sideArms,_scuba]; + [_unitPos,_group,_skillLevel,_uniforms,_headGear,_vests,_backpacks,_launcherType, _weaponList, _sideArms, _scuba] call blck_fnc_spawnUnit; - //private _unit = [_unitPos,_group,_skillLevel,_uniforms,_headGear,_vests,_backpacks,_launcherType, _weaponList, _sideArms, _scuba] call blck_fnc_spawnUnit; + //diag_log format["_fnc_spawnGroup: _unit %1 spawned at %2 at a distance from the group center of %3 and _vector of %4",_unit,_unitPos,_unitPos distance _pos,_pos getRelDir _unitPos]; }; _group selectLeader ((units _group) select 0); - // params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_pattern",["MOVE","SAD"]]]; + if (_configureWaypoints) then { if (_scuba) then {_infantryType = "scuba"} else {_infantryType = "infantry"}; - // params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_wpPatrolMode","SAFE"],["_soldierType","null"],["_patrolRadius",30],["_wpTimeout",[5.0,7.5,10]]]; + #define infantryPatrolRadius 30 #define infantryWaypointTimeout [5,7.5,10] [_pos,_minDist,_maxDist,_group,"random","SAD",_infantryType,_patrolRadius,infantryWaypointTimeout] spawn blck_fnc_setupWaypoints; @@ -83,4 +77,4 @@ if (blck_debugLevel > 2) then diag_log format["_fnc_spawnGroup:_group = %1",_group]; }; #endif -_group + diff --git a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf index f0d134c..8696e80 100644 --- a/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf +++ b/@GMS/addons/custom_server/Compiles/Missions/GMS_fnc_missionSpawner.sqf @@ -238,8 +238,8 @@ if !(_abort) then { _blck_AllMissionAI append (_temp select 0); }; - -if (count _scubaGroupParameters > 0) then +//diag_log format["[blckeagls] missionSpawner:: (236) missionAI spawned: _markerName %1 : _markerLabel %2 : count _blck_AllMissionAI = %3",_markerName,_markerLabel, count _blck_AllMissionAI]; +if !(_scubaGroupParameters isEqualTo []) then { #define isScubaMission true //diag_log format["_fnc_dynamicUMSspawner: spawning scuba groups with _scubaGroupParameters = %1",_scubaGroupParameters]; @@ -315,7 +315,7 @@ if (blck_debugLevel > 2) then {diag_log "_fnc_missionSpawner (256) helipatrols s #endif uisleep 3; -if (count _garrisonedBuilding_ATLsystem > 0) then +if !(_garrisonedBuilding_ATLsystem isEqualTo []) then { _temp = [_coords, _garrisonedBuilding_ATLsystem, _aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_garrisonBuilding_ATLsystem; _objects append (_temp select 1); @@ -330,7 +330,7 @@ if (blck_debugLevel > 2) then {diag_log "_fnc_missionSpawner (271) garrisons (AT #endif uiSleep 3; -if (count _garrisonedBuildings_BuildingPosnSystem > 0) then +if !(_garrisonedBuildings_BuildingPosnSystem isEqualTo []) then { _temp = [_coords, _garrisonedBuildings_BuildingPosnSystem, _aiDifficultyLevel,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms] call blck_fnc_garrisonBuilding_RelPosSystem; _objects append (_temp select 1); @@ -360,17 +360,17 @@ if (blck_debugLevel > 2) then {diag_log "_fnc_missionSpawner (309) emplaced weap #endif _vehToSpawn = [_noVehiclePatrols] call blck_fnc_getNumberFromRange; -if (blck_useVehiclePatrols && ((_vehToSpawn > 0) || count _missionPatrolVehicles > 0)) then +if (blck_useVehiclePatrols && ((_vehToSpawn > 0) || !(_missionPatrolVehicles isEqualTo []) )) then { //diag_log format["_missionSpawner(315): _vehToSpawn = %1 | _missionPatrolVehicles = %2",_vehToSpawn,_missionPatrolVehicles]; _temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_missionPatrolVehicles,useRelativePos,_uniforms,_headGear,_vests,_backpacks,_weaponList,_sideArms,false,_vehicleCrewCount] call blck_fnc_spawnMissionVehiclePatrols; - diag_log format["_fnc_missionSpawner (327) _temp = %1",_temp]; + _temp params ["_patrolVehicles","_units","_abort"]; _blck_AllMissionAI append _units; }; // Spawn any submarine patrols -if (blck_useVehiclePatrols && count _submarinePatrolParameters > 0) then +if (blck_useVehiclePatrols && !(_submarinePatrolParameters isEqualTo []) ) then { // params["_coords","_noVehiclePatrols","_aiDifficultyLevel","_missionPatrolVehicles",["_useRelativePos",true],["_uniforms",blck_SkinList], ["_headGear",blck_headgear],["_vests",blck_vests],["_backpacks",blck_backpacks],["_weaponList",[]],["_sideArms",blck_Pistols], ["_isScubaGroup",false]]; _temp = [_coords,_vehToSpawn,_aiDifficultyLevel,_submarinePatrolParameters,true,_umsUniforms,_umsHeadgear,_umsVests,[],_umsWeapons,[],isScubaMission] call blck_fnc_spawnMissionVehiclePatrols; @@ -386,7 +386,7 @@ if (blck_debugLevel > 2) then {diag_log "_fnc_missionSpawner (330) vehicle patro uiSleep delayTime; if (_spawnCratesTiming isEqualTo "atMissionSpawnGround") then { - if (count _missionLootBoxes > 0) then + if !(_missionLootBoxes isEqualTo []) then { _crates = [_coords,_missionLootBoxes,_loadCratesTiming, _spawnCratesTiming, "start", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; } @@ -407,7 +407,7 @@ uiSleep 10; if (blck_debugLevel > 2) then {diag_log "_fnc_missionSpawner (355) loot crate(s) spawned"}; #endif -if (count _missionLootVehicles > 0) then +if !(_missionLootVehicles isEqualTo []) then { _temp = [_coords,_missionLootVehicles,_loadCratesTiming,0] call blck_fnc_spawnMissionLootVehicles; _crates append _temp; @@ -578,7 +578,7 @@ if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then { if (!(_secureAsset) || (_secureAsset && (alive _assetSpawned))) then { - if (count _missionLootBoxes > 0) then + if !(_missionLootBoxes isEqualTo []) then { _crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _aiDifficultyLevel] call blck_fnc_spawnMissionCrates; }