mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2024-12-26 02:40:36 +01:00
import radiant_damage code to handle different height snareweed nodes
This commit is contained in:
parent
bf2c15258f
commit
11f566fc1f
@ -65,6 +65,8 @@ end
|
|||||||
setting("float", "glow_worm_delay_multiplier", 10.0, "glow worm growth delay multiplier")
|
setting("float", "glow_worm_delay_multiplier", 10.0, "glow worm growth delay multiplier")
|
||||||
setting("bool", "light_kills_fungus", true, "Light kills fungus")
|
setting("bool", "light_kills_fungus", true, "Light kills fungus")
|
||||||
|
|
||||||
|
setting("bool", "snareweed_damage", true, "Snareweed causes damage to players")
|
||||||
|
|
||||||
--Caverns
|
--Caverns
|
||||||
|
|
||||||
setting("float", "vertical_cavern_scale", 256, "Vertical cavern dimension scale")
|
setting("float", "vertical_cavern_scale", 256, "Vertical cavern dimension scale")
|
||||||
|
@ -8,5 +8,4 @@ wool?
|
|||||||
magma_conduits?
|
magma_conduits?
|
||||||
intllib?
|
intllib?
|
||||||
doc?
|
doc?
|
||||||
simplecrafting_lib?
|
simplecrafting_lib?
|
||||||
radiant_damage?
|
|
@ -17,18 +17,29 @@ minetest.register_node("dfcaverns:snareweed", {
|
|||||||
sounds = default.node_sound_dirt_defaults(),
|
sounds = default.node_sound_dirt_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if minetest.get_modpath("radiant_damage") then
|
if dfcaverns.config.snareweed_damage then
|
||||||
radiant_damage.register_radiant_damage({
|
local timer = 0
|
||||||
damage_name = "snareweed", -- a string used in logs to identify the type of damage dealt
|
|
||||||
interval = 1, -- number of seconds between each damage check
|
minetest.register_globalstep(function(dtime)
|
||||||
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.
|
timer = timer + dtime
|
||||||
inverse_square_falloff = false, -- if true, damage falls off with the inverse square of the distance. If false, damage is constant within the range.
|
if timer >= 1 then
|
||||||
damage = 2, -- number of damage points dealt each interval
|
timer = timer - 1
|
||||||
nodenames = {"dfcaverns:snareweed"}, -- nodes that cause this damage. Same format as the nodenames parameter for minetest.find_nodes_in_area
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
occlusion = false, -- if true, damaging effect only passes through air. Other nodes will cast "shadows".
|
local player_pos = player:getpos() -- node player's feet are in this location.
|
||||||
above_only = true, -- if true, damage only propagates directly upward.
|
local rounded_pos = vector.round(player_pos)
|
||||||
cumulative = false, -- if true, all nodes within range do damage. If false, only the nearest one does damage.
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -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.
|
#To disable glow worm growth, set this to 0.
|
||||||
dfcaverns_glow_worm_delay_multiplier (glow worm growth delay multiplier) float 10
|
dfcaverns_glow_worm_delay_multiplier (glow worm growth delay multiplier) float 10
|
||||||
dfcaverns_light_kills_fungus (Light kills fungus) bool true
|
dfcaverns_light_kills_fungus (Light kills fungus) bool true
|
||||||
|
dfcaverns_snareweed_damage (Snareweed causes damage to player) bool true
|
||||||
|
|
||||||
[Cavern dimensions]
|
[Cavern dimensions]
|
||||||
#Note that this doesn't guarantee caverns of this setting's size. This setting
|
#Note that this doesn't guarantee caverns of this setting's size. This setting
|
||||||
|
Loading…
Reference in New Issue
Block a user