本文整理汇总了C++中CTFPlayer::EyeVectors方法的典型用法代码示例。如果您正苦于以下问题:C++ CTFPlayer::EyeVectors方法的具体用法?C++ CTFPlayer::EyeVectors怎么用?C++ CTFPlayer::EyeVectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTFPlayer
的用法示例。
在下文中一共展示了CTFPlayer::EyeVectors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MaintainTargetInSlot
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponMedigun::MaintainTargetInSlot()
{
CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
if ( !pOwner )
return;
CBaseEntity *pTarget = m_hHealingTarget;
Assert( pTarget );
// Make sure the guy didn't go out of range.
bool bLostTarget = true;
Vector vecSrc = pOwner->Weapon_ShootPosition( );
Vector vecTargetPoint = pTarget->WorldSpaceCenter();
Vector vecPoint;
// If it's brush built, use absmins/absmaxs
pTarget->CollisionProp()->CalcNearestPoint( vecSrc, &vecPoint );
float flDistance = (vecPoint - vecSrc).Length();
if ( flDistance < GetStickRange() )
{
if ( m_flNextTargetCheckTime > gpGlobals->curtime )
return;
m_flNextTargetCheckTime = gpGlobals->curtime + 1.0f;
trace_t tr;
CMedigunFilter drainFilter( pOwner );
Vector vecAiming;
pOwner->EyeVectors( &vecAiming );
Vector vecEnd = vecSrc + vecAiming * GetTargetRange();
UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, DMG_GENERIC, &tr );
// Still visible?
if ( tr.m_pEnt == pTarget )
return;
UTIL_TraceLine( vecSrc, vecTargetPoint, MASK_SHOT, &drainFilter, &tr );
// Still visible?
if (( tr.fraction == 1.0f) || (tr.m_pEnt == pTarget))
return;
// If we failed, try the target's eye point as well
UTIL_TraceLine( vecSrc, pTarget->EyePosition(), MASK_SHOT, &drainFilter, &tr );
if (( tr.fraction == 1.0f) || (tr.m_pEnt == pTarget))
return;
}
// We've lost this guy
if ( bLostTarget )
{
RemoveHealingTarget();
}
}
示例2: FindNewTargetForSlot
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponMedigun::FindNewTargetForSlot()
{
CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
if ( !pOwner )
return;
Vector vecSrc = pOwner->Weapon_ShootPosition( );
if ( m_hHealingTarget )
{
RemoveHealingTarget();
}
// In Normal mode, we heal players under our crosshair
Vector vecAiming;
pOwner->EyeVectors( &vecAiming );
// Find a player in range of this player, and make sure they're healable.
Vector vecEnd = vecSrc + vecAiming * GetTargetRange();
trace_t tr;
UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, DMG_GENERIC, &tr );
if ( tr.fraction != 1.0 && tr.m_pEnt )
{
if ( CouldHealTarget( tr.m_pEnt ) )
{
#ifdef GAME_DLL
pOwner->SpeakConceptIfAllowed( MP_CONCEPT_MEDIC_STARTEDHEALING );
if ( tr.m_pEnt->IsPlayer() )
{
CTFPlayer *pTarget = ToTFPlayer( tr.m_pEnt );
pTarget->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_STARTEDHEALING );
}
// Start the heal target thinking.
SetContextThink( &CWeaponMedigun::HealTargetThink, gpGlobals->curtime, s_pszMedigunHealTargetThink );
#endif
m_hHealingTarget.Set( tr.m_pEnt );
m_flNextTargetCheckTime = gpGlobals->curtime + 1.0f;
}
}
}