mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-27 02:19:33 +01:00
Fix potions to hit mobs.
This commit is contained in:
parent
4a35ad3fd1
commit
8a08d27ee5
3 changed files with 26 additions and 4 deletions
|
@ -235,6 +235,23 @@ minetest.register_on_leaveplayer( function(player) _reset_player_effects(player)
|
|||
|
||||
minetest.register_on_dieplayer( function(player) _reset_player_effects(player) end)
|
||||
|
||||
function mcl_potions.is_obj_hit(self, pos)
|
||||
|
||||
for _,object in pairs(minetest.get_objects_inside_radius(pos, 1.1)) do
|
||||
|
||||
local entity = object:get_luaentity()
|
||||
|
||||
if entity and entity.name ~= self.object:get_luaentity().name then
|
||||
|
||||
if object:is_player() or entity._cmi_is_mob then return true end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.make_invisible(player, toggle)
|
||||
|
||||
if not player then return false end
|
||||
|
|
|
@ -19,7 +19,9 @@ local function register_lingering(name, descr, color, def)
|
|||
local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
|
||||
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||
obj:setacceleration({x=0, y=-9.8, z=0})
|
||||
item:take_item()
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
item:take_item()
|
||||
end
|
||||
return item
|
||||
end,
|
||||
stack_max = 1,
|
||||
|
@ -38,7 +40,7 @@ local function register_lingering(name, descr, color, def)
|
|||
local n = node.name
|
||||
local d = 2
|
||||
local redux_map = {7/8,0.5,0.25}
|
||||
if n ~= "air" then
|
||||
if n ~= "air" 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.add_particlespawner({
|
||||
amount = 1000,
|
||||
|
|
|
@ -5,6 +5,7 @@ local splash_image = function(colorstring, opacity)
|
|||
return "mcl_potions_splash_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_splash_bottle.png"
|
||||
end
|
||||
|
||||
|
||||
local function register_splash(name, descr, color, def)
|
||||
|
||||
local id = "mcl_potions:"..name.."_splash"
|
||||
|
@ -18,7 +19,9 @@ local function register_splash(name, descr, color, def)
|
|||
local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
|
||||
obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||
obj:set_acceleration({x=0, y=-9.8, z=0})
|
||||
item:take_item()
|
||||
if not minetest.settings:get_bool("creative_mode") then
|
||||
item:take_item()
|
||||
end
|
||||
return item
|
||||
end,
|
||||
stack_max = 1,
|
||||
|
@ -37,7 +40,7 @@ local function register_splash(name, descr, color, def)
|
|||
local n = node.name
|
||||
local d = 2
|
||||
local redux_map = {7/8,0.5,0.25}
|
||||
if n ~= "air" then
|
||||
if n ~= "air" 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.add_particlespawner({
|
||||
amount = 50,
|
||||
|
|
Loading…
Reference in a new issue