forked from MineClone5/MineClone5
Fix cactus not hurting player if above
This commit is contained in:
parent
661b586a64
commit
02679a02df
|
@ -134,21 +134,22 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- am I near a cactus?
|
-- Am I near a cactus?
|
||||||
local near = minetest.find_node_near(pos, 1, "mcl_core:cactus")
|
local near = minetest.find_node_near(pos, 1, "mcl_core:cactus")
|
||||||
|
if not near then
|
||||||
|
near = minetest.find_node_near({x=pos.x, y=pos.y-1, z=pos.z}, 1, "mcl_core:cactus")
|
||||||
|
end
|
||||||
if near then
|
if near then
|
||||||
-- am I touching the cactus? if so it hurts
|
-- Am I touching the cactus? If so, it hurts
|
||||||
for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do
|
local dist = vector.distance(pos, near)
|
||||||
if object:get_hp() > 0 then
|
local dist_feet = vector.distance({x=pos.x, y=pos.y-1, z=pos.z}, near)
|
||||||
if object:is_player() then
|
if dist < 1.1 or dist_feet < 1.1 then
|
||||||
mcl_death_messages.player_damage(object, string.format("%s was prickled by a cactus.", object:get_player_name()))
|
if player:get_hp() > 0 then
|
||||||
mcl_hunger.exhaust(object:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
mcl_death_messages.player_damage(player, string.format("%s was prickled by a cactus.", player:get_player_name()))
|
||||||
end
|
mcl_hunger.exhaust(player:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
||||||
object:set_hp(object:get_hp() - 1)
|
player:set_hp(player:get_hp() - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Apply black sky in the Void and deal Void damage
|
-- Apply black sky in the Void and deal Void damage
|
||||||
|
|
Loading…
Reference in New Issue