Guest User

Ship flyby sound

a guest
Sep 19th, 2011
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: code/object/objectsnd.cpp
  2. ===================================================================
  3. --- code/object/objectsnd.cpp   (revision 7762)
  4. +++ code/object/objectsnd.cpp   (working copy)
  5. @@ -423,10 +423,18 @@
  6.                 ship_info *sip = &Ship_info[Ships[closest_objp->instance].ship_info_index];
  7.                 game_snd *snd;
  8.  
  9. -               if (sip->flags & SIF_BOMBER)
  10. -                   snd = &Species_info[sip->species].snd_flyby_bomber;
  11. +               // m!m allow flyby sounds to be defined in the ship class
  12. +               if (sip->flyby_snd.sig >= 0)
  13. +               {
  14. +                   snd = &sip->flyby_snd;
  15. +               }
  16.                 else
  17. -                   snd = &Species_info[sip->species].snd_flyby_fighter;
  18. +               {
  19. +                   if (sip->flags & SIF_BOMBER)
  20. +                       snd = &Species_info[sip->species].snd_flyby_bomber;
  21. +                   else
  22. +                       snd = &Species_info[sip->species].snd_flyby_fighter;
  23. +               }
  24.  
  25.                 // play da sound
  26.                 snd_play_3d(snd, &closest_objp->pos, &View_position);
  27. Index: code/ship/ship.cpp
  28. ===================================================================
  29. --- code/ship/ship.cpp  (revision 7762)
  30. +++ code/ship/ship.cpp  (working copy)
  31. @@ -1268,6 +1268,32 @@
  32.     }
  33.  }
  34.  
  35. +void parse_flyby_snd(game_snd *gs)
  36. +{
  37. +   int is_3d;
  38. +   gs->sig = 0;
  39. +
  40. +   stuff_string(gs->filename, F_NAME, MAX_FILENAME_LEN, ",");
  41. +   if ( !stricmp(gs->filename,NOX("empty")) ) {
  42. +       gs->filename[0] = 0;
  43. +       advance_to_eoln(NULL);
  44. +       return;
  45. +   }
  46. +   Mp++;
  47. +   stuff_int(&gs->preload);
  48. +   stuff_float(&gs->default_volume);
  49. +   stuff_int(&is_3d);
  50. +   if ( is_3d ) {
  51. +       gs->flags |= GAME_SND_USE_DS3D;
  52. +       stuff_int(&gs->min);
  53. +       stuff_int(&gs->max);
  54. +   } else {
  55. +       gs->min = 0;
  56. +       gs->max = 0;
  57. +   }
  58. +   advance_to_eoln(NULL);
  59. +}
  60. +
  61.  /**
  62.   * Puts values into a ship_info.
  63.   */
  64. @@ -2630,6 +2656,15 @@
  65.     //Parse optional sound to be used for end of a glide
  66.     parse_sound("$GlideEndSnd:", &sip->glide_end_snd, sip->name);
  67.  
  68. +   if (optional_string("$FlybySnd:"))
  69. +   {
  70. +       parse_flyby_snd(&sip->flyby_snd);
  71. +   }
  72. +   else
  73. +   {
  74. +       sip->flyby_snd.sig = -1;
  75. +   }
  76. +
  77.     if(optional_string("$Closeup_pos:"))
  78.     {
  79.         stuff_vector(&sip->closeup_pos);
  80. Index: code/ship/ship.h
  81. ===================================================================
  82. --- code/ship/ship.h    (revision 7762)
  83. +++ code/ship/ship.h    (working copy)
  84. @@ -1374,6 +1374,8 @@
  85.     SCP_vector<cockpit_display_info> displays;
  86.  
  87.     SCP_map<SCP_string, path_metadata> pathMetadata;
  88. +
  89. +   game_snd flyby_snd;
  90.  } ship_info;
  91.  
  92.  extern int Num_wings;
RAW Paste Data