forked from mtcontrib/ambience
.28 waves trump sloshing water, walking in water Splash not swim sound
.28 Major reorg of water code. Also waves trump sloshing water, walking in water Splash not swim sound
This commit is contained in:
parent
5d0bb2a72e
commit
26bbeace26
BIN
ambience.zip
BIN
ambience.zip
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
--------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------
|
||||||
--Ambiance Configuration for version .27
|
--Ambiance Configuration for version .28
|
||||||
--Fixed removed occasional beach wave sound when treading water
|
--working on treading water already trumps beach, standing in water should not.
|
||||||
-- was caused by the bottom node we find is air which leads to surface noise!
|
--moving while standing in water should splash not swim.
|
||||||
|
|
||||||
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
|
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
|
||||||
|
|
||||||
@ -38,6 +38,10 @@ local music_volume = 0.3
|
|||||||
local counter=0--*****************
|
local counter=0--*****************
|
||||||
local last_x_pos = 0
|
local last_x_pos = 0
|
||||||
local last_z_pos = 0
|
local last_z_pos = 0
|
||||||
|
local node_under_feet
|
||||||
|
local node_at_upper_body
|
||||||
|
local node_at_lower_body
|
||||||
|
|
||||||
local played_on_start = false
|
local played_on_start = false
|
||||||
local night = {
|
local night = {
|
||||||
handler = {},
|
handler = {},
|
||||||
@ -148,6 +152,11 @@ local water_surface = {
|
|||||||
{name="lake_waves_2_calm", length=9.5},
|
{name="lake_waves_2_calm", length=9.5},
|
||||||
{name="lake_waves_2_variety", length=13.1}
|
{name="lake_waves_2_variety", length=13.1}
|
||||||
}
|
}
|
||||||
|
local splashing_water = {
|
||||||
|
handler = {},
|
||||||
|
frequency = 1000,
|
||||||
|
{name="Splash", length=1.22, gain=1}
|
||||||
|
}
|
||||||
|
|
||||||
local flowing_water = {
|
local flowing_water = {
|
||||||
handler = {},
|
handler = {},
|
||||||
@ -244,39 +253,70 @@ local atleast_nodes_in_grid = function(pos, search_distance, height, node_name,
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local get_immediate_nodes = function(pos)
|
||||||
|
pos.y = pos.y-1
|
||||||
|
node_under_feet = minetest.env:get_node(pos).name
|
||||||
|
pos.y = pos.y+2.2
|
||||||
|
node_at_upper_body = minetest.env:get_node(pos).name
|
||||||
|
pos.y = pos.y-1.19
|
||||||
|
node_at_lower_body = minetest.env:get_node(pos).name
|
||||||
|
pos.y = pos.y+0.99 --1.6
|
||||||
|
--minetest.chat_send_all("node_under_feet(" .. nodename .. ")")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local get_ambience = function(player)
|
local get_ambience = function(player)
|
||||||
|
local player_is_moving = false
|
||||||
|
local standing_in_water = false
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local water_surface_found = false
|
get_immediate_nodes(pos)
|
||||||
pos.y = pos.y+1.2
|
|
||||||
local nodename = minetest.env:get_node(pos).name
|
if last_x_pos ~=pos.x or last_z_pos ~=pos.z then
|
||||||
--minetest.chat_send_all("top nodename found(" .. nodename .. ")")
|
player_is_moving = true
|
||||||
if string.find(nodename, "default:water") then
|
end
|
||||||
|
last_x_pos =pos.x
|
||||||
|
last_z_pos =pos.z
|
||||||
|
|
||||||
|
if string.find(node_at_upper_body, "default:water") then
|
||||||
if music then
|
if music then
|
||||||
return {water=water, water_frequent=water_frequent, music=music}
|
return {water=water, water_frequent=water_frequent, music=music}
|
||||||
else
|
else
|
||||||
return {water=water, water_frequent=water_frequent}
|
return {water=water, water_frequent=water_frequent}
|
||||||
end
|
end
|
||||||
elseif nodename == "air" then
|
elseif node_at_upper_body == "air" then
|
||||||
pos.y = pos.y-1.19 --1.8
|
if string.find(node_at_lower_body, "default:water") then
|
||||||
local nodename = minetest.env:get_node(pos).name
|
|
||||||
--minetest.chat_send_all("bottom nodename found(" .. nodename .. ")")
|
|
||||||
pos.y = pos.y+0.99 --1.6
|
|
||||||
if string.find(nodename, "default:water") then
|
|
||||||
--minetest.chat_send_all("bottom counted as water")
|
--minetest.chat_send_all("bottom counted as water")
|
||||||
if last_x_pos ~=pos.x or last_z_pos ~=pos.z then
|
--we found air at upperbody, and water at lower body. Now there are 4 possibilities:
|
||||||
--minetest.chat_send_all("swimming move found")
|
--Key: under feet, moving or not
|
||||||
last_x_pos =pos.x
|
--swimming w, m swimming
|
||||||
last_z_pos =pos.z
|
--walking in water nw, m splashing
|
||||||
if music then
|
--treading water w, nm sloshing
|
||||||
return {swimming_frequent=swimming_frequent, music=music}
|
--standing in water nw, nm beach trumps, then sloshing
|
||||||
else
|
if player_is_moving then
|
||||||
return {swimming_frequent}
|
if string.find(node_under_feet, "default:water") then
|
||||||
end
|
if music then
|
||||||
|
return {swimming_frequent=swimming_frequent, music=music}
|
||||||
|
else
|
||||||
|
return {swimming_frequent}
|
||||||
|
end
|
||||||
|
else --didn't find water under feet: walking in water
|
||||||
|
if music then
|
||||||
|
return {splashing_water=splashing_water, music=music}
|
||||||
|
else
|
||||||
|
return {splashing_water}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else--player is not moving
|
||||||
|
if string.find(node_under_feet, "default:water") then
|
||||||
|
if music then
|
||||||
|
return {water_surface=water_surface, music=music}
|
||||||
|
else
|
||||||
|
return {water_surface}
|
||||||
|
end
|
||||||
|
else --didn't find water under feet
|
||||||
|
standing_in_water = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
last_x_pos =pos.x
|
|
||||||
last_z_pos =pos.z
|
|
||||||
water_surface_found = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -294,13 +334,7 @@ local get_ambience = function(player)
|
|||||||
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
|
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if water_surface_found then
|
|
||||||
if music then
|
|
||||||
return {water_surface=water_surface, music=music}
|
|
||||||
else
|
|
||||||
return {water_surface}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--if we are near sea level and there is lots of water around the area
|
--if we are near sea level and there is lots of water around the area
|
||||||
if pos.y < 7 and pos.y >0 and atleast_nodes_in_grid(pos, 60, 1, "default:water_source", 51 ) then
|
if pos.y < 7 and pos.y >0 and atleast_nodes_in_grid(pos, 60, 1, "default:water_source", 51 ) then
|
||||||
@ -310,7 +344,13 @@ local get_ambience = function(player)
|
|||||||
return {beach=beach, beach_frequent=beach_frequent}
|
return {beach=beach, beach_frequent=beach_frequent}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if standing_in_water then
|
||||||
|
if music then
|
||||||
|
return {water_surface=water_surface, music=music}
|
||||||
|
else
|
||||||
|
return {water_surface}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
desert_in_range = (nodes_in_range(pos, 6, "default:desert_sand")+nodes_in_range(pos, 6, "default:desert_stone"))
|
desert_in_range = (nodes_in_range(pos, 6, "default:desert_sand")+nodes_in_range(pos, 6, "default:desert_stone"))
|
||||||
|
Loading…
Reference in New Issue
Block a user