Improve sound experience
- Zip sounds are more pronounced - Scatter zip sounds along path for 3rd party observers - Add subtle hum to waiting ziprunes.
This commit is contained in:
parent
a4df67be69
commit
8793ff2cc0
33
init.lua
33
init.lua
@ -3,8 +3,8 @@ local math, minetest, nodecore, pairs, rawset, string, table, tonumber,
|
||||
vector
|
||||
= math, minetest, nodecore, pairs, rawset, string, table, tonumber,
|
||||
vector
|
||||
local math_abs, string_format, table_remove, table_sort
|
||||
= math.abs, string.format, table.remove, table.sort
|
||||
local math_abs, math_random, string_format, table_remove, table_sort
|
||||
= math.abs, math.random, string.format, table.remove, table.sort
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -133,15 +133,16 @@ local function dsqr(a, b)
|
||||
return vector.dot(v, v)
|
||||
end
|
||||
|
||||
local function playercheck(player)
|
||||
local vel = player:get_player_velocity()
|
||||
if vector.dot(vel, vel) > 0.1 then return end
|
||||
|
||||
local function playercheck(player, stepdata)
|
||||
local ctl = player:get_player_control()
|
||||
if ctl.sneak or ctl.jump or ctl.up or ctl.down or ctl.left or ctl.right then return end
|
||||
|
||||
local data = zipdata_get(player)
|
||||
if not data.pos then return end
|
||||
stepdata.properties.makes_footstep_sound = false
|
||||
|
||||
local vel = player:get_player_velocity()
|
||||
if vector.dot(vel, vel) > 0.1 then return end
|
||||
|
||||
local pos = vector.round(player:get_pos())
|
||||
if not inrange(pos, data.pos) then
|
||||
@ -176,11 +177,18 @@ local function playercheck(player)
|
||||
nodecore.log("action", string_format("%s: %s zips from %s to %s",
|
||||
modname, player:get_player_name(), minetest.pos_to_string(pos),
|
||||
minetest.pos_to_string(hit)))
|
||||
local backdir = vector.direction(hit, pos)
|
||||
for i = 0, vector.distance(pos, hit), 4 do
|
||||
local spos = vector.add(hit, vector.multiply(backdir, i))
|
||||
spos.x = spos.x + math_random() - 0.5
|
||||
spos.y = spos.y + math_random() - 0.5
|
||||
spos.z = spos.z + math_random() - 0.5
|
||||
nodecore.sound_play(modname .. "_zip", {pos = spos})
|
||||
end
|
||||
data.oldpos = appendpos(data.oldpos or {}, data.pos)
|
||||
data.pos = hit
|
||||
zipdata_set(player, data)
|
||||
player:set_pos({x = hit.x, y = hit.y - 0.49, z = hit.z})
|
||||
nodecore.sound_play(modname .. "_zip", {pos = hit})
|
||||
return sparkly(p, hit)
|
||||
end
|
||||
end
|
||||
@ -188,11 +196,11 @@ local function playercheck(player)
|
||||
energized(pos)
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
playercheck(player)
|
||||
end
|
||||
end)
|
||||
nodecore.register_playerstep({
|
||||
label = "ziprune check",
|
||||
priority = -100,
|
||||
action = playercheck
|
||||
})
|
||||
|
||||
local powernodes = {}
|
||||
for i = minpower, 8 do powernodes["nc_lux:cobble" .. i] = true end
|
||||
@ -230,6 +238,7 @@ nodecore.register_dnt({
|
||||
if not isziprune(pos, node) then return end
|
||||
|
||||
nodecore.dnt_set(pos, modname)
|
||||
nodecore.sound_play(modname .. "_hum", {pos = pos, gain = 0.25})
|
||||
minetest.add_particlespawner({
|
||||
amount = 20,
|
||||
time = 1,
|
||||
|
BIN
sounds/nc_ziprunes_hum.0.ogg
Normal file
BIN
sounds/nc_ziprunes_hum.0.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user