Ignore the shooter player when processing rounds (#1)

This removing the initial raycast offset and allows damaging players at point-blank range
This commit is contained in:
ANAND 2020-05-31 20:06:52 +05:30 committed by GitHub
parent 2a1c951c8a
commit 897f74cb7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -359,8 +359,14 @@ local function process_round(round)
local p1 = round.pos local p1 = round.pos
local p2 = v3d.add(p1, v3d.multiply(round.dir, round.spec.step)) local p2 = v3d.add(p1, v3d.multiply(round.dir, round.spec.step))
local ray = minetest.raycast(p1, p2, true, true) local ray = minetest.raycast(p1, p2, true, true)
local pointed_thing = ray:next() or {type="nothing"} local pointed_thing = ray:next()
if pointed_thing.type ~= "nothing" then if pointed_thing then
-- Iterate over ray again if pointed object == shooter
local ref = pointed_thing.ref
if ref and ref:is_player() and ref:get_player_name() == round.spec.user then
pointed_thing = ray:next()
end
return process_hit(pointed_thing, round.spec, round.dir) return process_hit(pointed_thing, round.spec, round.dir)
end end
round.pos = p2 round.pos = p2
@ -379,7 +385,7 @@ local function fire_weapon(player, itemstack, spec, extended)
return return
end end
pos.y = pos.y + player:get_properties().eye_height pos.y = pos.y + player:get_properties().eye_height
spec.origin = v3d.add(pos, v3d.multiply(dir, 1.5)) spec.origin = pos
local interval = spec.tool_caps.full_punch_interval local interval = spec.tool_caps.full_punch_interval
shots[spec.user] = minetest.get_us_time() / 1000000 + interval shots[spec.user] = minetest.get_us_time() / 1000000 + interval
local sound = spec.sounds.shot or "shooter_pistol" local sound = spec.sounds.shot or "shooter_pistol"