REPROCODE = {
_unit = _this;
_mineT = "APERSBoundingMine_Range_Mag";
_unit addmagazine _mineT;
_timeee = 0;
while {!(_mineT in (magazines _unit)) && {count (magazines _unit) > 0} && {_timeee < 5}} do {_timeee = _timeee + 1;_unit removeMagazine ((magazines _unit) call BIS_fnc_selectRandom); _unit addmagazine _mineT;};
sleep 1;
_muzz = "BoundingMineRangeMuzzle";
_unit forceWeaponFire [_muzz, _muzz];
};
Place the code init.sqf and use for AI unit with unitname SPAWN REPROCODE;