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

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

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

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