From 63b543a8fb24e027afbc6f01c139374e470cd082 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 14 Mar 2020 19:37:31 +0000 Subject: [PATCH] Fix non-shooters from being able to use grappling hooks --- mods/ctf/ctf_classes/init.lua | 2 ++ mods/ctf/ctf_classes/ranged.lua | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mods/ctf/ctf_classes/init.lua b/mods/ctf/ctf_classes/init.lua index 614767d..dc161d2 100644 --- a/mods/ctf/ctf_classes/init.lua +++ b/mods/ctf/ctf_classes/init.lua @@ -39,6 +39,8 @@ ctf_classes.register("shooter", { cons = {}, color = "#c60", properties = { + allow_grapples = true, + initial_stuff = { "shooter:rifle", "shooter:grapple_gun_loaded", diff --git a/mods/ctf/ctf_classes/ranged.lua b/mods/ctf/ctf_classes/ranged.lua index 8f4dd9a..628e68b 100644 --- a/mods/ctf/ctf_classes/ranged.lua +++ b/mods/ctf/ctf_classes/ranged.lua @@ -45,7 +45,7 @@ local function check_grapple(itemname) local old_func = def.on_use minetest.override_item(itemname, { on_use = function(itemstack, user, ...) - if ctf_classes.get(user).name ~= "shooter" then + if not ctf_classes.get(user).properties.allow_grapples then minetest.chat_send_player(user:get_player_name(), "Your class can't use that weapon! Change your class at spawn") @@ -66,3 +66,4 @@ end check_grapple("shooter:grapple_gun_loaded") check_grapple("shooter:grapple_gun") +check_grapple("shooter:grapple_hook")