This commit is contained in:
2022-04-21 16:15:41 +03:00
commit 9d4fc88901
601 changed files with 66252 additions and 0 deletions

View File

@ -0,0 +1,98 @@
/*
despawnBandits
Description: Deletes all AI units spawned by a trigger once all players leave the trigger area.
Usage: Called by a static trigger when all players have left the trigger area.
Last updated: 10:16 PM 5/26/2014
*/
private ["_trigger","_grpArray","_isCleaning","_grpCount","_debugMarkers","_triggerStatements","_deactStatements","_permDelete"];
if (!isServer) exitWith {}; //Execute script only on server.
_trigger = _this select 0; //Get the trigger object
_grpArray = _trigger getVariable ["GroupArray",[]]; //Find the groups spawned by the trigger.
_isCleaning = _trigger getVariable ["isCleaning",true]; //Find whether or not the trigger has been marked for cleanup. Triggers will flag themselves for cleaning after a successful spawn/respawn with setVariable ["isCleaning",false];
_triggerStatements = triggerStatements _trigger;
_grpCount = count _grpArray;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Trigger %1 Group Array: %2. isCleaning: %3. In static trigger array: %4",triggerText _trigger,_grpArray,_isCleaning,(_trigger in DZAI_staticTriggerArray)];};
if (!(_trigger in DZAI_staticTriggerArray) or {_isCleaning}) exitWith {if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Trigger %1 has a despawn script already running. Exiting despawn script.",triggerText _trigger];};};
_trigger setVariable["isCleaning",true]; //Mark the trigger as being in a cleanup state so that subsequent requests to despawn for the same trigger will not run.
_deactStatements = _triggerStatements select 2;
_triggerStatements set [2,""];
_trigger setTriggerStatements _triggerStatements;
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: No players remain in trigger area at %3. Deleting %1 AI groups in %2 seconds.",_grpCount, DZAI_despawnWait,(triggerText _trigger)];};
if (_debugMarkers) then {
_nul = _trigger spawn {
_tMarker = str (_this);
_tMarker setMarkerText "STATIC TRIGGER (DESPAWNING)";
_tMarker setMarkerColor "ColorOrange";
};
};
if (({isNull _x} count _grpArray) < _grpCount) then {uiSleep DZAI_despawnWait};
if (isNull _trigger) exitWith {[_trigger,"DZAI_staticTriggerArray"] call DZAI_updateSpawnCount};
if ((triggerActivated _trigger) && {({isNull _x} count _grpArray) < _grpCount}) exitWith { //Exit script if trigger has been reactivated since DZAI_despawnWait seconds has passed.
_trigger setVariable ["isCleaning",false]; //Allow next despawn request.
_triggerStatements set [2,_deactStatements];
_trigger setTriggerStatements _triggerStatements;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: A player has entered the trigger area at %1. Cancelling despawn script.",(triggerText _trigger)];};
if (_debugMarkers) then {
_nul = _trigger spawn {
_tMarker = str (_this);
_tMarker setMarkerText "STATIC TRIGGER (ACTIVE)";
_tMarker setMarkerColor "ColorRed";
};
};
};
_trigger setTriggerStatements ["this","true","false"]; //temporarily disable trigger from activating or deactivating while cleanup is performed
_permDelete = _trigger getVariable ["permadelete",false];
{
if (!isNull _x) then {
_groupSize = (_x getVariable ["groupSize",0]);
if ((_groupSize > 0) or {_permDelete}) then { //If trigger is not set to permanently despawn, then ignore empty groups.
//(DZAI_numAIUnits - _groupSize) call DZAI_updateUnitCount;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Despawning group %1 with %2 active units.",_x,(_x getVariable ["groupSize",0])];};
//_x call DZAI_deleteGroup;
_x setVariable ["GroupSize",-1];
_grpArray set [_forEachIndex,grpNull];
};
};
} forEach _grpArray;
[_trigger,"DZAI_staticTriggerArray"] call DZAI_updateSpawnCount;
if !(_permDelete) then {
//Cleanup variables attached to trigger
_trigger setVariable ["GroupArray",_grpArray - [grpNull]];
_trigger setVariable ["isCleaning",false];
_trigger setTriggerArea [600,600,0,false];
_trigger setTriggerStatements (_trigger getVariable "triggerStatements"); //restore original trigger statements
if (_debugMarkers) then {
_nul = _trigger spawn {
_tMarker = str (_this);
_tMarker setMarkerText "STATIC TRIGGER (INACTIVE)";
_tMarker setMarkerColor "ColorGreen";
};
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Despawned AI units at %1. Reset trigger's group array to: %2.",(triggerText _trigger),_trigger getVariable "GroupArray"];};
//diag_log format ["DEBUG :: Despawned trigger %1 has statements %2.",triggerText _trigger,triggerStatements _trigger];
} else {
if (_debugMarkers) then {
deleteMarker (str (_trigger));
};
deleteMarker (_trigger getVariable ["spawnmarker",""]);
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Permanently deleting a static spawn at %1.",triggerText _trigger]};
deleteVehicle _trigger;
};
true

View File

@ -0,0 +1,87 @@
/*
despawnBandits_dynamic
Last updated: 10:57 PM 3/10/2014
*/
private ["_trigger","_triggerLocation","_isForceDespawn","_grpArray","_canDespawn","_triggerExists","_debugMarkers","_triggerStatements","_deactStatements"];
if (!isServer) exitWith {}; //Execute script only on server.
_trigger = _this select 0; //Get the trigger object
_isForceDespawn = if ((count _this) > 1) then {_this select 1} else {false};
_triggerStatements = triggerStatements _trigger;
_grpArray = _trigger getVariable ["GroupArray",[]]; //Find the groups spawned by the trigger. Or set an empty group array if none are found.
if ((_trigger getVariable ["isCleaning",false]) && (!_isForceDespawn)) exitWith {if (DZAI_debugLevel > 1) then {diag_log "DZAI Extended Debug: Despawn script is already running. Exiting despawn script.";};};
_trigger setVariable["isCleaning",true]; //Mark the trigger as being in a cleanup state so that subsequent requests to despawn for the same trigger will not run.
_deactStatements = _triggerStatements select 2;
_trigger setTriggerStatements (_triggerStatements set [2,""]);
_canDespawn = true;
_triggerExists = true;
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
if (_isForceDespawn) then {
_trigger setTriggerStatements ["this","",""];
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: All units of dynamic AI group spawned by trigger %1 have been killed. Starting force despawn in 30 seconds.",triggerText _trigger];};
uiSleep 30;
} else {
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: No players remain in %1. Deleting spawned AI in %2 seconds.",triggerText _trigger,DZAI_dynDespawnWait];};
if (_debugMarkers) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorGreenAlpha";
_marker setMarkerAlpha 0.7; //Light green: Active trigger awaiting despawn.
};
};
uiSleep DZAI_dynDespawnWait; //Wait some time before deleting units. (amount of time to allow units to exist when the trigger area has no players)
if !(isNull _trigger) then { //Check if dynamic spawn area has been force-despawned (deleted). Force despawn will happen when all units have been killed.
_canDespawn = ((!triggerActivated _trigger) or {isNull (_grpArray select 0)}); //Can despawn dynamic spawn area if trigger isn't activated or spawned group is null
} else {
_triggerExists = false;
};
};
if !(_triggerExists) exitWith {}; //Cancel despawn process if it has already happened
if (_canDespawn) then {
_trigger setTriggerStatements ["this","",""]; //temporarily disable trigger from activating or deactivating while cleanup is performed
_grpArray = _grpArray - [grpNull];
{
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Deleting group %1 with %2 active units.",_x,(_x getVariable ["groupSize",0])];};
//(DZAI_numAIUnits - (_x getVariable ["groupSize",0])) call DZAI_updateUnitCount;
//_x call DZAI_deleteGroup;
_x setVariable ["GroupSize",-1];
} forEach _grpArray;
//Remove dynamic trigger from global dyn trigger array and clean up trigger
[_trigger,"DZAI_dynTriggerArray"] call DZAI_updateSpawnCount;
if (_debugMarkers) then {deleteMarker str(_trigger)};
//Begin deletion timer for temporary blacklist area and add it to global dyn location array to allow deletion
_triggerLocation = _trigger getVariable "triggerLocation";
_triggerLocation setVariable ["deletetime",(diag_tickTime + 900)];
DZAI_tempBlacklist set [(count DZAI_tempBlacklist),_triggerLocation];
if (_trigger in DZAI_reinforcePlaces) then {DZAI_reinforcePlaces = DZAI_reinforcePlaces - [_trigger]};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Removing expired dynamic trigger at %1.",mapGridPosition _trigger];};
deleteVehicle _trigger;
true
} else {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: A player has entered the trigger area at %1. Cancelling despawn script.",(triggerText _trigger)];}; //Exit script if trigger has been reactivated since DZAI_dynDespawnWait seconds has passed.
_trigger setVariable ["isCleaning",false]; //Allow next despawn request.
_triggerStatements set [2,_deactStatements];
_trigger setTriggerStatements _triggerStatements;
if (_debugMarkers) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorOrange";
_marker setMarkerAlpha 0.9; //Reset trigger indicator color to Active.
};
};
false
};

View File

@ -0,0 +1,78 @@
private ["_trigger","_triggerLocation","_isForceDespawn","_grpArray","_canDespawn","_triggerExists","_debugMarkers","_triggerStatements","_deactStatements"];
if (!isServer) exitWith {}; //Execute script only on server.
_trigger = _this select 0; //Get the trigger object
_isForceDespawn = if ((count _this) > 1) then {_this select 1} else {false};
_triggerStatements = triggerStatements _trigger;
_grpArray = _trigger getVariable ["GroupArray",[]]; //Find the groups spawned by the trigger. Or set an empty group array if none are found.
if ((_trigger getVariable ["isCleaning",false]) && (!_isForceDespawn)) exitWith {if (DZAI_debugLevel > 1) then {diag_log "DZAI Extended Debug: Despawn script is already running. Exiting despawn script.";};};
_trigger setVariable["isCleaning",true]; //Mark the trigger as being in a cleanup state so that subsequent requests to despawn for the same trigger will not run.
_deactStatements = _triggerStatements select 2;
_trigger setTriggerStatements (_triggerStatements set [2,""]);
_canDespawn = true;
_triggerExists = true;
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
if (_isForceDespawn) then {
_trigger setTriggerStatements ["this","",""];
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: All units of random AI group spawned by trigger %1 have been killed. Starting force despawn in 30 seconds.",triggerText _trigger];};
uiSleep 30;
} else {
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: No players remain in %1. Deleting spawned AI in %2 seconds.",triggerText _trigger,DZAI_randDespawnWait];};
if (_debugMarkers) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorGreenAlpha";
_marker setMarkerAlpha 0.7; //Light green: Active trigger awaiting despawn.
};
};
uiSleep DZAI_randDespawnWait; //Wait some time before deleting units. (amount of time to allow units to exist when the trigger area has no players)
if !(isNull _trigger) then { //Check if random spawn area has been force-despawned (deleted). Force despawn will happen when all units have been killed.
_canDespawn = ((!triggerActivated _trigger) or {isNull (_grpArray select 0)}); //Can despawn random spawn area if trigger isn't activated or spawned group is null
} else {
_triggerExists = false;
};
};
if !(_triggerExists) exitWith {}; //Cancel despawn process if it has already happened
if (_canDespawn) then {
_trigger setTriggerStatements ["this","",""]; //temporarily disable trigger from activating or deactivating while cleanup is performed
_grpArray = _grpArray - [grpNull];
{
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Deleting group %1 with %2 active units.",_x,(_x getVariable ["groupSize",0])];};
_x setVariable ["GroupSize",-1];
} forEach _grpArray;
//Remove random trigger from global dyn trigger array and clean up trigger
[_trigger,"DZAI_randTriggerArray"] call DZAI_updateSpawnCount;
if (_debugMarkers) then {deleteMarker str(_trigger)};
//Begin deletion timer for temporary blacklist area and add it to global dyn location array to allow deletion
_triggerLocation = _trigger getVariable "triggerLocation";
_triggerLocation setVariable ["deletetime",(diag_tickTime + 900)];
DZAI_tempBlacklist set [(count DZAI_tempBlacklist),_triggerLocation];
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Removing expired random trigger at %1.",mapGridPosition _trigger];};
deleteVehicle _trigger;
true
} else {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: A player has entered the trigger area at %1. Cancelling despawn script.",(triggerText _trigger)];}; //Exit script if trigger has been reactivated since DZAI_randDespawnWait seconds has passed.
_trigger setVariable ["isCleaning",false]; //Allow next despawn request.
_triggerStatements set [2,_deactStatements];
_trigger setTriggerStatements _triggerStatements;
if (_debugMarkers) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorOrange";
_marker setMarkerAlpha 0.9; //Reset trigger indicator color to Active.
};
};
false
};

View File

@ -0,0 +1,56 @@
/*
respawnBandits
Usage: [_unitGroup,_trigger,_maxUnits] call respawnBandits;
Description: Called internally by fnc_banditAIRespawn. Calls fnc_createAI to respawn a unit near a randomly selected building from a stored reference location.
Last updated: 8:38 AM 10/23/2013
*/
private ["_unitGroup","_trigger","_grpArray","_patrolDist","_equipType","_spawnPositions","_spawnPos","_unit","_pos","_startTime","_maxUnits","_totalAI","_aiGroup","_weapongrade"];
if (!isServer) exitWith {};
_startTime = diag_tickTime;
_unitGroup = _this select 0;
_trigger = _this select 1;
_maxUnits = _this select 2;
_patrolDist = _trigger getVariable ["patrolDist",150];
_equipType = _trigger getVariable ["equipType",1];
_spawnPositions = _trigger getVariable ["locationArray",[]];
_totalAI = 0;
_spawnPos = [];
if ((_trigger getVariable ["spawnChance",1]) call DZAI_chance) then {
_totalAI = ((_maxUnits select 0) + round(random (_maxUnits select 1)));
_spawnPos = if ((count _spawnPositions) > 0) then {_spawnPositions call DZAI_findSpawnPos} else {[(ASLtoATL getPosASL _trigger),random (_patrolDist),random(360),0] call SHK_pos};
};
if ((_totalAI == 0) or {((count _spawnPos) == 0)}) exitWith {
[0,_trigger,_unitGroup] call fnc_respawnHandler;
false
};
//Respawn the group
_weapongrade = _equipType call DZAI_getWeapongrade;
_aiGroup = [_totalAI,_unitGroup,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
if (isNull _unitGroup) then {diag_log format ["DZAI Error :: Respawned group at %1 was null group. New group reassigned: %2.",triggerText _trigger,_aiGroup]; _unitGroup = _aiGroup};
if (_patrolDist > 1) then {
if ((count (waypoints _unitGroup)) > 1) then {
_unitGroup setCurrentWaypoint ((waypoints _unitGroup) call BIS_fnc_selectRandom2);
} else {
_nul = [_unitGroup,(ASLtoATL getPosASL _trigger),_patrolDist] spawn DZAI_BIN_taskPatrol;
};
} else {
[_unitGroup, 0] setWaypointType "HOLD";
};
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {
_nul = _trigger call DZAI_addMapMarker;
};
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: %1 AI units respawned for group %2 (weapongrade %3) at %4 in %5 seconds (respawnBandits).",_totalAI,_unitGroup,_weapongrade,(triggerText _trigger),diag_tickTime - _startTime];};
true

View File

@ -0,0 +1,61 @@
//Respawn handler stage 1
private ["_respawnSleep","_nextRespawnTime","_mode"];
_respawnSleep = 0;
_nextRespawnTime = 0;
_mode = _this select 0;
call {
if (_mode == 0) exitWith {
//Infantry AI respawn
_trigger = _this select 1; //spawn area to respawn
_unitGroup = _this select 2; //infantry group to respawn
_fastMode = if ((count _this) > 3) then {_this select 3} else {false}; //shorter wait time if retrying a spawn
_respawnSleep = _trigger getVariable ["respawnTime",(DZAI_respawnTimeMin + (random DZAI_respawnTimeVariance))]; //Calculate wait time for respawn. Respawn time may be individually defined for custom spawns.
if (_fastMode) then {_respawnSleep = (_respawnSleep/2) max 60};
_nextRespawnTime = (diag_tickTime + _respawnSleep); //Determine time of next respawn
DZAI_respawnQueue set [(count DZAI_respawnQueue),[diag_tickTime + _respawnSleep,_mode,_trigger,_unitGroup]];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Added group %1 to respawn queue. Queue position %2. Wait Time %3 (respawnHandler)",_unitGroup,(count DZAI_respawnQueue),_respawnSleep];};
};
if (_mode == 1) exitWith {
//Custom vehicle AI respawn
_spawnParams = _this select 1; //parameters used to call DZAI_spawn_vehicle
_respawnSleep = if ((count _spawnParams) > 5) then {_spawnParams select 5} else {600}; //calculate respawn time
_nextRespawnTime = (diag_tickTime + _respawnSleep); //Determine time of next respawn
DZAI_respawnQueue set [(count DZAI_respawnQueue),[diag_tickTime + _respawnSleep,_mode,_spawnParams]];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Added custom AI vehicle %1 patrol to respawn queue. Queue position %2. Wait Time %3 (respawnHandler)",(_spawnParams select 1),(count DZAI_respawnQueue),_respawnSleep];};
};
if (_mode == 2) exitWith {
//Vehicle patrol AI respawn
_vehicleType = _this select 1;
_fastMode = if ((count _this) > 2) then {_this select 2} else {false}; //shorter wait time if retrying a spawn
if (_vehicleType isKindOf "Air") then {
_respawnSleep = (DZAI_respawnTMinA + random DZAI_respawnTimeVarAir);
} else {
_respawnSleep = (DZAI_respawnTMinL + random DZAI_respawnTimeVarLand);
if (_fastMode) then {_respawnSleep = (_respawnSleep/2) max 180};
};
_nextRespawnTime = (diag_tickTime + _respawnSleep); //Determine time of next respawn
DZAI_respawnQueue set [(count DZAI_respawnQueue),[diag_tickTime + _respawnSleep,_mode,_vehicleType]];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Added AI vehicle patrol type %1 to respawn queue. Queue position %2. Wait Time %3 (respawnHandler)",_vehicleType,(count DZAI_respawnQueue),_respawnSleep];};
};
};
if (!isNil "DZAI_respawnActive") exitWith {}; //If the first respawn has already occured, no need to modify the initial wait time.
if (!isNil "DZAI_nextRespawnTime") then {
if (_nextRespawnTime < DZAI_nextRespawnTime) then { //If the newest respawn is scheduled to happen sooner than the next closest respawn, reduce the initial wait time appropriately.
DZAI_nextRespawnTime = _nextRespawnTime; //Time of next spawn
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Decreased time to next respawn to %1 seconds.",_respawnSleep];};
};
} else {
DZAI_nextRespawnTime = _nextRespawnTime;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Time to first respawn set to %1 seconds.",_respawnSleep];};
};
if (!isNil "DZAI_queueActive") exitWith {};
DZAI_queueActive = true; //The respawn queue is established, so don't create another one until it's finished.
DZAI_respawnHandlerHandle = [] spawn fnc_respawnHandler2;
true

View File

@ -0,0 +1,129 @@
//Respawn handler stage 2
#define PROCESSING_WAIT_TIME 5 //Minimum time delay between respawns.
waitUntil {uiSleep 3; diag_tickTime > DZAI_nextRespawnTime};
DZAI_respawnActive = true; //First respawn is now being processed, so deny subsequent attempts to modify the initial wait time.
DZAI_queueActive = nil;
DZAI_nextRespawnTime = nil;
while {(count DZAI_respawnQueue) > 0} do {
private ["_minDelay","_delay"];
_minDelay = -1;
//diag_log format ["DEBUG: Contents of respawn queue before cleanup stage 1: %1.",DZAI_respawnQueue];
//Remove expired entries before proceeding.
{
if (((typeName (_x select 3)) == "GROUP") && {(isNull (_x select 3))}) then {
DZAI_respawnQueue set [_forEachIndex,objNull];
};
} forEach DZAI_respawnQueue;
//diag_log format ["DEBUG: Contents of respawn queue before cleanup stage 2: %1.",DZAI_respawnQueue];
if (objNull in DZAI_respawnQueue) then {
DZAI_respawnQueue = DZAI_respawnQueue - [objNull];
//diag_log "DEBUG :: Cleaned despawned groups from respawn queue.";
};
//diag_log format ["DEBUG: Contents of respawn queue after cleanup: %1.",DZAI_respawnQueue];
//Begin examining queue entries.
for "_i" from 0 to ((count DZAI_respawnQueue) - 1) do {
_timeToRespawn = (DZAI_respawnQueue select _i) select 0;
//If enough time has passed to respawn the group.
if (diag_tickTime > _timeToRespawn) then {
_mode = (DZAI_respawnQueue select _i) select 1;
call {
if (_mode == 0) exitWith {
//Infantry AI respawn
_trigger = (DZAI_respawnQueue select _i) select 2;
_unitGroup = (DZAI_respawnQueue select _i) select 3;
_grpArray = _trigger getVariable ["GroupArray",[]];
if ((_unitGroup in _grpArray) && {((_unitGroup getVariable ["GroupSize",0]) == 0)}) then {
if (((triggerStatements _trigger) select 1) == "") then {
//Trigger is active, so respawn the group
_maxUnits = _trigger getVariable ["maxUnits",[1,0]];
_respawned = [_unitGroup,_trigger,_maxUnits] call fnc_respawnBandits;
if ((DZAI_debugLevel > 0) && {!_respawned}) then {diag_log format ["DZAI Debug: No units were respawned for group %1 at %2. Group %1 reinserted into respawn queue.",_unitGroup,(triggerText _trigger)];};
} else {
//Trigger is inactive (despawned or deleted) so clean up group instead
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Spawn area %1 has already been despawned. Cleaning up group %2.",triggerText _trigger,_unitGroup]};
_unitGroup call DZAI_deleteGroup;
if (!isNull _trigger) then {
_trigger setVariable ["GroupArray",_grpArray - [grpNull]];
};
};
};
};
if (_mode == 1) exitWith {
//Custom vehicle AI respawn
_respawnParams = (DZAI_respawnQueue select _i) select 2;
_nul = _respawnParams spawn DZAI_spawnVehicle_custom;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Respawning custom AI vehicle patrol with params %1",((DZAI_respawnQueue select _i) select 2)]};
};
if (_mode == 2) exitWith {
//Vehicle AI patrol respawn
_vehicleTypeOld = (DZAI_respawnQueue select _i) select 2;
if (_vehicleTypeOld isKindOf "Air") then {
//Air-type vehicle AI patrol respawn
if ((count DZAI_heliTypesUsable) == 0) then {
_nul = _vehicleTypeOld spawn DZAI_spawnVehiclePatrol;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Respawning AI air vehicle patrol type %1.",_vehicleTypeOld]};
} else {
DZAI_heliTypesUsable set [(count DZAI_heliTypesUsable),_vehicleTypeOld];
_index = floor (random (count DZAI_heliTypesUsable));
_vehicleTypeNew = DZAI_heliTypesUsable select _index;
_nul = _vehicleTypeNew spawn DZAI_spawnVehiclePatrol;
DZAI_heliTypesUsable set [_index,objNull];
DZAI_heliTypesUsable = DZAI_heliTypesUsable - [objNull];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Respawning AI air vehicle type patrol %1.",_vehicleTypeNew]};
};
} else {
if (_vehicleTypeOld isKindOf "LandVehicle") then {
//Land-type vehicle AI patrol respawn
if ((count DZAI_heliTypesUsable) == 0) then {
_nul = _vehicleTypeOld spawn DZAI_spawnVehiclePatrol;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Respawning AI land vehicle patrol type %1.",_vehicleTypeOld]};
} else {
DZAI_vehTypesUsable set [(count DZAI_vehTypesUsable),_vehicleTypeOld];
_index = floor (random (count DZAI_vehTypesUsable));
_vehicleTypeNew = DZAI_vehTypesUsable select _index;
_nul = _vehicleTypeNew spawn DZAI_spawnVehiclePatrol;
DZAI_vehTypesUsable set [_index,objNull];
DZAI_vehTypesUsable = DZAI_vehTypesUsable - [objNull];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Respawning AI land vehicle patrol type %1.",_vehicleTypeNew]};
};
};
};
};
};
DZAI_respawnQueue set [_i,objNull];
uiSleep PROCESSING_WAIT_TIME;
} else {
//Find shortest delay to next group respawn.
_delay = ((_timeToRespawn - diag_tickTime) max PROCESSING_WAIT_TIME);
//diag_log format ["DEBUG :: Comparing new respawn time %1 with previous %2.",_delay,_minDelay];
if (_minDelay > 0) then {
//If next delay time is smaller than the current minimum delay, use it instead.
if (_delay < _minDelay) then {
_minDelay = _delay;
//diag_log format ["DEBUG :: Found shorter respawn interval: %1 seconds.",_minDelay];
};
} else {
//Initialize minimum delay to first found delay.
_minDelay = _delay;
//diag_log format ["DEBUG :: Set respawn interval to %1 seconds.",_minDelay];
};
};
};
//Remove processed entries
if (objNull in DZAI_respawnQueue) then {
DZAI_respawnQueue = DZAI_respawnQueue - [objNull];
//diag_log "DEBUG :: Cleaned respawned groups from respawn queue.";
};
if (_minDelay > -1) then {
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: %1 groups left in respawn queue. Next group is scheduled to respawn in %2 seconds.",(count DZAI_respawnQueue),_minDelay];};
uiSleep _minDelay;
};
};
DZAI_respawnActive = nil;
if (DZAI_debugLevel > 0) then {diag_log "DZAI Debug: Respawn queue is empty. Exiting respawn handler. (respawnHandler)";};

View File

@ -0,0 +1,99 @@
/*
spawnBandits
Usage: [_minAI, _addAI, _patrolDist, _trigger, _numGroups (optional)] spawn spawnBandits;
Description: Called through (mapname)_config.sqf when a static trigger is activated by a player.
Last updated: 8:38 AM 10/23/2013
*/
private ["_minAI","_addAI","_patrolDist","_trigger","_equipType","_numGroups","_grpArray","_triggerPos","_startTime","_totalSpawned","_debugMarkers","_triggerStatements","_groupsActive"];
if (!isServer) exitWith {};
_minAI = _this select 0; //Mandatory minimum number of AI units to spawn
_addAI = _this select 1; //Maximum number of additional AI units to spawn
_patrolDist = _this select 2; //Patrol radius from trigger center.
_trigger = _this select 3; //The trigger calling this script.
//_positionArray = _this select 4; //Array of manually-defined spawn points (markers). If empty, nearby buildings are used as spawn points.
_equipType = if ((count _this) > 5) then {_this select 5} else {1}; //(Optional) Select the item probability table to use
_numGroups = if ((count _this) > 6) then {_this select 6} else {1}; //(Optional) Number of groups of x number of units each to spawn
_startTime = diag_tickTime;
_grpArray = _trigger getVariable ["GroupArray",[]];
_groupsActive = count _grpArray;
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
if (_groupsActive == _numGroups) exitWith {
_triggerStatements = (triggerStatements _trigger);
_triggerStatements set [1,""];
_trigger setTriggerStatements _triggerStatements;
_trigger setTriggerArea [750,750,0,false];
[_trigger,"DZAI_staticTriggerArray"] call DZAI_updateSpawnCount;
if (_debugMarkers) then {
_nul = _trigger call DZAI_addMapMarker;
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Maximum number of groups already spawned at %1. Exiting spawn script (spawnBandits)",(triggerText _trigger)];};
};
_trigger setTriggerArea [750,750,0,false]; //Expand trigger area to prevent players from quickly leaving and start respawn process immediately
_triggerPos = ASLtoATL getPosASL _trigger;
//If trigger already has defined spawn points, then reuse them instead of recalculating new ones.
_locationArray = _trigger getVariable ["locationArray",[]];
_totalSpawned = 0;
//Spawn groups
for "_j" from 1 to (_numGroups - _groupsActive) do {
private ["_unitGroup","_spawnPos","_totalAI"];
_totalAI = 0;
_spawnPos = [];
if ((_trigger getVariable ["spawnChance",1]) call DZAI_chance) then {
_totalAI = (_minAI + round(random _addAI));
_spawnPos = if ((count _locationArray) > 0) then {_locationArray call DZAI_findSpawnPos} else {[(ASLtoATL getPosASL _trigger),random (_patrolDist),random(360),0] call SHK_pos};
};
//If non-zero unit amount and valid spawn position, spawn group, otherwise add it to respawn queue.
_unitGroup = grpNull;
if ((_totalAI > 0) && {(count _spawnPos) > 1}) then {
_weapongrade = _equipType call DZAI_getWeapongrade;
_unitGroup = [_totalAI,_unitGroup,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
_totalSpawned = _totalSpawned + _totalAI;
if (_patrolDist > 1) then {
0 = [_unitGroup,_triggerPos,_patrolDist] spawn DZAI_BIN_taskPatrol;
} else {
[_unitGroup, 0] setWaypointType "HOLD";
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawned group %1 (weapongrade: %2) with %3 units.",_unitGroup,_weapongrade,_totalAI];};
} else {
_unitGroup = [] call DZAI_createGroup;
_dummy = _unitGroup call DZAI_protectGroup;
_unitGroup setVariable ["GroupSize",0];
_unitGroup setVariable ["trigger",_trigger];
0 = [0,_trigger,_unitGroup] call fnc_respawnHandler;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: No units spawned for group %1. Added group to respawn queue.",_unitGroup];};
};
//Set group variables and add it to trigger's group array
_unitGroup setVariable ["unitType","static"];
_unitGroup allowFleeing 0;
_grpArray set [count _grpArray,_unitGroup];
};
_triggerStatements = (triggerStatements _trigger);
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Trigger group array updated to: %1.",_trigger getVariable "GroupArray"]};
_trigger setVariable ["isCleaning",false];
_triggerStatements set [1,""];
_trigger setTriggerStatements _triggerStatements;
[_trigger,"DZAI_staticTriggerArray"] call DZAI_updateSpawnCount;
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: Spawned %1 new AI groups (%2 units total) in %3 seconds at %4 (spawnBandits).",_numGroups,_totalSpawned,(diag_tickTime - _startTime),(triggerText _trigger)];};
if (_debugMarkers) then {
_nul = _trigger call DZAI_addMapMarker;
};
//diag_log format ["DEBUG :: Activated trigger %1 has statements %2.",triggerText _trigger,triggerStatements _trigger];
true

View File

@ -0,0 +1,75 @@
/*
spawnBandits_custom
Usage:
Description: DZAI custom spawn function (DZAI_spawn).
Last updated: 6:00 PM 10/24/2013
*/
private ["_patrolDist","_trigger","_grpArray","_triggerPos","_equipType","_weapongrade","_totalAI","_startTime","_tMarker","_unitGroup","_spawnPos","_totalAI"];
if (!isServer) exitWith {};
_startTime = diag_tickTime;
_totalAI = _this select 0;
//_this select 1;
_patrolDist = _this select 2;
_trigger = _this select 3;
_weapongrade = _this select 4;
//_spawnMarker = _this select 5;
_grpArray = _trigger getVariable ["GroupArray",[]];
if (count _grpArray > 0) exitWith {if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Active groups found at %1. Exiting spawn script (spawnBandits)",(triggerText _trigger)];};};
_trigger setTriggerArea [750,750,0,false];
_triggerPos = ASLtoATL getPosASL _trigger;
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: Processed static trigger spawn data in %1 seconds (Custom Spawn).",(diag_tickTime - _startTime)];};
_startTime = diag_tickTime;
if !(_trigger getVariable ["respawn",true]) then {
_maxUnits = _trigger getVariable ["maxUnits",[0,0]];
_totalAINew = (_maxUnits select 0);
if (_totalAINew > 0) then {_totalAI = _totalAINew}; //Retrieve AI amount if it was updated from initial value (for non-respawning custom spawns only)
};
_spawnPos = [(ASLtoATL getPosASL _trigger),random (_patrolDist),random(360),0] call SHK_pos;
_unitGroup = [_totalAI,grpNull,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
//Set group variables
_unitGroup setVariable ["unitType","static"];
_unitGroup allowFleeing 0;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Group %1 has group size %2.",_unitGroup,_totalAI];};
if (_patrolDist > 1) then {
0 = [_unitGroup,_triggerPos,_patrolDist] spawn DZAI_BIN_taskPatrol;
} else {
[_unitGroup, 0] setWaypointType "HOLD";
};
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: Spawned a group of %1 units in %2 seconds at %3 (Custom Spawn).",_totalAI,(diag_tickTime - _startTime),(triggerText _trigger)];};
_equipType = if (_weapongrade in DZAI_weaponGrades) then {(_weapongrade max 0)} else {3};
_grpArray set [count _grpArray,_unitGroup];
_triggerStatements = (triggerStatements _trigger);
if (!(_trigger getVariable ["initialized",false])) then {
0 = [0,_trigger,_grpArray,_patrolDist,_equipType,[],[_totalAI,0]] call DZAI_setTrigVars;
_trigger setVariable ["triggerStatements",+_triggerStatements];
} else {
_trigger setVariable ["isCleaning",false];
_trigger setVariable ["maxUnits",[_totalAI,0]];
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Trigger group array updated to: %1.",_grpArray]};
};
_triggerStatements set [1,""];
_trigger setTriggerStatements _triggerStatements;
[_trigger,"DZAI_staticTriggerArray"] call DZAI_updateSpawnCount;
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {
_nul = _trigger call DZAI_addMapMarker;
};
_unitGroup

View File

@ -0,0 +1,99 @@
/*
spawnBandits_dynamic
Usage: Called by an activated dynamic trigger when a player unit enters the trigger area.
Description: Spawns a group of AI units some distance from a dynamically-spawned trigger. These units do not respawn after death.
Last updated: 10:58 PM 6/6/2014
*/
private ["_patrolDist","_trigger","_totalAI","_unitGroup","_targetPlayer","_playerPos","_playerDir","_spawnPos","_startTime","_baseDist","_distVariance","_dirVariance","_behavior","_triggerStatements","_spawnDist"];
if (!isServer) exitWith {};
_startTime = diag_tickTime;
_patrolDist = _this select 0;
_trigger = _this select 1;
_targetPlayer = _trigger getVariable ["targetplayer",objNull];
if (isNull _targetPlayer) exitWith {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Cancelling dynamic spawn for target player. Reason: Player does not exist (logged out?).",name _targetPlayer]};
_nul = _trigger call DZAI_abortDynSpawn;
false
};
_baseDist = 200; //On foot distance: 200-275
_distVariance = 75;
_dirVariance = 90;
if (!((vehicle _targetPlayer) isKindOf "Man")) then {
_baseDist = _baseDist - 50; //In vehicle distance: 150-225m
_dirVariance = 67.5;
};
_playerPos = ASLtoATL getPosASL _targetPlayer;
_playerDir = getDir _targetPlayer;
_spawnDist = (_baseDist + random (_distVariance));
_spawnPos = [_playerPos,_spawnDist,[(_playerDir-_dirVariance),(_playerDir+_dirVariance)],0] call SHK_pos;
if (
(surfaceIsWater _spawnPos) or
{({(isPlayer _x) && {_x != _targetPlayer}} count (_spawnPos nearEntities [["CAManBase","LandVehicle"],125])) > 0} or
{(_spawnPos in (nearestLocation [_spawnPos,"Strategic"]))}
) exitWith {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Canceling dynamic spawn for target player %1. Possible reasons: Spawn position has water, player nearby, or is blacklisted.",name _targetPlayer]};
_nul = _trigger call DZAI_abortDynSpawn;
false
};
//Calculate group weapongrade and spawn units
_weapongrade = DZAI_dynEquipType call DZAI_getWeapongrade;
_totalAI = call {
if (_weapongrade == 0) exitWith {2 + floor (random 2)}; //2-3 units
if (_weapongrade == 1) exitWith {2 + floor (random 2)}; //2-3 units
if (_weapongrade == 2) exitWith {1 + floor (random 2)}; //1-2 units
if (_weapongrade == 3) exitWith {1 + floor (random 2)}; //1-2 units
1
};
_unitGroup = [_totalAI,grpNull,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
//Set group variables
_unitGroup setVariable ["unitType","dynamic"];
_unitGroup setBehaviour "AWARE";
//_unitGroup setCombatMode "RED"; //Handled by fn_createGroup.sqf
_unitGroup setSpeedMode "FULL";
_unitGroup allowFleeing 0;
//Begin hunting player or patrolling area
_behavior = if (DZAI_huntingChance call DZAI_chance) then {
_unitGroup reveal [_targetPlayer,4];
0 = [_unitGroup,_spawnPos,_patrolDist,_targetPlayer,ASLtoATL getPosASL _trigger] spawn DZAI_dyn_huntPlayer;
"HUNTING"
} else {
0 = [_unitGroup,_playerPos,_patrolDist] spawn DZAI_BIN_taskPatrol;
"PATROLLING"
};
if (DZAI_debugLevel > 0) then {
diag_log format["DZAI Debug: Spawned 1 new AI groups of %1 units each in %2 seconds at %3 using behavior mode %4. Distance from target: %5 meters.",_totalAI,(diag_tickTime - _startTime),(mapGridPosition _trigger),_behavior,_spawnDist];
};
_triggerStatements = (triggerStatements _trigger);
if (!(_trigger getVariable ["initialized",false])) then {
0 = [1,_trigger,[_unitGroup]] call DZAI_setTrigVars; //set dynamic trigger variables and create dynamic area blacklist
_trigger setVariable ["triggerStatements",+_triggerStatements];
};
_triggerStatements set [1,""];
_trigger setTriggerStatements _triggerStatements;
[_trigger,"DZAI_dynTriggerArray"] call DZAI_updateSpawnCount;
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorOrange";
_marker setMarkerAlpha 0.9; //Dark orange: Activated trigger
};
};
true

View File

@ -0,0 +1,99 @@
/*
spawnBandits_dynamic
Usage: Called by an activated dynamic trigger when a player unit enters the trigger area.
Description: Spawns a group of AI units some distance from a dynamically-spawned trigger. These units do not respawn after death.
Last updated: 10:58 PM 6/6/2014
*/
private ["_patrolDist","_trigger","_totalAI","_unitGroup","_targetPlayer","_playerPos","_playerDir","_spawnPos","_startTime","_baseDist","_distVariance","_dirVariance","_behavior","_triggerStatements","_spawnDist"];
if (!isServer) exitWith {};
_startTime = diag_tickTime;
_patrolDist = _this select 0;
_trigger = _this select 1;
_targetPlayer = _trigger getVariable ["targetplayer",objNull];
if (isNull _targetPlayer) exitWith {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Cancelling dynamic spawn for target player. Reason: Player does not exist (logged out?).",name _targetPlayer]};
_nul = _trigger call DZAI_abortDynSpawn;
false
};
_baseDist = 200; //On foot distance: 200-275
_distVariance = 75;
_dirVariance = 90;
if (!((vehicle _targetPlayer) isKindOf "Man")) then {
_baseDist = _baseDist - 50; //In vehicle distance: 150-225m
_dirVariance = 67.5;
};
_playerPos = ASLtoATL getPosASL _targetPlayer;
_playerDir = getDir _targetPlayer;
_spawnDist = (_baseDist + random (_distVariance));
_spawnPos = [_playerPos,_spawnDist,[(_playerDir-_dirVariance),(_playerDir+_dirVariance)],0] call SHK_pos;
if (
(surfaceIsWater _spawnPos) or
{({(isPlayer _x) && {_x != _targetPlayer}} count (_spawnPos nearEntities [["CAManBase","LandVehicle"],125])) > 0} or
{(_spawnPos in (nearestLocation [_spawnPos,"Strategic"]))}
) exitWith {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Canceling dynamic spawn for target player %1. Possible reasons: Spawn position has water, player nearby, or is blacklisted.",name _targetPlayer]};
_nul = _trigger call DZAI_abortDynSpawn;
false
};
//Calculate group weapongrade and spawn units
_weapongrade = DZAI_dynEquipType call DZAI_getWeapongrade;
_totalAI = call {
if (_weapongrade == 0) exitWith {2 + floor (random 2)}; //2-3 units
if (_weapongrade == 1) exitWith {2 + floor (random 2)}; //2-3 units
if (_weapongrade == 2) exitWith {1 + floor (random 2)}; //1-2 units
if (_weapongrade == 3) exitWith {1 + floor (random 2)}; //1-2 units
1
};
_unitGroup = [_totalAI,grpNull,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
//Set group variables
_unitGroup setVariable ["unitType","dynamic"];
_unitGroup setBehaviour "AWARE";
//_unitGroup setCombatMode "RED"; //Handled by fn_createGroup.sqf
_unitGroup setSpeedMode "FULL";
_unitGroup allowFleeing 0;
//Begin hunting player or patrolling area
_behavior = if (DZAI_huntingChance call DZAI_chance) then {
_unitGroup reveal [_targetPlayer,4];
0 = [_unitGroup,_spawnPos,_patrolDist,_targetPlayer,ASLtoATL getPosASL _trigger] spawn DZAI_dyn_huntPlayer;
"HUNTING"
} else {
0 = [_unitGroup,_playerPos,_patrolDist] spawn DZAI_BIN_taskPatrol;
"PATROLLING"
};
if (DZAI_debugLevel > 0) then {
diag_log format["DZAI Debug: Spawned 1 new AI groups of %1 units each in %2 seconds at %3 using behavior mode %4. Distance from target: %5 meters.",_totalAI,(diag_tickTime - _startTime),(mapGridPosition _trigger),_behavior,_spawnDist];
};
_triggerStatements = (triggerStatements _trigger);
if (!(_trigger getVariable ["initialized",false])) then {
0 = [_trigger,[_unitGroup]] call DZAI_setTrigVars; //set dynamic trigger variables and create dynamic area blacklist
_trigger setVariable ["triggerStatements",+_triggerStatements];
};
_triggerStatements set [1,""];
_trigger setTriggerStatements _triggerStatements;
_trigger call DZAI_updDynSpawnCount;
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorOrange";
_marker setMarkerAlpha 0.9; //Dark orange: Activated trigger
};
};
true

View File

@ -0,0 +1,71 @@
/*
spawnBandits_initialize
*/
private ["_minAI","_addAI","_patrolDist","_trigger","_equipType","_numGroups","_triggerPos","_locationArray","_positionArray","_startTime","_triggerStatements","_newTrigger"];
if (!isServer) exitWith {};
_startTime = diag_tickTime;
_minAI = _this select 0; //Mandatory minimum number of AI units to spawn
_addAI = _this select 1; //Maximum number of additional AI units to spawn
_patrolDist = _this select 2; //Patrol radius from trigger center.
_trigger = _this select 3; //The trigger calling this script.
_positionArray = _this select 4; //Array of manually-defined spawn points (markers). If empty, nearby buildings are used as spawn points.
_equipType = if ((count _this) > 5) then {_this select 5} else {1}; //(Optional) Select the item probability table to use
_numGroups = if ((count _this) > 6) then {_this select 6} else {1}; //(Optional) Number of groups of x number of units each to spawn
_triggerPos = ASLtoATL getPosASL _trigger;
_locationArray = [];
//If no markers specified in position array, then generate spawn points using building positions (search for buildings within 250m. generate a maximum of 150 positions).
if ((count _positionArray) == 0) then {
private["_nearbldgs"];
_nearbldgs = _triggerPos nearObjects ["HouseBase",250];
{
scopeName "bldgloop";
_pos = ASLtoATL getPosASL _x;
if (!(surfaceIsWater _pos)) then {
_locationCount = (count _locationArray);
_locationArray set [_locationCount,_pos];
if (_locationCount >= 150) then {
breakOut "bldgloop";
};
};
} count _nearbldgs;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawn trigger %1 is generating spawn positions from nearby buildings.",triggerText _trigger];};
} else {
{
if ((getMarkerColor _x) != "") then {
_pos = getMarkerPos _x;
if !(surfaceIsWater _pos) then {
_locationArray set [(count _locationArray),_pos];
deleteMarker _x;
};
};
} count _positionArray;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawn trigger %1 is generating spawn positions from provided markers.",triggerText _trigger];};
};
_newTrigger = createTrigger ["EmptyDetector", _triggerPos];
_newTrigger setTriggerArea [600, 600, 0, false];
_newTrigger setTriggerActivation ["ANY", "PRESENT", true];
_newTrigger setTriggerTimeout [10, 15, 20, true];
_newTrigger setTriggerText (triggerText _trigger);
_triggerStatements = [
"{isPlayer _x} count thisList > 0;", //Activation condition
format ["_nul = [%1,%2,%3,thisTrigger,%4,%5,%6] call fnc_spawnBandits;",_minAI,_addAI,_patrolDist,_positionArray,_equipType,_numGroups], //Activation statement
"_nul = [thisTrigger] spawn fnc_despawnBandits;" //Deactivation statement
];
_newTrigger setVariable ["respawnLimit",(missionNamespace getVariable ["DZAI_respawnLimit"+str(_equipType),5])];
_newTrigger setTriggerStatements _triggerStatements;
0 = [0,_newTrigger,[],_patrolDist,_equipType,_locationArray,[_minAI,_addAI]] call DZAI_setTrigVars;
//diag_log format ["DEBUG :: Created trigger %1 has statements %2.",triggerText _newTrigger,triggerStatements _newTrigger];
//diag_log format ["DEBUG :: Created trigger %1 has saved statements %2.",triggerText _newTrigger,(_newTrigger getVariable "triggerStatements")];
deleteVehicle _trigger;
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: Processed static trigger spawn data in %1 seconds (spawnBandits).",(diag_tickTime - _startTime)];};
true

View File

@ -0,0 +1,83 @@
private ["_patrolDist","_trigger","_totalAI","_unitGroup","_targetPlayer","_playerPos","_playerDir","_spawnPos","_startTime","_baseDist","_extraDist","_distVariance","_dirVariance","_behavior","_triggerStatements","_spawnDist","_thisList","_debugMarkers"];
if (!isServer) exitWith {};
_startTime = diag_tickTime;
_patrolDist = _this select 0;
_trigger = _this select 1;
_thisList = _this select 2;
//Calculate group weapongrade and spawn units
_weapongrade = DZAI_dynEquipType call DZAI_getWeapongrade;
_totalAI = call {
if (_weapongrade == 0) exitWith {2 + floor (random 2)}; //2-3 units
if (_weapongrade == 1) exitWith {1 + floor (random 2)}; //1-2 units
if (_weapongrade == 2) exitWith {1 + floor (random 2)}; //1-2 units
if (_weapongrade == 3) exitWith {1}; //1 unit
1
};
_checkArea = true;
_nearAttempts = 1;
_spawnPos = [0,0,0];
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
_baseDist = 0;
_extraDist = 400;
{
if (isPlayer _x) exitWith {
_playerPos = getPosASL _x;
if (count ((nearestLocations [_playerPos, ["Strategic"], 600])) < 2) then { //< 2: Don't count the Strategic area assigned to this spawn
_trigger setPosASL _playerPos;
_baseDist = 175;
_extraDist = 225;
if (_debugMarkers) then {
(str (_trigger)) setMarkerPos _playerPos;
};
};
};
} forEach _thisList;
_triggerPos = getPosASL _trigger;
while {_checkArea && {_nearAttempts < 4}} do {
_spawnPos = [_triggerPos,(_baseDist + (random _extraDist)),(random 360),0] call SHK_pos;
_checkArea = ({isPlayer _x} count (_spawnPos nearEntities [["CAManBase","Land"], 175]) > 0);
_nearAttempts = _nearAttempts + 1;
};
if (_nearAttempts > 3) exitWith {_nul = _trigger call DZAI_abortRandSpawn};
_unitGroup = [_totalAI,grpNull,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
//Set group variables
_unitGroup setVariable ["unitType","randomspawn"];
_unitGroup setBehaviour "AWARE";
_unitGroup setSpeedMode "FULL";
_unitGroup allowFleeing 0;
0 = [_unitGroup,_triggerPos,_patrolDist] spawn DZAI_BIN_taskPatrol;
if (DZAI_debugLevel > 0) then {
diag_log format["DZAI Debug: Spawned 1 new AI groups of %1 units each in %2 seconds at %3 (Random Spawn).",_totalAI,(diag_tickTime - _startTime),(mapGridPosition _trigger)];
};
_triggerStatements = (triggerStatements _trigger);
if (!(_trigger getVariable ["initialized",false])) then {
0 = [2,_trigger,[_unitGroup]] call DZAI_setTrigVars;
_trigger setVariable ["triggerStatements",+_triggerStatements];
};
_triggerStatements set [1,""];
_trigger setTriggerStatements _triggerStatements;
//[_trigger,"DZAI_randTriggerArray"] call DZAI_updateSpawnCount;
if (_debugMarkers) then {
_nul = _trigger spawn {
_marker = str(_this);
_marker setMarkerColor "ColorOrange";
_marker setMarkerAlpha 0.9; //Dark orange: Activated trigger
};
};
true

View File

@ -0,0 +1,201 @@
private ["_marker","_vehicleType","_weapongrade","_unitGroup","_driver","_vehicle","_gunnerSpots","_markerPos","_markerSize","_isAirVehicle","_unitType","_vehSpawnPos","_isArmed","_maxUnits","_maxCargoUnits","_maxGunnerUnits","_keepLooking"];
if (!isServer) exitWith {};
_vehicleType = _this;
_maxCargoUnits = 0;
_maxGunnerUnits = 0;
_weapongrade = 0;
_isAirVehicle = (_vehicleType isKindOf "Air");
_vehSpawnPos = [];
_spawnMode = "NONE";
_keepLooking = true;
_error = false;
call {
if (_vehicleType isKindOf "Air") exitWith {
//Note: no cargo units for air vehicles
_maxGunnerUnits = DZAI_heliGunnerUnits;
_weapongrade = DZAI_heliUnitLevel call DZAI_getWeapongrade;
_vehSpawnPos = [(getMarkerPos "DZAI_centerMarker"),300 + (random((getMarkerSize "DZAI_centerMarker") select 0)),random(360),1] call SHK_pos;
_vehSpawnPos set [2,150];
_spawnMode = "FLY";
};
if (_vehicleType isKindOf "LandVehicle") exitWith {
_maxGunnerUnits = DZAI_vehGunnerUnits;
_maxCargoUnits = DZAI_vehCargoUnits;
_weapongrade = DZAI_vehUnitLevel call DZAI_getWeapongrade;
while {_keepLooking} do {
_vehSpawnPos = [(getMarkerPos "DZAI_centerMarker"),300 + random((getMarkerSize "DZAI_centerMarker") select 0),random(360),0,[2,750]] call SHK_pos;
if ((count _vehSpawnPos) > 1) then {
_playerNear = ({isPlayer _x} count (_vehSpawnPos nearEntities [["CAManBase","Land","Air"], 300]) > 0);
if(!_playerNear) then {
_keepLooking = false; //Found road position, stop searching
};
} else {
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Unable to find road position to spawn AI %1. Retrying in 30 seconds.",_vehicleType]};
uiSleep 30; //Couldnt find road, search again in 30 seconds.
};
};
};
_error = true;
};
if (_error) exitWith {diag_log format ["DZAI Error: %1 attempted to spawn unsupported vehicle type %2.",__FILE__,_vehicleType]};
_unitGroup = [] call DZAI_createGroup;
_driver = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_driver] joinSilent _unitGroup;
_vehicle = createVehicle [_vehicleType, _vehSpawnPos, [], 0, _spawnMode];
_vehicle setPos _vehSpawnPos;
_driver moveInDriver _vehicle;
//Run high-priority commands to set up group vehicle
//_vehicle setFuel 1;
//_vehicle setVehicleAmmo 1;
//_vehicle engineOn true;
_nul = _vehicle call DZAI_protectObject;
if !(_vehicle isKindOf "Plane") then {
_vehicle setDir (random 360);
};
//Set variables
_vehicle setVariable ["unitGroup",_unitGroup];
//Determine vehicle armed state
_turretCount = count (configFile >> "CfgVehicles" >> _vehicleType >> "turrets");
_isArmed = ((({!(_x in ["CarHorn","BikeHorn","TruckHorn","TruckHorn2","SportCarHorn","MiniCarHorn"])} count (weapons _vehicle)) > 0) or {(_turretCount > 0)});
//Determine vehicle type and add needed eventhandlers
if (_isAirVehicle) then {
_vehicle setVariable ["durability",[0,0,0]]; //[structural, engine, tail rotor]
_vehicle addEventHandler ["Killed",{_this call DZAI_heliDestroyed;}]; //Begin despawn process when heli is destroyed.
_vehicle addEventHandler ["GetOut",{_this call DZAI_airLanding;}]; //Converts AI crew to ground AI units.
_vehicle addEventHandler ["HandleDamage",{_this call DZAI_hHandleDamage}];
} else {
_vehicle addEventHandler ["Killed",{_this call DZAI_vehDestroyed;}];
_vehicle addEventHandler ["HandleDamage",{_this call DZAI_vHandleDamage}];
};
_vehicle allowCrewInImmobile (!_isAirVehicle);
_vehicle setVehicleLock "LOCKED";
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
//Setup group and crew
0 = [_driver,_weapongrade] call DZAI_setSkills;
0 = [_driver,_weapongrade] call DZAI_setupLoadout;
_driver setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];
_driver setVariable ["unconscious",false];
_driver setVariable ["bodyName",(name _driver)];
if (!(_driver hasWeapon "NVGoggles")) then {
_nvg = _driver call DZAI_addTempNVG;
};
_driver addEventHandler [DZAI_healthType, DZAI_healthStatements];
_driver assignAsDriver _vehicle;
_driver setVariable ["isDriver",true];
_unitGroup selectLeader _driver;
_cargoSpots = _vehicle emptyPositions "cargo";
for "_i" from 0 to ((_cargoSpots min _maxCargoUnits) - 1) do {
_cargo = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_cargo] joinSilent _unitGroup;
0 = [_cargo,_weapongrade] call DZAI_setSkills;
0 = [_cargo,_weapongrade] call DZAI_setupLoadout;
_cargo setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];
_cargo setVariable ["unconscious",false];
_cargo setVariable ["bodyName",(name _cargo)];
if (!(_cargo hasWeapon "NVGoggles")) then {
_nvg = _cargo call DZAI_addTempNVG;
};
_cargo addEventHandler [DZAI_healthType, DZAI_healthStatements];
_cargo assignAsCargo _vehicle;
_cargo moveInCargo [_vehicle,_i];
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawned %1 cargo units for %2 vehicle %3.",(_cargoSpots min _maxCargoUnits),_unitGroup,_vehicleType]};
for "_i" from 0 to ((_turretCount min _maxGunnerUnits) - 1) do {
_gunner = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_gunner] joinSilent _unitGroup;
0 = [_gunner,_weapongrade] call DZAI_setSkills;
0 = [_gunner,_weapongrade] call DZAI_setupLoadout;
_gunner setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];
_gunner setVariable ["unconscious",false];
_gunner setVariable ["bodyName",(name _gunner)];
if (!(_gunner hasWeapon "NVGoggles")) then {
_nvg = _gunner call DZAI_addTempNVG;
};
_gunner addEventHandler [DZAI_healthType, DZAI_healthStatements];
_gunner assignAsGunner _vehicle;
_gunner moveInTurret [_vehicle,[_i]];
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawned %1 gunner units for %2 vehicle %3.",(_turretCount min _maxGunnerUnits),_unitGroup,_vehicleType]};
_unitGroup allowFleeing 0;
_unitGroup setBehaviour "AWARE";
_unitGroup setSpeedMode "NORMAL";
_unitGroup setCombatMode "YELLOW";
_unitType = if (_isAirVehicle) then {"air"} else {"land"};
_unitGroup setVariable ["unitType",_unitType];
_unitGroup setVariable ["weapongrade",_weapongrade];
_unitGroup setVariable ["assignedVehicle",_vehicle];
_unitGroup setVariable ["isArmed",_isArmed];
(units _unitGroup) allowGetIn true;
//If vehicle is air type and unarmed, check if user config has weapons specified.
if (_isAirVehicle && {!_isArmed}) then {
_index = (DZAI_airWeapons select 0) find _vehicleType;
if (_index > -1) then {
_vehWeapon = (DZAI_airWeapons select 1) select _index;
if ([_vehWeapon,"weapon"] call DZAI_checkClassname) then {
_vehicle addWeapon _vehWeapon;
_vehMag = getArray (configFile >> "CfgWeapons" >> _vehWeapon >> "magazines") select 0;
_vehicle addMagazine _vehMag;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Added weapon %1 and ammo %2 to AI %3 (Group: %1).",_vehWeapon,_vehMag,_vehicleType,_unitGroup]};
};
};
};
_rearm = [_unitGroup,_weapongrade] spawn DZAI_autoRearm_group; //start group-level manager
//if (daytime < 6 or {daytime > 20}) then {_vehicle action ["lightOn", _vehicle]};
if (_isAirVehicle) then {
//Set initial waypoint and begin patrol
[_unitGroup,0] setWaypointType "MOVE";
[_unitGroup,0] setWaypointTimeout [0.5,0.5,0.5];
[_unitGroup,0] setWaypointCompletionRadius 200;
[_unitGroup,0] setWaypointStatements ["true","[(group this)] spawn DZAI_heliDetectPlayers;"];
_waypoint = _unitGroup addWaypoint [_vehSpawnPos,0];
_waypoint setWaypointType "MOVE";
_waypoint setWaypointTimeout [3,6,9];
_waypoint setWaypointCompletionRadius 150;
_waypoint setWaypointStatements ["true","[(group this)] spawn DZAI_heliRandomPatrol;"];
[_unitGroup] spawn DZAI_heliRandomPatrol;
//if (DZAI_heliReinforceChance > 0) then {_oncall = [_vehicle,_unitGroup] spawn DZAI_heliOnCall}; //helicopter listen for reinforcement summons
_vehicle flyInHeight 125;
if ((!isNull _vehicle) && {!isNull _unitGroup}) then {
DZAI_curHeliPatrols = DZAI_curHeliPatrols + 1;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Created AI helicopter crew group %1 is now active and patrolling.",_unitGroup];};
};
} else {
//Set initial waypoint and begin patrol
[_unitGroup,0] setWaypointType "MOVE";
[_unitGroup,0] setWaypointTimeout [5,10,15];
[_unitGroup,0] setWaypointCompletionRadius 150;
[_unitGroup,0] setWaypointStatements ["true","[(group this)] spawn DZAI_vehPatrol;"];
[_unitGroup] spawn DZAI_vehPatrol;
if ((!isNull _vehicle) && {!isNull _unitGroup}) then {
DZAI_curLandPatrols = DZAI_curLandPatrols + 1;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Created AI land vehicle crew group %1 is now active and patrolling.",_unitGroup];};
};
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Created AI vehicle patrol at %1 with vehicle type %2 with %3 crew units.",_vehSpawnPos,_vehicleType,(count (units _unitGroup))]};
true

View File

@ -0,0 +1,181 @@
private ["_marker","_vehicleType","_weapongrade","_unitGroup","_driver","_vehicle","_gunnerSpots","_markerPos","_markerSize","_isAirVehicle","_unitType","_vehSpawnPos","_isArmed","_maxUnits","_maxCargoUnits","_maxGunnerUnits","_keepLooking"];
if (!isServer) exitWith {};
_marker = _this select 0;
_vehicleType = _this select 1;
_maxUnits = _this select 2;
_weapongrade = _this select 3;
//_respawnSelect = _this select 4; //Value not used in this script. Holds respawn settings.
//Calculate needed values
_markerPos = (getMarkerPos _marker);
if ((markerAlpha _marker) > 0) then {_marker setMarkerAlpha 0};
_markerSize = ((getMarkerSize _marker) select 0);
_maxCargoUnits = _maxUnits select 0;
_maxGunnerUnits = _maxUnits select 1;
_isAirVehicle = (_vehicleType isKindOf "Air");
_vehSpawnPos = [];
_roadSearching = 1; //SHK_pos will search for roads, and return random position if none found.
_waterPosAllowed = 0; //do not allow water position for land vehicles.
_spawnMode = "NONE";
if (_isAirVehicle) then {
_roadSearching = 0; //No need to search for road positions for air vehicles
_waterPosAllowed = 1; //Allow water position for air vehicles
_spawnMode = "FLY"; //set flying mode for air vehicles
_vehSpawnPos set [2,180]; //spawn air vehicles in air
_markerPos set [2,150]; //set marker height in air
if (_maxCargoUnits != 0) then {_maxCargoUnits = 0}; //disable cargo units for air vehicles
};
_keepLooking = true;
_waitTime = 10;
while {_keepLooking} do {
_vehSpawnPos = [_markerPos,random _markerSize,random(360),_waterPosAllowed,[_roadSearching,200]] call SHK_pos;
if (({isPlayer _x} count (_vehSpawnPos nearEntities [["CAManBase","Land","Air"],300])) == 0) then {
_keepLooking = false; //safe area found, continue to spawn the vehicle and crew
} else {
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Waiting %1 seconds for area at %2 to have no players nearby to spawn custom AI vehicle %3.",_waitTime,_marker,_vehicleType]};
uiSleep _waitTime; //wait a while before checking spawn area again. Scaling wait time from 10-30 seconds.
_waitTime = ((_waitTime + 5) min 60);
};
};
_unitGroup = [] call DZAI_createGroup;
_driver = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_driver] joinSilent _unitGroup;
_vehicle = createVehicle [_vehicleType, _vehSpawnPos, [], 0, _spawnMode];
_vehicle setPos _vehSpawnPos;
_driver moveInDriver _vehicle;
//Run needed commands to set up group vehicle
//_vehicle setFuel 1;
//_vehicle setVehicleAmmo 1;
//_vehicle engineOn true;
_nul = _vehicle call DZAI_protectObject;
if !(_vehicle isKindOf "Plane") then {
_vehicle setDir (random 360);
};
//Set variables
_vehicle setVariable ["unitGroup",_unitGroup];
//Determine vehicle armed state
_turretCount = count (configFile >> "CfgVehicles" >> _vehicleType >> "turrets");
_isArmed = ((({!(_x in ["CarHorn","BikeHorn","TruckHorn","TruckHorn2","SportCarHorn","MiniCarHorn"])} count (weapons _vehicle)) > 0) or {(_turretCount > 0)});
//Determine vehicle type and add needed eventhandlers
if (_isAirVehicle) then {
_vehicle setVariable ["durability",[0,0,0]]; //[structural, engine, tail rotor]
_vehicle addEventHandler ["Killed",{_this call DZAI_heliDestroyed;}]; //Begin despawn process when heli is destroyed.
_vehicle addEventHandler ["GetOut",{_this call DZAI_airLanding;}]; //Converts AI crew to ground AI units.
_vehicle addEventHandler ["HandleDamage",{_this call DZAI_hHandleDamage}];
} else {
_vehicle addEventHandler ["Killed",{_this call DZAI_vehDestroyed;}];
_vehicle addEventHandler ["HandleDamage",{_this call DZAI_vHandleDamage}];
};
_vehicle allowCrewInImmobile (!_isAirVehicle);
_vehicle setVehicleLock "LOCKED";
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
//Setup group and crew
0 = [_driver,_weapongrade] call DZAI_setSkills;
0 = [_driver,_weapongrade] call DZAI_setupLoadout;
_driver setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];
_driver setVariable ["unconscious",false];
_driver setVariable ["bodyName",(name _driver)];
if (!(_driver hasWeapon "NVGoggles")) then {
_nvg = _driver call DZAI_addTempNVG;
};
_driver addEventHandler [DZAI_healthType, DZAI_healthStatements];
_driver assignAsDriver _vehicle;
_driver setVariable ["isDriver",true];
_unitGroup selectLeader _driver;
if (_isAirVehicle) then {_vehicle flyInHeight 115};
_cargoSpots = _vehicle emptyPositions "cargo";
for "_i" from 0 to ((_cargoSpots min _maxCargoUnits) - 1) do {
_cargo = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_cargo] joinSilent _unitGroup;
0 = [_cargo,_weapongrade] call DZAI_setSkills;
0 = [_cargo,_weapongrade] call DZAI_setupLoadout;
_cargo setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];
_cargo setVariable ["unconscious",false];
_cargo setVariable ["bodyName",(name _cargo)];
if (!(_cargo hasWeapon "NVGoggles")) then {
_nvg = _cargo call DZAI_addTempNVG;
};
_cargo addEventHandler [DZAI_healthType, DZAI_healthStatements];
_cargo assignAsCargo _vehicle;
_cargo moveInCargo [_vehicle,_i];
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawned %1 cargo units for %2 vehicle %3.",(_cargoSpots min _maxCargoUnits),_unitGroup,_vehicleType]};
for "_i" from 0 to ((_turretCount min _maxGunnerUnits) - 1) do {
_gunner = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_gunner] joinSilent _unitGroup;
0 = [_gunner,_weapongrade] call DZAI_setSkills;
0 = [_gunner,_weapongrade] call DZAI_setupLoadout;
_gunner setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];
_gunner setVariable ["unconscious",false];
_gunner setVariable ["bodyName",(name _gunner)];
if (!(_gunner hasWeapon "NVGoggles")) then {
_nvg = _gunner call DZAI_addTempNVG;
};
_gunner addEventHandler [DZAI_healthType, DZAI_healthStatements];
_gunner assignAsGunner _vehicle;
_gunner moveInTurret [_vehicle,[_i]];
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawned %1 gunner units for %2 vehicle %3.",(_turretCount min _maxGunnerUnits),_unitGroup,_vehicleType]};
_unitGroup allowFleeing 0;
_unitGroup setBehaviour "AWARE";
_unitGroup setSpeedMode "NORMAL";
_unitGroup setCombatMode "YELLOW";
_unitType = if (_isAirVehicle) then {"aircustom"} else {"landcustom"};
_unitGroup setVariable ["unitType",_unitType];
_unitGroup setVariable ["weapongrade",_weapongrade];
_unitGroup setVariable ["assignedVehicle",_vehicle];
_unitGroup setVariable ["isArmed",_isArmed];
_unitGroup setVariable ["spawnParams",_this];
[_unitGroup,0] setWaypointPosition [_markerPos,0]; //Move group's initial waypoint position away from [0,0,0] (initial spawn position).
(units _unitGroup) allowGetIn true;
0 = [_unitGroup,_weapongrade] spawn DZAI_autoRearm_group;
0 = [_unitGroup,_markerPos,_markerSize,false] spawn DZAI_BIN_taskPatrol;
//if (daytime < 6 or {daytime > 20}) then {_vehicle action ["lightOn", _vehicle]};
if (_isAirVehicle) then {
_awareness = [_vehicle,_unitGroup] spawn DZAI_heliAwareness;
if (!_isArmed) then {
_index = (DZAI_airWeapons select 0) find _vehicleType;
if (_index > -1) then {
_vehWeapon = (DZAI_airWeapons select 1) select _index;
if ([_vehWeapon,"weapon"] call DZAI_checkClassname) then {
_vehicle addWeapon _vehWeapon;
_vehMag = getArray (configFile >> "CfgWeapons" >> _vehWeapon >> "magazines") select 0;
_vehicle addMagazine _vehMag;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Added weapon %1 and ammo %2 to AI %3 (Group: %1).",_vehWeapon,_vehMag,_vehicleType,_unitGroup]};
};
};
};
if ((!isNull _vehicle) && {!isNull _unitGroup}) then {
DZAI_curHeliPatrols = DZAI_curHeliPatrols + 1;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Custom AI helicopter crew group %1 is now active and patrolling.",_unitGroup];};
};
} else {
if ((!isNull _vehicle) && {!isNull _unitGroup}) then {
DZAI_curLandPatrols = DZAI_curLandPatrols + 1;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Custom AI land vehicle crew group %1 is now active and patrolling.",_unitGroup];};
};
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Created custom vehicle spawn at %1 with vehicle type %2 with %3 crew units.",_marker,_vehicleType,(count (units _unitGroup))]};
true