~(random 0.3)
requiredVersion "1.85"
_name = _this select 0
_method = _this select 1
_hasrifle = false
_unit = call format["%1",_name]
?_method == 0:_return = "checklocal";goto "guncheck"
#checklocal
_unit = call format["%1",_name]
?local _unit:goto "respawnloop"
~(1 + (random 3))
goto "checklocal"
#respawnloop
@!alive _unit
#checkmethod
?_method == 1:_return = "waitforlife";goto "guncheck"
#waitforlife
@alive call format["%1",_name]
_unit = call format["%1",_name]
_unit removemagazine (magazines _unit select 0)
_unit removeweapon (weapons _unit select 0)
"_unit addmagazine _x" foreach _mags
?_hasrifle:_guns = _guns - [_prigun];_guncount = count _guns
_c = 0
while "_c <= (_magcount - 1)" do {_unit addmagazine (_mags select _c); _c = _c + 1}
_c = 0
while "_c <= (_guncount - 1)" do {_unit addweapon (_guns select _c); _c = _c + 1}
?_hasrifle:_unit addweapon _prigun;_gun = _guns + [_prigun]
;//If unit has a rifle select it
?_hasrifle:goto "selectrifle"
;//No rifle - if unit has a pistol, select it
?_unit hasweapon ((weapons _unit - [secondaryweapon _unit,"Binocular","NVGoggles"]) select 0):_unit selectweapon ((weapons _unit - [secondaryweapon _unit,"Binocular","NVGoggles"]) select 0);goto "respawnloop"
;//No rifle or pistol, select secondary weapon
_unit selectweapon secondaryweapon _unit
goto "respawnloop"
#selectrifle
;// BUG WORKAROUND! - Added to compensate for selectweapon bug
;// Any gun with more than one muzzle (grenadelaunchers) cannot be selected with selectweapon!
;// Default Grenadelaunchers supported - Add your own types if you need to.
_unit selectweapon _prigun
?_prigun == "M16GrenadeLauncher":_unit selectweapon "M16Muzzle"
?_prigun == "Ak74GrenadeLauncher":_unit selectweapon "AK74Muzzle"
?_prigun == "Ak47GrenadeLauncher":_unit selectweapon "AK47Muzzle"
;//SAF bug fix additions
?_prigun == "M203":_unit selectweapon "sar21Muzzle"
goto "respawnloop"
#guncheck
_guns = weapons _unit
_mags = magazines _unit
~(random 0.5)
_guncount = count _guns
_magcount = count _mags
?_unit hasweapon (primaryweapon _unit):_hasrifle = true;_prigun = primaryweapon _unit;goto _return
_hasrifle = false
goto _return
I actually tried to add the codes below into "waitforlife" or "respawnloop":
_unit setUnitPos "UP"
_unit doMove getMarkerPos "aMarker"
the weird thing is I realised that these codes doesn't take effect at all
Please help
Thank you