本文整理汇总了C++中CBaseCombatWeapon::GetPrimaryAmmoType方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon::GetPrimaryAmmoType方法的具体用法?C++ CBaseCombatWeapon::GetPrimaryAmmoType怎么用?C++ CBaseCombatWeapon::GetPrimaryAmmoType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatWeapon
的用法示例。
在下文中一共展示了CBaseCombatWeapon::GetPrimaryAmmoType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Spawn
void CJaS_Marine_Jack::Spawn()
{
CASW_Marine_Resource *pResource = dynamic_cast<CASW_Marine_Resource *>( CreateEntityByName( "asw_marine_resource" ) );
pResource->SetProfileIndex( 6 );
pResource->SetMarineEntity( this );
SetMarineResource( pResource );
pResource->Spawn();
m_pProfileOverride = pResource->GetProfile();
SelectModelFromProfile();
SetModelFromProfile();
CBaseCombatWeapon *pWeapon = dynamic_cast<CBaseCombatWeapon *>( CreateEntityByName( "asw_weapon_sniper_rifle" ) );
if ( pWeapon )
{
pWeapon->Spawn();
pWeapon->GiveDefaultAmmo();
pWeapon->m_iClip1 = 9999;
GiveAmmo(9999, pWeapon->GetPrimaryAmmoType());
Weapon_Equip_In_Index( pWeapon, 0 );
Weapon_Switch( pWeapon );
}
m_bConstantSlowHeal = true;
m_hSquadFormation = static_cast<CASW_SquadFormation *>( CreateEntityByName( "asw_squadformation" ) );
m_hSquadFormation->Leader( this );
SetRenderColor( 0x99, 0x40, 0x40 );
BaseClass::Spawn();
}
示例3:
//-----------------------------------------------------------------------------
// 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;
}