Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell players how much the capture was worth #1287

Merged
merged 3 commits into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions mods/ctf/ctf_modebase/features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -687,15 +687,7 @@ return {

celebrate_team(pteam)

local text = " has captured the flag"
if many_teams then
text = " has captured the flag of team(s) " .. HumanReadable(teamnames)
minetest.chat_send_all(
minetest.colorize(tcolor, pname) ..
minetest.colorize(FLAG_MESSAGE_COLOR, text)
)
end
ctf_modebase.announce(string.format("Player %s (team %s)%s", pname, pteam, text))


ctf_modebase.flag_huds.untrack_capturer(pname)

Expand All @@ -706,7 +698,19 @@ return {
score = math.max(75, math.min(500, score))
capture_reward = capture_reward + score
end

local text = " has captured the flag"
if many_teams then
text = string.format(
" has captured the flag of team(s) %s and got %d points",
HumanReadable(teamnames),
capture_reward
)
minetest.chat_send_all(
minetest.colorize(tcolor, pname) ..
minetest.colorize(FLAG_MESSAGE_COLOR, text)
)
end
ctf_modebase.announce(string.format("Player %s (team %s)%s and got %d points", pname, pteam, text, capture_reward))
local team_score = team_scores[pteam].score
for teammate in pairs(ctf_teams.online_players[pteam].players) do
if teammate ~= pname then
Expand All @@ -721,12 +725,12 @@ return {
teams_left = teams_left - #teamnames

if teams_left <= 1 then
local capture_text = "Player %s captured"
local capture_text = "Player %s captured and got %d points"
if many_teams then
capture_text = "Player %s captured the last flag"
capture_text = "Player %s captured the last flag and got %d points"
end

ctf_modebase.summary.set_winner(string.format(capture_text, minetest.colorize(tcolor, pname)))
ctf_modebase.summary.set_winner(string.format(capture_text, minetest.colorize(tcolor, pname), capture_reward))

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

Expand All @@ -746,7 +750,7 @@ return {

for lost_player in pairs(ctf_teams.online_players[lost_team].players) do
team_switch_after_capture = true
ctf_teams.allocate_player(lost_player)
ctf_teams.allocate_player(lost_player)
team_switch_after_capture = false
end
end
Expand Down
Loading