; exit script 06 Field Excersise


; Saving player's status
aa = aP saveStatus "06Player";
; Player will be saved


; -------- Vehicles ---------

_veh = [T80, T72a, T72b, T72c, BMP, RT1, RT2, RT3, RT4, Tp1, Tp2, Tv1, Tv2];
_j = 0;
_i = count _veh;

#LOOPVehicles
? _j >= _i : goto "ENDVehicles"

_who = _veh select _j;
_do = false
? (alive _who) and  ((side (driver _who) == resistance) or ((driver _who != driver _who))) : _do = true;

? not (_do) : goto "LOOPVehIn"

? _who == T80 : GLB_06_T80 = true; saveVar "GLB_06_T80"; goto "LOOPVehIn"
? _who == T72a : GLB_06_T72a = true; saveVar "GLB_06_T72a"; goto "LOOPVehIn"
? _who == T72b : GLB_06_T72b = true; saveVar "GLB_06_T72b"; goto "LOOPVehIn"
? _who == T72c : GLB_06_T72c = true; saveVar "GLB_06_T72c"; goto "LOOPVehIn"
? _who == BMP : GLB_06_BMP = true; saveVar "GLB_06_BMP"; goto "LOOPVehIn"
? _who == RT1 : GLB_06_RT1 = true; saveVar "GLB_06_RT1"; goto "LOOPVehIn"
? _who == RT2 : GLB_06_RT2 = true; saveVar "GLB_06_RT2"; goto "LOOPVehIn"
? _who == RT3 : GLB_06_RT3 = true; saveVar "GLB_06_RT3"; goto "LOOPVehIn"
? _who == RT4 : GLB_06_RT4 = true; saveVar "GLB_06_RT4"; goto "LOOPVehIn"
? _who == Tp1 : GLB_06_Tp1 = true; saveVar "GLB_06_Tp1"; goto "LOOPVehIn"
? _who == Tp2 : GLB_06_Tp2 = true; saveVar "GLB_06_Tp2"; goto "LOOPVehIn"
? _who == Tv1 : GLB_06_Tv1 = true; saveVar "GLB_06_Tv1"; goto "LOOPVehIn"
? _who == Tv2 : GLB_06_Tv2 = true; saveVar "GLB_06_Tv2"; goto "LOOPVehIn"

#LOOPVehIn
_j = _j + 1;
goto "LOOPVehicles"

#ENDVehicles


GLB_06_HOWMANY = 8 - (count units group aP);
? GLB_06_HOWMANY < 0 : GLB_06_HOWMANY = 0;
saveVar "GLB_06_HOWMANY";

; Special soldiers
? alive aMed : GLB_06_MED = true; saveVar "GLB_06_MED"; xx = aMed saveStatus "06Medic";
? alive aMed2 : GLB_06_MED2 = true; saveVar "GLB_06_MED2"; xx = aMed2 saveStatus "06Medic2";

; ------- Player's group ---------

_i = count units group aP;
_j = 0;
_k = 0;
_Mis = "06";
_Out = [aMed, aMed2, aP];

#LOOP
? _j >= _i : goto "Next"

? ((units group aP) select _j) in _Out : goto "SKIP"
? alive ((units group aP) select _j) : xx = ((units group aP) select _j) saveStatus _Mis + (format ["Sold%1", _k]); _k = _k+1;

#SKIP
_j = _j + 1;
goto "LOOP"

#Next
GLB_06_NUMBER = _k; saveVar "GLB_06_NUMBER";


; ================== BEGIN: WEAPON POOL ====================

#POOL

; Added by mission designer

addWeaponPool ["RPGLauncher",2];
addWeaponPool ["Bizon",1];
addWeaponPool ["AK74",10];
addWeaponPool ["Tokarev",2];
addWeaponPool ["CZ75",1];

addMagazinePool ["RPGLauncher",6];
addMagazinePool ["BizonMag",10];
addMagazinePool ["AK74",50];
addMagazinePool ["TokarevMag",20];
addMagazinePool ["CZ75Mag",10];


; Alway adding basic weapons
? (queryWeaponPool "AK47CZ") < 10 : addWeaponPool ["AK47CZ", 10]
? (queryMagazinePool "AK47") < 100 : addMagazinePool ["AK47", 30]


; Weapon holders stolen?


_vehs = [RU1, RU2, RU3];
; These vehicles will add their weapons to pool if they are close enough

_a = 0;
_b = count units group aP;

; Add all group vehicles to _vehs
#LOOPGroupVeh

? _b >= _a : goto "ENDGroupVeh"

_who = (units group aP) select _a;
? (vehicle _who != _who) and not ((vehicle _who) in _vehs) : _vehs = _vehs + [vehicle _who];

_a = _a + 1;
goto "LOOPGroupVeh";

#ENDGroupVeh

_a = 0;
_b = count _vehs;

#LOOPHolders
? _a >= _b : goto "ENDHolders"

_work = false;
_u = _vehs select _a
? side (driver _u) == resistance : _work = true;
? alive _u and (driver _u != driver _u) : _work = true;

? _work : pickWeaponPool (vehicle _u); clearWeaponCargo (vehicle _u); clearMagazineCargo (vehicle _u);

_a = _a + 1;
goto "LOOPHolders"

#ENDHolders


; ================== END: WEAPON POOL ====================






; ------------- END -------------
