;;
;;
;;
;; Designed to be called by the VehicleInit line and run in each client and server.
;; The purpose is to add an eventhandler and to initialize the values for missile defense system for a unit (chaff or flares).
;;
;;
;; Parameters:
;;
;;_unit = _this select 0;
;;_mindistecm = _this select 1; // Minimun Distance to Deploy CM in Control Mode == Automatic
;;_typeecm = _this select 2; // Chaff(0)for Radar || Flares(1) for IR
;;_NumOfCM = _this select 3; // Number of Counter-Measures
;;_ctrlmode = _this select 4; // Deployment Control Mode: Automatic or Manual
;;
;;Example Helo with a flare system (3 flare packets):
;;
;; AirVehicle setVehicleInit [AirVehicle, 200, 1, 3, true]exec"ArmAI_Scripts\CORE\mando_units\mando_Init_DefenseSystem.sqs"
;; processInitCommands
;;
;;Requires Global Variables Define in init_Common.SQF:
;;
;;EH_IncomingBISMissile = [_this] call compile preprocessFileLineNumbers "ArmAI_Scripts\CORE\mando_units\mando_incoming.sqf";
;;EH_IncomingMandoMissile = [_this] call compile preprocessFileLineNumbers "ArmAI_Scripts\CORE\mando_units\replace_missile.sqf";
;;EH_CM_DeploymentControls = compile preprocessFileLineNumbers "ArmAI_Scripts\CORE\mando_units\VM_DeploymentControls.sqf";
;;Enable_Mando_Missiles = 0;
;;
private ["_unit", "_mindistecm", "_typeecm", "_NumOfCM","_ctrlmode", "_misecm", "_eh0","_eh1","_eh2"];
_unit = _this select 0;
_mindistecm = _this select 1;
_typeecm = _this select 2;
_MaxCM = _this select 3;
_ctrlmode = _this select 4;
;;// The following EVENT HANDLER needs to be active if you expect your CM to be effective against standard ArmA Missiles
;;// such as Stingers, Strellas, Sidewinders, or any other non-mando Air to Air Missile designed to trigger the IncomingMissile Event
;;// _eh = _unit addEventHandler ["IncomingMissile",{_this execVM "ArmAI_Scripts\CORE\mando_units\mando_incoming.sqf"}];
;;// The following EVENT HANDLER needs to be active if you plan to replace Air to Air Missiles
;;// such as Stingers, Strellas, Sidewinders with a Mando Missile to take full advantage of adjusting all aspects of your AA missiles
;;// _eh = _unit addEventHandler ["IncomingMissile",{_this execVM "ArmAI_Scripts\CORE\mando_units\replace_missile.sqf"}];
_eh1 = _unit addEventHandler ["IncomingMissile",{[_this] spawn EH_IncomingMandoMissile}];
;;//switch (Enable_Mando_Missiles) do
;;//{
;;//case 0: {_eh0 = _unit addEventHandler ["IncomingMissile",{[_this] spawn EH_IncomingBISMissile}];};
;;//case 1: {_eh1 = _unit addEventHandler ["IncomingMissile",{[_this] spawn EH_IncomingMandoMissile}];};
;;//case 1: {_eh1 = _unit addEventHandler ["IncomingMissile",{_this ExecVM "ArmAI_Scripts\CORE\mando_units\replace_missile.sqf"}];};
;;// };
;;// The following EVENT HANDLER needs to be activated upon the Pilot Getting Into the Vehicle to activate the CounterMeasures deployment controls
_eh2 = _unit addEventHandler ["GetIn",{[this,200,1,3,1, True] spawn EH_CM_DeploymentControls}];
;;// The following EVENT HANDLER needs to be activated upon the Pilot Getting OUT of the Vehicle
;;// _eh3 = _unit addEventHandler ["GetOut",{_unit removeEventHandler ["IncomingMissile", _eh];}]; -- PROBABLY NOT NEEDED - VM
_curNumOfCM = _MaxCM;
?(ARMA_DEBUG_lvl>0 && local server): [2,format ["mando_Init_DefenseSystem.sqs->CM Systems Initiated: _vehicle= %1 _MaxCM= %2",_unit,_MaxCM],"server"] call six_fTxRadio;
~0.5
?(ARMA_DEBUG_lvl>0 && local server): [2,format ["mando_Init_DefenseSystem.sqs->CM Systems Successfully Installed on Server: _vehicle= %1",_unit],"server"] call six_fTxRadio;
~0.5
;;// Initialize the new air vehicle with its full compilement of Counter-Measures
_curNumOfCM = _MaxCM;
?(ARMA_DEBUG_lvl>0 && local server): [2,format ["mando_Init_DefenseSystem.sqs->LocalVariables : _unit=%1 _curNumOfCM=%2 _MaxCM= %3",_unit,_curNumOfCM,_MaxCM],"server"] call six_fTxRadio;
~0.5
;;// Client-Side Initialization complete. We only want the server to keep the master vehicle variables. Run the following only on the server.
?!local server: goto "check"
;_unit setVariable ["mando_missileincomming", objNull]
mando_vehvar_vehiclew = _unit
mando_vehvar_w = "mando_missileincomming"
mando_vehvar_valuew = objNull
mando_vehvar_requestw = true
{publicVariable _x} forEach ["mando_vehvar_vehiclew", "mando_vehvar_w", "mando_vehvar_valuew", "mando_vehvar_requestw"]
~0.5
;_unit setVariable ["mando_MaxCM", _curNumOfCM]
mando_vehvar_vehiclew = _unit
mando_vehvar_w = "mando_MaxCM"
mando_vehvar_valuew = _curNumOfCM;
mando_vehvar_requestw = true
{publicVariable _x} forEach ["mando_vehvar_vehiclew", "mando_vehvar_w", "mando_vehvar_valuew", "mando_vehvar_requestw"]
~0.5
;_unit setVariable ["mando_CM_Left", _MaxCM]
mando_vehvar_vehiclew = _unit
mando_vehvar_w = "mando_CM_Left"
mando_vehvar_valuew = _MaxCM;
mando_vehvar_requestw = true
{publicVariable _x} forEach ["mando_vehvar_vehiclew", "mando_vehvar_w", "mando_vehvar_valuew", "mando_vehvar_requestw"]
~0.5
?(ARMA_DEBUG_lvl>0 && local server): [2,format ["mando_Init_DefenseSystem.sqs->Init Setting: _unit=%1 mando_CM_Left= %2 mando_MaxCM= %3",_unit,_unit getVariable "mando_CM_Left",_unit getVariable "mando_MaxCM"],"server"] call six_fTxRadio;
~0.5
#check
exit