@@ -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
0 commit comments