From e0b3b023b07ad7d424f0f40efb916ae62a1d548c Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sun, 1 Dec 2019 18:30:29 -0700 Subject: [PATCH] add a small bit of anti-griefing - the seal breach bell only tolls globally 13 times per activation --- df_caverns/underworld.lua | 2 +- df_underworld_items/puzzle_seal.lua | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/df_caverns/underworld.lua b/df_caverns/underworld.lua index 6f8d3fe..5ad4458 100644 --- a/df_caverns/underworld.lua +++ b/df_caverns/underworld.lua @@ -397,7 +397,7 @@ minetest.register_on_generated(function(minp, maxp, seed) -- puzzle seal local puzzle_seal = nil - if pit_uninitialized and math.random() < 0.025 then + if pit_uninitialized and math.random() < 0.1 then local index2d = mapgen_helper.index2d(emin, emax, minp.x + 3, minp.z + 3) local abs_cave = math.abs(nvals_cave[index2d]) -- range is from 0 to approximately 2, with 0 being connected and 2s being islands local wave = nvals_wave[index2d] * wave_mult diff --git a/df_underworld_items/puzzle_seal.lua b/df_underworld_items/puzzle_seal.lua index c14e558..f69c41c 100644 --- a/df_underworld_items/puzzle_seal.lua +++ b/df_underworld_items/puzzle_seal.lua @@ -58,7 +58,10 @@ local test_key = function(pos) end end if valid then - meta:set_int("unlocked", 1) + local unlocked = meta:get_int("unlocked") + if unlocked == 0 then + meta:set_int("unlocked", 1) + end return true end end @@ -105,7 +108,7 @@ local show_key = function(pos, index) minetest.sound_play("dfcaverns_seal_key", { pos = pos, gain = 0.125, - max_hear_distance = 16, + max_hear_distance = 32, }) local meta = minetest.get_meta(pos) local keystring = meta:get_string("key") @@ -131,12 +134,13 @@ local show_key = function(pos, index) }) end -local show_unlocked = function(pos) +local show_unlocked = function(pos, global) -- Plays globally. This is deliberate. - minetest.sound_play("dfcaverns_seal_unlocked", { - gain = 1.0, - pitch = 1.0, - }) + if global then + minetest.sound_play("dfcaverns_seal_unlocked", {}) + else + minetest.sound_play("dfcaverns_seal_unlocked", {pos = pos, max_hear_distance = 128,}) + end minetest.add_particle({ pos = pos, velocity = {x=0, y=1, z=0}, @@ -180,8 +184,10 @@ local puzzle_seal_def = { end, on_timer = function(pos, elapsed) local meta = minetest.get_meta(pos) - if meta:get_int("unlocked") > 0 then - show_unlocked(pos) + local unlocked = meta:get_int("unlocked") + if unlocked > 0 then + meta:set_int("unlocked", unlocked + 1) + show_unlocked(pos, unlocked <= 13) else local index = meta:get_int("key_index") show_key(pos, index)