本文整理汇总了C++中CTFPlayer::GetActiveTFWeapon方法的典型用法代码示例。如果您正苦于以下问题:C++ CTFPlayer::GetActiveTFWeapon方法的具体用法?C++ CTFPlayer::GetActiveTFWeapon怎么用?C++ CTFPlayer::GetActiveTFWeapon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTFPlayer
的用法示例。
在下文中一共展示了CTFPlayer::GetActiveTFWeapon方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleDucking
//-----------------------------------------------------------------------------
// Purpose:
// Input : *idealActivity -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CTFPlayerAnimState::HandleDucking( Activity &idealActivity )
{
if (GetBasePlayer()->GetFlags() & FL_DUCKING)
{
if ( GetOuterXYSpeed() < MOVING_MINIMUM_SPEED || m_pTFPlayer->m_Shared.IsLoser() )
{
idealActivity = ACT_MP_CROUCH_IDLE;
if ( m_pTFPlayer->m_Shared.InCond( TF_COND_AIMING ) || m_flHoldDeployedPoseUntilTime > gpGlobals->curtime )
{
idealActivity = ACT_MP_CROUCH_DEPLOYED_IDLE;
}
}
else
{
idealActivity = ACT_MP_CROUCHWALK;
if ( m_pTFPlayer->m_Shared.InCond( TF_COND_AIMING ) )
{
// Don't do this for the heavy! we don't usually let him deployed crouch walk
bool bIsMinigun = false;
CTFPlayer *pPlayer = GetTFPlayer();
if ( pPlayer && pPlayer->GetActiveTFWeapon() )
{
bIsMinigun = ( pPlayer->GetActiveTFWeapon()->GetWeaponID() == TF_WEAPON_MINIGUN );
}
if ( !bIsMinigun )
{
idealActivity = ACT_MP_CROUCH_DEPLOYED;
}
}
}
return true;
}
return false;
}
示例2: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudMenuEngyBuild::ShouldDraw( void )
{
CTFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pPlayer )
return false;
CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
if ( !pWpn )
return false;
// Don't show the menu for first person spectator
if ( pPlayer != pWpn->GetOwner() )
return false;
if ( !CHudElement::ShouldDraw() )
return false;
return ( pWpn->GetWeaponID() == TF_WEAPON_PDA_ENGINEER_BUILD );
}
示例3: ShouldDraw
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CHudMenuSpyDisguise::ShouldDraw( void )
{
CTFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pPlayer )
return false;
CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
if ( !pWpn )
return false;
// Don't show the menu for first person spectator
if ( pPlayer != pWpn->GetOwner() )
return false;
if ( pPlayer->m_Shared.InCond( TF_COND_TAUNTING ) )
return false;
return ( pWpn->GetWeaponID() == TF_WEAPON_PDA_SPY );
}
示例4: Smack
// -----------------------------------------------------------------------------
// Purpose:
// Note: Think function to delay the impact decal until the animation is finished
// playing.
// -----------------------------------------------------------------------------
void CTFWeaponBaseMelee::Smack( void )
{
trace_t trace;
CBasePlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
#if !defined (CLIENT_DLL)
// Move other players back to history positions based on local player's lag
lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
// We hit, setup the smack.
if ( DoSwingTrace( trace ) )
{
// Hit sound - immediate.
if( trace.m_pEnt->IsPlayer() )
{
WeaponSound( MELEE_HIT );
}
else
{
WeaponSound( MELEE_HIT_WORLD );
}
// Get the current player.
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return;
Vector vecForward;
AngleVectors( pPlayer->EyeAngles(), &vecForward );
Vector vecSwingStart = pPlayer->Weapon_ShootPosition();
Vector vecSwingEnd = vecSwingStart + vecForward * 48;
#ifndef CLIENT_DLL
// Do Damage.
int iCustomDamage = TF_DMG_CUSTOM_NONE;
float flDamage = GetMeleeDamage( trace.m_pEnt, iCustomDamage );
int iDmgType = DMG_BULLET | DMG_NEVERGIB | DMG_CLUB;
if ( IsCurrentAttackACrit() )
{
// TODO: Not removing the old critical path yet, but the new custom damage is marking criticals as well for melee now.
iDmgType |= DMG_CRITICAL;
}
CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
CTFUbersaw *pUbersaw = dynamic_cast<CTFUbersaw*>(pWpn);
CWeaponMedigun *pMedigun = static_cast<CWeaponMedigun*>(pPlayer->Weapon_OwnsThisID(TF_WEAPON_MEDIGUN));
if (pMedigun && pUbersaw)
{
if(trace.m_pEnt->IsPlayer() && trace.m_pEnt->GetTeamNumber() != pPlayer->GetTeamNumber())
{
pMedigun->AddCharge();
}
}
CWeaponKritzkrieg *pKritzkrieg = static_cast<CWeaponKritzkrieg*>(pPlayer->Weapon_OwnsThisID(TF_WEAPON_KRITZKRIEG));
if (pKritzkrieg && pUbersaw)
{
if(trace.m_pEnt->IsPlayer() && trace.m_pEnt->GetTeamNumber() != pPlayer->GetTeamNumber())
{
pKritzkrieg->AddCharge();
}
}
CTakeDamageInfo info( pPlayer, pPlayer, flDamage, iDmgType, iCustomDamage );
CalculateMeleeDamageForce( &info, vecForward, vecSwingEnd, 1.0f / flDamage * tf_meleeattackforcescale.GetFloat() );
trace.m_pEnt->DispatchTraceAttack( info, vecForward, &trace );
ApplyMultiDamage();
OnEntityHit( trace.m_pEnt );
#endif
// Don't impact trace friendly players or objects
if ( trace.m_pEnt && trace.m_pEnt->GetTeamNumber() != pPlayer->GetTeamNumber() )
{
#ifdef CLIENT_DLL
UTIL_ImpactTrace( &trace, DMG_CLUB );
#endif
m_bConnected = true;
}
}
#if !defined (CLIENT_DLL)
lagcompensation->FinishLagCompensation( pPlayer );
#endif
}
示例5: MyTouch
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFDroppedWeapon::MyTouch( CBasePlayer *pPlayer )
{
bool bSuccess = false;
CTFPlayer *pTFPlayer = dynamic_cast<CTFPlayer *>( pPlayer );
if ( ValidTouch( pTFPlayer ) && pTFPlayer->IsPlayerClass( TF_CLASS_MERCENARY ) )
{
// Don't remove weapon while a player is standing over it.
SetThink( NULL );
#ifndef DM_WEAPON_BUCKET
int iSlot = m_Item.GetStaticData()->GetLoadoutSlot( TF_CLASS_MERCENARY );
CTFWeaponBase *pWeapon = (CTFWeaponBase *)pTFPlayer->GetEntityForLoadoutSlot( iSlot );
const char *pszWeaponName = m_Item.GetEntityName();
int iAmmoType = m_pWeaponInfo->iAmmoType;
if ( pWeapon )
{
if ( pWeapon->GetItemID() == m_Item.GetItemDefIndex() )
{
// Give however many ammo we have
if ( pTFPlayer->GiveAmmo( m_iAmmo, iAmmoType, true, TF_AMMO_SOURCE_AMMOPACK ) )
bSuccess = true;
}
else if ( !(pTFPlayer->m_nButtons & IN_ATTACK) && ( pTFPlayer->m_nButtons & IN_USE ) ) // Check Use button
{
// Drop a usable weapon
pTFPlayer->DropWeapon( pWeapon );
if ( pWeapon == pTFPlayer->GetActiveTFWeapon() )
{
pWeapon->Holster();
}
pTFPlayer->Weapon_Detach( pWeapon );
UTIL_Remove( pWeapon );
pWeapon = NULL;
}
else
{
pTFPlayer->m_Shared.SetDesiredWeaponIndex( m_Item.GetItemDefIndex() );
}
}
#else
CTFWeaponBase *pWeapon = pTFPlayer->Weapon_OwnsThisID( m_nWeaponID );
if ( pWeapon )
{
if ( pTFPlayer->GiveAmmo( 999, GetTFWeaponInfo( m_nWeaponID )->iAmmoType ) );
bSuccess = true;
}
#endif
if ( !pWeapon )
{
CTFWeaponBase *pNewWeapon = (CTFWeaponBase *)pTFPlayer->GiveNamedItem( pszWeaponName, 0, &m_Item );
if ( pNewWeapon )
{
pPlayer->SetAmmoCount( m_iAmmo, iAmmoType );
pNewWeapon->DefaultTouch( pPlayer );
if ( pPlayer == GetOwnerEntity() )
{
// If this is the same guy who dropped it restore old clip size to avoid exploiting swapping
// weapons for faster reload.
pNewWeapon->m_iClip1 = m_iClip;
}
pTFPlayer->m_Shared.SetDesiredWeaponIndex( -1 );
bSuccess = true;
}
}
if ( bSuccess )
{
CSingleUserRecipientFilter user( pPlayer );
user.MakeReliable();
UserMessageBegin( user, "ItemPickup" );
WRITE_STRING( GetClassname() );
MessageEnd();
pPlayer->EmitSound( "BaseCombatCharacter.AmmoPickup" );
}
}
return bSuccess;
}
示例6: TeleporterThink
//.........这里部分代码省略.........
hPlayersToKill.AddToTail( pEnts[i] );
}
continue;
}
if ( pEnts[i]->IsBaseObject() )
continue;
// Solid entities will prevent a teleport
if ( pEnts[i]->IsSolid() && pEnts[i]->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), MASK_ALL ) &&
g_pGameRules->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), pEnts[i]->GetCollisionGroup() ) )
{
// We're going to teleport into something solid. Abort & destroy this exit.
bClear = false;
}
}
}
if ( bClear )
{
// Telefrag all enemy players we've found
for ( int player = 0; player < hPlayersToKill.Count(); player++ )
{
CTakeDamageInfo info( this, pTeleportingPlayer, 1000, DMG_CRUSH, TF_DMG_TELEFRAG );
hPlayersToKill[player]->TakeDamage( info );
}
pTeleportingPlayer->Teleport( &newPosition, &(GetAbsAngles()), &vec3_origin );
// Unzoom if we are a sniper zoomed!
if ( ( pTeleportingPlayer->GetPlayerClass()->GetClassIndex() == TF_CLASS_SNIPER ) &&
pTeleportingPlayer->m_Shared.InCond( TF_COND_AIMING ) )
{
CTFWeaponBase *pWpn = pTeleportingPlayer->GetActiveTFWeapon();
if ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE )
{
CTFSniperRifle *pRifle = static_cast<CTFSniperRifle*>( pWpn );
pRifle->ToggleZoom();
}
}
pTeleportingPlayer->SetFOV( pTeleportingPlayer, 0, tf_teleporter_fov_time.GetFloat(), tf_teleporter_fov_start.GetInt() );
color32 fadeColor = {255,255,255,100};
UTIL_ScreenFade( pTeleportingPlayer, fadeColor, 0.25, 0.4, FFADE_IN );
}
else
{
DetonateObject();
}
}
SetState( TELEPORTER_STATE_RECEIVING_RELEASE );
m_flMyNextThink = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEIN_TIME );
}
break;
case TELEPORTER_STATE_RECEIVING_RELEASE:
{
CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get();
if ( pTeleportingPlayer )
{
int iTeam = GetBuilder() ? GetBuilder()->GetTeamNumber() : GetTeamNumber();
示例7: DoAnimationEvent
//-----------------------------------------------------------------------------
// Purpose:
// Input : event -
//-----------------------------------------------------------------------------
void CTFPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData )
{
Activity iGestureActivity = ACT_INVALID;
switch( event )
{
case PLAYERANIMEVENT_ATTACK_PRIMARY:
{
CTFPlayer *pPlayer = GetTFPlayer();
if ( !pPlayer )
return;
CTFWeaponBase *pWpn = pPlayer->GetActiveTFWeapon();
bool bIsMinigun = ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_MINIGUN );
bool bIsSniperRifle = ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE );
// Heavy weapons primary fire.
if ( bIsMinigun )
{
// Play standing primary fire.
iGestureActivity = ACT_MP_ATTACK_STAND_PRIMARYFIRE;
if ( m_bInSwim )
{
// Play swimming primary fire.
iGestureActivity = ACT_MP_ATTACK_SWIM_PRIMARYFIRE;
}
else if ( GetBasePlayer()->GetFlags() & FL_DUCKING )
{
// Play crouching primary fire.
iGestureActivity = ACT_MP_ATTACK_CROUCH_PRIMARYFIRE;
}
if ( !IsGestureSlotPlaying( GESTURE_SLOT_ATTACK_AND_RELOAD, TranslateActivity(iGestureActivity) ) )
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, iGestureActivity );
}
}
else if ( bIsSniperRifle && pPlayer->m_Shared.InCond( TF_COND_ZOOMED ) )
{
// Weapon primary fire, zoomed in
if ( GetBasePlayer()->GetFlags() & FL_DUCKING )
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE_DEPLOYED );
}
else
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE_DEPLOYED );
}
iGestureActivity = ACT_VM_PRIMARYATTACK;
// Hold our deployed pose for a few seconds
m_flHoldDeployedPoseUntilTime = gpGlobals->curtime + 2.0;
}
else
{
// Weapon primary fire.
if ( GetBasePlayer()->GetFlags() & FL_DUCKING )
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE );
}
else
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE );
}
iGestureActivity = ACT_VM_PRIMARYATTACK;
}
break;
}
case PLAYERANIMEVENT_VOICE_COMMAND_GESTURE:
{
if ( !IsGestureSlotActive( GESTURE_SLOT_ATTACK_AND_RELOAD ) )
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, (Activity)nData );
}
break;
}
case PLAYERANIMEVENT_ATTACK_SECONDARY:
{
// Weapon secondary fire.
if ( GetBasePlayer()->GetFlags() & FL_DUCKING )
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_SECONDARYFIRE );
}
else
{
RestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_SECONDARYFIRE );
}
iGestureActivity = ACT_VM_PRIMARYATTACK;
break;
}
//.........这里部分代码省略.........
示例8: MyTouch
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CWeaponSpawner::MyTouch(CBasePlayer *pPlayer)
{
bool bSuccess = false;
CTFPlayer *pTFPlayer = dynamic_cast<CTFPlayer *>(pPlayer);
if ( ValidTouch( pTFPlayer ) && pTFPlayer->IsPlayerClass( TF_CLASS_MERCENARY ) )
{
#ifndef DM_WEAPON_BUCKET
int iSlot = m_Item.GetStaticData()->GetLoadoutSlot( TF_CLASS_MERCENARY );
CTFWeaponBase *pWeapon = (CTFWeaponBase *)pTFPlayer->GetEntityForLoadoutSlot( iSlot );
const char *pszWeaponName = m_Item.GetEntityName();
int iAmmoType = m_pWeaponInfo->iAmmoType;
if ( pWeapon )
{
if ( pTFPlayer->ItemsMatch( pWeapon->GetItem(), &m_Item, pWeapon ) )
{
if ( pTFPlayer->GiveAmmo( pWeapon->GetInitialAmmo(), iAmmoType, true, TF_AMMO_SOURCE_AMMOPACK ) )
bSuccess = true;
}
else if ( !(pTFPlayer->m_nButtons & IN_ATTACK) &&
(pTFPlayer->m_nButtons & IN_USE || pWeapon->GetWeaponID() == TF_WEAPON_PISTOL) )
{
// Drop a usable weapon
pTFPlayer->DropWeapon( pWeapon );
// Check Use button, always replace pistol
if ( pWeapon == pTFPlayer->GetActiveTFWeapon() )
{
pWeapon->Holster();
}
pTFPlayer->Weapon_Detach( pWeapon );
UTIL_Remove( pWeapon );
pWeapon = NULL;
}
else
{
pTFPlayer->m_Shared.SetDesiredWeaponIndex( m_nItemID );
}
}
#else
CTFWeaponBase *pWeapon = pTFPlayer->Weapon_OwnsThisID( m_nWeaponID );
const char *pszWeaponName = WeaponIdToClassname( m_nWeaponID );
if ( pWeapon )
{
if ( pPlayer->GiveAmmo(999, m_pWeaponInfo->iAmmoType) )
bSuccess = true;
}
#endif
if ( !pWeapon )
{
CTFWeaponBase *pNewWeapon = (CTFWeaponBase *)pTFPlayer->GiveNamedItem( pszWeaponName, 0, &m_Item );
if ( pNewWeapon )
{
pPlayer->SetAmmoCount( pNewWeapon->GetInitialAmmo(), iAmmoType );
pNewWeapon->DefaultTouch( pPlayer );
pTFPlayer->m_Shared.SetDesiredWeaponIndex( -1 );
bSuccess = true;
}
}
if ( bSuccess )
{
CSingleUserRecipientFilter user( pPlayer );
user.MakeReliable();
UserMessageBegin( user, "ItemPickup" );
WRITE_STRING( GetClassname() );
MessageEnd();
pPlayer->EmitSound( "BaseCombatCharacter.AmmoPickup" );
}
}
return bSuccess;
}
示例9: TeleporterThink
//.........这里部分代码省略.........
if ( pEnts[i] == this )
continue;
// kill players and NPCs
if ( pEnts[i]->IsPlayer() || pEnts[i]->IsNPC() )
{
if ( !pTeleportingPlayer->InSameTeam(pEnts[i]) )
{
hPlayersToKill.AddToTail( pEnts[i] );
}
continue;
}
if ( pEnts[i]->IsBaseObject() )
continue;
// Solid entities will prevent a teleport
if ( pEnts[i]->IsSolid() && pEnts[i]->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), MASK_ALL ) &&
g_pGameRules->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), pEnts[i]->GetCollisionGroup() ) )
{
// We're going to teleport into something solid. Abort & destroy this exit.
bClear = false;
}
}
}
if ( bClear )
{
// Telefrag all enemy players we've found
for ( int player = 0; player < hPlayersToKill.Count(); player++ )
{
hPlayersToKill[player]->TakeDamage( CTakeDamageInfo( pTeleportingPlayer, this, 1000, DMG_CRUSH ) );
}
pTeleportingPlayer->Teleport( &newPosition, &(GetAbsAngles()), &vec3_origin );
// Unzoom if we are a sniper zoomed!
if ( ( pTeleportingPlayer->GetPlayerClass()->GetClassIndex() == TF_CLASS_SNIPER ) &&
pTeleportingPlayer->m_Shared.InCond( TF_COND_AIMING ) )
{
CTFWeaponBase *pWpn = pTeleportingPlayer->GetActiveTFWeapon();
if ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE )
{
CTFSniperRifle *pRifle = static_cast<CTFSniperRifle*>( pWpn );
pRifle->ToggleZoom();
}
}
pTeleportingPlayer->SetFOV( pTeleportingPlayer, 0, tf_teleporter_fov_time.GetFloat(), tf_teleporter_fov_start.GetInt() );
color32 fadeColor = {255,255,255,100};
UTIL_ScreenFade( pTeleportingPlayer, fadeColor, 0.25, 0.4, FFADE_IN );
}
else
{
DetonateObject();
}
}
SetState( TELEPORTER_STATE_RECEIVING_RELEASE );
m_flMyNextThink = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEIN_TIME );
}
break;
case TELEPORTER_STATE_RECEIVING_RELEASE:
{
CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get();
if ( pTeleportingPlayer )
{
pTeleportingPlayer->TeleportEffect();
pTeleportingPlayer->m_Shared.RemoveCond( TF_COND_SELECTED_TO_TELEPORT );
CTF_GameStats.Event_PlayerUsedTeleport( GetBuilder(), pTeleportingPlayer );
pTeleportingPlayer->SpeakConceptIfAllowed( MP_CONCEPT_TELEPORTED );
}
// reset the pointers to the player now that we're done teleporting
SetTeleportingPlayer( NULL );
pMatch->SetTeleportingPlayer( NULL );
SetState( TELEPORTER_STATE_RECHARGING );
m_flMyNextThink = gpGlobals->curtime + ( TELEPORTER_RECHARGE_TIME );
}
break;
case TELEPORTER_STATE_RECHARGING:
// If we are finished recharging, go active
if ( gpGlobals->curtime > m_flRechargeTime )
{
SetState( TELEPORTER_STATE_READY );
EmitSound( "Building_Teleporter.Ready" );
}
break;
}
}