本文整理汇总了C++中GetFireRate函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFireRate函数的具体用法?C++ GetFireRate怎么用?C++ GetFireRate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFireRate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clamp
//-----------------------------------------------------------------------------
// Purpose: Make enough sound events to fill the estimated think interval
// returns: number of shots needed
//-----------------------------------------------------------------------------
int CHLMachineGun::WeaponSoundRealtime( WeaponSound_t shoot_type )
{
int numBullets = 0;
// ran out of time, clamp to current
if (m_flNextSoundTime < gpGlobals->curtime)
{
m_flNextSoundTime = gpGlobals->curtime;
}
// make enough sound events to fill up the next estimated think interval
float dt = clamp( m_flAnimTime - m_flPrevAnimTime, 0, 0.2 );
if (m_flNextSoundTime < gpGlobals->curtime + dt)
{
WeaponSound( SINGLE_NPC, m_flNextSoundTime );
m_flNextSoundTime += GetFireRate();
numBullets++;
}
if (m_flNextSoundTime < gpGlobals->curtime + dt)
{
WeaponSound( SINGLE_NPC, m_flNextSoundTime );
m_flNextSoundTime += GetFireRate();
numBullets++;
}
return numBullets;
}
示例2: WeaponSound
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponCombatLaserRifle::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
if (!pPlayer)
return;
WeaponSound(SINGLE);
// Fire the bullets
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming;
pPlayer->EyeVectors( &vecAiming );
PlayAttackAnimation( GetPrimaryAttackActivity() );
// Reduce the spread if the player's ducking
Vector vecSpread = GetBulletSpread();
vecSpread *= m_flInaccuracy;
TFGameRules()->FireBullets( CTakeDamageInfo( this, pPlayer, weapon_combat_laserrifle_damage.GetFloat(), DMG_PLASMA), 1,
vecSrc, vecAiming, vecSpread, weapon_combat_laserrifle_range.GetFloat(), m_iPrimaryAmmoType, 0, entindex(), 0 );
m_flInaccuracy += 0.3;
m_flInaccuracy = clamp(m_flInaccuracy, 0, 1);
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
m_iClip1 = m_iClip1 - 1;
}
示例3: ToBasePlayer
void CWeaponStickyLauncher::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
return;
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
WeaponSound(SINGLE);
pPlayer->m_fEffects |= EF_MUZZLEFLASH;
SendWeaponAnim( GetPrimaryAttackActivity() );
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
m_iClip1 = m_iClip1 - 1;
LaunchStickyBomb( pPlayer, vecSrc, vecAiming );
AddViewKick();
}
示例4: ToBasePlayer
void CWeaponCombatKnife::SecondaryAttack( void )
{
CBasePlayer* pOwner = ToBasePlayer( GetOwner() );
Assert( pOwner );
//Can't throw last knife
if ( pOwner->GetAmmoCount(GetPrimaryAmmoType()) <= 0 )
{
m_flNextSecondaryAttack = gpGlobals->curtime + 0.1f;
return;
}
#ifndef CLIENT_DLL
CDHLProjectile* pKnife = (CDHLProjectile*)(CreateEntityByName( "dhl_projectile" ));
Assert( pKnife );
pKnife->SetOwnerEntity( pOwner );
pKnife->Spawn();
//This is just an easy way of getting an eye vector, there isn't really any autoaim in MP
Vector vecDir = pOwner->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT );
//HACK - move it forward so it doesn't appear to spawn inside the player's face
Vector vecSrc = pOwner->Weapon_ShootPosition() + ( vecDir * 6.0f );
pKnife->Fire( vecSrc, vecDir * 1232.0f /*70mph*/, GetHL2MPWpnData().m_iPlayerDamage, this, pOwner, -1 );
if ( dhl_flamingknives.GetBool() )
pKnife->Ignite( 30.0f, false );
#endif
//Make sure this is done after the call to Fire()
int iAmmo = pOwner->GetAmmoCount(GetPrimaryAmmoType());
pOwner->RemoveAmmo( 1, GetPrimaryAmmoType() );
if ( iAmmo <= 0 )
{
AddEffects( EF_NODRAW );
#ifndef CLIENT_DLL
pOwner->Weapon_Drop( this, NULL, NULL );
Remove();
#endif
}
else
{
SendWeaponAnim( ACT_VM_THROW ); //Need to be able to predict this
pOwner->SetAnimation( PLAYER_ATTACK1 ); //Use the primary attack anim for now
ToHL2MPPlayer(pOwner)->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
m_flNextSecondaryAttack = gpGlobals->curtime + GetFireRate();
}
/*IPhysicsObject* pPhysObj = VPhysicsGetObject();
if ( pPhysObj )
{
pPhysObj->Sleep();
pPhysObj->EnableMotion( false );
pPhysObj->EnableCollisions( false );
}
m_bAllowPickup = false;*/
}
示例5: GetFireRate
//-----------------------------------------------------------------------------
// Purpose: Place the combat object
//-----------------------------------------------------------------------------
void CWeaponBaseCombatObject::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = dynamic_cast<CBaseTFPlayer*>((CBaseEntity*)GetOwner());
if ( !pPlayer )
return;
if ( pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return;
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
Vector vecPlaceOrigin;
QAngle angPlaceAngles;
if ( GetPlacePosition( pPlayer, &vecPlaceOrigin, &angPlaceAngles ) == false )
{
WeaponSound( DOUBLE );
return;
}
// Place the combat object
PlaceCombatObject( pPlayer, vecPlaceOrigin, angPlaceAngles );
WeaponSound( SINGLE );
pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
// If I'm now out of ammo, switch away
if ( !HasPrimaryAmmo() )
{
pPlayer->SelectLastItem();
}
}
示例6: ToBasePlayer
//-----------------------------------------------------------------------------
// Purpose: Spawn a grenade with no velocity and a timer of 0
//-----------------------------------------------------------------------------
void CGEWeaponGrenade::ExplodeInHand( void )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
return;
#ifndef CLIENT_DLL
Vector vecEye = pPlayer->EyePosition();
CGEGrenade *pGrenade = (CGEGrenade *)CBaseEntity::Create( "npc_grenade", vecEye, vec3_angle, NULL );
if ( pGrenade )
{
pGrenade->SetThrower( GetOwner() );
pGrenade->SetOwnerEntity( GetOwner() );
pGrenade->SetSourceWeapon(this);
pGrenade->SetVelocity( 0, NULL );
pGrenade->m_bHitSomething = true; //I'm not gonna just give it to you!
pGrenade->SetDamage( GetGEWpnData().m_iDamage );
pGrenade->SetDamageRadius( GetGEWpnData().m_flDamageRadius );
pGrenade->SetTimer( 0 );
}
#endif
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
// Remove the grenade from our ammo pool
pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
}
示例7: OnSerpentine
void Sinkhole_Top::OnSerpentine(DispenseList& dispenseList)
{
for (auto& throwableQuantity : dispenseList)
{
int amount = throwableQuantity->GetQuantity();
int total = amount;
// Shoot a number proportional to the total number being shot out. This will reduce times for large amounts of coins to a maximum number of shot
const int maxPerShot = (amount / k_MultishotQuantityThreshold) + 1;
int launchAmount = amount;
if (launchAmount > maxPerShot)
launchAmount = maxPerShot;
int slotNum = 0;
int n = m_SingleShotTicker/GetFireRate() % (12*2);
slotNum = (n < 12) ?
n :
((12*2)-1) - n;
Position startOffset = Position(2*TILE_SIZE, 3*TILE_SIZE);
Position start = Position(x + startOffset.x, y + startOffset.y);
Position launchPos(start.x + slotNum*TILE_SIZE/2, start.y);
throwableQuantity->Throw(launchPos, std::bind(&Sinkhole_Top::GetLaunchTo, this), launchAmount);
amount -= launchAmount;
}
}
示例8: ToBasePlayer
//-----------------------------------------------------------------------------
// Purpose: Allows firing as fast as button is pressed
//-----------------------------------------------------------------------------
void CWeaponMosinNagant::ItemPostFrame( void )
{
BaseClass::ItemPostFrame();
if ( m_bInReload )
return;
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner == NULL )
return;
if ( pOwner->m_nButtons & IN_ATTACK2 )
{
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
}
if ( ( pOwner->m_nButtons & IN_ATTACK ) && ( m_flNextPrimaryAttack < gpGlobals->curtime ) && ( m_iClip1 <= 0 ) )
{
DryFire();
}
#ifdef CLIENT_DLL
if ( m_bInZoom ) //Can't let them switch to third person
{
if ( ::input->CAM_IsThirdPerson() )
{
::input->CAM_ToFirstPerson();
m_bWantsThirdPerson = !m_bWantsThirdPerson;
}
}
#endif
}
示例9: switch
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CHLSelectFireMachineGun::PrimaryAttack( void )
{
if (m_bFireOnEmpty)
{
return;
}
switch( m_iFireMode )
{
case FIREMODE_FULLAUTO:
BaseClass::PrimaryAttack();
// Msg("%.3f\n", m_flNextPrimaryAttack.Get() );
SetWeaponIdleTime( gpGlobals->curtime + 3.0f );
break;
case FIREMODE_3RNDBURST:
m_iBurstSize = GetBurstSize();
// Call the think function directly so that the first round gets fired immediately.
BurstThink();
SetThink( &CHLSelectFireMachineGun::BurstThink );
m_flNextPrimaryAttack = gpGlobals->curtime + GetBurstCycleRate();
m_flNextSecondaryAttack = gpGlobals->curtime + GetBurstCycleRate();
// Pick up the rest of the burst through the think function.
SetNextThink( gpGlobals->curtime + GetFireRate() );
break;
}
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner )
{
m_iPrimaryAttacks++;
gamestats->Event_WeaponFired( pOwner, true, GetClassname() );
}
}
示例10: WeaponSound
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponCombatPlasmaGrenadeLauncher::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
if (!pPlayer)
return;
WeaponSound(SINGLE);
// Fire the bullets
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
PlayAttackAnimation( GetPrimaryAttackActivity() );
// Launch the grenade
Vector vecForward;
pPlayer->EyeVectors( &vecForward );
Vector vecOrigin = pPlayer->EyePosition();
vecOrigin += (vecForward);
#if !defined( CLIENT_DLL )
float flSpeed = 1200;
CGrenadeAntiPersonnel* pGrenade = CGrenadeAntiPersonnel::Create(vecOrigin, vecForward * flSpeed, pPlayer );
pGrenade->SetModel( "models/weapons/w_grenade.mdl" );
pGrenade->SetBounceSound( "PlasmaGrenade.Bounce" );
pGrenade->SetDamage( weapon_combat_plasmagrenadelauncher_damage.GetFloat() );
pGrenade->SetDamageRadius( weapon_combat_plasmagrenadelauncher_radius.GetFloat() );
pGrenade->SetExplodeOnContact( true );
#endif
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
m_iClip1 = m_iClip1 - 1;
}
示例11: GetCommander
void CASW_Weapon_Freeze_Grenades::DelayedAttack( void )
{
m_bShotDelayed = false;
CASW_Player *pPlayer = GetCommander();
if ( !pPlayer )
return;
CASW_Marine *pMarine = GetMarine();
if ( !pMarine || pMarine->GetWaterLevel() == 3 )
return;
#ifndef CLIENT_DLL
Vector vecSrc = pMarine->GetOffhandThrowSource();
Vector vecDest = pPlayer->GetCrosshairTracePos();
Vector newVel = UTIL_LaunchVector( vecSrc, vecDest, GetThrowGravity() ) * 28.0f;
float fGrenadeRadius = GetBoomRadius( pMarine );
if (asw_debug_marine_damage.GetBool())
{
Msg( "Freeze grenade radius = %f \n", fGrenadeRadius );
}
pMarine->GetMarineSpeech()->Chatter( CHATTER_GRENADE );
// freeze aliens completely, plus the freeze duration
float flFreezeAmount = 1.0f + MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_GRENADES, ASW_MARINE_SUBSKILL_GRENADE_FREEZE_DURATION);
if (ASWGameRules())
ASWGameRules()->m_fLastFireTime = gpGlobals->curtime;
CASW_Grenade_Freeze *pGrenade = CASW_Grenade_Freeze::Freeze_Grenade_Create(
1.0f,
flFreezeAmount,
fGrenadeRadius,
0,
vecSrc, pMarine->EyeAngles(), newVel, AngularImpulse(0,0,0), pMarine, this );
if ( pGrenade )
{
pGrenade->SetGravity( GetThrowGravity() );
pGrenade->SetExplodeOnWorldContact( true );
}
#endif
// decrement ammo
m_iClip1 -= 1;
#ifndef CLIENT_DLL
DestroyIfEmpty( true );
#endif
m_flSoonestPrimaryAttack = gpGlobals->curtime + ASW_FLARES_FASTEST_REFIRE_TIME;
if (m_iClip1 > 0) // only force the fire wait time if we have ammo for another shot
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
else
m_flNextPrimaryAttack = gpGlobals->curtime;
}
示例12: GetFireRate
void CWeaponUzi::PrimaryAttack( void )
{
BaseClass::PrimaryAttack();
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
//BP muzzlefash de la mort
/*Vector vecShootOrigin;
QAngle angShootDir;
GetAttachment(LookupAttachment("muzzle"), vecShootOrigin, angShootDir);
DispatchParticleEffect("muzzleflash_final_uzi", vecShootOrigin, angShootDir);*/
/*if(!GetOwner()->IsAlive())
ToBasePlayer( GetOwner() )->DoMuzzleFlash();*/
#define EASY_DAMPEN 0.5f
#define MAX_VERTICAL_KICK 1.0f //Degrees
#define SLIDE_LIMIT 2.0f //Seconds
//Get the view kick
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if ( pPlayer == NULL )
return;
//pPlayer->DoMuzzleFlash();
Vector vForward, vRight, vUp;
pPlayer->EyeVectors( &vForward, &vRight, &vUp );
Vector vecShootOrigin;
QAngle angShootDir;
GetAttachment(LookupAttachment("muzzle"), vecShootOrigin, angShootDir);
#ifdef CLIENT_DLL
Vector muzzlePoint = pPlayer->Weapon_ShootPosition() + vForward * 18.0f + vRight * 6.0f + vUp * -3.0f;
#else
Vector muzzlePoint = vecShootOrigin;
#endif
DispatchParticleEffect("muzzleflash_final_uzi", muzzlePoint, angShootDir);
#ifdef CLIENT_DLL
dlight_t *el = effects->CL_AllocDlight( LIGHT_INDEX_MUZZLEFLASH + index );
el->origin = muzzlePoint;
el->radius = random->RandomInt( 32, 64 );
el->decay = el->radius / 0.05f;
el->die = gpGlobals->curtime + 0.2f;
el->color.r = 255;
el->color.g = 192;
el->color.b = 64;
el->color.exponent = 5;
#endif
DoMachineGunKick( pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT );
}
示例13: GetCommander
void CASW_Weapon_Bait::DelayedAttack()
{
m_bShotDelayed = false;
CASW_Player *pPlayer = GetCommander();
if ( !pPlayer )
return;
CASW_Marine *pMarine = GetMarine();
if ( !pMarine || pMarine->GetWaterLevel() == 3 )
return;
// sets the animation on the marine holding this weapon
//pMarine->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL
Vector vecSrc = pMarine->GetOffhandThrowSource();
AngularImpulse rotSpeed(0,0,720);
Vector vecDest = pPlayer->GetCrosshairTracePos();
Vector newVel = UTIL_LaunchVector( vecSrc, vecDest, GetThrowGravity() ) * 28.0f;
CASW_Bait *pEnt = CASW_Bait::Bait_Create( vecSrc, QAngle(90,0,0), newVel, rotSpeed, pMarine );
if ( pEnt )
{
float flDuration = pEnt->GetDuration();
//CALL_ATTRIB_HOOK_FLOAT( flDuration, mod_duration );
pEnt->SetDuration( flDuration );
pEnt->SetGravity( GetThrowGravity() );
}
#endif
// decrement ammo
m_iClip1 -= 1;
#ifndef CLIENT_DLL
DestroyIfEmpty( true );
#endif
m_flSoonestPrimaryAttack = gpGlobals->curtime + ASW_BAIT_FASTEST_REFIRE_TIME;
if (m_iClip1 > 0) // only force the fire wait time if we have ammo for another shot
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
else
m_flNextPrimaryAttack = gpGlobals->curtime;
}
示例14: ToBasePlayer
void CWeaponSAA::ItemPostFrame( void )
{
BaseClass::ItemPostFrame();
if ( m_bInReload )
return;
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner == NULL )
return;
if ( pOwner->m_nButtons & IN_ATTACK2 )
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
if ( ( pOwner->m_nButtons & IN_ATTACK ) && ( m_flNextPrimaryAttack < gpGlobals->curtime ) && ( m_iClip1 <= 0 ) )
DryFire();
}
示例15: SetThink
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CHLSelectFireMachineGun::BurstThink( void )
{
CHLMachineGun::PrimaryAttack();
m_iBurstSize--;
if( m_iBurstSize == 0 )
{
// The burst is over!
SetThink(NULL);
// idle immediately to stop the firing animation
SetWeaponIdleTime( gpGlobals->curtime );
return;
}
SetNextThink( gpGlobals->curtime + GetFireRate() );
}