Implement random spawn within 3x3 area around flag (#437)

This commit is contained in:
ANAND 2019-07-24 19:24:14 +05:30 committed by Thomas--S
parent b5d19bcf5b
commit 99338c3013

View file

@ -41,3 +41,18 @@ function ctf_map.place_base(color, pos)
inv:add_item("main", ItemStack("default:glass 5")) inv:add_item("main", ItemStack("default:glass 5"))
inv:add_item("main", ItemStack("default:torch 10")) inv:add_item("main", ItemStack("default:torch 10"))
end end
-- Override ctf.get_spawn to implement random spawns
local old_spawn = ctf.get_spawn
function ctf.get_spawn(team)
local spawn = old_spawn(team)
if not spawn then
return
end
return vector.add(spawn, {
x = math.random(-1, 1),
y = 0,
z = math.random(-1, 1)
})
end