DayZ 1.30
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 строка 831

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

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

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