


spawnVehicle_custom.sqf:

	_vehicle setVariable ["unitGroup",_unitGroup];

	_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];		<--------------------- here are all the vehicle spawn parameters!


	_vehicle addEventHandler ["Killed",{_this call DZAI_heliDestroyed;}];

	-or-

	_vehicle addEventHandler ["Killed",{_this call DZAI_vehDestroyed;}];

		"killed" EH will return an array "_this" with 2 elements: the killed unit, and the killer


	local _this parameter list:
		_this select 0 is the marker
		_this select 1 is either type name or list of type names ....!
		_maxUnits = _this select 2;
		_weapongrade = _this select 3;





veh_destroyed.sqf:

	_vehicle = _this select 0;
	_unitGroup = _vehicle getVariable "unitGroup";

	[_unitGroup,_vehicle] call DZAI_respawnAIVehicle;

	

heli_destroyed.sqf

	_helicopter = _this select 0;
	_unitGroup = _helicopter getVariable "unitGroup";

	[_unitGroup,_helicopter] call DZAI_respawnAIVehicle;




DZAI_respawnAIVehicle:

	_vehicle = _this select 1;
	if (((_this select 0) getVariable ["unitType",""]) in ["aircustom","landcustom"]) then {		// yes, it will be!
		private ["_spawnParams"];
		_spawnParams = (_this select 0) getVariable ["spawnParams",false];
		if (_spawnParams select 4) then {
			[1,_spawnParams] call fnc_respawnHandler;
		};
	} else {
		[2,typeOf _vehicle] call fnc_respawnHandler;
	};
	 


respawnHandler1.sqf:

	_spawnParams = _this select 1;		//parameters used to call DZAI_spawn_vehicle
	DZAI_respawnQueue set [(count DZAI_respawnQueue),[diag_tickTime + _respawnSleep,_mode,_spawnParams]];	<-- the same spawn params!
	
	DZAI_respawnHandlerHandle = [] spawn fnc_respawnHandler2;


respawnHandler2.sqf:

	_respawnParams = (DZAI_respawnQueue select _i) select 2;		<-- there they are again!
	_nul = _respawnParams spawn DZAI_spawnVehicle_custom;			--> and back to the top!

