// allows medics to build a mash
if (player in list AirportIn) exitWith {hint localize "STR_M04t76"};

//EGG_EVO_CHITEMS = ["ToolKit","Medikit"];
if !((EGG_EVO_CHITEMS select 1) in (items player)) exitWith {hint "You need a MEDIKIT to build a MASH"};

mtent = mymash;
//deletevehicle mtent;

if (!isNil "mbox") then { deletevehicle mbox; };

player playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 3.0;
WaitUntil {animationState player != "AinvPknlMstpSlayWrflDnon_medic"};

_mark = format["%1mash",(name player)];
deleteMarker _mark;

//mtent = (EGG_EVO_MASH select 0) createVehicle (position player);Sleep EGG_EVO_GlobalSleep;

_posm = [(getposATL player select 0) + (sin(getdir player) * 3), (getposATL player select 1) + (cos(getdir player) * 3)];
mtent setpos _posm;

Sleep EGG_EVO_GlobalSleep;

_pos = position mtent;
_mssg = format["%1's MASH",(name player)];
_medmark = createMarker [_mark, _pos];
_medmark setMarkerShape "ICON";
_medmark setMarkerType "b_med";
_medmark setMarkerColor "ColorBlack";
_medmark setMarkerText _mssg;
_medmark setMarkerSize [0.5, 0.5];

_pos2 = [(getpos mtent select 0)+3,(getpos mtent select 1),0];

//temp - is this crashing the script?
mbox = (EGG_EVO_MASH select 1) createVehicle _pos2;
clearWeaponCargoGlobal mbox;
clearmagazineCargoGlobal mbox;
clearItemCargoGlobal mbox;
mbox addItemCargoGlobal ["FirstAidKit", 6];

mtent addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\resurrect.sqf"}];
mbox addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];

