/*
Bandit Supply Heli Crash by lazyink (Full credit for original code to TheSzerdi & TAW_Tonic)
New Mission Format by Vampire
*/
private ["_missName","_coords","_chopper","_truck","_trash","_trash2","_crate","_crate2","_aiGrp","_pilot","_gunner1","_gunner2"];
//Name of the Mission
_missName = "Helicopter Landing";
//DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result
_coords = call DZMSFindPos;
//We create the vehicles like normal
_chopper = createVehicle ["UH1H_TK_EP1",_coords,[], 0, "NONE"];
//DZMSSetupVehicle prevents the vehicle from disappearing and sets fuel and such
[_chopper] call DZMSSetupVehicle;
_chopper setDir -36.279881;
//Lets make AI for the chopper and get them in it
_aiGrp = creategroup east;
_pilot = _aiGrp createUnit ["SurvivorW2_DZ",getPos _chopper,[],0,"FORM"];
_gunner1 = _aiGrp createUnit ["SurvivorW2_DZ",getPos _chopper,[],0,"FORM"];
_gunner2 = _aiGrp createUnit ["SurvivorW2_DZ",getPos _chopper,[],0,"FORM"];
_pilot moveindriver _chopper;
_pilot assignAsDriver _chopper;
_gunner1 assignAsGunner _chopper;
[_gunner1] orderGetIn true;
_gunner2 assignAsGunner _chopper;
[_gunner2] orderGetIn true;
/*
_rndCount = 3;
for "_x" from 1 to _rndCount do {
_bodyname = format ["TavianaGuard%1",_x];
if(_x == 1) then {
_soldermodel = _modelarray select 0;
_soldermodel createunit [[(_startpos select 0),(_startpos select 1),0], _AISgroup, "_spawnTaviGroupLeader = this; _TavianaSquad = group this;"];
_spawnTaviGroupLeader enableAI "TARGET";
_spawnTaviGroupLeader enableAI "AUTOTARGET";
_spawnTaviGroupLeader enableAI "MOVE";
_spawnTaviGroupLeader enableAI "ANIM";
_spawnTaviGroupLeader enableAI "FSM";
_spawnTaviGroupLeader allowdamage true;
_spawnTaviGroupLeader setCombatMode "YELLOW";
_spawnTaviGroupLeader setBehaviour "STEALTH";
_spawnTaviGroupLeader setFormation "ECH LEFT";
_spawnTaviGroupLeader setSkill ["aimingAccuracy",1];
_spawnTaviGroupLeader setSkill ["aimingShake",1];
_spawnTaviGroupLeader setSkill ["aimingSpeed",1];
_spawnTaviGroupLeader setSkill ["commanding",1];
_spawnTaviGroupLeader setSkill ["endurance",1];
_spawnTaviGroupLeader setSkill ["spotDistance",1];
_spawnTaviGroupLeader setSkill ["spotTime",1];
_spawnTaviGroupLeader setSkill ["courage",1];
_spawnTaviGroupLeader setSkill ["reloadSpeed",1];
_spawnTaviGroupLeader setSkill ["general",1];
_spawnTaviGroupLeader setdamage 0.01;
_spawnTaviGroupLeader moveInTurret [_chopper, [0]];
_soldier1 assignAsGunner _chopper
[_soldier1] orderGetIn true
}
*/
_truck = createVehicle ["HMMWV_DZ",[(_coords select 0) - 8.7802,(_coords select 1) + 6.874,0],[], 0, "CAN_COLLIDE"];
[_truck] call DZMSSetupVehicle;
//Lets add the scenery
_trash = createVehicle ["Body1",[(_coords select 0) - 3.0185,(_coords select 1) - 0.084,0],[], 0, "CAN_COLLIDE"];
_trash2 = createVehicle ["Body2",[(_coords select 0) + 1.9248,(_coords select 1) + 2.1201,0],[], 0, "CAN_COLLIDE"];
[_trash] call DZMSProtectObj;
[_trash2] call DZMSProtectObj;
//DZMSBoxFill fills the box, DZMSProtectObj prevents it from disappearing
_crate = createVehicle ["USLaunchersBox",[(_coords select 0) - 6.1718,(_coords select 1) + 0.6426,0],[], 0, "CAN_COLLIDE"];
[_crate,"weapons"] ExecVM DZMSBoxSetup;
[_crate] call DZMSProtectObj;
_crate2 = createVehicle ["USLaunchersBox",[(_coords select 0) - 7.1718,(_coords select 1) + 1.6426,0],[], 0, "CAN_COLLIDE"];
[_crate2,"supply"] ExecVM DZMSBoxSetup;
[_crate2] call DZMSProtectObj;
//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray]
[[(_coords select 0) - 8.4614,(_coords select 1) - 5.0527,0],6,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[[(_coords select 0) - 8.4614,(_coords select 1) - 5.0527,0],4,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[[(_coords select 0) + 7.5337,(_coords select 1) + 4.2656,0],4,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[[(_coords select 0) + 7.5337,(_coords select 1) + 4.2656,0],4,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
//DZMSAddMajMarker is a simple script that adds a marker to the location
[_coords,_missname] ExecVM DZMSAddMajMarker;
[nil,nil,rTitleText,"A Supply Helicopter has been Forced to Land!\nStop the Bandits from Taking Control of it!", "PLAIN",10] call RE;
//Wait until the player is within 30 meters and also meets the kill req
[_coords,"DZMSUnitsMajor"] call DZMSWaitMissionComp;
//Call DZMSSaveVeh to attempt to save the vehicles to the database
//If saving is off, the script will exit.
[_chopper] ExecVM DZMSSaveVeh;
[_truck] ExecVM DZMSSaveVeh;
//Let everyone know the mission is over
[nil,nil,rTitleText,"The Helicopter has been Taken by Survivors!", "PLAIN",6] call RE;
diag_log text format["[DZMS]: Major SM4 Helicopter Landing Mission has Ended."];
deleteMarker "DZMSMajMarker";
deleteMarker "DZMSMajDot";
//Let the timer know the mission is over
DZMSMajDone = true;