1
0
Fork 0

Make throwable water bottles useful

This commit is contained in:
Wuzzy 2020-08-05 18:33:53 +02:00
parent 13963d00e5
commit 1f8488aba5
7 changed files with 81 additions and 9 deletions

View File

@ -22,7 +22,7 @@ mobs:register_mob("mobs_mc:blaze", {
textures = { textures = {
{"mobs_mc_blaze.png"}, {"mobs_mc_blaze.png"},
}, },
armor = { fleshy = 100, snowball_vulnerable = 100 }, armor = { fleshy = 100, snowball_vulnerable = 100, water_vulnerable = 100 },
visual_size = {x=3, y=3}, visual_size = {x=3, y=3},
sounds = { sounds = {
random = "mobs_mc_blaze_breath", random = "mobs_mc_blaze_breath",

View File

@ -520,6 +520,7 @@ mobs:register_mob("mobs_mc:enderman", {
end end
end end
end, end,
armor = { fleshy = 100, water_vulnerable = 100 },
water_damage = 8, water_damage = 8,
view_range = 64, view_range = 64,
fear_height = 4, fear_height = 4,

View File

@ -31,6 +31,7 @@ mobs:register_mob("mobs_mc:snowman", {
fall_damage = 0, fall_damage = 0,
water_damage = 4, water_damage = 4,
rain_damage = 4, rain_damage = 4,
armor = { fleshy = 100, water_vulnerable = 100 },
attacks_monsters = true, attacks_monsters = true,
collisionbox = {-0.35, -0.01, -0.35, 0.35, 1.89, 0.35}, collisionbox = {-0.35, -0.01, -0.35, 0.35, 1.89, 0.35},
visual = "mesh", visual = "mesh",

View File

@ -747,3 +747,29 @@ function mcl_potions.night_vision_func(player, null, duration)
end end
end end
function mcl_potions._extinguish_nearby_fire(pos)
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)
exting = true
end
end
return exting
end

View File

@ -277,9 +277,38 @@ minetest.register_craftitem("mcl_potions:river_water", {
}) })
-- TODO: Extinguish fire, damage mobs -- Hurt mobs
mcl_potions.register_splash("water", S("Splash Water Bottle"), "#0022FF", {tt=S("No effect"), potion_fun=function() end}) local water_splash = function(obj, damage)
mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", {tt=S("No effect"), potion_fun=function() end}) if not obj then
return
end
if not damage or (damage > 0 and damage < 1) then
damage = 1
end
-- Damage mobs that are vulnerable to water
local lua = obj:get_luaentity()
if lua and lua._cmi_is_mob then
obj:punch(obj, 1.0, {
full_punch_interval = 1.0,
damage_groups = {water_vulnerable=damage},
}, nil)
end
end
mcl_potions.register_splash("water", S("Splash 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."),
no_effect=true,
potion_fun=water_splash,
effect=1
})
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."),
no_effect=true,
potion_fun=water_splash,
effect=1
})
minetest.register_craftitem("mcl_potions:speckled_melon", { minetest.register_craftitem("mcl_potions:speckled_melon", {
description = S("Glistering Melon"), description = S("Glistering Melon"),

View File

@ -10,9 +10,9 @@ end
local lingering_effect_at = {} local lingering_effect_at = {}
local function add_lingering_effect(pos, color, def) local function add_lingering_effect(pos, color, def, is_water)
lingering_effect_at[pos] = {color = color, timer = 30, def = def} lingering_effect_at[pos] = {color = color, timer = 30, def = def, is_water = is_water}
end end
@ -46,6 +46,14 @@ minetest.register_globalstep(function(dtime)
texture = "mcl_potions_sprite.png^[colorize:"..vals.color..":127", texture = "mcl_potions_sprite.png^[colorize:"..vals.color..":127",
}) })
-- Extingish fire if water bottle
if vals.is_water then
if mcl_potions._extinguish_nearby_fire(pos) then
vals.timer = vals.timer / 2
end
end
-- Affect players and mobs
for _, obj in pairs(minetest.get_objects_inside_radius(pos, d)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, d)) do
local entity = obj:get_luaentity() local entity = obj:get_luaentity()
@ -114,13 +122,13 @@ function mcl_potions.register_lingering(name, descr, color, def)
visual_size = {x=w/2,y=w/2}, visual_size = {x=w/2,y=w/2},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
on_step = function(self, dtime) on_step = function(self, dtime)
local pos = self.object:getpos() local pos = self.object:get_pos()
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local n = node.name local n = node.name
local d = 4 local d = 4
if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" or mcl_potions.is_obj_hit(self, pos) then if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" or mcl_potions.is_obj_hit(self, pos) then
minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
add_lingering_effect(pos, color, def) add_lingering_effect(pos, color, def, name == "water")
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 40, amount = 40,
time = 1, time = 1,
@ -138,6 +146,9 @@ function mcl_potions.register_lingering(name, descr, color, def)
vertical = false, vertical = false,
texture = "mcl_potions_sprite.png^[colorize:"..color..":127", texture = "mcl_potions_sprite.png^[colorize:"..color..":127",
}) })
if name == "water" then
mcl_potions._extinguish_nearby_fire(pos)
end
self.object:remove() self.object:remove()
end end
end, end,

View File

@ -56,7 +56,7 @@ function mcl_potions.register_splash(name, descr, color, def)
visual_size = {x=w/2,y=w/2}, visual_size = {x=w/2,y=w/2},
collisionbox = {0,0,0,0,0,0}, collisionbox = {0,0,0,0,0,0},
on_step = function(self, dtime) on_step = function(self, dtime)
local pos = self.object:getpos() local pos = self.object:get_pos()
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local n = node.name local n = node.name
local d = 2 local d = 2
@ -80,6 +80,10 @@ function mcl_potions.register_splash(name, descr, color, def)
vertical = false, vertical = false,
texture = "mcl_potions_sprite.png^[colorize:"..color..":127", texture = "mcl_potions_sprite.png^[colorize:"..color..":127",
}) })
if name == "water" then
mcl_potions._extinguish_nearby_fire(pos)
end
self.object:remove() self.object:remove()
for _,obj in pairs(minetest.get_objects_inside_radius(pos, 4)) do for _,obj in pairs(minetest.get_objects_inside_radius(pos, 4)) do