本文整理汇总了C++中CBaseCombatWeapon::Clip1方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon::Clip1方法的具体用法?C++ CBaseCombatWeapon::Clip1怎么用?C++ CBaseCombatWeapon::Clip1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatWeapon
的用法示例。
在下文中一共展示了CBaseCombatWeapon::Clip1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReSupplyPlayer
bool Dota_Resupply::ReSupplyPlayer( CHL2MP_Player * pPlayer )
{
CBaseCombatWeapon * weapon;
int weaponLevel;
int iAmmoIndex;
bool gotSomething = false;
for ( int i = 1; i < MAX_AMMO_TYPES; i++ )
{
Item_t * item = GetItemDef()->GetItemOfIndex(i);
if ( item && item->pWeaponNeeded == NULL )
{
weapon = pPlayer->Weapon_OwnsThisType( item->pName );
weaponLevel = pPlayer->GetWeaponLevel( item->pName );
if ( weapon && weaponLevel > 0 )
{
iAmmoIndex = weapon->GetPrimaryAmmoType();
if ( iAmmoIndex < 0 || iAmmoIndex >= MAX_AMMO_SLOTS )
continue;
int iMax = (GetAmmoDef()->MaxCarry(iAmmoIndex) / 4) * weaponLevel;
if ( weapon->UsesClipsForAmmo1() ) {
int missingFromClip1 = weapon->GetMaxClip1() - weapon->Clip1();
iMax += missingFromClip1;
}
int iAdd = iMax - pPlayer->GetAmmoCount(iAmmoIndex);
if ( iAdd >= 1 )
gotSomething |= (pPlayer->GiveAmmo( iAdd, weapon->GetPrimaryAmmoType() ) != 0);
}
}
}
return gotSomething;
}
示例2:
//-----------------------------------------------------------------------------
// Purpose: Find the next best weapon to use and return it.
//-----------------------------------------------------------------------------
CBaseCombatWeapon *CSingleplayRules::GetNextBestWeapon( CBaseCombatCharacter *pPlayer, CBaseCombatWeapon *pCurrentWeapon )
{
if ( pCurrentWeapon && !pCurrentWeapon->AllowsAutoSwitchFrom() )
return NULL;
CBaseCombatWeapon *pBestWeapon = NULL;
CBaseCombatWeapon *pWeapon;
int nBestWeight = -1;
//Search for the best weapon to use next based on its weight
for ( int i = 0; i < pPlayer->WeaponCount(); i++ )
{
pWeapon = pPlayer->GetWeapon(i);
if ( pWeapon == NULL )
continue;
// If we have an active weapon and this weapon doesn't allow autoswitching away
// from another weapon, skip it.
if ( pCurrentWeapon && !pWeapon->AllowsAutoSwitchTo() )
continue;
// Must be eligible for switching to.
if (!pPlayer->Weapon_CanSwitchTo(pWeapon))
continue;
// Must be of higher quality.
if ( pWeapon->GetWeight() <= nBestWeight )
continue;
// We must have primary ammo
if ( pWeapon->UsesClipsForAmmo1() && pWeapon->Clip1() <= 0 && !pPlayer->GetAmmoCount( pWeapon->GetPrimaryAmmoType() ) )
continue;
// This is a better candidate than what we had.
nBestWeight = pWeapon->GetWeight();
pBestWeapon = pWeapon;
}
return pBestWeapon;
}