Random spawn locations
This commit is contained in:
parent
277ada0bdc
commit
c7c95a757e
1 changed files with 38 additions and 0 deletions
|
@ -1,3 +1,41 @@
|
||||||
|
local old = ctf.get_spawn
|
||||||
|
function ctf.get_spawn(tname)
|
||||||
|
local team = ctf.team(tname)
|
||||||
|
if team and #team.flags >= 1 then
|
||||||
|
local flag = team.flags[1]
|
||||||
|
local i = 0
|
||||||
|
local r = 6
|
||||||
|
while i < 6 do
|
||||||
|
i = i + 1
|
||||||
|
local pos = {x=0, z=0}
|
||||||
|
pos.x = flag.x + math.random() * 40 - 20
|
||||||
|
pos.z = math.random() * 30 + 49
|
||||||
|
if pos.x < -99 then
|
||||||
|
pos.x = -99
|
||||||
|
end
|
||||||
|
if pos.x > 99 then
|
||||||
|
pos.x = 99
|
||||||
|
end
|
||||||
|
if team.flags[1].z < 0 then
|
||||||
|
pos.z = -pos.z
|
||||||
|
end
|
||||||
|
local res = minetest.find_nodes_in_area_under_air(
|
||||||
|
{ x = pos.x - r, y = 2, z = pos.z - r},
|
||||||
|
{ x = pos.x + r, y = 17, z = pos.z + r},
|
||||||
|
{"default:dirt_with_grass"})
|
||||||
|
if #res > 0 then
|
||||||
|
res[1].y = res[1].y + 1
|
||||||
|
team.spawn = res[1]
|
||||||
|
return res[1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return team.spawn or old(tname)
|
||||||
|
else
|
||||||
|
return team.spawn
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local chest_formspec =
|
local chest_formspec =
|
||||||
"size[8,9]" ..
|
"size[8,9]" ..
|
||||||
default.gui_bg ..
|
default.gui_bg ..
|
||||||
|
|
Loading…
Reference in a new issue