2019-03-17 01:36:15 +00:00
|
|
|
function ctf_map.place_base(color, pos)
|
2019-10-09 06:19:29 +00:00
|
|
|
-- Spawn base
|
2018-01-27 19:12:08 +00:00
|
|
|
for x = pos.x - 2, pos.x + 2 do
|
2019-10-09 06:19:29 +00:00
|
|
|
for z = pos.z - 2, pos.z + 2 do
|
|
|
|
minetest.set_node({ x = x, y = pos.y - 1, z = z },
|
|
|
|
{ name = ctf_map.map.base_node or "ctf_map:cobble" })
|
|
|
|
end
|
2018-01-27 19:12:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Check for trees
|
2019-10-09 06:19:29 +00:00
|
|
|
for y = pos.y, pos.y + 3 do
|
|
|
|
for x = pos.x - 3, pos.x + 3 do
|
|
|
|
for z = pos.z - 3, pos.z + 3 do
|
|
|
|
local pos2 = { x = x, y = y, z = z }
|
|
|
|
if minetest.get_node(pos2).name == "default:tree" then
|
|
|
|
minetest.set_node(pos2, { name = "air" })
|
2018-01-27 19:12:08 +00:00
|
|
|
end
|
|
|
|
end
|
2019-10-09 06:19:29 +00:00
|
|
|
end
|
|
|
|
end
|
2018-01-27 19:12:08 +00:00
|
|
|
|
|
|
|
-- Spawn chest
|
2019-10-09 06:19:29 +00:00
|
|
|
local chest = { name = "ctf_map:chest_" .. color }
|
2018-01-27 19:12:08 +00:00
|
|
|
local dz = 2
|
|
|
|
if pos.z < 0 then
|
|
|
|
dz = -2
|
2019-10-09 06:19:29 +00:00
|
|
|
chest.param2 = minetest.dir_to_facedir({ x = 0, y = 0, z = -1 })
|
2018-01-27 19:12:08 +00:00
|
|
|
end
|
2018-04-06 13:04:56 +00:00
|
|
|
local pos3 = {
|
2018-01-27 19:12:08 +00:00
|
|
|
x = pos.x,
|
|
|
|
y = pos.y,
|
|
|
|
z = pos.z + dz
|
|
|
|
}
|
2018-04-06 13:04:56 +00:00
|
|
|
minetest.set_node(pos3, chest)
|
|
|
|
local inv = minetest.get_meta(pos3):get_inventory()
|
2018-01-27 19:12:08 +00:00
|
|
|
inv:add_item("main", ItemStack("default:cobble 99"))
|
|
|
|
inv:add_item("main", ItemStack("default:cobble 99"))
|
|
|
|
inv:add_item("main", ItemStack("default:cobble 99"))
|
|
|
|
inv:add_item("main", ItemStack("default:wood 99"))
|
|
|
|
inv:add_item("main", ItemStack("default:stick 30"))
|
|
|
|
inv:add_item("main", ItemStack("default:glass 5"))
|
|
|
|
inv:add_item("main", ItemStack("default:torch 10"))
|
|
|
|
end
|
2019-07-24 13:54:14 +00:00
|
|
|
|
|
|
|
-- 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
|