private ["_crate_type","_mission","_position","_crate","_rndnum","_baserunover","_baserunover0","_baserunover1","_baserunover2","_baserunover3","_baserunover4","_baserunover5","_baserunover6","_baserunover7","_baserunover8","_baserunover9","_baserunover10"];

// 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 = [80] call find_position;

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

//Setup the crate
_crate_type = crates_large call BIS_fnc_selectrandom; // Choose between crates_large, crates_medium and crates_small
_crate = createVehicle [_crate_type,[(_position select 0) - 0.01, (_position select 1) - 0.01,-0.15],[],0,"CAN_COLLIDE"];
_crate call wai_crate_setup;

//Buildings 
_baserunover0 = createVehicle ["MAP_Astan",[(_position select 0) - 3, (_position select 1) -5.4,-0.15],[], 0, "CAN_COLLIDE"];
_baserunover1 = createVehicle ["MAP_A_tent",[(_position select 0) + 3.8, (_position select 1) -1,-0.15],[], 0, "CAN_COLLIDE"];
_baserunover2 = createVehicle ["Land_Campfire_burning",[(_position select 0) - 2, (_position select 1) -1,-0.15],[], 0, "CAN_COLLIDE"];
_baserunover3 = createVehicle ["Fuel_can",[(_position select 0) +0.1, (_position select 1) +3,-0.15],[], 0, "CAN_COLLIDE"];
_baserunover4 = createVehicle ["Land_Blankets_EP1",[(_position select 0) - 4, (_position select 1) +0.4,-0.15],[], 0, "CAN_COLLIDE"];
_baserunover5 = createVehicle ["Park_bench1",[(_position select 0) - 1, (_position select 1) +4,-0.15],[], 0, "CAN_COLLIDE"];

_baserunover6 = createVehicle ["MAP_Astan",[(_position select 0) - 4, (_position select 1) +10,-0.015],[], 0, "CAN_COLLIDE"];
_baserunover7 = createVehicle ["Land_Bag_EP1",[(_position select 0) +1, (_position select 1) +7,-0.015],[], 0, "CAN_COLLIDE"];
_baserunover8 = createVehicle ["Land_A_tent",[(_position select 0) - 10, (_position select 1) -6,-0.015],[], 0, "CAN_COLLIDE"];
_baserunover9 = createVehicle ["LADAWreck",[(_position select 0) - 11, (_position select 1) +2,-0.015],[], 0, "CAN_COLLIDE"];
_baserunover10 = createVehicle ["Land_transport_cart_EP1",[(_position select 0) - 9, (_position select 1) +7,-0.015],[], 0, "CAN_COLLIDE"];


// Adding buildings to one variable just for tidiness
_baserunover = [_baserunover0,_baserunover1,_baserunover2,_baserunover3,_baserunover4,_baserunover5,_baserunover6,_baserunover7,_baserunover8,_baserunover9,_baserunover10];

// Set some directions for our buildings
_directions = [0,64,0,0,0,0,128,0,-166.5,16.4,23];
{ _x setDir (_directions select _forEachIndex) } forEach _baserunover;

// Make buildings flat on terrain surface
{ _x setVectorUp surfaceNormal position _x; } count _baserunover;

//Troops
_rndnum = round (random 5);
[[(_position select 0) - 13, (_position select 1) - 7,0],5,"Easy",["Random","AT"],3,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;
[[(_position select 0) + 7, (_position select 1) + 15,0],5,"Easy","Random",3,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;
[[(_position select 0) + 4, (_position select 1)- 14,0],_rndnum,"Easy","Random",3,"Random",_aiType,"Random",_aiType,_mission] call spawn_group;


// Array of mission variables to send
[
	_mission, // Mission number
	_position, // Position of mission
	"Medium", // Difficulty
	"Refugee Camp", // 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],
	[], // cleanup objects
	"STR_CL_HERO_REFUGEE_ANNOUNCE", // mission announcement
	"STR_CL_HERO_REFUGEE_WIN", // mission success
	"STR_CL_HERO_REFUGEE_FAIL", // mission fail
	[10,4,0,3,2] // Dynamic crate array
] call mission_winorfail;