From bbf156103c9a690b8076e182dc476db1b81dedf7 Mon Sep 17 00:00:00 2001 From: FlamingRCCars <106501309+FlamingRCCars@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:12:04 -0500 Subject: [PATCH 1/5] Add the "Thief" class Fixes #1172, I nerfed it a little to make it more balanced, and hopefully farooq can use it to add his score thingy, but I tested it, and it works. --- .../ctf_modes/ctf_mode_classes/classes.lua | 22 +++++++- mods/ctf/ctf_modes/ctf_mode_classes/init.lua | 5 +- .../ctf_mode_classes_thief_overlay.png | Bin 0 -> 2529 bytes mods/ctf/ctf_modes/ctf_mode_classes/thief.lua | 49 ++++++++++++++++++ 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 mods/ctf/ctf_modes/ctf_mode_classes/textures/ctf_mode_classes_thief_overlay.png create mode 100644 mods/ctf/ctf_modes/ctf_mode_classes/thief.lua diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua b/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua index dd8208b0ac..a06ce8a3c7 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua @@ -5,7 +5,7 @@ local CLASS_SWITCH_COOLDOWN = 30 local classes = {} -local class_list = {"knight", "ranged", "support"} +local class_list = {"knight", "ranged", "support", "thief"} local class_props = { knight = { name = "Knight", @@ -55,6 +55,26 @@ local class_props = { disallowed_items_markup = { ["ctf_melee:"] = "default_tool_steelsword.png^ctf_modebase_group.png", }, + }, + thief = { + name = "Thief", + description = "Criminal class, punch enemies with a bare hand to have a chance of stealing an item from them", + visual_size = vector.new(0.8, 0.9, 0.8), + physics = {speed = 1.2}, + items = { + "ctf_mode_classes:scaling_ladder", + "default:cobble 99" + }, + disallowed_items = { + "ctf_melee:", + "ctf_ranged:rifle", + "ctf_ranged:smg", + "ctf_ranged:sniper_magnum", + "ctf_ranged:shotgun", + }, + disallowed_items_markup = { + ["ctf_melee:"] = "default_tool_steelsword.png^ctf_modebase_group.png" + }, } } diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua index 4ae92222a2..ffbd4462f5 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua @@ -2,9 +2,10 @@ local rankings = ctf_rankings.init() local recent_rankings = ctf_modebase.recent_rankings(rankings) local features = ctf_modebase.features(rankings, recent_rankings) -local classes = ctf_core.include_files( +classes = ctf_core.include_files( "paxel.lua", - "classes.lua" + "classes.lua", + "thief.lua" ) local old_bounty_reward_func = ctf_modebase.bounties.bounty_reward_func diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/textures/ctf_mode_classes_thief_overlay.png b/mods/ctf/ctf_modes/ctf_mode_classes/textures/ctf_mode_classes_thief_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..cffaa9ff2ea0ab8067f5c8feede70b27bf0d6eb2 GIT binary patch literal 2529 zcmcImd2kcg9TssM2NQ!Y86zxvwUTA|SZOa^YY89nAsYm;EsQge46EIhytS@KvL!nt zA&g0!#!bp)j0wbsnK)_FBuoq?4KcwbK!6&X%!G!+!;p5|P#Bt-l+r2KeJdX&Q~qkE zJG0t-Pv7r*zwdj$_mf_;udYr?lq8BoqNEyYMLl?yf*X1=4t(yiym3S%TCjz;SnM?x z3uF)aUA%`AiBuPMZ8KWq$}+c>96Vq>3Fj-CJOho12jCt_d`fzG_w}_$KmDZhmZUAs zQxw1c#K^(#3q0>1KKzmR@e^?;M@MVNtJnwbG;1UNz17ot!%A4FI%AWGaaUXr_e=Lr%`k`^@m2PmjY8&zj+N zS{rH$Sh!~1+7aX$I#xTFjuytq!X+z`5=~JGFnGBz4Mn{kUxOJX=GlFr zSs#ESnkXI6U}{w3^$Jba1=HOO$4ZJaMGp9^Q1`Pe{f z&=XU^G8)dqc>yd0R>S6(s;;rw=h1>{H}4I^B7np5s4(yPk2gQcNBAa|{@mgqY@Y8& z$T^(?5ST$#_?cEApPC9YEG$Z~euihM*ejuR;Rf8rAVw`qA|&l35Za(;5f|>n^t7Ht zX`G$osquxvw2$Eg9>A>T0SRj$P?t`JAx>JyBBT~KAO<6iBb-r7FglDO^rUt!eoc@E zrAK=n&PU*31s(>)P$xO+Bn+_(Rpk$QX|QFymv(cS zfX@v>g0obay~YgVYIJsJ_t0S%fSTb|ystGnJL}-RTtk=^jKg#UiWyJ>$1pvrB@DBO zMlKivl_gMNs2T@r3cgbybzmSZ6deeS38E}Pjt={S4!_@HhJ_p;A!e>tLAB1fZ{gdw3{Tkrd6$EES^LIN<-xB-2d$+#EQvpju{T_($ysM;d94 zBoK}xvh2f*Lir z=5qYswcwN%r%)j6zqOb&LW_BLuS}XpZR-r~q1H6h_F~bX?|~7Bn`@=QXuchDKCq!d z&}={G+tUXAib!iJ${f~}x3{;f89_6v{(AW5)a_1NUe{xBboYBMv{sF2yBFL^JkT70B&S5rL}dNX zhZcQ>CcJy;)$|_{rjmbEm(o8jRWPRS*W0BT?B_&n_={&edriwJf{*>+$x5KwoPW7OYF6#`o5`qaXa+J?fBtIlkxX% z_l@Hl`B%Oit7W#0?mnkzf8qIc7ux@DI=z0uj`3SNs<&${TF*LqB7ZCF8WuHQy1##A TLhbv)Pg+go>WUA_H*Wbifxmxq literal 0 HcmV?d00001 diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua new file mode 100644 index 0000000000..3cba69b53f --- /dev/null +++ b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua @@ -0,0 +1,49 @@ +local robbery_cooldown = ctf_core.init_cooldowns() +local ROBBERY_INTERVAL = 5 + +local function rob_player(player, robber) + local inv = player:get_inventory() + local stack = inv:get_stack("main", math.random(1, inv:get_size("main"))) + local mode = ctf_modebase:get_current_mode() + if mode and mode.stuff_provider then + for _, item in ipairs(classes.get(player).items) do + if stack:get_name() == item or stack:get_name() == "" then + return "You didn't find anything to rob." + end + end + if robber:get_inventory():room_for_item("main", stack) then + inv:remove_item("main", stack) + robber:get_inventory():add_item("main", stack) + else + local pos = player:get_pos() + inv:remove_item("main", stack) + minetest.add_item(pos, stack) + end + return string.format("You stole %s %s", stack:get_count(), stack:get_description()) + end +end + +minetest.register_on_punchplayer(function(punched, puncher) + if puncher and puncher:is_player() and punched and punched:is_player() then + local wielded_item = puncher:get_wielded_item() + if puncher:get_wielded_item():get_name() == "" then + if robbery_cooldown:get(puncher:get_player_name()) then + hud_events.new(puncher, { + text = "You can only rob every "..ROBBERY_INTERVAL.." seconds", + color = "warning", + quick = true, + }) + return + end + local msg = rob_player(punched, puncher) + if msg then + hud_events.new(puncher, { + text = msg, + color = "warning", + quick = true, + }) + end + robbery_cooldown:set(puncher, ROBBERY_INTERVAL) + end + end +end) From b0351b56cbc89395e39cdf0f2907c29efb6ce956 Mon Sep 17 00:00:00 2001 From: FlamingRCCars <106501309+FlamingRCCars@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:19:04 -0500 Subject: [PATCH 2/5] Cleaned up a little --- mods/ctf/ctf_modes/ctf_mode_classes/thief.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua index 3cba69b53f..e56b6d46de 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua @@ -6,7 +6,7 @@ local function rob_player(player, robber) local stack = inv:get_stack("main", math.random(1, inv:get_size("main"))) local mode = ctf_modebase:get_current_mode() if mode and mode.stuff_provider then - for _, item in ipairs(classes.get(player).items) do + for _, item in ipairs(classes.get(player).items) do if stack:get_name() == item or stack:get_name() == "" then return "You didn't find anything to rob." end @@ -25,7 +25,6 @@ end minetest.register_on_punchplayer(function(punched, puncher) if puncher and puncher:is_player() and punched and punched:is_player() then - local wielded_item = puncher:get_wielded_item() if puncher:get_wielded_item():get_name() == "" then if robbery_cooldown:get(puncher:get_player_name()) then hud_events.new(puncher, { From 4a00ca63e8507fb6659af0c2a7b759eab3010d54 Mon Sep 17 00:00:00 2001 From: FlamingRCCars <106501309+FlamingRCCars@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:22:20 -0500 Subject: [PATCH 3/5] Possible fix an issue --- mods/ctf/ctf_modes/ctf_mode_classes/init.lua | 14 +++++++------- mods/ctf/ctf_modes/ctf_mode_classes/thief.lua | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua index ffbd4462f5..7baf2394da 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua @@ -2,7 +2,7 @@ local rankings = ctf_rankings.init() local recent_rankings = ctf_modebase.recent_rankings(rankings) local features = ctf_modebase.features(rankings, recent_rankings) -classes = ctf_core.include_files( +ctf_classes.classes = ctf_core.include_files( "paxel.lua", "classes.lua", "thief.lua" @@ -93,12 +93,12 @@ ctf_modebase.register_mode("classes", { end end, stuff_provider = function(player) - local initial_stuff = table.copy(classes.get(player).items or {}) + local initial_stuff = table.copy(ctf_classes.classes.get(player).items or {}) table.insert_all(initial_stuff, {"default:pick_stone", "default:torch 15", "default:stick 5"}) return initial_stuff end, initial_stuff_item_levels = custom_item_levels, - is_restricted_item = classes.is_restricted_item, + is_restricted_item = ctf_classes.classes.is_restricted_item, on_mode_start = function() ctf_modebase.bounties.bounty_reward_func = ctf_modebase.bounty_algo.kd.bounty_reward_func ctf_modebase.bounties.get_next_bounty = ctf_modebase.bounty_algo.kd.get_next_bounty @@ -108,7 +108,7 @@ ctf_modebase.register_mode("classes", { return old_get_skin(player) end - return old_get_skin(player) .. classes.get_skin_overlay(player) + return old_get_skin(player) .. ctf_classes.classes.get_skin_overlay(player) end end, on_mode_end = function() @@ -116,13 +116,13 @@ ctf_modebase.register_mode("classes", { ctf_modebase.bounties.get_next_bounty = old_get_next_bounty ctf_cosmetics.get_skin = old_get_skin - classes.finish() + ctf_classes.classes.finish() end, on_new_match = features.on_new_match, on_match_end = features.on_match_end, team_allocator = features.team_allocator, on_allocplayer = function(player, new_team) - classes.update(player) + ctf_classes.classes.update(player) features.on_allocplayer(player, new_team) end, on_leaveplayer = features.on_leaveplayer, @@ -133,7 +133,7 @@ ctf_modebase.register_mode("classes", { on_flag_drop = features.on_flag_drop, on_flag_capture = features.on_flag_capture, on_flag_rightclick = function(clicker) - classes.show_class_formspec(clicker) + ctf_classes.classes.show_class_formspec(clicker) end, get_chest_access = features.get_chest_access, on_punchplayer = features.on_punchplayer, diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua index e56b6d46de..128c71c473 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua @@ -6,7 +6,7 @@ local function rob_player(player, robber) local stack = inv:get_stack("main", math.random(1, inv:get_size("main"))) local mode = ctf_modebase:get_current_mode() if mode and mode.stuff_provider then - for _, item in ipairs(classes.get(player).items) do + for _, item in ipairs(ctf_classes.classes.get(player).items) do if stack:get_name() == item or stack:get_name() == "" then return "You didn't find anything to rob." end From fde6b8de165106c9879fd5d7305cfc616f2c0ffe Mon Sep 17 00:00:00 2001 From: FlamingRCCars <106501309+FlamingRCCars@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:33:43 -0500 Subject: [PATCH 4/5] Revert those changes --- mods/ctf/ctf_modes/ctf_mode_classes/init.lua | 14 +++++++------- mods/ctf/ctf_modes/ctf_mode_classes/thief.lua | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua index 7baf2394da..ffbd4462f5 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua @@ -2,7 +2,7 @@ local rankings = ctf_rankings.init() local recent_rankings = ctf_modebase.recent_rankings(rankings) local features = ctf_modebase.features(rankings, recent_rankings) -ctf_classes.classes = ctf_core.include_files( +classes = ctf_core.include_files( "paxel.lua", "classes.lua", "thief.lua" @@ -93,12 +93,12 @@ ctf_modebase.register_mode("classes", { end end, stuff_provider = function(player) - local initial_stuff = table.copy(ctf_classes.classes.get(player).items or {}) + local initial_stuff = table.copy(classes.get(player).items or {}) table.insert_all(initial_stuff, {"default:pick_stone", "default:torch 15", "default:stick 5"}) return initial_stuff end, initial_stuff_item_levels = custom_item_levels, - is_restricted_item = ctf_classes.classes.is_restricted_item, + is_restricted_item = classes.is_restricted_item, on_mode_start = function() ctf_modebase.bounties.bounty_reward_func = ctf_modebase.bounty_algo.kd.bounty_reward_func ctf_modebase.bounties.get_next_bounty = ctf_modebase.bounty_algo.kd.get_next_bounty @@ -108,7 +108,7 @@ ctf_modebase.register_mode("classes", { return old_get_skin(player) end - return old_get_skin(player) .. ctf_classes.classes.get_skin_overlay(player) + return old_get_skin(player) .. classes.get_skin_overlay(player) end end, on_mode_end = function() @@ -116,13 +116,13 @@ ctf_modebase.register_mode("classes", { ctf_modebase.bounties.get_next_bounty = old_get_next_bounty ctf_cosmetics.get_skin = old_get_skin - ctf_classes.classes.finish() + classes.finish() end, on_new_match = features.on_new_match, on_match_end = features.on_match_end, team_allocator = features.team_allocator, on_allocplayer = function(player, new_team) - ctf_classes.classes.update(player) + classes.update(player) features.on_allocplayer(player, new_team) end, on_leaveplayer = features.on_leaveplayer, @@ -133,7 +133,7 @@ ctf_modebase.register_mode("classes", { on_flag_drop = features.on_flag_drop, on_flag_capture = features.on_flag_capture, on_flag_rightclick = function(clicker) - ctf_classes.classes.show_class_formspec(clicker) + classes.show_class_formspec(clicker) end, get_chest_access = features.get_chest_access, on_punchplayer = features.on_punchplayer, diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua index 128c71c473..e56b6d46de 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua @@ -6,7 +6,7 @@ local function rob_player(player, robber) local stack = inv:get_stack("main", math.random(1, inv:get_size("main"))) local mode = ctf_modebase:get_current_mode() if mode and mode.stuff_provider then - for _, item in ipairs(ctf_classes.classes.get(player).items) do + for _, item in ipairs(classes.get(player).items) do if stack:get_name() == item or stack:get_name() == "" then return "You didn't find anything to rob." end From 99ee729546367b9ec4dd42c834c54f5c1cad4794 Mon Sep 17 00:00:00 2001 From: FlamingRCCars <106501309+FlamingRCCars@users.noreply.github.com> Date: Mon, 3 Jul 2023 15:44:31 -0500 Subject: [PATCH 5/5] Test this system --- mods/ctf/ctf_modes/ctf_mode_classes/classes.lua | 2 +- mods/ctf/ctf_modes/ctf_mode_classes/init.lua | 15 ++++++++------- mods/ctf/ctf_modes/ctf_mode_classes/thief.lua | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua b/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua index a06ce8a3c7..d87064cb09 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/classes.lua @@ -59,7 +59,7 @@ local class_props = { thief = { name = "Thief", description = "Criminal class, punch enemies with a bare hand to have a chance of stealing an item from them", - visual_size = vector.new(0.8, 0.9, 0.8), + visual_size = vector.new(0.9, 0.9, 0.9), physics = {speed = 1.2}, items = { "ctf_mode_classes:scaling_ladder", diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua index ffbd4462f5..78aa6d923c 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua @@ -2,7 +2,8 @@ local rankings = ctf_rankings.init() local recent_rankings = ctf_modebase.recent_rankings(rankings) local features = ctf_modebase.features(rankings, recent_rankings) -classes = ctf_core.include_files( +ctf_modes_classes = {} +ctf_modes_classes.classes = ctf_core.include_files( "paxel.lua", "classes.lua", "thief.lua" @@ -93,12 +94,12 @@ ctf_modebase.register_mode("classes", { end end, stuff_provider = function(player) - local initial_stuff = table.copy(classes.get(player).items or {}) + local initial_stuff = table.copy(ctf_modes_classes.classes.get(player).items or {}) table.insert_all(initial_stuff, {"default:pick_stone", "default:torch 15", "default:stick 5"}) return initial_stuff end, initial_stuff_item_levels = custom_item_levels, - is_restricted_item = classes.is_restricted_item, + is_restricted_item = ctf_modes_classes.classes.is_restricted_item, on_mode_start = function() ctf_modebase.bounties.bounty_reward_func = ctf_modebase.bounty_algo.kd.bounty_reward_func ctf_modebase.bounties.get_next_bounty = ctf_modebase.bounty_algo.kd.get_next_bounty @@ -108,7 +109,7 @@ ctf_modebase.register_mode("classes", { return old_get_skin(player) end - return old_get_skin(player) .. classes.get_skin_overlay(player) + return old_get_skin(player) .. ctf_modes_classes.classes.get_skin_overlay(player) end end, on_mode_end = function() @@ -116,13 +117,13 @@ ctf_modebase.register_mode("classes", { ctf_modebase.bounties.get_next_bounty = old_get_next_bounty ctf_cosmetics.get_skin = old_get_skin - classes.finish() + ctf_modes_classes.classes.finish() end, on_new_match = features.on_new_match, on_match_end = features.on_match_end, team_allocator = features.team_allocator, on_allocplayer = function(player, new_team) - classes.update(player) + ctf_modes_classes.classes.update(player) features.on_allocplayer(player, new_team) end, on_leaveplayer = features.on_leaveplayer, @@ -133,7 +134,7 @@ ctf_modebase.register_mode("classes", { on_flag_drop = features.on_flag_drop, on_flag_capture = features.on_flag_capture, on_flag_rightclick = function(clicker) - classes.show_class_formspec(clicker) + ctf_modes_classes.classes.show_class_formspec(clicker) end, get_chest_access = features.get_chest_access, on_punchplayer = features.on_punchplayer, diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua index e56b6d46de..fecaf9b027 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/thief.lua @@ -6,7 +6,7 @@ local function rob_player(player, robber) local stack = inv:get_stack("main", math.random(1, inv:get_size("main"))) local mode = ctf_modebase:get_current_mode() if mode and mode.stuff_provider then - for _, item in ipairs(classes.get(player).items) do + for _, item in ipairs(ctf_modes_classes.classes.get(player).items) do if stack:get_name() == item or stack:get_name() == "" then return "You didn't find anything to rob." end