@@ -22,7 +22,7 @@ ctf_core.testing = {
22
22
end
23
23
}
24
24
25
- local hud = mhud .init ()
25
+ local mapload_huds = mhud .init ()
26
26
local LOADING_SCREEN_TARGET_TIME = 7
27
27
local loading_screen_time
28
28
@@ -121,25 +121,27 @@ local old_announce = ctf_modebase.map_chosen
121
121
function ctf_modebase .map_chosen (map , ...)
122
122
set_playertags_state (PLAYERTAGS_OFF )
123
123
124
+ mapload_huds :clear_all ()
125
+
124
126
for _ , p in pairs (minetest .get_connected_players ()) do
125
127
if ctf_teams .get (p ) then
126
- hud :add (p , " loading_screen" , {
128
+ mapload_huds :add (p , " loading_screen" , {
127
129
hud_elem_type = " image" ,
128
130
position = {x = 0.5 , y = 0.5 },
129
131
image_scale = - 100 ,
130
132
z_index = 1000 ,
131
133
texture = " [combine:1x1^[invert:rgba^[opacity:1^[colorize:#141523:255"
132
134
})
133
135
134
- hud :add (p , " map_image" , {
136
+ mapload_huds :add (p , " map_image" , {
135
137
hud_elem_type = " image" ,
136
138
position = {x = 0.5 , y = 0.5 },
137
139
image_scale = - 100 ,
138
140
z_index = 1001 ,
139
141
texture = map .dirname .. " _screenshot.png^[opacity:30" ,
140
142
})
141
143
142
- hud :add (p , " loading_text" , {
144
+ mapload_huds :add (p , " loading_text" , {
143
145
hud_elem_type = " text" ,
144
146
position = {x = 0.5 , y = 0.5 },
145
147
alignment = {x = " center" , y = " up" },
@@ -148,7 +150,7 @@ function ctf_modebase.map_chosen(map, ...)
148
150
color = 0x7ec5ff ,
149
151
z_index = 1002 ,
150
152
})
151
- hud :add (p , {
153
+ mapload_huds :add (p , {
152
154
hud_elem_type = " text" ,
153
155
position = {x = 0.5 , y = 0.75 },
154
156
alignment = {x = " center" , y = " center" },
@@ -252,14 +254,22 @@ local function tp_player_near_flag(player)
252
254
local tname = ctf_teams .get (player )
253
255
if not tname then return end
254
256
255
- local pos = vector .offset (ctf_map .current_map .teams [tname ].flag_pos ,
256
- math.random (- 1 , 1 ),
257
- 0.5 ,
258
- math.random (- 1 , 1 )
259
- )
260
- local rotation_y = vector .dir_to_rotation (
261
- vector .direction (pos , ctf_map .current_map .teams [tname ].look_pos or ctf_map .current_map .flag_center )
262
- ).y
257
+ local rotation_y
258
+ local pos
259
+
260
+ if ctf_map .current_map .teams [tname ] then
261
+ pos = vector .offset (ctf_map .current_map .teams [tname ].flag_pos ,
262
+ math.random (- 1 , 1 ),
263
+ 0.5 ,
264
+ math.random (- 1 , 1 )
265
+ )
266
+ rotation_y = vector .dir_to_rotation (
267
+ vector .direction (pos , ctf_map .current_map .teams [tname ].look_pos or ctf_map .current_map .flag_center )
268
+ ).y
269
+ else
270
+ pos = vector .add (ctf_map .current_map .pos1 , vector .divide (ctf_map .current_map .size , 2 ))
271
+ rotation_y = player :get_look_horizontal ()
272
+ end
263
273
264
274
local function apply ()
265
275
player :set_pos (pos )
@@ -424,6 +434,8 @@ local delete_queue = {}
424
434
local team_switch_after_capture = false
425
435
426
436
return {
437
+ tp_player_near_flag = tp_player_near_flag ,
438
+
427
439
on_new_match = function ()
428
440
team_list = {}
429
441
for tname in pairs (ctf_map .current_map .teams ) do
@@ -467,8 +479,10 @@ return {
467
479
local total_time = (minetest .get_us_time () - loading_screen_time ) / 1e6
468
480
469
481
minetest .after (math.max (0 , LOADING_SCREEN_TARGET_TIME - total_time ), function ()
470
- hud :clear_all ()
482
+ mapload_huds :clear_all ()
471
483
set_playertags_state (PLAYERTAGS_ON )
484
+
485
+ ctf_modebase .build_timer .start ()
472
486
end )
473
487
end
474
488
end ,
@@ -480,6 +494,8 @@ return {
480
494
delete_queue = {ctf_map .current_map .pos1 , ctf_map .current_map .pos2 }
481
495
end
482
496
end ,
497
+ -- If you set this in a mode def it will replace the call to ctf_teams.allocate_teams() in match.lua
498
+ -- allocate_teams = function()
483
499
team_allocator = function (player )
484
500
player = PlayerName (player )
485
501
@@ -671,15 +687,7 @@ return {
671
687
672
688
celebrate_team (pteam )
673
689
674
- local text = " has captured the flag"
675
- if many_teams then
676
- text = " has captured the flag of team(s) " .. HumanReadable (teamnames )
677
- minetest .chat_send_all (
678
- minetest .colorize (tcolor , pname ) ..
679
- minetest .colorize (FLAG_MESSAGE_COLOR , text )
680
- )
681
- end
682
- ctf_modebase .announce (string.format (" Player %s (team %s)%s" , pname , pteam , text ))
690
+
683
691
684
692
ctf_modebase .flag_huds .untrack_capturer (pname )
685
693
@@ -690,7 +698,19 @@ return {
690
698
score = math.max (75 , math.min (500 , score ))
691
699
capture_reward = capture_reward + score
692
700
end
693
-
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 ))
694
714
local team_score = team_scores [pteam ].score
695
715
for teammate in pairs (ctf_teams .online_players [pteam ].players ) do
696
716
if teammate ~= pname then
@@ -705,12 +725,12 @@ return {
705
725
teams_left = teams_left - # teamnames
706
726
707
727
if teams_left <= 1 then
708
- local capture_text = " Player %s captured"
728
+ local capture_text = " Player %s captured and got %d points "
709
729
if many_teams then
710
- capture_text = " Player %s captured the last flag"
730
+ capture_text = " Player %s captured the last flag and got %d points "
711
731
end
712
732
713
- 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 ))
714
734
715
735
local win_text = HumanReadable (pteam ) .. " Team Wins!"
716
736
@@ -730,7 +750,7 @@ return {
730
750
731
751
for lost_player in pairs (ctf_teams .online_players [lost_team ].players ) do
732
752
team_switch_after_capture = true
733
- ctf_teams .allocate_player (lost_player )
753
+ ctf_teams .allocate_player (lost_player )
734
754
team_switch_after_capture = false
735
755
end
736
756
end
0 commit comments