OW_SOUND.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. // Filename : OW_SOUND.CPP
  21. // Description: Ambient Sound Functions
  22. #include <OSYS.h>
  23. #include <OAUDIO.h>
  24. #include <OSE.h>
  25. #include <OVOLUME.h>
  26. #include <OWEATHER.h>
  27. #include <OWORLD.h>
  28. // ------- define constant -------//
  29. #define MAX_BIRD 17
  30. //------- Begin of function World::process_ambient_sound -------//
  31. //
  32. void World::process_ambient_sound()
  33. {
  34. int temp = weather.temp_c();
  35. if( weather.rain_scale() == 0 && temp >= 15 && m.random(temp) >= 12)
  36. {
  37. int bird = m.random(MAX_BIRD) + 1;
  38. char sndFile[] = "BIRDS00";
  39. err_when( bird > 99 );
  40. sndFile[5] = (bird / 10) + '0';
  41. sndFile[6] = (bird % 10) + '0';
  42. int xLoc = m.random(max_x_loc) - (zoom_matrix->top_x_loc + zoom_matrix->disp_x_loc/2);
  43. int yLoc = m.random(max_y_loc) - (zoom_matrix->top_y_loc + zoom_matrix->disp_y_loc/2);
  44. PosVolume p(PosVolume(xLoc, yLoc));
  45. RelVolume relVolume(p, 200, MAX_MAP_WIDTH);
  46. if( relVolume.rel_vol < 80)
  47. relVolume.rel_vol = 80;
  48. se_ctrl.request(sndFile, relVolume);
  49. }
  50. }
  51. //-------- End of function World::process_ambient_sound --------//