From 446e7d2c5dbfc7aec2fd6230594ea325e3dca158 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Sun, 24 Apr 2022 21:18:26 +0200 Subject: [PATCH 01/28] Add landmine --- mods/ctf/ctf_map/ctf_traps.lua | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index b16fab5c22..514f7f1548 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -101,3 +101,98 @@ minetest.register_node("ctf_map:reinforced_cobble", { groups = {cracky = 1, stone = 2}, sounds = default.node_sound_stone_defaults(), }) + +minetest.register_node("ctf_map:landmine", { + description = "Landmine", + drawtype = "nodebox", + tiles = {"ctf_map_landmine.png", "ctf_map_landmine.png^[transformFY"}, + inventory_image = "ctf_map_landmine.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + groups = {cracky=1, level=2}, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, + }, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, + }, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local meta = minetest.get_meta(pos) + local name = placer:get_player_name() + + meta:set_string("placer", minetest.serialize({ + team = ctf_teams.get(name), + name = name, + })) + end +}) + +minetest.register_abm({ + label = "Landmine", + nodenames = {"ctf_map:landmine"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local objs = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) + if #objs == 0 then + return + else + local plyrs = minetest.get_objects_inside_radius(pos, 3) + local meta = minetest.get_meta(pos) + local placer = minetest.deserialize(meta:get_string("placer")) + local placer_obj = placer and minetest.get_player_by_name(placer.name) + + minetest.add_particlespawner({ + amount = 20, + time = 0.5, + minpos = vector.subtract(pos, 3), + maxpos = vector.add(pos, 3), + minvel = {x = 0, y = 5, z = 0}, + maxvel = {x = 0, y = 7, z = 0}, + minacc = {x = 0, y = 1, z = 0}, + maxacc = {x = 0, y = 1, z = 0}, + minexptime = 0.3, + maxexptime = 0.6, + minsize = 7, + maxsize = 10, + collisiondetection = true, + collision_removal = false, + vertical = false, + texture = "grenades_smoke.png", + }) + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = 0.3, + size = 15, + collisiondetection = false, + collision_removal = false, + object_collision = false, + vertical = false, + texture = "grenades_boom.png", + glow = 10 + }) + + minetest.sound_play("grenades_explode", { + pos = pos, + gain = 1.0, + max_hear_distance = 64, + }) + + for _, v in pairs(plyrs) do + if placer_obj then + v:punch(placer_obj, 1, {damage_groups = {fleshy = 10}}, nil) + else + local chp = v:get_hp() + v:set_hp(chp - 10) + end + end + minetest.remove_node(pos) + end + end +}) From a5d4a205d7e0a060408633238097b8b7f823df2f Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Sun, 24 Apr 2022 21:19:08 +0200 Subject: [PATCH 02/28] Add landmine texture --- mods/ctf/ctf_map/textures/ctf_map_landmine.png | Bin 0 -> 5390 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 mods/ctf/ctf_map/textures/ctf_map_landmine.png diff --git a/mods/ctf/ctf_map/textures/ctf_map_landmine.png b/mods/ctf/ctf_map/textures/ctf_map_landmine.png new file mode 100644 index 0000000000000000000000000000000000000000..82f1d23f23d85fc3a6d9ae0a924c2ee4c5c437fe GIT binary patch literal 5390 zcmeHKdpwi-A7AMpA?2i`%So zK&bBK2Z+*o>tJb=7RjHgOfJ@=qgmZAo9Vf!mgM zkGr?+vaIV}+~8UDpyy0y>R%N(>2W!<;{2XXowcv7)bVuHIPS0#TkUx`_Df&=eBfDxqm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wS`Lsd1FrGU?jxXI)d%ShIk>MI2eLg_;^WukPH7| zy2y?=0ugfLqagtif;lEp&>#-J1IdmcPQY~{kb$uo|A;P^2oy?C1}zSTGljE(OGujy z(r%p0AHIx683JjT0^s!x5Yc#|A09`=;i)j6*zshsnl=3)TNmvA@Zq9W_^b)Qc4IQQ zxxl>&`>|P#^QEEiU;K>E!@uYOhW_T{tN8s!*EhPpih-|E{#ISz==v%KzDoI9b^YJy zGWhhm1Bu}ikP?2GG4{QB5q=TU<$5kW>QU2bqcXZ5RO+U;=cT?N_saA)s`)%GCsuQ|eDjI+-JXoL zeH(ZY`V&w-lPxEi>L6CQH<&*F44o@vw(hOmb^YY>UyN3eaD5B}@~FZpLt!S{??W|m zC>nepUut Date: Sun, 24 Apr 2022 21:27:03 +0200 Subject: [PATCH 03/28] Update ctf_traps.lua --- mods/ctf/ctf_map/ctf_traps.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index 514f7f1548..0fc61ede8d 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -135,8 +135,11 @@ minetest.register_abm({ nodenames = {"ctf_map:landmine"}, interval = 1, chance = 1, + min_y = -3000, + max_y = 3000, action = function(pos, node, active_object_count, active_object_count_wider) - local objs = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) + local objs = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, + {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) if #objs == 0 then return else @@ -163,7 +166,7 @@ minetest.register_abm({ vertical = false, texture = "grenades_smoke.png", }) - + minetest.add_particle({ pos = pos, velocity = {x=0, y=0, z=0}, From 3c23a62de8563ab78ae401d7dec3c228e8721000 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Mon, 25 Apr 2022 22:18:28 +0200 Subject: [PATCH 04/28] Add landmine recipe --- mods/ctf/ctf_modebase/crafting.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mods/ctf/ctf_modebase/crafting.lua b/mods/ctf/ctf_modebase/crafting.lua index 8a2c28db9d..034e7f9ea4 100644 --- a/mods/ctf/ctf_modebase/crafting.lua +++ b/mods/ctf/ctf_modebase/crafting.lua @@ -165,4 +165,10 @@ crafting.register_recipe({ output = "ctf_map:reinforced_cobble 2", items = { "default:cobble 6", "default:steel_ingot" }, always_known = false, -}) \ No newline at end of file +}) + +crafting.register_recipe({ + output = "ctf_map:landmine", + items = { "default:steel_ingot 4", "grenades:frag" }, + always_known = false, +}) From cfbfd56a8a0a08bf47d0cd257775d3e6fc370097 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Mon, 25 Apr 2022 22:19:53 +0200 Subject: [PATCH 05/28] enable landmine classes --- mods/ctf/ctf_modes/ctf_mode_classes/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua index 708173d3bd..dd7565b507 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua @@ -42,7 +42,7 @@ ctf_modebase.register_mode("classes", { }, crafts = { "ctf_ranged:ammo", "default:axe_mese", "default:axe_diamond", "default:shovel_mese", "default:shovel_diamond", - "ctf_map:damage_cobble", "ctf_map:spike", "ctf_map:reinforced_cobble 2", + "ctf_map:damage_cobble", "ctf_map:spike", "ctf_map:reinforced_cobble 2", "ctf_map:landmine", }, physics = {sneak_glitch = true, new_move = false}, blacklisted_nodes = {"default:apple"}, From 630c2b61a6051a545ce7eae5747f25374e807bcb Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Mon, 25 Apr 2022 22:24:57 +0200 Subject: [PATCH 06/28] Enable landmine nadefight --- mods/ctf/ctf_modes/ctf_mode_nade_fight/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ctf/ctf_modes/ctf_mode_nade_fight/init.lua b/mods/ctf/ctf_modes/ctf_mode_nade_fight/init.lua index 1cd5db4c0e..c9a897cff2 100644 --- a/mods/ctf/ctf_modes/ctf_mode_nade_fight/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_nade_fight/init.lua @@ -38,6 +38,7 @@ ctf_modebase.register_mode("nade_fight", { ["ctf_map:spike" ] = {min_count = 1, max_count = 5, max_stacks = 3, rarity = 0.2}, ["ctf_map:damage_cobble" ] = {min_count = 5, max_count = 20, max_stacks = 2, rarity = 0.2}, ["ctf_map:reinforced_cobble"] = {min_count = 5, max_count = 25, max_stacks = 2, rarity = 0.2}, + ["ctf_map:landmine" ] = {min_count = 1, max_count = 3, max_stacks = 1, rarity = 0.2}, ["ctf_ranged:ammo" ] = {min_count = 3, max_count = 10, rarity = 0.3 , max_stacks = 2}, ["ctf_healing:medkit" ] = { rarity = 0.1 , max_stacks = 2}, @@ -49,6 +50,7 @@ ctf_modebase.register_mode("nade_fight", { "ctf_map:damage_cobble", "ctf_map:spike", "ctf_map:reinforced_cobble 2", + "ctf_map:landmine", }, physics = {sneak_glitch = true, new_move = false}, blacklisted_nodes = {"default:apple"}, From 139549d4b58b4f936cfea6c2b9575630e3966251 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Mon, 25 Apr 2022 22:26:26 +0200 Subject: [PATCH 07/28] Edit landmine classes --- mods/ctf/ctf_modes/ctf_mode_classes/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua index dd7565b507..c232ad2dd4 100644 --- a/mods/ctf/ctf_modes/ctf_mode_classes/init.lua +++ b/mods/ctf/ctf_modes/ctf_mode_classes/init.lua @@ -33,6 +33,7 @@ ctf_modebase.register_mode("classes", { ["ctf_map:spike" ] = {min_count = 1, max_count = 5, max_stacks = 3, rarity = 0.2}, ["ctf_map:damage_cobble" ] = {min_count = 5, max_count = 20, max_stacks = 2, rarity = 0.2}, ["ctf_map:reinforced_cobble"] = {min_count = 5, max_count = 25, max_stacks = 2, rarity = 0.2}, + ["ctf_map:landmine" ] = {min_count = 1, max_count = 5, max_stacks = 1, rarity = 0.2}, ["ctf_ranged:ammo" ] = {min_count = 3, max_count = 10, rarity = 0.3 , max_stacks = 2}, ["ctf_healing:medkit" ] = { rarity = 0.08 , max_stacks = 2}, From 6321a171e05ace993c68a92e1cd1dd234d696569 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:30:53 +0200 Subject: [PATCH 08/28] Update dependencies --- mods/ctf/ctf_map/mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/mod.conf b/mods/ctf/ctf_map/mod.conf index 378f931d9e..3fb5c31625 100644 --- a/mods/ctf/ctf_map/mod.conf +++ b/mods/ctf/ctf_map/mod.conf @@ -1,2 +1,2 @@ name = ctf_map -depends = ctf_core, ctf_teams, ctf_gui, default, ctf_changes, skybox +depends = ctf_core, ctf_teams, ctf_gui, default, ctf_changes, skybox, grenades From 41f03290a1a9b83d27b6ac319887a49ce2a2a182 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:32:58 +0200 Subject: [PATCH 09/28] reduce min_y level --- mods/ctf/ctf_map/ctf_traps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index 0fc61ede8d..fba7e2c5be 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -135,7 +135,7 @@ minetest.register_abm({ nodenames = {"ctf_map:landmine"}, interval = 1, chance = 1, - min_y = -3000, + min_y = 0, max_y = 3000, action = function(pos, node, active_object_count, active_object_count_wider) local objs = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, From 97bd61bdf20f8702b8890cf61ea01fbba0e8c6a7 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Wed, 20 Jul 2022 21:30:07 +0200 Subject: [PATCH 10/28] Update ctf_traps.lua make landmines walkable, remove y limits, prevent friendly fire and triggering, do not save player's team, add damage group, increase damage --- mods/ctf/ctf_map/ctf_traps.lua | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index eac510c34d..4539ee7b99 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -110,7 +110,7 @@ minetest.register_node("ctf_map:landmine", { inventory_image = "ctf_map_landmine.png", paramtype = "light", sunlight_propagates = true, - walkable = false, + walkable = true, groups = {cracky=1, level=2}, node_box = { type = "fixed", @@ -125,8 +125,7 @@ minetest.register_node("ctf_map:landmine", { local name = placer:get_player_name() meta:set_string("placer", minetest.serialize({ - team = ctf_teams.get(name), - name = name, + name = name })) end }) @@ -134,20 +133,24 @@ minetest.register_node("ctf_map:landmine", { minetest.register_abm({ label = "Landmine", nodenames = {"ctf_map:landmine"}, - interval = 1, + interval = 0.5, chance = 1, - min_y = 0, - max_y = 3000, action = function(pos, node, active_object_count, active_object_count_wider) - local objs = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, + local meta = minetest.get_meta(pos) + local placer = minetest.deserialize(meta:get_string("placer")) + local is_team = 0 + local trigger = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) - if #objs == 0 then + for _, v in pairs(trigger) do + if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer.name) then + is_team = is_team + 1 + end + end + if is_team == 0 then return else local plyrs = minetest.get_objects_inside_radius(pos, 3) - local meta = minetest.get_meta(pos) - local placer = minetest.deserialize(meta:get_string("placer")) - local placer_obj = placer and minetest.get_player_by_name(placer.name) + local placerobj = placer and minetest.get_player_by_name(placer.name) minetest.add_particlespawner({ amount = 20, @@ -189,11 +192,13 @@ minetest.register_abm({ }) for _, v in pairs(plyrs) do - if placer_obj then - v:punch(placer_obj, 1, {damage_groups = {fleshy = 10}}, nil) - else - local chp = v:get_hp() - v:set_hp(chp - 10) + if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer.name) then + if placerobj then + v:punch(placerobj, 1, {damage_groups = {fleshy = 15, landmine = 1}}) + else + local chp = v:get_hp() + v:set_hp(chp - 15) + end end end minetest.remove_node(pos) From 5921b744dc73b728e92b2204de97f60330ef7138 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Wed, 20 Jul 2022 21:31:37 +0200 Subject: [PATCH 11/28] Add landmine damage_group texture --- mods/ctf/ctf_modebase/features.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ctf/ctf_modebase/features.lua b/mods/ctf/ctf_modebase/features.lua index bc19d4caa3..570214aec2 100644 --- a/mods/ctf/ctf_modebase/features.lua +++ b/mods/ctf/ctf_modebase/features.lua @@ -18,6 +18,7 @@ local damage_group_textures = { knockback_grenade = "ctf_mode_nade_fight_knockback_grenade.png", black_hole_grenade = "ctf_mode_nade_fight_black_hole_grenade.png", damage_cobble = "ctf_map_damage_cobble.png", + landmine = "ctf_map_landmine.png", } local function get_weapon_image(hitter, tool_capabilities) From eea20607b3ac10dafe55be17d95c4def9d5b2351 Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Mon, 8 Aug 2022 20:46:22 +0200 Subject: [PATCH 12/28] Update ctf_traps.lua --- mods/ctf/ctf_map/ctf_traps.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index 4539ee7b99..4c09fc2b65 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -124,9 +124,7 @@ minetest.register_node("ctf_map:landmine", { local meta = minetest.get_meta(pos) local name = placer:get_player_name() - meta:set_string("placer", minetest.serialize({ - name = name - })) + meta:set_string("placer", name) end }) From 096bebb0313f18d1f1c092fac636fa95495fdd4e Mon Sep 17 00:00:00 2001 From: xenonca Date: Mon, 10 Oct 2022 20:21:10 +0200 Subject: [PATCH 13/28] Fix trigger team detection --- mods/ctf/ctf_map/ctf_traps.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index f59a3a1f4d..3be28b5a92 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -135,20 +135,22 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) - local placer = minetest.deserialize(meta:get_string("placer")) + local placer = meta:get_string("placer") local is_team = 0 local trigger = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) for _, v in pairs(trigger) do - if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer.name) then + if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer) then is_team = is_team + 1 + minetest.chat_send_all(tostring(ctf_teams.get(v:get_player_name())) .. " and " .. tostring(ctf_teams.get(placer))) end end if is_team == 0 then return else + minetest.chat_send_all(is_team) local plyrs = minetest.get_objects_inside_radius(pos, 3) - local placerobj = placer and minetest.get_player_by_name(placer.name) + local placerobj = placer and minetest.get_player_by_name(placer) minetest.add_particlespawner({ amount = 20, @@ -190,7 +192,7 @@ minetest.register_abm({ }) for _, v in pairs(plyrs) do - if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer.name) then + if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer) then if placerobj then v:punch(placerobj, 1, {damage_groups = {fleshy = 15, landmine = 1}}) else From a10e502a3e37c5336f24a39876f4a27c9578604e Mon Sep 17 00:00:00 2001 From: Xenon <36995016+xenonca@users.noreply.github.com> Date: Sat, 25 Feb 2023 21:28:24 +0100 Subject: [PATCH 14/28] Save placer team --- mods/ctf/ctf_map/ctf_traps.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index d19757927c..e6f1063938 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -197,8 +197,10 @@ minetest.register_node("ctf_map:landmine", { after_place_node = function(pos, placer, itemstack, pointed_thing) local meta = minetest.get_meta(pos) local name = placer:get_player_name() + local pteam = ctf_teams.get(placer) meta:set_string("placer", name) + meta:set_string("pteam", pteam) end }) @@ -210,19 +212,18 @@ minetest.register_abm({ action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) local placer = meta:get_string("placer") + local pteam = meta:get_string("pteam") local is_team = 0 local trigger = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) for _, v in pairs(trigger) do - if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer) then + if v:is_player() and ctf_teams.get(v:get_player_name()) ~= pteam then is_team = is_team + 1 - minetest.chat_send_all(tostring(ctf_teams.get(v:get_player_name())) .. " and " .. tostring(ctf_teams.get(placer))) end end if is_team == 0 then return else - minetest.chat_send_all(is_team) local plyrs = minetest.get_objects_inside_radius(pos, 3) local placerobj = placer and minetest.get_player_by_name(placer) @@ -266,7 +267,7 @@ minetest.register_abm({ }) for _, v in pairs(plyrs) do - if v:is_player() and ctf_teams.get(v:get_player_name()) ~= ctf_teams.get(placer) then + if v:is_player() and ctf_teams.get(v:get_player_name()) ~= pteam then if placerobj then v:punch(placerobj, 1, {damage_groups = {fleshy = 15, landmine = 1}}) else From 861554fa0f943768641232469e6cf32e0c7d6331 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 17:12:08 +0330 Subject: [PATCH 15/28] complete landmines --- mods/ctf/ctf_map/ctf_traps.lua | 204 +++++++++++++++++++++------------ 1 file changed, 131 insertions(+), 73 deletions(-) diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index 0163fcd245..51fe22e8e2 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -1,3 +1,96 @@ +local landmines = { + -- { x = ..., y = ..., z = ...} +} + +local landmine_globalstep_counter = 0.0 + +local function is_self_landmine(object_ref, pos) + local meta = minetest.get_meta(pos) + local team = meta:get_string("pteam") + local placer = meta:get_string("placer") + local pname = object_ref:get_player_name() + if not pname then + return nil -- the object ref is not a player + end + if pname == placer then + return true -- it's self landmine + end + if ctf_teams.get(pname) == team then + return true -- it's self landmine + end + + return false -- it's someone else's landmine +end + +local function landmine_explode(pos) + local near_objs = minetest.get_objects_inside_radius(pos, 3) + local meta = minetest.get_meta(pos) + local placer = meta:get_string("placer") + local placerobj = placer and minetest.get_player_by_name(placer) + + minetest.add_particlespawner({ + amount = 20, + time = 0.5, + minpos = vector.subtract(pos, 3), + maxpos = vector.add(pos, 3), + minvel = {x = 0, y = 5, z = 0}, + maxvel = {x = 0, y = 7, z = 0}, + minacc = {x = 0, y = 1, z = 0}, + maxacc = {x = 0, y = 1, z = 0}, + minexptime = 0.3, + maxexptime = 0.6, + minsize = 7, + maxsize = 10, + collisiondetection = true, + collision_removal = false, + vertical = false, + texture = "grenades_smoke.png", + }) + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = 0.3, + size = 15, + collisiondetection = false, + collision_removal = false, + object_collision = false, + vertical = false, + texture = "grenades_boom.png", + glow = 10 + }) + + minetest.sound_play("grenades_explode", { + pos = pos, + gain = 1.0, + max_hear_distance = 64, + }) + + for _, obj in pairs(near_objs) do + if is_self_landmine(obj, pos) == false then + if placerobj then + obj:punch( + placerobj, + 1, + { + damage_groups = { + fleshy = 15, + landmine = 1 + } + } + ) + else + local chp = obj:get_hp() + obj:set_hp(chp - 15) + end + end + end + minetest.remove_node(pos) + +end + + minetest.register_node("ctf_map:unwalkable_dirt", { description = "Unwalkable Dirt", tiles = {"default_dirt.png^[colorize:#ffff00:19"}, @@ -225,7 +318,10 @@ minetest.register_node("ctf_map:reinforced_cobble_hardened", { minetest.register_node("ctf_map:landmine", { description = "Landmine", drawtype = "nodebox", - tiles = {"ctf_map_landmine.png", "ctf_map_landmine.png^[transformFY"}, + tiles = { + "ctf_map_landmine.png", + "ctf_map_landmine.png^[transformFY" + }, inventory_image = "ctf_map_landmine.png", paramtype = "light", sunlight_propagates = true, @@ -246,82 +342,44 @@ minetest.register_node("ctf_map:landmine", { meta:set_string("placer", name) meta:set_string("pteam", pteam) + end, + on_punch = function(pos, _node, puncher, pointed_thing) + if is_self_landmine(puncher, pos) == false then + landmine_explode(pos) + end end }) -minetest.register_abm({ - label = "Landmine", - nodenames = {"ctf_map:landmine"}, - interval = 0.5, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local meta = minetest.get_meta(pos) - local placer = meta:get_string("placer") - local pteam = meta:get_string("pteam") - local is_team = 0 - local trigger = minetest.get_objects_in_area({x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, - {x=pos.x+0.5, y=pos.y-0.3, z=pos.z+0.5}) - for _, v in pairs(trigger) do - if v:is_player() and ctf_teams.get(v:get_player_name()) ~= pteam then - is_team = is_team + 1 + + + +minetest.register_globalstep(function(dtime) + landmine_globalstep_counter = landmine_globalstep_counter + dtime + if landmine_globalstep_counter < 0.25 then + return + end + landmine_globalstep_counter = 0.0 + for _idx, pos in pairs(landmines) do + local near_objs = minetest.get_objects_in_area( + { + x = pos.x-0.5, + y = pos.y-0.5, + z = pos.z-0.5 + }, + { + x = pos.x+0.5, + y = pos.y-0.3, + z = pos.z+0.5 + }) + local must_explode = false + for _, obj in pairs(near_objs) do + if is_self_landmine(obj, pos) == false then + must_explode = true + break end end - if is_team == 0 then - return - else - local plyrs = minetest.get_objects_inside_radius(pos, 3) - local placerobj = placer and minetest.get_player_by_name(placer) - - minetest.add_particlespawner({ - amount = 20, - time = 0.5, - minpos = vector.subtract(pos, 3), - maxpos = vector.add(pos, 3), - minvel = {x = 0, y = 5, z = 0}, - maxvel = {x = 0, y = 7, z = 0}, - minacc = {x = 0, y = 1, z = 0}, - maxacc = {x = 0, y = 1, z = 0}, - minexptime = 0.3, - maxexptime = 0.6, - minsize = 7, - maxsize = 10, - collisiondetection = true, - collision_removal = false, - vertical = false, - texture = "grenades_smoke.png", - }) - - minetest.add_particle({ - pos = pos, - velocity = {x=0, y=0, z=0}, - acceleration = {x=0, y=0, z=0}, - expirationtime = 0.3, - size = 15, - collisiondetection = false, - collision_removal = false, - object_collision = false, - vertical = false, - texture = "grenades_boom.png", - glow = 10 - }) - - minetest.sound_play("grenades_explode", { - pos = pos, - gain = 1.0, - max_hear_distance = 64, - }) - - for _, v in pairs(plyrs) do - if v:is_player() and ctf_teams.get(v:get_player_name()) ~= pteam then - if placerobj then - v:punch(placerobj, 1, {damage_groups = {fleshy = 15, landmine = 1}}) - else - local chp = v:get_hp() - v:set_hp(chp - 15) - end - end - end - minetest.remove_node(pos) + if must_explode then + landmine_explode(pos) end end -}) +end) From bd87b345c1b1eb7ec1879fcac6a02db63dc8be36 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 18:04:57 +0330 Subject: [PATCH 16/28] make landmines working fine --- mods/ctf/ctf_landmine/init.lua | 395 ++++++++++++++++++ mods/ctf/ctf_landmine/mod.conf | 2 + .../textures/ctf_landmine_landmine.png} | Bin mods/ctf/ctf_map/ctf_traps.lua | 162 ------- mods/ctf/ctf_map/init.lua | 2 +- mods/ctf/ctf_map/maps | 2 +- mods/ctf/ctf_map/mod.conf | 4 +- 7 files changed, 401 insertions(+), 166 deletions(-) create mode 100644 mods/ctf/ctf_landmine/init.lua create mode 100644 mods/ctf/ctf_landmine/mod.conf rename mods/ctf/{ctf_map/textures/ctf_map_landmine.png => ctf_landmine/textures/ctf_landmine_landmine.png} (100%) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua new file mode 100644 index 0000000000..41073fd51f --- /dev/null +++ b/mods/ctf/ctf_landmine/init.lua @@ -0,0 +1,395 @@ +local landmines = { + -- { x = ..., y = ..., z = ...} +} + +local landmine_globalstep_counter = 0.0 +local LANDMINE_COUNTER_THRESHOLD = 0.025 + +local function is_self_landmine(object_ref, pos) + local meta = minetest.get_meta(pos) + local team = meta:get_string("pteam") + local placer = meta:get_string("placer") + local pname = object_ref:get_player_name() + if pname == "" then + return nil -- the object ref is not a player + end + if pname == placer then + return true -- it's self landmine + end + if ctf_teams.get(object_ref) == team then + return true -- it's self landmine + end + + return false -- it's someone else's landmine +end + +local function landmine_explode(pos) + local near_objs = minetest.get_objects_inside_radius(pos, 3) + local meta = minetest.get_meta(pos) + local placer = meta:get_string("placer") + local placerobj = placer and minetest.get_player_by_name(placer) + + minetest.add_particlespawner({ + amount = 20, + time = 0.5, + minpos = vector.subtract(pos, 3), + maxpos = vector.add(pos, 3), + minvel = {x = 0, y = 5, z = 0}, + maxvel = {x = 0, y = 7, z = 0}, + minacc = {x = 0, y = 1, z = 0}, + maxacc = {x = 0, y = 1, z = 0}, + minexptime = 0.3, + maxexptime = 0.6, + minsize = 7, + maxsize = 10, + collisiondetection = true, + collision_removal = false, + vertical = false, + texture = "grenades_smoke.png", + }) + + minetest.add_particle({ + pos = pos, + velocity = {x=0, y=0, z=0}, + acceleration = {x=0, y=0, z=0}, + expirationtime = 0.3, + size = 15, + collisiondetection = false, + collision_removal = false, + object_collision = false, + vertical = false, + texture = "grenades_boom.png", + glow = 10 + }) + + minetest.sound_play("grenades_explode", { + pos = pos, + gain = 1.0, + max_hear_distance = 64, + }) + + for _, obj in pairs(near_objs) do + if is_self_landmine(obj, pos) == false then + if placerobj then + obj:punch( + placerobj, + 1, + { + damage_groups = { + fleshy = 15, + landmine = 1 + } + } + ) + else + local chp = obj:get_hp() + obj:set_hp(chp - 15) + end + end + end + minetest.remove_node(pos) + for idx, pos in ipairs(landmines) do + if pos == pos then + table.remove(landmines, idx) + break + end + end +end + + +minetest.register_node("ctf_traps:unwalkable_dirt", { + description = "Unwalkable Dirt", + tiles = {"default_dirt.png^[colorize:#ffff00:19"}, + is_ground_content = false, + walkable = false, + groups = {crumbly=3, soil=1} +}) + +minetest.register_node("ctf_traps:unwalkable_stone", { + description = "Unwalkable Stone", + tiles = {"default_stone.png^[colorize:#ffff00:17"}, + is_ground_content = false, + walkable = false, + groups = {cracky=3, stone=1} +}) + +minetest.register_node("ctf_traps:unwalkable_cobble", { + description = "Unwalkable Cobblestone", + tiles = {"default_cobble.png^[colorize:#ffff00:15"}, + is_ground_content = false, + walkable = false, + groups = {cracky=3, stone=2} +}) + +-- +--- Spike Trap +-- + +minetest.register_node("ctf_traps:spike", { + description = "Spike\n7 DPS", + drawtype = "plantlike", + tiles = {"ctf_traps_spike.png"}, + inventory_image = "ctf_traps_spike.png", + use_texture_alpha = "clip", + paramtype = "light", + paramtype2 = "meshoptions", + sunlight_propagates = true, + walkable = false, + damage_per_second = 7, + groups = {cracky=1, level=2}, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + on_place = function(itemstack, placer, pointed_thing) + local pteam = ctf_teams.get(placer) + + if pteam then + if not ctf_core.pos_inside(pointed_thing.above, ctf_teams.get_team_territory(pteam)) then + minetest.chat_send_player(placer:get_player_name(), "You can only place spikes in your own territory!") + return itemstack + end + + local newitemstack = ItemStack("ctf_traps:spike_"..pteam) + newitemstack:set_count(itemstack:get_count()) + + local result = minetest.item_place(newitemstack, placer, pointed_thing, 34) + + if result then + itemstack:set_count(result:get_count()) + end + + return itemstack + end + + return minetest.item_place(itemstack, placer, pointed_thing, 34) + end +}) + +for _, team in ipairs(ctf_teams.teamlist) do + if not ctf_teams.team[team].not_playing then + local spikecolor = ctf_teams.team[team].color + + minetest.register_node("ctf_traps:spike_"..team, { + description = HumanReadable(team).." Team Spike", + drawtype = "plantlike", + tiles = {"ctf_traps_spike.png^[colorize:"..spikecolor..":150"}, + inventory_image = "ctf_traps_spike.png^[colorize:"..spikecolor..":150", + use_texture_alpha = "clip", + paramtype = "light", + paramtype2 = "meshoptions", + sunlight_propagates = true, + walkable = false, + damage_per_second = 7, + groups = {cracky=1, level=2}, + drop = "ctf_traps:spike", + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + on_place = function(itemstack, placer, pointed_thing) + return minetest.item_place(itemstack, placer, pointed_thing, 34) + end + }) + end +end + +minetest.register_on_player_hpchange(function(player, hp_change, reason) + if reason.type == "node_damage" then + local team = ctf_teams.get(player) + + if team and reason.node == string.format("ctf_traps:spike_%s", team) then + return 0, true + end + end + + return hp_change +end, true) + +-- +-- Damage Cobble +-- + +local function damage_cobble_dig(pos, node, digger) + if not digger:is_player() then return end + + local digger_name = digger:get_player_name() + local digger_team = ctf_teams.get(digger_name) + + local meta = minetest.get_meta(pos) + local placer_name = meta:get_string("placer") + meta:set_string("placer", "") + + local placer_team = ctf_teams.get(placer_name) + if placer_team ~= digger_team and not ctf_modebase.match_started then + return + end + + if digger_team == placer_team then return end + + local placerobj = minetest.get_player_by_name(placer_name) + + if placerobj then + digger:punch(placerobj, 1, { + damage_groups = { + fleshy = 7, + damage_cobble = 1, + } + }) + else + digger:set_hp(digger:get_hp() - 7) + end + + minetest.remove_node(pos) + return true +end + +minetest.register_node("ctf_traps:damage_cobble", { + description = "Damage Cobble\n(Damages any enemy that breaks it)", + tiles = {"ctf_traps_damage_cobble.png"}, + is_ground_content = false, + walkable = true, + groups = {cracky=3, stone=2}, + on_ranged_shoot = function(pos, node, shooter, type) + if type == "pistol" then + return + end + + if not damage_cobble_dig(pos, node, shooter) then + return minetest.dig_node(pos) + end + end, + on_dig = function(pos, node, digger) + if not damage_cobble_dig(pos, node, digger) then + return minetest.node_dig(pos, node, digger) + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local meta = minetest.get_meta(pos) + meta:set_string("placer", placer:get_player_name()) + end +}) + +minetest.register_node("ctf_traps:reinforced_cobble", { + description = "Reinforced Cobblestone", + tiles = {"ctf_traps_reinforced_cobble.png"}, + is_ground_content = false, + groups = {cracky = 3, stone = 2}, + sounds = default.node_sound_stone_defaults(), + on_punch = function(pos, node, digger) + local meta = minetest.get_meta(pos) + local placer_team = meta:get_string("placer_team") + local digger_team = ctf_teams.get(digger) + if placer_team ~= digger_team then + minetest.set_node(pos, {name = "ctf_traps:reinforced_cobble_hardened"}) + meta = minetest.get_meta(pos) + meta:set_string("placer_team", placer_team) + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local meta = minetest.get_meta(pos) + meta:set_string("placer_team", ctf_teams.get(placer)) + end, + on_dig = function(pos, node, digger) + local meta = minetest.get_meta(pos) + meta:set_string("placer_team", "") + minetest.node_dig(pos, node, digger) + end +}) + +minetest.register_node("ctf_traps:reinforced_cobble_hardened", { + description = "Reinforced Cobblestone Hardened\nYou're not meant to use this", + tiles = {"ctf_traps_reinforced_cobble.png"}, + is_ground_content = false, + groups = {cracky = 1, stone = 2}, + sounds = default.node_sound_stone_defaults(), + drop = "ctf_traps:reinforced_cobble", + on_punch = function(pos, node, digger) + local meta = minetest.get_meta(pos) + local placer_team = meta:get_string("placer_team") + local digger_team = ctf_teams.get(digger) + if placer_team == digger_team then + minetest.set_node(pos, {name = "ctf_traps:reinforced_cobble"}) + meta = minetest.get_meta(pos) + meta:set_string("placer_team", placer_team) + end + end, + on_dig = function(pos, node, digger) + local meta = minetest.get_meta(pos) + meta:set_string("placer_team", "") + minetest.node_dig(pos, node, digger) + end +}) + +minetest.register_node("ctf_traps:landmine", { + description = "Landmine", + drawtype = "nodebox", + tiles = { + "ctf_traps_landmine.png", + "ctf_traps_landmine.png^[transformFY" + }, + inventory_image = "ctf_traps_landmine.png", + paramtype = "light", + sunlight_propagates = true, + walkable = true, + groups = {cracky=1, level=2}, + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, + }, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, + }, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local meta = minetest.get_meta(pos) + local name = placer:get_player_name() + local pteam = ctf_teams.get(placer) + + meta:set_string("placer", name) + meta:set_string("pteam", pteam) + table.insert(landmines, pos) + end, + on_punch = function(pos, _node, puncher, pointed_thing) + if is_self_landmine(puncher, pos) == false then + landmine_explode(pos) + end + end +}) + + + + +minetest.register_globalstep(function(dtime) + if #landmines == 0 then + return + end + landmine_globalstep_counter = landmine_globalstep_counter + dtime + if landmine_globalstep_counter < LANDMINE_COUNTER_THRESHOLD then + return + end + landmine_globalstep_counter = 0.0 + for _idx, pos in pairs(landmines) do + local near_objs = minetest.get_objects_in_area( + { + x = pos.x-0.5, + y = pos.y-0.5, + z = pos.z-0.5 + }, + { + x = pos.x+0.5, + y = pos.y-0.3, + z = pos.z+0.5 + }) + local must_explode = false + for _, obj in pairs(near_objs) do + if is_self_landmine(obj, pos) == false then + must_explode = true + break + end + end + if must_explode then + landmine_explode(pos) + end + end +end) diff --git a/mods/ctf/ctf_landmine/mod.conf b/mods/ctf/ctf_landmine/mod.conf new file mode 100644 index 0000000000..d7fef8985b --- /dev/null +++ b/mods/ctf/ctf_landmine/mod.conf @@ -0,0 +1,2 @@ +name = ctf_traps +depends = ctf_teams, grenades, default diff --git a/mods/ctf/ctf_map/textures/ctf_map_landmine.png b/mods/ctf/ctf_landmine/textures/ctf_landmine_landmine.png similarity index 100% rename from mods/ctf/ctf_map/textures/ctf_map_landmine.png rename to mods/ctf/ctf_landmine/textures/ctf_landmine_landmine.png diff --git a/mods/ctf/ctf_map/ctf_traps.lua b/mods/ctf/ctf_map/ctf_traps.lua index 51fe22e8e2..077e5bfe0a 100644 --- a/mods/ctf/ctf_map/ctf_traps.lua +++ b/mods/ctf/ctf_map/ctf_traps.lua @@ -1,96 +1,3 @@ -local landmines = { - -- { x = ..., y = ..., z = ...} -} - -local landmine_globalstep_counter = 0.0 - -local function is_self_landmine(object_ref, pos) - local meta = minetest.get_meta(pos) - local team = meta:get_string("pteam") - local placer = meta:get_string("placer") - local pname = object_ref:get_player_name() - if not pname then - return nil -- the object ref is not a player - end - if pname == placer then - return true -- it's self landmine - end - if ctf_teams.get(pname) == team then - return true -- it's self landmine - end - - return false -- it's someone else's landmine -end - -local function landmine_explode(pos) - local near_objs = minetest.get_objects_inside_radius(pos, 3) - local meta = minetest.get_meta(pos) - local placer = meta:get_string("placer") - local placerobj = placer and minetest.get_player_by_name(placer) - - minetest.add_particlespawner({ - amount = 20, - time = 0.5, - minpos = vector.subtract(pos, 3), - maxpos = vector.add(pos, 3), - minvel = {x = 0, y = 5, z = 0}, - maxvel = {x = 0, y = 7, z = 0}, - minacc = {x = 0, y = 1, z = 0}, - maxacc = {x = 0, y = 1, z = 0}, - minexptime = 0.3, - maxexptime = 0.6, - minsize = 7, - maxsize = 10, - collisiondetection = true, - collision_removal = false, - vertical = false, - texture = "grenades_smoke.png", - }) - - minetest.add_particle({ - pos = pos, - velocity = {x=0, y=0, z=0}, - acceleration = {x=0, y=0, z=0}, - expirationtime = 0.3, - size = 15, - collisiondetection = false, - collision_removal = false, - object_collision = false, - vertical = false, - texture = "grenades_boom.png", - glow = 10 - }) - - minetest.sound_play("grenades_explode", { - pos = pos, - gain = 1.0, - max_hear_distance = 64, - }) - - for _, obj in pairs(near_objs) do - if is_self_landmine(obj, pos) == false then - if placerobj then - obj:punch( - placerobj, - 1, - { - damage_groups = { - fleshy = 15, - landmine = 1 - } - } - ) - else - local chp = obj:get_hp() - obj:set_hp(chp - 15) - end - end - end - minetest.remove_node(pos) - -end - - minetest.register_node("ctf_map:unwalkable_dirt", { description = "Unwalkable Dirt", tiles = {"default_dirt.png^[colorize:#ffff00:19"}, @@ -314,72 +221,3 @@ minetest.register_node("ctf_map:reinforced_cobble_hardened", { minetest.node_dig(pos, node, digger) end }) - -minetest.register_node("ctf_map:landmine", { - description = "Landmine", - drawtype = "nodebox", - tiles = { - "ctf_map_landmine.png", - "ctf_map_landmine.png^[transformFY" - }, - inventory_image = "ctf_map_landmine.png", - paramtype = "light", - sunlight_propagates = true, - walkable = true, - groups = {cracky=1, level=2}, - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, - }, - selection_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, - }, - after_place_node = function(pos, placer, itemstack, pointed_thing) - local meta = minetest.get_meta(pos) - local name = placer:get_player_name() - local pteam = ctf_teams.get(placer) - - meta:set_string("placer", name) - meta:set_string("pteam", pteam) - end, - on_punch = function(pos, _node, puncher, pointed_thing) - if is_self_landmine(puncher, pos) == false then - landmine_explode(pos) - end - end -}) - - - - -minetest.register_globalstep(function(dtime) - landmine_globalstep_counter = landmine_globalstep_counter + dtime - if landmine_globalstep_counter < 0.25 then - return - end - landmine_globalstep_counter = 0.0 - for _idx, pos in pairs(landmines) do - local near_objs = minetest.get_objects_in_area( - { - x = pos.x-0.5, - y = pos.y-0.5, - z = pos.z-0.5 - }, - { - x = pos.x+0.5, - y = pos.y-0.3, - z = pos.z+0.5 - }) - local must_explode = false - for _, obj in pairs(near_objs) do - if is_self_landmine(obj, pos) == false then - must_explode = true - break - end - end - if must_explode then - landmine_explode(pos) - end - end -end) diff --git a/mods/ctf/ctf_map/init.lua b/mods/ctf/ctf_map/init.lua index 43b4469aa0..11081b59f9 100644 --- a/mods/ctf/ctf_map/init.lua +++ b/mods/ctf/ctf_map/init.lua @@ -88,7 +88,7 @@ ctf_core.include_files( "map_functions.lua", "editor_functions.lua", "mapedit_gui.lua", - "ctf_traps.lua" + "ctf_traps.lua", ) local directory = minetest.get_modpath(minetest.get_current_modname()) .. "/maps/" diff --git a/mods/ctf/ctf_map/maps b/mods/ctf/ctf_map/maps index 631fc3f699..3a375ae9a8 160000 --- a/mods/ctf/ctf_map/maps +++ b/mods/ctf/ctf_map/maps @@ -1 +1 @@ -Subproject commit 631fc3f69950419afe9164aecef01881f36b19f3 +Subproject commit 3a375ae9a82a9308a0677e23a8ac7367d54fc637 diff --git a/mods/ctf/ctf_map/mod.conf b/mods/ctf/ctf_map/mod.conf index 51eaeebe0c..fde0f366ad 100644 --- a/mods/ctf/ctf_map/mod.conf +++ b/mods/ctf/ctf_map/mod.conf @@ -1,3 +1,3 @@ name = ctf_map -depends = ctf_core, ctf_teams, ctf_gui, default, ctf_changes, skybox, grenades -optional_depends = worldedit \ No newline at end of file +depends = ctf_core, ctf_teams, ctf_gui, default, ctf_changes, skybox +optional_depends = worldedit From cace35f8c4f1f3f8e13c311b5bd03c6c86818eb4 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 18:07:42 +0330 Subject: [PATCH 17/28] optimize texture image of landmine --- .../textures/ctf_landmine_landmine.png | Bin 5390 -> 4961 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ctf/ctf_landmine/textures/ctf_landmine_landmine.png b/mods/ctf/ctf_landmine/textures/ctf_landmine_landmine.png index 82f1d23f23d85fc3a6d9ae0a924c2ee4c5c437fe..7a5540b954df27401334a7fb7febebece5cd580d 100644 GIT binary patch literal 4961 zcmbtY2Ut_d7M>)KMv>5@LDjs6fl)nY9(G$sbr&}rvm+jm$IaIKr!uYcgu^jn_I+Gl^@a^qg=K%7-gVWWE$6}V zrjtX*mf`RnL_e=zjVhz94K<4Ld;9hctjL|DuV_%f%io-CaH@Revp-I(S#vOzwEfZY z7gxFtKJ>z-xk&8y=vqsZB%3?7bS~XtciyAaDZ_gP@2Y&h-f`MbpWBW{{nE_LaW%1? zOE%IhTr@qEK26&^smyMFjm{&5;58bZ3%2%nY-@aZAw=tZ%rxPFYh*V0XLkyL#CS@r z&ekz#h~8E1-nIPlx!GZ#Hasl75P&soNAKh6_bz`m`;WVI!R6aUrD%HPlXLa6+Q10y zYIM+zp~HekZ}5_txI5)@kBQYMPI`59Zc*0Cxcib5)fbjEKT=jn?>2U>H@5WJ$p!bW z3{;4kuUcF^`uOdQd+onrigzB^l#rF<9NOgG`;7MT#o&v5k-rdzjX9cK%gKCSlIGfySGh^TT|Dc(nRAo1MwA-oZL?~>%kE3`-Mi-6 zJ)OFf)u~FeoRU!#I4lV*E^vM=NGhXPSoSSFre!QSbb+M4pZ`hDdM zu)}n-Dsz9*yQ}#@PX3KfNe7#nL@mCI;@r#S`oFCuTn=5^Qk7XY*{MBk@IjWs2ls1D z(_CNtyq=mjq!kG3;{))SURenDg>~-cw&7D<67kZAj&eA@~ zX}9QKwg|nq`*iu@9<`svE-PmlNL z3*Rx{y!qv!JtxnH7o{tZV>c9~JE*_7zwTb~qDFtKS2dx{d!6JLrG(Sg6{{CyUH6#E z?XE9W<+xN-T<3h4qe}*pX50@9-ttp?rw<3$f3WOqa^RF!`=Vshs;~$rw^M!@ZKTY1 z9;t8qEt4|?wCpJK>$`OhFCpC_vuhSAJUjJ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5RO+U;=cT?N_saA)s`)%GCsuQ|eDjI+-JXoL zeH(ZY`V&w-lPxEi>L6CQH<&*F44o@vw(hOmb^YY>UyN3eaD5B}@~FZpLt!S{??W|m zC>nepUut Date: Tue, 11 Jun 2024 18:08:28 +0330 Subject: [PATCH 18/28] wrong comma --- mods/ctf/ctf_map/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/init.lua b/mods/ctf/ctf_map/init.lua index 11081b59f9..43b4469aa0 100644 --- a/mods/ctf/ctf_map/init.lua +++ b/mods/ctf/ctf_map/init.lua @@ -88,7 +88,7 @@ ctf_core.include_files( "map_functions.lua", "editor_functions.lua", "mapedit_gui.lua", - "ctf_traps.lua", + "ctf_traps.lua" ) local directory = minetest.get_modpath(minetest.get_current_modname()) .. "/maps/" From ae4e29e59f68f8cc4fe0d226868fa5cddcaf9fa9 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 18:13:11 +0330 Subject: [PATCH 19/28] final corrections --- mods/ctf/ctf_landmine/init.lua | 233 +-------------------------------- mods/ctf/ctf_landmine/mod.conf | 2 +- 2 files changed, 5 insertions(+), 230 deletions(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index 41073fd51f..7d00477b8a 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -96,239 +96,14 @@ local function landmine_explode(pos) end end - -minetest.register_node("ctf_traps:unwalkable_dirt", { - description = "Unwalkable Dirt", - tiles = {"default_dirt.png^[colorize:#ffff00:19"}, - is_ground_content = false, - walkable = false, - groups = {crumbly=3, soil=1} -}) - -minetest.register_node("ctf_traps:unwalkable_stone", { - description = "Unwalkable Stone", - tiles = {"default_stone.png^[colorize:#ffff00:17"}, - is_ground_content = false, - walkable = false, - groups = {cracky=3, stone=1} -}) - -minetest.register_node("ctf_traps:unwalkable_cobble", { - description = "Unwalkable Cobblestone", - tiles = {"default_cobble.png^[colorize:#ffff00:15"}, - is_ground_content = false, - walkable = false, - groups = {cracky=3, stone=2} -}) - --- ---- Spike Trap --- - -minetest.register_node("ctf_traps:spike", { - description = "Spike\n7 DPS", - drawtype = "plantlike", - tiles = {"ctf_traps_spike.png"}, - inventory_image = "ctf_traps_spike.png", - use_texture_alpha = "clip", - paramtype = "light", - paramtype2 = "meshoptions", - sunlight_propagates = true, - walkable = false, - damage_per_second = 7, - groups = {cracky=1, level=2}, - selection_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, - }, - on_place = function(itemstack, placer, pointed_thing) - local pteam = ctf_teams.get(placer) - - if pteam then - if not ctf_core.pos_inside(pointed_thing.above, ctf_teams.get_team_territory(pteam)) then - minetest.chat_send_player(placer:get_player_name(), "You can only place spikes in your own territory!") - return itemstack - end - - local newitemstack = ItemStack("ctf_traps:spike_"..pteam) - newitemstack:set_count(itemstack:get_count()) - - local result = minetest.item_place(newitemstack, placer, pointed_thing, 34) - - if result then - itemstack:set_count(result:get_count()) - end - - return itemstack - end - - return minetest.item_place(itemstack, placer, pointed_thing, 34) - end -}) - -for _, team in ipairs(ctf_teams.teamlist) do - if not ctf_teams.team[team].not_playing then - local spikecolor = ctf_teams.team[team].color - - minetest.register_node("ctf_traps:spike_"..team, { - description = HumanReadable(team).." Team Spike", - drawtype = "plantlike", - tiles = {"ctf_traps_spike.png^[colorize:"..spikecolor..":150"}, - inventory_image = "ctf_traps_spike.png^[colorize:"..spikecolor..":150", - use_texture_alpha = "clip", - paramtype = "light", - paramtype2 = "meshoptions", - sunlight_propagates = true, - walkable = false, - damage_per_second = 7, - groups = {cracky=1, level=2}, - drop = "ctf_traps:spike", - selection_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, - }, - on_place = function(itemstack, placer, pointed_thing) - return minetest.item_place(itemstack, placer, pointed_thing, 34) - end - }) - end -end - -minetest.register_on_player_hpchange(function(player, hp_change, reason) - if reason.type == "node_damage" then - local team = ctf_teams.get(player) - - if team and reason.node == string.format("ctf_traps:spike_%s", team) then - return 0, true - end - end - - return hp_change -end, true) - --- --- Damage Cobble --- - -local function damage_cobble_dig(pos, node, digger) - if not digger:is_player() then return end - - local digger_name = digger:get_player_name() - local digger_team = ctf_teams.get(digger_name) - - local meta = minetest.get_meta(pos) - local placer_name = meta:get_string("placer") - meta:set_string("placer", "") - - local placer_team = ctf_teams.get(placer_name) - if placer_team ~= digger_team and not ctf_modebase.match_started then - return - end - - if digger_team == placer_team then return end - - local placerobj = minetest.get_player_by_name(placer_name) - - if placerobj then - digger:punch(placerobj, 1, { - damage_groups = { - fleshy = 7, - damage_cobble = 1, - } - }) - else - digger:set_hp(digger:get_hp() - 7) - end - - minetest.remove_node(pos) - return true -end - -minetest.register_node("ctf_traps:damage_cobble", { - description = "Damage Cobble\n(Damages any enemy that breaks it)", - tiles = {"ctf_traps_damage_cobble.png"}, - is_ground_content = false, - walkable = true, - groups = {cracky=3, stone=2}, - on_ranged_shoot = function(pos, node, shooter, type) - if type == "pistol" then - return - end - - if not damage_cobble_dig(pos, node, shooter) then - return minetest.dig_node(pos) - end - end, - on_dig = function(pos, node, digger) - if not damage_cobble_dig(pos, node, digger) then - return minetest.node_dig(pos, node, digger) - end - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - local meta = minetest.get_meta(pos) - meta:set_string("placer", placer:get_player_name()) - end -}) - -minetest.register_node("ctf_traps:reinforced_cobble", { - description = "Reinforced Cobblestone", - tiles = {"ctf_traps_reinforced_cobble.png"}, - is_ground_content = false, - groups = {cracky = 3, stone = 2}, - sounds = default.node_sound_stone_defaults(), - on_punch = function(pos, node, digger) - local meta = minetest.get_meta(pos) - local placer_team = meta:get_string("placer_team") - local digger_team = ctf_teams.get(digger) - if placer_team ~= digger_team then - minetest.set_node(pos, {name = "ctf_traps:reinforced_cobble_hardened"}) - meta = minetest.get_meta(pos) - meta:set_string("placer_team", placer_team) - end - end, - after_place_node = function(pos, placer, itemstack, pointed_thing) - local meta = minetest.get_meta(pos) - meta:set_string("placer_team", ctf_teams.get(placer)) - end, - on_dig = function(pos, node, digger) - local meta = minetest.get_meta(pos) - meta:set_string("placer_team", "") - minetest.node_dig(pos, node, digger) - end -}) - -minetest.register_node("ctf_traps:reinforced_cobble_hardened", { - description = "Reinforced Cobblestone Hardened\nYou're not meant to use this", - tiles = {"ctf_traps_reinforced_cobble.png"}, - is_ground_content = false, - groups = {cracky = 1, stone = 2}, - sounds = default.node_sound_stone_defaults(), - drop = "ctf_traps:reinforced_cobble", - on_punch = function(pos, node, digger) - local meta = minetest.get_meta(pos) - local placer_team = meta:get_string("placer_team") - local digger_team = ctf_teams.get(digger) - if placer_team == digger_team then - minetest.set_node(pos, {name = "ctf_traps:reinforced_cobble"}) - meta = minetest.get_meta(pos) - meta:set_string("placer_team", placer_team) - end - end, - on_dig = function(pos, node, digger) - local meta = minetest.get_meta(pos) - meta:set_string("placer_team", "") - minetest.node_dig(pos, node, digger) - end -}) - -minetest.register_node("ctf_traps:landmine", { +minetest.register_node("ctf_landmine:landmine", { description = "Landmine", drawtype = "nodebox", tiles = { - "ctf_traps_landmine.png", - "ctf_traps_landmine.png^[transformFY" + "ctf_landmine_landmine.png", + "ctf_landmine_landmine.png^[transformFY" }, - inventory_image = "ctf_traps_landmine.png", + inventory_image = "ctf_landmine_landmine.png", paramtype = "light", sunlight_propagates = true, walkable = true, diff --git a/mods/ctf/ctf_landmine/mod.conf b/mods/ctf/ctf_landmine/mod.conf index d7fef8985b..5843f0f616 100644 --- a/mods/ctf/ctf_landmine/mod.conf +++ b/mods/ctf/ctf_landmine/mod.conf @@ -1,2 +1,2 @@ -name = ctf_traps +name = ctf_landmine depends = ctf_teams, grenades, default From e14a37ac55d15dd2025e813d0ab470b2f54de13c Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 18:14:01 +0330 Subject: [PATCH 20/28] fix some small correction --- mods/ctf/ctf_landmine/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index 7d00477b8a..219ed7b6c0 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -88,8 +88,8 @@ local function landmine_explode(pos) end end minetest.remove_node(pos) - for idx, pos in ipairs(landmines) do - if pos == pos then + for idx, pos_ in ipairs(landmines) do + if pos_ == pos then table.remove(landmines, idx) break end From 1146608b1de5a48258c91317740d1eedadec2d98 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 18:17:57 +0330 Subject: [PATCH 21/28] clear landmines table on new match --- mods/ctf/ctf_landmine/init.lua | 4 ++++ mods/ctf/ctf_landmine/mod.conf | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index 219ed7b6c0..ac4f58156b 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -168,3 +168,7 @@ minetest.register_globalstep(function(dtime) end end end) + +ctf_api.register_on_match_end(function() + landmines = {} +end) diff --git a/mods/ctf/ctf_landmine/mod.conf b/mods/ctf/ctf_landmine/mod.conf index 5843f0f616..029b88b3e2 100644 --- a/mods/ctf/ctf_landmine/mod.conf +++ b/mods/ctf/ctf_landmine/mod.conf @@ -1,2 +1,2 @@ name = ctf_landmine -depends = ctf_teams, grenades, default +depends = ctf_teams, grenades, default, ctf_api From a5e42f18baba8cc1af1c2ea9026888b87f70bbb5 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Tue, 11 Jun 2024 18:18:57 +0330 Subject: [PATCH 22/28] make luacheck happy --- mods/ctf/ctf_landmine/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index ac4f58156b..d81a97d339 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -169,6 +169,6 @@ minetest.register_globalstep(function(dtime) end end) -ctf_api.register_on_match_end(function() +ctf_api.register_on_match_end(function() landmines = {} end) From 490fc843dadd6cb65b0fc0ee57a44b56cdd52d77 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Mon, 2 Dec 2024 00:21:29 +0330 Subject: [PATCH 23/28] refactor the code, iterate over players positions instead of landmines --- mods/ctf/ctf_landmine/init.lua | 120 ++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 45 deletions(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index d81a97d339..01b82742b4 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -1,12 +1,30 @@ local landmines = { - -- { x = ..., y = ..., z = ...} + -- core.hash_node_position(pos) -> true/false + -- like landmines[core.hash_node_position(pos)] = true } +local number_of_landmines = 0 + +local add_landmine = function(pos) + landmines[core.hash_node_position(pos)] = true + number_of_landmines = number_of_landmines + 1 +end + +local clear_landmines = function() + landmines = {} + number_of_landmines = 0 +end + +local remove_landmine = function(pos) + landmines[core.hash_node_position(pos)] = false + number_of_landmines = number_of_landmines - 1 +end + local landmine_globalstep_counter = 0.0 local LANDMINE_COUNTER_THRESHOLD = 0.025 local function is_self_landmine(object_ref, pos) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local team = meta:get_string("pteam") local placer = meta:get_string("placer") local pname = object_ref:get_player_name() @@ -24,12 +42,12 @@ local function is_self_landmine(object_ref, pos) end local function landmine_explode(pos) - local near_objs = minetest.get_objects_inside_radius(pos, 3) - local meta = minetest.get_meta(pos) + local near_objs = core.get_objects_inside_radius(pos, 3) + local meta = core.get_meta(pos) local placer = meta:get_string("placer") - local placerobj = placer and minetest.get_player_by_name(placer) + local placerobj = placer and core.get_player_by_name(placer) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 20, time = 0.5, minpos = vector.subtract(pos, 3), @@ -48,7 +66,7 @@ local function landmine_explode(pos) texture = "grenades_smoke.png", }) - minetest.add_particle({ + core.add_particle({ pos = pos, velocity = {x=0, y=0, z=0}, acceleration = {x=0, y=0, z=0}, @@ -62,7 +80,7 @@ local function landmine_explode(pos) glow = 10 }) - minetest.sound_play("grenades_explode", { + core.sound_play("grenades_explode", { pos = pos, gain = 1.0, max_hear_distance = 64, @@ -87,16 +105,11 @@ local function landmine_explode(pos) end end end - minetest.remove_node(pos) - for idx, pos_ in ipairs(landmines) do - if pos_ == pos then - table.remove(landmines, idx) - break - end - end + core.remove_node(pos) + remove_landmine(pos) end -minetest.register_node("ctf_landmine:landmine", { +core.register_node("ctf_landmine:landmine", { description = "Landmine", drawtype = "nodebox", tiles = { @@ -117,16 +130,16 @@ minetest.register_node("ctf_landmine:landmine", { fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, }, after_place_node = function(pos, placer, itemstack, pointed_thing) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local name = placer:get_player_name() local pteam = ctf_teams.get(placer) meta:set_string("placer", name) meta:set_string("pteam", pteam) - table.insert(landmines, pos) + add_landmine(pos) end, on_punch = function(pos, _node, puncher, pointed_thing) - if is_self_landmine(puncher, pos) == false then + if not is_self_landmine(puncher, pos) then landmine_explode(pos) end end @@ -135,40 +148,57 @@ minetest.register_node("ctf_landmine:landmine", { -minetest.register_globalstep(function(dtime) - if #landmines == 0 then - return - end +core.register_globalstep(function(dtime) landmine_globalstep_counter = landmine_globalstep_counter + dtime if landmine_globalstep_counter < LANDMINE_COUNTER_THRESHOLD then return end landmine_globalstep_counter = 0.0 - for _idx, pos in pairs(landmines) do - local near_objs = minetest.get_objects_in_area( - { - x = pos.x-0.5, - y = pos.y-0.5, - z = pos.z-0.5 - }, - { - x = pos.x+0.5, - y = pos.y-0.3, - z = pos.z+0.5 - }) - local must_explode = false - for _, obj in pairs(near_objs) do - if is_self_landmine(obj, pos) == false then - must_explode = true - break + if number_of_landmines == 0 then + return + end + local start_time = core.get_gametime() + local players_n = #core.get_connected_players() + local landmines_n = number_of_landmines + for obj in core.get_connected_players() do + local pos = { + x = math.ceil(obj:get_pos().x), + y = math.ceil(obj:get_pos().y), + z = math.ceil(obj:get_pos().z) + } + local positions_to_check = { + pos, + vector.add(pos, { x = 0, y = 0, z = 1}), + vector.add(pos, { x = 1, y = 0, z = 0}), + vector.add(pos, { x = 0, y = 0, z = -1}), + vector.add(pos, { x = -1, y = 0, z = 0}), + vector.add(pos, { x = 0, y = 1, z = 0}), + } + local landmine_positions = {} + for pos in ipairs(positions_to_check) do + if landmines[core.hash_node_position(pos)] then + table.insert(landmine_positions, pos) + end + en1 + -- explode them! + for pos in ipairs(landmine_positions) do + if not is_self_landmine(obj, pos) then + landmine_explode(pos) end end - if must_explode then - landmine_explode(pos) - end + core.debug( + string.format( + "[CTF Landmine] Used %f of server time for %d landmines and %d players", + core.get_gametime() - start_time, + landmines_n, + players_n + ) + ) + +)) end end) -ctf_api.register_on_match_end(function() - landmines = {} +ctf_api.register_on _match_end(function() + clear_landmines() end) From 2292af72f14baf52e55d9866bc5082708e2e6e8d Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Mon, 2 Dec 2024 00:24:36 +0330 Subject: [PATCH 24/28] make luacheck happy --- mods/ctf/ctf_landmine/init.lua | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index 01b82742b4..b191351b6d 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -175,30 +175,28 @@ core.register_globalstep(function(dtime) vector.add(pos, { x = 0, y = 1, z = 0}), } local landmine_positions = {} - for pos in ipairs(positions_to_check) do - if landmines[core.hash_node_position(pos)] then - table.insert(landmine_positions, pos) + for pos2 in ipairs(positions_to_check) do + if landmines[core.hash_node_position(pos2)] then + table.insert(landmine_positions, pos2) end - en1 + end -- explode them! - for pos in ipairs(landmine_positions) do - if not is_self_landmine(obj, pos) then - landmine_explode(pos) + for pos2 in ipairs(landmine_positions) do + if not is_self_landmine(obj, pos2) then + landmine_explode(pos2) end end - core.debug( - string.format( - "[CTF Landmine] Used %f of server time for %d landmines and %d players", - core.get_gametime() - start_time, - landmines_n, - players_n - ) - ) - -)) end + core.debug( + string.format( + "[CTF Landmine] Used %f of server time for %d landmines and %d players", + core.get_gametime() - start_time, + landmines_n, + players_n + ) + ) end) -ctf_api.register_on _match_end(function() +ctf_api.register_on_match_end(function() clear_landmines() end) From 4c93cc87fb3054bfe80a90b05316e264d6f20a99 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Mon, 2 Dec 2024 20:38:11 +0330 Subject: [PATCH 25/28] correct maps submodule commit --- mods/ctf/ctf_map/maps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/maps b/mods/ctf/ctf_map/maps index 3a375ae9a8..e831d074cf 160000 --- a/mods/ctf/ctf_map/maps +++ b/mods/ctf/ctf_map/maps @@ -1 +1 @@ -Subproject commit 3a375ae9a82a9308a0677e23a8ac7367d54fc637 +Subproject commit e831d074cfd388d06f961227706c00023e8ba2ff From 3cc8fc7a4f23ce82fa5026038d29736c43abd846 Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Mon, 2 Dec 2024 20:43:40 +0330 Subject: [PATCH 26/28] fix errors --- mods/ctf/ctf_landmine/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ctf/ctf_landmine/init.lua b/mods/ctf/ctf_landmine/init.lua index b191351b6d..d6be751615 100644 --- a/mods/ctf/ctf_landmine/init.lua +++ b/mods/ctf/ctf_landmine/init.lua @@ -160,7 +160,7 @@ core.register_globalstep(function(dtime) local start_time = core.get_gametime() local players_n = #core.get_connected_players() local landmines_n = number_of_landmines - for obj in core.get_connected_players() do + for _idx, obj in ipairs(core.get_connected_players()) do local pos = { x = math.ceil(obj:get_pos().x), y = math.ceil(obj:get_pos().y), @@ -175,13 +175,13 @@ core.register_globalstep(function(dtime) vector.add(pos, { x = 0, y = 1, z = 0}), } local landmine_positions = {} - for pos2 in ipairs(positions_to_check) do + for _idx2, pos2 in ipairs(positions_to_check) do if landmines[core.hash_node_position(pos2)] then table.insert(landmine_positions, pos2) end end -- explode them! - for pos2 in ipairs(landmine_positions) do + for _idx2, pos2 in ipairs(landmine_positions) do if not is_self_landmine(obj, pos2) then landmine_explode(pos2) end From 1abf18483de050fcb04341f8af603ce6fde3903e Mon Sep 17 00:00:00 2001 From: Farooq Karimi Zadeh Date: Mon, 2 Dec 2024 20:48:28 +0330 Subject: [PATCH 27/28] fixed kill log texture error --- mods/ctf/ctf_modebase/features.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_modebase/features.lua b/mods/ctf/ctf_modebase/features.lua index f0163177c7..35cfce827f 100644 --- a/mods/ctf/ctf_modebase/features.lua +++ b/mods/ctf/ctf_modebase/features.lua @@ -202,7 +202,7 @@ local damage_group_textures = { knockback_grenade = "ctf_mode_nade_fight_knockback_grenade.png", black_hole_grenade = "ctf_mode_nade_fight_black_hole_grenade.png", damage_cobble = "ctf_map_damage_cobble.png", - landmine = "ctf_map_landmine.png", + landmine = "ctf_landmine_landmine.png", } local function get_weapon_image(hitter, tool_capabilities) From b8390fc27bba172b4fffc651cbf814b966119afd Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Mon, 2 Dec 2024 12:06:42 -0800 Subject: [PATCH 28/28] Update crafting.lua --- mods/ctf/ctf_modebase/crafting.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_modebase/crafting.lua b/mods/ctf/ctf_modebase/crafting.lua index a8087b34ec..253993a467 100644 --- a/mods/ctf/ctf_modebase/crafting.lua +++ b/mods/ctf/ctf_modebase/crafting.lua @@ -178,4 +178,4 @@ crafting.register_recipe({ output = "ctf_map:landmine", items = { "default:steel_ingot 4", "grenades:frag" }, always_known = false, -}) \ No newline at end of file +})