コード例 #1
0
ファイル: EnvBeam.cpp プロジェクト: xxauroraxx/Source.Python
//-----------------------------------------------------------------------------
// Purpose: Think function for striking at intervals.
//-----------------------------------------------------------------------------
void CEnvBeam::StrikeThink( void )
{
	if ( m_life != 0 )
	{
		if ( m_spawnflags & SF_BEAM_RANDOM )
			SetNextThink( gpGlobals->curtime + m_life + random->RandomFloat( 0, m_restrike ) );
		else
			SetNextThink( gpGlobals->curtime + m_life + m_restrike );
	}
	m_active = 1;

	if (!m_iszEndEntity)
	{
		if (!m_iszStartEntity)
		{
			RandomArea( );
		}
		else
		{
			CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
			if (pStart != NULL)
			{
				RandomPoint( pStart->GetAbsOrigin() );
			}
			else
			{
				Msg( "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity) );
			}
		}
		return;
	}

	Strike();
}
コード例 #2
0
ファイル: Laser.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
void CLaser::StrikeThink(void)
{
	CBaseEntity *pEnd = RandomTargetname(STRING(pev->message));

	if(pEnd)
		m_firePosition = pEnd->pev->origin;

	TraceResult tr;

	UTIL_TraceLine(pev->origin, m_firePosition, dont_ignore_monsters, NULL, &tr);
	FireAtPoint(tr);
	pev->nextthink = gpGlobals->time + 0.1;
}
コード例 #3
0
void CE_CEnvLaser::StrikeThink( void )
{
	CEntity *pEnd = RandomTargetname( STRING( *m_iszLaserTarget ) );

	Vector vecFireAt = GetAbsEndPos();
	if ( pEnd )
	{
		vecFireAt = pEnd->GetAbsOrigin();
	}

	trace_t tr;

	UTIL_TraceLine( GetAbsOrigin(), vecFireAt, MASK_SOLID, NULL, COLLISION_GROUP_NONE, &tr );
	FireAtPoint( tr );
	SetNextThink( gpGlobals->curtime );
}
コード例 #4
0
void CLightning::StrikeThink( void )
{
	if ( m_life != 0 )
	{
		if ( pev->spawnflags & SF_BEAM_RANDOM )
			pev->nextthink = gpGlobals->time + m_life + RANDOM_FLOAT( 0, m_restrike );
		else
			pev->nextthink = gpGlobals->time + m_life + m_restrike;
	}
	m_active = 1;

	if (FStringNull(m_iszEndEntity))
	{
		if (FStringNull(m_iszStartEntity))
		{
			RandomArea( );
		}
		else
		{
			CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
			if (pStart != NULL)
				RandomPoint( pStart->pev->origin );
			else
				ALERT( at_console, "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity) );
		}
		return;
	}

	CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
	CBaseEntity *pEnd = RandomTargetname( STRING(m_iszEndEntity) );

	if ( pStart != NULL && pEnd != NULL )
	{
		if ( IsPointEntity( pStart ) || IsPointEntity( pEnd ) )
		{
			if ( pev->spawnflags & SF_BEAM_RING)
			{
				// don't work
				return;
			}
		}
		MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
			if ( IsPointEntity( pStart ) || IsPointEntity( pEnd ) )
			{
				if ( !IsPointEntity( pEnd ) )	// One point entity must be in pEnd
				{
					CBaseEntity *pTemp;
					pTemp = pStart;
					pStart = pEnd;
					pEnd = pTemp;
				}
				if ( !IsPointEntity( pStart ) )	// One sided
				{
					WRITE_BYTE( TE_BEAMENTPOINT );
					WRITE_SHORT( pStart->entindex() );
					WRITE_COORD( pEnd->pev->origin.x);
					WRITE_COORD( pEnd->pev->origin.y);
					WRITE_COORD( pEnd->pev->origin.z);
				}
				else
				{
					WRITE_BYTE( TE_BEAMPOINTS);
					WRITE_COORD( pStart->pev->origin.x);
					WRITE_COORD( pStart->pev->origin.y);
					WRITE_COORD( pStart->pev->origin.z);
					WRITE_COORD( pEnd->pev->origin.x);
					WRITE_COORD( pEnd->pev->origin.y);
					WRITE_COORD( pEnd->pev->origin.z);
				}


			}
			else
			{
				if ( pev->spawnflags & SF_BEAM_RING)
					WRITE_BYTE( TE_BEAMRING );
				else
					WRITE_BYTE( TE_BEAMENTS );
				WRITE_SHORT( pStart->entindex() );
				WRITE_SHORT( pEnd->entindex() );
			}

			WRITE_SHORT( m_spriteTexture );
			WRITE_BYTE( m_frameStart ); // framestart
			WRITE_BYTE( (int)pev->framerate); // framerate
			WRITE_BYTE( (int)(m_life*10.0) ); // life
			WRITE_BYTE( m_boltWidth );  // width
			WRITE_BYTE( m_noiseAmplitude );   // noise
			WRITE_BYTE( (int)pev->rendercolor.x );   // r, g, b
			WRITE_BYTE( (int)pev->rendercolor.y );   // r, g, b
			WRITE_BYTE( (int)pev->rendercolor.z );   // r, g, b
			WRITE_BYTE( pev->renderamt );	// brightness
			WRITE_BYTE( m_speed );		// speed
		MESSAGE_END();
		DoSparks( pStart->pev->origin, pEnd->pev->origin );
		if ( pev->dmg > 0 )
		{
			TraceResult tr;
			UTIL_TraceLine( pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, NULL, &tr );
			BeamDamageInstant( &tr, pev->dmg );
		}
	}
}
コード例 #5
0
ファイル: EnvBeam.cpp プロジェクト: xxauroraxx/Source.Python
//-----------------------------------------------------------------------------
// Purpose: Strikes once for its configured lifetime.
//-----------------------------------------------------------------------------
void CEnvBeam::Strike( void )
{
	CBroadcastRecipientFilter filter;

	CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
	CBaseEntity *pEnd = RandomTargetname( STRING(m_iszEndEntity) );

	if ( pStart == NULL || pEnd == NULL )
		return;

	m_speed = (int)clamp( m_speed, 0, MAX_BEAM_SCROLLSPEED );
	
	int pointStart = IsStaticPointEntity( pStart );
	int pointEnd = IsStaticPointEntity( pEnd );

	if ( pointStart || pointEnd )
	{
		if ( m_spawnflags & SF_BEAM_RING )
		{
			// don't work
			return;
		}

		te->BeamEntPoint( filter, 0.0,
			pointStart ? 0 : pStart->entindex(),
			pointStart ? &pStart->GetAbsOrigin() : NULL,
			pointEnd ? 0 : pEnd->entindex(),
			pointEnd ? &pEnd->GetAbsOrigin() : NULL,
			m_spriteTexture,
			0,	// No halo
			m_frameStart,
			(int)m_flFrameRate,
			m_life,
			m_boltWidth,
			m_boltWidth,	// End width
			0,				// No fade
			m_noiseAmplitude,
			m_clrRender->r,	m_clrRender->g,	m_clrRender->b,	m_clrRender->a,
			m_speed );
	}
	else
	{
		if ( m_spawnflags & SF_BEAM_RING)
		{
			te->BeamRing( filter, 0.0,
				pStart->entindex(), 
				pEnd->entindex(), 
				m_spriteTexture, 
				0,	// No halo
				m_frameStart,
				(int)m_flFrameRate,
				m_life,
				m_boltWidth,
				0,	// No spread
				m_noiseAmplitude,
				m_clrRender->r,
				m_clrRender->g,
				m_clrRender->b,
				m_clrRender->a,
				m_speed );
		}
		else
		{
			te->BeamEnts( filter, 0.0,
				pStart->entindex(), 
				pEnd->entindex(), 
				m_spriteTexture,
				0,	// No halo
				m_frameStart,
				(int)m_flFrameRate,
				m_life,
				m_boltWidth,
				m_boltWidth,	// End width
				0,				// No fade
				m_noiseAmplitude,
				m_clrRender->r,
				m_clrRender->g,
				m_clrRender->b,
				m_clrRender->a,
				m_speed );

		}
	}

	DoSparks( pStart->GetAbsOrigin(), pEnd->GetAbsOrigin() );
	if ( m_flDamage > 0 )
	{
		trace_t tr;
		UTIL_TraceLine( pStart->GetAbsOrigin(), pEnd->GetAbsOrigin(), MASK_SOLID, NULL, COLLISION_GROUP_NONE, &tr );
		BeamDamageInstant( &tr, m_flDamage );
	}
	
}
コード例 #6
0
//-----------------------------------------------------------------------------
// Purpose: Strikes once for its configured lifetime.
//-----------------------------------------------------------------------------
void CEnvBeam::Strike( void )
{
	CBroadcastRecipientFilter filter;

	CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) );
	CBaseEntity *pEnd = RandomTargetname( STRING(m_iszEndEntity) );

	// if the end entity is missing, we use the Hammer-specified vector offset instead.
	bool bEndPointFromEntity = pEnd != NULL;

	if ( pStart == NULL || ( !bEndPointFromEntity && !HasEndPointHandle() ) )
		return;

	Vector vEndPointLocation;
	if ( bEndPointFromEntity )
	{
		 vEndPointLocation = pEnd->GetAbsOrigin() ;
	}
	else
	{
		EntityToWorldSpace( m_vEndPointRelative, &vEndPointLocation );
	}

	m_speed = clamp( m_speed, 0, MAX_BEAM_SCROLLSPEED );
	
	bool pointStart = IsStaticPointEntity( pStart );
	bool pointEnd = !bEndPointFromEntity || IsStaticPointEntity( pEnd );

	if ( pointStart || pointEnd )
	{
		if ( m_spawnflags & SF_BEAM_RING )
		{
			// don't work
			return;
		}

		te->BeamEntPoint( filter, 0.0,
			pointStart ? 0 : pStart->entindex(),
			pointStart ? &pStart->GetAbsOrigin() : NULL,
			pointEnd ? 0 : pEnd->entindex(),
			pointEnd ? &vEndPointLocation : NULL,
			m_spriteTexture,
			0,	// No halo
			m_frameStart,
			(int)m_flFrameRate,
			m_life,
			m_boltWidth,
			m_boltWidth,	// End width
			0,				// No fade
			m_noiseAmplitude,
			m_clrRender->r,	m_clrRender->g,	m_clrRender->b,	m_clrRender->a,
			m_speed );
	}
	else
	{
		if ( m_spawnflags & SF_BEAM_RING)
		{
			te->BeamRing( filter, 0.0,
				pStart->entindex(), 
				pEnd->entindex(), 
				m_spriteTexture, 
				0,	// No halo
				m_frameStart,
				(int)m_flFrameRate,
				m_life,
				m_boltWidth,
				0,	// No spread
				m_noiseAmplitude,
				m_clrRender->r,
				m_clrRender->g,
				m_clrRender->b,
				m_clrRender->a,
				m_speed );
		}
		else
		{
			te->BeamEnts( filter, 0.0,
				pStart->entindex(), 
				pEnd->entindex(), 
				m_spriteTexture,
				0,	// No halo
				m_frameStart,
				(int)m_flFrameRate,
				m_life,
				m_boltWidth,
				m_boltWidth,	// End width
				0,				// No fade
				m_noiseAmplitude,
				m_clrRender->r,
				m_clrRender->g,
				m_clrRender->b,
				m_clrRender->a,
				m_speed );

		}
	}

	DoSparks( pStart->GetAbsOrigin(), pEnd->GetAbsOrigin() );
	if ( m_flDamage > 0 )
	{
		trace_t tr;
		UTIL_TraceLine( pStart->GetAbsOrigin(), pEnd->GetAbsOrigin(), MASK_SOLID, NULL, COLLISION_GROUP_NONE, &tr );
		BeamDamageInstant( &tr, m_flDamage );
	}
	
}