Try to spawn and attach a magazine.
772 {
773
774 if ( GetMagazineTypeCount(0) == 0 )
775 {
776 ErrorEx(
string.Format(
"No 'magazines' config entry for %1.",
this));
777 return null;
778 }
779
780
781 if ( magazineType == "" )
782 {
783 if ( flags & WeaponWithAmmoFlags.MAX_CAPACITY_MAG)
784 magazineType = GetMaxMagazineTypeName(0);
785 else
786 magazineType = GetRandomMagazineTypeName(0);
787 }
788
789 EntityAI magAI = GetInventory().CreateAttachment(magazineType);
790 if (!magAI)
791 {
793 return null;
794 }
795
796 Magazine mag;
797 if (!CastTo(mag, magAI))
798 {
800 return null;
801 }
802
803
804 if (flags & WeaponWithAmmoFlags.QUANTITY_RNG)
805 mag.ServerSetAmmoCount(Math.RandomIntInclusive(0, mag.GetAmmoMax()));
806
808 {
809 string bulletType;
810 float dmg;
811 if(mag.ServerAcquireCartridge(dmg,bulletType))
812 {
814 }
815 }
816
817
818 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
819 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || chamberRng;
820 if (chamber || chamberRng)
821 {
823 }
824
825
828
829 return mag;
830 }
void RandomizeFSMState()
With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon...
bool FillChamber(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the chamber.
bool MustBeChambered(int muzzleIndex)
override string GetDebugName()