import radiant_damage code to handle different height snareweed nodes

This commit is contained in:
FaceDeer 2018-05-26 22:14:09 -06:00
parent bf2c15258f
commit 11f566fc1f
4 changed files with 27 additions and 14 deletions

View File

@ -65,6 +65,8 @@ end
setting("float", "glow_worm_delay_multiplier", 10.0, "glow worm growth delay multiplier")
setting("bool", "light_kills_fungus", true, "Light kills fungus")
setting("bool", "snareweed_damage", true, "Snareweed causes damage to players")
--Caverns
setting("float", "vertical_cavern_scale", 256, "Vertical cavern dimension scale")

View File

@ -8,5 +8,4 @@ wool?
magma_conduits?
intllib?
doc?
simplecrafting_lib?
radiant_damage?
simplecrafting_lib?

View File

@ -17,18 +17,29 @@ minetest.register_node("dfcaverns:snareweed", {
sounds = default.node_sound_dirt_defaults(),
})
if minetest.get_modpath("radiant_damage") then
radiant_damage.register_radiant_damage({
damage_name = "snareweed", -- a string used in logs to identify the type of damage dealt
interval = 1, -- number of seconds between each damage check
range = 5, -- range of the damage. Can be omitted if inverse_square_falloff is true, in that case it defaults to the range at which 1 point of damage is done.
inverse_square_falloff = false, -- if true, damage falls off with the inverse square of the distance. If false, damage is constant within the range.
damage = 2, -- number of damage points dealt each interval
nodenames = {"dfcaverns:snareweed"}, -- nodes that cause this damage. Same format as the nodenames parameter for minetest.find_nodes_in_area
occlusion = false, -- if true, damaging effect only passes through air. Other nodes will cast "shadows".
above_only = true, -- if true, damage only propagates directly upward.
cumulative = false, -- if true, all nodes within range do damage. If false, only the nearest one does damage.
})
if dfcaverns.config.snareweed_damage then
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 1 then
timer = timer - 1
for _, player in pairs(minetest.get_connected_players()) do
local player_pos = player:getpos() -- node player's feet are in this location.
local rounded_pos = vector.round(player_pos)
nearby_nodes = minetest.find_nodes_in_area(vector.add(rounded_pos, {x=0, y= -8, z=0}), rounded_pos, {"dfcaverns:snareweed"})
for _, node_pos in ipairs(nearby_nodes) do
local node = minetest.get_node(node_pos)
local distance = player_pos.y - node_pos.y
if distance <= node.param2/16 then
minetest.log("action", player:get_player_name() .. " takes 2 damage from snareweed")
player:set_hp(player:get_hp() - 2)
break
end
end
end
end
end)
end

View File

@ -22,6 +22,7 @@ dfcaverns_sweet_pod_delay_multiplier (sweet_pod growth delay multiplier) float 2
#To disable glow worm growth, set this to 0.
dfcaverns_glow_worm_delay_multiplier (glow worm growth delay multiplier) float 10
dfcaverns_light_kills_fungus (Light kills fungus) bool true
dfcaverns_snareweed_damage (Snareweed causes damage to player) bool true
[Cavern dimensions]
#Note that this doesn't guarantee caverns of this setting's size. This setting