本文整理汇总了C++中CBaseTFPlayer类的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTFPlayer类的具体用法?C++ CBaseTFPlayer怎么用?C++ CBaseTFPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBaseTFPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Assert
//-----------------------------------------------------------------------------
// Purpose: Detach the player from the "Buff Station."
//-----------------------------------------------------------------------------
void CObjectBuffStation::DetachPlayerByIndex( int nIndex )
{
// Valid index?
Assert( nIndex < BUFF_STATION_MAX_PLAYERS );
// Get the player.
CBaseTFPlayer *pPlayer = m_hPlayers[nIndex].Get();
if ( !pPlayer )
{
m_hPlayers.Set( nIndex, NULL );
return;
}
// Remove the damage modifier.
m_aPlayerAttachInfo[nIndex].m_DamageModifier.RemoveModifier();
// Remove the rope (cable).
if ( m_aPlayerAttachInfo[nIndex].m_hRope.Get() )
{
m_aPlayerAttachInfo[nIndex].m_hRope->DetachPoint( 1 );
m_aPlayerAttachInfo[nIndex].m_hRope->DieAtNextRest();
}
// Unconstrain the player movement.
pPlayer->DeactivateMovementConstraint();
// Keep track of player events.
g_pNotify->RemoveEntity( this, pPlayer );
// Reduce player count.
m_nPlayerCount--;
m_hPlayers.Set( nIndex, NULL );
}
示例2: IsValidFn_PlayersWantingAssist
static bool IsValidFn_PlayersWantingAssist( void *pUserData, int a )
{
CSortBase *pSortBase = (CSortBase*)pUserData;
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)pSortBase->m_pPlayer->GetTeam()->GetPlayer( a );
if ( !pPlayer->IsAlive() )
{
// This guy sure could have used an assist but YOU'RE TOO SLOW!!!
return false;
}
// Don't try to assist yourself...
if ( pPlayer == pSortBase->m_pPlayer )
return false;
// Make sure this guy was shot recently.
if ( (gpGlobals->curtime - pPlayer->LastTimeDamagedByEnemy()) > COMMANDO_ASSIST_SHOT_DELAY )
return false;
// Is the guy close enough?
if ( pSortBase->m_pPlayer->GetAbsOrigin().DistToSqr( pPlayer->GetAbsOrigin() ) > COMMAND_ASSIST_DISTANCE_SQR )
return false;
return true;
}
示例3: SequenceDuration
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
float CWeaponCombatBurstRifle::GetFireRate( void )
{
if ( !inv_demo.GetFloat() )
{
float flFireRate = ( SequenceDuration() * 0.6f ) + SHARED_RANDOMFLOAT( 0.0, 0.035f );
CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>( GetOwner() );
if ( pPlayer )
{
// Ducking players should fire more rapidly.
if ( pPlayer->GetFlags() & FL_DUCKING )
{
flFireRate *= weapon_combat_burstrifle_ducking_mod.GetFloat();
}
}
return flFireRate;
}
// Get the player and check to see if we are powered up.
CBaseTFPlayer *pPlayer = ( CBaseTFPlayer* )GetOwner();
if ( pPlayer && pPlayer->HasPowerup( POWERUP_BOOST ) )
{
return BURSTRIFLE_BOOSTED_FIRERATE;
}
return SHARED_RANDOMFLOAT( 0.075f, 0.15f );
}
示例4: ToBaseTFPlayer
//-----------------------------------------------------------------------------
// New technologies:
//-----------------------------------------------------------------------------
void CWeaponCombat_ChargeablePlasma::GainedNewTechnology( CBaseTechnology *pTechnology )
{
BaseClass::GainedNewTechnology( pTechnology );
CBaseTFPlayer *pPlayer = ToBaseTFPlayer( (CBaseEntity*)GetOwner() );
if ( pPlayer )
{
// Charge-up mode?
if ( pPlayer->HasNamedTechnology( "com_comboshield_charge" ) )
{
m_bHasCharge = true;
}
else
{
m_bHasCharge = false;
}
// Burst shot mode?
if ( pPlayer->HasNamedTechnology( "com_comboshield_tripleshot" ) )
{
m_bHasBurstShot = true;
}
else
{
m_bHasBurstShot = false;
}
}
}
示例5: Assert
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CGrenadeRocket::MissileTouch( CBaseEntity *pOther )
{
Assert( pOther );
if ( !pOther->IsSolid() )
return;
Vector vecAbsOrigin = GetAbsOrigin();
CPASFilter filter( vecAbsOrigin );
te->Explosion( filter, 0.0, &vecAbsOrigin, g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, 100, m_flDamage );
StopSound( "GrenadeRocket.FlyLoop" );
// Don't apply explosive damage if it hit a shield of any kind...
bool bHittingShield = false;
if (pOther->GetCollisionGroup() == TFCOLLISION_GROUP_SHIELD)
{
bHittingShield = true;
}
else if ( pOther->IsPlayer() )
{
CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>(pOther);
trace_t tr;
float flDamage = m_flDamage;
bHittingShield = pPlayer->IsHittingShield( GetAbsVelocity(), &flDamage );
}
if (!bHittingShield)
{
RadiusDamage( CTakeDamageInfo( this, m_pRealOwner, m_flDamage, DMG_BLAST ), vecAbsOrigin, 100, CLASS_NONE );
}
UTIL_Remove( this );
}
示例6: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponCombatLaserRifle::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
if (!pPlayer)
return;
WeaponSound(SINGLE);
// Fire the bullets
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming;
pPlayer->EyeVectors( &vecAiming );
PlayAttackAnimation( GetPrimaryAttackActivity() );
// Reduce the spread if the player's ducking
Vector vecSpread = GetBulletSpread();
vecSpread *= m_flInaccuracy;
TFGameRules()->FireBullets( CTakeDamageInfo( this, pPlayer, weapon_combat_laserrifle_damage.GetFloat(), DMG_PLASMA), 1,
vecSrc, vecAiming, vecSpread, weapon_combat_laserrifle_range.GetFloat(), m_iPrimaryAmmoType, 0, entindex(), 0 );
m_flInaccuracy += 0.3;
m_flInaccuracy = clamp(m_flInaccuracy, 0, 1);
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
m_iClip1 = m_iClip1 - 1;
}
示例7: GetDamageType
//-----------------------------------------------------------------------------
// Purpose: Try and find an entity to lock onto
//-----------------------------------------------------------------------------
CBaseEntity *CWeaponCombat_ChargeablePlasma::GetLockTarget( void )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
if ( !pPlayer )
return NULL;
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming;
pPlayer->EyeVectors( &vecAiming );
Vector vecEnd = vecSrc + vecAiming * MAX_TRACE_LENGTH;
trace_t tr;
TFGameRules()->WeaponTraceLine( vecSrc, vecEnd, MASK_SHOT, pPlayer, GetDamageType(), &tr );
if ( (tr.fraction < 1.0f) && tr.m_pEnt )
{
CBaseEntity *pTargetEntity = tr.m_pEnt;
// Don't guide on same team or on anything other than players, objects, and NPCs
if ( pTargetEntity->InSameTeam(pPlayer) || (!pTargetEntity->IsPlayer()
&& (pTargetEntity->MyNPCPointer() == NULL)) )
return NULL;
// Compute the target offset relative to the target
Vector vecWorldOffset;
VectorSubtract( tr.endpos, pTargetEntity->GetAbsOrigin(), vecWorldOffset );
VectorIRotate( vecWorldOffset, pTargetEntity->EntityToWorldTransform(), m_vecTargetOffset );
m_flLockedAt = gpGlobals->curtime + 0.2;
return pTargetEntity;
}
return NULL;
}
示例8: ToBaseTFPlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponBuilder::ItemPostFrame( void )
{
CBaseTFPlayer *pOwner = ToBaseTFPlayer( GetOwner() );
if ( !pOwner )
return;
// Ignore input while the player's building anything
if ( pOwner->IsBuilding() )
return;
// Switch away if I'm not in placement mode
if ( m_iBuildState != BS_PLACING && m_iBuildState != BS_PLACING_INVALID )
{
pOwner->SwitchToNextBestWeapon( NULL );
return;
}
if (( pOwner->m_nButtons & IN_ATTACK ) && (m_flNextPrimaryAttack <= gpGlobals->curtime) )
{
PrimaryAttack();
}
// Allow shield post frame
AllowShieldPostFrame( true );
WeaponIdle();
}
示例9: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose: Place the combat object
//-----------------------------------------------------------------------------
void CWeaponBaseCombatObject::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = dynamic_cast<CBaseTFPlayer*>((CBaseEntity*)GetOwner());
if ( !pPlayer )
return;
if ( pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0 )
return;
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
Vector vecPlaceOrigin;
QAngle angPlaceAngles;
if ( GetPlacePosition( pPlayer, &vecPlaceOrigin, &angPlaceAngles ) == false )
{
WeaponSound( DOUBLE );
return;
}
// Place the combat object
PlaceCombatObject( pPlayer, vecPlaceOrigin, angPlaceAngles );
WeaponSound( SINGLE );
pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
// If I'm now out of ammo, switch away
if ( !HasPrimaryAmmo() )
{
pPlayer->SelectLastItem();
}
}
示例10: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponCombatPlasmaGrenadeLauncher::PrimaryAttack( void )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
if (!pPlayer)
return;
WeaponSound(SINGLE);
// Fire the bullets
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
PlayAttackAnimation( GetPrimaryAttackActivity() );
// Launch the grenade
Vector vecForward;
pPlayer->EyeVectors( &vecForward );
Vector vecOrigin = pPlayer->EyePosition();
vecOrigin += (vecForward);
#if !defined( CLIENT_DLL )
float flSpeed = 1200;
CGrenadeAntiPersonnel* pGrenade = CGrenadeAntiPersonnel::Create(vecOrigin, vecForward * flSpeed, pPlayer );
pGrenade->SetModel( "models/weapons/w_grenade.mdl" );
pGrenade->SetBounceSound( "PlasmaGrenade.Bounce" );
pGrenade->SetDamage( weapon_combat_plasmagrenadelauncher_damage.GetFloat() );
pGrenade->SetDamageRadius( weapon_combat_plasmagrenadelauncher_radius.GetFloat() );
pGrenade->SetExplodeOnContact( true );
#endif
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
m_iClip1 = m_iClip1 - 1;
}
示例11: BullRushTouch
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassCommando::BullRushTouch( CBaseEntity *pTouched )
{
if ( pTouched->IsPlayer() && !pTouched->InSameTeam( m_pPlayer ) )
{
// Get the player.
CBaseTFPlayer *pTFPlayer = ( CBaseTFPlayer* )pTouched;
// Check to see if we have "touched" this player already this bullrush cycle.
if ( m_aHitPlayers.Find( pTFPlayer ) != -1 )
return;
// Hitting the player now.
m_aHitPlayers.AddToTail( pTFPlayer );
// ROBIN: Bullrush now instantly kills again
float flDamage = 200;
// Calculate the damage a player takes based on distance(time).
//float flDamage = 1.0f - ( ( COMMANDO_BULLRUSH_TIME - m_ClassData.m_flBullRushTime ) * ( 1.0f / COMMANDO_BULLRUSH_TIME ) );
//flDamage *= 115.0f; // max bullrush damage
trace_t tr = m_pPlayer->GetTouchTrace();
CTakeDamageInfo info( m_pPlayer, m_pPlayer, flDamage, DMG_CLUB, DMG_KILL_BULLRUSH );
CalculateMeleeDamageForce( &info, (tr.endpos - tr.startpos), tr.endpos );
pTFPlayer->TakeDamage( info );
CPASAttenuationFilter filter( m_pPlayer, "Commando.BullRushFlesh" );
CBaseEntity::EmitSound( filter, m_pPlayer->entindex(), "Commando.BullRushFlesh" );
pTFPlayer->Touch( m_pPlayer );
}
}
示例12: GetParentObject
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseTFVehicle::FinishedBuilding( void )
{
BaseClass::FinishedBuilding();
// See if we've finished building on a vehicle that has a passenger slot assigned to my buildpoint.
CBaseObject *pParent = GetParentObject();
if ( pParent && pParent->IsAVehicle() )
{
CBaseTFVehicle *pVehicle = static_cast<CBaseTFVehicle*>(pParent);
int iRole = pVehicle->GetChildVehicleRole( this );
if ( iRole != -1 )
{
// Is there a player in the role assigned to this buildpoint?
CBaseTFPlayer *pExistingPlayer = static_cast<CBaseTFPlayer*>( pVehicle->GetPassenger( iRole ) );
if ( pExistingPlayer )
{
// Remove the player from my parent vehicle and put them in me
pExistingPlayer->LeaveVehicle();
// Get in the vehicle.
pExistingPlayer->GetInVehicle( this, VEHICLE_DRIVER );
}
}
}
}
示例13: GetImpaledTarget
//-----------------------------------------------------------------------------
// Purpose: Check to see if our target has moved beyond our length
//-----------------------------------------------------------------------------
void CHarpoon::ConstrainThink( void )
{
if ( !GetImpaledTarget() || !m_hLinkedHarpoon.Get() )
return;
// Moved too far away?
float flDistSq = m_hLinkedHarpoon->GetAbsOrigin().DistToSqr( GetImpaledTarget()->GetAbsOrigin() );
if ( flDistSq > m_flConstrainLength )
{
// Break the rope
if ( m_hRope )
{
m_hRope->DetachPoint(1);
m_hRope->DieAtNextRest();
m_hRope = NULL;
}
// If we're impaling a player, remove his movement constraint
if ( GetImpaledTarget()->IsPlayer() )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer *)GetImpaledTarget();
pPlayer->DeactivateMovementConstraint();
}
SetThink( NULL );
}
else
{
SetNextThink( gpGlobals->curtime + 0.1f );
}
}
示例14: RecalculateAccuracy
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponCombatLaserRifle::RecalculateAccuracy( void )
{
CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
if (!pPlayer)
return;
m_flAccuracyTime += gpGlobals->frametime;
while ( m_flAccuracyTime > 0.05 )
{
if ( !(pPlayer->GetFlags() & FL_ONGROUND) )
{
m_flInaccuracy += 0.05;
}
else if ( pPlayer->GetFlags() & FL_DUCKING )
{
m_flInaccuracy -= 0.08;
}
/*
else if ( pPlayer->GetLocalVelocity().LengthSqr() > (100*100) )
{
// Never get worse than 1/2 accuracy from running
if ( m_flInaccuracy < 0.25 )
{
m_flInaccuracy += 0.01;
if ( m_flInaccuracy > 0.5 )
{
m_flInaccuracy = 0.5;
}
}
else if ( m_flInaccuracy > 0.25 )
{
m_flInaccuracy -= 0.01;
}
}
*/
else
{
m_flInaccuracy -= 0.04;
}
// Crouching prevents accuracy ever going beyond a point
if ( pPlayer->GetFlags() & FL_DUCKING )
{
m_flInaccuracy = clamp(m_flInaccuracy, 0, 0.8);
}
else
{
m_flInaccuracy = clamp(m_flInaccuracy, 0, 1);
}
m_flAccuracyTime -= 0.05;
#ifndef CLIENT_DLL
//if ( m_flInaccuracy )
//Msg("Inaccuracy %.2f (%.2f)\n", m_flInaccuracy, gpGlobals->curtime );
#endif
}
}
示例15: ClientPutInServer
/*
===========
ClientPutInServer
called each time a player is spawned into the game
============
*/
void ClientPutInServer( edict_t *pEdict, const char *playername )
{
// Allocate a CBaseTFPlayer for pev, and call spawn
CBaseTFPlayer *pPlayer = CBaseTFPlayer::CreatePlayer( "player", pEdict );
pPlayer->InitialSpawn();
pPlayer->SetPlayerName( playername );
pPlayer->Spawn();
}