您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ClearMultiDamage函数代码示例

51自学网 2021-06-01 20:11:15
  C++
这篇教程C++ ClearMultiDamage函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ClearMultiDamage函数的典型用法代码示例。如果您正苦于以下问题:C++ ClearMultiDamage函数的具体用法?C++ ClearMultiDamage怎么用?C++ ClearMultiDamage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ClearMultiDamage函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetLocalVelocity

//Called from PhysicsSimulate() or ReceiveMessage()bool CDHLProjectile::OnTouch( trace_t &touchtr, bool bDecalOnly /*= false*/, ITraceFilter* pTraceFilter /*= NULL*/ ){	//Direction	Vector vecDir = touchtr.endpos - touchtr.startpos;	if ( vecDir == vec3_origin ) //Sometimes endpos==startpos so we need to get dir from velocity instead	{		#ifdef CLIENT_DLL			vecDir = GetLocalVelocity();		#else			vecDir = m_vecCurVelocity;		#endif		VectorNormalize( vecDir );	}	CBaseEntity* ent = touchtr.m_pEnt;	if ( !ent )		return false;	if ( touchtr.DidHit() )	{		//Never collide with self, shooter, or other projectiles		if ( ent == this || dynamic_cast<CDHLProjectile*>(ent)			|| ent == (CBaseEntity*)m_pShooter )			//|| ( (m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE) && (ent == m_pFiringWeapon) ) ) //Combat knife - don't collide with weapon ent			return false;		//Hack: Sometimes hits are registered prematurely (usually to the torso area) with no hitbox.  Pretend nothing happened unless one is found.		if ( ent->IsPlayer() && touchtr.hitgroup == 0 )			return false;		//Check friendly fire		if ( CheckFriendlyFire( ent ) )		{			if ( !bDecalOnly )			{				ClearMultiDamage();				//Do damage				CTakeDamageInfo	dmgInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET  );				if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )				{					//CalculateMeleeDamageForce( &dmgInfo, vecDir, touchtr.endpos, 0.01f );					Vector vecForce = vecDir;					VectorNormalize( vecForce );					//vecForce *= 10.0f; //Ripped from C_ClientRagdoll::ImpactTrace					dmgInfo.SetDamageForce( vecForce );					#ifndef CLIENT_DLL						if ( IsOnFire() )						{							CBaseAnimating* pBAnim = dynamic_cast<CBaseAnimating*>(ent);							if ( pBAnim )								pBAnim->Ignite( 10.0f, false );						}					#endif				}				else					CalculateBulletDamageForce( &dmgInfo, m_iAmmoType, vecDir, touchtr.endpos, 1.0f );				dmgInfo.SetDamagePosition( touchtr.endpos );				ent->DispatchTraceAttack( dmgInfo, vecDir, &touchtr );				ApplyMultiDamage();			}			#ifdef CLIENT_DLL				if ( ent->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS )					return false;				//Decals and such				if ( !( touchtr.surface.flags & SURF_SKY ) && !touchtr.allsolid )				{					IPredictionSystem::SuppressEvents( false );					if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) )					{						UTIL_ImpactTrace( &touchtr, DMG_BULLET );					}					if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )						PlayImpactSound( touchtr.m_pEnt, touchtr, touchtr.endpos, touchtr.surface.surfaceProps );					IPredictionSystem::SuppressEvents( !prediction->IsFirstTimePredicted() );				}			#endif		}		if ( pTraceFilter && m_iType != DHL_PROJECTILE_TYPE_COMBATKNIFE )		{			PenetrationData_t nPenetrationData = DHLShared::TestPenetration( touchtr, m_pShooter, pTraceFilter, 				m_iTimesPenetrated, m_flDistanceTravelled, m_iAmmoType );			if ( nPenetrationData.m_bShouldPenetrate )			{				m_flDistanceTravelled += GetLocalOrigin().DistTo( nPenetrationData.m_vecNewBulletPos );				MoveProjectileToPosition( nPenetrationData.m_vecNewBulletPos );				m_iTimesPenetrated++;				return true; //Keep going - but don't do anything else in this frame of PhysicsSimulate()			}		}			//We're done unless what we hit was breakable glass		if ( ent->GetCollisionGroup() != COLLISION_GROUP_BREAKABLE_GLASS )		{			#ifdef CLIENT_DLL//.........这里部分代码省略.........
开发者ID:dreckard,项目名称:dhl2,代码行数:101,


示例2: FX_FireBullets

//.........这里部分代码省略.........	// Fire bullets, calculate impacts & effects.	StartGroupingSounds();#if !defined (CLIENT_DLL)	// Move other players back to history positions based on local player's lag	lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );#endif	// Get the shooting angles.	Vector vecShootForward, vecShootRight, vecShootUp;	AngleVectors( vecAngles, &vecShootForward, &vecShootRight, &vecShootUp );	// Initialize the static firing information.	FireBulletsInfo_t fireInfo;	fireInfo.m_vecSrc = vecOrigin;	if ( flDamage < 0.0f )	{		fireInfo.m_flDamage = pWeaponInfo->GetWeaponData( iMode ).m_nDamage;	}	else	{		fireInfo.m_flDamage = static_cast<int>(flDamage);	}	fireInfo.m_flDistance = pWeaponInfo->GetWeaponData( iMode ).m_flRange;	fireInfo.m_iShots = 1;	fireInfo.m_vecSpread.Init( flSpread, flSpread, 0.0f );	fireInfo.m_iAmmoType = pWeaponInfo->iAmmoType;	// Setup the bullet damage type & roll for crit.	int	nDamageType	= DMG_GENERIC;	int nCustomDamageType = TF_DMG_CUSTOM_NONE;	CTFWeaponBase *pWeapon = pPlayer->GetActiveTFWeapon();	if ( pWeapon )	{		nDamageType	= pWeapon->GetDamageType();		if ( pWeapon->IsCurrentAttackACrit() || bCritical )		{			nDamageType |= DMG_CRITICAL;		}		nCustomDamageType = pWeapon->GetCustomDamageType();	}	if ( iWeapon != TF_WEAPON_MINIGUN )	{		fireInfo.m_iTracerFreq = 2;	}	// Reset multi-damage structures.	ClearMultiDamage();	int nBulletsPerShot = pWeaponInfo->GetWeaponData( iMode ).m_nBulletsPerShot;	for ( int iBullet = 0; iBullet < nBulletsPerShot; ++iBullet )	{		// Initialize random system with this seed.		RandomSeed( iSeed );			// Determine if the first bullet should be perfectly accurate.		bool bPerfectAccuracy = false;		if ( pWeapon && iBullet == 0 )		{			float flFireInterval = gpGlobals->curtime - pWeapon->GetLastFireTime();			if ( nBulletsPerShot == 1 )				bPerfectAccuracy = flFireInterval > 1.25f;			else				bPerfectAccuracy = flFireInterval > 0.25f;		}		float x = 0.0f;		float y = 0.0f;		// tf_use_fixed_weapon_spread calculations go here.		if ( !bPerfectAccuracy )		{			// Get circular gaussian spread.			x = RandomFloat( -0.5, 0.5 ) + RandomFloat( -0.5, 0.5 );			y = RandomFloat( -0.5, 0.5 ) + RandomFloat( -0.5, 0.5 );		}		// Initialize the varialbe firing information.		fireInfo.m_vecDirShooting = vecShootForward + ( x *  flSpread * vecShootRight ) + ( y * flSpread * vecShootUp );		fireInfo.m_vecDirShooting.NormalizeInPlace();		// Fire a bullet.		pPlayer->FireBullet( fireInfo, bDoEffects, nDamageType, nCustomDamageType );		// Use new seed for next bullet.		++iSeed; 	}	// Apply damage if any.	ApplyMultiDamage();#if !defined (CLIENT_DLL)	lagcompensation->FinishLagCompensation( pPlayer );#endif	EndGroupingSounds();}
开发者ID:Navton,项目名称:TF2Classic,代码行数:101,


示例3: RadiusDamage

void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){	CBaseEntity *pEntity = NULL;	TraceResult	tr;	float		flAdjustedDamage, falloff;	Vector		vecSpot;	if ( flRadius )		falloff = flDamage / flRadius;	else		falloff = 1.0;	int bInWater = (UTIL_PointContents ( vecSrc ) == CONTENTS_WATER);	vecSrc.z += 1;// in case grenade is lying on the ground	if ( !pevAttacker )		pevAttacker = pevInflictor;	// iterate on all entities in the vicinity.	while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, flRadius )) != NULL)	{		if ( pEntity->pev->takedamage != DAMAGE_NO )		{			// UNDONE: this should check a damage mask, not an ignore			if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )			{// houndeyes don't hurt other houndeyes with their attack				continue;			}			// blast's don't tavel into or out of water			if (bInWater && pEntity->pev->waterlevel == 0)				continue;			if (!bInWater && pEntity->pev->waterlevel == 3)				continue;			vecSpot = pEntity->BodyTarget( vecSrc );						UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), &tr );			if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() )			{// the explosion can 'see' this entity, so hurt them!				if (tr.fStartSolid)				{					// if we're stuck inside them, fixup the position and distance					tr.vecEndPos = vecSrc;					tr.flFraction = 0.0;				}								// decrease damage for an ent that's farther from the bomb.				flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length() * falloff;				flAdjustedDamage = flDamage - flAdjustedDamage;							if ( flAdjustedDamage < 0 )				{					flAdjustedDamage = 0;				}							// ALERT( at_console, "hit %s/n", STRING( pEntity->pev->classname ) );				if (tr.flFraction != 1.0)				{					ClearMultiDamage( );					pEntity->TraceAttack( pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize( ), &tr, bitsDamageType );					ApplyMultiDamage( pevInflictor, pevAttacker );				}				else				{					pEntity->TakeDamage ( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType );				}			}		}	}}
开发者ID:RichardRohac,项目名称:hl-amnesia-src,代码行数:73,


示例4: GetAbsVelocity

//-----------------------------------------------------------------------------// Purpose: // Input  : *pOther - //-----------------------------------------------------------------------------void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ){	if ( !pOther->IsSolid() || pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS) )		return;	if ( pOther->m_takedamage != DAMAGE_NO )	{		trace_t	tr, tr2;		tr = BaseClass::GetTouchTrace();		Vector	vecNormalizedVel = GetAbsVelocity();		ClearMultiDamage();		VectorNormalize( vecNormalizedVel );		if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() && pOther->IsNPC() )		{			CTakeDamageInfo	dmgInfo( this, GetOwnerEntity(), m_iDamage, DMG_NEVERGIB );			dmgInfo.AdjustPlayerDamageInflictedForSkillLevel();			CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f );			dmgInfo.SetDamagePosition( tr.endpos );			pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr );		}		else		{			CTakeDamageInfo	dmgInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET | DMG_NEVERGIB );			CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f );			dmgInfo.SetDamagePosition( tr.endpos );			pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr );		}		ApplyMultiDamage();		//Adrian: keep going through the glass.		if ( pOther->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS )			 return;		SetAbsVelocity( Vector( 0, 0, 0 ) );		// play body "thwack" sound		EmitSound( "Weapon_Crossbow.BoltHitBody" );		Vector vForward;		AngleVectors( GetAbsAngles(), &vForward );		VectorNormalize ( vForward );		UTIL_TraceLine( GetAbsOrigin(),	GetAbsOrigin() + vForward * 128, MASK_OPAQUE, pOther, COLLISION_GROUP_NONE, &tr2 );		if ( tr2.fraction != 1.0f )		{//			NDebugOverlay::Box( tr2.endpos, Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 0, 255, 0, 0, 10 );//			NDebugOverlay::Box( GetAbsOrigin(), Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 0, 0, 255, 0, 10 );			if ( tr2.m_pEnt == NULL || ( tr2.m_pEnt && tr2.m_pEnt->GetMoveType() == MOVETYPE_NONE ) )			{				CEffectData	data;				data.m_vOrigin = tr2.endpos;				data.m_vNormal = vForward;				data.m_nEntIndex = tr2.fraction != 1.0f;							DispatchEffect( "BoltImpact", data );			}		}				SetTouch( NULL );		SetThink( NULL );		UTIL_Remove( this );	}	else	{		trace_t	tr;		tr = BaseClass::GetTouchTrace();		// See if we struck the world		if ( pOther->GetMoveType() == MOVETYPE_NONE && !( tr.surface.flags & SURF_SKY ) )		{			EmitSound( "Weapon_Crossbow.BoltHitWorld" );			// if what we hit is static architecture, can stay around for a while.			Vector vecDir = GetAbsVelocity();			float speed = VectorNormalize( vecDir );			// See if we should reflect off this surface			float hitDot = DotProduct( tr.plane.normal, -vecDir );						if ( ( hitDot < 0.5f ) && ( speed > 100 ) )			{				Vector vReflection = 2.0f * tr.plane.normal * hitDot + vecDir;								QAngle reflectAngles;				VectorAngles( vReflection, reflectAngles );				SetLocalAngles( reflectAngles );//.........这里部分代码省略.........
开发者ID:hlstriker,项目名称:source-sdk-2013,代码行数:101,


示例5: RadiusDamage2

void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType){	CBaseEntity *pEntity = NULL;	TraceResult tr;	float flAdjustedDamage, falloff;	Vector vecSpot;	if (flRadius)		falloff = flDamage / flRadius;	else		falloff = 1.0;	int bInWater = (UTIL_PointContents(vecSrc) == CONTENTS_WATER);	// in case grenade is lying on the ground	vecSrc.z += 1;	if (!pevAttacker)		pevAttacker = pevInflictor;	// iterate on all entities in the vicinity.	while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius)) != NULL)	{		if (pEntity->pev->takedamage != DAMAGE_NO)		{			// UNDONE: this should check a damage mask, not an ignore			if (iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore)				continue;			// blast's don't tavel into or out of water			if (bInWater && pEntity->pev->waterlevel == 0)				continue;			if (!bInWater && pEntity->pev->waterlevel == 3)				continue;			vecSpot = pEntity->BodyTarget(vecSrc);			UTIL_TraceLine(vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), &tr);			if (tr.flFraction == 1.0f || tr.pHit == pEntity->edict())			{				if (tr.fStartSolid)				{					tr.vecEndPos = vecSrc;					tr.flFraction = 0;				}				flAdjustedDamage = flDamage - (vecSrc - pEntity->pev->origin).Length() * falloff;				if (flAdjustedDamage < 0)					flAdjustedDamage = 0;				else if (flAdjustedDamage > 75)					flAdjustedDamage = 75;				if (tr.flFraction == 1.0f)					pEntity->TakeDamage(pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType);				else				{					ClearMultiDamage();					pEntity->TraceAttack(pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize(), &tr, bitsDamageType);					ApplyMultiDamage(pevInflictor, pevAttacker);				}			}		}	}}
开发者ID:a1batross,项目名称:ReGameDLL_CS,代码行数:68,


示例6: UTIL_TraceLine

void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ){	Vector vecDest = vecOrigSrc + vecDir * 2048;	edict_t		*pentIgnore;	TraceResult tr;	pentIgnore = m_pPlayer->edict();	Vector tmpSrc = vecOrigSrc + gpGlobals->v_up * -8 + gpGlobals->v_right * 3;	// ALERT( at_console, "." );		UTIL_TraceLine( vecOrigSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr );	if (tr.fAllSolid)		return;#ifndef CLIENT_DLL	CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);	if (pEntity == NULL)		return;	if ( g_pGameRules->IsMultiplayer() )	{		if ( m_pSprite && pEntity->pev->takedamage )		{			m_pSprite->pev->effects &= ~EF_NODRAW;		}		else if ( m_pSprite )		{			m_pSprite->pev->effects |= EF_NODRAW;		}	}#endif	float timedist;	switch ( m_fireMode )	{	case FIRE_NARROW:#ifndef CLIENT_DLL		if ( pev->dmgtime < gpGlobals->time )		{			// Narrow mode only does damage to the entity it hits			ClearMultiDamage();			if (pEntity->pev->takedamage)			{				pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM );			}			ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);			if ( g_pGameRules->IsMultiplayer() )			{				// multiplayer uses 1 ammo every 1/10th second				if ( gpGlobals->time >= m_flAmmoUseTime )				{					UseAmmo( 1 );					m_flAmmoUseTime = gpGlobals->time + 0.1;				}			}			else			{				// single player, use 3 ammo/second				if ( gpGlobals->time >= m_flAmmoUseTime )				{					UseAmmo( 1 );					m_flAmmoUseTime = gpGlobals->time + 0.166;				}			}			pev->dmgtime = gpGlobals->time + GetPulseInterval();		}#endif		timedist = ( pev->dmgtime - gpGlobals->time ) / GetPulseInterval();		break;		case FIRE_WIDE:#ifndef CLIENT_DLL		if ( pev->dmgtime < gpGlobals->time )		{			// wide mode does damage to the ent, and radius damage			ClearMultiDamage();			if (pEntity->pev->takedamage)			{				pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonWide, vecDir, &tr, DMG_ENERGYBEAM | DMG_ALWAYSGIB);			}			ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);			if ( g_pGameRules->IsMultiplayer() )			{				// radius damage a little more potent in multiplayer.				::RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, gSkillData.plrDmgEgonWide/4, 128, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB );			}			if ( !m_pPlayer->IsAlive() )				return;			if ( g_pGameRules->IsMultiplayer() )//.........这里部分代码省略.........
开发者ID:JoelTroch,项目名称:am_src_rebirth,代码行数:101,


示例7: Square

//.........这里部分代码省略.........						float flMass = pBlockingEntity->VPhysicsGetObject()->GetMass();						float scale = flMass / MASS_ABSORB_ALL_DAMAGE;						// Absorbed all the damage.						if( scale >= 1.0f )						{							continue;						}						ASSERT( scale > 0.0f );						flBlockedDamagePercent = scale;						//Msg("  Object (%s) weighing %fkg blocked %f percent of explosion damage/n", pBlockingEntity->GetClassname(), flMass, scale * 100.0f);					}					else					{						// Some object that's not the world and not physics. Generically block 25% damage						flBlockedDamagePercent = 0.25f;					}				}			}		}		// decrease damage for an ent that's farther from the bomb.		flAdjustedDamage = ( vecSrc - tr.endpos ).Length() * falloff;		flAdjustedDamage = info.GetDamage() - flAdjustedDamage;		if ( flAdjustedDamage <= 0 )		{			continue;		}		// the explosion can 'see' this entity, so hurt them!		if (tr.startsolid)		{			// if we're stuck inside them, fixup the position and distance			tr.endpos = vecSrc;			tr.fraction = 0.0;		}				CTakeDamageInfo adjustedInfo = info;		//Msg("%s: Blocked damage: %f percent (in:%f  out:%f)/n", pEntity->GetClassname(), flBlockedDamagePercent * 100, flAdjustedDamage, flAdjustedDamage - (flAdjustedDamage * flBlockedDamagePercent) );		adjustedInfo.SetDamage( flAdjustedDamage - (flAdjustedDamage * flBlockedDamagePercent) );		// Now make a consideration for skill level!		if( info.GetAttacker() && info.GetAttacker()->IsPlayer() && pEntity->IsNPC() )		{			// An explosion set off by the player is harming an NPC. Adjust damage accordingly.			adjustedInfo.AdjustPlayerDamageInflictedForSkillLevel();		}		Vector dir = vecSpot - vecSrc;		VectorNormalize( dir );		// If we don't have a damage force, manufacture one		if ( adjustedInfo.GetDamagePosition() == vec3_origin || adjustedInfo.GetDamageForce() == vec3_origin )		{			if ( !( adjustedInfo.GetDamageType() & DMG_PREVENT_PHYSICS_FORCE ) )			{				CalculateExplosiveDamageForce( &adjustedInfo, dir, vecSrc );			}		}		else		{			// Assume the force passed in is the maximum force. Decay it based on falloff.			float flForce = adjustedInfo.GetDamageForce().Length() * falloff;			adjustedInfo.SetDamageForce( dir * flForce );			adjustedInfo.SetDamagePosition( vecSrc );		}		if ( tr.fraction != 1.0 && pEntity == tr.m_pEnt )		{			ClearMultiDamage( );			pEntity->DispatchTraceAttack( adjustedInfo, dir, &tr );			ApplyMultiDamage();		}		else		{			pEntity->TakeDamage( adjustedInfo );		}		// Now hit all triggers along the way that respond to damage... 		pEntity->TraceAttackToTriggers( adjustedInfo, vecSrc, tr.endpos, dir );#if defined( GAME_DLL )		if ( info.GetAttacker() && info.GetAttacker()->IsPlayer() && ToBaseCombatCharacter( tr.m_pEnt ) )		{			// This is a total hack!!!			bool bIsPrimary = true;			CBasePlayer *player = ToBasePlayer( info.GetAttacker() );			CBaseCombatWeapon *pWeapon = player->GetActiveWeapon();			if ( pWeapon && FClassnameIs( pWeapon, "weapon_smg1" ) )			{				bIsPrimary = false;			}			gamestats->Event_WeaponHit( player, bIsPrimary, (pWeapon != NULL) ? player->GetActiveWeapon()->GetClassname() : "NULL", info );		}#endif	}}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:101,


示例8: ClearMultiDamage

/*================FireBulletsGo to the trouble of combining multiple pellets into a single damage call.This version is used by Players, uses the random seed generator to sync client and server side shots.================*/Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand ){	static int tracerCount;	TraceResult tr;	Vector vecRight = gpGlobals->v_right;	Vector vecUp = gpGlobals->v_up;	float x, y, z;	if ( pevAttacker == NULL )		pevAttacker = pev;  // the default attacker is ourselves	ClearMultiDamage();	gMultiDamage.type = DMG_BULLET | DMG_NEVERGIB;	for ( ULONG iShot = 1; iShot <= cShots; iShot++ )	{		//Use player's random seed.		// get circular gaussian spread		x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 );		y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 );		z = x * x + y * y;		Vector vecDir = vecDirShooting +						x * vecSpread.x * vecRight +						y * vecSpread.y * vecUp;		Vector vecEnd;		vecEnd = vecSrc + vecDir * flDistance;		UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev)/*pentIgnore*/, &tr);				// do damage, paint decals		if (tr.flFraction != 1.0)		{			CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);			if ( iDamage )			{				pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB) );								TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);				DecalGunshot( &tr, iBulletType );			} 			else switch(iBulletType)			{			default:			case BULLET_PLAYER_9MM:						pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET); 				break;			case BULLET_PLAYER_MP5:						pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET); 				break;			case BULLET_PLAYER_BUCKSHOT:					 // make distance based!				pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgBuckshot, vecDir, &tr, DMG_BULLET); 				break;						case BULLET_PLAYER_357:						pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET); 				break;							case BULLET_NONE: // FIX 				pEntity->TraceAttack(pevAttacker, 50, vecDir, &tr, DMG_CLUB);				TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);				// only decal glass				if ( !FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != 0)				{					UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0,2) );				}				break;			}		}		// make bullet trails		UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (flDistance * tr.flFraction) / 64.0 );	}	ApplyMultiDamage(pev, pevAttacker);	return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 );}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:90,


示例9: GetAmmoDef

//.........这里部分代码省略.........		}		else		{			//Do Regular hit effects			// Don't decal nodraw surfaces			if ( !( tr.surface.flags & (SURF_SKY|SURF_NODRAW|SURF_HINT|SURF_SKIP) ) )			{				CBaseEntity *pEntity = tr.m_pEnt;				if ( !( !friendlyfire.GetBool() && pEntity && pEntity->GetTeamNumber() == GetTeamNumber() ) )				{					UTIL_ImpactTrace( &tr, iDamageType );				}			}		}#endif		// Get surface where the bullet entered ( if it had different surfaces on enter and exit )		surfacedata_t *pSurfaceData = physprops->GetSurfaceData( tr.surface.surfaceProps );		Assert( pSurfaceData );				float flMaterialMod = GetDensityFromMaterial(pSurfaceData);		if ( iDamageType & DMG_MACHINEGUN )		{			flMaterialMod *= 0.65;		}		// try to penetrate object		Vector penetrationEnd;		float flMaxDistance = flDamage / flMaterialMod;#ifndef CLIENT_DLL		ClearMultiDamage();		float flActualDamage = flDamage;		CTakeDamageInfo dmgInfo( info.m_pAttacker, info.m_pAttacker, flActualDamage, iDamageType );		CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, info.m_vecDirShooting, tr.endpos );		tr.m_pEnt->DispatchTraceAttack( dmgInfo, info.m_vecDirShooting, &tr );		DevMsg( 2, "Giving damage ( %.1f ) to entity of type %s/n", flActualDamage, tr.m_pEnt->GetClassname() );		TraceAttackToTriggers( dmgInfo, tr.startpos, tr.endpos, info.m_vecDirShooting );#endif		int stepsize = 16;		// displacement always stops the bullet		if ( tr.IsDispSurface() )		{			DevMsg( 2, "bullet was stopped by displacement/n" );			ApplyMultiDamage();			break;		}		// trace through the solid to find the exit point and how much material we went through		if ( !TraceToExit( tr.endpos, info.m_vecDirShooting, penetrationEnd, stepsize, flMaxDistance ) )		{			DevMsg( 2, "bullet was stopped/n" );			ApplyMultiDamage();			break;		}		// find exact penetration exit		CTraceFilterSimple ignoreShooter( this, iCollisionGroup );
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:67,


示例10: 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 && GetAbsVelocity().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;	// 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 = GetAbsVelocity(); 	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, GetAbsOrigin(), pev->dmg / 0.4, 0.3 );		m_fRegisteredSound = TRUE;	}	if( pev->flags & FL_ONGROUND )	{		// add a bit of static friction		Vector vecVelocity = GetAbsVelocity();		vecVelocity *= 0.8f;		SetAbsVelocity( vecVelocity );		pev->sequence = RANDOM_LONG( 1, 1 );	}	else	{		// play bounce sound		BounceSound();	}	pev->framerate = GetAbsVelocity().Length() / 200.0;	if( pev->framerate > 1.0 )		pev->framerate = 1;	else if( pev->framerate < 0.5 )		pev->framerate = 0;}
开发者ID:FWGS,项目名称:XashXT,代码行数:65,


示例11: ZapThink

void CNihilanthHVR :: ZapThink( void  ){	pev->nextthink = gpGlobals->time + 0.05;	// check world boundaries	if (m_hEnemy == NULL ||  pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096)	{		SetTouch( NULL );		UTIL_Remove( this );		return;	}	if (pev->velocity.Length() < 2000)	{		pev->velocity = pev->velocity * 1.2;	}	// MovetoTarget( m_hEnemy->Center( ) );	if ((m_hEnemy->Center() - pev->origin).Length() < 256)	{		TraceResult tr;		UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, edict(), &tr );		CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);		if (pEntity != NULL && pEntity->pev->takedamage)		{			ClearMultiDamage( );			pEntity->TraceAttack( pev, gSkillData.nihilanthZap, pev->velocity, &tr, DMG_SHOCK );			ApplyMultiDamage( pev, pev );		}		MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );			WRITE_BYTE( TE_BEAMENTPOINT );			WRITE_SHORT( entindex() );			WRITE_COORD( tr.vecEndPos.x );			WRITE_COORD( tr.vecEndPos.y );			WRITE_COORD( tr.vecEndPos.z );			WRITE_SHORT( g_sModelIndexLaser );			WRITE_BYTE( 0 ); // frame start			WRITE_BYTE( 10 ); // framerate			WRITE_BYTE( 3 ); // life			WRITE_BYTE( 20 );  // width			WRITE_BYTE( 20 );   // noise			WRITE_BYTE( 64 );   // r, g, b			WRITE_BYTE( 196 );   // r, g, b			WRITE_BYTE( 255);   // r, g, b			WRITE_BYTE( 255 );	// brightness			WRITE_BYTE( 10 );		// speed		MESSAGE_END();		UTIL_EmitAmbientSound( edict(), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) );		SetTouch( NULL );		UTIL_Remove( this );		pev->nextthink = gpGlobals->time + 0.2;		return;	}	pev->frame = (int)(pev->frame + 1) % 11;	MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );		WRITE_BYTE( TE_ELIGHT );		WRITE_SHORT( entindex( ) );		// entity, attachment		WRITE_COORD( pev->origin.x );		// origin		WRITE_COORD( pev->origin.y );		WRITE_COORD( pev->origin.z );		WRITE_COORD( 128 );	// radius		WRITE_BYTE( 128 );	// R		WRITE_BYTE( 128 );	// G		WRITE_BYTE( 255 );	// B		WRITE_BYTE( 10 );	// life * 10		WRITE_COORD( 128 ); // decay	MESSAGE_END();	// Crawl( );}
开发者ID:6779660,项目名称:halflife,代码行数:79,


示例12: VectorCopy

void CGrenade::BounceTouch( CBaseEntity *pOther ){	// don't hit the guy that launched this grenade	if ( pOther->edict() == pev->owner )		return;	        // Grenades to tend to get "stuck" on sloped surfaces due to the HL physics    // system, so move it away from whatever we're colliding with.    // Get the surface normal.    Vector theVelocityDirection;    VectorCopy(pev->velocity, theVelocityDirection);    VectorNormalize(theVelocityDirection);    Vector theTraceStart;    Vector theTraceEnd;    VectorMA(pev->origin, -10, theVelocityDirection, theTraceStart);    VectorMA(pev->origin,  10, theVelocityDirection, theTraceEnd);    TraceResult tr;    UTIL_TraceLine(theTraceStart, theTraceEnd, dont_ignore_monsters, dont_ignore_glass, ENT(pev), &tr);    if (tr.flFraction < 1) // Should always be the case.    {        VectorMA(pev->origin, 2, tr.vecPlaneNormal, pev->origin);        UTIL_SetOrigin(pev, pev->origin);    }	// 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, this->m_damageType); 			ApplyMultiDamage( pev, pevOwner);		}		m_flNextAttack = gpGlobals->time + 1.0; // debounce	}		Vector vecTestVelocity;	// pev->avelocity = Vector (300, 300, 300);		float theDamageModifier;	int theUpgradeLevel = AvHPlayerUpgrade::GetWeaponUpgrade(this->pev->iuser3, this->pev->iuser4, &theDamageModifier);	int theDamage = this->pev->dmg*theDamageModifier;	// 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, theDamage / 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 = 0;//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;    pev->velocity = pev->velocity * 0.8;}
开发者ID:Arkshine,项目名称:NS,代码行数:93,


示例13: UTIL_MakeVectors

int CCrowbar::Swing( int fFirst ){	int fDidHit = FALSE;	TraceResult tr;	UTIL_MakeVectors (m_pPlayer->pev->v_angle);	Vector vecSrc	= m_pPlayer->GetGunPosition( );	Vector vecEnd	= vecSrc + gpGlobals->v_forward * 32;	UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );#ifndef CLIENT_DLL	if ( tr.flFraction >= 1.0 )	{		UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );		if ( tr.flFraction < 1.0 )		{			// Calculate the point of intersection of the line (or hull) and the object we hit			// This is and approximation of the "best" intersection			CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );			if ( !pHit || pHit->IsBSPModel() )				FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );			vecEnd = tr.vecEndPos;	// This is the point on the actual surface (the hull could have hit space)		}	}#endif	PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, 	0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,	0.0, 0, 0.0 );	if ( tr.flFraction >= 1.0 )	{		if (fFirst)		{			// miss			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;						// player "shoot" animation			m_pPlayer->SetAnimation( PLAYER_ATTACK1 );		}	}	else	{		switch( ((m_iSwing++) % 2) + 1 )		{		case 0:			SendWeaponAnim( CROWBAR_ATTACK1HIT ); break;		case 1:			SendWeaponAnim( CROWBAR_ATTACK2HIT ); break;		case 2:			SendWeaponAnim( CROWBAR_ATTACK3HIT ); break;		}		// player "shoot" animation		m_pPlayer->SetAnimation( PLAYER_ATTACK1 );		#ifndef CLIENT_DLL		// hit		fDidHit = TRUE;		CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);		ClearMultiDamage( );		if ( (m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )		{			// first swing does full damage			pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); 		}		else		{			// subsequent swings do half			pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); 		}			ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );		// play thwack, smack, or dong sound		float flVol = 1.0;		int fHitWorld = TRUE;		if (pEntity)		{			if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )			{				// play thwack or smack sound				switch( RANDOM_LONG(0,2) )				{				case 0:					EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); break;				case 1:					EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM); break;				case 2:					EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM); break;				}				m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME;				if ( !pEntity->IsAlive() )					  return TRUE;//.........这里部分代码省略.........
开发者ID:NoFreeWill,项目名称:MultiplayerSource,代码行数:101,


示例14: ToBasePlayer

void CWeaponGravityGun::EffectUpdate( void ){	Vector start, angles, forward, right;	trace_t tr;	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );	if ( !pOwner )		return;	m_viewModelIndex = pOwner->entindex();	// Make sure I've got a view model	CBaseViewModel *vm = pOwner->GetViewModel();	if ( vm )	{		m_viewModelIndex = vm->entindex();	}	pOwner->EyeVectors( &forward, &right, NULL );	start = pOwner->Weapon_ShootPosition();	Vector end = start + forward * 4096;	UTIL_TraceLine( start, end, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );	end = tr.endpos;	float distance = tr.fraction * 4096;	if ( tr.fraction != 1 )	{		// too close to the player, drop the object		if ( distance < 36 )		{			DetachObject();			return;		}	}	if ( m_hObject == NULL && tr.DidHitNonWorldEntity() )	{		CBaseEntity *pEntity = tr.m_pEnt;		// inform the object what was hit		ClearMultiDamage();		pEntity->DispatchTraceAttack( CTakeDamageInfo( pOwner, pOwner, 0, DMG_PHYSGUN ), forward, &tr );		ApplyMultiDamage();		AttachObject( pEntity, start, tr.endpos, distance );		m_lastYaw = pOwner->EyeAngles().y;	}	// Add the incremental player yaw to the target transform	matrix3x4_t curMatrix, incMatrix, nextMatrix;	AngleMatrix( m_gravCallback.m_targetRotation, curMatrix );	AngleMatrix( QAngle(0,pOwner->EyeAngles().y - m_lastYaw,0), incMatrix );	ConcatTransforms( incMatrix, curMatrix, nextMatrix );	MatrixAngles( nextMatrix, m_gravCallback.m_targetRotation );	m_lastYaw = pOwner->EyeAngles().y;	CBaseEntity *pObject = m_hObject;	if ( pObject )	{		if ( m_useDown )		{			if ( pOwner->m_afButtonPressed & IN_USE )			{				m_useDown = false;			}		}		else 		{			if ( pOwner->m_afButtonPressed & IN_USE )			{				m_useDown = true;			}		}		if ( m_useDown )		{			pOwner->SetPhysicsFlag( PFLAG_DIROVERRIDE, true );			if ( pOwner->m_nButtons & IN_FORWARD )			{				m_distance = UTIL_Approach( 1024, m_distance, gpGlobals->frametime * 100 );			}			if ( pOwner->m_nButtons & IN_BACK )			{				m_distance = UTIL_Approach( 40, m_distance, gpGlobals->frametime * 100 );			}		}		if ( pOwner->m_nButtons & IN_WEAPON1 )		{			m_distance = UTIL_Approach( 1024, m_distance, m_distance * 0.1 );		}		if ( pOwner->m_nButtons & IN_WEAPON2 )		{			m_distance = UTIL_Approach( 40, m_distance, m_distance * 0.1 );		}		// Send the object a physics damage message (0 damage). Some objects interpret this 		// as something else being in control of their physics temporarily.		pObject->TakeDamage( CTakeDamageInfo( this, pOwner, 0, DMG_PHYSGUN ) );		Vector newPosition = start + forward * m_distance;		// 24 is a little larger than 16 * sqrt(2) (extent of player bbox)//.........这里部分代码省略.........
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:101,


示例15: GetAbsVelocity

//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ){	if ( pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS | FSOLID_TRIGGER) )	{		// Some NPCs are triggers that can take damage (like antlion grubs). We should hit them.		if ( ( pOther->m_takedamage == DAMAGE_NO ) || ( pOther->m_takedamage == DAMAGE_EVENTS_ONLY ) )			return;	}	if ( pOther->m_takedamage != DAMAGE_NO )	{		trace_t	tr, tr2;		tr = BaseClass::GetTouchTrace();		Vector	vecNormalizedVel = GetAbsVelocity();		ClearMultiDamage();		VectorNormalize( vecNormalizedVel );#if defined(HL2_EPISODIC)		//!!!HACKHACK - specific hack for ep2_outland_10 to allow crossbow bolts to pass through her bounding box when she's crouched in front of the player		// (the player thinks they have clear line of sight because Alyx is crouching, but her BBOx is still full-height and blocks crossbow bolts.		if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() && pOther->Classify() == CLASS_PLAYER_ALLY_VITAL && FStrEq(STRING(gpGlobals->mapname), "ep2_outland_10") )		{			// Change the owner to stop further collisions with Alyx. We do this by making her the owner.			// The player won't get credit for this kill but at least the bolt won't magically disappear!			SetOwnerEntity( pOther );			return;		}#endif//HL2_EPISODIC		if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() && pOther->IsNPC() )		{			CTakeDamageInfo	dmgInfo( this, GetOwnerEntity(), sk_plr_dmg_crossbow.GetFloat(), DMG_NEVERGIB );			dmgInfo.AdjustPlayerDamageInflictedForSkillLevel();			CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f );			dmgInfo.SetDamagePosition( tr.endpos );			pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr );			CBasePlayer *pPlayer = ToBasePlayer( GetOwnerEntity() );			if ( pPlayer )			{				gamestats->Event_WeaponHit( pPlayer, true, "weapon_crossbow", dmgInfo );			}		}		else		{			CTakeDamageInfo	dmgInfo( this, GetOwnerEntity(), sk_plr_dmg_crossbow.GetFloat(), DMG_BULLET | DMG_NEVERGIB );			CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, tr.endpos, 0.7f );			dmgInfo.SetDamagePosition( tr.endpos );			pOther->DispatchTraceAttack( dmgInfo, vecNormalizedVel, &tr );		}		ApplyMultiDamage();		//Adrian: keep going through the glass.		if ( pOther->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS )			 return;		/*if ( !pOther->IsAlive() )		{			// We killed it! 			const surfacedata_t *pdata = physprops->GetSurfaceData( tr.surface.surfaceProps );			if ( pdata->game.material == CHAR_TEX_GLASS )			{				return;			}		}*/		SetAbsVelocity( Vector( 0, 0, 0 ) );		// play body "thwack" sound		EmitSound( "Weapon_Crossbow.BoltHitBody" );		Vector vForward;		AngleVectors( GetAbsAngles(), &vForward );		VectorNormalize ( vForward );		UTIL_TraceLine( GetAbsOrigin(),	GetAbsOrigin() + vForward * 128, MASK_BLOCKLOS, pOther, COLLISION_GROUP_NONE, &tr2 );		if ( tr2.fraction != 1.0f )		{//			NDebugOverlay::Box( tr2.endpos, Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 0, 255, 0, 0, 10 );//			NDebugOverlay::Box( GetAbsOrigin(), Vector( -16, -16, -16 ), Vector( 16, 16, 16 ), 0, 0, 255, 0, 10 );			if ( tr2.m_pEnt == NULL || ( tr2.m_pEnt && tr2.m_pEnt->GetMoveType() == MOVETYPE_NONE ) )			{				CEffectData	data;				data.m_vOrigin = tr2.endpos;				data.m_vNormal = vForward;				data.m_nEntIndex = tr2.fraction != 1.0f;							DispatchEffect( "BoltImpact", data );			}		}		//.........这里部分代码省略.........
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:101,


示例16: ClearMultiDamage

void CBaseGrenade::BounceTouch( CBaseEntity *pOther ){	if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER | FSOLID_VOLUME_CONTENTS) )		return;	// don't hit the guy that launched this grenade	if ( pOther == GetThrower() )		return;	// only do damage if we're moving fairly fast	if ( (pOther->m_takedamage != DAMAGE_NO) && (m_flNextAttack < gpGlobals->curtime && GetAbsVelocity().Length() > 100))	{		if (m_hThrower)		{#if !defined( CLIENT_DLL )			trace_t tr;			tr = CBaseEntity::GetTouchTrace( );			ClearMultiDamage( );			Vector forward;			AngleVectors( GetLocalAngles(), &forward, NULL, NULL );			CTakeDamageInfo info( this, m_hThrower, 1, DMG_CLUB );			CalculateMeleeDamageForce( &info, GetAbsVelocity(), GetAbsOrigin() );			pOther->DispatchTraceAttack( info, forward, &tr ); 			ApplyMultiDamage();#endif		}		m_flNextAttack = gpGlobals->curtime + 1.0; // debounce	}	Vector vecTestVelocity;	// m_vecAngVelocity = 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 = GetAbsVelocity(); 	vecTestVelocity.z *= 0.45;	if ( !m_bHasWarnedAI && vecTestVelocity.Length() <= 60 )	{		// grenade is moving really slow. It's probably very close to where it will ultimately stop moving. 		// emit the danger sound.				// register a radius louder than the explosion, so we make sure everyone gets out of the way#if !defined( CLIENT_DLL )		CSoundEnt::InsertSound ( SOUND_DANGER, GetAbsOrigin(), m_flDamage / 0.4, 0.3, this );#endif		m_bHasWarnedAI = true;	}	if (GetFlags() & FL_ONGROUND)	{		// add a bit of static friction//		SetAbsVelocity( GetAbsVelocity() * 0.8 );		// SetSequence( random->RandomInt( 1, 1 ) ); // FIXME: missing tumble animations	}	else	{		// play bounce sound		BounceSound();	}	m_flPlaybackRate = GetAbsVelocity().Length() / 200.0;	if (GetPlaybackRate() > 1.0)		m_flPlaybackRate = 1;	else if (GetPlaybackRate() < 0.5)		m_flPlaybackRate = 0;}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:69,


示例17: AngleVectors

//.........这里部分代码省略.........				}			}			else			{				//Do Regular hit effects				// Don't decal nodraw surfaces				if ( !( tr.surface.flags & (SURF_SKY|SURF_NODRAW|SURF_HINT|SURF_SKIP) ) )				{					CBaseEntity *pEntity = tr.m_pEnt;					//Tony; only while using teams do we check for friendly fire.					if ( pEntity && pEntity->IsPlayer() && (pEntity->GetBaseAnimating() && !pEntity->GetBaseAnimating()->IsRagdoll()) )					{#if defined ( SDK_USE_TEAMS )						if ( pEntity->GetTeamNumber() == GetTeamNumber() )						{							if ( !friendlyfire.GetBool() )								UTIL_ImpactTrace( &tr, iDamageType );						}#else						UTIL_ImpactTrace( &tr, iDamageType );#endif					}					//Tony; non player, just go nuts,					else					{						UTIL_ImpactTrace( &tr, iDamageType );					}				}			}		} // bDoEffects		// add damage to entity that we hit#ifdef GAME_DLL		float flBulletDamage = iDamage * flDistanceMultiplier / (i+1);	// Each iteration the bullet drops in strength		ClearMultiDamage();		CTakeDamageInfo info( pevAttacker, pevAttacker, flBulletDamage, iDamageType );		CalculateBulletDamageForce( &info, iBulletType, vecDir, tr.endpos );		tr.m_pEnt->DispatchTraceAttack( info, vecDir, &tr );		TraceAttackToTriggers( info, tr.startpos, tr.endpos, vecDir );		ApplyMultiDamage();#else		flDistanceMultiplier = flDistanceMultiplier; // Silence warning.#endif		pIgnore = tr.m_pEnt;		float flPenetrationDistance;		switch (eWeaponType)		{		case WT_RIFLE:			flPenetrationDistance = 25;			break;		case WT_SHOTGUN:			flPenetrationDistance = 5;			break;		case WT_SMG:			flPenetrationDistance = 15;			break;		case WT_PISTOL:		default:			flPenetrationDistance = 15;			break;		}		Vector vecBackwards = tr.endpos + vecDir * flPenetrationDistance;		if (tr.m_pEnt->IsBSPModel())			UTIL_TraceLine( vecBackwards, tr.endpos, CONTENTS_SOLID|CONTENTS_MOVEABLE, NULL, COLLISION_GROUP_NONE, &tr );		else			UTIL_TraceLine( vecBackwards, tr.endpos, CONTENTS_HITBOX, NULL, COLLISION_GROUP_NONE, &tr );		if (tr.startsolid)			break;				if (tr.m_pEnt)		{			// let's have a bullet exit effect if we penetrated a solid surface			if (tr.m_pEnt->IsBSPModel())				UTIL_ImpactTrace( &tr, iDamageType );			// ignore the entity we just hit for the next trace to avoid weird impact behaviors			pIgnore = tr.m_pEnt;		}		// Set up the next trace.		vecSrc = tr.endpos + vecDir;	// One unit in the direction of fire so that we firmly embed ourselves in whatever solid was hit.	}		// the bullet's done penetrating, let's spawn our particle system	if (bDoEffects && (pevAttacker == this))		MakeTracer( vecTracerSrc, tr, TRACER_TYPE_DEFAULT );}
开发者ID:jlwitthuhn,项目名称:DoubleAction,代码行数:101,


示例18: switch

// Go to the trouble of combining multiple pellets into a single damage call.// This version is used by Players, uses the random seed generator to sync client and server side shots.Vector CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand){	int iOriginalPenetration = iPenetration;	int iPenetrationPower;	float flPenetrationDistance;	int iCurrentDamage = iDamage;	float flCurrentDistance;	TraceResult tr, tr2;	Vector vecRight, vecUp;	bool bHitMetal = false;	int iSparksAmount = 1;	vecRight = gpGlobals->v_right;	vecUp = gpGlobals->v_up;	switch (iBulletType)	{	case BULLET_PLAYER_9MM:		iPenetrationPower = 21;		flPenetrationDistance = 800;		break;	case BULLET_PLAYER_45ACP:		iPenetrationPower = 15;		flPenetrationDistance = 500;		break;	case BULLET_PLAYER_50AE:		iPenetrationPower = 30;		flPenetrationDistance = 1000;		break;	case BULLET_PLAYER_762MM:		iPenetrationPower = 39;		flPenetrationDistance = 5000;		break;	case BULLET_PLAYER_556MM:		iPenetrationPower = 35;		flPenetrationDistance = 4000;		break;	case BULLET_PLAYER_338MAG:		iPenetrationPower = 45;		flPenetrationDistance = 8000;		break;	case BULLET_PLAYER_57MM:		iPenetrationPower = 30;		flPenetrationDistance = 2000;		break;	case BULLET_PLAYER_357SIG:		iPenetrationPower = 25;		flPenetrationDistance = 800;		break;	default:		iPenetrationPower = 0;		flPenetrationDistance = 0;		break;	}	if (!pevAttacker)	{		// the default attacker is ourselves		pevAttacker = pev;	}	gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB);	float x, y, z;	if (IsPlayer())	{		// Use player's random seed.		// get circular gaussian spread		x = UTIL_SharedRandomFloat(shared_rand, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 1, -0.5, 0.5);		y = UTIL_SharedRandomFloat(shared_rand + 2, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 3, -0.5, 0.5);	}	else	{		do		{			x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);			y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);			z = x * x + y * y;		}		while (z > 1);	}	Vector vecDir, vecEnd;	Vector vecOldSrc, vecNewSrc;	vecDir = vecDirShooting + x * vecSpread * vecRight + y * vecSpread * vecUp;	vecEnd = vecSrc + vecDir * flDistance;	float flDamageModifier = 0.5;	while (iPenetration != 0)	{		ClearMultiDamage();		UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr);//.........这里部分代码省略.........
开发者ID:a1batross,项目名称:ReGameDLL_CS,代码行数:101,


示例19: ToBasePlayer

//-----------------------------------------------------------------------------// Purpose: //----------------------------------------------------------------------------- void CWeaponGauss::Fire( void ) {         CBasePlayer *pOwner = ToBasePlayer( GetOwner() );                  if ( pOwner == NULL )                return;        m_bCharging = false;          Vector  startPos= pOwner->Weapon_ShootPosition();         Vector  aimDir  = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES );          Vector vecUp, vecRight;         VectorVectors( aimDir, vecRight, vecUp );          float x, y, z;          //Gassian spread         do {                 x = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5);                 y = random->RandomFloat(-0.5,0.5) + random->RandomFloat(-0.5,0.5);                z = x*x+y*y;         } while (z > 1);          Vector  endPos  = startPos + ( aimDir * MAX_TRACE_LENGTH );                  //Shoot a shot straight out         trace_t tr;         UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );#ifndef CLIENT_DLL         ClearMultiDamage();#endif          CBaseEntity *pHit = tr.m_pEnt;#ifndef CLIENT_DLL                  CTakeDamageInfo dmgInfo( this, pOwner, sk_dmg_gauss.GetFloat(), DMG_SHOCK | DMG_BULLET );#endif          if ( pHit != NULL )        {#ifndef CLIENT_DLL                 CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos, 7.0f * 5.0f  );                 pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr );#endif         }                  if ( tr.DidHitWorld() )         {                 float hitAngle = -DotProduct( tr.plane.normal, aimDir );                  if ( hitAngle < 0.5f )                 {                         Vector vReflection;                                          vReflection = 2.0 * tr.plane.normal * hitAngle + aimDir;                                                  startPos        = tr.endpos;                         endPos          = startPos + ( vReflection * MAX_TRACE_LENGTH );                                                  //Draw beam to reflection point                         DrawBeam( tr.startpos, tr.endpos, 1.6, true );                          CPVSFilter filter( tr.endpos );                         te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 );                          UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );                          //Find new reflection end position                         UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );                          if ( tr.m_pEnt != NULL )                         {#ifndef CLIENT_DLL                                 dmgInfo.SetDamageForce( GetAmmoDef()->DamageForce(m_iPrimaryAmmoType) * vReflection );                                 dmgInfo.SetDamagePosition( tr.endpos );                                 tr.m_pEnt->DispatchTraceAttack( dmgInfo, vReflection, &tr );#endif                         }                         //Connect reflection point to end                         DrawBeam( tr.startpos, tr.endpos, 0.4 );                 }                 else                {                         DrawBeam( tr.startpos, tr.endpos, 1.6, true );                 }         }         else         {                 DrawBeam( tr.startpos, tr.endpos, 1.6, true );         }#ifndef CLIENT_DLL                  ApplyMultiDamage();#endif          UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" );//.........这里部分代码省略.........
开发者ID:Sub-Zero1324,项目名称:HL2-DM-Gauss-Gun-Code,代码行数:101,


示例20: UTIL_GetGlobalTrace

void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ){	float	flpitch;	TraceResult tr = UTIL_GetGlobalTrace( );	// don't hit the guy that launched this grenade	if ( pev->owner && pOther->edict() == pev->owner )		return;	// at least until we've bounced once	pev->owner = NULL;	pev->angles.x = 0;	pev->angles.z = 0;	// avoid bouncing too much	if (m_flNextHit > gpGlobals->time)		return;	// higher pitch as squeeker gets closer to detonation time	flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY);	if ( pOther->pev->takedamage && m_flNextAttack < gpGlobals->time )	{		// attack!		// make sure it's me who has touched them		if (tr.pHit == pOther->edict())		{			// and it's not another squeakgrenade			if (tr.pHit->v.modelindex != pev->modelindex)			{				// ALERT( at_console, "hit enemy/n");				ClearMultiDamage( );				pOther->TraceAttack(pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); 				if (m_hOwner != NULL)					ApplyMultiDamage( pev, m_hOwner->pev );				else					ApplyMultiDamage( pev, pev );				pev->dmg += gSkillData.snarkDmgPop; // add more explosion damage				// m_flDie += 2.0; // add more life				// make bite sound				EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch);				m_flNextAttack = gpGlobals->time + 0.5;			}		}		else		{			// ALERT( at_console, "been hit/n");		}	}	m_flNextHit = gpGlobals->time + 0.1;	m_flNextHunt = gpGlobals->time;	if ( g_pGameRules->IsMultiplayer() )	{		// in multiplayer, we limit how often snarks can make their bounce sounds to prevent overflows.		if ( gpGlobals->time < m_flNextBounceSoundTime )		{			// too soon!			return;		}	}	if (!(pev->flags & FL_ONGROUND))	{		// play bounce sound		float flRndSound = RANDOM_FLOAT ( 0 , 1 );		if ( flRndSound <= 0.33 )			EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch);				else if (flRndSound <= 0.66)			EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch);		else 			EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch);		CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 256, 0.25 );	}	else	{		// skittering sound		CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 100, 0.1 );	}	m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second.}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:89,


示例21: HandleAnimEvent

//.........这里部分代码省略.........			{				EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, m_voicePitch );			}		}		break;		case ISLAVE_AE_ZAP_POWERUP:		{			// speed up attack when on hard			if (g_iSkillLevel == SKILL_HARD)				pev->framerate = 1.5;			UTIL_MakeAimVectors( pev->angles );			if (m_iBeams == 0)			{				Vector vecSrc = pev->origin + gpGlobals->v_forward * 2;				MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc );					WRITE_BYTE(TE_DLIGHT);					WRITE_COORD(vecSrc.x);	// X					WRITE_COORD(vecSrc.y);	// Y					WRITE_COORD(vecSrc.z);	// Z					WRITE_BYTE( 12 );		// radius * 0.1					WRITE_BYTE( 255 );		// r					WRITE_BYTE( 180 );		// g					WRITE_BYTE( 96 );		// b					WRITE_BYTE( 20 / pev->framerate );		// time * 10					WRITE_BYTE( 0 );		// decay * 0.1				MESSAGE_END( );			}			if (m_hDead != 0)			{				WackBeam( -1, m_hDead );				WackBeam( 1, m_hDead );			}			else			{				ArmBeam( -1 );				ArmBeam( 1 );				BeamGlow( );			}			EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "debris/zap4.wav", 1, ATTN_NORM, 0, 100 + m_iBeams * 10 );			pev->skin = m_iBeams / 2;		}		break;		case ISLAVE_AE_ZAP_SHOOT:		{			ClearBeams( );			if (m_hDead != 0)			{				Vector vecDest = m_hDead->pev->origin + Vector( 0, 0, 38 );				TraceResult trace;				UTIL_TraceHull( vecDest, vecDest, dont_ignore_monsters, human_hull, m_hDead->edict(), &trace );				if ( !trace.fStartSolid )				{					CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->pev->origin, m_hDead->pev->angles );					pNew->pev->spawnflags |= 1;					WackBeam( -1, pNew );					WackBeam( 1, pNew );					UTIL_Remove( m_hDead );					EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) );					/*					CBaseEntity *pEffect = Create( "test_effect", pNew->Center(), pev->angles );					pEffect->Use( this, this, USE_ON, 1 );					*/					break;				}			}			ClearMultiDamage();			UTIL_MakeAimVectors( pev->angles );			ZapBeam( -1 );			ZapBeam( 1 );			EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "hassault/hw_shoot1.wav", 1, ATTN_NORM, 0, RANDOM_LONG( 130, 160 ) );			// STOP_SOUND( ENT(pev), CHAN_WEAPON, "debris/zap4.wav" );			ApplyMultiDamage(pev, pev);			m_flNextAttack = gpGlobals->time + RANDOM_FLOAT( 0.5, 4.0 );		}		break;		case ISLAVE_AE_ZAP_DONE:		{			ClearBeams( );		}		break;		default:			CSquadMonster::HandleAnimEvent( pEvent );			break;	}}
开发者ID:Skumek,项目名称:hlsdk,代码行数:101,


示例22: ENT

void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ){	m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;	Vector vecSrc = vecOrigSrc;	Vector vecDest = vecSrc + vecDir * 8192;	edict_t		*pentIgnore;	TraceResult tr, beam_tr;	float flMaxFrac = 1.0;	int	nTotal = 0;	int fHasPunched = 0;	int fFirstBeam = 1;	int	nMaxHits = 10;	pentIgnore = ENT( m_pPlayer->pev );#ifdef CLIENT_DLL	if ( m_fPrimaryFire == false )		 g_irunninggausspred = true;#endif		// The main firing event is sent unreliably so it won't be delayed.	PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 );	// This reliable event is used to stop the spinning sound	// It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client	// It's sent reliably anyway, which could lead to other delays	PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 );		/*ALERT( at_console, "%f %f %f/n%f %f %f/n", 		vecSrc.x, vecSrc.y, vecSrc.z, 		vecDest.x, vecDest.y, vecDest.z );*/	//	ALERT( at_console, "%f %f/n", tr.flFraction, flMaxFrac );#ifndef CLIENT_DLL	while (flDamage > 10 && nMaxHits > 0)	{		nMaxHits--;		// ALERT( at_console, "." );		UTIL_TraceLine(vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr);		if (tr.fAllSolid)			break;		CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);		if (pEntity == NULL)			break;		if ( fFirstBeam )		{			m_pPlayer->pev->effects |= EF_MUZZLEFLASH;			fFirstBeam = 0;				nTotal += 26;		}				if (pEntity->pev->takedamage)		{			ClearMultiDamage();			pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET );			ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);		}		if ( pEntity->ReflectGauss() )		{			float n;			pentIgnore = NULL;			n = -DotProduct(tr.vecPlaneNormal, vecDir);			if (n < 0.5) // 60 degrees			{				// ALERT( at_console, "reflect %f/n", n );				// reflect				Vector r;							r = 2.0 * tr.vecPlaneNormal * n + vecDir;				flMaxFrac = flMaxFrac - tr.flFraction;				vecDir = r;				vecSrc = tr.vecEndPos + vecDir * 8;				vecDest = vecSrc + vecDir * 8192;				// explode a bit				m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST );				nTotal += 34;								// lose energy				if (n == 0) n = 0.1;				flDamage = flDamage * (1 - n);			}			else			{//.........这里部分代码省略.........
开发者ID:JoelTroch,项目名称:am_src_rebirth,代码行数:101,


示例23: FlameDamage

void CGargantua :: FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ){	CBaseEntity *pEntity = NULL;	TraceResult	tr;	float		flAdjustedDamage;	Vector		vecSpot;	Vector vecMid = (vecStart + vecEnd) * 0.5;	float searchRadius = (vecStart - vecMid).Length();	Vector vecAim = (vecEnd - vecStart).Normalize( );	// iterate on all entities in the vicinity.	while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecMid, searchRadius )) != NULL)	{		if ( pEntity->pev->takedamage != DAMAGE_NO )		{			// UNDONE: this should check a damage mask, not an ignore			if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )			{// houndeyes don't hurt other houndeyes with their attack				continue;			}						vecSpot = pEntity->BodyTarget( vecMid );					float dist = DotProduct( vecAim, vecSpot - vecMid );			if (dist > searchRadius)				dist = searchRadius;			else if (dist < -searchRadius)				dist = searchRadius;						Vector vecSrc = vecMid + dist * vecAim;			UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(pev), &tr );			if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() )			{// the explosion can 'see' this entity, so hurt them!				// decrease damage for an ent that's farther from the flame.				dist = ( vecSrc - tr.vecEndPos ).Length();				if (dist > 64)				{					flAdjustedDamage = flDamage - (dist - 64) * 0.4;					if (flAdjustedDamage <= 0)						continue;				}				else				{					flAdjustedDamage = flDamage;				}				// ALERT( at_console, "hit %s/n", STRING( pEntity->pev->classname ) );				if (tr.flFraction != 1.0)				{					ClearMultiDamage( );					pEntity->TraceAttack( pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize( ), &tr, bitsDamageType );					ApplyMultiDamage( pevInflictor, pevAttacker );				}				else				{					pEntity->TakeDamage ( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType );				}			}		}	}}
开发者ID:FaucetDC,项目名称:HLDC_SDK,代码行数:67,


示例24: ClearMultiDamage_api

void EXT_FUNC ClearMultiDamage_api(){	ClearMultiDamage();}
开发者ID:csportal,项目名称:ReGameDLL_CS,代码行数:4,


示例25: HuntThink

void CControllerHeadBall :: HuntThink( void  ){	SetNextThink( 0.1 );	pev->renderamt -= 5;	MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );		WRITE_BYTE( TE_ELIGHT );		WRITE_SHORT( entindex( ) );		// entity, attachment		WRITE_COORD( pev->origin.x );		// origin		WRITE_COORD( pev->origin.y );		WRITE_COORD( pev->origin.z );		WRITE_COORD( pev->renderamt / 16 );	// radius		WRITE_BYTE( 255 );	// R		WRITE_BYTE( 255 );	// G		WRITE_BYTE( 255 );	// B		WRITE_BYTE( 2 );	// life * 10		WRITE_COORD( 0 ); // decay	MESSAGE_END();	// check world boundaries  if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == 0 || m_hOwner == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096)	{		SetTouch( NULL );		UTIL_Remove( this );		return;	}	MovetoTarget( m_hEnemy->Center( ) );	if ((m_hEnemy->Center() - pev->origin).Length() < 64)	{		TraceResult tr;		UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT(pev), &tr );		CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);		if (pEntity != NULL && pEntity->pev->takedamage)		{			ClearMultiDamage( );			pEntity->TraceAttack( m_hOwner->pev, gSkillData.controllerDmgZap, pev->velocity, &tr, DMG_SHOCK );			ApplyMultiDamage( pev, m_hOwner->pev );		}		MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );			WRITE_BYTE( TE_BEAMENTPOINT );			WRITE_SHORT( entindex() );			WRITE_COORD( tr.vecEndPos.x );			WRITE_COORD( tr.vecEndPos.y );			WRITE_COORD( tr.vecEndPos.z );			WRITE_SHORT( g_sModelIndexLaser );			WRITE_BYTE( 0 ); // frame start			WRITE_BYTE( 10 ); // framerate			WRITE_BYTE( 3 ); // life			WRITE_BYTE( 20 );  // width			WRITE_BYTE( 0 );   // noise			WRITE_BYTE( 255 );   // r, g, b			WRITE_BYTE( 255 );   // r, g, b			WRITE_BYTE( 255 );   // r, g, b			WRITE_BYTE( 255 );	// brightness			WRITE_BYTE( 10 );		// speed		MESSAGE_END();		UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) );		m_flNextAttack = gpGlobals->time + 3.0;		SetThink(&CControllerHeadBall :: DieThink );		SetNextThink( 0.3 );	}	// Crawl( );}
开发者ID:RichardRohac,项目名称:hl-amnesia-src,代码行数:73,


示例26: GetBliinkPlayerStats

//.........这里部分代码省略.........#ifdef CLIENT_DLL                // draw red client impact markers                debugoverlay->AddBoxOverlay( tr.endpos, Vector(-2,-2,-2), Vector(2,2,2), QAngle( 0, 0, 0), 255,0,0,127, 4 );                if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )                {                        C_BasePlayer *player = ToBasePlayer( tr.m_pEnt );                        player->DrawClientHitboxes( 4, true );                }#else                // draw blue server impact markers                NDebugOverlay::Box( tr.endpos, Vector(-2,-2,-2), Vector(2,2,2), 0,0,255,127, 4 );                if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )                {                        CBasePlayer *player = ToBasePlayer( tr.m_pEnt );                        player->DrawServerHitboxes( 4, true );                }#endif        }                //calculate the damage based on the distance the bullet travelled.                flCurrentDistance += tr.fraction * flMaxRange;                // damage get weaker of distance                fCurrentDamage *= pow ( 0.85f, (flCurrentDistance / 500));                int iDamageType = DMG_BULLET | DMG_NEVERGIB;#ifndef CLIENT_DLL				CBliinkPlayer* pAttacker = static_cast<CBliinkPlayer*> ( pevAttacker );				int iActiveAmmo = GetAmmoDef()->Index( pAttacker->GetActiveWeapon()->GetWpnData().szAmmo1 );				int iAmmoSubtype = pAttacker->GetBliinkInventory().GetAmmoSubtype( iActiveAmmo );				switch( iAmmoSubtype )				{				case ITEM_STYPE_AMMO_NORMAL:					break;				case ITEM_STYPE_AMMO_POISON:					iDamageType &= DMG_POISON; break;				case ITEM_STYPE_AMMO_FOGGED:					iDamageType &= DMG_NERVEGAS; break;				case ITEM_STYPE_AMMO_FIRE:					iDamageType &= DMG_BURN; break;				case ITEM_STYPE_AMMO_SLOW:					iDamageType &= DMG_PARALYZE; break;				}#endif                if( bDoEffects )                {                        // See if the bullet ended up underwater + started out of the water                        if ( enginetrace->GetPointContents( tr.endpos ) & (CONTENTS_WATER|CONTENTS_SLIME) )                        {                                       trace_t waterTrace;                                UTIL_TraceLine( vecSrc, tr.endpos, (MASK_SHOT|CONTENTS_WATER|CONTENTS_SLIME), this, COLLISION_GROUP_NONE, &waterTrace );                                if( waterTrace.allsolid != 1 )                                {                                        CEffectData     data;                                        data.m_vOrigin = waterTrace.endpos;                                        data.m_vNormal = waterTrace.plane.normal;                                        data.m_flScale = random->RandomFloat( 8, 12 );                                        if ( waterTrace.contents & CONTENTS_SLIME )                                        {                                                data.m_fFlags |= FX_WATER_IN_SLIME;                                        }                                        DispatchEffect( "gunshotsplash", data );                                }                        }                        else                        {                                //Do Regular hit effects                                // Don't decal nodraw surfaces                                if ( !( tr.surface.flags & (SURF_SKY|SURF_NODRAW|SURF_HINT|SURF_SKIP) ) )                                {                                        CBaseEntity *pEntity = tr.m_pEnt;                                        UTIL_ImpactTrace( &tr, iDamageType );                                }                        }                } // bDoEffects                // add damage to entity that we hit#ifdef GAME_DLL                ClearMultiDamage();                CTakeDamageInfo info( pevAttacker, pevAttacker, fCurrentDamage, iDamageType );                CalculateBulletDamageForce( &info, iBulletType, vecDir, tr.endpos );                tr.m_pEnt->DispatchTraceAttack( info, vecDir, &tr );                TraceAttackToTriggers( info, tr.startpos, tr.endpos, vecDir );                ApplyMultiDamage();#endif}
开发者ID:Randdalf,项目名称:bliink,代码行数:101,


示例27: ClearMultiDamage

/*================FireBulletsGo to the trouble of combining multiple pellets into a single damage call.This version is used by Monsters.================*/void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ){	static int tracerCount;	int tracer;	TraceResult tr;	Vector vecRight = gpGlobals->v_right;	Vector vecUp = gpGlobals->v_up;	if ( pevAttacker == NULL )		pevAttacker = pev;  // the default attacker is ourselves	ClearMultiDamage();	gMultiDamage.type = DMG_BULLET | DMG_NEVERGIB;	for (ULONG iShot = 1; iShot <= cShots; iShot++)	{		// get circular gaussian spread		float x, y, z;		do {			x = RANDOM_FLOAT(-0.5,0.5) + RANDOM_FLOAT(-0.5,0.5);			y = RANDOM_FLOAT(-0.5,0.5) + RANDOM_FLOAT(-0.5,0.5);			z = x*x+y*y;		} while (z > 1);		Vector vecDir = vecDirShooting +						x * vecSpread.x * vecRight +						y * vecSpread.y * vecUp;		Vector vecEnd;		vecEnd = vecSrc + vecDir * flDistance;		UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev)/*pentIgnore*/, &tr);		tracer = 0;		if (iTracerFreq != 0 && (tracerCount++ % iTracerFreq) == 0)		{			Vector vecTracerSrc;			if ( IsPlayer() )			{// adjust tracer position for player				vecTracerSrc = vecSrc + Vector ( 0 , 0 , -4 ) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16;			}			else			{				vecTracerSrc = vecSrc;			}						if ( iTracerFreq != 1 )		// guns that always trace also always decal				tracer = 1;			switch( iBulletType )			{			case BULLET_MONSTER_MP5:			case BULLET_MONSTER_9MM:			case BULLET_MONSTER_12MM:			default:				MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecTracerSrc );					WRITE_BYTE( TE_TRACER );					WRITE_COORD( vecTracerSrc.x );					WRITE_COORD( vecTracerSrc.y );					WRITE_COORD( vecTracerSrc.z );					WRITE_COORD( tr.vecEndPos.x );					WRITE_COORD( tr.vecEndPos.y );					WRITE_COORD( tr.vecEndPos.z );				MESSAGE_END();				break;			}		}		// do damage, paint decals		if (tr.flFraction != 1.0)		{			CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);			if ( iDamage )			{				pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB) );								TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);				DecalGunshot( &tr, iBulletType );			} 			else switch(iBulletType)			{			default:			case BULLET_MONSTER_9MM:				pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET);								TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType);				DecalGunshot( &tr, iBulletType );				break;			case BULLET_MONSTER_MP5:				pEntity->TraceAttack(pevAttacker, gSkillData.monDmgMP5, vecDir, &tr, DMG_BULLET);//.........这里部分代码省略.........
开发者ID:RichardRohac,项目名称:hl-amnesia-src,代码行数:101,


示例28: GetAbsVelocity

void CASW_Flamer_Projectile::FlameHit( CBaseEntity *pOther, const Vector &vecHitPos, bool bOnlyHurtUnignited ){	if (!pOther)		return;	bool bHurt = true;	if ( pOther->m_takedamage != DAMAGE_NO)	{		if ( pOther == m_pLastHitEnt )			return;		if ( bOnlyHurtUnignited)		{			CBaseAnimating* pAnim = dynamic_cast<CBaseAnimating*>(pOther);			if ( pAnim && pAnim->IsOnFire() )			{				bHurt = false;			}		}		if ( bHurt )		{			Vector	vecNormalizedVel = GetAbsVelocity();			ClearMultiDamage();			VectorNormalize( vecNormalizedVel );			if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() && pOther->IsNPC() )			{				CTakeDamageInfo	dmgInfo( this, m_pGetsCreditedForDamage, m_flDamage, DMG_BURN );				dmgInfo.AdjustPlayerDamageInflictedForSkillLevel();				CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, vecHitPos, asw_flamer_force.GetFloat() );				dmgInfo.SetDamagePosition( vecHitPos );				dmgInfo.SetWeapon( m_hCreatorWeapon.Get() );				pOther->TakeDamage(dmgInfo);			}			else			{				CTakeDamageInfo	dmgInfo( this, m_pGetsCreditedForDamage, m_flDamage, DMG_BURN );				CalculateMeleeDamageForce( &dmgInfo, vecNormalizedVel, vecHitPos, asw_flamer_force.GetFloat() );				dmgInfo.SetDamagePosition( vecHitPos );				dmgInfo.SetWeapon( m_hCreatorWeapon.Get() );				pOther->TakeDamage(dmgInfo);			}			ApplyMultiDamage();			// keep going through normal entities?			m_pLastHitEnt = pOther;		}		if ( pOther->Classify() == CLASS_ASW_SHIELDBUG )	// We also want to bounce off shield bugs		{			Vector vel = GetAbsVelocity();			Vector dir = vel;			VectorNormalize( dir );			// reflect velocity around normal			vel = -2.0f * dir + vel;			vel *= 0.4f;			// absorb 80% in impact			SetAbsVelocity( vel );		}		return;	}	if ( pOther->GetCollisionGroup() == ASW_COLLISION_GROUP_PASSABLE )		return;	trace_t	tr;	tr = BaseClass::GetTouchTrace();	// See if we struck the world	if ( pOther->GetMoveType() == MOVETYPE_NONE && !( tr.surface.flags & SURF_SKY ) )	{		Vector vel = GetAbsVelocity();		if ( tr.startsolid )		{			if ( !m_inSolid )			{				// UNDONE: Do a better contact solution that uses relative velocity?				vel *= -1.0f; // bounce backwards				SetAbsVelocity(vel);			}			m_inSolid = true;			return;		}		m_inSolid = false;		if ( tr.DidHit() )		{			Vector dir = vel;			VectorNormalize(dir);			// reflect velocity around normal			vel = -2.0f * tr.plane.normal * DotProduct(vel,tr.plane.normal) + vel;//.........这里部分代码省略.........
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:101,



注:本文中的ClearMultiDamage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ClearNameValueList函数代码示例
C++ ClearDrawScreen函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。