本文整理汇总了C++中CBaseCombatCharacter::EyePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatCharacter::EyePosition方法的具体用法?C++ CBaseCombatCharacter::EyePosition怎么用?C++ CBaseCombatCharacter::EyePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatCharacter
的用法示例。
在下文中一共展示了CBaseCombatCharacter::EyePosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EntityIsVisibleToPlayer
//---------------------------------------------------------
//---------------------------------------------------------
bool CVisibilityMonitor::EntityIsVisibleToPlayer( const visibility_target_t &target, CBasePlayer *pPlayer, int *numTraces )
{
CBaseCombatCharacter *pEyeEntity = pPlayer->ActivePlayerCombatCharacter();
Vector vecTargetOrigin = target.entity->WorldSpaceCenter();
Vector vecPlayerOrigin = pEyeEntity->EyePosition();
float flDistSqr = vecPlayerOrigin.DistToSqr( vecTargetOrigin );
if( flDistSqr <= target.minDistSqr )
{
// Increment the counter of traces done during this polling cycle
*numTraces += 1;
trace_t tr;
int mask = MASK_BLOCKLOS_AND_NPCS & ~CONTENTS_BLOCKLOS;
UTIL_TraceLine( vecPlayerOrigin, vecTargetOrigin, mask, pEyeEntity, COLLISION_GROUP_NONE, &tr );
if( tr.fraction == 1.0f || tr.m_pEnt == target.entity )
return true;
if( debug_visibility_monitor.GetInt() > 1 )
{
NDebugOverlay::Line( vecPlayerOrigin, vecTargetOrigin, 255, 0, 0, false, vismon_poll_frequency.GetFloat() );
}
}
return false;
}
示例2: HandleAnimEvent
//-----------------------------------------------------------------------------
// Purpose: Catch stalker specific messages
// Input :
// Output :
//-----------------------------------------------------------------------------
void CNPC_Stalker::HandleAnimEvent( animevent_t *pEvent )
{
switch( pEvent->Event() )
{
case NPC_EVENT_LEFTFOOT:
{
EmitSound( "NPC_Stalker.FootstepLeft", pEvent->eventtime );
}
break;
case NPC_EVENT_RIGHTFOOT:
{
EmitSound( "NPC_Stalker.FootstepRight", pEvent->eventtime );
}
break;
case STALKER_AE_MELEE_HIT:
{
CBaseEntity *pHurt;
pHurt = CheckTraceHullAttack( 32, Vector(-16,-16,-16), Vector(16,16,16), sk_stalker_melee_dmg.GetFloat(), DMG_SLASH );
if ( pHurt )
{
if ( pHurt->GetFlags() & (FL_NPC|FL_CLIENT) )
{
pHurt->ViewPunch( QAngle( 5, 0, random->RandomInt(-10,10)) );
}
// Spawn some extra blood if we hit a BCC
CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pHurt );
if (pBCC)
{
SpawnBlood(pBCC->EyePosition(), g_vecAttackDir, pBCC->BloodColor(), sk_stalker_melee_dmg.GetFloat());
}
// Play a attack hit sound
EmitSound( "NPC_Stalker.Hit" );
}
break;
}
default:
BaseClass::HandleAnimEvent( pEvent );
break;
}
}
示例3: MoveThink
//------------------------------------------------------------------------------
// Purpose :
//------------------------------------------------------------------------------
void CLookDoor::MoveThink(void)
{
// --------------------------------
// Make sure we have a looker
// --------------------------------
if (m_hLooker == NULL)
{
m_hLooker = (CBaseEntity*)gEntList.FindEntityByName( NULL, m_target, NULL );
if (m_hLooker == NULL)
{
return;
}
}
//--------------------------------------
// Calculate an orgin for the door
//--------------------------------------
Vector vOrigin = 0.5*(GetAbsMaxs() + GetAbsMins()) - GetAbsOrigin();
// If FROM_OPEN flag is set, door proximity is measured
// from the open and not the closed position
if (FBitSet (m_spawnflags, SF_LDOOR_FROM_OPEN))
{
vOrigin += m_vecPosition2;
}
// ------------------------------------------------------
// First add movement based on proximity
// ------------------------------------------------------
float flProxMove = 0;
if (m_flProximityDistance > 0)
{
float flDist = (m_hLooker->GetAbsOrigin() - vOrigin).Length()-m_flProximityOffset;
if (flDist < 0) flDist = 0;
if (flDist < m_flProximityDistance)
{
if (FBitSet (m_spawnflags, SF_LDOOR_THRESHOLD))
{
flProxMove = 1.0;
}
else
{
flProxMove = 1-flDist/m_flProximityDistance;
}
}
}
// ------------------------------------------------------
// Then add movement based on view angle
// ------------------------------------------------------
float flViewMove = 0;
if (m_flFieldOfView > 0)
{
// ----------------------------------------
// Check that toucher is facing the target
// ----------------------------------------
Assert( dynamic_cast< CBaseCombatCharacter* >( m_hLooker.Get() ) );
CBaseCombatCharacter* pBCC = (CBaseCombatCharacter*)m_hLooker.Get();
Vector vTouchDir = pBCC->EyeDirection3D( );
Vector vTargetDir = vOrigin - pBCC->EyePosition();
VectorNormalize(vTargetDir);
float flDotPr = DotProduct(vTouchDir,vTargetDir);
if (flDotPr < m_flFieldOfView)
{
flViewMove = 0.0;
}
else
{
flViewMove = (flDotPr-m_flFieldOfView)/(1.0 - m_flFieldOfView);
}
}
//---------------------------------------
// Summate the two moves
//---------------------------------------
float flMove = flProxMove + flViewMove;
if (flMove > 1.0)
{
flMove = 1.0;
}
// If behavior is inverted do the reverse
if (FBitSet (m_spawnflags, SF_LDOOR_INVERT))
{
flMove = 1-flMove;
}
// Move the door
SetPosition( flMove );
}
示例4: LaunchRocket
//-----------------------------------------------------------------------------
// Purpose: Launch a bounce/impact grenade
//-----------------------------------------------------------------------------
void CGEWeaponRocketLauncher::LaunchRocket( void )
{
CBaseCombatCharacter *pOwner = GetOwner();
if ( !pOwner )
return;
#ifndef CLIENT_DLL
Vector vForward, vRight, vUp;
AngleVectors( pOwner->EyeAngles(), &vForward, &vRight, &vUp );
// Manipulate the shoot position such that it is in front of our gun muzzle
Vector vecSrc = pOwner->Weapon_ShootPosition();
if ( pOwner->IsPlayer() )
{
VectorMA( vecSrc, 4.5f, vRight, vecSrc ); // 3.0, 5.0
VectorMA( vecSrc, 16.5f, vForward, vecSrc ); // 20, 19
VectorMA( vecSrc, -5.25f, vUp, vecSrc ); // -2, -6, -5, 5.25
}
else
{
VectorMA( vecSrc, 20.0, vForward, vecSrc );
}
CheckLaunchPosition( pOwner->EyePosition(), vecSrc );
if ( pOwner->MyNPCPointer() )
vForward = pOwner->MyNPCPointer()->GetActualShootTrajectory( vecSrc );
QAngle angAiming;
VectorAngles( vForward, angAiming );
// Convert us into a bot player :-D
if ( pOwner->IsNPC() )
{
CNPC_GEBase *pNPC = (CNPC_GEBase*) pOwner;
if ( pNPC->GetBotPlayer() )
pOwner = pNPC->GetBotPlayer();
}
CGERocket *pRocket = (CGERocket*)CBaseEntity::Create( "npc_rocket", vecSrc, angAiming, NULL );
if ( pRocket )
{
pRocket->SetThrower( pOwner );
pRocket->SetOwnerEntity( pOwner );
pRocket->SetSourceWeapon(this);
pRocket->SetDamage( GetGEWpnData().m_iDamage );
pRocket->SetDamageRadius( GetGEWpnData().m_flDamageRadius );
if (pOwner->GetTeamNumber() == TEAM_JANUS)
pRocket->SetCollisionGroup( COLLISION_GROUP_GRENADE_JANUS );
else if (pOwner->GetTeamNumber() == TEAM_MI6)
pRocket->SetCollisionGroup( COLLISION_GROUP_GRENADE_MI6 );
// Tell the owner what we threw to implement anti-spamming
if ( pOwner->IsPlayer() )
ToGEMPPlayer( pOwner )->AddThrownObject( pRocket );
}
#endif
// Remove the rocket from our ammo pool
m_iClip1 -= 1;
WeaponSound( SINGLE );
SwitchBodygroup(1, 1);
//Add our view kick in
AddViewKick();
}
示例5: ThrowGrenade
//-----------------------------------------------------------------------------
// Purpose: Throw a primed grenade with timeleft of (gpGlobals->curtime - m_flPrimedTime)
//-----------------------------------------------------------------------------
void CGEWeaponGrenade::ThrowGrenade( float throwforce )
{
CBaseCombatCharacter *pOwner = GetOwner();
if ( !pOwner )
return;
// Remove the grenade from our ammo pool
pOwner->RemoveAmmo( 1, m_iPrimaryAmmoType );
#ifndef CLIENT_DLL
Vector vecEye = pOwner->EyePosition();
Vector vForward, vRight;
AngleVectors( pOwner->EyeAngles(), &vForward, &vRight, NULL );
Vector vecSrc = vecEye + vForward * 18.0f + vRight * 8.0f;
CheckThrowPosition( vecEye, vecSrc );
vForward[2] += 0.1f;
Vector vecThrow;
pOwner->GetVelocity( &vecThrow, NULL );
vecThrow += vForward * throwforce;
// Convert us into a bot player :-D
if ( pOwner->IsNPC() )
{
CNPC_GEBase *pNPC = (CNPC_GEBase*) pOwner;
if ( pNPC->GetBotPlayer() )
pOwner = pNPC->GetBotPlayer();
}
CGEGrenade *pGrenade = (CGEGrenade *)CBaseEntity::Create( "npc_grenade", vecSrc, vec3_angle, NULL );
if ( pGrenade )
{
pGrenade->SetThrower( pOwner );
pGrenade->SetOwnerEntity( pOwner );
pGrenade->SetVelocity( vecThrow, AngularImpulse(600,random->RandomInt(-1000,1000),0) );
pGrenade->SetDamage( GetGEWpnData().m_iDamage );
pGrenade->SetDamageRadius( GetGEWpnData().m_flDamageRadius );
pGrenade->SetSourceWeapon(this);
if (throwforce == GE_GRENADE_THROW_FORCE / 5) // For acheivement tracking.
pGrenade->m_bDroppedOnDeath = true;
// The timer is whatever is left over from the primed time + our fuse minus our
// current time to give us an absolute time in seconds
pGrenade->SetTimer( (m_flPrimedTime + GE_GRENADE_FUSE_TIME) - gpGlobals->curtime );
// Tell the owner what we threw to implement anti-spamming
if ( pOwner->IsPlayer() )
ToGEMPPlayer(pOwner)->AddThrownObject( pGrenade );
}
#endif
m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
m_flTimeWeaponIdle = gpGlobals->curtime + GE_GRENADE_IDLE_DELAY;
m_bDrawNext = true;
WeaponSound( SINGLE );
}