mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 16:39:33 +01:00
Better lingering for lingering water bottle
This commit is contained in:
parent
9c304105e9
commit
ff476c29b6
3 changed files with 31 additions and 17 deletions
|
@ -748,26 +748,40 @@ function mcl_potions.night_vision_func(player, null, duration)
|
|||
|
||||
end
|
||||
|
||||
function mcl_potions._extinguish_nearby_fire(pos)
|
||||
function mcl_potions._extinguish_nearby_fire(pos, radius)
|
||||
local epos = {x=pos.x, y=pos.y+0.5, z=pos.z}
|
||||
local dnode = minetest.get_node({x=pos.x,y=pos.y-0.5,z=pos.z})
|
||||
if minetest.get_item_group(dnode.name, "fire") ~= 0 then
|
||||
epos.y = pos.y - 0.5
|
||||
end
|
||||
local dirs = {
|
||||
{x=0,y=0,z=0},
|
||||
{x=0,y=0,z=-1},
|
||||
{x=0,y=0,z=1},
|
||||
{x=-1,y=0,z=0},
|
||||
{x=1,y=0,z=0},
|
||||
}
|
||||
local exting = false
|
||||
for d=1, #dirs do
|
||||
local tpos = vector.add(epos, dirs[d])
|
||||
local node = minetest.get_node(tpos)
|
||||
if minetest.get_item_group(node.name, "fire") ~= 0 then
|
||||
minetest.sound_play("fire_extinguish_flame", {pos = tpos, gain = 0.25, max_hear_distance = 16}, true)
|
||||
minetest.remove_node(tpos)
|
||||
-- No radius: Splash, extinguish epos and 4 nodes around
|
||||
if not radius then
|
||||
local dirs = {
|
||||
{x=0,y=0,z=0},
|
||||
{x=0,y=0,z=-1},
|
||||
{x=0,y=0,z=1},
|
||||
{x=-1,y=0,z=0},
|
||||
{x=1,y=0,z=0},
|
||||
}
|
||||
for d=1, #dirs do
|
||||
local tpos = vector.add(epos, dirs[d])
|
||||
local node = minetest.get_node(tpos)
|
||||
if minetest.get_item_group(node.name, "fire") ~= 0 then
|
||||
minetest.sound_play("fire_extinguish_flame", {pos = tpos, gain = 0.25, max_hear_distance = 16}, true)
|
||||
minetest.remove_node(tpos)
|
||||
exting = true
|
||||
end
|
||||
end
|
||||
-- Has radius: lingering, extinguish all nodes in area
|
||||
else
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=epos.x-radius,y=epos.y,z=epos.z-radius},
|
||||
{x=epos.x+radius,y=epos.y,z=epos.z+radius},
|
||||
{"group:fire"})
|
||||
for n=1, #nodes do
|
||||
minetest.sound_play("fire_extinguish_flame", {pos = nodes[n], gain = 0.25, max_hear_distance = 16}, true)
|
||||
minetest.remove_node(nodes[n])
|
||||
exting = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -304,7 +304,7 @@ mcl_potions.register_splash("water", S("Splash Water Bottle"), "#0022FF", {
|
|||
})
|
||||
mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", {
|
||||
tt=S("Extinguishes fire and hurts some mobs"),
|
||||
longdesc=S("A throwable water bottle that will shatter on impact, where it extinguishes nearby fire and hurts mobs that are vulnerable to water."),
|
||||
longdesc=S("A throwable water bottle that will shatter on impact, where it creates a cloud of water vapor that lingers on the ground for a while. This cloud extinguishes fire and hurts mobs that are vulnerable to water."),
|
||||
no_effect=true,
|
||||
potion_fun=water_splash,
|
||||
effect=1
|
||||
|
|
|
@ -53,7 +53,7 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
-- Extinguish fire if water bottle
|
||||
if vals.is_water then
|
||||
if mcl_potions._extinguish_nearby_fire(pos) then
|
||||
if mcl_potions._extinguish_nearby_fire(pos, d) then
|
||||
vals.timer = vals.timer / 2
|
||||
end
|
||||
end
|
||||
|
@ -162,7 +162,7 @@ function mcl_potions.register_lingering(name, descr, color, def)
|
|||
texture = texture.."^[colorize:"..color..":127",
|
||||
})
|
||||
if name == "water" then
|
||||
mcl_potions._extinguish_nearby_fire(pos)
|
||||
mcl_potions._extinguish_nearby_fire(pos, d)
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue