本文整理汇总了C++中CBaseCombatCharacter::SetNextAttack方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatCharacter::SetNextAttack方法的具体用法?C++ CBaseCombatCharacter::SetNextAttack怎么用?C++ CBaseCombatCharacter::SetNextAttack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatCharacter
的用法示例。
在下文中一共展示了CBaseCombatCharacter::SetNextAttack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyWeaponSwitchTime
void CASW_Weapon::ApplyWeaponSwitchTime()
{
// play weaponswitch sound
if (ASWGameRules() && ASWGameRules()->GetGameState() >= ASW_GS_INGAME)
{
WeaponSound(SPECIAL3);
}
float flSequenceEndTime = gpGlobals->curtime + ASW_WEAPON_SWITCH_TIME;
CBaseCombatCharacter *pOwner = GetOwner();
if (pOwner)
pOwner->SetNextAttack( flSequenceEndTime );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = flSequenceEndTime;
m_bSwitchingWeapons = true;
}
示例2: ItemBusyFrame
void CASW_Weapon::ItemBusyFrame( void )
{
CASW_Marine* pMarine = GetMarine();
if ( !pMarine )
return;
bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1;
GetButtons(bAttack1, bAttack2, bReload, bOldReload, bOldAttack1 );
// check for clearing our weapon switching bool
if (m_bSwitchingWeapons && gpGlobals->curtime > m_flNextPrimaryAttack)
{
m_bSwitchingWeapons = false;
}
// check for clearing our firing bool from reloading
if (m_bInReload && gpGlobals->curtime > m_fReloadClearFiringTime)
{
ClearIsFiring();
}
if ( (bReload && !bOldReload) && UsesClipsForAmmo1() && asw_fast_reload_enabled.GetBool() )
{
if ( m_bInReload )
{
// check for a fast reload
//Msg("%f Check for fast reload while busy\n", gpGlobals->curtime);
if (gpGlobals->curtime >= m_fFastReloadStart && gpGlobals->curtime <= m_fFastReloadEnd)
{
// todo: reduce next attack time
m_fFastReloadEnd = 0;
m_fFastReloadStart = 0;
CBaseCombatCharacter *pOwner = GetOwner();
if ( pOwner )
{
float flSucceedDelay = gpGlobals->curtime + 0.5f;
pOwner->SetNextAttack( flSucceedDelay );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = flSucceedDelay;
}
// TODO: hook up anim
//pMarine->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_SUCCEED );
DispatchParticleEffect( "fast_reload", PATTACH_POINT_FOLLOW, this, "muzzle" );
pMarine->m_flPreventLaserSightTime = gpGlobals->curtime + 2.5f;
#ifdef GAME_DLL
pMarine->m_nFastReloadsInARow++;
IGameEvent * event = gameeventmanager->CreateEvent( "fast_reload" );
if ( event )
{
event->SetInt( "marine", pMarine->entindex() );
event->SetInt( "reloads", pMarine->m_nFastReloadsInARow );
gameeventmanager->FireEvent( event );
}
if ( pMarine->m_nFastReloadsInARow >= 4 && pMarine->IsInhabited() )
{
if ( pMarine->GetMarineResource() )
{
pMarine->GetMarineResource()->m_bDidFastReloadsInARow = true;
}
if ( pMarine->GetCommander() )
{
pMarine->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_FAST_RELOADS_IN_A_ROW );
}
}
#endif
CSoundParameters params;
if ( !GetParametersForSound( "FastReload.Success", params, NULL ) )
return;
EmitSound_t playparams(params);
playparams.m_nPitch = params.pitch;
CASW_Player *pPlayer = GetCommander();
if ( pPlayer )
{
CSingleUserRecipientFilter filter( pMarine->GetCommander() );
if ( IsPredicted() && CBaseEntity::GetPredictionPlayer() )
{
filter.UsePredictionRules();
}
EmitSound(filter, entindex(), playparams);
}
//Msg("%f RELOAD SUCCESS! - bAttack1 = %d, bOldAttack1 = %d\n", gpGlobals->curtime, bAttack1, bOldAttack1 );
//Msg( "S: %f - %f - %f RELOAD SUCCESS! -- Progress = %f\n", gpGlobals->curtime, fFastStart, fFastEnd, flProgress );
#ifdef GAME_DLL
pMarine->GetMarineSpeech()->PersonalChatter(CHATTER_SELECTION);
#endif
m_bFastReloadSuccess = true;
m_bFastReloadFailure = false;
}
else if (m_fFastReloadStart != 0)
{
CSoundParameters params;
//.........这里部分代码省略.........
示例3: DefaultReload
bool CWeaponDODBase::DefaultReload( int iClipSize1, int iClipSize2, int iActivity )
{
CBaseCombatCharacter *pOwner = GetOwner();
if (!pOwner)
return false;
// If I don't have any spare ammo, I can't reload
if ( pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return false;
bool bReload = false;
// If you don't have clips, then don't try to reload them.
if ( UsesClipsForAmmo1() )
{
// need to reload primary clip?
int primary = min(iClipSize1 - m_iClip1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));
if ( primary != 0 )
{
bReload = true;
}
}
if ( UsesClipsForAmmo2() )
{
// need to reload secondary clip?
int secondary = min(iClipSize2 - m_iClip2, pOwner->GetAmmoCount(m_iSecondaryAmmoType));
if ( secondary != 0 )
{
bReload = true;
}
}
if ( !bReload )
return false;
CDODPlayer *pPlayer = GetDODPlayerOwner();
if ( pPlayer )
{
#ifdef CLIENT_DLL
PlayWorldReloadSound( pPlayer );
#else
pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
#endif
}
SendWeaponAnim( iActivity );
// Play the player's reload animation
if ( pOwner->IsPlayer() )
{
( ( CBasePlayer * )pOwner)->SetAnimation( PLAYER_RELOAD );
}
float flSequenceEndTime = gpGlobals->curtime + SequenceDuration();
pOwner->SetNextAttack( flSequenceEndTime );
m_flNextPrimaryAttack = m_flNextSecondaryAttack = flSequenceEndTime;
m_bInReload = true;
return true;
}