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

◆ FillChamber()

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

Try to fill the chamber.

Аргументы
[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 chamber was filled

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

930 {
931 bool didSomething = false;
932 bool chamberFullRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG_SPORADIC);
933 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
934 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER);
935
936
937 if (chamber || chamberFullRng)
938 {
939 // Make sure the given ammoType is actually useable
940 if (ammoType != "")
941 {
942 if (!AmmoTypesAPI.MagazineTypeToAmmoType(ammoType, ammoType))
943 return false;
944 }
945 else if (!(flags & WeaponWithAmmoFlags.AMMO_CHAMBER_RNG))
946 {
947 ammoType = GetRandomChamberableAmmoTypeName(0);
948 }
949
950 // fill chambers
951 int muzzCount = GetMuzzleCount();
952 int amountToChamber = muzzCount;
953
954 if (chamberRng)
955 amountToChamber = Math.RandomIntInclusive(0, muzzCount);
956
957
958 for (int m = 0; m < muzzCount; ++m)
959 {
960 if (chamberFullRng)
961 chamber = Math.RandomIntInclusive(0, 1);
962
963 if (chamber)
964 {
965 if (FillSpecificChamber(m))
966 {
967 didSomething = true;
968 amountToChamber--;
969 if (amountToChamber <= 0)
970 break;
971 }
972 }
973 }
974 }
975
976 if (!didSomething)
977 return false;
978
979 // FSM cares about chamber state
981 Synchronize();
982
983 return true;
984 }
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

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

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