Shuffle spawn positions as well
This commit is contained in:
parent
1f3424289e
commit
797111174b
@ -8,6 +8,8 @@ local countdown = false
|
||||
local registrants = {}
|
||||
local currGame = {}
|
||||
|
||||
local spots_shuffled = {}
|
||||
|
||||
local timer_hudids = {}
|
||||
|
||||
local timer = nil
|
||||
@ -222,7 +224,7 @@ local start_game_now = function(contestants)
|
||||
if spawning.is_spawn("player_"..i) then
|
||||
spawning.spawn(player, "player_"..i)
|
||||
end
|
||||
end, {player, i})
|
||||
end, {player, spots_shuffled[i]})
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all("The Hungry Games has begun!")
|
||||
@ -265,8 +267,8 @@ local start_game = function()
|
||||
print("filling chests...")
|
||||
random_chests.refill()
|
||||
--Find out how many spots there are to spawn
|
||||
local spots = get_spots()
|
||||
local diff = spots-table.getn(registrants)
|
||||
local nspots = get_spots()
|
||||
local diff = nspots-table.getn(registrants)
|
||||
local contestants = {}
|
||||
|
||||
-- Shuffle players
|
||||
@ -281,6 +283,20 @@ local start_game = function()
|
||||
players_shuffled[j] = players[shuffle_free[rnd]]
|
||||
table.remove(shuffle_free, rnd)
|
||||
end
|
||||
|
||||
-- Shuffle spots as well
|
||||
shuffle_free = {}
|
||||
spots_shuffled = {}
|
||||
for j=1,nspots do
|
||||
shuffle_free[j] = j
|
||||
end
|
||||
for j=1,nspots do
|
||||
local rnd = math.random(1, #shuffle_free)
|
||||
spots_shuffled[j] = shuffle_free[rnd]
|
||||
table.remove(shuffle_free, rnd)
|
||||
end
|
||||
|
||||
-- Spawn players
|
||||
for p=1,#players_shuffled do
|
||||
local player = players_shuffled[p]
|
||||
if diff > 0 then
|
||||
@ -300,7 +316,7 @@ local start_game = function()
|
||||
else
|
||||
minetest.chat_send_player(name, "There are no spots for you to spawn!")
|
||||
end
|
||||
end, {player, i})
|
||||
end, {player, spots_shuffled[i]})
|
||||
if registrants[player:get_player_name()] then i = i + 1 end
|
||||
end
|
||||
minetest.setting_set("enable_damage", "false")
|
||||
@ -308,8 +324,8 @@ local start_game = function()
|
||||
set_timer("starting", hungry_games.countdown)
|
||||
for i=1, (hungry_games.countdown-1) do
|
||||
minetest.after(i, function(list)
|
||||
contestants = list[1]
|
||||
i = list[2]
|
||||
local contestants = list[1]
|
||||
local i = list[2]
|
||||
local time_left = hungry_games.countdown-i
|
||||
if time_left%4==0 and time_left >= 16 then
|
||||
minetest.sound_play("hungry_games_starting_drum")
|
||||
@ -322,7 +338,7 @@ local start_game = function()
|
||||
if spawning.is_spawn("player_"..i) then
|
||||
spawning.spawn(player, "player_"..i)
|
||||
end
|
||||
end, {player, i})
|
||||
end, {player, spots_shuffled[i]})
|
||||
end
|
||||
end, {contestants,i})
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user