From 355a171949853e657c88f6dfbb1a7088951a2014 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Wed, 6 Jan 2021 09:45:18 -0800 Subject: [PATCH] Give sniper rifles the ability to break nodes again --- mods/pvp/sniper_rifles/init.lua | 18 ++++++++++++++++++ mods/pvp/sniper_rifles/mod.conf | 2 +- mods/pvp/sniper_rifles/rifles.lua | 6 ++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mods/pvp/sniper_rifles/init.lua b/mods/pvp/sniper_rifles/init.lua index be0d705..a0ba73b 100644 --- a/mods/pvp/sniper_rifles/init.lua +++ b/mods/pvp/sniper_rifles/init.lua @@ -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") diff --git a/mods/pvp/sniper_rifles/mod.conf b/mods/pvp/sniper_rifles/mod.conf index 4884491..89f99fb 100644 --- a/mods/pvp/sniper_rifles/mod.conf +++ b/mods/pvp/sniper_rifles/mod.conf @@ -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. diff --git a/mods/pvp/sniper_rifles/rifles.lua b/mods/pvp/sniper_rifles/rifles.lua index 3aa6ca8..c70a2e3 100644 --- a/mods/pvp/sniper_rifles/rifles.lua +++ b/mods/pvp/sniper_rifles/rifles.lua @@ -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, } } })