本文整理汇总了C++中CBasePlayer::ArmorValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CBasePlayer::ArmorValue方法的具体用法?C++ CBasePlayer::ArmorValue怎么用?C++ CBasePlayer::ArmorValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBasePlayer
的用法示例。
在下文中一共展示了CBasePlayer::ArmorValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RechargeThink
//-----------------------------------------------------------------------------
// Super-powers the entities
//-----------------------------------------------------------------------------
void CTriggerSuperArmor::RechargeThink()
{
Assert( m_hTouchingEntities.Count() == 1 );
for ( int i = m_hTouchingEntities.Count(); --i >= 0; )
{
CBasePlayer *pPlayer = assert_cast<CBasePlayer*>( m_hTouchingEntities[i].Get() );
if (( pPlayer->ArmorValue() < MAX_SUPER_ARMOR ) || ( pPlayer->GetHealth() < 100 ))
{
pPlayer->TakeHealth( 5, DMG_GENERIC );
pPlayer->IncrementArmorValue( 15, MAX_SUPER_ARMOR );
if ( pPlayer->ArmorValue() >= MAX_SUPER_ARMOR )
{
pPlayer->EmitSound( "TriggerSuperArmor.DoneCharging" );
StopLoopingSounds();
}
else
{
if ( m_flLoopingSoundTime < gpGlobals->curtime )
{
StartLoopingSounds( m_hTouchingEntities[i] );
}
}
}
}
SetContextThink( &CTriggerSuperArmor::RechargeThink, gpGlobals->curtime + 0.1f, s_pRechargeThinkContext );
}
示例2: Use
void CNewRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// if it's not a player, ignore
if ( !pActivator || !pActivator->IsPlayer() )
return;
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pActivator);
// Reset to a state of continuous use.
m_iCaps = FCAP_CONTINUOUS_USE;
if ( m_iOn )
{
float flCharges = CHARGES_PER_SECOND;
float flCalls = CALLS_PER_SECOND;
if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) )
flCharges = CITADEL_CHARGES_PER_SECOND;
m_flJuice -= flCharges / flCalls;
StudioFrameAdvance();
}
// Only usable if you have the HEV suit on
if ( !pPlayer->IsSuitEquipped() )
{
if (m_flSoundTime <= gpGlobals->curtime)
{
m_flSoundTime = gpGlobals->curtime + 0.62;
EmitSound( "SuitRecharge.Deny" );
}
return;
}
// if there is no juice left, turn it off
if ( m_iJuice <= 0 )
{
// Start our deny animation over again
ResetSequence( LookupSequence( "emptyclick" ) );
m_nState = 1;
// Shut off
Off();
// Play a deny sound
if ( m_flSoundTime <= gpGlobals->curtime )
{
m_flSoundTime = gpGlobals->curtime + 0.62;
EmitSound( "SuitRecharge.Deny" );
}
return;
}
// Get our maximum armor value
int nMaxArmor = 100;
if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) )
{
nMaxArmor = sk_suitcharger_citadel_maxarmor.GetInt();
}
int nIncrementArmor = 1;
// The citadel charger gives more per charge and also gives health
if ( HasSpawnFlags( SF_CITADEL_RECHARGER ) )
{
nIncrementArmor = 10;
#ifdef HL2MP
nIncrementArmor = 2;
#endif
// Also give health for the citadel version.
if ( pActivator->GetHealth() < pActivator->GetMaxHealth() && m_flNextCharge < gpGlobals->curtime )
{
pActivator->TakeHealth( 5, DMG_GENERIC );
}
}
// If we're over our limit, debounce our keys
if ( pPlayer->ArmorValue() >= nMaxArmor)
{
// Citadel charger must also be at max health
if ( !HasSpawnFlags(SF_CITADEL_RECHARGER) || ( HasSpawnFlags( SF_CITADEL_RECHARGER ) && pActivator->GetHealth() >= pActivator->GetMaxHealth() ) )
{
// Make the user re-use me to get started drawing health.
pPlayer->m_afButtonPressed &= ~IN_USE;
m_iCaps = FCAP_IMPULSE_USE;
EmitSound( "SuitRecharge.Deny" );
return;
}
}
// This is bumped out if used within the time period
SetNextThink( gpGlobals->curtime + CHARGE_RATE );
SetThink( &CNewRecharge::Off );
// Time to recharge yet?
//.........这里部分代码省略.........
示例3: Use
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// if it's not a player, ignore
if ( !pActivator->IsPlayer() )
return;
// if there is no juice left, turn it off
if (m_iJuice <= 0)
{
SetTextureFrameIndex( 1 );
Off();
}
// if the player doesn't have the suit, or there is no juice left, make the deny noise
if ( m_iJuice <= 0 )
{
if (m_flSoundTime <= gpGlobals->curtime)
{
m_flSoundTime = gpGlobals->curtime + 0.62;
EmitSound( "SuitRecharge.Deny" );
}
return;
}
SetNextThink( gpGlobals->curtime + 0.25 );
SetThink(Off);
// Time to recharge yet?
if (m_flNextCharge >= gpGlobals->curtime)
return;
// Make sure that we have a caller
if (!pActivator)
return;
m_hActivator = pActivator;
//only recharge the player
if (!m_hActivator->IsPlayer() )
return;
// Play the on sound or the looping charging sound
if (!m_iOn)
{
m_iOn++;
EmitSound( "SuitRecharge.Start" );
m_flSoundTime = 0.56 + gpGlobals->curtime;
}
if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->curtime))
{
m_iOn++;
CPASAttenuationFilter filter( this, "SuitRecharge.ChargingLoop" );
filter.MakeReliable();
EmitSound( filter, entindex(), "SuitRecharge.ChargingLoop" );
}
CBasePlayer *pl = (CBasePlayer *) m_hActivator.Get();
// charge the player
if (pl->ArmorValue() < 100)
{
m_iJuice--;
pl->IncrementArmorValue( 1, 100 );
}
// Send the output.
float flRemaining = m_iJuice / sk_suitcharger.GetFloat();
m_OutRemainingCharge.Set(flRemaining, pActivator, this);
// govern the rate of charge
m_flNextCharge = gpGlobals->curtime + 0.1;
}
示例4: Use
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// Make sure that we have a caller
if (!pActivator)
return;
// if it's not a player, ignore
if ( !pActivator->IsPlayer() )
return;
CBasePlayer *pPlayer = dynamic_cast<CBasePlayer *>( pActivator );
if ( pPlayer == NULL )
return;
// Reset to a state of continuous use.
m_iCaps = FCAP_CONTINUOUS_USE;
// if there is no juice left, turn it off
if (m_iJuice <= 0)
{
SetTextureFrameIndex( 1 );
Off();
}
// if the player doesn't have the suit, or there is no juice left, make the deny noise
if ( m_iJuice <= 0 )
{
if (m_flSoundTime <= gpGlobals->curtime)
{
m_flSoundTime = gpGlobals->curtime + 0.62;
EmitSound( "SuitRecharge.Deny" );
}
return;
}
// If we're over our limit, debounce our keys
if ( pPlayer->ArmorValue() >= HL1_MAX_ARMOR)
{
// Make the user re-use me to get started drawing health.
pPlayer->m_afButtonPressed &= ~IN_USE;
m_iCaps = FCAP_IMPULSE_USE;
EmitSound( "SuitRecharge.Deny" );
return;
}
SetNextThink( gpGlobals->curtime + 0.25 );
SetThink(&CRecharge::Off);
// Time to recharge yet?
if (m_flNextCharge >= gpGlobals->curtime)
return;
m_hActivator = pActivator;
// Play the on sound or the looping charging sound
if (!m_iOn)
{
m_iOn++;
EmitSound( "SuitRecharge.Start" );
m_flSoundTime = 0.56 + gpGlobals->curtime;
}
if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->curtime))
{
m_iOn++;
CPASAttenuationFilter filter( this, "SuitRecharge.ChargingLoop" );
filter.MakeReliable();
EmitSound( filter, entindex(), "SuitRecharge.ChargingLoop" );
}
CBasePlayer *pl = (CBasePlayer *) m_hActivator.Get();
// charge the player
if (pl->ArmorValue() < HL1_MAX_ARMOR)
{
m_iJuice--;
pl->IncrementArmorValue( 1, HL1_MAX_ARMOR );
}
// Send the output.
float flRemaining = m_iJuice / sk_suitcharger.GetFloat();
m_OutRemainingCharge.Set(flRemaining, pActivator, this);
// govern the rate of charge
m_flNextCharge = gpGlobals->curtime + 0.1;
}