bool C_ASW_Ammo_Drop::AllowedToPickup( C_ASW_Marine *pMarine )
{
	// if the marine can't use it, the use portion is zero
	return ( GetAmmoUseUnits( pMarine ) != NULL );
}
void CASW_Ammo_Drop::ActivateUseIcon( CASW_Marine* pMarine, int nHoldType )
{
    if ( nHoldType == ASW_USE_HOLD_START )
        return;

    CASW_Weapon *pWeapon = GetAmmoUseUnits( pMarine );

    if( pWeapon )
    {
        int iAmmoType = pWeapon->GetPrimaryAmmoType();
        int iGuns = pMarine->GetNumberOfWeaponsUsingAmmo( iAmmoType );
        int iMaxAmmoCount = GetAmmoDef()->MaxCarry( iAmmoType, pMarine ) * iGuns;
        int iBullets = pMarine->GetAmmoCount( iAmmoType );
        int iAmmoCost = GetAmmoUnitCost( iAmmoType );
        int iClipsToGive = CASW_Ammo_Drop_Shared::GetAmmoClipsToGive( iAmmoType );

        pMarine->SetAmmoCount( MIN( iBullets + pWeapon->GetMaxClip1() * iClipsToGive, iMaxAmmoCount ), iAmmoType );
        m_iAmmoUnitsRemaining -= iAmmoCost;

        pMarine->GetMarineSpeech()->Chatter(CHATTER_USE);

        IGameEvent * event = gameeventmanager->CreateEvent( "ammo_pickup" );
        if ( event )
        {
            CASW_Player *pPlayer = pMarine->GetCommander();
            event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
            event->SetInt( "entindex", pMarine->entindex() );

            gameeventmanager->FireEvent( event );
        }

        if ( m_iAmmoUnitsRemaining <= 0 )
        {
            CTakeDamageInfo info;

            BaseClass::Event_Killed( info );
        }

        CASW_Marine *pDeployer = m_hDeployer.Get();

        if ( pDeployer && pMarine != pDeployer && !m_bSuppliedAmmo )
        {
            m_bSuppliedAmmo = true;
            if ( pDeployer->GetCommander() )
            {
                pDeployer->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_AMMO_RESUPPLY );
            }
        }
    }
    else
    {
        if ( pMarine->IsInhabited() )
        {
            CASW_Player *pCommander = pMarine->GetCommander();
            if ( pCommander )
            {
                CSingleUserRecipientFilter filter( pCommander );
                EmitSound( filter, pMarine->entindex(), "ASW_Ammobag.Fail", NULL, 0.0f );
            }
        }
    }
}