DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ FillInnerMagazine()

bool Weapon::FillInnerMagazine ( string ammoType = "",
int flags = WeaponWithAmmoFlags.CHAMBER )
inlineprotected

Try to fill the inner magazine.

Аргументы
[in]ammoTypestring The ammo to load, passing in empty string will select random
Заметки
It is best to fill in the actual 'ammo', as in the ones usually prefixed by 'Bullet_', to skip searching for it
Аргументы
[in]flagsint Setup flags, please read WeaponWithAmmoFlags
Возвращает
Whether any ammo was added to the gun or not

См. определение в файле Weapon_Base.c строка 827

828 {
829 // Don't try to fill it when there are none
830 if (!HasInternalMagazine(-1))
831 return false;
832
833 // Make sure the given ammoType is actually useable
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 // No full RNG flag, so pick one random and use only this one
848 if (ammoRng && !ammoFullRng)
849 ammoType = GetRandomChamberableAmmoTypeName(0);
850
851 // Fill the internal magazine
852 for (int i = 0; i < muzzCount; ++i)
853 {
854 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
855
856 // Decide random quantity when enabled
857 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
858 ammoCount = Math.RandomIntInclusive(0, ammoCount);
859
860 // Only do the things when there is actually ammo to fill
861 if (ammoCount > 0)
862 {
863 // Push in the cartridges
864 for (int j = 0; j < ammoCount; ++j)
865 {
866 // Full random, decide a new one for every cartridge
867 if ( ammoFullRng )
868 ammoType = GetRandomChamberableAmmoTypeName(i);
869
870 PushCartridgeToInternalMagazine(i, 0, ammoType);
871 didSomething = true;
872 }
873 }
874 }
875
876 // Call the chamber method if asked for
877 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
878 if (chamber && FillChamber(ammoType, flags))
879 {
880 didSomething = true;
881 }
882
883 // Does not need any FSM fixing, FSM does not care about inner magazines
884
885 return didSomething;
886 }
bool FillChamber(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the chamber.
Определения Weapon_Base.c:895

Перекрестные ссылки FillChamber(), AmmoTypesAPI::MagazineTypeToAmmoType() и Math::RandomIntInclusive().

Используется в SpawnAmmo().