本文整理汇总了C++中CBaseEntity::GetAbsVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::GetAbsVelocity方法的具体用法?C++ CBaseEntity::GetAbsVelocity怎么用?C++ CBaseEntity::GetAbsVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::GetAbsVelocity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetGroundEntity
void CASW_Drone_Movement::SetGroundEntity( CBaseEntity *newGround )
{
CBaseEntity *oldGround = m_pNPC->GetGroundEntity();
Vector vecBaseVelocity = m_pNPC->GetBaseVelocity();
if ( !oldGround && newGround )
{
// Subtract ground velocity at instant we hit ground jumping
vecBaseVelocity -= newGround->GetAbsVelocity();
vecBaseVelocity.z = newGround->GetAbsVelocity().z;
}
else if ( oldGround && !newGround )
{
// Add in ground velocity at instant we started jumping
vecBaseVelocity += oldGround->GetAbsVelocity();
vecBaseVelocity.z = oldGround->GetAbsVelocity().z;
}
// TODO
//else if ( oldGround && newGround && oldGround != newGround )
//{
// subtract old and add new ground velocity? When might his occur, who knows? ywb 9/24/03
//}
m_pNPC->SetBaseVelocity( vecBaseVelocity );
m_pNPC->SetGroundEntity( newGround );
}
示例2: if
void CHL2GameMovement::SetGroundEntity( CBaseEntity *newGround )
{
CBaseEntity *oldGround = player->GetGroundEntity();
Vector vecBaseVelocity = player->GetBaseVelocity();
//Adrian: Special case for combine balls.
if ( newGround && newGround->GetCollisionGroup() == HL2COLLISION_GROUP_COMBINE_BALL_NPC )
{
return;
}
else if ( !oldGround && newGround )
{
// Subtract ground velocity at instant we hit ground jumping
vecBaseVelocity -= newGround->GetAbsVelocity();
vecBaseVelocity.z = newGround->GetAbsVelocity().z;
}
else if ( oldGround && !newGround )
{
// Add in ground velocity at instant we started jumping
vecBaseVelocity += oldGround->GetAbsVelocity();
vecBaseVelocity.z = oldGround->GetAbsVelocity().z;
}
player->SetBaseVelocity( vecBaseVelocity );
player->SetGroundEntity( newGround );
}
示例3: UpdatePlayerDopplerShift
//------------------------------------------------------------------------------
// Purpose :
// Input :
// Output :
//------------------------------------------------------------------------------
void CBaseHelicopter::UpdatePlayerDopplerShift( )
{
// -----------------------------
// make rotor, engine sounds
// -----------------------------
if (m_iSoundState == 0)
{
// Sound startup.
InitializeRotorSound();
}
else
{
CBaseEntity *pPlayer = NULL;
// UNDONE: this needs to send different sounds to every player for multiplayer.
// FIXME: this isn't the correct way to find a player!!!
pPlayer = gEntList.FindEntityByName( NULL, "!player" );
if (pPlayer)
{
Vector dir;
VectorSubtract( pPlayer->GetAbsOrigin(), GetAbsOrigin(), dir );
VectorNormalize(dir);
#if 1
float velReceiver = DotProduct( pPlayer->GetAbsVelocity(), dir );
float velTransmitter = -DotProduct( GetAbsVelocity(), dir );
// speed of sound == 13049in/s
int iPitch = (int)(100 * ((1 - velReceiver / 13049) / (1 + velTransmitter / 13049)));
#else
// This is a bogus doppler shift, but I like it better
float relV = DotProduct( GetAbsVelocity() - pPlayer->GetAbsVelocity(), dir );
int iPitch = (int)(100 + relV / 50.0);
#endif
// clamp pitch shifts
if (iPitch > 250)
{
iPitch = 250;
}
if (iPitch < 50)
{
iPitch = 50;
}
UpdateRotorSoundPitch( iPitch );
// Msg( "Pitch:%d\n", iPitch );
}
else
{
Msg( "Chopper didn't find a player!\n" );
}
}
}
示例4: ProcessAnimationEvents
void CWeaponBaseGun::ProcessAnimationEvents()
{
// Lowers the weapon once the player goes faster than the limit speed
// Credit: This is a modified version of
// https://developer.valvesoftware.com/wiki/Lowering_your_weapon_on_sprint
// If we currently don't want the weapon to ever lower, don't calculate it. Easy
if (!mom_weapon_speed_lower_enable.GetBool()) return;
CBaseEntity *pOwner = GetOwnerEntity();
// With pOwner being just CBaseEntity, we allow the replay entity to also lower its weapon!
if (!pOwner) return;
vec_t pCurrent2DVelocitySqr = pOwner->GetAbsVelocity().Length2DSqr();
float pThresholdSpeed = mom_weapon_speed_lower.GetFloat();
// Don't simplify this. Seriously.
if ((!m_bWeaponIsLowered || (m_bWeaponIsLowered && GetIdealActivity() == ACT_VM_IDLE)) &&
pCurrent2DVelocitySqr >= pThresholdSpeed * pThresholdSpeed) // pow is faster than a square root
{
/* The rht of the OR takes care of the weapon being not lowered after shooting. Note how it's not
* GetIdealActivity() != ACT_VM_IDLE_LOWERED so we don't change the firing animation!
* It takes a bit until the weapon lowers itself again (IDLE is not set instantly) but that's perfect!
*/
m_bWeaponIsLowered = true;
SendWeaponAnim(ACT_VM_IDLE_LOWERED);
}
else if (m_bWeaponIsLowered && pCurrent2DVelocitySqr < pThresholdSpeed * pThresholdSpeed)
{
m_bWeaponIsLowered = false;
SendWeaponAnim(ACT_VM_IDLE);
}
}
示例5: TransferChildren
void TransferChildren( CBaseEntity *pOldParent, CBaseEntity *pNewParent )
{
CBaseEntity *pChild = pOldParent->FirstMoveChild();
while ( pChild )
{
// NOTE: Have to do this before the unlink to ensure local coords are valid
Vector vecAbsOrigin = pChild->GetAbsOrigin();
QAngle angAbsRotation = pChild->GetAbsAngles();
Vector vecAbsVelocity = pChild->GetAbsVelocity();
// QAngle vecAbsAngVelocity = pChild->GetAbsAngularVelocity();
UnlinkChild( pOldParent, pChild );
LinkChild( pNewParent, pChild );
// FIXME: This is a hack to guarantee update of the local origin, angles, etc.
pChild->m_vecAbsOrigin.Init( FLT_MAX, FLT_MAX, FLT_MAX );
pChild->m_angAbsRotation.Init( FLT_MAX, FLT_MAX, FLT_MAX );
pChild->m_vecAbsVelocity.Init( FLT_MAX, FLT_MAX, FLT_MAX );
pChild->SetAbsOrigin(vecAbsOrigin);
pChild->SetAbsAngles(angAbsRotation);
pChild->SetAbsVelocity(vecAbsVelocity);
// pChild->SetAbsAngularVelocity(vecAbsAngVelocity);
pChild = pOldParent->FirstMoveChild();
}
}
示例6: OnTakeDamage
int CFuncShootBoost::OnTakeDamage(const CTakeDamageInfo &info)
{
CBaseEntity *pInflictor = info.GetAttacker();
if (pInflictor)
{
Vector finalVel = m_vPushDir.Normalized() * m_fPushForce;
switch (m_iIncrease)
{
case 0:
break;
case 1:
finalVel += pInflictor->GetAbsVelocity();
break;
case 2:
if (finalVel.LengthSqr() < pInflictor->GetAbsVelocity().LengthSqr())
finalVel = pInflictor->GetAbsVelocity();
break;
case 3: // The description of this method says the player velocity is increaed by final velocity,
// but we're just adding one vec to the other, which is not quite the same
if (finalVel.LengthSqr() < pInflictor->GetAbsVelocity().LengthSqr())
finalVel += pInflictor->GetAbsVelocity();
break;
case 4:
pInflictor->SetBaseVelocity(finalVel);
break;
default:
DevWarning("CFuncShootBoost:: %i not recognised as valid for m_iIncrease", m_iIncrease);
break;
}
if (m_Destination)
{
if (((CBaseTrigger *) m_Destination)->IsTouching(pInflictor))
{
pInflictor->SetAbsVelocity(finalVel);
}
}
else
{
pInflictor->SetAbsVelocity(finalVel);
}
}
// As we don't want to break it, we don't call BaseClass::OnTakeDamage(info);
// OnTakeDamage returns the damage dealt
return info.GetDamage();
}
示例7: SetGroundEntity
// This was the virtual void, overriding it for snow friction
void CMomentumGameMovement::SetGroundEntity(trace_t *pm)
{
//CMomentumPlayer *player = GetMomentumPlayer();
CBaseEntity *newGround = pm ? pm->m_pEnt : NULL;
CBaseEntity *oldGround = player->GetGroundEntity();
Vector vecBaseVelocity = player->GetBaseVelocity();
if (!oldGround && newGround)
{
// Subtract ground velocity at instant we hit ground jumping
vecBaseVelocity -= newGround->GetAbsVelocity();
vecBaseVelocity.z = newGround->GetAbsVelocity().z;
}
else if (oldGround && !newGround)
{
// Add in ground velocity at instant we started jumping
vecBaseVelocity += oldGround->GetAbsVelocity();
vecBaseVelocity.z = oldGround->GetAbsVelocity().z;
}
player->SetBaseVelocity(vecBaseVelocity);
player->SetGroundEntity(newGround);
// If we are on something...
if (newGround)
{
CategorizeGroundSurface(*pm);//Snow friction override
// Then we are not in water jump sequence
player->m_flWaterJumpTime = 0;
// Standing on an entity other than the world, so signal that we are touching something.
if (!pm->DidHitWorld())
{
MoveHelper()->AddToTouched(*pm, mv->m_vecVelocity);
}
mv->m_vecVelocity.z = 0.0f;
}
}
示例8: HandleAnimEvent
void CNPC_Gargantua::HandleAnimEvent( animevent_t *pEvent )
{
CPASAttenuationFilter filter( this );
switch( pEvent->event )
{
case GARG_AE_SLASH_LEFT:
{
// HACKHACK!!!
CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0, sk_gargantua_dmg_slash.GetFloat(), DMG_SLASH );
if (pHurt)
{
if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
{
pHurt->ViewPunch( QAngle( -30, -30, 30 ) );
Vector vRight;
AngleVectors( GetAbsAngles(), NULL, &vRight, NULL );
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() - vRight * 100 );
}
EmitSound( filter, entindex(), "Garg.AttackHit" );
}
else // Play a random attack miss sound
{
EmitSound( filter, entindex(),"Garg.AttackMiss" );
}
}
break;
case GARG_AE_RIGHT_FOOT:
case GARG_AE_LEFT_FOOT:
UTIL_ScreenShake( GetAbsOrigin(), 4.0, 3.0, 1.0, 1500, SHAKE_START );
EmitSound( filter, entindex(), "Garg.Footstep" );
break;
case GARG_AE_STOMP:
StompAttack();
m_seeTime = gpGlobals->curtime + 12;
break;
case GARG_AE_BREATHE:
EmitSound( filter, entindex(), "Garg.Breath" );
break;
default:
BaseClass::HandleAnimEvent(pEvent);
break;
}
}
示例9: HandleAnimEvent
void CGargantua::HandleAnimEvent(AnimEvent_t& event)
{
switch( event.event )
{
case GARG_AE_SLASH_LEFT:
{
// HACKHACK!!!
CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0, gSkillData.GetGargantuaDmgSlash(), DMG_SLASH );
if (pHurt)
{
if ( pHurt->GetFlags().Any( FL_MONSTER | FL_CLIENT ) )
{
pHurt->SetPunchAngle( Vector(
-30, // pitch
-30, // yaw
30 //roll
) );
//UTIL_MakeVectors( GetAbsAngles() ); // called by CheckTraceHullAttack
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() - gpGlobals->v_right * 100 );
}
EMIT_SOUND_DYN ( this, CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0,15) );
}
else // Play a random attack miss sound
EMIT_SOUND_DYN ( this, CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0,15) );
Vector forward;
UTIL_MakeVectorsPrivate( GetAbsAngles(), &forward, nullptr, nullptr );
}
break;
case GARG_AE_RIGHT_FOOT:
case GARG_AE_LEFT_FOOT:
UTIL_ScreenShake( GetAbsOrigin(), 4.0, 3.0, 1.0, 750 );
EMIT_SOUND_DYN ( this, CHAN_BODY, pFootSounds[ RANDOM_LONG(0,ARRAYSIZE(pFootSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) );
break;
case GARG_AE_STOMP:
StompAttack();
m_seeTime = gpGlobals->time + 12;
break;
case GARG_AE_BREATHE:
EMIT_SOUND_DYN ( this, CHAN_VOICE, pBreatheSounds[ RANDOM_LONG(0,ARRAYSIZE(pBreatheSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) );
break;
default:
CBaseMonster::HandleAnimEvent( event );
break;
}
}
示例10: HandleAnimEvent
void CNPC_Gargantua::HandleAnimEvent( animevent_t *pEvent )
{
CPASAttenuationFilter filter( this );
switch( pEvent->event )
{
case GARG_AE_SLASH_LEFT:
{
// HACKHACK!!!
CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0, sk_gargantua_dmg_slash.GetFloat(), DMG_SLASH );
if (pHurt)
{
if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
{
pHurt->ViewPunch( QAngle( -30, -30, 30 ) );
Vector vRight;
AngleVectors( GetAbsAngles(), NULL, &vRight, NULL );
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() - vRight * 100 );
}
enginesound->EmitSound( filter, entindex(), CHAN_WEAPON, pAttackHitSounds[ random->RandomInt(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 50 + random->RandomInt(0,15) );
}
else // Play a random attack miss sound
enginesound->EmitSound( filter, entindex(), CHAN_WEAPON, pAttackMissSounds[ random->RandomInt(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 50 + random->RandomInt(0,15) );
}
break;
case GARG_AE_RIGHT_FOOT:
case GARG_AE_LEFT_FOOT:
UTIL_ScreenShake( GetAbsOrigin(), 4.0, 3.0, 1.0, 1500, SHAKE_START );
enginesound->EmitSound( filter, entindex(), CHAN_BODY, pFootSounds[ random->RandomInt(0,ARRAYSIZE(pFootSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + random->RandomInt(-10,10) );
break;
case GARG_AE_STOMP:
StompAttack();
m_seeTime = gpGlobals->curtime + 12;
break;
case GARG_AE_BREATHE:
enginesound->EmitSound( filter, entindex(), CHAN_VOICE, pBreatheSounds[ random->RandomInt(0,ARRAYSIZE(pBreatheSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + random->RandomInt(-10,10) );
break;
default:
BaseClass::HandleAnimEvent(pEvent);
break;
}
}
示例11: Think
void CGrenadeSpit::Think( void )
{
InitHissSound();
if ( m_pHissSound == NULL )
return;
// Add a doppler effect to the balls as they travel
#ifdef HL2SB
CBaseEntity *pPlayer = AI_GetNearestPlayer( GetAbsOrigin() );
#else
CBaseEntity *pPlayer = AI_GetSinglePlayer();
#endif
if ( pPlayer != NULL )
{
Vector dir;
VectorSubtract( pPlayer->GetAbsOrigin(), GetAbsOrigin(), dir );
VectorNormalize(dir);
float velReceiver = DotProduct( pPlayer->GetAbsVelocity(), dir );
float velTransmitter = -DotProduct( GetAbsVelocity(), dir );
// speed of sound == 13049in/s
int iPitch = 100 * ((1 - velReceiver / 13049) / (1 + velTransmitter / 13049));
// clamp pitch shifts
if ( iPitch > 250 )
{
iPitch = 250;
}
if ( iPitch < 50 )
{
iPitch = 50;
}
// Set the pitch we've calculated
CSoundEnvelopeController::GetController().SoundChangePitch( m_pHissSound, iPitch, 0.1f );
}
// Set us up to think again shortly
SetNextThink( gpGlobals->curtime + 0.05f );
}
示例12: ProcessImpacts
void CMoveHelperClient::ProcessImpacts( void )
{
m_pHost->PhysicsTouchTriggers();
// Don't bother if the player ain't solid
if ( m_pHost->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
return;
// Save off the velocity, cause we need to temporarily reset it
Vector vel = m_pHost->GetAbsVelocity();
// Touch other objects that were intersected during the movement.
for (int i = 0 ; i < m_TouchList.Count(); i++)
{
// Run the impact function as if we had run it during movement.
C_BaseEntity *entity = ClientEntityList().GetEnt( m_TouchList[i].trace.m_pEnt->entindex() );
if ( !entity )
continue;
Assert( entity != m_pHost );
// Don't ever collide with self!!!!
if ( entity == m_pHost )
continue;
// Reconstruct trace results.
m_TouchList[i].trace.m_pEnt = entity;
// Use the velocity we had when we collided, so boxes will move, etc.
m_pHost->SetAbsVelocity( m_TouchList[i].deltavelocity );
entity->PhysicsImpact( m_pHost, m_TouchList[i].trace );
}
// Restore the velocity
m_pHost->SetAbsVelocity( vel );
// So no stuff is ever left over, sigh...
ResetTouchList();
}
示例13: GetOwner
int CWeaponStunStick::WeaponMeleeAttack1Condition( float flDot, float flDist )
{
// Attempt to lead the target (needed because citizens can't hit manhacks with the crowbar!)
CAI_BaseNPC *pNPC = GetOwner()->MyNPCPointer();
CBaseEntity *pEnemy = pNPC->GetEnemy();
if (!pEnemy)
return COND_NONE;
Vector vecVelocity;
AngularImpulse angVelocity;
pEnemy->GetVelocity( &vecVelocity, &angVelocity );
// Project where the enemy will be in a little while, add some randomness so he doesn't always hit
float dt = sk_crowbar_lead_time.GetFloat();
dt += random->RandomFloat( -0.3f, 0.2f );
if ( dt < 0.0f )
dt = 0.0f;
Vector vecExtrapolatedPos;
VectorMA( pEnemy->WorldSpaceCenter(), dt, vecVelocity, vecExtrapolatedPos );
Vector vecDelta;
VectorSubtract( vecExtrapolatedPos, pNPC->WorldSpaceCenter(), vecDelta );
if ( fabs( vecDelta.z ) > 70 )
{
return COND_TOO_FAR_TO_ATTACK;
}
Vector vecForward = pNPC->BodyDirection2D( );
vecDelta.z = 0.0f;
float flExtrapolatedDot = DotProduct2D( vecDelta.AsVector2D(), vecForward.AsVector2D() );
if ((flDot < 0.7) && (flExtrapolatedDot < 0.7))
{
return COND_NOT_FACING_ATTACK;
}
float flExtrapolatedDist = Vector2DNormalize( vecDelta.AsVector2D() );
if( pEnemy->IsPlayer() )
{
//Vector vecDir = pEnemy->GetSmoothedVelocity();
//float flSpeed = VectorNormalize( vecDir );
// If player will be in front of me in one-half second, clock his arse.
Vector vecProjectEnemy = pEnemy->GetAbsOrigin() + (pEnemy->GetAbsVelocity() * 0.35);
Vector vecProjectMe = GetAbsOrigin();
if( (vecProjectMe - vecProjectEnemy).Length2D() <= 48.0f )
{
return COND_CAN_MELEE_ATTACK1;
}
}
/*
if( metropolice_move_and_melee.GetBool() )
{
if( pNPC->IsMoving() )
{
flTargetDist *= 1.5f;
}
}
*/
float flTargetDist = 48.0f;
if ((flDist > flTargetDist) && (flExtrapolatedDist > flTargetDist))
{
return COND_TOO_FAR_TO_ATTACK;
}
return COND_CAN_MELEE_ATTACK1;
}
示例14: HandleAnimEvent
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CNPC_Bullsquid::HandleAnimEvent( animevent_t *pEvent )
{
switch( pEvent->event )
{
case BSQUID_AE_SPIT:
{
if ( GetEnemy() )
{
Vector vSpitPos;
QAngle vSpitAngle;
GetAttachment( "Mouth", vSpitPos, vSpitAngle);
Vector vTarget = GetEnemy()->GetAbsOrigin();
Vector vToss;
CBaseEntity* pBlocker;
float flGravity = sv_gravity.GetFloat() * SPIT_GRAVITY;
ThrowLimit(vSpitPos, vTarget, flGravity, 3, Vector(0,0,0), Vector(0,0,0), GetEnemy(), &vToss, &pBlocker);
CGrenadeSpit *pGrenade = (CGrenadeSpit*)CreateNoSpawn( "grenade_spit", vSpitPos, vec3_angle, this );
//pGrenade->KeyValue( "velocity", vToss );
pGrenade->Spawn( );
pGrenade->SetOwner( this );
pGrenade->SetOwnerEntity( this );
pGrenade->SetSpitSize( 2 );
pGrenade->SetAbsVelocity( vToss );
// Tumble through the air
pGrenade->SetLocalAngularVelocity(
QAngle(
random->RandomFloat ( -100, -500 ),
random->RandomFloat ( -100, -500 ),
random->RandomFloat ( -100, -500 )
)
);
AttackSound();
CPVSFilter filter( vSpitPos );
te->SpriteSpray( filter, 0.0,
&vSpitPos, &vToss, m_nSquidSpitSprite, 5, 10, 15 );
}
}
break;
case BSQUID_AE_BITE:
{
// SOUND HERE!
CBaseEntity *pHurt = CheckTraceHullAttack( 70, Vector(-16,-16,-16), Vector(16,16,16), sk_bullsquid_dmg_bite.GetFloat(), DMG_SLASH );
if ( pHurt )
{
Vector forward, up;
AngleVectors( GetAbsAngles(), &forward, NULL, &up );
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() - (forward * 100) );
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() + (up * 100) );
pHurt->RemoveFlag( FL_ONGROUND );
}
}
break;
case BSQUID_AE_WHIP_SND:
{
EmitSound( "NPC_Bullsquid.TailWhip" );
break;
}
/*
case BSQUID_AE_TAILWHIP:
{
CBaseEntity *pHurt = CheckTraceHullAttack( 70, Vector(-16,-16,-16), Vector(16,16,16), sk_bullsquid_dmg_whip.GetFloat(), DMG_SLASH | DMG_ALWAYSGIB );
if ( pHurt )
{
Vector right, up;
AngleVectors( GetAbsAngles(), NULL, &right, &up );
if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) )
pHurt->ViewPunch( QAngle( 20, 0, -20 ) );
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() + (right * 200) );
pHurt->SetAbsVelocity( pHurt->GetAbsVelocity() + (up * 100) );
}
}
break;
*/
case BSQUID_AE_BLINK:
{
// close eye.
m_nSkin = 1;
}
break;
case BSQUID_AE_HOP:
{
float flGravity = sv_gravity.GetFloat();
//.........这里部分代码省略.........
示例15: SonicAttack
//=========================================================
// SonicAttack
//=========================================================
void CNPC_Houndeye::SonicAttack ( void )
{
EmitSound( "NPC_Houndeye.SonicAttack" );
if (m_pEnergyWave)
{
UTIL_Remove(m_pEnergyWave);
}
Vector vFacingDir = EyeDirection3D( );
m_pEnergyWave = (CEnergyWave*)Create( "energy_wave", EyePosition(), GetLocalAngles() );
m_flEndEnergyWaveTime = gpGlobals->curtime + 1; //<<TEMP>> magic
m_pEnergyWave->SetAbsVelocity( 100*vFacingDir );
CBaseEntity *pEntity = NULL;
// iterate on all entities in the vicinity.
for ( CEntitySphereQuery sphere( GetAbsOrigin(), HOUNDEYE_MAX_ATTACK_RADIUS ); pEntity = sphere.GetCurrentEntity(); sphere.NextEntity() )
{
if (pEntity->Classify() == CLASS_HOUNDEYE)
{
continue;
}
if (pEntity->GetFlags() & FL_NOTARGET)
{
continue;
}
IPhysicsObject *pPhysicsObject = pEntity->VPhysicsGetObject();
if ( pEntity->m_takedamage != DAMAGE_NO || pPhysicsObject)
{
// --------------------------
// Adjust damage by distance
// --------------------------
float flDist = (pEntity->WorldSpaceCenter() - GetAbsOrigin()).Length();
float flDamageAdjuster = 1-( flDist / HOUNDEYE_MAX_ATTACK_RADIUS );
// --------------------------
// Adjust damage by direction
// --------------------------
Vector forward;
AngleVectors( GetAbsAngles(), &forward );
Vector vEntDir = (pEntity->GetAbsOrigin() - GetAbsOrigin());
VectorNormalize(vEntDir);
float flDotPr = DotProduct(forward,vEntDir);
flDamageAdjuster *= flDotPr;
if (flDamageAdjuster < 0)
{
continue;
}
// --------------------------
// Adjust damage by visibility
// --------------------------
if ( !FVisible( pEntity ) )
{
if ( pEntity->IsPlayer() )
{
// if this entity is a client, and is not in full view, inflict half damage. We do this so that players still
// take the residual damage if they don't totally leave the houndeye's effective radius. We restrict it to clients
// so that monsters in other parts of the level don't take the damage and get pissed.
flDamageAdjuster *= 0.5;
}
else if ( !FClassnameIs( pEntity, "func_breakable" ) && !FClassnameIs( pEntity, "func_pushable" ) )
{
// do not hurt nonclients through walls, but allow damage to be done to breakables
continue;
}
}
// ------------------------------
// Apply the damage
// ------------------------------
if (pEntity->m_takedamage != DAMAGE_NO)
{
CTakeDamageInfo info( this, this, flDamageAdjuster * sk_Houndeye_dmg_blast.GetFloat(), DMG_SONIC | DMG_ALWAYSGIB );
CalculateExplosiveDamageForce( &info, (pEntity->GetAbsOrigin() - GetAbsOrigin()), pEntity->GetAbsOrigin() );
pEntity->TakeDamage( info );
// Throw the player
if ( pEntity->IsPlayer() )
{
Vector forward;
AngleVectors( GetLocalAngles(), &forward );
Vector vecVelocity = pEntity->GetAbsVelocity();
vecVelocity += forward * 250 * flDamageAdjuster;
vecVelocity.z = 300 * flDamageAdjuster;
pEntity->SetAbsVelocity( vecVelocity );
pEntity->ViewPunch( QAngle(random->RandomInt(-20,20), 0, random->RandomInt(-20,20)) );
}
}
// ------------------------------
// Apply physics foces
// ------------------------------
//.........这里部分代码省略.........