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

◆ GetMagazineToReload()

EntityAI ManBase::GetMagazineToReload ( EntityAI weapon)
inlineprotected

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

4896 {
4897 Weapon_Base weapon_base = Weapon_Base.Cast(weapon);
4898 WeaponManager weapon_manager = GetWeaponManager();
4899 EntityAI magazine_to_reload;
4900
4901 EntityAI ammo_magazine; //magazine
4902 int last_ammo_magazine_count;
4903 int ammo_magazine_count;
4904
4905 EntityAI ammo_pile; //ammo pile
4906 int last_ammo_pile_count;
4907 int ammo_pile_count;
4908
4909 //Get all magazines in (player) inventory
4910 GameInventory inventory = GetInventory();
4911 int nAttachment = inventory.AttachmentCount();
4912 for (int att_i = 0; att_i < nAttachment; ++att_i)
4913 {
4914 EntityAI attachment = inventory.GetAttachmentFromIndex(att_i);
4915 ref CargoBase attachment_cargo = attachment.GetInventory().GetCargo();
4916
4917 if (attachment_cargo)
4918 {
4919 int nAttachmentCargoItem = attachment_cargo.GetItemCount();
4920 for (int cgo_i = 0; cgo_i < nAttachmentCargoItem; ++cgo_i)
4921 {
4922 EntityAI cargo_item = attachment_cargo.GetItem(cgo_i);
4923
4924 //check for proper magazine
4925 if (cargo_item.IsMagazine())
4926 {
4927 Magazine magazine = Magazine.Cast(cargo_item);
4928 ammo_pile_count = magazine.GetAmmoCount();
4929
4930 //magazines (get magazine with max ammo count)
4931 if (weapon_manager.CanAttachMagazine(weapon_base, magazine) || weapon_manager.CanSwapMagazine(weapon_base, magazine))
4932 {
4933 if (ammo_pile_count > 0)
4934 {
4935 if (last_ammo_magazine_count == 0)
4936 {
4937 ammo_magazine = magazine;
4938 last_ammo_magazine_count = ammo_pile_count;
4939 }
4940 else
4941 {
4942 if (last_ammo_magazine_count < ammo_pile_count)
4943 {
4944 ammo_magazine = magazine;
4945 last_ammo_magazine_count = ammo_pile_count;
4946 }
4947 }
4948 }
4949 }
4950 //bullets (get ammo pile with min ammo count)
4951 else if (weapon_manager.CanLoadBullet(weapon_base, magazine))
4952 {
4953 if (ammo_pile_count > 0)
4954 {
4955 if (last_ammo_pile_count == 0)
4956 {
4957 ammo_pile = magazine;
4958 last_ammo_pile_count = ammo_pile_count;
4959 }
4960 else
4961 {
4962 if (last_ammo_pile_count > ammo_pile_count)
4963 {
4964 ammo_pile = magazine;
4965 last_ammo_pile_count = ammo_pile_count;
4966 }
4967 }
4968 }
4969 }
4970 }
4971 }
4972 }
4973 }
4974
4975 //prioritize magazine
4976 if (ammo_magazine)
4977 {
4978 return ammo_magazine;
4979 }
4980
4981 return ammo_pile;
4982 }
class LogManager EntityAI
proto native EntityAI GetAttachmentFromIndex(int index)
proto native int AttachmentCount()
Returns count of attachments attached to this item.
override WeaponManager GetWeaponManager()
Определения PlayerBase.c:1989
bool CanLoadBullet(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
Определения WeaponManager.c:200
bool CanAttachMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
Определения WeaponManager.c:91
bool CanSwapMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
Определения WeaponManager.c:132

Перекрестные ссылки GameInventory::AttachmentCount(), WeaponManager::CanAttachMagazine(), WeaponManager::CanLoadBullet(), WeaponManager::CanSwapMagazine(), GameInventory::GetAttachmentFromIndex() и GetWeaponManager().

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