本文整理汇总了C++中CTFPlayer类的典型用法代码示例。如果您正苦于以下问题:C++ CTFPlayer类的具体用法?C++ CTFPlayer怎么用?C++ CTFPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTFPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFFlareGun::LaunchProjectile(void)
{
// Get the player owning the weapon.
CTFPlayer *pPlayer = ToTFPlayer(GetPlayerOwner());
if (!pPlayer)
return;
CalcIsAttackCritical();
SendWeaponAnim(ACT_VM_PRIMARYATTACK);
pPlayer->SetAnimation(PLAYER_ATTACK1);
pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY);
FireProjectile(pPlayer);
#if !defined( CLIENT_DLL )
pPlayer->SpeakWeaponFire();
CTF_GameStats.Event_PlayerFiredWeapon(pPlayer, IsCurrentAttackACrit());
#endif
// Set next attack times.
m_flNextPrimaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData(m_iWeaponMode).m_flTimeFireDelay;
SetWeaponIdleTime(gpGlobals->curtime + SequenceDuration());
// Check the reload mode and behave appropriately.
if (m_bReloadsSingly)
{
m_iReloadMode.Set(TF_RELOAD_START);
}
}
示例2: GetEnemyTeam
void CTFBotVision::Update()
{
if (TFGameRules()->IsMannVsMachineMode()) {
if (!this->m_ctUpdate.IsElapsed()) {
return;
}
this->m_ctUpdate.Start(RandomFloat(0.9f, 1.1f));
}
IVision::Update();
CTFBot *actor = static_cast<CTFBot *>(this->GetBot()->GetEntity());
if (actor == nullptr) {
return;
}
CUtlVector<CTFPlayer *> enemies;
CollectPlayers<CTFPlayer>(enemies, GetEnemyTeam(actor), true, false);
FOR_EACH_VEC(enemies, i) {
CTFPlayer *enemy = enemies[i];
if (enemy->IsPlayerClass(TF_CLASS_SPY)) {
const CKnownEntity *known = this->GetKnown(enemy);
if (known != nullptr && (known->IsVisibleRecently() ||
!player->m_Shared.InCond(TF_COND_DISGUISING))) {
actor->ForgetSpy(enemy);
}
}
}
示例3: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CTFViewModel::GetSkin()
{
int nSkin = BaseClass::GetSkin();
CTFWeaponBase *pWeapon = ( CTFWeaponBase * )GetOwningWeapon();
if ( !pWeapon )
return nSkin;
CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
if ( pPlayer )
{
if ( pWeapon->GetTFWpnData().m_bHasTeamSkins_Viewmodel )
{
switch( pPlayer->GetTeamNumber() )
{
case TF_TEAM_RED:
nSkin = 0;
break;
case TF_TEAM_BLUE:
nSkin = 1;
break;
case TF_TEAM_GREEN:
nSkin = 2;
break;
case TF_TEAM_YELLOW:
nSkin = 3;
break;
}
}
}
return nSkin;
}
示例4: UpdatePlayerData
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFPlayerResource::UpdatePlayerData( void )
{
int i;
BaseClass::UpdatePlayerData();
for ( i = 1 ; i <= gpGlobals->maxClients; i++ )
{
CTFPlayer *pPlayer = (CTFPlayer*)UTIL_PlayerByIndex( i );
if ( pPlayer && pPlayer->IsConnected() )
{
PlayerStats_t *pPlayerStats = CTF_GameStats.FindPlayerStats( pPlayer );
if ( pPlayerStats )
{
m_iMaxHealth.Set( i, pPlayer->GetPlayerClass()->GetMaxHealth() );
m_iPlayerClass.Set( i, pPlayer->GetPlayerClass()->GetClassIndex() );
int iTotalScore = CTFGameRules::CalcPlayerScore( &pPlayerStats->statsAccumulated );
m_iTotalScore.Set( i, iTotalScore );
Vector vecColor = pPlayer->m_vecPlayerColor;
m_iColors.Set(i, Vector(vecColor.x, vecColor.y, vecColor.z));
//Msg("Server %f %f %f\n", m_iColors.Get(i).x, m_iColors.Get(i).y, m_iColors.Get(i).z);
m_iKillstreak.Set(i, pPlayer->m_Shared.GetKillstreak());
}
}
}
}
示例5: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose: only called for local player
//-----------------------------------------------------------------------------
void C_TFWeaponBuilder::Redraw()
{
if ( m_iValidBuildPoseParam >= 0 )
{
CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
if ( !pOwner )
return;
// Assuming here that our model is the same as our viewmodel's model!
CBaseViewModel *pViewModel = pOwner->GetViewModel(0);
if ( pViewModel )
{
float flPoseParamValue = pViewModel->GetPoseParameter( m_iValidBuildPoseParam );
C_BaseObject *pObj = m_hObjectBeingBuilt.Get();
if ( pObj && pObj->WasLastPlacementPosValid() )
{
// pose param approach 1.0
flPoseParamValue = Approach( 1.0, flPoseParamValue, 3.0 * gpGlobals->frametime );
}
else
{
// pose param approach 0.0
flPoseParamValue = Approach( 0.0, flPoseParamValue, 1.5 * gpGlobals->frametime );
}
pViewModel->SetPoseParameter( m_iValidBuildPoseParam, flPoseParamValue );
}
}
BaseClass::Redraw();
}
示例6: FireGameEvent
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHudMenuSpyDisguise::FireGameEvent( IGameEvent *event )
{
const char * type = event->GetName();
if ( Q_strcmp(type, "spy_pda_reset") == 0 )
{
CTFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( pPlayer )
{
bool bShowBlue = ( pPlayer->GetTeamNumber() == TF_TEAM_RED );
for ( int i=0; i<9; i++ )
{
m_pClassItems_Red[i]->SetVisible( !bShowBlue );
m_pClassItems_Blue[i]->SetVisible( bShowBlue );
}
m_iShowingTeam = ( bShowBlue ) ? TF_TEAM_BLUE : TF_TEAM_RED;
}
}
else
{
CHudElement::FireGameEvent( event );
}
}
示例7: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CChangeClassZone::Touch( CBaseEntity *pOther )
{
if ( !IsDisabled() )
{
CTFPlayer *pPlayer = ToTFPlayer( pOther );
if ( pPlayer )
{
if ( pPlayer->GetNextChangeClassTime() > gpGlobals->curtime )
return;
int iTeam = GetTeamNumber();
if ( iTeam && ( pPlayer->GetTeamNumber() != iTeam ) )
return;
// bring up the player's changeclass menu
CCommand args;
args.Tokenize( "changeclass" );
pPlayer->ClientCommand( args );
pPlayer->SetNextChangeClassTime( gpGlobals->curtime + TF_CHANGECLASS_NEXT_USE_TIME );
CPASAttenuationFilter filter( pOther, TF_CHANGECLASS_SOUND );
EmitSound( filter, pOther->entindex(), TF_CHANGECLASS_SOUND );
}
}
}
示例8: GetTFPlayerOwner
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFSniperRifle::ZoomOut( void )
{
BaseClass::ZoomOut();
// Stop aiming
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return;
pPlayer->m_Shared.RemoveCond( TF_COND_AIMING );
pPlayer->TeamFortress_SetSpeed();
#ifdef GAME_DLL
// Destroy the sniper dot.
DestroySniperDot();
pPlayer->ClearExpression();
#endif
// if we are thinking about zooming, cancel it
m_flUnzoomTime = -1;
m_flRezoomTime = -1;
m_bRezoomAfterShot = false;
m_flChargedDamage = 0.0f;
}
示例9: GetTFPlayerOwner
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWeaponBaseGun::ItemPostFrame( void )
{
int iOldBurstSize = m_iBurstSize;
CTFPlayer *pOwner = GetTFPlayerOwner();
if ( pOwner )
{
if ( m_iBurstSize > 0 )
{
// Fake the fire button.
pOwner->m_nButtons |= IN_ATTACK;
}
}
BaseClass::ItemPostFrame();
// Stop burst if we run out of ammo.
if ( ( UsesClipsForAmmo1() && m_iClip1 <= 0 ) ||
( !UsesClipsForAmmo1() && pOwner->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 ) )
{
m_iBurstSize = 0;
}
if ( iOldBurstSize > 0 && m_iBurstSize == 0 )
{
// Delay the next burst.
m_flNextPrimaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData( TF_WEAPON_PRIMARY_MODE ).m_flBurstDelay;
}
}
示例10: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose: Player holding this weapon has started building something
// Assumes we are in a valid build position
//-----------------------------------------------------------------------------
void CTFWeaponBuilder::StartBuilding( void )
{
CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
CBaseObject *pObj = m_hObjectBeingBuilt.Get();
if ( pPlayer && pPlayer->m_Shared.IsCarryingObject() )
{
Assert( pObj );
pObj->RedeployBuilding( ToTFPlayer( GetOwner() ) );
m_hObjectBeingBuilt = NULL;
pPlayer->m_Shared.SetCarriedObject( NULL );
return;
}
Assert( pObj );
pObj->StartBuilding( GetOwner() );
pObj->AddSpawnFlags( SF_OBJ_UPGRADABLE );
m_hObjectBeingBuilt = NULL;
if ( pPlayer )
{
pPlayer->RemoveInvisibility();
}
}
示例11: SendWeaponAnim
// ---------------------------------------------------------------------------- -
// Purpose:
//-----------------------------------------------------------------------------
void CTFCompoundBow::PrimaryAttack( void )
{
if ( !CanAttack() )
{
m_flChargeBeginTime = 0;
return;
}
if ( m_flChargeBeginTime <= 0 )
{
// Set the weapon mode.
m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;
// save that we had the attack button down
m_flChargeBeginTime = gpGlobals->curtime;
SendWeaponAnim( ACT_ITEM2_VM_CHARGE );
CTFPlayer *pOwner = GetTFPlayerOwner();
if ( pOwner )
{
WeaponSound( SPECIAL1 );
pOwner->m_Shared.AddCond( TF_COND_AIMING );
pOwner->TeamFortress_SetSpeed();
}
}
}
示例12: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFMinigun::WindDown( void )
{
// Get the player owning the weapon.
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return;
SendWeaponAnim( ACT_MP_ATTACK_STAND_POSTFIRE );
// Set the appropriate firing state.
m_iWeaponState = AC_STATE_IDLE;
pPlayer->m_Shared.RemoveCond( TF_COND_AIMING );
#ifdef CLIENT_DLL
WeaponSoundUpdate();
#else
pPlayer->ClearWeaponFireScene();
#endif
// Time to weapon idle.
m_flTimeWeaponIdle = gpGlobals->curtime + 2.0;
// Update player's speed
pPlayer->TeamFortress_SetSpeed();
#ifdef CLIENT_DLL
m_flBarrelTargetVelocity = 0;
#endif
}
示例13: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
// Input :
//-----------------------------------------------------------------------------
void CViewModelInvisProxy::OnBind( C_BaseEntity *pEnt )
{
if ( !m_pPercentInvisible )
return;
if ( !pEnt )
return;
CTFViewModel *pVM = dynamic_cast<CTFViewModel *>( pEnt );
if ( !pVM )
{
m_pPercentInvisible->SetFloatValue( 0.0f );
return;
}
CTFPlayer *pPlayer = ToTFPlayer( pVM->GetOwner() );
if ( !pPlayer )
{
m_pPercentInvisible->SetFloatValue( 0.0f );
return;
}
float flPercentInvisible = pPlayer->GetPercentInvisible();
// remap from 0.22 to 0.5
// but drop to 0.0 if we're not invis at all
float flWeaponInvis = ( flPercentInvisible < 0.01 ) ?
0.0 :
RemapVal( flPercentInvisible, 0.0, 1.0, tf_vm_min_invis.GetFloat(), tf_vm_max_invis.GetFloat() );
m_pPercentInvisible->SetFloatValue( flWeaponInvis );
}
示例14: ToTFPlayer
void CTFWeaponBuilder::SecondaryAttack( void )
{
if ( m_bInAttack2 )
return;
// require a re-press
m_bInAttack2 = true;
CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
if ( !pOwner )
return;
if ( pOwner->DoClassSpecialSkill() )
{
// intentionally blank
}
else if ( m_iBuildState == BS_PLACING )
{
if ( m_hObjectBeingBuilt )
{
pOwner->StopHintTimer( HINT_ALTFIRE_ROTATE_BUILDING );
m_hObjectBeingBuilt->RotateBuildAngles();
}
}
m_flNextSecondaryAttack = gpGlobals->curtime + 0.2f;
}
示例15: SetCurrentState
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFWeaponBuilder::Deploy( void )
{
bool bDeploy = BaseClass::Deploy();
if ( bDeploy )
{
SetCurrentState( BS_PLACING );
StartPlacement();
m_flNextPrimaryAttack = gpGlobals->curtime + 0.35f;
m_flNextSecondaryAttack = gpGlobals->curtime; // asap
CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
if (!pPlayer)
return false;
pPlayer->SetNextAttack( gpGlobals->curtime );
m_iWorldModelIndex = modelinfo->GetModelIndex( GetWorldModel() );
m_flNextDenySound = 0;
// Set off the hint here, because we don't know until now if our building
// is rotate-able or not.
if ( m_hObjectBeingBuilt && !m_hObjectBeingBuilt->MustBeBuiltOnAttachmentPoint() )
{
// set the alt-fire hint so it gets removed when we holster
m_iAltFireHint = HINT_ALTFIRE_ROTATE_BUILDING;
pPlayer->StartHintTimer( m_iAltFireHint );
}
}
return bDeploy;
}