From 1512784d81c1470ed945665cff5e22cac77b36a5 Mon Sep 17 00:00:00 2001 From: AFCMS <61794590+AFCMS@users.noreply.github.com> Date: Sun, 29 Aug 2021 18:06:18 +0200 Subject: [PATCH 1/5] MTG: Optionally use 9 sliced background (#924) --- mods/mtg/default/init.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mods/mtg/default/init.lua b/mods/mtg/default/init.lua index c4c020d..d7ee118 100644 --- a/mods/mtg/default/init.lua +++ b/mods/mtg/default/init.lua @@ -10,10 +10,22 @@ default.LIGHT_MAX = 14 -- GUI related stuff minetest.register_on_joinplayer(function(player) - player:set_formspec_prepend([[ - bgcolor[#080808BB;true] - background[5,5;1,1;gui_formbg.png;true] - listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]]) + -- Set formspec prepend + local formspec = [[ + bgcolor[#080808BB;true] + listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] + ]] + + local name = player:get_player_name() + local info = minetest.get_player_information(name) + + if info.formspec_version > 1 then + formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]" + else + formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]" + end + + player:set_formspec_prepend(formspec) end) function default.get_hotbar_bg(x,y) From f06eca30f0b6d3178194123cc30dd6a40feeafab Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Mon, 30 Aug 2021 08:20:09 -0700 Subject: [PATCH 2/5] Make worldedit an optional dependency of map_maker --- mods/ctf/ctf_map/map_maker/mod.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/map_maker/mod.conf b/mods/ctf/ctf_map/map_maker/mod.conf index 75dd924..d7c01fc 100644 --- a/mods/ctf/ctf_map/map_maker/mod.conf +++ b/mods/ctf/ctf_map/map_maker/mod.conf @@ -1,2 +1,3 @@ name = map_maker -depends = ctf_map_core, worldedit +depends = ctf_map_core +optional_depends = worldedit From 84dc7da461c8c08481c072ad72631b5dd02c5414 Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Fri, 3 Sep 2021 17:22:20 +0300 Subject: [PATCH 3/5] Rework melee damage (#878) --- mods/ctf/ctf/teams.lua | 46 ++++++++++++++++---------------- mods/ctf/ctf_classes/classes.lua | 2 +- mods/ctf/ctf_classes/init.lua | 13 +++++++++ mods/ctf/ctf_classes/melee.lua | 31 --------------------- mods/ctf/ctf_events/init.lua | 2 +- mods/ctf/ctf_metrics/init.lua | 2 +- mods/pvp/anticoward/init.lua | 4 +-- mods/pvp/kill_assist/init.lua | 2 +- mods/pvp/medkits/init.lua | 9 +++---- 9 files changed, 45 insertions(+), 66 deletions(-) diff --git a/mods/ctf/ctf/teams.lua b/mods/ctf/ctf/teams.lua index b62469e..a81efbd 100644 --- a/mods/ctf/ctf/teams.lua +++ b/mods/ctf/ctf/teams.lua @@ -450,6 +450,10 @@ function ctf.can_attack(player, hitter, time_from_last_punch, tool_capabilities, return true end +function ctf.get_damage_modifier(player, tool_capabilities) + return 0 +end + ctf.registered_on_attack = {} function ctf.register_on_attack(func) if ctf._mt_loaded then @@ -458,15 +462,8 @@ function ctf.register_on_attack(func) table.insert(ctf.registered_on_attack, func) end -local dead_players = {} -minetest.register_on_respawnplayer(function(player) - dead_players[player:get_player_name()] = nil -end) -minetest.register_on_joinplayer(function(player) - dead_players[player:get_player_name()] = nil -end) minetest.register_on_punchplayer(function(player, hitter, - time_from_last_punch, tool_capabilities, dir, damage, ...) + time_from_last_punch, tool_capabilities, dir, orig_damage, ...) if player and hitter then local pname = player:get_player_name() local hname = hitter:get_player_name() @@ -474,10 +471,6 @@ minetest.register_on_punchplayer(function(player, hitter, local to = ctf.player(pname) local from = ctf.player(hname) - if dead_players[pname] then - return - end - if to.team == from.team and to.team ~= "" and to.team ~= nil and to.name ~= from.name then hud_event.new(hname, { @@ -491,31 +484,38 @@ minetest.register_on_punchplayer(function(player, hitter, end if ctf.can_attack(player, hitter, time_from_last_punch, tool_capabilities, - dir, damage, ...) == false + dir, orig_damage, ...) == false then return true end local hp = player:get_hp() - if hp == 0 then - return false + if hp <= 0 then + return true end - if hp - damage <= 0 then - dead_players[pname] = true - local wielded = hitter:get_wielded_item() - for i = 1, #ctf.registered_on_killedplayer do - ctf.registered_on_killedplayer[i](pname, hname, - wielded, tool_capabilities) - end - return false + if tool_capabilities and tool_capabilities.damage_groups and tool_capabilities.damage_groups.fleshy then + local modifier = ctf.get_damage_modifier(hitter, tool_capabilities) + tool_capabilities.damage_groups.fleshy = math.max(1, tool_capabilities.damage_groups.fleshy + modifier) end + local damage = minetest.get_hit_params(player:get_armor_groups(), tool_capabilities, time_from_last_punch).hp + damage = math.min(damage, hp) + for i = 1, #ctf.registered_on_attack do ctf.registered_on_attack[i]( player, hitter, time_from_last_punch, tool_capabilities, dir, damage, ... ) end + + if hp <= damage then + for i = 1, #ctf.registered_on_killedplayer do + ctf.registered_on_killedplayer[i](pname, hname, tool_capabilities) + end + end + + player:set_hp(hp - damage) + return true end end) diff --git a/mods/ctf/ctf_classes/classes.lua b/mods/ctf/ctf_classes/classes.lua index bdbff8a..fbc69fb 100644 --- a/mods/ctf/ctf_classes/classes.lua +++ b/mods/ctf/ctf_classes/classes.lua @@ -8,7 +8,7 @@ ctf_classes.register("knight", { properties = { max_hp = 30, speed = 0.90, - melee_bonus = 1, + sword_modifier = 1, initial_stuff = { "ctf_classes:sword_bronze", diff --git a/mods/ctf/ctf_classes/init.lua b/mods/ctf/ctf_classes/init.lua index f126c32..ed946bf 100644 --- a/mods/ctf/ctf_classes/init.lua +++ b/mods/ctf/ctf_classes/init.lua @@ -69,3 +69,16 @@ ctf_classes.register_on_changed(function(player, old, new) ctf.chat_send_team(ctf.player(pname).team, minetest.colorize("#ABCDEF", pname .. " is now a " .. new.description)) end) + +local old_get_damage_modifier = ctf.get_damage_modifier +function ctf.get_damage_modifier(player, tool_capabilities) + local modifier = 0 + if tool_capabilities.damage_groups.sword then + local class = ctf_classes.get(player) + if class.properties.sword_modifier then + modifier = class.properties.sword_modifier + end + end + + return modifier + old_get_damage_modifier(player, tool_capabilities) +end diff --git a/mods/ctf/ctf_classes/melee.lua b/mods/ctf/ctf_classes/melee.lua index 8cd894c..1dba648 100644 --- a/mods/ctf/ctf_classes/melee.lua +++ b/mods/ctf/ctf_classes/melee.lua @@ -1,33 +1,3 @@ -minetest.register_on_player_hpchange(function(player, hp_change, reason) - if reason.type ~= "punch" or not reason.object or not reason.object:is_player() then - return hp_change - end - - local class = ctf_classes.get(reason.object) - - if class.properties.melee_bonus and reason.object:get_wielded_item():get_name():find("sword") then - local change = hp_change - class.properties.melee_bonus - - if player:get_hp() + change <= 0 and player:get_hp() + hp_change > 0 then - local wielded_item = reason.object:get_wielded_item() - - for i = 1, #ctf.registered_on_killedplayer do - ctf.registered_on_killedplayer[i]( - player:get_player_name(), - reason.object:get_player_name(), - wielded_item, - wielded_item:get_tool_capabilities() - ) - end - end - - return change - end - - return hp_change -end, true) - - local sword_special_timer = {} local SWORD_SPECIAL_COOLDOWN = 20 local function sword_special_timer_func(pname, timeleft) @@ -68,7 +38,6 @@ minetest.register_tool("ctf_classes:sword_bronze", { end local pteam = ctf.player(pname).team - if not pteam then -- can be nil during map change return end diff --git a/mods/ctf/ctf_events/init.lua b/mods/ctf/ctf_events/init.lua index 18bf340..b8b96fe 100644 --- a/mods/ctf/ctf_events/init.lua +++ b/mods/ctf/ctf_events/init.lua @@ -120,7 +120,7 @@ function ctf_events.update_all() end end -ctf.register_on_killedplayer(function(victim, killer, stack, tool_caps) +ctf.register_on_killedplayer(function(victim, killer, tool_caps) local victim_color = ctf_colors.get_color(ctf.player(victim)) local killer_color = ctf_colors.get_color(ctf.player(killer)) diff --git a/mods/ctf/ctf_metrics/init.lua b/mods/ctf/ctf_metrics/init.lua index 6210ea3..aa555bf 100644 --- a/mods/ctf/ctf_metrics/init.lua +++ b/mods/ctf/ctf_metrics/init.lua @@ -15,7 +15,7 @@ end -- Kills -- local kill_counter = counter("ctf_kills", "Total kills") -ctf.register_on_killedplayer(function(victim, killer, type) +ctf.register_on_killedplayer(function(victim, killer) kill_counter:increment() end) diff --git a/mods/pvp/anticoward/init.lua b/mods/pvp/anticoward/init.lua index de93a2a..9f851de 100644 --- a/mods/pvp/anticoward/init.lua +++ b/mods/pvp/anticoward/init.lua @@ -38,12 +38,11 @@ ctf.register_on_attack(function(player, hitter, potential_cowards[pname].timer = 0 potential_cowards[pname].puncher = hname - potential_cowards[pname].wielded_item = hitter:get_wielded_item() potential_cowards[pname].toolcaps = tool_capabilities end end) -ctf.register_on_killedplayer(function(victim, killer, _, toolcaps) +ctf.register_on_killedplayer(function(victim, killer, toolcaps) if toolcaps.damage_groups.combat_log or toolcaps.damage_groups.suicide then return end @@ -72,7 +71,6 @@ function handle_leave_or_die(pname, leave) ctf.registered_on_killedplayer[i]( pname, hname, - potential_cowards[pname].wielded_item, potential_cowards[pname].toolcaps ) end diff --git a/mods/pvp/kill_assist/init.lua b/mods/pvp/kill_assist/init.lua index b813500..5315586 100644 --- a/mods/pvp/kill_assist/init.lua +++ b/mods/pvp/kill_assist/init.lua @@ -69,7 +69,7 @@ function kill_assist.reward_assists(victim, killer, reward) kill_assist.clear_assists(victim) end -ctf.register_on_killedplayer(function(victim, killer, _, toolcaps) +ctf.register_on_killedplayer(function(victim, killer, toolcaps) local reward = ctf_stats.calculateKillReward(victim, killer, toolcaps) reward = math.floor(reward * 100) / 100 kill_assist.reward_assists(victim, killer, reward) diff --git a/mods/pvp/medkits/init.lua b/mods/pvp/medkits/init.lua index 5848a0b..9a71e87 100644 --- a/mods/pvp/medkits/init.lua +++ b/mods/pvp/medkits/init.lua @@ -133,22 +133,21 @@ end) -- If player takes damage while healing, -- stop regen and revert back to original state -minetest.register_on_player_hpchange(function(player, hp, reason) +minetest.register_on_player_hpchange(function(player, hp_change, reason) local name = player:get_player_name() - if hp < 0 then + if hp_change < 0 then if players[name] then player:hud_remove(players[name].hud) players[name] = nil -- Don't use stop_healing(), it uses set_hp() and won't allocate deaths or score properly end - if reason and reason.type == "punch" then + if reason.type == "punch" then local hitter = reason.object if hitter and players[hitter:get_player_name()] then stop_healing(hitter, "attack") end end end - return hp -end, true) +end) minetest.register_on_leaveplayer(function(player) players[player:get_player_name()] = nil From ea9d9ad2d88f7a578300c96204af7c375078f6c0 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Fri, 3 Sep 2021 16:20:18 -0700 Subject: [PATCH 4/5] Revert "Rework melee damage (#878)" (#925) This reverts commit 84dc7da461c8c08481c072ad72631b5dd02c5414. --- mods/ctf/ctf/teams.lua | 46 ++++++++++++++++---------------- mods/ctf/ctf_classes/classes.lua | 2 +- mods/ctf/ctf_classes/init.lua | 13 --------- mods/ctf/ctf_classes/melee.lua | 31 +++++++++++++++++++++ mods/ctf/ctf_events/init.lua | 2 +- mods/ctf/ctf_metrics/init.lua | 2 +- mods/pvp/anticoward/init.lua | 4 ++- mods/pvp/kill_assist/init.lua | 2 +- mods/pvp/medkits/init.lua | 9 ++++--- 9 files changed, 66 insertions(+), 45 deletions(-) diff --git a/mods/ctf/ctf/teams.lua b/mods/ctf/ctf/teams.lua index a81efbd..b62469e 100644 --- a/mods/ctf/ctf/teams.lua +++ b/mods/ctf/ctf/teams.lua @@ -450,10 +450,6 @@ function ctf.can_attack(player, hitter, time_from_last_punch, tool_capabilities, return true end -function ctf.get_damage_modifier(player, tool_capabilities) - return 0 -end - ctf.registered_on_attack = {} function ctf.register_on_attack(func) if ctf._mt_loaded then @@ -462,8 +458,15 @@ function ctf.register_on_attack(func) table.insert(ctf.registered_on_attack, func) end +local dead_players = {} +minetest.register_on_respawnplayer(function(player) + dead_players[player:get_player_name()] = nil +end) +minetest.register_on_joinplayer(function(player) + dead_players[player:get_player_name()] = nil +end) minetest.register_on_punchplayer(function(player, hitter, - time_from_last_punch, tool_capabilities, dir, orig_damage, ...) + time_from_last_punch, tool_capabilities, dir, damage, ...) if player and hitter then local pname = player:get_player_name() local hname = hitter:get_player_name() @@ -471,6 +474,10 @@ minetest.register_on_punchplayer(function(player, hitter, local to = ctf.player(pname) local from = ctf.player(hname) + if dead_players[pname] then + return + end + if to.team == from.team and to.team ~= "" and to.team ~= nil and to.name ~= from.name then hud_event.new(hname, { @@ -484,38 +491,31 @@ minetest.register_on_punchplayer(function(player, hitter, end if ctf.can_attack(player, hitter, time_from_last_punch, tool_capabilities, - dir, orig_damage, ...) == false + dir, damage, ...) == false then return true end local hp = player:get_hp() - if hp <= 0 then - return true + if hp == 0 then + return false end - if tool_capabilities and tool_capabilities.damage_groups and tool_capabilities.damage_groups.fleshy then - local modifier = ctf.get_damage_modifier(hitter, tool_capabilities) - tool_capabilities.damage_groups.fleshy = math.max(1, tool_capabilities.damage_groups.fleshy + modifier) + if hp - damage <= 0 then + dead_players[pname] = true + local wielded = hitter:get_wielded_item() + for i = 1, #ctf.registered_on_killedplayer do + ctf.registered_on_killedplayer[i](pname, hname, + wielded, tool_capabilities) + end + return false end - local damage = minetest.get_hit_params(player:get_armor_groups(), tool_capabilities, time_from_last_punch).hp - damage = math.min(damage, hp) - for i = 1, #ctf.registered_on_attack do ctf.registered_on_attack[i]( player, hitter, time_from_last_punch, tool_capabilities, dir, damage, ... ) end - - if hp <= damage then - for i = 1, #ctf.registered_on_killedplayer do - ctf.registered_on_killedplayer[i](pname, hname, tool_capabilities) - end - end - - player:set_hp(hp - damage) - return true end end) diff --git a/mods/ctf/ctf_classes/classes.lua b/mods/ctf/ctf_classes/classes.lua index fbc69fb..bdbff8a 100644 --- a/mods/ctf/ctf_classes/classes.lua +++ b/mods/ctf/ctf_classes/classes.lua @@ -8,7 +8,7 @@ ctf_classes.register("knight", { properties = { max_hp = 30, speed = 0.90, - sword_modifier = 1, + melee_bonus = 1, initial_stuff = { "ctf_classes:sword_bronze", diff --git a/mods/ctf/ctf_classes/init.lua b/mods/ctf/ctf_classes/init.lua index ed946bf..f126c32 100644 --- a/mods/ctf/ctf_classes/init.lua +++ b/mods/ctf/ctf_classes/init.lua @@ -69,16 +69,3 @@ ctf_classes.register_on_changed(function(player, old, new) ctf.chat_send_team(ctf.player(pname).team, minetest.colorize("#ABCDEF", pname .. " is now a " .. new.description)) end) - -local old_get_damage_modifier = ctf.get_damage_modifier -function ctf.get_damage_modifier(player, tool_capabilities) - local modifier = 0 - if tool_capabilities.damage_groups.sword then - local class = ctf_classes.get(player) - if class.properties.sword_modifier then - modifier = class.properties.sword_modifier - end - end - - return modifier + old_get_damage_modifier(player, tool_capabilities) -end diff --git a/mods/ctf/ctf_classes/melee.lua b/mods/ctf/ctf_classes/melee.lua index 1dba648..8cd894c 100644 --- a/mods/ctf/ctf_classes/melee.lua +++ b/mods/ctf/ctf_classes/melee.lua @@ -1,3 +1,33 @@ +minetest.register_on_player_hpchange(function(player, hp_change, reason) + if reason.type ~= "punch" or not reason.object or not reason.object:is_player() then + return hp_change + end + + local class = ctf_classes.get(reason.object) + + if class.properties.melee_bonus and reason.object:get_wielded_item():get_name():find("sword") then + local change = hp_change - class.properties.melee_bonus + + if player:get_hp() + change <= 0 and player:get_hp() + hp_change > 0 then + local wielded_item = reason.object:get_wielded_item() + + for i = 1, #ctf.registered_on_killedplayer do + ctf.registered_on_killedplayer[i]( + player:get_player_name(), + reason.object:get_player_name(), + wielded_item, + wielded_item:get_tool_capabilities() + ) + end + end + + return change + end + + return hp_change +end, true) + + local sword_special_timer = {} local SWORD_SPECIAL_COOLDOWN = 20 local function sword_special_timer_func(pname, timeleft) @@ -38,6 +68,7 @@ minetest.register_tool("ctf_classes:sword_bronze", { end local pteam = ctf.player(pname).team + if not pteam then -- can be nil during map change return end diff --git a/mods/ctf/ctf_events/init.lua b/mods/ctf/ctf_events/init.lua index b8b96fe..18bf340 100644 --- a/mods/ctf/ctf_events/init.lua +++ b/mods/ctf/ctf_events/init.lua @@ -120,7 +120,7 @@ function ctf_events.update_all() end end -ctf.register_on_killedplayer(function(victim, killer, tool_caps) +ctf.register_on_killedplayer(function(victim, killer, stack, tool_caps) local victim_color = ctf_colors.get_color(ctf.player(victim)) local killer_color = ctf_colors.get_color(ctf.player(killer)) diff --git a/mods/ctf/ctf_metrics/init.lua b/mods/ctf/ctf_metrics/init.lua index aa555bf..6210ea3 100644 --- a/mods/ctf/ctf_metrics/init.lua +++ b/mods/ctf/ctf_metrics/init.lua @@ -15,7 +15,7 @@ end -- Kills -- local kill_counter = counter("ctf_kills", "Total kills") -ctf.register_on_killedplayer(function(victim, killer) +ctf.register_on_killedplayer(function(victim, killer, type) kill_counter:increment() end) diff --git a/mods/pvp/anticoward/init.lua b/mods/pvp/anticoward/init.lua index 9f851de..de93a2a 100644 --- a/mods/pvp/anticoward/init.lua +++ b/mods/pvp/anticoward/init.lua @@ -38,11 +38,12 @@ ctf.register_on_attack(function(player, hitter, potential_cowards[pname].timer = 0 potential_cowards[pname].puncher = hname + potential_cowards[pname].wielded_item = hitter:get_wielded_item() potential_cowards[pname].toolcaps = tool_capabilities end end) -ctf.register_on_killedplayer(function(victim, killer, toolcaps) +ctf.register_on_killedplayer(function(victim, killer, _, toolcaps) if toolcaps.damage_groups.combat_log or toolcaps.damage_groups.suicide then return end @@ -71,6 +72,7 @@ function handle_leave_or_die(pname, leave) ctf.registered_on_killedplayer[i]( pname, hname, + potential_cowards[pname].wielded_item, potential_cowards[pname].toolcaps ) end diff --git a/mods/pvp/kill_assist/init.lua b/mods/pvp/kill_assist/init.lua index 5315586..b813500 100644 --- a/mods/pvp/kill_assist/init.lua +++ b/mods/pvp/kill_assist/init.lua @@ -69,7 +69,7 @@ function kill_assist.reward_assists(victim, killer, reward) kill_assist.clear_assists(victim) end -ctf.register_on_killedplayer(function(victim, killer, toolcaps) +ctf.register_on_killedplayer(function(victim, killer, _, toolcaps) local reward = ctf_stats.calculateKillReward(victim, killer, toolcaps) reward = math.floor(reward * 100) / 100 kill_assist.reward_assists(victim, killer, reward) diff --git a/mods/pvp/medkits/init.lua b/mods/pvp/medkits/init.lua index 9a71e87..5848a0b 100644 --- a/mods/pvp/medkits/init.lua +++ b/mods/pvp/medkits/init.lua @@ -133,21 +133,22 @@ end) -- If player takes damage while healing, -- stop regen and revert back to original state -minetest.register_on_player_hpchange(function(player, hp_change, reason) +minetest.register_on_player_hpchange(function(player, hp, reason) local name = player:get_player_name() - if hp_change < 0 then + if hp < 0 then if players[name] then player:hud_remove(players[name].hud) players[name] = nil -- Don't use stop_healing(), it uses set_hp() and won't allocate deaths or score properly end - if reason.type == "punch" then + if reason and reason.type == "punch" then local hitter = reason.object if hitter and players[hitter:get_player_name()] then stop_healing(hitter, "attack") end end end -end) + return hp +end, true) minetest.register_on_leaveplayer(function(player) players[player:get_player_name()] = nil From 0574a435a9b16e1195c1ff92d119572be2f7ac67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 18 Sep 2021 11:17:02 -0600 Subject: [PATCH 5/5] Update maps submodule Bumps [mods/ctf/ctf_map/ctf_map_core/maps](https://github.com/MT-CTF/maps) from `6afcf12` to `5915ff6`. - [Release notes](https://github.com/MT-CTF/maps/releases) - [Commits](https://github.com/MT-CTF/maps/compare/6afcf12e1ca22873fc4066b242f57b8398131745...5915ff62802cb178a61fe0de29172846014b1b43) --- updated-dependencies: - dependency-name: mods/ctf/ctf_map/ctf_map_core/maps dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- mods/ctf/ctf_map/ctf_map_core/maps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/ctf_map_core/maps b/mods/ctf/ctf_map/ctf_map_core/maps index 6afcf12..5915ff6 160000 --- a/mods/ctf/ctf_map/ctf_map_core/maps +++ b/mods/ctf/ctf_map/ctf_map_core/maps @@ -1 +1 @@ -Subproject commit 6afcf12e1ca22873fc4066b242f57b8398131745 +Subproject commit 5915ff62802cb178a61fe0de29172846014b1b43