0
0
Fork 0

Better lingering for lingering water bottle

This commit is contained in:
Wuzzy 2020-08-05 19:44:19 +02:00
parent 9c304105e9
commit ff476c29b6
3 changed files with 31 additions and 17 deletions

View File

@ -748,12 +748,15 @@ function mcl_potions.night_vision_func(player, null, duration)
end 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 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}) 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 if minetest.get_item_group(dnode.name, "fire") ~= 0 then
epos.y = pos.y - 0.5 epos.y = pos.y - 0.5
end end
local exting = false
-- No radius: Splash, extinguish epos and 4 nodes around
if not radius then
local dirs = { local dirs = {
{x=0,y=0,z=0}, {x=0,y=0,z=0},
{x=0,y=0,z=-1}, {x=0,y=0,z=-1},
@ -761,7 +764,6 @@ function mcl_potions._extinguish_nearby_fire(pos)
{x=-1,y=0,z=0}, {x=-1,y=0,z=0},
{x=1,y=0,z=0}, {x=1,y=0,z=0},
} }
local exting = false
for d=1, #dirs do for d=1, #dirs do
local tpos = vector.add(epos, dirs[d]) local tpos = vector.add(epos, dirs[d])
local node = minetest.get_node(tpos) local node = minetest.get_node(tpos)
@ -771,5 +773,17 @@ function mcl_potions._extinguish_nearby_fire(pos)
exting = true exting = true
end end
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
return exting return exting
end end

View File

@ -304,7 +304,7 @@ mcl_potions.register_splash("water", S("Splash Water Bottle"), "#0022FF", {
}) })
mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", { mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", {
tt=S("Extinguishes fire and hurts some mobs"), 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, no_effect=true,
potion_fun=water_splash, potion_fun=water_splash,
effect=1 effect=1

View File

@ -53,7 +53,7 @@ minetest.register_globalstep(function(dtime)
-- Extinguish fire if water bottle -- Extinguish fire if water bottle
if vals.is_water then 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 vals.timer = vals.timer / 2
end end
end end
@ -162,7 +162,7 @@ function mcl_potions.register_lingering(name, descr, color, def)
texture = texture.."^[colorize:"..color..":127", texture = texture.."^[colorize:"..color..":127",
}) })
if name == "water" then if name == "water" then
mcl_potions._extinguish_nearby_fire(pos) mcl_potions._extinguish_nearby_fire(pos, d)
end end
self.object:remove() self.object:remove()
end end