Try to spawn and attach a magazine.
764 {
765
766 if ( GetMagazineTypeCount(0) == 0 )
767 {
768 ErrorEx(
string.Format(
"No 'magazines' config entry for %1.",
this));
769 return null;
770 }
771
772
773 if ( magazineType == "" )
774 {
775 if ( flags & WeaponWithAmmoFlags.MAX_CAPACITY_MAG)
776 magazineType = GetMaxMagazineTypeName(0);
777 else
778 magazineType = GetRandomMagazineTypeName(0);
779 }
780
781 EntityAI magAI = GetInventory().CreateAttachment(magazineType);
782 if (!magAI)
783 {
785 return null;
786 }
787
788 Magazine mag;
789 if (!CastTo(mag, magAI))
790 {
792 return null;
793 }
794
795
796 if (flags & WeaponWithAmmoFlags.QUANTITY_RNG)
797 mag.ServerSetAmmoCount(Math.RandomIntInclusive(0, mag.GetAmmoMax()));
798
800 {
801 string bulletType;
802 float dmg;
803 if(mag.ServerAcquireCartridge(dmg,bulletType))
804 {
806 }
807 }
808
809
810 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
811 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || chamberRng;
812 if (chamber || chamberRng)
813 {
815 }
816
817
820
821 return mag;
822 }
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()