void CObjectActionReload::execute () { inherited::execute (); VERIFY (m_item); VERIFY (object().inventory().ActiveItem()); VERIFY (object().inventory().ActiveItem()->object().ID() == m_item->object().ID()); CWeapon *weapon = smart_cast<CWeapon*>(object().inventory().ActiveItem()); VERIFY (weapon); if (weapon->IsPending()) return; if (weapon->GetAmmoElapsed()) { VERIFY (weapon->GetSuitableAmmoTotal() >= weapon->GetAmmoElapsed()); if (weapon->GetSuitableAmmoTotal() == weapon->GetAmmoElapsed()) return; VERIFY (weapon->GetAmmoMagSize() >= weapon->GetAmmoElapsed()); if (weapon->GetAmmoMagSize() == weapon->GetAmmoElapsed()) return; } object().inventory().Action (kWPN_RELOAD,CMD_START); }
float CPersonalWeaponTypeFunction::ffGetTheBestWeapon() { u32 dwBestWeapon = 0; if (ef_storage().non_alife().member() && ef_storage().non_alife().member_item()) return (float(dwfGetWeaponType())); if (ef_storage().non_alife().member()) { const CInventoryOwner *tpInventoryOwner = smart_cast<const CInventoryOwner*>(ef_storage().non_alife().member()); if (tpInventoryOwner) { xr_vector<CInventorySlot>::const_iterator I = tpInventoryOwner->inventory().m_slots.begin(); xr_vector<CInventorySlot>::const_iterator E = tpInventoryOwner->inventory().m_slots.end(); for ( ; I != E; ++I) if ((*I).m_pIItem) { CWeapon *tpCustomWeapon = smart_cast<CWeapon*>((*I).m_pIItem); if (tpCustomWeapon && (tpCustomWeapon->GetSuitableAmmoTotal(true) > tpCustomWeapon->GetAmmoMagSize()/10)) { ef_storage().non_alife().member_item() = tpCustomWeapon; u32 dwCurrentBestWeapon = dwfGetWeaponType(); if (dwCurrentBestWeapon > dwBestWeapon) dwBestWeapon = dwCurrentBestWeapon; ef_storage().non_alife().member_item() = 0; } } } } else { if (!ef_storage().alife().member() || !ef_storage().alife().member()->m_tpCurrentBestWeapon) return(0); ef_storage().alife().member_item() = ef_storage().alife().member()->m_tpCurrentBestWeapon; dwBestWeapon = dwfGetWeaponType(); } return(float(dwBestWeapon)); }