Small performance improvements: blck_fnc_missionSpawner

This commit is contained in:
Chris Cardozo 2020-05-31 07:01:25 -04:00
parent 16eac40e0e
commit df6e8777d1
2 changed files with 17 additions and 23 deletions

View File

@ -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

View File

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