本文整理匯總了C++中GetActiveWeapon函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetActiveWeapon函數的具體用法?C++ GetActiveWeapon怎麽用?C++ GetActiveWeapon使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetActiveWeapon函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetActiveWeapon
//=========================================================
// Traduce una animación.
//=========================================================
Activity CIN_Player::TranslateActivity(Activity baseAct, bool *pRequired)
{
// Esta será la nueva animación.
Activity translated = baseAct;
// El jugador tiene una arma, usar la animación con esa arma.
if ( GetActiveWeapon() )
translated = GetActiveWeapon()->ActivityOverride(baseAct, pRequired);
// Estamos desarmados, verificar si existe una animación.
else if ( unarmedActtable )
{
acttable_t *pTable = unarmedActtable;
int actCount = ARRAYSIZE(unarmedActtable);
for ( int i = 0; i < actCount; i++, pTable++ )
{
if ( baseAct == pTable->baseAct )
translated = (Activity)pTable->weaponAct;
}
}
else if ( pRequired )
*pRequired = false;
// @DEBUG: Guardamos la animación nueva para poder usarla en la información de depuración: anim_showstatelog
#ifndef CLIENT_DLL
//DevMsg("[ANIM] %s \r\n", ActivityList_NameForIndex(translated));
#endif
return translated;
}
示例2: OnKilledNPC
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CNPC_Monk::OnKilledNPC( CBaseCombatCharacter *pKilled )
{
if ( !pKilled )
{
return;
}
if ( pKilled->Classify() == CLASS_ZOMBIE )
{
// Don't speak if the gun is empty, cause grigori will want to speak while he's reloading.
if ( GetActiveWeapon() )
{
if ( GetActiveWeapon()->UsesPrimaryAmmo() && !GetActiveWeapon()->HasPrimaryAmmo() )
{
// Gun is empty. I'm about to reload.
if( m_iNumZombies >= 2 )
{
// Don't talk about killing a single zombie if there are more coming.
// the reload behavior will say "come to me, children", etc.
return;
}
}
}
if( m_iNumZombies == 1 || random->RandomInt( 1, 3 ) == 1 )
{
SpeakIfAllowed( TLK_ENEMY_DEAD );
}
}
}
示例3: Weapon_OwnsThisType
void CHL2MP_Player::Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector *pvecTarget, const Vector *pVelocity )
{
//Drop a grenade if it's primed.
if ( GetActiveWeapon() )
{
CBaseCombatWeapon *pGrenade = Weapon_OwnsThisType("weapon_frag");
if ( GetActiveWeapon() == pGrenade )
{
if ( ( m_nButtons & IN_ATTACK ) || (m_nButtons & IN_ATTACK2) )
{
DropPrimedFragGrenade( this, pGrenade );
return;
}
//DHL - Skillet
else
{
pGrenade->Drop( *pVelocity );
return;
}
}
}
BaseClass::Weapon_Drop( pWeapon, pvecTarget, pVelocity );
}
示例4: Weapon_CanSwitchTo
bool CSDKPlayer::Weapon_CanSwitchTo( CBaseCombatWeapon *pWeapon )
{
if (IsPlayer())
{
CBasePlayer *pPlayer = (CBasePlayer *)this;
#if !defined( CLIENT_DLL )
IServerVehicle *pVehicle = pPlayer->GetVehicle();
#else
IClientVehicle *pVehicle = pPlayer->GetVehicle();
#endif
if (pVehicle && !pPlayer->UsingStandardWeaponsInVehicle())
return false;
}
if ( !pWeapon->CanDeploy() )
return false;
if ( GetActiveWeapon() )
{
if ( !GetActiveWeapon()->CanHolster() )
return false;
}
return true;
}
示例5: switch
void CNPC_Monk::StartTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_RELOAD:
{
if ( GetActiveWeapon() && GetActiveWeapon()->HasPrimaryAmmo() )
{
// Don't reload if you have done so while moving (See BACK_AWAY_AND_RELOAD schedule).
TaskComplete();
return;
}
if( m_iNumZombies >= 2 && random->RandomInt( 1, 3 ) == 1 )
{
SpeakIfAllowed( TLK_ATTACKING );
}
Activity reloadGesture = TranslateActivity( ACT_GESTURE_RELOAD );
if ( reloadGesture != ACT_INVALID && IsPlayingGesture( reloadGesture ) )
{
ResetIdealActivity( ACT_IDLE );
return;
}
BaseClass::StartTask( pTask );
}
break;
default:
BaseClass::StartTask( pTask );
break;
}
}
示例6: GetActiveWeapon
void C_HL2MP_Player::DoImpactEffect( trace_t &tr, int nDamageType )
{
if ( GetActiveWeapon() )
{
GetActiveWeapon()->DoImpactEffect( tr, nDamageType );
return;
}
BaseClass::DoImpactEffect( tr, nDamageType );
}
示例7: GetAbsOrigin
bool CNPC_Monk::IsValidEnemy( CBaseEntity *pEnemy )
{
if ( BaseClass::IsValidEnemy( pEnemy ) && GetActiveWeapon() )
{
float flDist;
flDist = ( GetAbsOrigin() - pEnemy->GetAbsOrigin() ).Length();
if( flDist <= GetActiveWeapon()->m_fMaxRange1 )
return true;
}
return false;
}
示例8: SetCondition
//-----------------------------------------------------------------------------
// Purpose: check ammo
//-----------------------------------------------------------------------------
void CAI_BaseHumanoid::CheckAmmo( void )
{
BaseClass::CheckAmmo();
// FIXME: put into GatherConditions()?
// FIXME: why isn't this a baseclass function?
if (!GetActiveWeapon())
return;
// Don't do this while holstering / unholstering
if ( IsWeaponStateChanging() )
return;
if (GetActiveWeapon()->UsesPrimaryAmmo())
{
if (!GetActiveWeapon()->HasPrimaryAmmo() )
{
SetCondition(COND_NO_PRIMARY_AMMO);
}
else if (GetActiveWeapon()->UsesClipsForAmmo1() && GetActiveWeapon()->Clip1() < (GetActiveWeapon()->GetMaxClip1() / 4 + 1))
{
// don't check for low ammo if you're near the max range of the weapon
SetCondition(COND_LOW_PRIMARY_AMMO);
}
}
if (!GetActiveWeapon()->HasSecondaryAmmo() )
{
if ( GetActiveWeapon()->UsesClipsForAmmo2() )
{
SetCondition(COND_NO_SECONDARY_AMMO);
}
}
}
示例9: GetActiveWeapon
Activity CDODPlayer::TranslateActivity( Activity baseAct, bool *pRequired /* = NULL */ )
{
Activity translated = baseAct;
if ( GetActiveWeapon() )
{
translated = GetActiveWeapon()->ActivityOverride( baseAct, pRequired );
}
else if (pRequired)
{
*pRequired = false;
}
return translated;
}
示例10: GetActiveWeapon
void CHL2MP_Player::FireBullets ( const FireBulletsInfo_t &info )
{
#ifndef GE_DLL
// Move other players back to history positions based on local player's lag
lagcompensation->StartLagCompensation( this, this->GetCurrentCommand() );
FireBulletsInfo_t modinfo = info;
CWeaponHL2MPBase *pWeapon = dynamic_cast<CWeaponHL2MPBase *>( GetActiveWeapon() );
if ( pWeapon )
{
modinfo.m_iPlayerDamage = modinfo.m_iDamage = pWeapon->GetHL2MPWpnData().m_iPlayerDamage;
}
NoteWeaponFired();
BaseClass::FireBullets( modinfo );
// Move other players back to history positions based on local player's lag
lagcompensation->FinishLagCompensation( this );
#else
BaseClass::FireBullets( info );
#endif
}
示例11: GetNavigator
bool CAI_BaseHumanoid::OnMoveBlocked( AIMoveResult_t *pResult )
{
if ( *pResult != AIMR_BLOCKED_NPC && GetNavigator()->GetBlockingEntity() && !GetNavigator()->GetBlockingEntity()->IsNPC() )
{
CBaseEntity *pBlocker = GetNavigator()->GetBlockingEntity();
float massBonus = ( IsNavigationUrgent() ) ? 40.0 : 0;
if ( pBlocker->GetMoveType() == MOVETYPE_VPHYSICS &&
pBlocker != GetGroundEntity() &&
!pBlocker->IsNavIgnored() &&
!dynamic_cast<CBasePropDoor *>(pBlocker) &&
pBlocker->VPhysicsGetObject() &&
pBlocker->VPhysicsGetObject()->IsMoveable() &&
( pBlocker->VPhysicsGetObject()->GetMass() <= 35.0 + massBonus + 0.1 ||
( pBlocker->VPhysicsGetObject()->GetMass() <= 50.0 + massBonus + 0.1 && IsSmall( pBlocker ) ) ) )
{
DbgNavMsg1( this, "Setting ignore on object %s", pBlocker->GetDebugName() );
pBlocker->SetNavIgnore( 2.5 );
}
#if 0
else
{
CPhysicsProp *pProp = dynamic_cast<CPhysicsProp*>( pBlocker );
if ( pProp && pProp->GetHealth() && pProp->GetExplosiveDamage() == 0.0 && GetActiveWeapon() && !GetActiveWeapon()->ClassMatches( "weapon_rpg" ) )
{
Msg( "!\n" );
// Destroy!
}
}
#endif
}
return BaseClass::OnMoveBlocked( pResult );
}
示例12: PlayerUse
//-----------------------------------------------------------------------------
// Purpose: Called every usercmd by the player PreThink
//-----------------------------------------------------------------------------
void CBasePlayer::ItemPreFrame()
{
// Handle use events
PlayerUse();
CBaseCombatWeapon *pActive = GetActiveWeapon();
// Allow all the holstered weapons to update
for ( int i = 0; i < WeaponCount(); ++i )
{
CBaseCombatWeapon *pWeapon = GetWeapon( i );
if ( pWeapon == NULL )
continue;
if ( pActive == pWeapon )
continue;
pWeapon->ItemHolsterFrame();
}
if ( gpGlobals->curtime < m_flNextAttack )
return;
if (!pActive)
return;
#if defined( CLIENT_DLL )
// Not predicting this weapon
if ( !pActive->IsPredicted() )
return;
#endif
pActive->ItemPreFrame();
}
示例13: EmitSound
//-----------------------------------------------------------------------------
// Purpose
//-----------------------------------------------------------------------------
void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
{
// We override sound requests so that we can play them locally on the owning player
if ( ( event == AE_CL_PLAYSOUND ) || ( event == CL_EVENT_SOUND ) )
{
// Only do this if we're owned by someone
if ( GetOwner() != NULL )
{
CLocalPlayerFilter filter;
EmitSound( filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin() );
return;
}
}
// Otherwise pass the event to our associated weapon
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
// NVNT notify the haptics system of our viewmodel's event
if ( haptics )
haptics->ProcessHapticEvent(4,"Weapons",pWeapon->GetName(),"AnimationEvents",VarArgs("%i",event));
bool bResult = pWeapon->OnFireEvent( this, origin, angles, event, options );
if ( !bResult )
{
BaseClass::FireEvent( origin, angles, event, options );
}
}
}
示例14: GetLastWeapon
CBaseCombatWeapon* CSDKPlayer::GetLastWeapon()
{
// This is pretty silly, but I'd rather mess around with stock Valve code as little as possible.
#ifdef CLIENT_DLL
CBaseCombatWeapon* pLastWeapon = BaseClass::GetLastWeapon();
#else
CBaseCombatWeapon* pLastWeapon = BaseClass::Weapon_GetLast();
#endif
if (pLastWeapon && pLastWeapon != GetActiveWeapon())
return pLastWeapon;
CWeaponSDKBase* pHeaviest = NULL;
CWeaponSDKBase* pBrawl = NULL;
for (int i = 0; i < WeaponCount(); i++)
{
if (!GetWeapon(i))
continue;
if (GetWeapon(i) == GetActiveWeapon())
continue;
CWeaponSDKBase* pSDKWeapon = dynamic_cast<CWeaponSDKBase*>(GetWeapon(i));
if (!pSDKWeapon)
continue;
if (pSDKWeapon->GetWeaponID() == SDK_WEAPON_BRAWL)
{
pBrawl = pSDKWeapon;
continue;
}
if (!pHeaviest)
{
pHeaviest = pSDKWeapon;
continue;
}
if (pHeaviest->GetWeight() < pSDKWeapon->GetWeight())
pHeaviest = pSDKWeapon;
}
if (!pHeaviest)
pHeaviest = pBrawl;
return pHeaviest;
}
示例15: VPROF
//-----------------------------------------------------------------------------
// Purpose: Called every usercmd by the player PostThink
//-----------------------------------------------------------------------------
void CBasePlayer::ItemPostFrame()
{
VPROF( "CBasePlayer::ItemPostFrame" );
// Put viewmodels into basically correct place based on new player origin
CalcViewModelView( EyePosition(), EyeAngles() );
// check if the player is using something
if ( m_hUseEntity != NULL )
{
#if !defined( CLIENT_DLL )
ImpulseCommands();// this will call playerUse
#endif
return;
}
if ( gpGlobals->curtime < m_flNextAttack )
{
if ( GetActiveWeapon() )
{
GetActiveWeapon()->ItemBusyFrame();
}
}
else
{
if ( GetActiveWeapon() )
{
#if defined( CLIENT_DLL )
// Not predicting this weapon
if ( GetActiveWeapon()->IsPredicted() )
#endif
{
GetActiveWeapon()->ItemPostFrame( );
}
}
}
#if !defined( CLIENT_DLL )
ImpulseCommands();
#else
// NOTE: If we ever support full impulse commands on the client,
// remove this line and call ImpulseCommands instead.
m_nImpulse = 0;
#endif
}