Sorting out bugs in mission spawner and other functions

bug fixes
coding efficiency improvements
This commit is contained in:
Ghostrider-DbD- 2017-01-21 17:20:24 -05:00
parent 69591a6c9b
commit b369c1ae9d
25 changed files with 571 additions and 318 deletions

View File

@ -20,41 +20,50 @@ _obj = [];
while {true} do
{
uiSleep blck_mainThreadUpdateInterval; // defined in custom_server\compiles\blck_variables.sqf
uiSleep 5; // defined in custom_server\compiles\blck_variables.sqf
if ((diag_tickTime - _timer5sec) > 5) then
{
[] call blck_fnc_vehicleMonitor;
_timer5sec = diag_tickTime;
};
if ((diag_tickTime - _timer1min) > 60) then
if ((diag_tickTime - _timer1min) > 15) then
{
diag_log format["_fnc_mainThread:: (30) diag_tickTime = %1", diag_tickTime];
diag_log format["_fnc_mainThread:: (31) blck_liveMissionAI = %1", blck_liveMissionAI];
_ai = blck_liveMissionAI;
{
diag_log format["_fnc_mainThread:: (34) evaluating liveAIArray %1 with diag_tickTime %2", _x,diag_tickTime];
if (diag_tickTime > (_x select 1) ) then {
//diag_log format["_fnc_mainTread:: cleaning up AI group %1",_x];
diag_log format["_fnc_mainTread:: cleaning up AI group %1",_x];
[_x select 0] call blck_fnc_cleanupAliveAI;
blck_liveMissionAI set[ _forEachIndex, -1];
blck_liveMissionAI = blck_liveMissionAI - [-1]; // Remove that list of live AI from the list.
diag_log format["_fnc_mainTread:: blck_liveMissionAI updated from %1",_ai];
diag_log format["_fnc_mainTread:: blck_liveMissionAI updated to %1",blck_liveMissionAI];
};
blck_liveMissionAI = blck_liveMissionAI - [_x]; // Remove that list of live AI from the list.
}forEach _ai;
diag_log format["_fnc_mainThread:: (44) blck_oldMissionObjects = %1", blck_oldMissionObjects];
_obj = blck_oldMissionObjects;
{
//diag_log format["mainThread::-->> missionObjects _x = %1",_x];
diag_log format["mainThread::-->> evaluating missionObjects = %1 diag_tickTime %2",_x,diag_tickTime];
if (diag_tickTime > (_x select 1) ) then {
//diag_log format["_fnc_mainTread:: cleaning up mission objects %1",_x];
diag_log format["_fnc_mainTread:: cleaning up mission objects %1",_x];
[_x select 0] call blck_fnc_cleanupObjects;
blck_oldMissionObjects set[_forEachIndex, -1];
blck_oldMissionObjects = blck_oldMissionObjects - [-1];
diag_log format["_fnc_mainTread:: blck_oldMissionObjects updated from %1",_obj];
diag_log format["_fnc_mainTread:: blck_oldMissionObjects updated to %1",blck_oldMissionObjects];
};
blck_oldMissionObjects = blck_oldMissionObjects - [_x];
}forEach _obj;
[] call GMS_fnc_cleanupDeadAI;
[] call blck_fnc_cleanupDeadAI;
if (_modType isEqualTo "Epoch") then {
//diag_log "calling blck_fnc_cleanEmptyGroups";
[] call blck_fnc_cleanEmptyGroups;
}; // Exile cleans up empty groups automatically so this should not be needed with that mod.
/* [Jan 14, 2017] reverted the the approach based on mission timers for now
/* [Jan 13, 2017] reverted the the approach based on mission timers for now
{
if (blck_debugLevel > 2) then {diag_log format["_fnc_mainThread:: -- >> _x = %1 and _x select 6 = %2",_x, _x select 6];};
if (_x select 6 > 0) then // The mission is not running, check the time left till it is spawned
@ -78,8 +87,9 @@ while {true} do
};
}forEach blck_pendingMissions;
_timer1min = diag_tickTime;
*/
};
*/
if ((diag_tickTime - _timer5min) > 300) then {
if (blck_timeAcceleration) then
{

View File

@ -27,7 +27,7 @@ if (blck_debugLevel isEqualTo 3) then
_groupSpawned = createGroup blck_AI_Side;
if !(isNull _groupSpawned) then
{
diag_log format["_fnc_spawnGroup:: -- >> Group created = %1",_groupSpawned];
if (blck_debugON) then {diag_log format["_fnc_spawnGroup:: -- >> Group created = %1",_groupSpawned]};
_groupSpawned setcombatmode blck_combatMode;
_groupSpawned allowfleeing 0;
_groupSpawned setspeedmode "FULL";

View File

@ -3,10 +3,11 @@
call as [ [list of AI], time] call blck_fnc_addLiveAItoQue; where time is the time delay before deletion occurs
by Ghostrider-DbD-
Last modified 10-14-16
Last modified 1-14-17
*/
//diag_log format["_fnc_addLiveAIToQue:: -> when called, blck_liveMissionAI = %1",blck_liveMissionAI];
params["_aiList","_timeDelay"];
if (blck_debugON) then {diag_log format["_fnc_addLiveAIToQue:: -->> _aiList = %1 || _timeDelay = %2",_aiList,_timeDelay];};
//diag_log format["_fnc_addLiveAIToQue:: -->> _aiList = %1 || _timeDelay = %2",_aiList,_timeDelay];
blck_liveMissionAI pushback [_aiList, (diag_tickTime + _timeDelay)];
//diag_log format["_fnc_addLiveAIToQue:: -> blck_fnc_addLiveAI updated to %1",blck_liveMissionAI];

View File

@ -7,6 +7,8 @@
*/
params["_objList","_timeDelay"];
if (blck_debugON) then {diag_log format["_fnc_addObjToQue:: -- >> _objList = %1 || _timeDelay = %2",_objList,_timeDelay];};
//diag_log format["_fnc_addObjToQue:: -- >> _objList = %1 || _timeDelay = %2",_objList,_timeDelay];
//diag_log format["_fnc_addObjToQue:: (11) -- >> blck_oldMissionObjects prior to update = %1",blck_oldMissionObjects];
blck_oldMissionObjects pushback [_objList, (diag_tickTime + _timeDelay)];
//diag_log format["_fnc_addObjToQue:: (11) -- >> blck_oldMissionObjects after update = %1",blck_oldMissionObjects];

View File

@ -6,13 +6,20 @@
for DBD Clan
By Ghostrider-DBD-
Copyright 2016
Last Modified 8-13-16
Last Modified 1-13-17
*/
params["_buildings"];
params["_objects"];
{
if ((typeOf _x) isKindOf "LandVehicle") then
{
//diag_log format["cleanupObjects.sqf: -- >> object %1 is typeOf %2",_x, typeOf _x];
deleteVehicle _x;
} forEach _buildings;
private _crew = crew _x;
{
[_x] call blck_deleteAI;
}forEach _crew;
};
deleteVehicle _x;
} forEach _objects;

View File

@ -0,0 +1,232 @@
/*
Generic Mission Spawner
for DBD Clan
By Ghostrider-DBD-
Copyright 2016
Last modified 1/12/17
*/
private ["_crates","_aiGroup","_objects","_groupPatrolRadius","_missionLandscape","_mines","_blck_AllMissionAI","_blck_localMissionMarker","_AI_Vehicles"];
params["_coords","_missionType","_aiDifficultyLevel"];
waitUntil {blck_missionSpawning isEqualTo false};
blck_missionSpawning = true;
diag_log format["[blckeagls] missionSpawner:: Initializing mission: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
private["_chanceHeliPatrol","_noPara","_reinforcementLootCounts","_chanceLoot","_heliCrew"];
if (isNil "_chanceReinforcements") then
{
_chanceReinforcements = 0;
_noPara = 0;
_reinforcementLootCounts = [0,0,0,0,0,0];
_chanceHeliPatrol = 0;
_chanceLoot = 0;
};
private["_timeOut","_blck_AllMissionAI"]; // _timeOut is the time in seconds after which a mission is deactivated.
if (isNil "_markerColor") then {_markerColor = "ColorBlack"};
if (isNil "_markerType") then {_markerType = ["mil_box",[]]};
if (isNil "_timeOut") then {_timeOut = -1;};
if (isNil "_noPara") then {_noPara = 0};
if (isNil "_chanceHeliPatrol") then {_chanceHeliPatrol = 0;};
if (isNil "_chanceLoot") then {_chanceLoot = 0};
if (isNil "_heliCrew") then {_heliCrew = 3};
if (isNil "_reinforcementLootCounts") then
{
private["__weap","_mags","_backpacks","_optics","_loadout"];
_weap = 2 + floor(random(4));
_mags = 5 + floor(random(6));
_backpacks = 1 + floor(random(2));
_optics = 1 + floor(random(6));
_loadout = 1 + floor(random(3));
_reinforcementLootCounts = [_weap,_mags,_optics,0,0,_backpacks];
if (blck_debugLevel > 0) then {diag_log "missionSpawner:: default values used for _reinforcementLootCounts";};
}
else
{
if (blck_debugLevel > 0) then {diag_log "missionSpawner:: Mission specific values used for _reinforcementLootCounts";};
};
if (blck_debugLevel > 0) then {
diag_log format["[blckEagle] Mission Reinforcement Parameters: changeReinforcements %1 numAI %2 changePatrol %3 chanceLoot %4",_chanceReinforcements,_noPara,_chanceHeliPatrol,_chanceLoot];
};
private["_useMines","_abortMissionSpawner","_blck_AllMissionAI","_delayTime","_groupPatrolRadius"];
if (isNil "_useMines") then {_useMines = blck_useMines;};
_objects = [];
_mines = [];
_crates = [];
_aiGroup = [];
_missionAIVehicles = [];
_blck_AllMissionAI = [];
_AI_Vehicles = [];
_blck_localMissionMarker = [_missionType,_coords,"","",_markerColor,_markerType];
_delayTime = 1;
_groupPatrolRadius = 50;
_abortMissionSpawner = false;
[_blck_localMissionMarker select 0,"Active",_coords] call blck_fnc_updateMissionQue;
if (blck_labelMapMarkers select 0) then
{
//diag_log "SM1.sqf: labeling map markers *****";
_blck_localMissionMarker set [2, _markerMissionName];
};
if !(blck_preciseMapMarkers) then
{
//diag_log "SM1.sqf: Map marker will be OFFSET from the mission position";
_blck_localMissionMarker set [1,[_coords,75] call blck_fnc_randomPosition];
};
_blck_localMissionMarker set [3,blck_labelMapMarkers select 1]; // Use an arrow labeled with the mission name?
[["start",_startMsg,_blck_localMissionMarker select 2]] call blck_fnc_messageplayers;
[_blck_localMissionMarker] execVM "debug\spawnMarker.sqf";
uiSleep 1;
blck_missionSpawning = false;
if (blck_debugLevel > 0) then {diag_log "missionSpawner:: waiting for player to trigger the mission";};
private _missionStartTime = diag_tickTime;
waitUntil{[_coords,blck_TriggerDistance,blck_MissionTimout] call blck_fnc_missionStartConditionsMet;};
if (((diag_tickTime - _missionStartTime) > blck_MissionTimout)) exitWith
{
//["timeOut",_endMsg,_blck_localMissionMarker select 2] call blck_fnc_messageplayers;
[_blck_localMissionMarker select 0] execVM "debug\deleteMarker.sqf";
[_objects, 1] spawn blck_fnc_cleanupObjects;
[_blck_localMissionMarker select 0,"Completed"] call blck_fnc_updateMissionQue;
if (blck_debugLevel > 0) then
{
diag_log format["[blckeagls] missionSpawner:: Mission Timed Out: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
};
if (blck_debugLevel > 0) then
{ diag_log format["[blckeagls] missionSpawner:: -- >> Mission tripped by nearby player: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
if (count _missionLootBoxes > 0) then
{
_crates = [_coords,_missionLootBoxes] call blck_fnc_spawnMissionCrates;
}
else
{
_crates = [_coords,[[selectRandom blck_crateTypes /*"Box_NATO_Wps_F"*/,[0,0,0],_crateLoot,_lootCounts]]] call blck_fnc_spawnMissionCrates;
};
if (blck_debugLevel > 0) then
{
diag_log format["[blckeagls] missionSpawner:: Crates Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
uiSleep _delayTime;
private ["_temp"];
if (blck_SmokeAtMissions select 0) then // spawn a fire and smoke near the crate
{
_temp = [_coords,blck_SmokeAtMissions select 1] call blck_fnc_smokeAtCrates;
_objects append _temp;
};
uiSleep _delayTime;
if (_useMines) then
{
_mines = [_coords] call blck_fnc_spawnMines;
uiSleep _delayTime;;
};
if (_missionLandscapeMode isEqualTo "random") then
{
_temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape;
} else {
_temp = [_coords, floor(random(360)),_missionLandscape,true] call blck_fnc_spawnCompositionObjects;
};
_objects append _temp;
diag_log format["_fnc_missionSpawner::->> mission objects spawned = %1",_objects];
if (blck_debugON) then
{
diag_log format["[blckeagls] missionSpawner:: Landscape spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
uiSleep _delayTime;;
if ((count _missionLootVehicles) > 0) then // spawn loot vehicles
{
diag_log "[blckEagles] _fnc_missionSpawner:: Spawning Mission Loot Vehicles";
private _vehs = [_missionLootVehicles] call blck_fnc_spawnMissionLootVehicles;
};
uiSleep _delayTime;
diag_log "[blckEagle] _fnc_missionSpawner:: spawning AI";
_blck_AllMissionAI = [_coords,_minNoAI,_maxNoAI,_aiDifficultyLevel,_uniforms,_headGear] call blck_fnc_spawnMissionAI;
diag_log format["[blckeagls] _fnc_missionSpawner (190):-> _blck_AllMissionAI = %1",_blck_AllMissionAI];
if (blck_debugON) then
{
diag_log format["[blckeagls] missionSpawner:: AI Patrols Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
uiSleep _delayTime;
private _emp = [];
diag_log format["[blckeagls] _fnc_missionSpawner (197):-> _noEmplacedWeapons = %1",_noEmplacedWeapons];
if (!blck_useStatic && (_noEmplacedWeapons > 0)) then
{
private ["_emplacedGroup","_emplacedPositions"];
_emplacedPositions = [_coords,_count,35,50] call blck_fnc_findPositionsAlongARadius;
//diag_log format["missionSpawner:: _emplacedPositions = %1",_emplacedPositions];
{
_emplacedGroup = [_x,1,1,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
if !(isNull _emplacedGroup) then
{
_blck_AllMissionAI = _blck_AllMissionAI + (units _emplacedGroup);
_emplacedWeapon = [_x,_emplacedGroup,blck_staticWeapons,5,15] call blck_fnc_spawnEmplacedWeapon;
_missionAIVehicles pushback _emplacedWeapon;
uiSleep _delayTime;
};
}forEach _emplacedPositions;
};
if (blck_debugLevel > 0) then {diag_log format["[blckeagls] _fnc_missionSpawner (208):-> _blck_AllMissionAI = %1",_blck_AllMissionAI];};
uiSleep _delayTime;
if (blck_useVehiclePatrols && (_noVehiclePatrols > 0)) then
{
diag_log "[blckEagles] _fnc_missionSpawner:: spawning patrol vehicles";
private _return = [_coords,_noVehiclePatrols,_aiDifficultyLevel,_uniforms,_headGear] call blck_fnc_spawnMissionVehiclePatrols;
if (count _return isEqualTo 2) then
{
_blck_AllMissionAI = _blck_AllMissionAI + (_return select 0);
_AI_Vehicles = _AI_Vehicles + (_return select 1);
};
};
if ((random(1) < _chanceReinforcements)) then
{
diag_log format["[blckeagls] missionSpawner:: calling in reinforcements: _heliCrew = %1",4];
private["_grpPilot","_supplyHeli"];
_grpPilot = createGroup blck_AI_Side;
_grpPara = createGroup blck_AI_Side;
if (!(isNulL _grpPilot) && !(isNull _grpPara)) then
{
//_supplyHeli = [_coords,_grpPilot,_chanceLoot] call blck_fnc_spawnMissionHeli;
//[_coords,_grpPara,_noPara,_aiDifficultyLevel,_chanceLoot,_reinforcementLootCounts,_uniforms,_headgear,_supplyHeli,_grpPilot] spawn blck_fnc_callInReinforcements;
} else { deleteGroup _grpPilot; deleteGroup _grpPara;};
};
if (blck_debugON) then {diag_log "[blckeagls] _fnc_missionSpawner (214) :: waiting for mission completion criterion to be met";
waitUntil{[_crates,_blck_AllMissionAI,_endCondition] call blck_fnc_missionEndConditionsMet;};
if (blck_debugLevel > 0) then
{
diag_log format["[blckeagls] missionSpawner:: Mission completion criteria fulfilled: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
if (blck_useSignalEnd) then
{
[_crates select 0] spawn blck_fnc_signalEnd;
};
[_mines] spawn blck_fnc_clearMines;
[_objects, blck_cleanupCompositionTimer] call blck_fnc_addObjToQue;
[_blck_AllMissionAI,blck_AliveAICleanUpTime] call blck_fnc_addLiveAItoQue;
[["end",_endMsg,_blck_localMissionMarker select 2]] call blck_fnc_messageplayers;
[_blck_localMissionMarker select 1, _missionType] execVM "debug\missionCompleteMarker.sqf";
[_blck_localMissionMarker select 0] execVM "debug\deleteMarker.sqf";
[_blck_localMissionMarker select 0,"Completed"] call blck_fnc_updateMissionQue;
diag_log format["[blckeagls] missionSpawner:: end of mission: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];

View File

@ -78,17 +78,6 @@ _blck_localMissionMarker set [3,blck_labelMapMarkers select 1]; // Use an arrow
[["start",_startMsg,_blck_localMissionMarker select 2]] call blck_fnc_messageplayers;
[_blck_localMissionMarker] execVM "debug\spawnMarker.sqf";
_fn_playerWithinRange = {
params["_pos"];
private["_return"];
_return = false;
{
if (isPlayer _x and _x distance _pos <= blck_TriggerDistance) then {_return = true};
}forEach allPlayers; // playableunits; changed for Arma 1.66
_return;
};
uiSleep 1;
/////////////////////////////
// Everything has been set up for the mission and it is now waiting to be triggered by a nearby player or to time out.
@ -96,7 +85,7 @@ uiSleep 1;
////////////////////////////
blck_missionSpawning = false;
diag_log "missionSpawner:: waiting for player to trigger the mission";
if (blck_debugON) then {diag_log "missionSpawner:: waiting for player to trigger the mission";};
private["_wait","_missionStartTime","_playerInRange","_missionTimedOut"];
_missionStartTime = diag_tickTime;
_playerInRange = false;
@ -109,7 +98,7 @@ while {_wait} do
_wait = false;
_playerInRange = true;
} else {
if ([_coords] call _fn_playerWithinRange) then
if ({isPlayer _x && _x distance _coords < blck_TriggerDistance} count allPlayers > 0) then
{
_wait = false;
_playerInRange = true;
@ -156,7 +145,7 @@ if (_playerInRange) then
}
else
{
_crates = [_coords,[[selectRandom blck_crateTypes /*"Box_NATO_Wps_F"*/,[0,0,0],_crateLoot,_lootCounts]]] call blck_fnc_spawnMissionCrates;
_crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]]] call blck_fnc_spawnMissionCrates;
};
//_objects append _crates;
@ -167,33 +156,35 @@ if (_playerInRange) then
};
uiSleep _delayTime;
private ["_temp"];
if (blck_SmokeAtMissions select 0) then // spawn a fire and smoke near the crate
{
private ["_temp"];
_temp = [_coords,blck_SmokeAtMissions select 1] call blck_fnc_smokeAtCrates;
_objects append _temp;
_temp = nil;
if (typeName _temp isEqualTo "ARRAY") then
{
_objects append _temp;
};
};
uiSleep _delayTime;
if (_useMines) then
{
_mines = [_coords] call blck_fnc_spawnMines;
//waitUntil{!(_mines isEqualTo [];);
uiSleep _delayTime;;
};
uiSleep _delayTime;
_obj = [];
_temp = [];
if (_missionLandscapeMode isEqualTo "random") then
{
_obj = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape;
_temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape;
} else {
_obj = [_coords, floor(random(360)),_missionLandscape,true] call blck_fnc_spawnCompositionObjects;
_temp = [_coords, floor(random(360)),_missionLandscape,true] call blck_fnc_spawnCompositionObjects;
};
//diag_log format["_fnc_missionSpawner::->> _obj = %1",_obj];
_objects append _obj;
//diag_log format["_fnc_missionSpawner::->> _objects = %1",_objects];
_obj= nil;
if (typeName _temp isEqualTo "ARRAY") then
{
_objects append _temp;
};
//diag_log format["_fnc_missionSpawner:: (181)->> _objects = %1",_objects];
if (blck_debugON) then
{
diag_log format["[blckeagls] missionSpawner:: Landscape spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
@ -201,56 +192,123 @@ if (_playerInRange) then
uiSleep _delayTime;;
// ========
// Old version
// ========
/*
if ((count _missionLootVehicles) > 0) then // spawn loot vehicles
{
{
//diag_log format["spawnMissionCVehicles.sqf _x = %1",_x];
_offset = _x select 1; // offset relative to _coords at which to spawn the vehicle
_pos = [(_coords select 0)+(_offset select 0),(_coords select 1) + (_offset select 1),(_coords select 2)+(_offset select 2)];
_veh = [_x select 0 /* vehicle class name*/, _pos] call blck_fnc_spawnVehicle;
_veh = [_x select 0, _pos] call blck_fnc_spawnVehicle;
_vehs pushback _veh;
[_veh,_x select 2 /*loot array*/, _x select 3 /*array of values specifying number of items of each loot type to load*/] call blck_fnc_fillBoxes;
[_veh,_x select 2, _x select 3] call blck_fnc_fillBoxes;
}forEach _missionLootVehicles;
};
*/
// ========
// Modular Version
// ========
[_missionLootVehicles] call blck_fnc_spawnMissionLootVehicles;
// ==========
uiSleep _delayTime;
private _precise = false;
if (blck_useStatic && (_noEmplacedWeapons > 0)) then
{
private["_static","_count"];
if ( count (_missionEmplacedWeapons) > 0 ) then
// =======
// Old version
// =======
/*if ( count (_missionEmplacedWeapons) isEqualTo 0 ) then
{
_static = _missionCfg select 4 select 1;
_count = _missionCfg select 4 select 0;
}
else
{
_static = blck_staticWeapons;
_count = _noEmplacedWeapons;
_missionEmplacedWeapons = [_coords,_noEmplacedWeapons,35,50] call blck_fnc_findPositionsAlongARadius;
_precise = true;
};
private ["_emplacedGroup","_emplacedPositions"];
_emplacedPositions = [_coords,_count,35,50] call blck_fnc_findPositionsAlongARadius;
//diag_log format["missionSpawner:: _emplacedPositions = %1",_emplacedPositions];
{
_emplacedGroup = [_x,1,1,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
//_emplacedUnits = units _emplacedGroup;
_blck_AllMissionAI = _blck_AllMissionAI + (units _emplacedGroup);
_emplacedWeapon = [_x,_emplacedGroup,blck_staticWeapons,5,15] call blck_fnc_spawnEmplacedWeapon;
_missionAIVehicles pushback _emplacedWeapon;
uiSleep _delayTime;
}forEach _emplacedPositions;
//diag_log format["missionSpawner:: emplaced weapons data: _AI_Vehicles %1 _blck_AllMissionAI %1",_AI_Vehicles,_blck_AllMissionAI];
if !(isNull _emplacedGroup) then
{
_blck_AllMissionAI append (units _emplacedGroup);
_emplacedWeapon = [_x,_emplacedGroup,blck_staticWeapons,5,15,_precise] call blck_fnc_spawnEmplacedWeapon;
};
}forEach _missionEmplacedWeapons;
//===============================
*/
// ======
// Modular Version
// ======
private ["_emplacedUnits"];
_emplacedUnits = [_missionEmplacedWeapons,_noEmplacedWeapons,_aiDifficultyLevel,_coords,_uniforms,_headGear] call blck_fnc_spawnMissionEmplacedWeapons;
//diag_log format["missionSpawner :: (247) _emplacedUnits = %1",_emplacedUnits];
uisleep 0.1;
if (typeName _emplacedUnits isEqualTo "ARRAY") then
{
if (typeName _emplacedUnits isEqualTo "ARRAY") then
{
_blck_AllMissionAI append _emplacedUnits;
};
//diag_log format["missionSpawner :: (255) _blck_AllMissionAI updated to = %1",_blck_AllMissionAI];
};
//==============================
if (blck_debugON) then
{
diag_log format["[blckeagls] missionSpawner:: Static Weapons Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
};
uiSleep _delayTime;
//diag_log format["_fnc_missionSpawner:: after adding any static weapons, _blck_AllMissionAI is %1",_blck_AllMissionAI];
uisleep _delayTime;
if (blck_useVehiclePatrols && (_noVehiclePatrols > 0)) then
{
// ==============
// Old code
// ===============
/*
private["_vehGroup","_patrolVehicle"];
//_vehiclePatrolSpawns= [_coords,_noVehiclePatrols,45,60] call blck_fnc_findPositionsAlongARadius;
{
_vehGroup = [_x,3,3,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
diag_log format["missionSpawner:: (249) group for AI Patrol vehicle spawn: group is %1 with units of %2",_vehGroup, units _vehGroup];
diag_log format["missionSpawner:: (250) _blck_AllMissionAI prior to appending _vehGroup units = %1",_blck_AllMissionAI];
uiSleep 0.1;
if !(isNull _vehGroup) then
{
if (typeName (units _vehGroup) isEqualTo "ARRAY") then
{
_blck_AllMissionAI = _blck_AllMissionAI append (units _vehGroup);
diag_log format["missionSpawner:: _blck_AllMissionAI after appending _vehGroup units = %1",_blck_AllMissionAI];
_randomVehicle = selectRandom blck_AIPatrolVehicles;
_patrolVehicle = [_coords,_x,_randomVehicle,(_x distance _coords) -5,(_x distance _coords) + 5,_vehGroup] call blck_fnc_spawnVehiclePatrol;
};
};
}forEach [_coords,_noVehiclePatrols,45,60] call blck_fnc_findPositionsAlongARadius;;
*/
// =====================
// Modular version
// =====================
private["_vehUnits"];
_vehUnits = [_coords,_noVehiclePatrols,_aiDifficultyLevel,_uniforms,_headGear] call blck_fnc_spawnMissionVehiclePatrols;
//diag_log format["missionSpawner :: (240) _vehUnits = %1",_vehUnits];
if (typeName _vehUnits isEqualTo "ARRAY") then
{
_blck_AllMissionAI append _vehUnits;
};
//diag_log format["_fnc_missionSpawner:: after adding any vehicle patrols, _blck_AllMissionAI is %1",_blck_AllMissionAI];
//diag_log format["missionSpawner:: _noAIGroups = %1; spawning AI Groups now",_noAIGroups];
uiSleep _delayTime;
if (blck_debugON) then
{
diag_log format["[blckeagls] missionSpawner:: Vehicle Patrols Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
};
uiSleep _delayTime;
// =====
// Old Version
// +++++++++++
/*
private["_unitsToSpawn","_unitsPerGroup","_ResidualUnits","_newGroup"];
_unitsToSpawn = round(_minNoAI + round(random(_maxNoAI - _minNoAI)));
_unitsPerGroup = floor(_unitsToSpawn/_noAIGroups);
@ -261,9 +319,8 @@ if (_playerInRange) then
case 1: { // spawn the group near the mission center
//params["_pos", ["_numai1",5], ["_numai2",10], ["_skillLevel","red"], "_center", ["_minDist",20], ["_maxDist",35], ["_uniforms",blck_SkinList], ["_headGear",blck_headgear] ];
_newGroup = [_coords,_unitsToSpawn,_unitsToSpawn,_aiDifficultyLevel,_coords,3,18,_uniforms,_headGear] call blck_fnc_spawnGroup;
_newAI = units _newGroup;
_blck_AllMissionAI = _blck_AllMissionAI + _newAI;
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=1 _newGroup=%1 _newAI = %2",_newGroup, _newAI];
_blck_AllMissionAI = _blck_AllMissionAI append (units _newGroup);
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=1 _newGroup=%1 _newAI = %2",_newGroup, (units _newGroup)];
};
case 2: {
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=2"]; // spawn groups on either side of the mission area
@ -278,42 +335,50 @@ if (_playerInRange) then
_adjusttedGroupSize = _unitsPerGroup;
};
_newGroup = [_x,_adjusttedGroupSize,_adjusttedGroupSize,_aiDifficultyLevel,_coords,1,12,_uniforms,_headGear] call blck_fnc_spawnGroup;
_newAI = units _newGroup;
_blck_AllMissionAI = _blck_AllMissionAI + _newAI;
//diag_log format["missionSpawner: Spawning 2 Groups: _newGroup=%1 _newAI = %2",_newGroup, _newAI];
_blck_AllMissionAI = _blck_AllMissionAI append (units _newGroup);
//diag_log format["missionSpawner: Spawning 2 Groups: _newGroup=%1 _newAI = %2",_newGroup, (units _newGroup)];
}forEach _groupLocations;
};
case 3: { // spawn one group near the center of the mission and the rest on the perimeter
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=3"];
_newGroup = [_coords,_unitsPerGroup + _ResidualUnits,_unitsPerGroup + _ResidualUnits,_aiDifficultyLevel,_coords,1,12,_uniforms,_headGear] call blck_fnc_spawnGroup;
_newAI = units _newGroup;
_blck_AllMissionAI = _blck_AllMissionAI + _newAI;
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=3 _newGroup=%1 _newAI = %2",_newGroup, _newAI];
_blck_AllMissionAI = _blck_AllMissionAI append (units _newGroup);
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=3 _newGroup=%1 _newAI = %2",_newGroup, append (units _newGroup)];
_groupLocations = [_coords,2,20,35] call blck_fnc_findPositionsAlongARadius;
{
_newGroup = [_x,_unitsPerGroup,_unitsPerGroup,_aiDifficultyLevel,_coords,1,12,_uniforms,_headGear] call blck_fnc_spawnGroup;
_newAI = units _newGroup;
_blck_AllMissionAI = _blck_AllMissionAI + _newAI;
//diag_log format["missionSpawner: Spawning 2 Groups:_newGroup=%1 _newAI = %2",_newGroup, _newAI];
_blck_AllMissionAI = _blck_AllMissionAI append (units _newGroup);
//diag_log format["missionSpawner: Spawning 2 Groups:_newGroup=%1 _newAI = %2",_newGroup, (units _newGroup)];
}forEach _groupLocations;
};
default { // spawn one group near the center of the mission and the rest on the perimeter
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=default"];
_newGroup = [_coords,_unitsPerGroup + _ResidualUnits,_unitsPerGroup + _ResidualUnits,_aiDifficultyLevel,_coords,1,12,_uniforms,_headGear] call blck_fnc_spawnGroup;
_newAI = units _newGroup;
_blck_AllMissionAI = _blck_AllMissionAI + _newAI;
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=%3 _newGroup=%1 _newAI = %2",_newGroup, _newAI,_noAIGroups];
_blck_AllMissionAI = _blck_AllMissionAI append (units _newGroup);
//diag_log format["missionSpawner: Spawning Groups: _noAIGroups=%3 _newGroup=%1 _newAI = %2",_newGroup, (units _newGroup),_noAIGroups];
_groupLocations = [_coords,(_noAIGroups - 1),20,40] call blck_fnc_findPositionsAlongARadius;
{
_newGroup = [_x,_unitsPerGroup,_unitsPerGroup,_aiDifficultyLevel,_coords,1,12,_uniforms,_headGear] call blck_fnc_spawnGroup;
_newAI = units _newGroup;
_blck_AllMissionAI = _blck_AllMissionAI + _newAI;
//diag_log format["missionSpawner: Spawning %3 Groups: _newGroup=%1 _newAI = %2",_newGroup, _newAI,_noAIGroups];
_blck_AllMissionAI = _blck_AllMissionAI append (units _newGroup);
//diag_log format["missionSpawner: Spawning %3 Groups: _newGroup=%1 _newAI = %2",_newGroup, (units _newGroup),_noAIGroups];
}forEach _groupLocations;
};
};
*/
////////
// Modular Version
// =====
private ["_infantry"];
_infantry = [_coords, _minNoAI,_maxNoAI,_aiDifficultyLevel,_uniforms,_headGear] call blck_fnc_spawnMissionAI;
//diag_log format["missionSpawner:: (337) -> _infantry = %1",_infantry];
if (typeName _infantry isEqualto "ARRAY") then
{
_blck_AllMissionAI append _infantry;
};
uiSleep _delayTime;
if (blck_debugON) then
{
@ -336,7 +401,7 @@ if (_playerInRange) then
private["_grpReinforcements"];
_grpReinforcements = grpNull;
diag_log format["[blckeagls] missionSpawner:: calling in reinforcements: Current mission: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
//diag_log format["[blckeagls] missionSpawner:: calling in reinforcements: Current mission: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
[] spawn {
//[_coords,_noPara,_aiDifficultyLevel,_chanceLoot,_reinforcementLootCounts,_weaponList,_uniforms,_headgear,_chanceHeliPatrol] call blck_fnc_Reinforcements;
//waitUntil {_grpReinforcements != grpNull};
@ -349,31 +414,6 @@ if (_playerInRange) then
};
};
if (blck_useVehiclePatrols && (_noVehiclePatrols > 0)) then
{
private["_vehGroup","_patrolVehicle","_vehiclePatrolSpawns"];
_vehiclePatrolSpawns= [_coords,_noVehiclePatrols,45,60] call blck_fnc_findPositionsAlongARadius;
//diag_log format["missionSpawner:: _vehiclePatrolSpawns = %1",_vehiclePatrolSpawns];
//for "_i" from 1 to _noVehiclePatrols do
{
_vehGroup = [_x,3,3,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
//diag_log format["missionSpawner:: group for AI Patrol vehicle spawn: group is %1 with units of %2",_vehGroup, units _vehGroup];
_blck_AllMissionAI = _blck_AllMissionAI + (units _vehGroup);
_randomVehicle = blck_AIPatrolVehicles call BIS_fnc_selectRandom;
//diag_log format["missionSpawner:: vehicle selected is %1", _randomVehicle];
_patrolVehicle = [_coords,_x,_randomVehicle,(_x distance _coords) -5,(_x distance _coords) + 5,_vehGroup] call blck_fnc_spawnVehiclePatrol;
//diag_log format["missionSpawner:: patrol vehicle spawned was %1",_patrolVehicle];
_vehGroup setVariable["groupVehicle",_patrolVehicle,true];
//uiSleep _delayTime;
_AI_Vehicles pushback _patrolVehicle;
}forEach _vehiclePatrolSpawns;
//diag_log format["missionSpawner:: vehicle patrols data: _AI_Vehicles %1 _blck_AllMissionAI %1",_AI_Vehicles,_blck_AllMissionAI];
uiSleep _delayTime;
if (blck_debugON) then
{
diag_log format["[blckeagls] missionSpawner:: Vehicle Patrols Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
};
// Trigger for mission end
//diag_log format["[blckeagls] mission Spawner _endCondition = %1",_endCondition];
private["_missionComplete"];
@ -434,11 +474,15 @@ if (_playerInRange) then
};
};
[_mines] spawn blck_fnc_clearMines;
[_objects, blck_cleanupCompositionTimer] call blck_fnc_addObjToQue;
[_blck_AllMissionAI,blck_AliveAICleanUpTime] call blck_fnc_addLiveAItoQue;
//diag_log format["missionSpawner:: (473) _objects = %1",_objects];
uisleep 0.1;
[_objects, blck_cleanupCompositionTimer] spawn blck_fnc_addObjToQue;
//diag_log format["missionSpawner:: (476) _blck_AllMissionAI = %1",_blck_AllMissionAI];
uisleep 0.1;
[_blck_AllMissionAI,blck_AliveAICleanUpTimer] spawn blck_fnc_addLiveAItoQue;
[["end",_endMsg,_blck_localMissionMarker select 2]] call blck_fnc_messageplayers;
[_blck_localMissionMarker select 1, _missionType] execVM "debug\missionCompleteMarker.sqf";
[_blck_localMissionMarker select 0] execVM "debug\deleteMarker.sqf";
//[_blck_localMissionMarker select 0,"Completed"] call blck_fnc_updateMissionQue;
uisleep 0.1;
diag_log format["[blckeagls] missionSpawner:: end of mission: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};

View File

@ -2,11 +2,10 @@
Spawn objects from an array using offsects from a central location.
The code provided by M3Editor EDEN has been addapted to add checks for vehicles, should they be present.
Returns an array of spawned objects.
version of 11/9/16
version of 1/13/17
*/
//diag_log format["_fnc_spawnBaseObjects: _this = %1",_this];
params["_center","_azi","_objects","_setVector"];
//diag_log format["_fnc_spawnBaseObjects: _objs = %1",_objects];
private ["_newObjs"];
@ -23,21 +22,7 @@ _newObjs = [];
// Lock any vehicles placed as part of the mission landscape. Note that vehicles that can be taken by players can be added via the mission template.
if ( (typeOf _obj) isKindOf "LandVehicle" || (typeOf _obj) isKindOf "Air" || (typeOf _obj) isKindOf "Sea") then
{
//diag_log format["_fnc_spawnBaseObjects:: Locking vehicle of type %1",typeOf _obj];
//_obj = _x select 0;
_obj setVehicleLock "LOCKEDPLAYER";
_obj addEventHandler ["GetIn",{ // forces player to be ejected if he/she tries to enter the vehicle
private ["_theUnit"];
_theUnit = _this select 2;
_theUnit action ["Eject", vehicle _theUnit];
hint "Use of this vehicle is forbidden";
}];
clearItemCargoGlobal _obj;
clearWeaponCargoGlobal _obj;
clearMagazineCargoGlobal _obj;
clearBackpackCargoGlobal _obj;
[_obj] call blck_fnc_configureMissionVehicle;
};
} forEach _objects;
//diag_log format["_fnc_spawnBaseObjects _newObjs = %1",_newObjs];
_newObjs

View File

@ -5,57 +5,31 @@
*/
// [_missionEmplacedWeapons,_noEmplacedWeapons,_aiDifficultyLevel,_coords,_uniforms,_headGear] call blck_fnc_spawnMissionEmplacedWeapons;
params["_missionEmplacedWeapons","_noEmplacedWeapons","_aiDifficultyLevel","_coords","_uniforms","_headGear"];
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons(9):: - > _noEmplacedWeapons = %1",_noEmplacedWeapons];
private ["_emplacedGroup","_emplacedPositions","_missionGroups","_missionAI","_missionStatics","_false","_return","_count"];
_missionGroups = [];
_missionAI = [];
_missionStatics = [];
_return = [];
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons(15):: - > _noEmplacedWeapons = %1",_noEmplacedWeapons];
if (count _missionEmplacedWeapons > 0) then
private ["_emplacedGroup","_emplacedAI"];
_emplacedAI = [];
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons(10):: - > _noEmplacedWeapons = %1",_noEmplacedWeapons];
if ( count (_missionEmplacedWeapons) isEqualTo 0 ) then
{
{
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons (19):: - > _spawning from _missionEmplacedWeapons %1",_missionEmplacedWeapons];
_emplacedGroup = [_x,1,1,_aiDifficultyLevel,_coords,0,0.1,_uniforms,_headGear] call blck_fnc_spawnGroup;
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons (21):: - > _spawned group %1",_emplacedGroup];
if !(isNull _emplacedGroup) then
{
_missionGroups pushback _emplacedGroup;
{_x allowDamage false;} forEach units _emplacedGroup;
_emplacedWeapon = [_x,_emplacedGroup,blck_staticWeapons,5,15] call blck_fnc_spawnEmplacedWeapon;
_emplacedWeapon setPosATL _x;
_missionStatics pushback _missionStatics;
uiSleep _delayTime;
{_x allowDamage true;} forEach units _emplacedGroup;
};
} forEach _missionEmplacedWeapons;
} else {
_emplacedPositions = [_coords,_count,35,50] call blck_fnc_findPositionsAlongARadius;
{
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons (36):: - > _noEmplacedWeapons = %1",_noEmplacedWeapons];
_emplacedGroup = [_x,1,1,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons (38):: - > _spawned group %1",_emplacedGroup];
if !(isNull _emplacedGroup) then
{
_missionGroups pushback _emplacedGroup;
_emplacedWeapon = [_x,_emplacedGroup,blck_staticWeapons,5,15] call blck_fnc_spawnEmplacedWeapon;
_missionStatics pushback _missionStatics;
uiSleep _delayTime;
};
}forEach _emplacedPositions;
_missionEmplacedWeapons = [_coords,_noEmplacedWeapons,35,50] call blck_fnc_findPositionsAlongARadius;
_precise = false;
};
{
if !(isNull _x) then {_missionAI pushback (units _x);
}forEach _missionGroups;
_emplacedGroup = [_x,1,1,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
if !(isNull _emplacedGroup) then
{
diag_log format["_fnc_spawnMissionEmplacedWeapons:: (23) -> spawning _blck_fnc_spawnEmplaceWeapon with group %1",_emplacedGroup];
[_x,_emplacedGroup,blck_staticWeapons,5,15,_precise] call blck_fnc_spawnEmplacedWeapon;
} else {
diag_log format["[blckeagls] _fnc_spawnMissionEmplacedWeapons(26):: - > Null group spawned"];
};
if (typeName (units _emplacedGroup) isEqualTo "ARRAY") then
{
_emplacedAI append (units _emplacedGroup);
diag_log format["_fnc_spawnMissionEmplacedWeapons:: (31)-> _emplacedAI updated to %1",_emplacedAI];
};
}forEach _missionEmplacedWeapons;
if ( (count _missionAI) < 1) then
{
{deleteVehicle _x} forEach _missionStatics;
}
else
{
_return = [_missionAI,_missionStatics];
};
_return;
_emplacedAI

View File

@ -1,46 +1,30 @@
/*
[_coords,_noVehiclePatrols,_aiDifficultyLevel,_uniforms,_headGear] call _fnc_spawnMissionVehiclePatrols
[_coords,_noVehiclePatrols,_aiDifficultyLevel,_uniforms,_headGear] call blck_fnc_spawnMissionVehiclePatrols
by Ghostrider-DbD-
1/9/17
1/13/17
returns [] if no groups could be created
returns [_AI_Vehicles,_missionAI] otherwise;
*/
params["_coords","_noVehiclePatrols","_aiDifficultyLevel","_uniforms","_headGear"];
private["_vehGroup","_patrolVehicle","_vehiclePatrolSpawns","_missionAI","_missiongroups","_AI_Vehicles","_abort","_vehiclePatrolSpawns","_randomVehicle","_return"];
_missionAI = [];
_missiongroups = [];
_AI_Vehicles = [];
_return = [];
_abort = false;
_vehiclePatrolSpawns= [_coords,_noVehiclePatrols,45,60] call blck_fnc_findPositionsAlongARadius;
{
_vehGroup = [_x,3,3,_aiDifficultyLevel,_coords,1,2,_uniforms,_headGear] call blck_fnc_spawnGroup;
if (isNull _vehGroup) exitWith {_abort = true;};
_missiongroups pushback _vehGroup;
_randomVehicle = blck_AIPatrolVehicles call BIS_fnc_selectRandom;
_patrolVehicle = [_coords,_x,_randomVehicle,(_x distance _coords) -5,(_x distance _coords) + 5,_vehGroup] call blck_fnc_spawnVehiclePatrol;
_vehGroup setVariable["groupVehicle",_patrolVehicle,true];
_AI_Vehicles pushback _patrolVehicle;
//if (isNull _vehGroup) exitWith {_abort = true;};
diag_log format["_fnc_spawnMissionVehiclePatrols:: -> _vehGroup = %1 and units _vehGroup = %2",_vehGroup, units _vehGroup];
if (typename (units _vehGroup) isEqualTo "ARRAY") then
{
_randomVehicle = selectRandom blck_AIPatrolVehicles;
_patrolVehicle = [_coords,_x,_randomVehicle,(_x distance _coords) -5,(_x distance _coords) + 5,_vehGroup] call blck_fnc_spawnVehiclePatrol;
_vehGroup setVariable["groupVehicle",_patrolVehicle,true];
_missionAI append (units _vehGroup);
};
}forEach _vehiclePatrolSpawns;
if (blck_debugLevel > 1) then
{
diag_log format["[blckeagls] missionSpawner:: Vehicle Patrols Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
if (_abort) then
{
{deleteVehicle _x} forEach _AI_Vehicles;
{
{deleteVehicle _x} forEach (units _x);
deleteGroup _x;
} forEach _missiongroups;
};
if !(_abort) then
{
{
_missionAI append (units _x);
}forEach _missiongroups;
_return = [_missionAI,_AI_Vehicles];
diag_log format["[blckeagls] _fnc_spawnMissionVehiclePatrols :: Vehicle Patrols Spawned: _cords %1 : _missionType %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_missionType,_aiDifficultyLevel,_markerMissionName];
};
_return;
_missionAI;

View File

@ -5,40 +5,10 @@
Last updated 10/22/16
*/
private["_ai","_veh"];
params["_aiList"];
//diag_log format["_fnc_cleanupAliveAI:: called with blck_AICleanUpTimer = %1 and count of alive AI = %2",0, count _aiList];
{
//diag_log format["cleanupAliveAI:: for unit _x, alive = %1, GMS_DiedAt = %2",(alive _x), _x getVariable["GMS_DiedAt", -1]];
if ( alive _x && (_x getVariable["GMS_DiedAt", -1] < 0)) then { // The unit has not been processed by a kill handler. This double test is probably not needed.
_ai = _x;
if ( vehicle _ai != _ai) then // the AI is in a vehicle of some sort so lets be sure to delete it
{
_veh = vehicle _ai;
//diag_log format["cleanupAliveAI:: deleting vehicle %1",_veh];
_veh setDamage 1;
deleteVehicle _veh;
};
//diag_log format["_fnc_cleanupAliveAI:: _x is %4, typeOf _x %1 typeOf vehicle _x %2, blck_vehicle %3", (typeOf _x), (typeOf (vehicle _x)),_veh,_x];
{
_ai removeAllEventHandlers _x;
}forEach ["Killed","Fired","HandleDamage","HandleHeal","FiredNear"];
{
deleteVehicle _x;
}forEach nearestObjects [getPos _ai,["WeaponHolderSimulated","GroundWeapoonHolder"],3];
//_group = group _ai;
[_ai] joinSilent grpNull;
if (count units group _ai < 1) then
{
deletegroup group _ai;
};
deleteVehicle _ai;
};
diag_log format["_fnc_cleanupAliveAI:: -> deleteing AI Unit %1",_x];
[_x] call blck_fnc_deleteAI;
}forEach _aiList;
diag_log format["_fnc_cleanupAliveAI:: AI Cleanup Completed"];

View File

@ -1,28 +1,20 @@
/*
Delete Dead AI and nearby weapons after an appropriate period.
by Ghostrider
Last updated 10/22/16
Last updated 1/13/17
*/
private["_aiList","_ai"];
//diag_log format["_fnc_cleanupDeadAI Called"];
_aiList = blck_deadAI;
{
// As written, this ignores any bodies that do not have GMS_DiedAt defined.
if ( (_x getVariable ["GMS_DiedAt",0]) > 0 ) then
if ( diag_tickTime > _x getVariable ["blck_cleanupAt",0] ) then // DBD_DeleteAITimer
{
if ( diag_tickTime > ((_x getVariable ["GMS_DiedAt",0]) + blck_bodyCleanUpTimer) ) then // DBD_DeleteAITimer
_ai = _x;
{
_ai = _x;
{
deleteVehicle _x;
}forEach nearestObjects [getPos _x,["WeaponHolder"],3];
uiSleep 0.1;
//diag_log ["deleting AI %2 at _pos %1",getPos _ai,_ai];
blck_deadAI = blck_deadAI - [_ai];
deleteVehicle _ai;
};
deleteVehicle _x;
}forEach nearestObjects [getPos _ai,["WeaponHolderSimulated","GroundWeapoonHolder"],3];
blck_deadAI = blck_deadAI - [_ai];
deleteVehicle _ai;
};
} forEach _aiList;

View File

@ -0,0 +1,20 @@
/*
Delete a unit.
by Ghostrider
Last updated 1/13/17
*/
private["_ai"];
params["_unit"];
diag_log format["_fnc_deleteAI::-> deleting unit = %1",_unit];
{
_unit removeAllEventHandlers _x;
}forEach ["Killed","Fired","HandleDamage","HandleHeal","FiredNear"];
private _group = (group _unit);
deleteVehicle _unit;
if (count units _group < 1) then
{
deletegroup _group;
};

View File

@ -1,6 +1,6 @@
/*
Handle AI Deaths
Last Modified 1/4/17
Last Modified 1/13/17
By Ghostrider-DBD-
Copyright 2016
*/
@ -8,8 +8,7 @@
private["_group","_isLegal","_weapon","_lastkill","_kills","_message","_killstreakMsg"];
params["_unit","_killer","_isLegal"];
//diag_log format["#- processAIKill.sqf -# called for unit %1",_unit];
_unit setVariable ["GMS_DiedAt", (diag_tickTime),true];
_unit setVariable ["blck_cleanupAt", (diag_tickTime) + blck_bodyCleanUpTimer, true];
blck_deadAI pushback _unit;
_group = group _unit;

View File

@ -1,6 +1,6 @@
// Configures a mission vehicle
// by Ghostrider-DBD-
// Last Updated 10/25/16
// Last Updated 1/13/17
params["_veh"];
@ -9,14 +9,14 @@ clearMagazineCargoGlobal _veh;
clearBackpackCargoGlobal _veh;
clearItemCargoGlobal _veh;
_veh setVehicleLock "LOCKEDPLAYER";
_veh addEventHandler ["GetIn",{
_veh addEventHandler ["GetIn",{ // Note: only fires when vehicle is local to player
private["_unit","_veh"];
_unit = _this select 2;
_veh = _this select 0;
if (isPlayer _unit) then
{
_unit action ["eject",_veh];
cutText ["You are not allowed to enter that vehicle at this time","PLAIN DOWN"];
titleText ["You are not allowed to enter that vehicle at this time","PLAIN DOWN"];
};
}];

View File

@ -0,0 +1,9 @@
/*
by Ghostrider-Dbd-
1/13/17
*/
params["_vehicle"];
{
_vehicle removeAllEventHandlers _x;
}forEach ["GetIn","GetOut","Killed","Fired","HandleDamage","HandleHeal","FiredNear"];
deleteVehicle _vehicle;

View File

@ -0,0 +1,21 @@
// Spawns an emplaced weapons, man's it, and saves it to an array of monitored vehicles.
// by Ghostrider-DBD-
// Last Updated 10-25-16
private["_emplaced","_safepos","_emp","_gunner"];
params["_pos","_emplacedGroup","_emplacedTypes",["_minDist",20],["_maxDist",35],["_precise",false] ];
if (isNull _emplacedGroup) exitWith {diag_log "[blckeagls] ERROR CONDITION:-->> NULL-GROUP Provided to _fnc_spawnEmplaced"; objNull;};
diag_log format["_fnc_spawnEmplacedGroup:: -- >> _emplacedGroup = %1",_emplacedGroup];
_safepos = [_pos,_minDist,_maxDist,0,0,20,0] call BIS_fnc_findSafePos;
_emplaced = selectRandom _emplacedTypes;
_emp = [_emplaced,_safepos] call blck_fnc_spawnVehicle;
_emp setVariable["DBD_vehType","emplaced"];
if (_precise) then {_emp setPosATL _pos];
_gunner = (units _emplacedGroup) select 0;
_gunner moveingunner _emp;
[_emp] call blck_fnc_configureMissionVehicle;
waitUntil { count crew _emp > 0};
blck_missionVehicles pushback _emp;
diag_log format["spawnEmplaced.sqf: Emplaced weapon %1 spawned"];
_emp

View File

@ -5,47 +5,44 @@
By Ghostrider-DBD-
Copyright 2016
Last updated 1-17-17
Last updated 1-13-17
*/
private _vehList = blck_missionVehicles;
private ["_veh","_vehList"];
_vehList = blck_missionVehicles;
//diag_log format["_fnc_vehicleMonitor:: function called with blck_missionVehicles = %1",_vehList];
{
private ["_veh"];
_veh = _x;
if (_veh getVariable["blck_DeleteAt",0] > 0) then
{
if (diag_tickTime > (_veh getVariable["blck_DeleteAt",0])) then
{
[_veh] call blck_deleteVehicle;
blck_missionVehicles = blck_missionVehicles - [_veh];
};
};
if ({alive _x} count crew _veh < 1) then
{
if (_veh getVariable["DBD_vehType","none"] isEqualTo "emplaced") then
{
[_veh] spawn {uiSleep 1;(_this select 0) setDamage 1;};
blck_missionVehicles = blck_missionVehicles - [_veh];
if (blck_debugOn) then{
diag_log format["_fnc_vehicleMonitor:: deleting emplaced weapon %1",_veh];
if (blck_debugOn) then
{
diag_log format["_fnc_vehicleMonitor:: case of destroyed where vehicle = %1",_veh];
};
_veh setDamage 1;
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
}else {
if (blck_killEmptyAIVehicles) then
{
blck_missionVehicles = blck_missionVehicles - [_veh];
[_veh] spawn {
params["_v"];
//diag_log format["vehicleMonitor.sqf:: case of patrol vehicle: _veh %1 is about to be killed with getAllHitPointsDamage = %2",_v, (getAllHitPointsDamage _v)];
uiSleep 20;
{
_v setHitPointDamage [_x, 1];
//diag_log format["vehicleMonitor: hitpart %1 for vehicle %1 set to 1",_x,_v];
} forEach ["HitLFWheel","HitLF2Wheel","HitRFWheel","HitRF2Wheel","HitEngine","HitLBWheel","HitLMWheel","HitRBWheel","HitRMWheel","HitTurret","HitGun","HitTurret","HitGun","HitTurret","HitGun","HitTurret","HitGun"];
if (blck_debugLevel isEqualTo 3) then
{
diag_log format["_fnc_vehicleMonitor:: damage applied to a patrol vehicle -- >> current damage for vehicle %1 is = %2",_v, (getAllHitPointsDamage _v)];
};
[_v] spawn { // spawn this so we don't hold up the rest the evaluations and cleanup needed.
private _v = _this select 0;
uiSleep 60;
if (blck_debugOn) then {
diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle:deleting vehicle _veh",_v];
};
deleteVehicle _v;
};
if (blck_debugOn) then
{
diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle destroyed where vehicle = %1",_veh];
};
{
_veh setHitPointDamage [_x, 1];
} forEach ["HitLFWheel","HitLF2Wheel","HitRFWheel","HitRF2Wheel","HitEngine","HitLBWheel","HitLMWheel","HitRBWheel","HitRMWheel","HitTurret","HitGun","HitTurret","HitGun","HitTurret","HitGun","HitTurret","HitGun"];
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
} else {
//diag_log format["vehicleMonitor.sqf: make vehicle available to players; stripping eventHandlers from_veh %1",_veh];
blck_missionVehicles = blck_missionVehicles - [_veh];

View File

@ -69,12 +69,13 @@ blck_fnc_setupWaypoints = compileFinal preprocessFileLineNumbers "\q\addons\cus
blck_fnc_cleanEmptyGroups = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Functions\GMS_fnc_cleanEmptyGroups.sqf"; // GMS_fnc_cleanEmptyGroups
// Functions specific to vehicles, whether wheeled or static
blck_fnc_spawnEmplacedWeapon = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_spawnEmplaced.sqf"; // Self-evident
blck_fnc_spawnVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_spawnVehicle.sqf"; // Spawn a temporary vehicle of a specified type at a specific position
blck_fnc_spawnVehiclePatrol = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_spawnVehiclePatrol.sqf"; // Spawn an AI vehicle control and have it patrol the mission perimeter
blck_fnc_spawnEmplacedWeapon = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_spawnEmplacedWeapon.sqf";
blck_fnc_spawnVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_spawnVehicle.sqf";
blck_fnc_spawnVehiclePatrol = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_spawnVehiclePatrol.sqf";
blck_fnc_protectVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_protectVehicle.sqf";
blck_fnc_configureMissionVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_configureMissionVehicle.sqf";
blck_fnc_vehicleMonitor = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_vehicleMonitor.sqf"; // Checks for vehicles for which all AI are dead and handles any changes needed when this is true.
blck_fnc_vehicleMonitor = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_vehicleMonitor.sqf";
blck_fnc_deleteVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_deleteVehicle.sqf";
// functions to support Units
blck_fnc_removeGear = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_removeGear.sqf"; // Strip an AI unit of all gear.
@ -86,9 +87,10 @@ blck_fnc_removeLaunchers = compileFinal preprocessFileLineNumbers "\q\addons\cu
blck_fnc_removeNVG = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_removeNVG.sqf";
blck_fnc_alertNearbyUnits = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_alertNearbyUnits.sqf";
blck_fnc_processIlleagalAIKills = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_processIlleagalAIKills.sqf";
GMS_fnc_cleanupDeadAI = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_cleanupDeadAI.sqf"; // handles deletion of AI bodies and gear when it is time.
blck_fnc_cleanupDeadAI = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_cleanupDeadAI.sqf"; // handles deletion of AI bodies and gear when it is time.
blck_fnc_setSkill = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_setSkill.sqf";
blck_fnc_cleanupAliveAI = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_cleanupAliveAI.sqf";
blck_fnc_deleteAI = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_deleteAI.sqf";
diag_log "[blckeagls] Functions Loaded";
blck_functionsCompiled = true;

View File

@ -6,8 +6,8 @@
Last modified 10/25/16
*/
//blck_variablesLoaded = false;
blck_debugON = false;
blck_debugLevel = 0; // Sets level of detail for debugging info - WIP.
blck_debugON = true;
blck_debugLevel = 1; // Sets level of detail for debugging info - WIP.
blck_minFPS = 10;
////////////////////////////////////////////////

View File

@ -159,7 +159,7 @@ Last modified 8/1/15
blck_bodyCleanUpTimer = 1200; // time in seconds after which dead AI bodies are deleted
// Each time an AI is killed, the location of the killer will be revealed to all AI within this range of the killed AI, set to -1 to disable
// values are ordered as follows [blue, red, green, orange];
blck_AliveAICleanUpTime = 900; // Time after mission completion at which any remaining live AI are deleted.
blck_AliveAICleanUpTimer = 900; // Time after mission completion at which any remaining live AI are deleted.
blck_cleanupCompositionTimer = 1200;
blck_AIAlertDistance = [250,325,450,500];
//blck_AIAlertDistance = [150,225,400,500];

View File

@ -157,7 +157,7 @@ Last modified 8/1/15
blck_bodyCleanUpTimer = 1200; // time in seconds after which dead AI bodies are deleted
// Each time an AI is killed, the location of the killer will be revealed to all AI within this range of the killed AI, set to -1 to disable
// values are ordered as follows [blue, red, green, orange];
blck_AliveAICleanUpTime = 900; // Time after mission completion at which any remaining live AI are deleted.
blck_AliveAICleanUpTimer = 900; // Time after mission completion at which any remaining live AI are deleted.
blck_cleanupCompositionTimer = 1200;
blck_AIAlertDistance = [150,225,250,300];
//blck_AIAlertDistance = [150,225,400,500];

View File

@ -32,17 +32,17 @@ if (blck_debugON) then
blck_cleanupCompositionTimer = 10; // Time after mission completion at which items in the composition are deleted.
blck_AliveAICleanUpTime = 10; // Time after mission completion at which any remaining live AI are deleted.
blck_AliveAICleanUpTimer = 10; // Time after mission completion at which any remaining live AI are deleted.
blck_bodyCleanUpTimer = 10;
blck_SpawnEmplaced_Orange = 4; // Number of static weapons at Orange Missions
blck_SpawnEmplaced_Green = 3; // Number of static weapons at Green Missions
blck_SpawnEmplaced_Blue = 1; // Number of static weapons at Blue Missions
blck_SpawnEmplaced_Blue = 0; // Number of static weapons at Blue Missions
blck_SpawnEmplaced_Red = 2;
blck_SpawnVeh_Orange = 4; // Number of static weapons at Orange Missions
blck_SpawnVeh_Green = 3; // Number of static weapons at Green Missions
blck_SpawnVeh_Blue = 1; // Number of static weapons at Blue Missions
blck_SpawnVeh_Blue = 0; // Number of static weapons at Blue Missions
blck_SpawnVeh_Red = 2;
//blck_reinforcementsBlue = [0, 0, 0.0, 0]; // Chance of reinforcements, number of reinforcements, Chance of reinforcing heli patrols, chance of dropping supplies for the reinforcements

View File

@ -1,9 +1,13 @@
/*
blck Mission system by Ghostrider-DBD-
Loosely based on the AI mission system by blckeagls ver 2.0.2
Contributions by Narines: bug fixes, testing, 'fired' event handler
Contributions by Narines: bug fixes, testing, infinite ammo fix.
Ideas or code from that by Vampire and KiloSwiss have been used for certain functions.
1/13/17 Build 29.
Modularizing mission spawner.
Searching for bug that causes mission completion code to hang.
1/13/17 Version 6.54 Build 27
Rerverted back to the code that spawned a single instance of each mission until I can debug certain issues.

View File

@ -1,3 +1,3 @@
private ["_version","_versionDate"];
_blck_version = "6.54 Build 28";
_blck_versionDate = "1-13-17 10:00 PM";
_blck_version = "6.54 Build 29";
_blck_versionDate = "1-21-17 5:00 PM";