本文整理汇总了C++中ToTFPlayer函数的典型用法代码示例。如果您正苦于以下问题:C++ ToTFPlayer函数的具体用法?C++ ToTFPlayer怎么用?C++ ToTFPlayer使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToTFPlayer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToTFPlayer
const char *CHudChat::GetDisplayedSubtitlePlayerName( int clientIndex )
{
C_TFPlayer *pPlayer = ToTFPlayer( UTIL_PlayerByIndex( clientIndex ) );
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
if ( !pPlayer || !pLocalPlayer )
return BaseClass::GetDisplayedSubtitlePlayerName( clientIndex );
// If they are disguised as the enemy, and not on our team
if ( pPlayer->m_Shared.InCond( TF_COND_DISGUISED ) &&
pPlayer->m_Shared.GetDisguiseTeam() != pPlayer->GetTeamNumber() &&
!pLocalPlayer->InSameTeam( pPlayer ) )
{
C_TFPlayer *pDisguiseTarget = ToTFPlayer( pPlayer->m_Shared.GetDisguiseTarget() );
Assert( pDisguiseTarget );
if ( !pDisguiseTarget )
{
return BaseClass::GetDisplayedSubtitlePlayerName( clientIndex );
}
return pDisguiseTarget->GetPlayerName();
}
return BaseClass::GetDisplayedSubtitlePlayerName( clientIndex );
}
示例2: 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();
}
}
示例3: defined
void CTFViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition, const QAngle& eyeAngles )
{
#if defined( CLIENT_DLL )
Vector vecNewOrigin = eyePosition;
QAngle vecNewAngles = eyeAngles;
// Check for lowering the weapon
C_TFPlayer *pPlayer = ToTFPlayer( owner );
Assert( pPlayer );
bool bLowered = pPlayer->IsWeaponLowered();
QAngle vecLoweredAngles(0,0,0);
m_vLoweredWeaponOffset.x = Approach( bLowered ? cl_gunlowerangle.GetFloat() : 0, m_vLoweredWeaponOffset.x, cl_gunlowerspeed.GetFloat() );
vecLoweredAngles.x += m_vLoweredWeaponOffset.x;
vecNewAngles += vecLoweredAngles;
// Viewmodel offset
Vector forward, right, up;
AngleVectors(eyeAngles, &forward, &right, &up);
vecNewOrigin += forward*v_viewmodel_offset_x.GetFloat() + right*v_viewmodel_offset_y.GetFloat() + up*v_viewmodel_offset_z.GetFloat();
if (owner->GetActiveWeapon())
ToTFPlayer(owner)->GetActiveTFWeapon()->UpdateViewModel();
BaseClass::CalcViewModelView( owner, vecNewOrigin, vecNewAngles );
#endif
}
示例4: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose: Burn charge level to generate invulnerability
//-----------------------------------------------------------------------------
void CWeaponMedigun::SecondaryAttack( void )
{
CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
if ( !pOwner )
return;
if ( !CanAttack() )
return;
// Ensure they have a full charge and are not already in charge release mode
if ( m_flChargeLevel < 1.0 || m_bChargeRelease )
{
#ifdef CLIENT_DLL
// Deny, flash
if ( !m_bChargeRelease && m_flFlashCharge <= 0 )
{
m_flFlashCharge = 10;
pOwner->EmitSound( "Player.DenyWeaponSelection" );
}
#endif
return;
}
if ( pOwner->HasTheFlag() )
{
#ifdef GAME_DLL
CSingleUserRecipientFilter filter( pOwner );
TFGameRules()->SendHudNotification( filter, HUD_NOTIFY_NO_INVULN_WITH_FLAG );
#endif
pOwner->EmitSound( "Player.DenyWeaponSelection" );
return;
}
// Start super charge
m_bChargeRelease = true;
m_flReleaseStartedAt = 0;//gpGlobals->curtime;
#ifdef GAME_DLL
CTF_GameStats.Event_PlayerInvulnerable( pOwner );
pOwner->m_Shared.RecalculateChargeEffects();
pOwner->SpeakConceptIfAllowed( MP_CONCEPT_MEDIC_CHARGEDEPLOYED );
if ( m_hHealingTarget && m_hHealingTarget->IsPlayer() )
{
CTFPlayer *pTFPlayer = ToTFPlayer( m_hHealingTarget );
pTFPlayer->m_Shared.RecalculateChargeEffects();
pTFPlayer->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_CHARGEDEPLOYED );
}
IGameEvent * event = gameeventmanager->CreateEvent( "player_chargedeployed" );
if ( event )
{
event->SetInt( "userid", pOwner->GetUserID() );
gameeventmanager->FireEvent( event, true ); // don't send to clients
}
#endif
}
示例5: ToTFPlayer
bool CUsefulHealTargetFilter::IsAllowed(CBaseEntity *ent) const
{
if (ent == nullptr || !ent->IsPlayer() ||
ent->GetTeamNumber() != this->m_iTeamNum) {
return false;
}
if (ToTFPlayer(ent)->IsPlayerClass(TF_CLASS_MEDIC) ||
ToTFPlayer(ent)->IsPlayerClass(TF_CLASS_SNIPER)) {
return false;
}
return true;
}
示例6: Holster
//-----------------------------------------------------------------------------
// Purpose: Stop placement when holstering
//-----------------------------------------------------------------------------
bool CTFWeaponBuilder::Holster( CBaseCombatWeapon *pSwitchingTo )
{
if ( GetOwner() && ToTFPlayer(GetOwner()) && ToTFPlayer(GetOwner())->m_Shared.IsCarryingObject() )
return false;
if ( m_iBuildState == BS_PLACING || m_iBuildState == BS_PLACING_INVALID )
{
SetCurrentState( BS_IDLE );
}
StopPlacement();
return BaseClass::Holster(pSwitchingTo);
}
示例7: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFWeaponBaseMelee::CalcIsAttackCriticalHelper( void )
{
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return false;
int nCvarValue = tf_weapon_criticals_melee.GetInt();
if ( nCvarValue == 0 )
return false;
if ( nCvarValue == 1 && !tf_weapon_criticals.GetBool() )
return false;
float flPlayerCritMult = pPlayer->GetCritMult();
float flCritChance = TF_DAMAGE_CRIT_CHANCE_MELEE * flPlayerCritMult;
CALL_ATTRIB_HOOK_FLOAT( flCritChance, mult_crit_chance );
// If the chance is 0, just bail.
if ( flCritChance == 0.0f )
return false;
return ( RandomInt( 0, WEAPON_RANDOM_RANGE-1 ) <= flCritChance * WEAPON_RANDOM_RANGE );
}
示例8: Assert
//-----------------------------------------------------------------------------
// Purpose: Overridden to allow players to run faster than the maxspeed
//-----------------------------------------------------------------------------
void CTFGameMovement::ProcessMovement( CBasePlayer *pBasePlayer, CMoveData *pMove )
{
// Verify data.
Assert( pBasePlayer );
Assert( pMove );
if ( !pBasePlayer || !pMove )
return;
// Reset point contents for water check.
ResetGetPointContentsCache();
// Cropping movement speed scales mv->m_fForwardSpeed etc. globally
// Once we crop, we don't want to recursively crop again, so we set the crop
// flag globally here once per usercmd cycle.
m_iSpeedCropped = SPEED_CROPPED_RESET;
// Get the current TF player.
m_pTFPlayer = ToTFPlayer( pBasePlayer );
player = m_pTFPlayer;
mv = pMove;
// The max speed is currently set to the scout - if this changes we need to change this!
mv->m_flMaxSpeed = TF_MAX_SPEED; /*tf_maxspeed.GetFloat();*/
// Run the command.
PlayerMove();
FinishMove();
}
示例9: GetTFPlayerOwner
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponMedigun::AddCharge( void )
{
#ifdef GAME_DLL
CTFPlayer *pPlayer = GetTFPlayerOwner();
CTFPlayer *pHealingTarget = ToTFPlayer( m_hHealingTarget );
#endif
float flNewLevel = min( m_flChargeLevel + 0.25, 1.0 );
if ( flNewLevel >= 1.0 && m_flChargeLevel < 1.0 )
{
#ifdef GAME_DLL
if ( pPlayer )
{
pPlayer->SpeakConceptIfAllowed( MP_CONCEPT_MEDIC_CHARGEREADY );
}
if ( pHealingTarget )
{
pHealingTarget->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_CHARGEREADY );
}
#endif
}
m_flChargeLevel = flNewLevel;
}
示例10: 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();
}
示例11: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFMinigun::WindUp( void )
{
// Get the player owning the weapon.
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return;
// Play wind-up animation and sound (SPECIAL1).
SendWeaponAnim( ACT_MP_ATTACK_STAND_PREFIRE );
// Set the appropriate firing state.
m_iWeaponState = AC_STATE_STARTFIRING;
pPlayer->m_Shared.AddCond( TF_COND_AIMING );
#ifndef CLIENT_DLL
pPlayer->StopRandomExpressions();
#endif
#ifdef CLIENT_DLL
WeaponSoundUpdate();
#endif
// Update player's speed
pPlayer->TeamFortress_SetSpeed();
}
示例12: filter
//-----------------------------------------------------------------------------
// Found a Target
//-----------------------------------------------------------------------------
void CObjectSentrygun::FoundTarget( CBaseEntity *pTarget, const Vector &vecSoundCenter )
{
m_hEnemy = pTarget;
if ( ( m_iAmmoShells > 0 ) || ( m_iAmmoRockets > 0 && m_iUpgradeLevel == 3 ) )
{
// Play one sound to everyone but the target.
CPASFilter filter( vecSoundCenter );
if ( pTarget->IsPlayer() )
{
CTFPlayer *pPlayer = ToTFPlayer( pTarget );
// Play a specific sound just to the target and remove it from the genral recipient list.
CSingleUserRecipientFilter singleFilter( pPlayer );
EmitSound( singleFilter, entindex(), "Building_Sentrygun.AlertTarget" );
filter.RemoveRecipient( pPlayer );
}
EmitSound( filter, entindex(), "Building_Sentrygun.Alert" );
}
// Update timers, we are attacking now!
m_iState.Set( SENTRY_STATE_ATTACKING );
m_flNextAttack = gpGlobals->curtime + SENTRY_THINK_DELAY;
if ( m_flNextRocketAttack < gpGlobals->curtime )
{
m_flNextRocketAttack = gpGlobals->curtime + 0.5;
}
}
示例13: 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);
}
}
示例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: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFHunterRifle::ItemPostFrame( void )
{
// If we're lowered, we're not allowed to fire
if ( m_bLowered )
return;
// Get the owning player.
CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
if ( !pPlayer )
return;
CheckReload();
if ( !CanAttack() )
{
if ( IsZoomed() )
{
ToggleZoom();
}
return;
}
HandleZooms();
if ( m_flNextSecondaryAttack <= gpGlobals->curtime )
{
// Don't start charging in the time just after a shot before we unzoom to play rack anim.
if ( pPlayer->m_Shared.InCond( TF_COND_AIMING ) && !m_bRezoomAfterShot )
{
m_flChargedSpread = max(m_flChargedSpread - gpGlobals->frametime * TF_WEAPON_HUNTERRIFLE_CHARGE_PER_SEC, TF_WEAPON_HUNTERRIFLE_SPREAD_MIN);
}
else
{
m_flChargedSpread = min(TF_WEAPON_HUNTERRIFLE_SPREAD_MAX, m_flChargedSpread + gpGlobals->frametime * TF_WEAPON_HUNTERRIFLE_UNCHARGE_PER_SEC);
}
}
// Fire.
if ( pPlayer->m_nButtons & IN_ATTACK )
{
Fire( pPlayer );
}
// Reload pressed / Clip Empty
if ( ( pPlayer->m_nButtons & IN_RELOAD ) && !m_bInReload )
{
// reload when reload is pressed, or if no buttons are down and weapon is empty.
Reload();
}
// Idle.
if ( !( ( pPlayer->m_nButtons & IN_ATTACK) || ( pPlayer->m_nButtons & IN_ATTACK2 ) ) )
{
// No fire buttons down or reloading
if ( !ReloadOrSwitchWeapons() && ( m_bInReload == false ) )
{
WeaponIdle();
}
}
}