Try to fill the chamber.
896 {
897
898 int muzzCount = GetMuzzleCount();
899 bool anyEmpty = false;
900
901 for (int m = 0; m < muzzCount; ++m)
902 {
903 if (IsChamberEmpty(m))
904 {
905 anyEmpty = true;
906 break;
907 }
908 }
909
910 if (!anyEmpty)
911 return false;
912
913
914 if (ammoType != "")
915 if (!AmmoTypesAPI.MagazineTypeToAmmoType(ammoType, ammoType))
916 return false;
917
918
919 bool didSomething = false;
920 bool chamberFullRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG_SPORADIC);
921 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
922 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER);
923
924 if (chamber || chamberRng || chamberFullRng)
925 {
926 int amountToChamber = muzzCount;
927
928
929 if (chamberRng)
930 amountToChamber = Math.RandomIntInclusive(0, muzzCount);
931
932 bool chamberAmmoRng = (ammoType == "");
933 bool chamberAmmoFullRng = chamberAmmoRng && (flags & WeaponWithAmmoFlags.AMMO_CHAMBER_RNG);
934
935
936 if (chamberAmmoRng && !chamberAmmoFullRng)
937 ammoType = GetRandomChamberableAmmoTypeName(0);
938
939 for (int i = 0; i < muzzCount; ++i)
940 {
941
942 if (!IsChamberEmpty(i))
943 continue;
944
945
946 if (chamberFullRng)
947 chamber = Math.RandomIntInclusive(0, 1);
948
949
950 if (chamber)
951 {
952
953 if ( chamberAmmoFullRng )
954 ammoType = GetRandomChamberableAmmoTypeName(i);
955
956
957 PushCartridgeToChamber(i, 0, ammoType);
958 didSomething = true;
959
960
961 --amountToChamber;
962 if (amountToChamber <= 0)
963 break;
964 }
965 }
966 }
967
968
969 if (!didSomething)
970 return false;
971
972
975
976 return true;
977 }
void RandomizeFSMState()
With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon...