本文整理汇总了C++中CBaseCombatCharacter::GetAmmoCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatCharacter::GetAmmoCount方法的具体用法?C++ CBaseCombatCharacter::GetAmmoCount怎么用?C++ CBaseCombatCharacter::GetAmmoCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatCharacter
的用法示例。
在下文中一共展示了CBaseCombatCharacter::GetAmmoCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Reload
//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponShotgun::Reload( void )
{
// Check that StartReload was called first
if (!m_bInReload)
{
Warning("ERROR: Shotgun Reload called incorrectly!\n");
}
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return false;
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
return false;
if (m_iClip1 >= GetMaxClip1())
return false;
int j = MIN(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if (j <= 0)
return false;
FillClip();
// Play reload on different channel as otherwise steals channel away from fire sound
WeaponSound(RELOAD);
SendWeaponAnim( ACT_VM_RELOAD );
pOwner->m_flNextAttack = gpGlobals->curtime;
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
return true;
}
示例2: Reload
//-----------------------------------------------------------------------------
// Purpose: Same as base reload but doesn't change the owner's next attack time. This
// lets us zoom out while reloading. This hack is necessary because our
// ItemPostFrame is only called when the owner's next attack time has
// expired.
// Output : Returns true if the weapon was reloaded, false if no more ammo.
//-----------------------------------------------------------------------------
bool CWeaponSniperRifle::Reload( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return false;
}
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) > 0)
{
int primary = MIN(GetMaxClip1() - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
int secondary = MIN(GetMaxClip2() - m_iClip2, pOwner->GetAmmoCount(m_iSecondaryAmmoType));
if (primary > 0 || secondary > 0)
{
// Play reload on different channel as it happens after every fire
// and otherwise steals channel away from fire sound
WeaponSound(RELOAD);
SendWeaponAnim( ACT_VM_RELOAD );
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_bInReload = true;
}
return true;
}
return false;
}
示例3: StartReload
//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponShotgun::StartReload( void )
{
if ( m_bNeedPump )
return false;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return false;
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
return false;
if (m_iClip1 >= GetMaxClip1())
return false;
int j = MIN(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if (j <= 0)
return false;
SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
// Make shotgun shell visible
SetBodygroup(1,0);
pOwner->m_flNextAttack = gpGlobals->curtime;
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_bInReload = true;
return true;
}
示例4: GetOwner
//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input :
// Output :
//-----------------------------------------------------------------------------
bool CWeapon870AE::StartReload( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return false;
if (m_iItemID == 0)
{
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
return false;
if (m_iClip1 >= GetMaxClip1())
return false;
// If shotgun totally emptied then a pump animation is needed
//NOTENOTE: This is kinda lame because the player doesn't get strong feedback on when the reload has finished,
// without the pump. Technically, it's incorrect, but it's good for feedback...
int j = MIN(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if (j <= 0)
return false;
}
else
{
CBasePlayer *pPlayer = ToBasePlayer(GetOwner());
if (pPlayer)
{
if (pPlayer->Inventory_CountAllObjectContentsOfID(GetPrimaryAmmoID()) <= 0)
return false;
if (m_iClip1 >= GetMaxClip1())
return false;
int j = MIN(1, pPlayer->Inventory_CountAllObjectContentsOfID(GetPrimaryAmmoID()));
if (j <= 0)
return false;
}
}
SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
// Make shotgun shell visible
SetBodygroup(1,0);
pOwner->m_flNextAttack = gpGlobals->curtime;
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_bInReload = true;
return true;
}
示例5: WeaponIdle
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_Tripwire::WeaponIdle( void )
{
// Ready to switch animations?
if ( HasWeaponIdleTimeElapsed() )
{
if (m_bClearReload)
{
m_bNeedReload = false;
m_bClearReload = false;
}
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return;
}
int iAnim = 0;
if (m_bAttachTripwire)
{
TripwireAttach();
iAnim = ACT_SLAM_TRIPMINE_ATTACH2;
}
else if (m_bNeedReload)
{
// If owner had ammo draw the correct tripwire type
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0)
{
iAnim = ACT_SLAM_TRIPMINE_DRAW;
m_bClearReload = true;
}
else
{
pOwner->Weapon_Drop( this );
UTIL_Remove(this);
}
}
else if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
{
pOwner->Weapon_Drop( this );
UTIL_Remove(this);
}
// If I don't need to reload just do the appropriate idle
else
{
iAnim = ACT_SLAM_TRIPMINE_IDLE;
}
SendWeaponAnim( iAnim );
}
}
示例6: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::PrimaryAttack( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return;
}
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
{
return;
}
switch (m_tSlamState)
{
case SLAM_TRIPMINE_READY:
if (CanAttachSLAM())
{
StartTripmineAttach();
}
break;
case SLAM_SATCHEL_THROW:
StartSatchelThrow();
break;
case SLAM_SATCHEL_ATTACH:
StartSatchelAttach();
break;
}
}
示例7: WeaponIdle
void CWeaponMine::WeaponIdle( void )
{
if(gpGlobals->curtime > m_flNextPrimaryAttack){
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
return;
//Si on a une mine à finir de poser
if(m_bAttachMine)
FinishAttach();
//Sinon si on doit recharger
if( m_bNeedReload )
{
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0){
SendWeaponAnim(ACT_SLAM_TRIPMINE_DRAW);
m_bNeedReload = false;
}
#ifndef CLIENT_DLL
//Sinon on a pas assez de munitions et on drop l'arme
else
{
pOwner->Weapon_Drop(this);
UTIL_Remove(this);
}
#endif
}
//Sinon on idle
else
{
SendWeaponAnim(ACT_SLAM_TRIPMINE_IDLE);
m_flWallSwitchTime = 0;
}
}
}
示例8: CreateLaserPointer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponTranquilizer::CreateLaserPointer( void )
{
#ifndef CLIENT_DLL
if ( m_hLaserDot != NULL )
return;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return;
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return;
m_hLaserDot = CLaserDot::Create( GetAbsOrigin(), GetOwner() );
m_hLaserDot->TurnOff();
m_hLaserDot->SetRenderMode(kRenderWorldGlow);
if(HL2MPRules()->IsTeamplay())
{
if(pOwner->GetTeamNumber() == TEAM_PINK)
m_hLaserDot->SetRenderColor(255,100,255,255);
else
m_hLaserDot->SetRenderColor(153,255,153,255);
}
else
m_hLaserDot->SetRenderColor(255,0,0,255);
UpdateLaserPosition();
#endif
}
示例9: Weapon_Switch
//-----------------------------------------------------------------------------
// Purpose: Switch to next best weapon
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::Weapon_Switch( void )
{
// Note that we may pick the SLAM again, when we switch
// weapons, in which case we have to save and restore the
// detonator armed state.
// The SLAMs may be about to blow up, but haven't done so yet
// and the deploy function will find the undetonated charges
// and we are armed
bool saveState = m_bDetonatorArmed;
CBaseCombatCharacter *pOwner = GetOwner();
pOwner->SwitchToNextBestWeapon( pOwner->GetActiveWeapon() );
if (pOwner->GetActiveWeapon() == this)
{
m_bDetonatorArmed = saveState;
}
#ifndef CLIENT_DLL
// If not armed and have no ammo
if (!m_bDetonatorArmed && pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
{
pOwner->ClearActiveWeapon();
}
#endif
}
示例10: SLAMThink
//-----------------------------------------------------------------------------
// Purpose:
// Input :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::SLAMThink( void )
{
if (m_flWallSwitchTime <= gpGlobals->curtime)
{
// If not in tripmine mode we need to check to see if we are close to
// a wall. If we are we go into satchel_attach mode
CBaseCombatCharacter *pOwner = GetOwner();
if ((m_tSlamState != SLAM_TRIPMINE_READY) && (pOwner && pOwner->GetAmmoCount(m_iSecondaryAmmoType) > 0))
{
if (CanAttachSLAM())
{
if (m_tSlamState == SLAM_SATCHEL_THROW)
{
SetSlamState(SLAM_SATCHEL_ATTACH);
int iAnim = m_bDetonatorArmed ? ACT_SLAM_THROW_TO_STICKWALL : ACT_SLAM_THROW_TO_STICKWALL_ND;
SendWeaponAnim( iAnim );
m_flWallSwitchTime = gpGlobals->curtime + SequenceDuration();
}
}
else
{
if (m_tSlamState == SLAM_SATCHEL_ATTACH)
{
SetSlamState(SLAM_SATCHEL_THROW);
int iAnim = m_bDetonatorArmed ? ACT_SLAM_STICKWALL_TO_THROW : ACT_SLAM_STICKWALL_TO_THROW_ND;
SendWeaponAnim( iAnim );
m_flWallSwitchTime = gpGlobals->curtime + SequenceDuration();
}
}
}
}
SetNextThink( gpGlobals->curtime + 0.1f );
}
示例11: Deploy
bool CWeapon_SLAM::Deploy( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
{
return false;
}
m_bDetonatorArmed = AnyUndetonatedCharges();
SetModel( GetViewModel() );
m_tSlamState = (int)SLAM_SATCHEL_THROW;
// ------------------------------
// Pick the right draw animation
// ------------------------------
int iActivity;
// If detonator is already armed
m_bNeedReload = false;
if (m_bDetonatorArmed)
{
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
{
iActivity = ACT_SLAM_DETONATOR_DRAW;
m_bNeedReload = true;
}
else if (CanAttachSLAM())
{
iActivity = ACT_SLAM_DETONATOR_STICKWALL_DRAW;
SetSlamState(SLAM_TRIPMINE_READY);
}
else
{
iActivity = ACT_SLAM_DETONATOR_THROW_DRAW;
SetSlamState(SLAM_SATCHEL_THROW);
}
}
else
{
if (CanAttachSLAM())
{
iActivity = ACT_SLAM_TRIPMINE_DRAW;
SetSlamState(SLAM_TRIPMINE_READY);
}
else
{
iActivity = ACT_SLAM_THROW_ND_DRAW;
SetSlamState(SLAM_SATCHEL_THROW);
}
}
return DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), iActivity, (char*)GetAnimPrefix() );
}
示例12: WeaponSwitch
void CWeapon_Manhack::WeaponSwitch( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (pOwner==NULL) return;
pOwner->SwitchToNextBestWeapon( pOwner->GetActiveWeapon() );
if (CPropVehicleManhack::GetManhackVehicle() == NULL && pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{
pOwner->ClearActiveWeapon();
}
}
示例13: PrimaryAttack
void CWeaponMine::PrimaryAttack( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
return;
if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
return;
if (!m_bAttachMine)
StartAttach();
}
示例14: Reload
bool CWeaponShotgun::Reload( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner == NULL )
return false;
if ( pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 )
return false;
if ( m_iClip1 >= GetMaxClip1() )
return false;
// don't reload until recoil is done
if ( m_flNextPrimaryAttack > gpGlobals->curtime )
return false;
// check to see if we're ready to reload
if ( m_fInSpecialReload == 0 )
{
SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
m_fInSpecialReload = 1;
pOwner->m_flNextAttack = gpGlobals->curtime + 0.6;
SetWeaponIdleTime( gpGlobals->curtime + 0.6 );
m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
m_flNextSecondaryAttack = gpGlobals->curtime + 1.0;
return true;
}
else if ( m_fInSpecialReload == 1 )
{
if ( !HasWeaponIdleTimeElapsed() )
return false;
// was waiting for gun to move to side
m_fInSpecialReload = 2;
// Play reload on different channel as otherwise steals channel away from fire sound
WeaponSound( RELOAD );
SendWeaponAnim( ACT_VM_RELOAD );
SetWeaponIdleTime( gpGlobals->curtime + 0.5 );
}
else
{
FillClip();
m_fInSpecialReload = 1;
}
return true;
}
示例15: HasAmmo
//-----------------------------------------------------------------------------
// Purpose: Return true if this weapon has some ammo
//-----------------------------------------------------------------------------
bool CASW_Weapon::HasAmmo( void )
{
// Weapons with no ammo types can always be selected
if ( m_iPrimaryAmmoType == -1 && m_iSecondaryAmmoType == -1 )
return true;
if ( GetWeaponFlags() & ITEM_FLAG_SELECTONEMPTY )
return true;
CBaseCombatCharacter *pOwner = GetOwner();
if ( !pOwner )
return false;
return ( m_iClip1 > 0 || pOwner->GetAmmoCount( m_iPrimaryAmmoType ) || m_iClip2 > 0 || pOwner->GetAmmoCount( m_iSecondaryAmmoType ) );
}