本文整理汇总了C++中ApplyMultiDamage函数的典型用法代码示例。如果您正苦于以下问题:C++ ApplyMultiDamage函数的具体用法?C++ ApplyMultiDamage怎么用?C++ ApplyMultiDamage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ApplyMultiDamage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: UTIL_GetGlobalTrace
void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
if (pOther->pev->takedamage)
{
TraceResult tr = UTIL_GetGlobalTrace( );
entvars_t *pevOwner;
if (m_hOwner != NULL)
{
pevOwner = m_hOwner->pev;
}
else
{
pevOwner = pev;
}
ClearMultiDamage( );
pOther->TraceAttack(pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM );
ApplyMultiDamage( pevOwner, pevOwner );
UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) );
}
UTIL_Remove( this );
}
示例3: FX_Trail
void CMmissile::ExplodeTouch( CBaseEntity *pOther )
{
if ( UTIL_PointContents(pev->origin) == CONTENT_SKY )
{
FX_Trail( pev->origin, entindex(), PROJ_REMOVE );
UTIL_Remove( this );
return;
}
if (pOther->pev->health == 666)
{
return;
}
TraceResult tr;
Vector vecSpot = pev->origin - pev->velocity.Normalize() * 32;
Vector vecEnd = pev->origin + pev->velocity.Normalize() * 64;
UTIL_TraceLine( vecSpot, vecEnd, ignore_monsters, ENT(pev), &tr );
entvars_t *pevOwner = VARS( pev->owner );
RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, DMG_BLAST );
FX_Trail( tr.vecEndPos + (tr.vecPlaneNormal * 15), entindex(), (UTIL_PointContents(pev->origin) == CONTENT_WATER)?PROJ_MMISSILE_DETONATE_WATER:PROJ_MMISSILE_DETONATE );
int tex = (int)TEXTURETYPE_Trace(&tr, vecSpot, vecEnd);
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
FX_ImpRocket( tr.vecEndPos, tr.vecPlaneNormal, pEntity->IsBSPModel()?1:0, BULLET_SMALEXP, (float)tex );
if (pOther->pev->takedamage)
{
ClearMultiDamage( );
pOther->TraceAttack(pevOwner, pev->dmg/3, gpGlobals->v_forward, &tr, DMG_BULLETMAGNUM );
ApplyMultiDamage( pev, pevOwner);
}
UTIL_Remove( this );
}
示例4: UTIL_Remove
void CTankProj::ExplodeTouch( CBaseEntity *pOther )
{
if ( UTIL_PointContents(pev->origin) == CONTENT_SKY )
{
UTIL_Remove( this );
return;
}
TraceResult tr;
Vector vecSpot = pev->origin - pev->velocity.Normalize() * 32;
Vector vecEnd = pev->origin + pev->velocity.Normalize() * 64;
UTIL_TraceLine( vecSpot, vecEnd, ignore_monsters, ENT(pev), &tr );
int tex = (int)TEXTURETYPE_Trace(&tr, vecSpot, vecEnd);
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
FX_ImpRocket( tr.vecEndPos, tr.vecPlaneNormal, pEntity->IsBSPModel()?1:0, BULLET_HIGHEXP, (float)tex );
entvars_t *pevOwner = VARS( pev->owner );
::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, pev->dmg*0.8, CLASS_NONE, DMG_BLAST);
FX_Explosion( tr.vecEndPos + (tr.vecPlaneNormal * 25), EXPLOSION_TANKPROJ );
if (pOther->pev->takedamage)
{
ClearMultiDamage( );
pOther->TraceAttack(pevOwner, pev->dmg/4, gpGlobals->v_forward, &tr, DMG_BULLETMAGNUM );
ApplyMultiDamage( pev, pevOwner);
}
UTIL_Remove( this );
}
示例5: FireSentryBulletsNEW
void FireSentryBulletsNEW( int shotcount, gedict_t * targ, float spread_x, float spread_y, float spread_z )
{
vec3_t src;
vec3_t dst;
vec3_t norm_dir;
sgAimNew( self, targ, src, dst, norm_dir );
ClearMultiDamage( );
traceline( PASSVEC3( src ), PASSVEC3( dst ), 0, self );
VectorScale( norm_dir, 4, puff_org );
VectorSubtract( g_globalvars.trace_endpos, puff_org, puff_org );
for ( ; shotcount > 0 ; shotcount-- )
{
// для каждого выстрела определяем trace_ent trace_endpos
// т.к.выстрелы могут убрать препятствия
traceline( PASSVEC3( src ), PASSVEC3( dst ), 0, self );
// TraceAttack требует нормализованый вектор для корректного определения blood_org
if(g_globalvars.trace_fraction != 1)
TraceAttack( 4, norm_dir );
}
ApplyMultiDamage( );
Multi_Finish( );
}
示例6: UTIL_MakeVectors
// Quake Bullet firing
void CBasePlayer::Q_FireBullets(int iShots, Vector vecDir, Vector vecSpread)
{
TraceResult trace;
UTIL_MakeVectors(pev->v_angle);
Vector vecSrc = pev->origin + (gpGlobals->v_forward * 10);
vecSrc.z = pev->absmin.z + (pev->size.z * 0.7);
ClearMultiDamage();
while(iShots > 0)
{
Vector vecPath = vecDir + (RANDOM_FLOAT(-1, 1) * vecSpread.x * gpGlobals->v_right) + (RANDOM_FLOAT(-1, 1) * vecSpread.y * gpGlobals->v_up);
Vector vecEnd = vecSrc + (vecPath * 2048);
UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &trace);
if(trace.flFraction != 1.0)
{
CBaseEntity *pEntity = CBaseEntity::Instance(trace.pHit);
if(pEntity && pEntity->pev->takedamage && pEntity->IsPlayer())
{
pEntity->TraceAttack(pev, 4, vecPath, &trace, DMG_BULLET);
//AddMultiDamage(pev, pEntity, 4, DMG_BULLET);
}
else if(pEntity && pEntity->pev->takedamage)
{
pEntity->TakeDamage(pev, pev, 4, DMG_BULLET);
}
}
iShots--;
}
ApplyMultiDamage(pev, pev);
}
示例7: VARS
void CGrenade::BounceTouch( CBaseEntity *pOther )
{
// don't hit the guy that launched this grenade
if ( pOther->edict() == pev->owner )
return;
// only do damage if we're moving fairly fast
if (m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100)
{
entvars_t *pevOwner = VARS( pev->owner );
if (pevOwner)
{
TraceResult tr = UTIL_GetGlobalTrace( );
ClearMultiDamage( );
pOther->TraceAttack(pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB );
ApplyMultiDamage( pev, pevOwner);
}
m_flNextAttack = gpGlobals->time + 1.0; // debounce
}
Vector vecTestVelocity;
// pev->avelocity = Vector (300, 300, 300);
// this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical
// or thrown very far tend to slow down too quickly for me to always catch just by testing velocity.
// trimming the Z velocity a bit seems to help quite a bit.
vecTestVelocity = pev->velocity;
vecTestVelocity.z *= 0.45;
if ( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 )
{
//ALERT( at_console, "Grenade Registered!: %f\n", vecTestVelocity.Length() );
// grenade is moving really slow. It's probably very close to where it will ultimately stop moving.
// go ahead and emit the danger sound.
// register a radius louder than the explosion, so we make sure everyone gets out of the way
CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 );
m_fRegisteredSound = TRUE;
}
if (pev->flags & FL_ONGROUND)
{
// add a bit of static friction
pev->velocity = pev->velocity * 0.8;
pev->sequence = RANDOM_LONG( 1, 1 );
}
else
{
// play bounce sound
BounceSound();
}
pev->framerate = pev->velocity.Length() / 200.0;
if (pev->framerate > 1.0)
pev->framerate = 1;
else if (pev->framerate < 0.5)
pev->framerate = 0;
}
示例8: FX_Trail
void CFlame::Fly( void )
{
if ( pev->frags <= 0 || UTIL_PointContents(pev->origin) == CONTENT_WATER )
{
FX_Trail( pev->origin, entindex(), PROJ_REMOVE );
UTIL_Remove( this );
return;
}
pev->frags--;
entvars_t *pevOwner = VARS(pev->owner);
CBaseEntity *pOther = NULL;
while ((pOther = UTIL_FindEntityInSphere( pOther, pev->origin, 50 )) != NULL)
{
if (pOther->edict() != pev->owner && pOther->pev->takedamage && pOther->Classify() != CLASS_MACHINE )
{
TraceResult tr;
UTIL_TraceLine( pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT(pev), &tr );
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
ClearMultiDamage( );
pEntity->TraceAttack( pevOwner, pev->dmg/3, pev->velocity, &tr, DMG_IGNITE | DMG_NEVERGIB);
ApplyMultiDamage( pev, pevOwner );
}
}
pev->nextthink = gpGlobals->time + 0.1;
}
示例9: 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();
}
示例10: 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 );
}
}
示例11: 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();
}
示例12: 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 );
}
示例13: WorldSpaceCenter
void CFlechette::DoAOEDamage()
{
CBaseEntity *ppEnts[256];
Vector vecCenter = WorldSpaceCenter();
float flRadius = flechette_radius.GetFloat();
vecCenter.z -= flRadius * 0.8f;
int nEntCount = UTIL_EntitiesInSphere( ppEnts, 256, vecCenter, flRadius, 0 );
int i;
for ( i = 0; i < nEntCount; i++ )
{
if ( ppEnts[i] == NULL )
continue;
bool bDoDamage = true;
if(ppEnts[i]->IsPlayer() || ppEnts[i]->IsNPC())
{
CBasePlayer *pOtherPlayer = ToBasePlayer(ppEnts[i]);
CBasePlayer *pPlayer = ToBasePlayer(GetOwnerEntity());
if(pOtherPlayer != NULL && pPlayer != NULL)
{
if((HL2MPRules()->IsTeamplay() && (pPlayer->GetTeamNumber() == pOtherPlayer->GetTeamNumber()))
|| HL2MPRules()->GetGameType() == GAME_COOP)
{
const int oldHealth = pOtherPlayer->GetHealth();
pOtherPlayer->TakeHealth( HEAL_AMOUNT, DMG_GENERIC );
bDoDamage = false;
if(oldHealth <= HEAL_AMOUNT)
pOtherPlayer->PlayAutovocal(HEALED,0);
if(oldHealth != pOtherPlayer->GetHealth()) // Si on a vraiment heal
pOtherPlayer->EmitSound("Tranqu.Heal");
}
}
if(bDoDamage && ppEnts[i] != GetOwnerEntity())
{
int iApplyDamage = 0;
if(ppEnts[i]->IsNPC())
iApplyDamage = 70;
else
{
if(ppEnts[i]->GetHealth() < m_iDamage + 10)
iApplyDamage = 100;
else
iApplyDamage = ppEnts[i]->GetHealth() - m_iDamage;
}
CTakeDamageInfo dmgInfo( this, GetOwnerEntity(), GetOwnerEntity(), iApplyDamage, DMG_POISON | DMG_NEVERGIB );
//CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f );
dmgInfo.SetDamagePosition( vecCenter );
ppEnts[i]->TakeDamage(dmgInfo);
//ppEnts[i]->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr );
}
}
ApplyMultiDamage();
}
}
示例14: AddMultiDamage
void AddMultiDamage( gedict_t * hit, float damage )
{
if ( !hit )
return;
if ( hit != multi_ent )
{
ApplyMultiDamage();
multi_damage = damage;
multi_ent = hit;
} else
multi_damage = multi_damage + damage;
}
示例15: AddMultiDamage
//-----------------------------------------------------------------------------
// Purpose: Add damage to the existing multidamage, and apply if it won't fit
//-----------------------------------------------------------------------------
void AddMultiDamage( const CTakeDamageInfo &info, CBaseEntity *pEntity )
{
if ( !pEntity )
return;
if ( pEntity != g_MultiDamage.GetTarget() )
{
ApplyMultiDamage();
g_MultiDamage.Init( pEntity, info.GetInflictor(), info.GetAttacker(), info.GetWeapon(), vec3_origin, vec3_origin, vec3_origin, 0.0, info.GetDamageType(), info.GetDamageCustom() );
}
g_MultiDamage.AddDamageType( info.GetDamageType() );
g_MultiDamage.SetDamage( g_MultiDamage.GetDamage() + info.GetDamage() );
g_MultiDamage.SetDamageForce( g_MultiDamage.GetDamageForce() + info.GetDamageForce() );
g_MultiDamage.SetDamagePosition( info.GetDamagePosition() );
g_MultiDamage.SetReportedPosition( info.GetReportedPosition() );
g_MultiDamage.SetMaxDamage( MAX( g_MultiDamage.GetMaxDamage(), info.GetDamage() ) );
g_MultiDamage.SetAmmoType( info.GetAmmoType() );
if ( g_MultiDamage.GetPlayerPenetrationCount() == 0 )
{
g_MultiDamage.SetPlayerPenetrationCount( info.GetPlayerPenetrationCount() );
}
bool bHasPhysicsForceDamage = !g_pGameRules->Damage_NoPhysicsForce( info.GetDamageType() );
if ( bHasPhysicsForceDamage && g_MultiDamage.GetDamageType() != DMG_GENERIC )
{
// If you hit this assert, you've called TakeDamage with a damage type that requires a physics damage
// force & position without specifying one or both of them. Decide whether your damage that's causing
// this is something you believe should impart physics force on the receiver. If it is, you need to
// setup the damage force & position inside the CTakeDamageInfo (Utility functions for this are in
// takedamageinfo.cpp. If you think the damage shouldn't cause force (unlikely!) then you can set the
// damage type to DMG_GENERIC, or | DMG_CRUSH if you need to preserve the damage type for purposes of HUD display.
if ( g_MultiDamage.GetDamageForce() == vec3_origin || g_MultiDamage.GetDamagePosition() == vec3_origin )
{
static int warningCount = 0;
if ( ++warningCount < 10 )
{
if ( g_MultiDamage.GetDamageForce() == vec3_origin )
{
Warning( "AddMultiDamage: g_MultiDamage.GetDamageForce() == vec3_origin\n" );
}
if ( g_MultiDamage.GetDamagePosition() == vec3_origin)
{
Warning( "AddMultiDamage: g_MultiDamage.GetDamagePosition() == vec3_origin\n" );
}
}
}
}
}