DayZ 1.28
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 строка 839

840 {
841 // Don't try to fill it when there are none
842 if (!HasInternalMagazine(-1))
843 return false;
844
845 // Make sure the given ammoType is actually useable
846 if (ammoType != "")
847 {
848 if (!AmmoTypesAPI.MagazineTypeToAmmoType(ammoType, ammoType))
849 return false;
850 }
851
852
853 bool didSomething = false;
854 bool needUpdateStateMachine = false;
855 int muzzCount = GetMuzzleCount();
856
857 bool ammoRng = ammoType == "";
858 bool ammoFullRng = ammoRng && (flags & WeaponWithAmmoFlags.AMMO_MAG_RNG);
859
860 // No full RNG flag, so pick one random and use only this one
861 if (ammoRng && !ammoFullRng)
862 ammoType = GetRandomChamberableAmmoTypeName(0);
863
864 // Fill the internal magazine
865 for (int i = 0; i < muzzCount; ++i)
866 {
867 bool loadAnyBullet = false;
868 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
869
870 // Decide random quantity when enabled
871 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
872 ammoCount = Math.RandomIntInclusive(0, ammoCount);
873
874 // Only do the things when there is actually ammo to fill
875 if (ammoCount > 0)
876 {
877 // Push in the cartridges
878 for (int j = 0; j < ammoCount; ++j)
879 {
880 // Full random, decide a new one for every cartridge
881 if ( ammoFullRng )
882 ammoType = GetRandomChamberableAmmoTypeName(i);
883
884 PushCartridgeToInternalMagazine(i, 0, ammoType);
885 loadAnyBullet = true;
886 didSomething = true;
887 }
888
889 if (loadAnyBullet && MustBeChambered(i))
890 {
891 if ( ammoFullRng )
892 ammoType = GetRandomChamberableAmmoTypeName(i);
893
894 if (FillSpecificChamber(i, 0, ammoType))
895 needUpdateStateMachine = true;
896
897 }
898 }
899 }
900
901 // Call the chamber method if asked for
902 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
903 if (chamber && FillChamber(ammoType, flags))
904 {
905 didSomething = true;
906 }
907
908 // Only fix the FSM and Synchronize when absolutely needed
909 if (!didSomething)
910 return false;
911
912 if( needUpdateStateMachine )
913 {
914 // FSM cares about chamber state
916 Synchronize();
917 }
918
919 return true;
920 }
void Synchronize()
Определения CombinationLock.c:151
bool FillSpecificChamber(int muzzleIndex, float dmg=0, string ammoType="")
Определения Weapon_Base.c:986
void RandomizeFSMState()
With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon...
Определения Weapon_Base.c:675
bool FillChamber(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the chamber.
Определения Weapon_Base.c:929
bool MustBeChambered(int muzzleIndex)
Определения Weapon_Base.c:2267

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

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