private ["_rndnum","_crate_type","_mission","_position","_crate","_baserunover","_baserunover0","_baserunover1","_baserunover2","_baserunover3","_baserunover4","_baserunover5","_baserunover6","_baserunover7","_baserunover8","_baserunover9","_baserunover10","_baserunover11","_baserunover12","_baserunover13","_baserunover14","_baserunover15","_baserunover16","_baserunover17","_baserunover18","_baserunover19","_baserunover20","_baserunover21","_baserunover22","_baserunover23","_baserunover24","_baserunover25","_baserunover26","_baserunover27","_baserunover28","_baserunover29","_baserunover30"];

// Get mission number, important we do this early
_mission = count wai_mission_data -1;
_missionType = _this select 0; // Type of mission: "MainHero" or "MainBandit"
_aiType = _this select 1; // Type of AI - opposite of mission type
_position = [30] call find_position;

diag_log format["WAI: [Mission:[Hero] Gold Mine]: Starting... %1",_position];

//Setup the crate
_crate_type = crates_small call BIS_fnc_selectRandom;
_crate = createVehicle [_crate_type,[(_position select 0) + 0.2,(_position select 1),0], [], 0, "CAN_COLLIDE"];
_crate call wai_crate_setup;
//Buildings 
_baserunover0 = createVehicle ["MAP_R2_RockWall",[(_position select 0) -24, (_position select 1) +11,-7.1],[], 0, "CAN_COLLIDE"];
_baserunover1 = createVehicle ["MAP_R2_RockWall",[(_position select 0) +6, (_position select 1) +16, -5.9],[], 0, "CAN_COLLIDE"];
_baserunover2 = createVehicle ["MAP_R2_RockWall",[(_position select 0) + 30, (_position select 1) + 3, -7.1],[], 0, "CAN_COLLIDE"];
_baserunover3 = createVehicle ["MAP_R2_RockWall", [(_position select 0) +45, (_position select 1) -18, -7.1],[], 0, "CAN_COLLIDE"];
_baserunover4 = createVehicle ["MAP_R2_RockWall", [(_position select 0) - 29, (_position select 1) -12, -7.1],[], 0, "CAN_COLLIDE"];
_baserunover5 = createVehicle ["MAP_R2_RockWall", [(_position select 0) - 0.1, (_position select 1) +15, +16.85],[], 0, "CAN_COLLIDE"];
_baserunover6 = createVehicle ["MAP_R2_RockWall",[(_position select 0) + 19, (_position select 1) -9, +17.6],[], 0, "CAN_COLLIDE"];
_baserunover7 = createVehicle ["MAP_R2_RockWall",[(_position select 0) -11, (_position select 1) -3, +14.8],[], 0, "CAN_COLLIDE"];
_baserunover8 = createVehicle ["MAP_R2_RockWall",[(_position select 0) -3, (_position select 1) -9, +20.37],[], 0, "CAN_COLLIDE"];
_baserunover9 = createVehicle ["MAP_R2_RockWall", [(_position select 0) -29, (_position select 1) -27, -7.1],[], 0, "CAN_COLLIDE"];
_baserunover10 = createVehicle ["MAP_R2_RockWall", [(_position select 0) -20, (_position select 1) -36, -7.1],[], 0, "CAN_COLLIDE"];
_baserunover11 = createVehicle ["MAP_R2_RockWall", [(_position select 0) - 2, (_position select 1) - 25, +16.2],[], 0, "CAN_COLLIDE"];
_baserunover12 = createVehicle ["MAP_R2_RockWall",[(_position select 0) + 11, (_position select 1) - 30, +16.2],[], 0, "CAN_COLLIDE"];
_baserunover13 = createVehicle ["MAP_R2_RockTower",[(_position select 0) +7, (_position select 1) - 24, -20.4],[], 0, "CAN_COLLIDE"];
_baserunover14 = createVehicle ["MAP_R2_Boulder2",[(_position select 0) +14, (_position select 1) - 27, -0.015],[], 0, "CAN_COLLIDE"];
_baserunover15 = createVehicle ["MAP_R2_Boulder1",[(_position select 0) +18, (_position select 1) - 37, -0.015],[], 0, "CAN_COLLIDE"];
_baserunover16 = createVehicle ["MAP_R2_Rock1",[(_position select 0) - 2, (_position select 1) - 7, -25.05],[], 0, "CAN_COLLIDE"];
_baserunover17 = createVehicle ["MAP_Ind_HammerMill", [(_position select 0) +30, (_position select 1) - 53,-6.1],[], 0, "CAN_COLLIDE"];
_baserunover18 = createVehicle ["UralWreck", [(_position select 0) +34, (_position select 1) -59,-0.01],[], 0, "CAN_COLLIDE"];
_baserunover19 = createVehicle ["MAP_Ind_Conveyer", [(_position select 0) + 22, (_position select 1) -45, 0.1],[], 0, "CAN_COLLIDE"];
_baserunover20 = createVehicle ["Land_Dirthump01",[(_position select 0) +13, (_position select 1) - 38,-1.41],[], 0, "CAN_COLLIDE"];
_baserunover21 = createVehicle ["Land_Dirthump01",[(_position select 0) +13, (_position select 1) - 39,-1.45],[], 0, "CAN_COLLIDE"];
_baserunover22 = createVehicle ["MAP_R2_RockTower",[(_position select 0) + 60, (_position select 1) -55,-26.69],[], 0, "CAN_COLLIDE"];
_baserunover23 = createVehicle ["MAP_R2_RockTower", [(_position select 0) + 12, (_position select 1) -121,-0.02],[], 0, "CAN_COLLIDE"];
_baserunover24 = createVehicle ["Gold_Vein_DZE", [(_position select 0) +13, (_position select 1) -14,-0.01],[], 0, "CAN_COLLIDE"];
_baserunover25 = createVehicle ["Gold_Vein_DZE", [(_position select 0) - 6, (_position select 1) - 25,-0.01],[], 0, "CAN_COLLIDE"];
_baserunover26 = createVehicle ["Gold_Vein_DZE",[(_position select 0) - 8, (_position select 1) -17,-0.01],[], 0, "CAN_COLLIDE"];
_baserunover27 = createVehicle ["fiberplant",[(_position select 0) +7, (_position select 1) -1,-0.02],[], 0, "CAN_COLLIDE"];
_baserunover28 = createVehicle ["fiberplant",[(_position select 0) +5, (_position select 1) -6,-0.02],[], 0, "CAN_COLLIDE"];
_baserunover29 = createVehicle ["fiberplant",[(_position select 0) - 13, (_position select 1) -21,-0.02],[], 0, "CAN_COLLIDE"];
_baserunover30 = createVehicle ["fiberplant", [(_position select 0) + 19, (_position select 1) -21,-0.02],[], 0, "CAN_COLLIDE"];

_baserunover = [_baserunover0,_baserunover1,_baserunover2,_baserunover3,_baserunover4,_baserunover5,_baserunover6,_baserunover7,_baserunover8,_baserunover9,_baserunover10,_baserunover11,_baserunover12,_baserunover13,_baserunover14,_baserunover15,_baserunover16,_baserunover17,_baserunover18,_baserunover19,_baserunover20,_baserunover21,_baserunover22,_baserunover23,_baserunover24,_baserunover25,_baserunover26,_baserunover27,_baserunover28,_baserunover29,_baserunover30];

_directions = [-85.388,-151.6,40.18,131.1,-258.57,0,-128.72,165.8,0,66.4,23.5,-13.9,-28.07,0,0,0,-4.74,-69.97,14.54,116.29,92.4,42.23,0,98.4,0,0,0,0,0,0,0];
{ _x setDir (_directions select _forEachIndex) } forEach _baserunover;

{ _x setVectorUp surfaceNormal position  _x; } count _baserunover;

//Troops
_rndnum = round (random 5);
[[(_position select 0) +20, (_position select 1) - 54, 0],5,"Medium",["Random","AT"],4,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;
[[(_position select 0) - 15, (_position select 1) - 70, 0],5,"Medium","Random",4,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;
[[(_position select 0) + 60, (_position select 1) - 38, 0],4,"Medium","Random",4,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;
[[(_position select 0) + 33, (_position select 1) + 20, 0],_rndnum,"Medium","Random",4,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;

//Static Guns
[[
	[(_position select 0) + 44, (_position select 1) - 55, 0],
	[(_position select 0) + 4, (_position select 1) - 70, 0]
],"M2StaticMG","Hard",_aiType,_aiType,1,2,"Random","Random",_mission] call spawn_static;

// Array of mission variables to send
[
	_mission, // Mission number
	_position, // Position of mission
	"Medium", // Difficulty
	"Gold Mine", // Name of Mission
	_missionType, // Mission Type: MainHero or MainBandit
	true, // show mission marker?
	true, // make minefields available for this mission
	_crate, // crate object info
	["crate"], // Completion type: ["crate"], ["kill"], or ["assassinate", _unitGroup],
	[_baserunover], // cleanup objects
	"STR_CL_HERO_GOLDMINE_ANNOUNCE", // mission announcement
	"STR_CL_HERO_GOLDMINE_WIN", // mission success
	"STR_CL_HERO_GOLDMINE_FAIL", // mission fail
	[10,5,20,3,2] // Dynamic crate array
] call mission_winorfail;