Skip to content

Commit

Permalink
Ignore the shooter player when processing rounds
Browse files Browse the repository at this point in the history
This removing the initial raycast offset and allows damaging players at point-blank range
  • Loading branch information
ClobberXD committed May 31, 2020
1 parent 2a1c951 commit 60d106d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions shooter/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,14 @@ local function process_round(round)
local p1 = round.pos
local p2 = v3d.add(p1, v3d.multiply(round.dir, round.spec.step))
local ray = minetest.raycast(p1, p2, true, true)
local pointed_thing = ray:next() or {type="nothing"}
if pointed_thing.type ~= "nothing" then
local pointed_thing = ray:next()
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)
end
round.pos = p2
Expand All @@ -379,7 +385,7 @@ local function fire_weapon(player, itemstack, spec, extended)
return
end
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
shots[spec.user] = minetest.get_us_time() / 1000000 + interval
local sound = spec.sounds.shot or "shooter_pistol"
Expand Down

0 comments on commit 60d106d

Please sign in to comment.