本文整理汇总了C++中CTFPlayer::EyePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CTFPlayer::EyePosition方法的具体用法?C++ CTFPlayer::EyePosition怎么用?C++ CTFPlayer::EyePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTFPlayer
的用法示例。
在下文中一共展示了CTFPlayer::EyePosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsPlacementPosValid
//-----------------------------------------------------------------------------
// Purpose: Check that the selected position is buildable
//-----------------------------------------------------------------------------
bool CBaseObject::IsPlacementPosValid( void )
{
bool bValid = CalculatePlacementPos();
if ( !bValid )
{
return false;
}
CTFPlayer *pPlayer = GetOwner();
if ( !pPlayer )
{
return false;
}
#ifndef CLIENT_DLL
if ( !EstimateValidBuildPos() )
return false;
#endif
// Verify that the entire object can fit here
// Important! here we want to collide with players and other buildings, but not dropped weapons
trace_t tr;
UTIL_TraceEntity( this, m_vecBuildOrigin, m_vecBuildOrigin, MASK_SOLID, NULL, COLLISION_GROUP_PLAYER, &tr );
if ( tr.fraction < 1.0f )
return false;
// Make sure we can see the final position
UTIL_TraceLine( pPlayer->EyePosition(), m_vecBuildOrigin + Vector(0,0,m_vecBuildMaxs[2] * 0.5), MASK_PLAYERSOLID_BRUSHONLY, pPlayer, COLLISION_GROUP_NONE, &tr );
if ( tr.fraction < 1.0 )
{
return false;
}
return true;
}
示例2: FlyThink
void CTFBaseRocket::FlyThink( void )
{
if ( gpGlobals->curtime > m_flCollideWithTeammatesTime && m_bCollideWithTeammates == false )
{
m_bCollideWithTeammates = true;
}
if ( tf2c_homing_rockets.GetBool() || ( tf2c_homing_deflected_rockets.GetBool() && m_iDeflected ) )
{
// Find the closest visible enemy player.
CUtlVector<CTFPlayer *> vecPlayers;
int count = CollectPlayers( &vecPlayers, TEAM_ANY, true );
float flClosest = FLT_MAX;
Vector vecClosestTarget = vec3_origin;
for ( int i = 0; i < count; i++ )
{
CTFPlayer *pPlayer = vecPlayers[i];
if ( pPlayer == GetOwnerEntity() )
continue;
if ( pPlayer->GetTeamNumber() == GetTeamNumber() && !TFGameRules()->IsDeathmatch() )
continue;
Vector vecTarget;
QAngle angTarget;
if ( GetWeaponID() == TF_WEAPON_COMPOUND_BOW )
{
int iBone = pPlayer->LookupBone( "bip_head" );
pPlayer->GetBonePosition( iBone, vecTarget, angTarget );;
}
else
{
vecTarget = pPlayer->EyePosition();
}
if ( FVisible( vecTarget ) )
{
float flDistSqr = ( vecTarget - GetAbsOrigin() ).LengthSqr();
if ( flDistSqr < flClosest )
{
flClosest = flDistSqr;
vecClosestTarget = vecTarget;
}
}
}
// Head towards him.
if ( vecClosestTarget != vec3_origin )
{
Vector vecTarget = vecClosestTarget;
Vector vecDir = vecTarget - GetAbsOrigin();
VectorNormalize( vecDir );
float flSpeed = GetAbsVelocity().Length();
QAngle angForward;
VectorAngles( vecDir, angForward );
SetAbsAngles( angForward );
SetAbsVelocity( vecDir * flSpeed );
}
}
SetNextThink( gpGlobals->curtime + 0.1f );
}
示例3: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFFlameThrower::PrimaryAttack()
{
// Are we capable of firing again?
if ( m_flNextPrimaryAttack > gpGlobals->curtime )
return;
// Get the player owning the weapon.
CTFPlayer *pOwner = ToTFPlayer( GetPlayerOwner() );
if ( !pOwner )
return;
if ( !CanAttack() )
{
#if defined ( CLIENT_DLL )
StopFlame();
#endif
m_iWeaponState = FT_STATE_IDLE;
return;
}
CalcIsAttackCritical();
// Because the muzzle is so long, it can stick through a wall if the player is right up against it.
// Make sure the weapon can't fire in this condition by tracing a line between the eye point and the end of the muzzle.
trace_t trace;
Vector vecEye = pOwner->EyePosition();
Vector vecMuzzlePos = GetVisualMuzzlePos();
CTraceFilterIgnoreObjects traceFilter( this, COLLISION_GROUP_NONE );
UTIL_TraceLine( vecEye, vecMuzzlePos, MASK_SOLID, &traceFilter, &trace );
if ( trace.fraction < 1.0 && ( !trace.m_pEnt || trace.m_pEnt->m_takedamage == DAMAGE_NO ) )
{
// there is something between the eye and the end of the muzzle, most likely a wall, don't fire, and stop firing if we already are
if ( m_iWeaponState > FT_STATE_IDLE )
{
#if defined ( CLIENT_DLL )
StopFlame();
#endif
m_iWeaponState = FT_STATE_IDLE;
}
return;
}
switch ( m_iWeaponState )
{
case FT_STATE_IDLE:
case FT_STATE_AIRBLASTING:
{
// Just started, play PRE and start looping view model anim
pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRE );
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
m_flStartFiringTime = gpGlobals->curtime + 0.16; // 5 frames at 30 fps
m_iWeaponState = FT_STATE_STARTFIRING;
}
break;
case FT_STATE_STARTFIRING:
{
// if some time has elapsed, start playing the looping third person anim
if ( gpGlobals->curtime > m_flStartFiringTime )
{
m_iWeaponState = FT_STATE_FIRING;
m_flNextPrimaryAttackAnim = gpGlobals->curtime;
}
}
break;
case FT_STATE_FIRING:
{
if ( gpGlobals->curtime >= m_flNextPrimaryAttackAnim )
{
pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
m_flNextPrimaryAttackAnim = gpGlobals->curtime + 1.4; // fewer than 45 frames!
}
}
break;
default:
break;
}
#ifdef CLIENT_DLL
// Restart our particle effect if we've transitioned across water boundaries
if ( m_iParticleWaterLevel != -1 && pOwner->GetWaterLevel() != m_iParticleWaterLevel )
{
if ( m_iParticleWaterLevel == WL_Eyes || pOwner->GetWaterLevel() == WL_Eyes )
{
RestartParticleEffect();
}
}
#endif
#ifdef CLIENT_DLL
// Handle the flamethrower light
if (tf2c_muzzlelight.GetBool())
{
//.........这里部分代码省略.........