More precise logic for player names.
Try to detect player traces going through a change in fluid medium such as water/air or water/glass, and block facial recognition through it. Specifically allow air-into-glass transitions, or into any other medium otherwise clear enough to allow sunlight to propagate.
This commit is contained in:
parent
40c239a798
commit
087b8c8f1b
Binary file not shown.
Before Width: | Height: | Size: 150 B After Width: | Height: | Size: 147 B |
@ -10,9 +10,6 @@ local modname = minetest.get_current_modname()
|
||||
-- Maximum distance at which custom nametags are visible.
|
||||
local distance = tonumber(minetest.settings:get(modname .. "_distance")) or 16
|
||||
|
||||
-- Precision (number of steps) for line-of-sight check for displaying nametags
|
||||
local precision = tonumber(minetest.settings:get(modname .. "_precision")) or 50
|
||||
|
||||
-- Keep track of active player HUDs.
|
||||
local huds = {}
|
||||
|
||||
@ -70,14 +67,33 @@ local function canseeface(p1, n1, p2, n2)
|
||||
local ld = (ll / 15 * distance)
|
||||
if dsqr > (ld * ld) then return end
|
||||
|
||||
-- Check for line of sight from approximate eye level
|
||||
-- of one player to the other.
|
||||
-- Make sure players' eyes are inside the same fluid.
|
||||
o1.y = o1.y + e1
|
||||
o2.y = o2.y + e2
|
||||
for pt in minetest.raycast(o1, o2) do
|
||||
if pt.type ~= "object"
|
||||
or (pt.ref ~= p2 and pt.ref ~= p1)
|
||||
then return end
|
||||
local f1 = minetest.get_node(o1).name
|
||||
local d1 = minetest.registered_items[f1]
|
||||
f1 = d1 and d1.liquid_alterantive_source or f1
|
||||
local f2 = minetest.get_node(o2).name
|
||||
local d2 = minetest.registered_items[f2]
|
||||
f2 = d2 and d2.liquid_alterantive_source or f2
|
||||
if f1 ~= f2 then return minetest.log(dump({f1, f2}))end
|
||||
|
||||
-- Check for line of sight from approximate eye level
|
||||
-- of one player to the other.
|
||||
for pt in minetest.raycast(o1, o2, true, true) do
|
||||
if pt.type == "node" then
|
||||
local nn = minetest.get_node(pt.under).name
|
||||
local nd = minetest.registered_items[nn]
|
||||
if not nd then return end
|
||||
if not (f1 == "air" and nd.sunlight_propagates) then
|
||||
nn = nd.liquid_alternative_source or nn
|
||||
if nn ~= f1 then return end
|
||||
end
|
||||
elseif pt.type == "object" then
|
||||
if pt.ref ~= p1 and pt.ref ~= p2 then return end
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Players must be facing each other; cannot identify another
|
||||
|
Loading…
x
Reference in New Issue
Block a user