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


C++ Detonate函数代码示例

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


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

示例1: GetAbsOrigin

//-----------------------------------------------------------------------------
// Purpose: This think function simulates (moves/collides) the HeadcrabCanister while in
//          the world.
//-----------------------------------------------------------------------------
void CEnvHeadcrabCanister::HeadcrabCanisterWorldThink( void )
{
	// Get the current time.
	float flTime = gpGlobals->curtime;

	Vector vecStartPosition = GetAbsOrigin();

	// Update HeadcrabCanister position for swept collision test.
	Vector vecEndPosition;
	QAngle vecEndAngles;
	m_Shared.GetPositionAtTime( flTime, vecEndPosition, vecEndAngles );

	if ( !m_bIncomingSoundStarted && !HasSpawnFlags( SF_NO_IMPACT_SOUND ) )
	{
		float flDistSq = ENV_HEADCRABCANISTER_INCOMING_SOUND_TIME * m_Shared.m_flFlightSpeed;
		flDistSq *= flDistSq;
		if ( vecEndPosition.DistToSqr(m_vecImpactPosition) <= flDistSq )
		{
			// Figure out if we're close enough to play the incoming sound
			EmitSound( "HeadcrabCanister.IncomingSound" );
			m_bIncomingSoundStarted = true;
		}
	}

	TestForCollisionsAgainstEntities( vecEndPosition );
	if ( m_Shared.DidImpact( flTime ) )
	{
		if ( !m_bHasDetonated )
		{
			Detonate();
			m_bHasDetonated = true;
		}
		
		if ( !HasSpawnFlags( SF_REMOVE_ON_IMPACT ) )
		{
			Landed();
		}

		return;
	}
		   
	// Always move full movement.
	SetAbsOrigin( vecEndPosition );

	// Touch triggers along the way
	PhysicsTouchTriggers( &vecStartPosition );

	SetNextThink( gpGlobals->curtime + 0.2f );
	SetAbsAngles( vecEndAngles );

	if ( !m_bHasDetonated )
	{
		if ( vecEndPosition.DistToSqr( m_vecImpactPosition ) < BoundingRadius() * BoundingRadius() )
		{
			Detonate();
			m_bHasDetonated = true;
		}
	}
}
开发者ID:NEITMod,项目名称:HL2BM2,代码行数:63,代码来源:env_headcrabcanister.cpp

示例2: GetTouchTrace

void CGrenadeEnergy::GrenadeEnergyTouch( CBaseEntity *pOther )
{
	if ( pOther->m_takedamage )
	{
		float flLifeLeft = 1-(gpGlobals->curtime  - m_flLaunchTime)/ENERGY_GRENADE_LIFETIME;

		if ( pOther->GetFlags() & (FL_CLIENT) )
		{
			CBasePlayer *pPlayer = ( CBasePlayer * )pOther;
			float		flKick	 = 120 * flLifeLeft;
			pPlayer->m_Local.m_vecPunchAngle.SetX( flKick * (random->RandomInt(0,1) == 1) ? -1 : 1 );
			pPlayer->m_Local.m_vecPunchAngle.SetY( flKick * (random->RandomInt(0,1) == 1) ? -1 : 1 );
		}
		float flDamage = m_flDamage * flLifeLeft;
		if (flDamage < 1) 
		{
			flDamage = 1;
		}

		trace_t tr;
		tr = GetTouchTrace();
		CTakeDamageInfo info( this, GetThrower(), m_flDamage * flLifeLeft, DMG_SONIC );
		CalculateMeleeDamageForce( &info, (tr.endpos - tr.startpos), tr.endpos );
		pOther->TakeDamage( info );
	}
	Detonate();
}
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:27,代码来源:grenade_energy.cpp

示例3: Assert

void CGrenadeHomer::GrenadeHomerTouch( CBaseEntity *pOther )
{
	Assert( pOther );

	// Don't take damage from other homing grenades so can shoot in vollies
	if (FClassnameIs( pOther, "grenade_homer") || !pOther->IsSolid() )
	{
		return;
	}

	// ----------------------------------
	// If I hit the sky, don't explode
	// ----------------------------------
	trace_t tr;
	UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + GetAbsVelocity(),  MASK_SOLID_BRUSHONLY, 
		this, COLLISION_GROUP_NONE, &tr);

	if (tr.surface.flags & SURF_SKY)
	{
		StopRocketTrail();
		UTIL_Remove( this );
	}
	else
	{
		Detonate();
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:27,代码来源:grenade_homer.cpp

示例4: Detonate

void CGrenadeFrag::DelayThink() 
{
	if( gpGlobals->curtime > m_flDetonateTime )
	{
		Detonate();
		return;
	}

	if( !m_bHasWarnedAI && gpGlobals->curtime >= m_flWarnAITime )
	{
#if !defined( CLIENT_DLL )
		CSoundEnt::InsertSound ( SOUND_DANGER, GetAbsOrigin(), 400, 1.5, this );
#endif
		m_bHasWarnedAI = true;
	}
	
	if( gpGlobals->curtime > m_flNextBlipTime )
	{
		BlipSound();
		
		if( m_bHasWarnedAI )
		{
			m_flNextBlipTime = gpGlobals->curtime + FRAG_GRENADE_BLIP_FAST_FREQUENCY;
		}
		else
		{
			m_flNextBlipTime = gpGlobals->curtime + FRAG_GRENADE_BLIP_FREQUENCY;
		}
	}

	SetNextThink( gpGlobals->curtime + 0.1 );
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:32,代码来源:grenade_frag.cpp

示例5: GetEntity

void CC4Projectile::OnServerExplosion( const ExplosionInfo& explosionInfo )
{
	if(gEnv->bMultiplayer)
	{
		//Check for explosions
		IPhysicalEntity *pPE = GetEntity()->GetPhysics();
		if(pPE)
		{
			float affected = gEnv->pSystem->GetIPhysicalWorld()->IsAffectedByExplosion(pPE);
			if(affected > 0.001f && m_hitPoints > 0 && !CheckAnyProjectileFlags(ePFlag_destroying))
			{
				//Only enemy explosions
				if(CGameRules* pGameRules = g_pGame->GetGameRules())
				{
					EntityId explosionTeamId = pGameRules->GetTeam(explosionInfo.shooterId);
					if(explosionTeamId != m_teamId)
					{
						m_armed = true;
						Detonate();
						return;
					}
				}		
			}
		}
	}

	CProjectile::OnServerExplosion(explosionInfo);
}
开发者ID:Xydrel,项目名称:Infected,代码行数:28,代码来源:C4Projectile.cpp

示例6: 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

示例7: SetNextThink

//-----------------------------------------------------------------------------
// Purpose:  The grenade has a slight delay before it goes live.  That way the
//			 person firing it can bounce it off a nearby wall.  However if it
//			 hits another character it blows up immediately
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CGrenadeAR2::GrenadeAR2Think( void )
{
	SetNextThink( gpGlobals->curtime + 0.05f );

	if (!m_bIsLive)
	{
		// Go live after a short delay
		if (m_fSpawnTime + MAX_AR2_NO_COLLIDE_TIME < gpGlobals->curtime)
		{
			m_bIsLive  = true;
		}
	}
	
	// If I just went solid and my velocity is zero, it means I'm resting on
	// the floor already when I went solid so blow up
	if (m_bIsLive)
	{
		if (GetAbsVelocity().Length() == 0.0 ||
			GetGroundEntity() != NULL )
		{
			Detonate();
		}
	}

	// The old way of making danger sounds would scare the crap out of EVERYONE between you and where the grenade
	// was going to hit. The radius of the danger sound now 'blossoms' over the grenade's lifetime, making it seem
	// dangerous to a larger area downrange than it does from where it was fired.
	if( m_fDangerRadius <= AR2_GRENADE_MAX_DANGER_RADIUS )
	{
		m_fDangerRadius += ( AR2_GRENADE_MAX_DANGER_RADIUS * 0.05 );
	}

	CSoundEnt::InsertSound( SOUND_DANGER, GetAbsOrigin() + GetAbsVelocity() * 0.5, m_fDangerRadius, 0.2, this, SOUNDENT_CHANNEL_REPEATED_DANGER );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:41,代码来源:grenade_ar2.cpp

示例8: StartGenericFX

//
// ProjectileObj::Collided
//
// Called when the projectile colides with something
//
void ProjectileObj::Collided(MapObj *with, const Vector *veloc)
{
  // Call Parent scope first
  MapObj::Collided(with, veloc);

  StartGenericFX(0xF288B23E, NULL, TRUE); // "ProjectileObj::Hit"

  // If the projectile explodes on impact then detonate
  if (ProjectileType()->GetImpact())
  {
    // If it hit something then apply some damage to it
    if (with && !ProjectileType()->explosionType.Alive())
    {
      //FIXME(925491294, "aiarossi"); // Fri Apr 30 09:54:54 1999
      // this is passing the impulse velocity of the projectile to the map obj
      S32 deltaHp = -GetDamage(with->MapType()->GetArmourClass());

      with->ModifyHitPoints(deltaHp, source.GetPointer(), sourceTeam, veloc);

      // Apply hit modifiers
      if (deltaHp)
      {
        weaponType->GetDamage().GetModifiers().Apply(with);
      }
    }
    
    // Kaboom
    Detonate();
  }
}
开发者ID:vgck,项目名称:opendr2,代码行数:35,代码来源:projectileobj.cpp

示例9: Detonate

LTBOOL CProjectile::TestInsideObject(HOBJECT hTestObj, AmmoType eAmmoType)
{
    if (!hTestObj) return LTFALSE;

	// TO DO???
	// NOTE:  This code may need to be updated to use test the dims
	// of the CharacterHitBox instead of the dims of the object...
	// TO DO???

	// See if we are inside the test object...

    LTVector vTestPos, vTestDims;
    g_pLTServer->GetObjectPos(hTestObj, &vTestPos);
    g_pLTServer->GetObjectDims(hTestObj, &vTestDims);

	if (m_vFirePos.x < vTestPos.x - vTestDims.x ||
		m_vFirePos.x > vTestPos.x + vTestDims.x ||
		m_vFirePos.y < vTestPos.y - vTestDims.y ||
		m_vFirePos.y > vTestPos.y + vTestDims.y ||
		m_vFirePos.z < vTestPos.z - vTestDims.z ||
		m_vFirePos.z > vTestPos.z + vTestDims.z)
	{
        return LTFALSE;
	}


	// We're inside the object, so we automatically hit the object...

	if (eAmmoType == PROJECTILE)
	{
		Detonate(hTestObj);
	}
	else
	{
		if (eAmmoType == VECTOR)
		{
			if (IsCharacter(hTestObj))
			{
                CCharacter *pChar = (CCharacter*) g_pLTServer->HandleToObject(hTestObj);
                if (!pChar) return LTFALSE;

				ModelNode eModelNode = g_pModelButeMgr->GetSkeletonDefaultHitNode(pChar->GetModelSkeleton());

				pChar->SetModelNodeLastHit(eModelNode);

				m_fInstDamage *= pChar->ComputeDamageModifier(eModelNode);
			}

			ImpactDamageObject(m_hFiredFrom, hTestObj);
		}

        LTVector vNormal(0, 1, 0);
		AddImpact(hTestObj, m_vFlashPos, vTestPos, vNormal, GetSurfaceType(hTestObj));
	}

	RemoveObject();

    return LTTRUE;
}
开发者ID:germanocaldeira,项目名称:no-one-lives-forever,代码行数:59,代码来源:Projectile.cpp

示例10: GetAbsAngles

void CASW_Boomer_Blob::Touch( CBaseEntity *pOther )
{
	if ( !pOther || pOther == GetOwnerEntity() )
	{
		return;
	}

	if ( !pOther->IsSolid() || pOther->IsSolidFlagSet( FSOLID_VOLUME_CONTENTS ) )
	{
		return;
	}

/*
	if ( pOther == GetWorldEntity() )
	{
		// lay flat
		QAngle angMortar = GetAbsAngles();
		SetAbsAngles( QAngle( 0, angMortar.x, 0 ) );

		SetAbsVelocity( vec3_origin );
	}
*/

	if ( m_bExplodeOnWorldContact )
	{
		Detonate();
	}

	// make sure we don't die on things we shouldn't
	if ( !ASWGameRules() || !ASWGameRules()->ShouldCollide( GetCollisionGroup(), pOther->GetCollisionGroup() ) )
	{
		return;
	}

	if ( pOther->m_takedamage == DAMAGE_NO )
	{
		if (GetAbsVelocity().Length2D() > 60)
		{
			EmitSound("Grenade.ImpactHard");
		}
	}

	// can't detonate yet?
	if ( gpGlobals->curtime < m_fEarliestTouchDetonationTime )
	{
		return;
	}

	// we don't want the mortar grenade to explode on impact of marine's because 
	// it's more fun to have them avoid the area it landed in than to take blind damage
	/*
	if ( pOther->m_takedamage != DAMAGE_NO )
	{
		if ( pOther->IsNPC() && pOther->Classify() != CLASS_PLAYER_ALLY_VITAL )
		{
			Detonate();
		}
	}*/
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:59,代码来源:asw_boomer_blob.cpp

示例11: ResetSequence

void CASW_Boomer_Blob::CheckNearbyTargets( )
{	
	// see if an alien is nearby
	if ( gpGlobals->curtime >= m_fEarliestAOEDetonationTime )
	{
		if ( !m_bModelOpening && gpGlobals->curtime >= (m_fDetonateTime - ASW_BOOMER_WARN_DELAY) )
		{
			// we are one second from detonating, commit to detonating and start the opening sequence
			// regardless of anyone nearby
			m_bModelOpening = true;
			ResetSequence( LookupSequence( "MortarBugProjectile_Opening" ) );

			CEffectData	data;
			data.m_vOrigin = GetAbsOrigin();
			CPASFilter filter( data.m_vOrigin );
			filter.SetIgnorePredictionCull(true);
			DispatchParticleEffect( "boomer_grenade_open", PATTACH_ABSORIGIN_FOLLOW, this, -1, false, -1, &filter );
		}

		// if we exceeded the detonation time, just detonate
		if ( gpGlobals->curtime >= m_fDetonateTime )
		{
			Detonate();
			return;
		}

		// if the model is opening, do the animation advance
		if ( m_bModelOpening )
		{
			StudioFrameAdvance();
			SetNextThink( gpGlobals->curtime );
			return;
		}

		float flRadius = asw_boomer_blob_radius_check_scale.GetFloat() * m_DmgRadius;
		Vector vecSrc = GetAbsOrigin();
		CBaseEntity *pEntity = NULL;
		for ( CEntitySphereQuery sphere( vecSrc, flRadius ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
		{
			if ( !pEntity || !pEntity->IsPlayer() )
				continue;

			// give them a 2 second warning before detonation
			m_fDetonateTime = MIN( m_fDetonateTime, m_fDetonateTime + ASW_BOOMER_WARN_DELAY );
		}
	}
	
	if ( m_fDetonateTime <= gpGlobals->curtime + asw_boomer_blob_radius_check_interval.GetFloat() )
	{
		SetThink( &CASW_Boomer_Blob::Detonate );
		SetNextThink( m_fDetonateTime );
	}
	else
	{
		SetThink( &CASW_Boomer_Blob::CheckNearbyTargets );
		SetNextThink( gpGlobals->curtime + asw_boomer_blob_radius_check_interval.GetFloat() );
	}
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:58,代码来源:asw_boomer_blob.cpp

示例12: IsMainWorld

void CProjectileFX::HandleTouch(CollisionInfo *pInfo)
{
	if (!m_pClientDE || !pInfo || !pInfo->m_hObject || !g_pGameClientShell) return;

	 // Let it get out of our bounding box...

	CMoveMgr* pMoveMgr = g_pPlayerMgr->GetMoveMgr();
	if (pMoveMgr)
	{
		// Don't colide with the move mgr object...

		HLOCALOBJ hMoveObj = pMoveMgr->GetObject();
		if (pInfo->m_hObject == hMoveObj) return;

		// Don't colide with the player object...

		HLOCALOBJ hPlayerObj = m_pClientDE->GetClientObject();
		if (pInfo->m_hObject == hPlayerObj) return;
	}


	// See if we want to impact on this object...

    uint32 dwUsrFlags;
	g_pCommonLT->GetObjectFlags(pInfo->m_hObject, OFT_User, dwUsrFlags);
	if (dwUsrFlags & USRFLG_IGNORE_PROJECTILES) return;

    LTBOOL bIsWorld = IsMainWorld(pInfo->m_hObject);

	// Don't impact on non-solid objects...

    uint32 dwFlags;
	g_pCommonLT->GetObjectFlags(pInfo->m_hObject, OFT_Flags, dwFlags);
	if (!bIsWorld && !(dwFlags & FLAG_SOLID)) return;


	// See if we hit the sky...

	if (bIsWorld)
	{
		SurfaceType eType = GetSurfaceType(pInfo->m_hPoly);

		if (eType == ST_SKY)
		{
            m_bWantRemove = LTTRUE;
			return;
		}
		else if (eType == ST_INVISIBLE)
		{
			// Keep going, ignore this object...
			return;
		}
	}

	Detonate(pInfo);
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:56,代码来源:ProjectileFX.cpp

示例13: Detonate

void CGrenadeMP5::GrenadeMP5Touch( CBaseEntity *pOther )
{
	if ( !pOther->IsSolid() )
		return;

	// If I'm live go ahead and blow up
	if (m_bIsLive)
	{
		Detonate();
	}
	else
	{
		// If I'm not live, only blow up if I'm hitting an chacter that
		// is not the owner of the weapon
		CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pOther );
		if (pBCC && GetThrower() != pBCC)
		{
			m_bIsLive = true;
			Detonate();
		}
	}
}
开发者ID:hitmen047,项目名称:TF2HLCoop,代码行数:22,代码来源:hl1_grenade_mp5.cpp

示例14: Detonate

void CDeferredExplosionQueue::FrameUpdatePreEntityThink( )
{
	// if nothing has exploded this frame and we've got something in the queue, blow it up
	if ( m_fLastExplosionTime <= gpGlobals->curtime - ASW_EXPLODING_PROP_INTERVAL && 
		 m_Explodables.Count() > 0 )
	{
		CASW_Exploding_Prop *pBoom = m_Explodables.Head().m_hHandle.Get();
		if ( pBoom ) 
		{
			Detonate( pBoom, m_Explodables.Head().m_damageInfo );
		}
		m_Explodables.RemoveAtHead();
	}
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:14,代码来源:asw_barrel_explosive.cpp

示例15: Detonate

void Bomb::DoUpdate(double dt) {
  if (!IsAlive())
    return;

  // die after time to live
  m_living_time += dt;
  if (m_living_time>=g_bomb_time_to_live)
    Detonate();

  // process animation; change frame if necessary
  const double frame_duration = .3;
  m_time_from_last_frame_switch += dt;
  if( m_time_from_last_frame_switch > frame_duration ) {
    m_anim_frame_num = (m_anim_frame_num+rand()%7)%3;   // choose next frame at random
    m_time_from_last_frame_switch -= frame_duration;
  }
}
开发者ID:mmilewski,项目名称:bynadlaster,代码行数:17,代码来源:Bomb.cpp


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