当前位置: 首页>>代码示例>>C++>>正文


C++ CTakeDamageInfo函数代码示例

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


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

示例1: WeaponSound

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponCombatLaserRifle::PrimaryAttack( void )
{
	CBaseTFPlayer *pPlayer = (CBaseTFPlayer*)GetOwner();
	if (!pPlayer)
		return;
	
	WeaponSound(SINGLE);

	// Fire the bullets
	Vector vecSrc = pPlayer->Weapon_ShootPosition( );
	Vector vecAiming;
	pPlayer->EyeVectors( &vecAiming );

	PlayAttackAnimation( GetPrimaryAttackActivity() );

	// Reduce the spread if the player's ducking
	Vector vecSpread = GetBulletSpread();
	vecSpread *= m_flInaccuracy;

	TFGameRules()->FireBullets( CTakeDamageInfo( this, pPlayer, weapon_combat_laserrifle_damage.GetFloat(), DMG_PLASMA), 1, 
		vecSrc, vecAiming, vecSpread, weapon_combat_laserrifle_range.GetFloat(), m_iPrimaryAmmoType, 0, entindex(), 0 );

	m_flInaccuracy += 0.3;
	m_flInaccuracy = clamp(m_flInaccuracy, 0, 1);

	m_flNextPrimaryAttack = gpGlobals->curtime + GetFireRate();
	m_iClip1 = m_iClip1 - 1;
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:31,代码来源:weapon_combat_laserrifle.cpp

示例2: CalculateDefaultPhysicsDamage

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : index - 
//			*pEvent - 
//-----------------------------------------------------------------------------
void CGrubNugget::VPhysicsCollision( int index, gamevcollisionevent_t *pEvent )
{
	int damageType;
	float damage = CalculateDefaultPhysicsDamage( index, pEvent, 1.0f, true, damageType );
	if ( damage > 5.0f )
	{
		CBaseEntity *pHitEntity = pEvent->pEntities[!index];
		if ( pHitEntity == NULL )
		{
			// hit world
			pHitEntity = GetContainingEntity( INDEXENT(0) );
		}
		
		Vector damagePos;
		pEvent->pInternalData->GetContactPoint( damagePos );
		Vector damageForce = pEvent->postVelocity[index] * pEvent->pObjects[index]->GetMass();
		if ( damageForce == vec3_origin )
		{
			// This can happen if this entity is motion disabled, and can't move.
			// Use the velocity of the entity that hit us instead.
			damageForce = pEvent->postVelocity[!index] * pEvent->pObjects[!index]->GetMass();
		}

		// FIXME: this doesn't pass in who is responsible if some other entity "caused" this collision
		PhysCallbackDamage( this, CTakeDamageInfo( pHitEntity, pHitEntity, damageForce, damagePos, damage, damageType ), *pEvent, index );
	}

	BaseClass::VPhysicsCollision( index, pEvent );
}
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:34,代码来源:npc_antliongrub.cpp

示例3: CTakeDamageInfo

//-----------------------------------------------------------------------------
// Purpose: An entity has blocked the brush.
// Input  : pOther - 
//-----------------------------------------------------------------------------
void CFuncRotating::Blocked( CBaseEntity *pOther )
{
#ifdef HL1_DLL
	if( m_flBlockDamage > 0 )
#endif
		pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:11,代码来源:bmodels.cpp

示例4: UTIL_GetGlobalTrace

void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
	if( pOther->pev->takedamage )
	{
		TraceResult tr = UTIL_GetGlobalTrace();

		CBaseEntity* pOwner;
		if( m_hOwner != nullptr )
		{
			pOwner = m_hOwner;
		}
		else
		{
			pOwner = this;
		}

		g_MultiDamage.Clear();
		pOther->TraceAttack( CTakeDamageInfo( pOwner, gSkillData.GetControllerDmgBall(), DMG_ENERGYBEAM ), pev->velocity.Normalize(), &tr );
		g_MultiDamage.ApplyMultiDamage( pOwner, pOwner );

		UTIL_EmitAmbientSound( this, tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) );

	}

	UTIL_Remove( this );
}
开发者ID:swmpdg,项目名称:HLEnhanced,代码行数:26,代码来源:CControllerZapBall.cpp

示例5: UTIL_TraceLine

void CGrenadeSpit::GrenadeSpitTouch( CBaseEntity *pOther )
{
	if (m_fSpitDeathTime != 0)
	{
		return;
	}
	if ( pOther->GetCollisionGroup() == HL2COLLISION_GROUP_SPIT)
	{
		return;
	}
	if ( !pOther->m_takedamage )
	{

		// make a splat on the wall
		trace_t tr;
		UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + GetAbsVelocity() * 10, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
		UTIL_DecalTrace(&tr, "BeerSplash" );

		// make some flecks
		// CPVSFilter filter( tr.endpos );
		//te->SpriteSpray( filter, 0.0,
		//	tr.endpos, tr.plane.normal, m_nSquidSpitSprite, 30, 0.8, 5 );
	}
	else
	{
		RadiusDamage ( CTakeDamageInfo( this, GetThrower(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL );
	}

	Detonate();
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:30,代码来源:grenade_spit.cpp

示例6: 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();
}
开发者ID:AgentAgrimar,项目名称:source-sdk-trilogy,代码行数:38,代码来源:hl1_weapon_crowbar.cpp

示例7: UTIL_TraceLine

void CASW_Boomer_Blob::DoExplosion( )
{
	// scorch the ground
	trace_t		tr;
	UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + Vector( 0, 0, -80 ), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr);

	if ( m_bMaster )
	{
		if ( ( tr.m_pEnt != GetWorldEntity() ) || ( tr.hitbox != 0 ) )
		{
			// non-world needs smaller decals
			if( tr.m_pEnt && !tr.m_pEnt->IsNPC() )
			{
				UTIL_DecalTrace( &tr, "SmallScorch" );
			}
		}
		else
		{
			UTIL_DecalTrace( &tr, "Scorch" );
		}

		UTIL_ASW_ScreenShake( GetAbsOrigin(), 7.0f, 45.0f, 0.5f, 150, SHAKE_START );
	}

	// explosion effects
	DispatchParticleEffect( "boomer_drop_explosion", GetAbsOrigin(), Vector( m_DmgRadius, 0.0f, 0.0f ), QAngle( 0.0f, 0.0f, 0.0f ) );
	EmitSound( "ASW_Boomer_Grenade.Explode" );

	// damage to nearby things
	ASWGameRules()->RadiusDamage( CTakeDamageInfo( this, m_hFirer.Get(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL );
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:31,代码来源:asw_boomer_blob.cpp

示例8: Assert

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGrenadeRocket::MissileTouch( CBaseEntity *pOther )
{
	Assert( pOther );
	if ( !pOther->IsSolid() )
		return;

	Vector vecAbsOrigin = GetAbsOrigin();
	CPASFilter filter( vecAbsOrigin );
	te->Explosion( filter, 0.0,	&vecAbsOrigin, g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, 100, m_flDamage );

	StopSound( "GrenadeRocket.FlyLoop" );

	// Don't apply explosive damage if it hit a shield of any kind...
	bool bHittingShield = false;
	if (pOther->GetCollisionGroup() == TFCOLLISION_GROUP_SHIELD)
	{
		bHittingShield = true;
	}
	else if ( pOther->IsPlayer() )
	{
		CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>(pOther);

		trace_t tr;
		float flDamage = m_flDamage;
		bHittingShield = pPlayer->IsHittingShield( GetAbsVelocity(), &flDamage );
	}

	if (!bHittingShield)
	{
		RadiusDamage( CTakeDamageInfo( this, m_pRealOwner, m_flDamage, DMG_BLAST ), vecAbsOrigin, 100, CLASS_NONE );
	}

	UTIL_Remove( this );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:37,代码来源:grenade_rocket.cpp

示例9: CTakeDamageInfo

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pOther - 
//-----------------------------------------------------------------------------
void CFlare::FlareBurnTouch( CBaseEntity *pOther )
{
	if ( pOther && pOther->m_takedamage && ( m_flNextDamage < gpGlobals->curtime ) )
	{
		pOther->TakeDamage( CTakeDamageInfo( this, m_pOwner, 1, (DMG_BULLET|DMG_BURN) ) );
		m_flNextDamage = gpGlobals->curtime + 1.0f;
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:12,代码来源:weapon_flaregun.cpp

示例10: CTakeDamageInfo

//-----------------------------------------------------------------------------
// Purpose: Called every frame when the bruch is blocked while moving
// Input  : pOther - The blocking entity.
//-----------------------------------------------------------------------------
void CFuncMoveLinear::Blocked( CBaseEntity *pOther )
{
	// Hurt the blocker 
	if ( m_flBlockDamage )
	{
		pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) );
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:12,代码来源:func_movelinear.cpp

示例11: luasrc_CTakeDamageInfo

static int luasrc_CTakeDamageInfo (lua_State *L) {
  if (lua_gettop(L) < 4) {
    CTakeDamageInfo info = CTakeDamageInfo();
    lua_pushdamageinfo(L, info);
  } else if (lua_gettop(L) <= 5) {
    CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checknumber(L, 3), luaL_checkint(L, 4), luaL_optint(L, 5, 0));
    lua_pushdamageinfo(L, info);
  } else if (lua_gettop(L) <= 6) {
    CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checkentity(L, 3), luaL_checknumber(L, 4), luaL_checkint(L, 5), luaL_optint(L, 6, 0));
    lua_pushdamageinfo(L, info);
  } else if (lua_gettop(L) < 9) {
    CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checkvector(L, 3), luaL_checkvector(L, 4), luaL_checknumber(L, 5), luaL_checkint(L, 6), luaL_optint(L, 7, 0), &luaL_optvector(L, 8, NULL));
    lua_pushdamageinfo(L, info);
  } else {
    CTakeDamageInfo info = CTakeDamageInfo(luaL_checkentity(L, 1), luaL_checkentity(L, 2), luaL_checkentity(L, 3), luaL_checkvector(L, 4), luaL_checkvector(L, 5), luaL_checknumber(L, 6), luaL_checkint(L, 7), luaL_optint(L, 8, 0), &luaL_optvector(L, 9, NULL));
    lua_pushdamageinfo(L, info);
  }
  return 1;
}
开发者ID:WorldGamers,项目名称:Mobile-Forces-Source,代码行数:19,代码来源:ltakedamageinfo.cpp

示例12: GetAbsOrigin

void CTripmineGrenade::BeamBreakThink( void  )
{
	// See if I can go solid yet (has dropper moved out of way?)
	if (IsSolidFlagSet( FSOLID_NOT_SOLID ))
	{
		trace_t tr;
		Vector	vUpBit = GetAbsOrigin();
		vUpBit.z += 5.0;

		UTIL_TraceEntity( this, GetAbsOrigin(), vUpBit, MASK_SHOT, &tr );
		if ( !tr.startsolid && (tr.fraction == 1.0) )
		{
			RemoveSolidFlags( FSOLID_NOT_SOLID );
		}
	}

	trace_t tr;

	// NOT MASK_SHOT because we want only simple hit boxes
	UTIL_TraceLine( GetAbsOrigin(), m_vecEnd, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );

	// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );

	// respawn detect. 
	if ( !m_pBeam )
	{
		MakeBeam( );
		if ( tr.m_pEnt )
			m_hOwner = tr.m_pEnt;	// reset owner too
	}


	CBaseEntity *pEntity = tr.m_pEnt;
	CBaseCombatCharacter *pBCC  = ToBaseCombatCharacter( pEntity );

	bool bAttachMoved = false;
	if ( m_bAttached && m_hAttachEntity.Get() != NULL )
	{
		if ( m_hAttachEntity.Get()->GetAbsOrigin() != m_vAttachedPosition )
			bAttachMoved = true;
	}

	// Also blow up if the attached entity goes away, ie: a crate
	if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001 || ( m_bAttached && m_hAttachEntity.Get() == NULL) || bAttachMoved )
	{
		m_iHealth = 0;
		if (m_pConstraint)
			m_pConstraint->Deactivate();

		Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) );
		return;
	}

	SetNextThink( gpGlobals->curtime + 0.05f );
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:55,代码来源:grenade_tripmine.cpp

示例13: RadiusDamage

//-----------------------------------------------------------------------------
// Purpose: Explode and die
//-----------------------------------------------------------------------------
void CBasePlasmaProjectile::Detonate( void )
{
#if !defined( CLIENT_DLL )
	// Should I explode?
	if ( m_flExplosiveRadius )
	{
		RadiusDamage( CTakeDamageInfo( this, GetOwnerEntity(), m_flDamage, m_DamageType | DMG_BLAST ), GetAbsOrigin(), m_flExplosiveRadius, CLASS_NONE, NULL );
	}
#endif
	Remove( );
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:14,代码来源:plasmaprojectile.cpp

示例14: UTIL_GetGlobalTrace

void CShockBeam::BallTouch( CBaseEntity* pOther )
{
	if( pOther->GetTakeDamageMode() != DAMAGE_NO )
	{
		TraceResult tr = UTIL_GetGlobalTrace();

		CBaseEntity* pOwner = GetOwner();

		g_MultiDamage.Clear();

		int bitsDamageTypes = DMG_ALWAYSGIB | DMG_SHOCK;

		if( CBaseMonster* pMonster = pOther->MyMonsterPointer() )
		{
			bitsDamageTypes = 64;
			if( pMonster->m_flShockDuration > 1.0 )
			{
				bitsDamageTypes = 8192;
			}

			pMonster->AddShockEffect( 63, 152, 208, 16, 0.5 );
		}

		pOther->TraceAttack( 
			CTakeDamageInfo( 
				pOwner, 
				bIsMultiplayer() ? gSkillData.GetPlrDmgShockRoachM() : gSkillData.GetPlrDmgShockRoachS(),
				bitsDamageTypes ), 
			GetAbsVelocity().Normalize(),
			&tr );

		g_MultiDamage.ApplyMultiDamage( this, pOwner );

		SetAbsVelocity( g_vecZero );
	}

	SetThink( &CShockBeam::ExplodeThink );
	SetNextThink( gpGlobals->time + 0.01 );

	if( pOther->GetTakeDamageMode() == DAMAGE_NO )
	{
		TraceResult tr;

		UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + GetAbsVelocity() * 10, dont_ignore_monsters, edict(), &tr );
	
		UTIL_DecalTrace( &tr, DECAL_OFSCORCH1 + UTIL_RandomLong( 0, 2 ) );

		MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, GetAbsOrigin() );
			WRITE_BYTE( TE_SPARKS );
			WRITE_COORD_VECTOR( GetAbsOrigin() );
		MESSAGE_END();
	}
}
开发者ID:swmpdg,项目名称:HLEnhanced,代码行数:53,代码来源:CShockBeam.cpp

示例15: UTIL_Remove

void CGrenadeAR2::Detonate(void)
{
	if (!m_bIsLive)
	{
		return;
	}
	m_bIsLive		= false;
	m_takedamage	= DAMAGE_NO;	

	if(m_hSmokeTrail)
	{
		UTIL_Remove(m_hSmokeTrail);
		m_hSmokeTrail = NULL;
	}

	CPASFilter filter( GetAbsOrigin() );

	te->Explosion( filter, 0.0,
		&GetAbsOrigin(), 
		g_sModelIndexFireball,
		2.0, 
		15,
		TE_EXPLFLAG_NONE,
		m_DmgRadius,
		m_flDamage );

	Vector vecForward = GetAbsVelocity();
	VectorNormalize(vecForward);
	trace_t		tr;
	UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() + 60*vecForward, MASK_SHOT, 
		this, COLLISION_GROUP_NONE, &tr);


	if ((tr.m_pEnt != GetWorldEntity()) || (tr.hitbox != 0))
	{
		// non-world needs smaller decals
		if( tr.m_pEnt && !tr.m_pEnt->IsNPC() )
		{
			UTIL_DecalTrace( &tr, "SmallScorch" );
		}
	}
	else
	{
		UTIL_DecalTrace( &tr, "Scorch" );
	}

	UTIL_ScreenShake( GetAbsOrigin(), 25.0, 150.0, 1.0, 750, SHAKE_START );

	RadiusDamage ( CTakeDamageInfo( this, GetThrower(), m_flDamage, DMG_BLAST ), GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL );

	UTIL_Remove( this );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:52,代码来源:grenade_ar2.cpp


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