本文整理汇总了C++中CalculateMeleeDamageForce函数的典型用法代码示例。如果您正苦于以下问题:C++ CalculateMeleeDamageForce函数的具体用法?C++ CalculateMeleeDamageForce怎么用?C++ CalculateMeleeDamageForce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CalculateMeleeDamageForce函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTouchTrace
void CNPC_ControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
if (m_takedamage = DAMAGE_YES )
{
trace_t tr;
tr = GetTouchTrace( );
ClearMultiDamage( );
Vector vecAttackDir = GetAbsVelocity();
VectorNormalize( vecAttackDir );
if (m_hOwner != NULL)
{
CTakeDamageInfo info( this, m_hOwner, sk_controller_dmgball.GetFloat(), DMG_ENERGYBEAM );
CalculateMeleeDamageForce( &info, vecAttackDir, tr.endpos );
pOther->DispatchTraceAttack( info, vecAttackDir, &tr );
}
else
{
CTakeDamageInfo info( this, this, sk_controller_dmgball.GetFloat(), DMG_ENERGYBEAM );
CalculateMeleeDamageForce( &info, vecAttackDir, tr.endpos );
pOther->DispatchTraceAttack( info, vecAttackDir, &tr );
}
ApplyMultiDamage();
// void UTIL_EmitAmbientSound( CBaseEntity *entity, const Vector &vecOrigin, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float soundtime /*= 0.0f*/ )
UTIL_EmitAmbientSound( GetSoundSourceIndex(), tr.endpos, "Controller.ElectroSound", 0.3, SNDLVL_NORM, 0, random->RandomInt( 90, 99 ) );
}
Kill();
}
示例2: GetAbsOrigin
void CNPC_Infected::MeleeAttack( float distance, float damage, QAngle &viewPunch, Vector &shove )
{
Vector vecForceDir;
// Always hurt bullseyes for now
if ( ( GetEnemy() != NULL ) && ( GetEnemy()->Classify() == CLASS_BULLSEYE ) )
{
vecForceDir = (GetEnemy()->GetAbsOrigin() - GetAbsOrigin());
CTakeDamageInfo info( this, this, damage, DMG_SLASH );
CalculateMeleeDamageForce( &info, vecForceDir, GetEnemy()->GetAbsOrigin() );
GetEnemy()->TakeDamage( info );
return;
}
CBaseEntity *pHurt = CheckTraceHullAttack( distance, -Vector(16,16,32), Vector(16,16,32), damage, DMG_SLASH, 5.0f );
if ( pHurt )
{
vecForceDir = ( pHurt->WorldSpaceCenter() - WorldSpaceCenter() );
//FIXME: Until the interaction is setup, kill combine soldiers in one hit -- jdw
if ( FClassnameIs( pHurt, "npc_combine_s" ) )
{
CTakeDamageInfo dmgInfo( this, this, pHurt->m_iHealth+25, DMG_SLASH );
CalculateMeleeDamageForce( &dmgInfo, vecForceDir, pHurt->GetAbsOrigin() );
pHurt->TakeDamage( dmgInfo );
return;
}
CBasePlayer *pPlayer = ToBasePlayer( pHurt );
if ( pPlayer != NULL )
{
//Kick the player angles
if ( !(pPlayer->GetFlags() & FL_GODMODE ) && pPlayer->GetMoveType() != MOVETYPE_NOCLIP )
{
pPlayer->ViewPunch( viewPunch );
Vector dir = pHurt->GetAbsOrigin() - GetAbsOrigin();
VectorNormalize(dir);
QAngle angles;
VectorAngles( dir, angles );
Vector forward, right;
AngleVectors( angles, &forward, &right, NULL );
//Push the target back
pHurt->ApplyAbsVelocityImpulse( - right * shove[1] - forward * shove[0] );
}
}
// Play a random attack hit sound
EmitSound( "Zombie.Punch" );
}
else
{
EmitSound( "Zombie.AttackMiss" );
}
}
示例3: info
//-----------------------------------------------------------------------------
// 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 );
}
}
示例4: VectorNormalize
void CNPC_Hydra::Stab( CBaseEntity *pOther, const Vector &vecSpeed, trace_t &tr )
{
if (pOther->m_takedamage == DAMAGE_YES && !pOther->IsPlayer())
{
Vector dir = vecSpeed;
VectorNormalize( dir );
if ( !sv_hydraTestSpike.GetInt() )
{
ClearMultiDamage();
// FIXME: this is bogus
CTakeDamageInfo info( this, this, pOther->m_iHealth+25, DMG_SLASH );
CalculateMeleeDamageForce( &info, dir, tr.endpos );
pOther->DispatchTraceAttack( info, dir, &tr );
ApplyMultiDamage();
}
else
{
CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating *>(pOther);
if ( pAnimating )
{
AttachStabbedEntity( pAnimating, vecSpeed * 30, tr );
}
}
}
else
{
Nudge( pOther, tr.endpos, vecSpeed );
}
}
示例5: GetPlayerOwner
//=====================================================================================//
// Purpose: Performs the screen shake and it checks to see if we hit an entity to
// handle the proper damage
// An entity here can be another player or a wood plank
//=====================================================================================//
void CTDPBludgeonWeaponBase::Hit( trace_t &tr, Activity nHitActivity )
{
// Do we have a valid owner holding the weapon?
CTDPPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
// Let's shake the screen a little
AddViewKick();
// if tr.m_pEnt is not NULL it means we have hit a target
if ( tr.m_pEnt != NULL )
{
Vector vForward;
pPlayer->EyeVectors( &vForward, NULL, NULL );
VectorNormalize( vForward );
// Process the damage and send it to the entity we just hit
CTakeDamageInfo dmgInfo( GetOwner(), GetOwner(), GetDamageForActivity( nHitActivity ), DMG_CLUB );
CalculateMeleeDamageForce( &dmgInfo, vForward, tr.endpos );
tr.m_pEnt->DispatchTraceAttack( dmgInfo, vForward, &tr );
ApplyMultiDamage();
#if defined( GAME_DLL )
// Now hit all triggers along the ray that...
TraceAttackToTriggers( dmgInfo, tr.startpos, tr.endpos, vForward );
#endif
}
// Apply an impact effect
ImpactEffect( tr );
}
示例6: GetTouchTrace
void CGrenadeEnergy::GrenadeEnergyTouch( CBaseEntity *pOther )
{
if ( pOther->m_takedamage )
{
float flLifeLeft = 1-(gpGlobals->curtime - m_flLaunchTime)/ENERGY_GRENADE_LIFETIME;
if ( pOther->GetFlags() & (FL_CLIENT) )
{
CBasePlayer *pPlayer = ( CBasePlayer * )pOther;
float flKick = 120 * flLifeLeft;
pPlayer->m_Local.m_vecPunchAngle.SetX( flKick * (random->RandomInt(0,1) == 1) ? -1 : 1 );
pPlayer->m_Local.m_vecPunchAngle.SetY( flKick * (random->RandomInt(0,1) == 1) ? -1 : 1 );
}
float flDamage = m_flDamage * flLifeLeft;
if (flDamage < 1)
{
flDamage = 1;
}
trace_t tr;
tr = GetTouchTrace();
CTakeDamageInfo info( this, GetThrower(), m_flDamage * flLifeLeft, DMG_SONIC );
CalculateMeleeDamageForce( &info, (tr.endpos - tr.startpos), tr.endpos );
pOther->TakeDamage( info );
}
Detonate();
}
示例7: ToBasePlayer
//------------------------------------------------------------------------------
// Purpose: Implement impact function
//------------------------------------------------------------------------------
void CWeaponCrowbar::Hit( void )
{
//Make sound for the AI
#ifndef CLIENT_DLL
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
CSoundEnt::InsertSound( SOUND_BULLET_IMPACT, m_traceHit.endpos, 400, 0.2f, pPlayer );
CBaseEntity *pHitEntity = m_traceHit.m_pEnt;
//Apply damage to a hit target
if ( pHitEntity != NULL )
{
Vector hitDirection;
pPlayer->EyeVectors( &hitDirection, NULL, NULL );
VectorNormalize( hitDirection );
ClearMultiDamage();
CTakeDamageInfo info( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB );
CalculateMeleeDamageForce( &info, hitDirection, m_traceHit.endpos );
pHitEntity->DispatchTraceAttack( info, hitDirection, &m_traceHit );
ApplyMultiDamage();
// Now hit all triggers along the ray that...
TraceAttackToTriggers( CTakeDamageInfo( GetOwner(), GetOwner(), sk_plr_dmg_crowbar.GetFloat(), DMG_CLUB ), m_traceHit.startpos, m_traceHit.endpos, hitDirection );
//Play an impact sound
ImpactSound( pHitEntity );
}
#endif
//Apply an impact effect
ImpactEffect();
}
示例8: AngleVectors
// Overridden for Gargantua because his swing starts lower as
// a percentage of his height (otherwise he swings over the
// players head)
//=========================================================
CBaseEntity* CNPC_Gargantua::GargantuaCheckTraceHullAttack(float flDist, int iDamage, int iDmgType)
{
trace_t tr;
Vector vForward, vUp;
AngleVectors( GetAbsAngles(), &vForward, NULL, &vUp );
Vector vecStart = GetAbsOrigin();
vecStart.z += 64;
Vector vecEnd = vecStart + ( vForward * flDist) - ( vUp * flDist * 0.3);
//UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr );
UTIL_TraceEntity( this, GetAbsOrigin(), vecEnd, MASK_SOLID, &tr );
if ( tr.m_pEnt )
{
CBaseEntity *pEntity = tr.m_pEnt;
if ( iDamage > 0 )
{
CTakeDamageInfo info( this, this, iDamage, iDmgType );
CalculateMeleeDamageForce( &info, vForward, tr.endpos );
pEntity->TakeDamage( info );
}
return pEntity;
}
return NULL;
}
示例9: info
void CNPC_Tentacle::HitTouch( CBaseEntity *pOther )
{
if (m_flHitTime > gpGlobals->curtime)
return;
// only look at the ones where the player hit me
if( pOther == NULL || pOther->GetModelIndex() == GetModelIndex() || ( pOther->GetSolidFlags() & FSOLID_TRIGGER ) )
return;
//Right now the BoneFollower will always be hit in box 0, and
//will pass that to us. Make *any* touch by the physics objects a kill
//as the ragdoll only covers the top portion of the tentacle.
if ( pOther->m_takedamage )
{
CTakeDamageInfo info( this, this, m_iHitDmg, DMG_CLUB );
Vector vDamageForce = pOther->GetAbsOrigin() - GetAbsOrigin();
VectorNormalize( vDamageForce );
CalculateMeleeDamageForce( &info, vDamageForce, pOther->GetAbsOrigin() );
pOther->TakeDamage( info );
m_flHitTime = gpGlobals->curtime + 0.5;
}
}
示例10: Assert
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseProjectile::ProjectileTouch( CBaseEntity *pOther )
{
// Verify a correct "other."
Assert( pOther );
if ( !pOther->IsSolid() || pOther->IsSolidFlagSet( FSOLID_VOLUME_CONTENTS ) )
return;
// Handle hitting skybox (disappear).
const trace_t *pTrace = &CBaseEntity::GetTouchTrace();
trace_t *pNewTrace = const_cast<trace_t*>( pTrace );
if( pTrace->surface.flags & SURF_SKY )
{
UTIL_Remove( this );
return;
}
CTakeDamageInfo info;
info.SetAttacker( GetOwnerEntity() );
info.SetInflictor( this );
info.SetDamage( GetDamage() );
info.SetDamageType( GetDamageType() );
CalculateMeleeDamageForce( &info, GetAbsVelocity(), GetAbsOrigin(), GetDamageScale() );
Vector dir;
AngleVectors( GetAbsAngles(), &dir );
pOther->DispatchTraceAttack( info, dir, pNewTrace );
ApplyMultiDamage();
UTIL_Remove( this );
}
示例11: Assert
int CASW_Parasite::CalcDamageInfo( CTakeDamageInfo *pInfo )
{
Assert(ASWGameRules());
pInfo->Set( this, this, asw_parasite_defanged_damage.GetFloat(), DMG_ACID );
CalculateMeleeDamageForce( pInfo, GetAbsVelocity(), GetAbsOrigin() );
return pInfo->GetDamage();
}
示例12: SetNextThink
void CStomp::Think( void )
{
trace_t tr;
SetNextThink( gpGlobals->curtime + 0.1 );
// Do damage for this frame
Vector vecStart = GetAbsOrigin();
vecStart.z += 30;
Vector vecEnd = vecStart + (m_vecMoveDir * m_flSpeed * gpGlobals->frametime);
UTIL_TraceHull( vecStart, vecEnd, Vector(-32, -32, -32), Vector(32, 32, 32), MASK_SOLID, m_pOwner, COLLISION_GROUP_NONE, &tr );
// NDebugOverlay::Line( vecStart, vecEnd, 0, 255, 0, false, 10.0f );
if ( tr.m_pEnt )
{
CBaseEntity *pEntity = tr.m_pEnt;
CTakeDamageInfo info( this, this, 50, DMG_SONIC );
CalculateMeleeDamageForce( &info, m_vecMoveDir, tr.endpos );
pEntity->TakeDamage( info );
}
// Accelerate the effect
m_flSpeed += (gpGlobals->frametime) * m_uiFramerate;
m_uiFramerate += (gpGlobals->frametime) * 2000;
// Move and spawn trails
while ( gpGlobals->curtime - m_flDmgTime > STOMP_INTERVAL )
{
SetAbsOrigin( GetAbsOrigin() + m_vecMoveDir * m_flSpeed * STOMP_INTERVAL );
for ( int i = 0; i < 2; i++ )
{
CSprite *pSprite = CSprite::SpriteCreate( GARG_STOMP_SPRITE_NAME, GetAbsOrigin(), TRUE );
if ( pSprite )
{
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() - Vector(0,0,500), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
pSprite->SetAbsOrigin( tr.endpos );
// pSprite->pev->velocity = Vector(RandomFloat(-200,200),RandomFloat(-200,200),175);
pSprite->SetNextThink( gpGlobals->curtime + 0.3 );
pSprite->SetThink( &CSprite::SUB_Remove );
pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxFadeFast );
}
g_pEffects->EnergySplash( tr.endpos, tr.plane.normal );
}
m_flDmgTime += STOMP_INTERVAL;
// Scale has the "life" of this effect
m_flScale -= STOMP_INTERVAL * m_flSpeed;
if ( m_flScale <= 0 )
{
// Life has run out
UTIL_Remove(this);
// STOP_SOUND( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND );
CPASAttenuationFilter filter( this );
StopSound( entindex(), CHAN_STATIC, GARG_STOMP_BUZZ_SOUND );
}
}
}
示例13: FirePistol
//---------------------------------------------------------
//---------------------------------------------------------
void CNPC_Assassin::HandleAnimEvent( animevent_t *pEvent )
{
if ( pEvent->event == AE_ASSASIN_FIRE_PISTOL_RIGHT )
{
FirePistol( 0 );
return;
}
if ( pEvent->event == AE_ASSASIN_FIRE_PISTOL_LEFT )
{
FirePistol( 1 );
return;
}
if ( pEvent->event == AE_ASSASIN_KICK_HIT )
{
Vector attackDir = BodyDirection2D();
Vector attackPos = WorldSpaceCenter() + ( attackDir * 64.0f );
trace_t tr;
UTIL_TraceHull( WorldSpaceCenter(), attackPos, -Vector(8,8,8), Vector(8,8,8), MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &tr );
if ( ( tr.m_pEnt != NULL ) && ( tr.DidHitWorld() == false ) )
{
if ( tr.m_pEnt->m_takedamage != DAMAGE_NO )
{
CTakeDamageInfo info( this, this, 5, DMG_CLUB );
CalculateMeleeDamageForce( &info, (tr.endpos - tr.startpos), tr.endpos );
tr.m_pEnt->TakeDamage( info );
CBasePlayer *pPlayer = ToBasePlayer( tr.m_pEnt );
if ( pPlayer != NULL )
{
//Kick the player angles
pPlayer->ViewPunch( QAngle( -30, 40, 10 ) );
}
EmitSound( "Zombie.AttackHit" );
//EmitSound( "Assassin.AttackHit" );
}
}
else
{
EmitSound( "Assassin.AttackMiss" );
//EmitSound( "Assassin.AttackMiss" );
}
return;
}
BaseClass::HandleAnimEvent( pEvent );
}
示例14: ToBasePlayer
//------------------------------------------------------------------------------
// Purpose: Implement impact function
//------------------------------------------------------------------------------
void CBaseSDKBludgeonWeapon::Hit( trace_t &traceHit, Activity nHitActivity, bool bIsSecondary )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
//Do view kick
AddViewKick();
//Make sound for the AI
CSoundEnt::InsertSound( SOUND_BULLET_IMPACT, traceHit.endpos, 400, 0.2f, pPlayer );
// This isn't great, but it's something for when the crowbar hits.
pPlayer->RumbleEffect( RUMBLE_AR2, 0, RUMBLE_FLAG_RESTART );
CBaseEntity *pHitEntity = traceHit.m_pEnt;
//Apply damage to a hit target
if ( pHitEntity != NULL )
{
Vector hitDirection;
pPlayer->EyeVectors( &hitDirection, NULL, NULL );
VectorNormalize( hitDirection );
CTakeDamageInfo info( GetOwner(), GetOwner(), GetDamageForActivity( nHitActivity ), DMG_CLUB );
if( pPlayer && pHitEntity->IsNPC() )
{
// If bonking an NPC, adjust damage.
info.AdjustPlayerDamageInflictedForSkillLevel();
}
CalculateMeleeDamageForce( &info, hitDirection, traceHit.endpos );
pHitEntity->DispatchTraceAttack( info, hitDirection, &traceHit );
ApplyMultiDamage();
// Now hit all triggers along the ray that...
TraceAttackToTriggers( info, traceHit.startpos, traceHit.endpos, hitDirection );
if ( ToBaseCombatCharacter( pHitEntity ) )
{
gamestats->Event_WeaponHit( pPlayer, !bIsSecondary, GetClassname(), info );
}
}
// Apply an impact effect
ImpactEffect( traceHit );
}
示例15: SetTouch
void CBreakable::BreakTouch( CBaseEntity *pOther )
{
float flDamage;
// only players can break these right now
if ( !pOther->IsPlayer() || !IsBreakable() )
{
return;
}
// can I be broken when run into?
if ( HasSpawnFlags( SF_BREAK_TOUCH ) )
{
flDamage = pOther->GetSmoothedVelocity().Length() * 0.01;
if (flDamage >= m_iHealth)
{
m_takedamage = DAMAGE_YES;
SetTouch( NULL );
OnTakeDamage( CTakeDamageInfo( pOther, pOther, flDamage, DMG_CRUSH ) );
// do a little damage to player if we broke glass or computer
CTakeDamageInfo info( pOther, pOther, flDamage/4, DMG_SLASH );
CalculateMeleeDamageForce( &info, (pOther->GetAbsOrigin() - GetAbsOrigin()), GetAbsOrigin() );
pOther->TakeDamage( info );
}
}
// can I be broken when stood upon?
if ( HasSpawnFlags( SF_BREAK_PRESSURE ) && pOther->GetGroundEntity() == this )
{
// play creaking sound here.
DamageSound();
m_hBreaker = pOther;
SetThink ( &CBreakable::Die );
SetTouch( NULL );
// Add optional delay
SetNextThink( gpGlobals->curtime + m_flPressureDelay );
}
}