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