Start map reset, ie: Flash CTF mode
This commit is contained in:
parent
232cc7b35f
commit
61830d59bb
@ -4,6 +4,18 @@ ctf.register_on_init(function()
|
||||
ctf._set("endgame.reset_on_winner", true)
|
||||
end)
|
||||
|
||||
local function safe_place(pos, node)
|
||||
ctf.log("endgame", "attempting to place...")
|
||||
minetest.get_voxel_manip(pos, { x = pos.x + 1, y = pos.y + 1, z = pos.z + 1})
|
||||
minetest.set_node(pos, node)
|
||||
if minetest.get_node(pos).name ~= node.name then
|
||||
ctf.error("endgame", "failed to place node, retrying...")
|
||||
minetest.after(0.5, function()
|
||||
safe_place(pos, node)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
ctf_flag.register_on_capture(function(attname, flag)
|
||||
if not ctf.setting("endgame.destroy_team") then
|
||||
return
|
||||
@ -31,20 +43,37 @@ ctf_flag.register_on_capture(function(attname, flag)
|
||||
minetest.chat_send_all("Resetting the map, this may take a few moments...")
|
||||
minetest.after(0.5, function()
|
||||
ctf.reset()
|
||||
minetest.delete_area(vector.new(-16*2, -16*2, -16*2), vector.new(16*2, 16*2, 16*2))
|
||||
minetest.delete_area(vector.new(-16*3, -16*3, -16*3), vector.new(16*3, 16*3, 16*3))
|
||||
ctf.team({name="red", color="red", add_team=true})
|
||||
ctf.team({name="blue", color="blue", add_team=true})
|
||||
for name, player in pairs(ctf.players) do
|
||||
local alloc_mode = tonumber(ctf.setting("allocate_mode"))
|
||||
if alloc_mode == 0 then
|
||||
return
|
||||
|
||||
minetest.after(1, function()
|
||||
local fred = {x=15, y=7, z=39, team="red"}
|
||||
local fblue = {x=-9,y=9,z=-50, team="blue"}
|
||||
ctf_flag.add("red", fred)
|
||||
ctf_flag.add("blue", fblue)
|
||||
safe_place(fred, {name="ctf_flag:flag"})
|
||||
safe_place(fblue, {name="ctf_flag:flag"})
|
||||
|
||||
for i, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local inv = player:get_inventory()
|
||||
inv:set_list("main", {})
|
||||
inv:set_list("craft", {})
|
||||
|
||||
local alloc_mode = tonumber(ctf.setting("allocate_mode"))
|
||||
if alloc_mode == 0 then
|
||||
return
|
||||
end
|
||||
local team = ctf.autoalloc(name, alloc_mode)
|
||||
if team then
|
||||
ctf.log("autoalloc", name .. " was allocated to " .. team)
|
||||
ctf.join(name, team)
|
||||
end
|
||||
end
|
||||
local team = ctf.autoalloc(name, alloc_mode)
|
||||
if team then
|
||||
ctf.log("autoalloc", name .. " was allocated to " .. team)
|
||||
ctf.join(name, team)
|
||||
end
|
||||
end
|
||||
minetest.log("endgame", "reset done")
|
||||
minetest.chat_send_all("All done! Next round!")
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
@ -89,6 +89,9 @@ function ctf_flag.add(team, pos)
|
||||
return
|
||||
end
|
||||
|
||||
ctf.log("flag", "Adding flag to " .. team .. " at (" .. pos.x ..
|
||||
", " .. pos.y .. ", " .. pos.z .. ")")
|
||||
|
||||
if not ctf.team(team).flags then
|
||||
ctf.team(team).flags = {}
|
||||
end
|
||||
@ -136,6 +139,9 @@ function ctf_flag.delete(team, pos)
|
||||
return
|
||||
end
|
||||
|
||||
ctf.log("flag", "Deleting flag from " .. team .. " at (" .. pos.x ..
|
||||
", " .. pos.y .. ", " .. pos.z .. ")")
|
||||
|
||||
for i = 1, #ctf.team(team).flags do
|
||||
if (
|
||||
ctf.team(team).flags[i].x == pos.x and
|
||||
|
Loading…
x
Reference in New Issue
Block a user