Beispiel #1
0
void  CInventory::AddAvailableItems(TIItemContainer& items_container, bool for_trade) const
{
	for(TIItemContainer::const_iterator it = m_ruck.begin(); m_ruck.end() != it; ++it) 
	{
		PIItem pIItem = *it;
		if(!for_trade || pIItem->CanTrade())
			items_container.push_back(pIItem);
	}

	if(m_bBeltUseful)
	{
		for(TIItemContainer::const_iterator it = m_belt.begin(); m_belt.end() != it; ++it) 
		{
			PIItem pIItem = *it;
			if(!for_trade || pIItem->CanTrade())
				items_container.push_back(pIItem);
		}
	}
	
	if(m_bSlotsUseful)
	{
		u16 I = FirstSlot();
		u16 E = LastSlot();
		for(;I<=E;++I)
		{
			PIItem item = ItemFromSlot(I);
			if(item && (!for_trade || item->CanTrade())  )
			{
				if(!SlotIsPersistent(I) || item->BaseSlot()==GRENADE_SLOT )
					items_container.push_back(item);
			}
		}
	}		
}
Beispiel #2
0
void  CInventory::AddAvailableItems(TIItemContainer& items_container, bool for_trade) const
{
    for(TIItemContainer::const_iterator it = m_ruck.begin(); m_ruck.end() != it; ++it)
    {
        PIItem pIItem = *it;
        if(!for_trade || pIItem->CanTrade())
            items_container.push_back(pIItem);
    }

    if(m_bBeltUseful)
    {
        for(TIItemContainer::const_iterator it = m_belt.begin(); m_belt.end() != it; ++it)
        {
            PIItem pIItem = *it;
            if(!for_trade || pIItem->CanTrade())
                items_container.push_back(pIItem);
        }
    }

    if(m_bSlotsUseful)
    {
        TISlotArr::const_iterator slot_it			= m_slots.begin();
        TISlotArr::const_iterator slot_it_e			= m_slots.end();
        for(; slot_it!=slot_it_e; ++slot_it)
        {
            const CInventorySlot& S = *slot_it;
            if(S.m_pIItem && (!for_trade || S.m_pIItem->CanTrade())  )
            {
                if(!S.m_bPersistent || S.m_pIItem->GetSlot()==GRENADE_SLOT )
                    items_container.push_back(S.m_pIItem);
            }
        }
    }
}
Beispiel #3
0
void CUIGameCTA::BuyMenuItemInserter(PIItem const & item)
{
    VERIFY(m_pCurBuyMenu);
    if (!item)
        return;

    if (item->IsInvalid() || smart_cast<CWeaponKnife*>(&item->object()) )
        return;

    CArtefact* pArtefact = smart_cast<CArtefact*>(item);
    if (pArtefact)
        return;

    if (!pSettings->line_exist(m_costSection, item->object().cNameSect()))
        return;

    if (!item->CanTrade())
        return;

    u8 addons = 0;
    CWeapon* pWeapon = smart_cast<CWeapon*>(item);
    if (pWeapon)
        addons = pWeapon->GetAddonsState();

    CWeaponAmmo* pAmmo = smart_cast<CWeaponAmmo*>(item);
    if (pAmmo && (pAmmo->m_boxCurr != pAmmo->m_boxSize))
        return;

    m_pCurBuyMenu->ItemToSlot(item->object().cNameSect(), addons);
}
Beispiel #4
0
bool CUIActorMenu::CanMoveToPartner(PIItem pItem)
{
	if(!pItem->CanTrade())
		return false;

	if ( !m_pPartnerInvOwner->trade_parameters().enabled(
		CTradeParameters::action_buy(0), pItem->object().cNameSect() ) )
	{
		return false;
	}

	float r1				= CalcItemsWeight( m_pTradeActorList );		// actor
	float r2				= CalcItemsWeight( m_pTradePartnerList );	// partner
	float itmWeight			 = pItem->Weight();
	float partner_inv_weight = m_pPartnerInvOwner->inventory().CalcTotalWeight();
	float partner_max_weight = m_pPartnerInvOwner->MaxCarryWeight();

	if ( partner_inv_weight - r2 + r1 + itmWeight > partner_max_weight )
	{
		return false;
	}
	return true;
}