Give sniper rifles the ability to break nodes again

This commit is contained in:
LoneWolfHT 2021-01-06 09:45:18 -08:00
parent 8c33103e4c
commit 355a171949
3 changed files with 23 additions and 3 deletions

View file

@ -153,4 +153,22 @@ function sniper_rifles.register_rifle(name, def)
rifles[name] = table.copy(def)
end
local old_is_protected = minetest.is_protected
local r = ctf.setting("flag.nobuild_radius") + 5
local rs = r * r
function minetest.is_protected(pos, name, info, ...)
if r <= 0 or rs == 0 or not info or not info.is_gun then
return old_is_protected(pos, name, info, ...)
end
local flag, distSQ = ctf_flag.get_nearest(pos)
if flag and pos.y >= flag.y - 1 and distSQ < rs then
minetest.chat_send_player(name,
"You can't shoot blocks within "..r.." nodes of a flag!")
return true
else
return old_is_protected(pos, name, info, ...)
end
end
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/rifles.lua")

View file

@ -1,3 +1,3 @@
name = sniper_rifles
depends = shooter, physics
depends = shooter, physics, ctf, ctf_flag
description = Sniper rifle API (depends on shooter) along with couple of sniper rifles.

View file

@ -11,7 +11,8 @@ sniper_rifles.register_rifle("sniper_rifles:rifle_762", {
sounds = { shot = "sniper_rifles_shot" },
particle = "shooter_bullet.png",
groups = {
snappy = 2, fleshy = 1, oddly_breakable_by_hand = 1
cracky = 3, snappy = 2, crumbly = 2, choppy = 2,
fleshy = 1, oddly_breakable_by_hand = 1,
}
}
})
@ -29,7 +30,8 @@ sniper_rifles.register_rifle("sniper_rifles:rifle_magnum", {
sounds = { shot = "sniper_rifles_shot" },
particle = "shooter_bullet.png",
groups = {
snappy = 1, fleshy = 1, oddly_breakable_by_hand = 1
cracky = 2, snappy = 1, crumbly = 1, choppy = 1,
fleshy = 1, oddly_breakable_by_hand = 1,
}
}
})