diff --git a/mods/ctf/ctf_modebase/ranking_commands.lua b/mods/ctf/ctf_modebase/ranking_commands.lua index ee79b59a1..44b5aae13 100644 --- a/mods/ctf/ctf_modebase/ranking_commands.lua +++ b/mods/ctf/ctf_modebase/ranking_commands.lua @@ -96,7 +96,8 @@ ctf_api.register_on_match_end(function() end) ctf_core.register_chatcommand_alias("donate", "d", { - description = "Donate your match score to your teammate\nCan be used only once in 2.5 minutes", + description = "Donate your match score to your teammate\nCan be used only once in 2.5 minutes".. + "\nReplace with :max or any negative number to donate the maximum amount", params = " [message]", func = function(name, param) local current_mode = ctf_modebase:get_current_mode() @@ -113,6 +114,8 @@ ctf_core.register_chatcommand_alias("donate", "d", { dmessage = dmessage .. " " .. p elseif ctf_core.to_number(p) and score == 0 then score = p + elseif p == ":max" and score == 0 then + score = -1 else local team = ctf_teams.get(p) if not team and pcount > 0 then @@ -151,15 +154,21 @@ ctf_core.register_chatcommand_alias("donate", "d", { end score = math.floor(score) + local cur_score = math.min( + current_mode.recent_rankings.get(name).score or 0, + (current_mode.rankings:get(name) or {}).score or 0 + ) + + if score < 0 then + score = math.floor(cur_score / 2 / pcount) + end + if score < 5 then return false, "You should donate at least 5 score!" end local scoretotal = score * pcount - local cur_score = math.min( - current_mode.recent_rankings.get(name).score or 0, - (current_mode.rankings:get(name) or {}).score or 0 - ) + if scoretotal > cur_score / 2 then return false, "You can donate only half of your match score!" end