mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2025-02-03 05:50:26 +01:00
add rare big webs to the chasms, to give them a unique feature
This commit is contained in:
parent
d2b5443a25
commit
c6f26e5bec
24
big_webs/LICENSE.txt
Normal file
24
big_webs/LICENSE.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Sounds and textures are under various licenses, see the license.txt file in the /sounds and /textures directories for details.
|
||||
|
||||
License for Code
|
||||
----------------
|
||||
|
||||
Copyright (C) 2021 FaceDeer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
110
big_webs/init.lua
Normal file
110
big_webs/init.lua
Normal file
@ -0,0 +1,110 @@
|
||||
local modname = minetest.get_current_modname()
|
||||
local S = minetest.get_translator(modname)
|
||||
|
||||
local default_path = minetest.get_modpath("default")
|
||||
|
||||
local get_node_box = function(connector_thickness)
|
||||
return {
|
||||
type = "connected",
|
||||
--fixed = {-hub_thickness,-hub_thickness,-hub_thickness,hub_thickness,hub_thickness,hub_thickness},
|
||||
connect_top = {-connector_thickness, 0, -connector_thickness, connector_thickness, 0.5, connector_thickness},
|
||||
connect_bottom = {-connector_thickness, -0.5, -connector_thickness, connector_thickness, 0, connector_thickness},
|
||||
connect_back = {-connector_thickness, -connector_thickness, 0, connector_thickness, connector_thickness, 0.5},
|
||||
connect_right = {0, -connector_thickness, -connector_thickness, 0.5, connector_thickness, connector_thickness},
|
||||
connect_front = {-connector_thickness, -connector_thickness, -0.5, connector_thickness, connector_thickness, 0},
|
||||
connect_left = {-0.5, -connector_thickness, -connector_thickness, 0, connector_thickness, connector_thickness},
|
||||
disconnected = {-connector_thickness, -connector_thickness, -connector_thickness, connector_thickness, connector_thickness, connector_thickness},
|
||||
}
|
||||
end
|
||||
|
||||
local in_anchor_group = function(name)
|
||||
return
|
||||
minetest.get_item_group(name, "soil") > 0 or
|
||||
minetest.get_item_group(name, "stone") > 0 or
|
||||
minetest.get_item_group(name, "tree") > 0 or
|
||||
minetest.get_item_group(name, "leaves") > 0 or
|
||||
minetest.get_item_group(name, "sand") > 0 or
|
||||
minetest.get_item_group(name, "wood") > 0
|
||||
end
|
||||
|
||||
local cardinal_directions = {
|
||||
{x=1,y=0,z=0},
|
||||
{x=-1,y=0,z=0},
|
||||
{x=0,y=1,z=0},
|
||||
{x=0,y=1,z=0},
|
||||
{x=0,y=0,z=1},
|
||||
{x=0,y=0,z=-1}
|
||||
}
|
||||
|
||||
local insert_if_not_in_hashtable = function(pos, insert_into, if_not_in)
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
if if_not_in[hash] then
|
||||
return
|
||||
end
|
||||
table.insert(insert_into, pos)
|
||||
end
|
||||
|
||||
-- flood fill through the web to get all web and anchor locations
|
||||
local get_web_nodes = function(pos, webs, anchors)
|
||||
local to_check = {}
|
||||
table.insert(to_check, pos)
|
||||
while next(to_check) ~= nil do
|
||||
local check_pos = table.remove(to_check)
|
||||
local check_node = minetest.get_node(check_pos)
|
||||
if minetest.get_item_group(check_node.name, "webbing") > 0 then
|
||||
webs[minetest.hash_node_position(check_pos)] = true
|
||||
for _, dir in pairs(cardinal_directions) do
|
||||
insert_if_not_in_hashtable(vector.add(check_pos, dir), to_check, webs)
|
||||
end
|
||||
elseif in_anchor_group(check_node.name) then
|
||||
anchors[minetest.hash_node_position(check_pos)] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local sound
|
||||
if default_path then
|
||||
sound = default.node_sound_leaves_defaults()
|
||||
end
|
||||
|
||||
minetest.register_node("big_webs:webbing", {
|
||||
description = S("Big Spiderweb"),
|
||||
_doc_items_longdesc = S("Thick ropes of sticky silk, strung between cavern walls in hopes of catching bats and larger beasts."),
|
||||
_doc_items_usagehelp = S("Webbing can be collected and re-strung elsewhere to aid in climbing."),
|
||||
tiles = {
|
||||
{name="big_webs.png"},
|
||||
},
|
||||
use_texture_alpha = "blend",
|
||||
connects_to = {"group:soil", "group:stone", "group:tree", "group:leaves", "group:sand", "group:wood", "group:webbing"},
|
||||
connect_sides = { "top", "bottom", "front", "left", "back", "right" },
|
||||
drawtype = "nodebox",
|
||||
node_box = get_node_box(0.0625),
|
||||
collision_box = get_node_box(0.0625),
|
||||
paramtype = "light",
|
||||
--light_source = 2,
|
||||
is_ground_content = false,
|
||||
climbable = true,
|
||||
walkable = false,
|
||||
floodable = true,
|
||||
groups = {choppy = 2, webbing = 1, flammable=1},
|
||||
sounds = sound,
|
||||
on_timer = function(pos, elapsed)
|
||||
local webs = {}
|
||||
local anchors = {}
|
||||
get_web_nodes(pos, webs, anchors)
|
||||
local first_anchor = next(anchors)
|
||||
-- if first_anchor then
|
||||
-- minetest.chat_send_all("supported")
|
||||
-- else
|
||||
-- minetest.chat_send_all("unsupported")
|
||||
-- end
|
||||
for hash, _ in pairs(webs) do
|
||||
local web_pos = minetest.get_position_from_hash(hash)
|
||||
if first_anchor == nil then
|
||||
-- unsupported web
|
||||
minetest.set_node(web_pos, {name="air"})
|
||||
end
|
||||
minetest.get_node_timer(web_pos):stop() -- no need to recheck
|
||||
end
|
||||
end,
|
||||
})
|
11
big_webs/locale/template.txt
Normal file
11
big_webs/locale/template.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# textdomain: big_webs
|
||||
|
||||
|
||||
### init.lua ###
|
||||
|
||||
Big Spiderweb=
|
||||
|
||||
Thick ropes of sticky silk, strung between cavern walls in hopes of catching bats and larger beasts.=
|
||||
|
||||
Webbing can be collected and re-strung elsewhere to aid in climbing.=
|
||||
|
2
big_webs/mod.conf
Normal file
2
big_webs/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name=big_webs
|
||||
optional_depends=default
|
BIN
big_webs/textures/big_webs.png
Normal file
BIN
big_webs/textures/big_webs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 309 B |
@ -4,6 +4,8 @@ local maxy = tonumber(minetest.settings:get("chasms_maxy")) or -50
|
||||
local miny = tonumber(minetest.settings:get("chasms_miny")) or -2500
|
||||
local falloff = tonumber(minetest.settings:get("chasms_falloff")) or 100
|
||||
|
||||
local web_probability = 0.1 -- the chance that a given mapblock will have webbing criss-crossing the chasm
|
||||
|
||||
local chasms_threshold = tonumber(minetest.settings:get("chasms_threshold")) or 0.9
|
||||
local np_chasms_default = {
|
||||
offset = 0,
|
||||
@ -61,12 +63,44 @@ local get_intensity = function(y)
|
||||
end
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_web
|
||||
|
||||
local big_webs_path = minetest.get_modpath("big_webs")
|
||||
if big_webs_path then
|
||||
c_web = minetest.get_content_id("big_webs:webbing")
|
||||
end
|
||||
|
||||
local z_displace = 10000
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if minp.y >= maxy or maxp.y <= miny then
|
||||
return
|
||||
end
|
||||
|
||||
-- build a set of web patterns
|
||||
local webs
|
||||
if big_webs_path then
|
||||
local seed = math.random()*10000000
|
||||
math.randomseed(minp.y + z_displace*minp.z) -- use consistent seeds across the x axis
|
||||
if math.random() < web_probability then
|
||||
webs = {}
|
||||
for count = 1, math.random(10,30) do
|
||||
local width = math.random(5, 20)
|
||||
local direction_vertical = math.random() > 0.5
|
||||
local web_y = math.random(minp.y+8, maxp.y-8)
|
||||
local web_z = math.random(minp.z+8, maxp.z-8)
|
||||
for i = -math.floor(width/2), math.ceil(width/2) do
|
||||
if direction_vertical then
|
||||
webs[(web_y+i) + web_z*z_displace] = true
|
||||
else
|
||||
webs[web_y + (web_z+i)*z_displace] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
math.randomseed(seed)
|
||||
end
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
vm:get_data(data)
|
||||
|
||||
@ -83,9 +117,19 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local waver = math.min(math.max(math.floor(waver_data[i]+0.5), -waver_strength), waver_strength)
|
||||
local intensity = get_intensity(y)
|
||||
if chasm_data[chasm_area:index(x+waver, y, z)]*intensity > chasms_threshold then
|
||||
if webs then
|
||||
if webs[y + z*z_displace] and math.random() < 0.85 then -- random holes in the web
|
||||
data[i] = c_web
|
||||
minetest.get_node_timer({x=x,y=y,z=z}):start(1) -- this timer will check for unsupported webs
|
||||
else
|
||||
data[i] = c_air
|
||||
end
|
||||
else
|
||||
data[i] = c_air
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:calc_lighting()
|
||||
vm:write_to_map()
|
||||
|
@ -1,3 +1,3 @@
|
||||
name=chasms
|
||||
depends=mapgen_helper
|
||||
optional_depends=df_caverns
|
||||
optional_depends=df_caverns, big_webs
|
Loading…
Reference in New Issue
Block a user