data.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. -- This file is reloadable.
  2. -- Table of registered sounds. Algorithm intended for intermittent sounds only, continuous sounds need special treatment.
  3. -- Data includes what environment the sound needs to play, what time of day, what elevations, etc. This table is updated dynamically.
  4. ambiance.allsounds = {}
  5. ambiance.tmpsounds = {
  6. -- Dripping water: occurs in over-world caves at any time of day.
  7. -- Can also be heard in developed areas, underground.
  8. {
  9. name="drippingwater", mingain=0.2, maxgain = 1.0, miny=-25000, maxy=-30, time="", indoors=nil,
  10. noise_params = {
  11. offset = 0,
  12. scale = 1,
  13. spread = {x=256, y=256, z=256},
  14. seed = 2129394,
  15. octaves = 3,
  16. persist = 0.5,
  17. lacunarity = 1.5,
  18. flags = "",
  19. },
  20. noise_threshold = 0.0,
  21. },
  22. -- Cave bats: occurs in over-world caves, only at night.
  23. {
  24. name="cave_bats", gain=0.7, miny=-25000, maxy=-60, time="night", indoors=false, mintime=60, maxtime=120,
  25. noise_params = {
  26. offset = 0,
  27. scale = 1,
  28. spread = {x=256, y=256, z=256},
  29. seed = 577891,
  30. octaves = 2,
  31. persist = 0.5,
  32. lacunarity = 1.5,
  33. flags = "",
  34. },
  35. noise_threshold = 0.3,
  36. },
  37. -- Wind: surface sound only, any time of day (but more common at night).
  38. {name="wind1", gain=0.5, miny=-15, maxy=3300, time="day", indoors=false, },
  39. {name="wind2", gain=0.5, miny=-15, maxy=3300, time="day", indoors=false, },
  40. {name="desertwind", gain=0.5, miny=-15, maxy=3300, time="day", indoors=false, },
  41. {name="wind1", gain=1.0, miny=-15, maxy=3300, time="night", indoors=false, mintime=20, maxtime=50, },
  42. {name="wind2", gain=1.0, miny=-15, maxy=3300, time="night", indoors=false, mintime=20, maxtime=50, },
  43. {name="desertwind", gain=1.0, miny=-15, maxy=3300, time="night", indoors=false, mintime=20, maxtime=50, },
  44. -- Plays in caverealms.
  45. {
  46. name="cavewind", gain=1.0, miny=-31000, maxy=-256, time="", indoors=nil, mintime=25, maxtime=45,
  47. -- These parameters match the mapgen.
  48. noise_params = {
  49. flags = "defaults",
  50. lacunarity = 2,
  51. offset = 0,
  52. scale = 1,
  53. spread = {x=768, y=256, z=768},
  54. seed = 59033,
  55. octaves = 6,
  56. persistence = 0.63,
  57. },
  58. -- Mapgen threshold is 0.6.
  59. -- Use a slightly lower threshold so that the sound extends outside the caverns a bit.
  60. noise_threshold = 0.5,
  61. -- The world-seed is very large, causing integer overflow.
  62. -- So we need to get the engine to calculate it against the world seed,
  63. -- in order to ensure we use the same final seed the engine uses.
  64. include_world_seed = true,
  65. },
  66. {
  67. name="cavedraft", gain=1.0, miny=-31000, maxy=-256, time="", indoors=nil, mintime=100, maxtime=400,
  68. -- These parameters match the mapgen.
  69. noise_params = {
  70. flags = "defaults",
  71. lacunarity = 2,
  72. offset = 0,
  73. scale = 1,
  74. spread = {x=768, y=256, z=768},
  75. seed = 59033,
  76. octaves = 6,
  77. persistence = 0.63,
  78. },
  79. -- Mapgen threshold is 0.6.
  80. -- Use a slightly lower threshold so that the sound extends outside the caverns a bit.
  81. noise_threshold = 0.5,
  82. -- The world-seed is very large, causing integer overflow.
  83. -- So we need to get the engine to calculate it against the world seed,
  84. -- in order to ensure we use the same final seed the engine uses.
  85. include_world_seed = true,
  86. },
  87. {
  88. name="darkwind", gain=1.0, miny=-31000, maxy=-256, time="", indoors=nil, mintime=200, maxtime=500,
  89. -- These parameters match the mapgen.
  90. noise_params = {
  91. flags = "defaults",
  92. lacunarity = 2,
  93. offset = 0,
  94. scale = 1,
  95. spread = {x=768, y=256, z=768},
  96. seed = 59033,
  97. octaves = 6,
  98. persistence = 0.63,
  99. },
  100. -- Mapgen threshold is 0.6.
  101. -- Use a slightly lower threshold so that the sound extends outside the caverns a bit.
  102. noise_threshold = 0.5,
  103. -- The world-seed is very large, causing integer overflow.
  104. -- So we need to get the engine to calculate it against the world seed,
  105. -- in order to ensure we use the same final seed the engine uses.
  106. include_world_seed = true,
  107. },
  108. -- This plays in both overworld and channelwood (jarkati has its own entry).
  109. {name="desertwind", mingain=0.2, maxgain=0.4, miny=-15,maxy=3300,time="", indoors=nil, mintime=6, maxtime=8, }, -- Continuous quiet loop.
  110. -- Various animal sounds.
  111. {
  112. name="wolves", gain=1.0, miny=-10, maxy=1000, time="night", indoors=false,
  113. noise_params = {
  114. offset = 0,
  115. scale = 1,
  116. spread = {x=256, y=256, z=256},
  117. seed = 381783,
  118. octaves = 2,
  119. persist = 0.5,
  120. lacunarity = 1.5,
  121. flags = "",
  122. },
  123. noise_threshold = 0.3,
  124. },
  125. {
  126. name="coyote", gain=1.0, miny=-10, maxy=1000, time="night", indoors=false,
  127. noise_params = {
  128. offset = 0,
  129. scale = 1,
  130. spread = {x=256, y=256, z=256},
  131. seed = 6822034,
  132. octaves = 2,
  133. persist = 0.5,
  134. lacunarity = 1.5,
  135. flags = "",
  136. },
  137. noise_threshold = 0.3,
  138. },
  139. {name="craw", gain=1.0, miny=3000, maxy=3300, time="day" , indoors=false, },
  140. {name="hornedowl", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, },
  141. -- Owl in Overworld.
  142. {
  143. name="owl", gain=1.0, miny=-10, maxy=1000, time="night", indoors=false,
  144. noise_params = {
  145. offset = 0,
  146. scale = 1,
  147. spread = {x=256, y=256, z=256},
  148. seed = 589981,
  149. octaves = 2,
  150. persist = 0.5,
  151. lacunarity = 1.5,
  152. flags = "",
  153. },
  154. noise_threshold = 0.5,
  155. },
  156. -- Owl in Channelwood.
  157. {
  158. name="owl", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false,
  159. noise_params = {
  160. offset = 0,
  161. scale = 1,
  162. spread = {x=256, y=256, z=256},
  163. seed = 2819294,
  164. octaves = 2,
  165. persist = 0.5,
  166. lacunarity = 1.5,
  167. flags = "",
  168. },
  169. noise_threshold = 0.2,
  170. },
  171. -- Continuous lava rumble in the nether.
  172. {name="lava", gain=0.8, miny=-31000, maxy=-25000, time="", indoors=nil, mintime=7, maxtime=7, },
  173. -- More animal sounds. These should play with less frequency.
  174. -- Only in Channelwood. Overworld nature bird/insect sounds use sound-beacons (due to scarcity of trees/water).
  175. {name="cricket", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=10, maxtime=30, },
  176. {name="jungle_night_1", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=10, maxtime=30, },
  177. {name="cardinal", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, mintime=20, maxtime=60, },
  178. {name="crestedlark", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, mintime=20, maxtime=60, },
  179. {name="deer", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=20, maxtime=120, },
  180. {name="frog", gain=0.7, miny=3000, maxy=3300, time="liminal", indoors=false, },
  181. {name="robin", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, },
  182. {name="bluejay", gain=1.0, miny=3000, maxy=3300, time="liminal", indoors=false, },
  183. {name="gull", gain=1.0, miny=3000, maxy=3300, time="day", indoors=false, },
  184. {name="peacock", gain=1.0, miny=3000, maxy=3300, time="liminal", indoors=false, },
  185. {
  186. name="canadianloon1", gain=1.0, miny=3000, maxy=3300, time="night", indoors=false, mintime=120, maxtime=360,
  187. noise_params = {
  188. offset = 0,
  189. scale = 1,
  190. spread = {x=256, y=256, z=256},
  191. seed = 6582929,
  192. octaves = 2,
  193. persist = 0.5,
  194. lacunarity = 1.5,
  195. flags = "",
  196. },
  197. noise_threshold = 0.3,
  198. },
  199. -- Rare deep cave sounds.
  200. {
  201. name="obsidianmonster_obsidianmonster", gain=1.0, miny=-31000, maxy=-128, time="", indoors=false, mintime=280, maxtime=560,
  202. noise_params = {
  203. offset = 0,
  204. scale = 1,
  205. spread = {x=256, y=256, z=256},
  206. seed = 589731,
  207. octaves = 2,
  208. persist = 0.5,
  209. lacunarity = 1.5,
  210. flags = "",
  211. },
  212. noise_threshold = 0.3,
  213. },
  214. {
  215. name="mobs_sandmonster", gain=1.0, miny=-31000, maxy=-128, time="", indoors=false, mintime=280, maxtime=560,
  216. noise_params = {
  217. offset = 0,
  218. scale = 1,
  219. spread = {x=256, y=256, z=256},
  220. seed = 57187382,
  221. octaves = 2,
  222. persist = 0.5,
  223. lacunarity = 1.5,
  224. flags = "",
  225. },
  226. noise_threshold = 0.3,
  227. },
  228. {
  229. name="mobs_spider", gain=1.0, miny=-31000, maxy=-128, time="", indoors=false, mintime=280, maxtime=560,
  230. noise_params = {
  231. offset = 0,
  232. scale = 1,
  233. spread = {x=256, y=256, z=256},
  234. seed = 5672824,
  235. octaves = 2,
  236. persist = 0.5,
  237. lacunarity = 1.5,
  238. flags = "",
  239. },
  240. noise_threshold = 0.3,
  241. },
  242. -- Nether yuck.
  243. {
  244. name="nether_extract_blood", gain=1.0, miny=-31000, maxy=-20000, time="", indoors=false, mintime=280, maxtime=860,
  245. noise_params = {
  246. offset = 0,
  247. scale = 1,
  248. spread = {x=256, y=256, z=256},
  249. seed = 282934,
  250. octaves = 2,
  251. persist = 0.5,
  252. lacunarity = 1.5,
  253. flags = "",
  254. },
  255. noise_threshold = 0.3,
  256. },
  257. -- Continuous wind on Jarkati surface.
  258. {name="wind1", gain=1.5, miny=3735, maxy=3900, time="", indoors=false, mintime=20, maxtime=40, },
  259. {name="wind2", gain=1.5, miny=3735, maxy=3900, time="", indoors=false, mintime=20, maxtime=40, },
  260. {name="desertwind", gain=1.5, miny=3735, maxy=3900, time="", indoors=false, mintime=20, maxtime=40, },
  261. {name="desertwind", mingain=0.2, maxgain=0.4, miny=3735, maxy=3900, time="", indoors=nil,mintime=6, maxtime=8, }, -- Continuous quiet loop.
  262. -- Continuous wind in the Outback.
  263. {name="wind1", gain=1.0, miny=4160, maxy=4200, time="", indoors=nil, mintime=20, maxtime=40, },
  264. {name="wind2", gain=1.0, miny=4160, maxy=4200, time="", indoors=nil, mintime=20, maxtime=40, },
  265. {name="desertwind", gain=1.0, miny=4160, maxy=4200, time="", indoors=nil, mintime=20, maxtime=40, },
  266. {name="desertwind", mingain=0.2, maxgain=0.4, miny=4160, maxy=4200, time="", indoors=nil,mintime=6, maxtime=8, }, -- Continuous quiet loop.
  267. -- Nighttime insects.
  268. {name="night_cicadas", mingain=0.2, maxgain=1.0, miny=4160, maxy=4200, time="night", indoors=nil,mintime=7, maxtime=11, }, -- Continuous quiet loop.
  269. {name="wolves", mingain=0.2, maxgain=1.3, miny=4160, maxy=4200, time="night", indoors=nil, mintime=20, maxtime=60, },
  270. {name="coyote", mingain=0.2, maxgain=1.3, miny=4160, maxy=4200, time="night", indoors=nil, mintime=10, maxtime=30, },
  271. }
  272. -- Initialize extra table parameters.
  273. minetest.after(0, function()
  274. for k, v in ipairs(ambiance.tmpsounds) do
  275. -- Mintime & maxtime are the min and max seconds a sound can play again after it has played.
  276. -- The timer is reset to a new random value between min and max every time the sound plays.
  277. v.mintime = v.mintime or 30
  278. v.maxtime = v.maxtime or 120
  279. if v.mintime < 0 then v.mintime = 0 end
  280. if v.maxtime < v.mintime then v.maxtime = v.mintime end
  281. -- If minimum or maximum gain are not specified, calculate min and max gain.
  282. v.mingain = v.mingain or (v.gain - 0.5)
  283. v.maxgain = v.maxgain or (v.gain + 0.1)
  284. if v.mingain < 0 then v.mingain = 0 end
  285. if v.maxgain < v.mingain then v.maxgain = v.mingain end
  286. -- Initialize timer to a random value between min and max time.
  287. -- This ensures all sounds start with random times on first run.
  288. v.timer = math.random(v.mintime, v.maxtime)
  289. -- Create perlin noise object if wanted.
  290. if v.noise_params then
  291. if v.include_world_seed then
  292. v.perlin = minetest.get_perlin(v.noise_params)
  293. assert(v.perlin)
  294. else
  295. v.perlin = PerlinNoise(v.noise_params)
  296. assert(v.perlin)
  297. end
  298. assert(v.perlin)
  299. end
  300. v.noise_threshold = v.noise_threshold or 0
  301. end
  302. ambiance.allsounds = ambiance.tmpsounds
  303. ambiance.tmpsounds = nil
  304. end)
  305. -- Lava & scuba sounds (or any special sound) must be handled differently.