示例#1
0
void CE_CBeam::BeamInit( const char *pSpriteName, float width )
{
	SetColor( 255, 255, 255 );
	SetBrightness( 255 );
	SetNoise( 0 );
	SetFrame( 0 );
	SetScrollRate( 0 );
	SetModelName( MAKE_STRING( pSpriteName ) );
	SetRenderMode( kRenderTransTexture );
	SetTexture( engine->PrecacheModel( pSpriteName ) );
	SetWidth( width );
	SetEndWidth( width );
	SetFadeLength( 0 );			// No fade

	for (int i=0;i<MAX_BEAM_ENTS;i++)
	{
		Set_m_hAttachEntity(i,NULL);
		Set_m_nAttachIndex(i, 0);
	}

	m_nHaloIndex	= 0;
	m_fHaloScale	= BEAM_DEFAULT_HALO_SCALE;
	m_nBeamType		= 0;
	m_nBeamFlags    = 0;
}
示例#2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CEnvLaser::KeyValue( const char *szKeyName, const char *szValue )
{
	if (FStrEq(szKeyName, "width"))
	{
		SetWidth( atof(szValue) );
	}
	else if (FStrEq(szKeyName, "NoiseAmplitude"))
	{
		SetNoise( atoi(szValue) );
	}
	else if (FStrEq(szKeyName, "TextureScroll"))
	{
		SetScrollRate( atoi(szValue) );
	}
	else if (FStrEq(szKeyName, "texture"))
	{
		SetModelName( AllocPooledString(szValue) );
	}
	else
	{
		BaseClass::KeyValue( szKeyName, szValue );
	}

	return true;
}
示例#3
0
cSdlTMS9919::cSdlTMS9919()
    :

      m_Initialized(false),
      m_MasterVolume(0), m_ShiftRegister(NOISE_RESET), m_NoiseGenerator(0),
      m_MixBuffer(NULL)
{
    //    FUNCTION_ENTRY ( this, "cSdlTMS9919 ctor", true );

    memset(m_VolumeTable, 0, sizeof(m_VolumeTable));
    memset(&m_AudioSpec, 0, sizeof(m_AudioSpec));
    memset(m_Info, 0, sizeof(m_Info));

    SetMasterVolume(50);

    float volume = 128.0 / 4.0;
    for (unsigned int i = 0; i < 16 - 1; i++) {
        m_VolumeTable[i] = (int)volume;
        volume = (float)(volume / 1.258925412); // Reduce volume by 2dB
    }
    m_VolumeTable[15] = 0;

    SDL_AudioSpec wanted;
    memset(&wanted, 0, sizeof(SDL_AudioSpec));

    // Set the audio format
    wanted.freq     = 44100;
    wanted.format   = AUDIO_S16;
    wanted.channels = 1;
    wanted.samples  = DEFAULT_SAMPLES;
    wanted.callback = _AudioCallback;
    wanted.userdata = this;

    memcpy(&m_AudioSpec, &wanted, sizeof(SDL_AudioSpec));

    /*  we don't want to initialize sdl audio here
        SDL_InitSubSystem(SDL_INIT_AUDIO);
        // Open the audio device, forcing the desired format
        if ( SDL_OpenAudio ( &wanted, &m_AudioSpec ) < 0 ) {
    //        ERROR ( "Couldn't open audio: " << SDL_GetError ());
        } else {
    //        TRACE ( "Using " << m_AudioSpec.format << "-bit " <<
    m_AudioSpec.freq << "Hz Audio" );*/
    m_Initialized = true;
    m_MixBuffer   = new Uint8[m_AudioSpec.samples];
    memset(m_MixBuffer, 0, sizeof(Uint8) * m_AudioSpec.samples);
    //        SDL_PauseAudio ( false );
    // }

    //    Mix_HookMusic(_AudioCallback, this);
    NOISE_COLOR_E color = m_NoiseColor;
    int type            = m_NoiseType;
    m_NoiseColor        = (NOISE_COLOR_E)-1;
    m_NoiseType         = -1;
    SetNoise(color, type);
}
示例#4
0
void CBeam::BeamInit( const char *pSpriteName, int width )
{
	pev->flags |= FL_CUSTOMENTITY;
	SetColor( 255, 255, 255 );
	SetBrightness( 255 );
	SetNoise( 0 );
	SetFrame( 0 );
	SetScrollRate( 0 );
	pev->model = MAKE_STRING( pSpriteName );
	SetTexture( PRECACHE_MODEL( ( char * ) pSpriteName ) );
	SetWidth( width );
	pev->skin = 0;
	pev->sequence = 0;
	pev->rendermode = 0;
}
示例#5
0
void CLaser::KeyValue(KeyValueData *pkvd)
{
	if(FStrEq(pkvd->szKeyName, "LaserTarget"))
	{
		pev->message   = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "width"))
	{
		SetWidth((int)atof(pkvd->szValue));
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "NoiseAmplitude"))
	{
		SetNoise(atoi(pkvd->szValue));
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "TextureScroll"))
	{
		SetScrollRate(atoi(pkvd->szValue));
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "texture"))
	{
		pev->model     = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "EndSprite"))
	{
		m_iszSpriteName = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled  = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "framestart"))
	{
		pev->frame     = atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "damage"))
	{
		pev->dmg       = atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else
		CBeam::KeyValue(pkvd);
}
示例#6
0
void CBeam::InputNoise( inputdata_t &inputdata )
{
	SetNoise( inputdata.value.Float() );
}
示例#7
0
void CLightning::BeamUpdateVars( void )
{
	int beamType;
	int pointStart, pointEnd;

	edict_t *pStart = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_iszStartEntity) );
	edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(m_iszEndEntity) );
	pointStart = IsPointEntity( CBaseEntity::Instance(pStart) );
	pointEnd = IsPointEntity( CBaseEntity::Instance(pEnd) );

	pev->skin = 0;
	pev->sequence = 0;
	pev->rendermode = 0;
	pev->flags |= FL_CUSTOMENTITY;
	pev->model = m_iszSpriteName;
	SetTexture( m_spriteTexture );

	beamType = BEAM_ENTS;
	if ( pointStart || pointEnd )
	{
		if ( !pointStart )	// One point entity must be in pStart
		{
			edict_t *pTemp;
			// Swap start & end
			pTemp = pStart;
			pStart = pEnd;
			pEnd = pTemp;
			int swap = pointStart;
			pointStart = pointEnd;
			pointEnd = swap;
		}
		if ( !pointEnd )
			beamType = BEAM_ENTPOINT;
		else
			beamType = BEAM_POINTS;
	}

	SetType( beamType );
	if ( beamType == BEAM_POINTS || beamType == BEAM_ENTPOINT || beamType == BEAM_HOSE )
	{
		SetStartPos( pStart->v.origin );
		if ( beamType == BEAM_POINTS || beamType == BEAM_HOSE )
			SetEndPos( pEnd->v.origin );
		else
			SetEndEntity( ENTINDEX(pEnd) );
	}
	else
	{
		SetStartEntity( ENTINDEX(pStart) );
		SetEndEntity( ENTINDEX(pEnd) );
	}

	RelinkBeam();

	SetWidth( m_boltWidth );
	SetNoise( m_noiseAmplitude );
	SetFrame( m_frameStart );
	SetScrollRate( m_speed );
	if ( pev->spawnflags & SF_BEAM_SHADEIN )
		SetFlags( BEAM_FSHADEIN );
	else if ( pev->spawnflags & SF_BEAM_SHADEOUT )
		SetFlags( BEAM_FSHADEOUT );
}
示例#8
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEnvBeam::BeamUpdateVars( void )
{
	CBaseEntity *pStart = gEntList.FindEntityByName( NULL, m_iszStartEntity );
	CBaseEntity *pEnd = gEntList.FindEntityByName( NULL, m_iszEndEntity );

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

	m_nNumBeamEnts = 2;

	m_speed = (int)clamp( m_speed, 0, MAX_BEAM_SCROLLSPEED );

	// NOTE: If the end entity is the beam itself (and the start entity
	// isn't *also* the beam itself, we've got problems. This is a problem
	// because SetAbsStartPos actually sets the entity's origin.
	if ( ( pEnd == this ) && ( pStart != this ) )
	{
		DevMsg("env_beams cannot have the end entity be the beam itself\n"
			"unless the start entity is also the beam itself!\n" );
		Assert(0);
	}

	SetModelName( m_iszSpriteName );
	SetTexture( m_spriteTexture );

	SetType( BEAM_ENTPOINT );

	if ( IsStaticPointEntity( pStart ) )
	{
		SetAbsStartPos( pStart->GetAbsOrigin() );
	}
	else
	{
		SetStartEntity( pStart );
	}

	if ( IsStaticPointEntity( pEnd ) )
	{
		SetAbsEndPos( pEnd->GetAbsOrigin() );
	}
	else
	{
		SetEndEntity( pEnd );
	}

	RelinkBeam();

	SetWidth( MIN(MAX_BEAM_WIDTH, m_boltWidth) );
	SetNoise( MIN(MAX_BEAM_NOISEAMPLITUDE, m_noiseAmplitude) );
	SetFrame( m_frameStart );
	SetScrollRate( m_speed );
	if ( m_spawnflags & SF_BEAM_SHADEIN )
	{
		SetBeamFlags( FBEAM_SHADEIN );
	}
	else if ( m_spawnflags & SF_BEAM_SHADEOUT )
	{
		SetBeamFlags( FBEAM_SHADEOUT );
	}
}