Skip to content

Commit b2d9843

Browse files
authored
Include capture points in capture messages (#1287)
* draft * tell players how much the capture was worth * make luacheck happy
1 parent 18d0b00 commit b2d9843

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

mods/ctf/ctf_modebase/features.lua

+18-14
Original file line numberDiff line numberDiff line change
@@ -687,15 +687,7 @@ return {
687687

688688
celebrate_team(pteam)
689689

690-
local text = " has captured the flag"
691-
if many_teams then
692-
text = " has captured the flag of team(s) " .. HumanReadable(teamnames)
693-
minetest.chat_send_all(
694-
minetest.colorize(tcolor, pname) ..
695-
minetest.colorize(FLAG_MESSAGE_COLOR, text)
696-
)
697-
end
698-
ctf_modebase.announce(string.format("Player %s (team %s)%s", pname, pteam, text))
690+
699691

700692
ctf_modebase.flag_huds.untrack_capturer(pname)
701693

@@ -706,7 +698,19 @@ return {
706698
score = math.max(75, math.min(500, score))
707699
capture_reward = capture_reward + score
708700
end
709-
701+
local text = " has captured the flag"
702+
if many_teams then
703+
text = string.format(
704+
" has captured the flag of team(s) %s and got %d points",
705+
HumanReadable(teamnames),
706+
capture_reward
707+
)
708+
minetest.chat_send_all(
709+
minetest.colorize(tcolor, pname) ..
710+
minetest.colorize(FLAG_MESSAGE_COLOR, text)
711+
)
712+
end
713+
ctf_modebase.announce(string.format("Player %s (team %s)%s and got %d points", pname, pteam, text, capture_reward))
710714
local team_score = team_scores[pteam].score
711715
for teammate in pairs(ctf_teams.online_players[pteam].players) do
712716
if teammate ~= pname then
@@ -721,12 +725,12 @@ return {
721725
teams_left = teams_left - #teamnames
722726

723727
if teams_left <= 1 then
724-
local capture_text = "Player %s captured"
728+
local capture_text = "Player %s captured and got %d points"
725729
if many_teams then
726-
capture_text = "Player %s captured the last flag"
730+
capture_text = "Player %s captured the last flag and got %d points"
727731
end
728732

729-
ctf_modebase.summary.set_winner(string.format(capture_text, minetest.colorize(tcolor, pname)))
733+
ctf_modebase.summary.set_winner(string.format(capture_text, minetest.colorize(tcolor, pname), capture_reward))
730734

731735
local win_text = HumanReadable(pteam) .. " Team Wins!"
732736

@@ -746,7 +750,7 @@ return {
746750

747751
for lost_player in pairs(ctf_teams.online_players[lost_team].players) do
748752
team_switch_after_capture = true
749-
ctf_teams.allocate_player(lost_player)
753+
ctf_teams.allocate_player(lost_player)
750754
team_switch_after_capture = false
751755
end
752756
end

0 commit comments

Comments
 (0)