Ejemplo n.º 1
0
/*
===============
CG_TestTS_f

Test a trail system
===============
*/
void CG_TestTS_f()
{
	char tsName[ MAX_QPATH ];

	if ( trap_Argc() < 2 )
	{
		return;
	}

	Q_strncpyz( tsName, CG_Argv( 1 ), MAX_QPATH );
	testTSHandle = CG_RegisterTrailSystem( tsName );

	if ( testTSHandle )
	{
		CG_DestroyTestTS_f();

		testTS = CG_SpawnNewTrailSystem( testTSHandle );

		if ( CG_IsTrailSystemValid( &testTS ) )
		{
			CG_SetAttachmentCent( &testTS->frontAttachment, &cg_entities[ 0 ] );
			CG_AttachToCent( &testTS->frontAttachment );
		}
	}
}
Ejemplo n.º 2
0
/*
===============
CG_InitWeapons

Precaches weapons
===============
*/
void CG_InitWeapons( void )
{
  int   i;

  memset( cg_weapons, 0, sizeof( cg_weapons ) );

  for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
    CG_RegisterWeapon( i );

  cgs.media.level2ZapTS = CG_RegisterTrailSystem( "models/weapons/lev2zap/lightning" );
}
Ejemplo n.º 3
0
/*
===============
CG_InitBuildables

Initialises the animation db
===============
*/
void CG_InitBuildables( void )
{
  char          filename[ MAX_QPATH ];
  char          soundfile[ MAX_QPATH ];
  char          *buildableName;
  char          *modelFile;
  int           i;
  int           j;
  fileHandle_t  f;

  memset( cg_buildables, 0, sizeof( cg_buildables ) );

  //default sounds
  for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ )
  {
    strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] );

    Com_sprintf( filename, sizeof( filename ), "sound/buildables/alien/%s", soundfile );
    defaultAlienSounds[ j ] = trap_S_RegisterSound( filename, qfalse );

    Com_sprintf( filename, sizeof( filename ), "sound/buildables/human/%s", soundfile );
    defaultHumanSounds[ j ] = trap_S_RegisterSound( filename, qfalse );
  }

  cg.buildablesFraction = 0.0f;

  for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ )
  {
    buildableName = BG_FindNameForBuildable( i );

    //animation.cfg
    Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName );
    if ( !CG_ParseBuildableAnimationFile( filename, i ) )
      Com_Printf( S_COLOR_YELLOW "WARNING: failed to load animation file %s\n", filename );

    //sound.cfg
    Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/sound.cfg", buildableName );
    if ( !CG_ParseBuildableSoundFile( filename, i ) )
      Com_Printf( S_COLOR_YELLOW "WARNING: failed to load sound file %s\n", filename );

    //models
    for( j = 0; j <= 3; j++ )
    {
      if( ( modelFile = BG_FindModelsForBuildable( i, j ) ) )
        cg_buildables[ i ].models[ j ] = trap_R_RegisterModel( modelFile );
    }

    //sounds
    for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ )
    {
      strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] );
      Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/%s", buildableName, soundfile );

      if( cg_buildables[ i ].sounds[ j ].enabled )
      {
        if( trap_FS_FOpenFile( filename, &f, FS_READ ) > 0 )
        {
          //file exists so close it
          trap_FS_FCloseFile( f );

          cg_buildables[ i ].sounds[ j ].sound = trap_S_RegisterSound( filename, qfalse );
        }
        else
        {
          //file doesn't exist - use default
          if( BG_FindTeamForBuildable( i ) == BIT_ALIENS )
            cg_buildables[ i ].sounds[ j ].sound = defaultAlienSounds[ j ];
          else
            cg_buildables[ i ].sounds[ j ].sound = defaultHumanSounds[ j ];
        }
      }
    }

    cg.buildablesFraction = (float)i / (float)( BA_NUM_BUILDABLES - 1 );
    trap_UpdateScreen( );
  }

  cgs.media.teslaZapTS = CG_RegisterTrailSystem( "models/buildables/tesla/zap" );
}
Ejemplo n.º 4
0
/*
===============
CG_ParseWeaponModeSection

Parse a weapon mode section
===============
*/
static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p )
{
  char  *token;
  int   i;

  // read optional parameters
  while( 1 )
  {
    token = COM_Parse( text_p );

    if( !token )
      break;

    if( !Q_stricmp( token, "" ) )
      return qfalse;

    if( !Q_stricmp( token, "missileModel" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileModel = trap_R_RegisterModel( token );

      if( !wim->missileModel )
        CG_Printf( S_COLOR_RED "ERROR: missile model not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "missileSprite" ) )
    {
      int size = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      size = atoi( token );

      if( size < 0 )
        size = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileSprite = trap_R_RegisterShader( token );
      wim->missileSpriteSize = size;
      wim->usesSpriteMissle = qtrue;

      if( !wim->missileSprite )
        CG_Printf( S_COLOR_RED "ERROR: missile sprite not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "missileRotates" ) )
    {
      wim->missileRotates = qtrue;

      continue;
    }
    else if( !Q_stricmp( token, "missileAnimates" ) )
    {
      wim->missileAnimates = qtrue;

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileAnimStartFrame = atoi( token );

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileAnimNumFrames = atoi( token );

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileAnimFrameRate = atoi( token );

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileAnimLooping = atoi( token );

      continue;
    }
    else if( !Q_stricmp( token, "missileParticleSystem" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileParticleSystem = CG_RegisterParticleSystem( token );

      if( !wim->missileParticleSystem )
        CG_Printf( S_COLOR_RED "ERROR: missile particle system not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "missileTrailSystem" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileTrailSystem = CG_RegisterTrailSystem( token );

      if( !wim->missileTrailSystem )
        CG_Printf( S_COLOR_RED "ERROR: missile trail system not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "muzzleParticleSystem" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->muzzleParticleSystem = CG_RegisterParticleSystem( token );

      if( !wim->muzzleParticleSystem )
        CG_Printf( S_COLOR_RED "ERROR: muzzle particle system not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "impactParticleSystem" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->impactParticleSystem = CG_RegisterParticleSystem( token );

      if( !wim->impactParticleSystem )
        CG_Printf( S_COLOR_RED "ERROR: impact particle system not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "impactMark" ) )
    {
      int size = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      size = atoi( token );

      if( size < 0 )
        size = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->impactMark = trap_R_RegisterShader( token );
      wim->impactMarkSize = size;

      if( !wim->impactMark )
        CG_Printf( S_COLOR_RED "ERROR: impact mark shader not found %s\n", token );

      continue;
    }
    else if( !Q_stricmp( token, "impactSound" ) )
    {
      int index = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      index = atoi( token );

      if( index < 0 )
        index = 0;
      else if( index > 3 )
        index = 3;

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->impactSound[ index ] = trap_S_RegisterSound( token, qfalse );

      continue;
    }
    else if( !Q_stricmp( token, "impactFleshSound" ) )
    {
      int index = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      index = atoi( token );

      if( index < 0 )
        index = 0;
      else if( index > 3 )
        index = 3;

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->impactFleshSound[ index ] = trap_S_RegisterSound( token, qfalse );

      continue;
    }
    else if( !Q_stricmp( token, "alwaysImpact" ) )
    {
      wim->alwaysImpact = qtrue;

      continue;
    }
    else if( !Q_stricmp( token, "flashDLightColor" ) )
    {
      for( i = 0 ; i < 3 ; i++ )
      {
        token = COM_Parse( text_p );
        if( !token )
          break;

        wim->flashDlightColor[ i ] = atof( token );
      }

      continue;
    }
    else if( !Q_stricmp( token, "continuousFlash" ) )
    {
      wim->continuousFlash = qtrue;

      continue;
    }
    else if( !Q_stricmp( token, "missileDlightColor" ) )
    {
      for( i = 0 ; i < 3 ; i++ )
      {
        token = COM_Parse( text_p );
        if( !token )
          break;

        wim->missileDlightColor[ i ] = atof( token );
      }

      continue;
    }
    else if( !Q_stricmp( token, "missileDlight" ) )
    {
      int size = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      size = atoi( token );

      if( size < 0 )
        size = 0;

      wim->missileDlight = size;

      continue;
    }
    else if( !Q_stricmp( token, "firingSound" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->firingSound = trap_S_RegisterSound( token, qfalse );

      continue;
    }
    else if( !Q_stricmp( token, "missileSound" ) )
    {
      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->missileSound = trap_S_RegisterSound( token, qfalse );

      continue;
    }
    else if( !Q_stricmp( token, "flashSound" ) )
    {
      int index = 0;

      token = COM_Parse( text_p );
      if( !token )
        break;

      index = atoi( token );

      if( index < 0 )
        index = 0;
      else if( index > 3 )
        index = 3;

      token = COM_Parse( text_p );
      if( !token )
        break;

      wim->flashSound[ index ] = trap_S_RegisterSound( token, qfalse );

      continue;
    }
    else if( !Q_stricmp( token, "}" ) )
      return qtrue; //reached the end of this weapon section
    else
    {
      CG_Printf( S_COLOR_RED "ERROR: unknown token '%s' in weapon section\n", token );
      return qfalse;
    }
  }

  return qfalse;
}