Try to fill the inner magazine.
828 {
829
830 if (!HasInternalMagazine(-1))
831 return false;
832
833
834 if (ammoType != "")
835 {
836 if (!AmmoTypesAPI.MagazineTypeToAmmoType(ammoType, ammoType))
837 return false;
838 }
839
840
841 bool didSomething = false;
842 int muzzCount = GetMuzzleCount();
843
844 bool ammoRng = ammoType == "";
845 bool ammoFullRng = ammoRng && (flags & WeaponWithAmmoFlags.AMMO_MAG_RNG);
846
847
848 if (ammoRng && !ammoFullRng)
849 ammoType = GetRandomChamberableAmmoTypeName(0);
850
851
852 for (int i = 0; i < muzzCount; ++i)
853 {
854 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
855
856
857 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
858 ammoCount = Math.RandomIntInclusive(0, ammoCount);
859
860
861 if (ammoCount > 0)
862 {
863
864 for (int j = 0; j < ammoCount; ++j)
865 {
866
867 if ( ammoFullRng )
868 ammoType = GetRandomChamberableAmmoTypeName(i);
869
870 PushCartridgeToInternalMagazine(i, 0, ammoType);
871 didSomething = true;
872 }
873 }
874 }
875
876
877 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
879 {
880 didSomething = true;
881 }
882
883
884
885 return didSomething;
886 }
bool FillChamber(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the chamber.