Fix potions to hit mobs.
This commit is contained in:
parent
4a35ad3fd1
commit
8a08d27ee5
|
@ -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)
|
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)
|
function mcl_potions.make_invisible(player, toggle)
|
||||||
|
|
||||||
if not player then return false end
|
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")
|
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:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||||
obj:setacceleration({x=0, y=-9.8, z=0})
|
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
|
return item
|
||||||
end,
|
end,
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
|
@ -38,7 +40,7 @@ local function register_lingering(name, descr, color, def)
|
||||||
local n = node.name
|
local n = node.name
|
||||||
local d = 2
|
local d = 2
|
||||||
local redux_map = {7/8,0.5,0.25}
|
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.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 1000,
|
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"
|
return "mcl_potions_splash_overlay.png^[colorize:"..colorstring..":"..tostring(opacity).."^mcl_potions_splash_bottle.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function register_splash(name, descr, color, def)
|
local function register_splash(name, descr, color, def)
|
||||||
|
|
||||||
local id = "mcl_potions:"..name.."_splash"
|
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")
|
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_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||||
obj:set_acceleration({x=0, y=-9.8, z=0})
|
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
|
return item
|
||||||
end,
|
end,
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
|
@ -37,7 +40,7 @@ local function register_splash(name, descr, color, def)
|
||||||
local n = node.name
|
local n = node.name
|
||||||
local d = 2
|
local d = 2
|
||||||
local redux_map = {7/8,0.5,0.25}
|
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.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 50,
|
amount = 50,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user