diff --git a/license.txt b/license.txt index 9bab5bc..ee664ab 100644 --- a/license.txt +++ b/license.txt @@ -86,3 +86,5 @@ Desert Simple.wav, Creative Commons 0 License, Proxima4, http://www.freesound.or http://www.freesfx.co.uk/soundeffects/forests-jungles/ icecrack.ogg by ecfike, Creative Commons 0 license (https://freesound.org/people/ecfike/sounds/177212/) + +big_splash.ogg by gubodup, Creative Commons 0 License (https://freesound.org/people/qubodup/sounds/442773/) diff --git a/settingtypes.txt b/settingtypes.txt index fafa529..3d5abf3 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -3,3 +3,5 @@ ambience_music (Ambience music) bool true # If enabled then ambience will take over sounds when moving in water ambience_water_move (Ambience water movement) bool true + +ambience_water_splash (Big splash when jumping in water) bool false diff --git a/sounds/big_splash.ogg b/sounds/big_splash.ogg new file mode 100644 index 0000000..600abf5 Binary files /dev/null and b/sounds/big_splash.ogg differ diff --git a/soundsets.lua b/soundsets.lua index 713f2f1..b3e34f6 100644 --- a/soundsets.lua +++ b/soundsets.lua @@ -11,6 +11,51 @@ local mod_def = core.get_modpath("default") local mod_mcl = core.get_modpath("mcl_core") +-- Big Splash jumping in water + +if core.settings:get_bool("ambience_water_splash") == true then + + local in_water = {} + + ambience.add_set("big_splash", { + + frequency = 1000, + + sounds = { + {name = "big_splash", gain = 0.3, length = 4, ephemeral = true} + }, + + sound_check = function(def) + + local hdef = core.registered_nodes[def.head_node] + local fdef = core.registered_nodes[def.feet_node] + local name = def.player:get_player_name() + local vel + + if core.has_feature("direct_velocity_on_players") then + vel = def.player:get_velocity() + else + vel = def.player:get_player_velocity() + end + + if hdef and hdef.groups and hdef.groups.water + and fdef and fdef.groups and fdef.groups.water then + + if not in_water[name] and vel.y < -0.15 then + in_water[name] = 2 + return "big_splash" + end + else + if fdef and fdef.groups and fdef.groups.water then + in_water[name] = 1 + else + in_water[name] = nil + end + end + end + }) +end + -- Underwater sounds play when player head is submerged ambience.add_set("underwater", {