Removed power system
This commit is contained in:
parent
90f9510b90
commit
da26fed15a
@ -212,15 +212,6 @@ function ctf.load()
|
|||||||
for i = 1, #ctf.registered_on_load do
|
for i = 1, #ctf.registered_on_load do
|
||||||
ctf.registered_on_load[i](table)
|
ctf.registered_on_load[i](table)
|
||||||
end
|
end
|
||||||
-- Convert old data
|
|
||||||
for teamname,unused in pairs(ctf.teams) do
|
|
||||||
if not ctf.teams[teamname].power then
|
|
||||||
ctf.teams[teamname].power = 0
|
|
||||||
for player,unused in pairs(ctf.teams[teamname].players) do
|
|
||||||
ctf.teams[teamname].power = ctf.teams[teamname].power + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ctf._loaddata = table
|
ctf._loaddata = table
|
||||||
|
@ -39,8 +39,7 @@ function ctf.create_team(name, data)
|
|||||||
spawn = nil,
|
spawn = nil,
|
||||||
players = {},
|
players = {},
|
||||||
applications = {},
|
applications = {},
|
||||||
access = {},
|
access = {}
|
||||||
power = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i = 1, #ctf.registered_on_new_team do
|
for i = 1, #ctf.registered_on_new_team do
|
||||||
@ -166,18 +165,18 @@ function ctf.application_join(name, tname)
|
|||||||
ctf.log("teams", "Missing parameters to ctf.request_join")
|
ctf.log("teams", "Missing parameters to ctf.request_join")
|
||||||
end
|
end
|
||||||
local player = ctf.player(name)
|
local player = ctf.player(name)
|
||||||
|
|
||||||
if player.team and player.team == tname then
|
if player.team and player.team == tname then
|
||||||
minetest.chat_send_player(name, "You are already a member of team " .. tname)
|
minetest.chat_send_player(name, "You are already a member of team " .. tname)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if not ctf.setting("players_can_change_team") and player.team and ctf.team(player.team) then
|
if not ctf.setting("players_can_change_team") and player.team and ctf.team(player.team) then
|
||||||
ctf.action("teams", name .. " requested to change to " .. tname)
|
ctf.action("teams", name .. " requested to change to " .. tname)
|
||||||
minetest.chat_send_player(name, "You are not allowed to switch teams, traitor!")
|
minetest.chat_send_player(name, "You are not allowed to switch teams, traitor!")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local team_data = ctf.team(tname)
|
local team_data = ctf.team(tname)
|
||||||
if not team_data then
|
if not team_data then
|
||||||
minetest.chat_send_player(name, "No such team.")
|
minetest.chat_send_player(name, "No such team.")
|
||||||
@ -185,7 +184,7 @@ function ctf.application_join(name, tname)
|
|||||||
minetest.log("action", name .. " requested to join to " .. tname .. ", which doesn't exist")
|
minetest.log("action", name .. " requested to join to " .. tname .. ", which doesn't exist")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(team_data.applications,name)
|
table.insert(team_data.applications,name)
|
||||||
--ctf.post(tname, {msg = name .. " has applied to join!" })
|
--ctf.post(tname, {msg = name .. " has applied to join!" })
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
@ -485,7 +484,7 @@ function ctf.access_remove_team_all(name)
|
|||||||
end
|
end
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Player joins team
|
-- Player joins team
|
||||||
-- Called by /join, /team join, auto allocate or by response of the team manager.
|
-- Called by /join, /team join, auto allocate or by response of the team manager.
|
||||||
function ctf.join(name, team, force, by)
|
function ctf.join(name, team, force, by)
|
||||||
@ -540,9 +539,7 @@ function ctf.join(name, team, force, by)
|
|||||||
|
|
||||||
player.team = team
|
player.team = team
|
||||||
team_data.players[player.name] = player
|
team_data.players[player.name] = player
|
||||||
|
|
||||||
ctf.team(team).power = ctf.team(team).power + 1
|
|
||||||
|
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
|
|
||||||
minetest.log("action", name .. " joined team " .. team)
|
minetest.log("action", name .. " joined team " .. team)
|
||||||
|
@ -215,7 +215,7 @@ minetest.register_chatcommand("access", {
|
|||||||
elseif param ~= "" and param ~= nil then
|
elseif param ~= "" and param ~= nil then
|
||||||
minetest.chat_send_player(name, "'"..param.."' is an invalid parameter to /access")
|
minetest.chat_send_player(name, "'"..param.."' is an invalid parameter to /access")
|
||||||
access_console_help(name)
|
access_console_help(name)
|
||||||
else
|
else
|
||||||
access_console_help(name)
|
access_console_help(name)
|
||||||
return true, "Showing access help"
|
return true, "Showing access help"
|
||||||
end
|
end
|
||||||
@ -365,7 +365,6 @@ minetest.register_chatcommand("teamkick", {
|
|||||||
if ctf.remove_player(param) then
|
if ctf.remove_player(param) then
|
||||||
ctf.player(param).auth = false
|
ctf.player(param).auth = false
|
||||||
ctf.player(param).recuiter = false
|
ctf.player(param).recuiter = false
|
||||||
ctf.team(team).power = ctf.team(team).power - 1
|
|
||||||
return true, "Kicked " .. param .. " from " .. team .. "!"
|
return true, "Kicked " .. param .. " from " .. team .. "!"
|
||||||
else
|
else
|
||||||
return false, "Failed to kick " .. param.. "!"
|
return false, "Failed to kick " .. param.. "!"
|
||||||
@ -386,7 +385,6 @@ minetest.register_chatcommand("teamleave", {
|
|||||||
if ctf.remove_player(name) then
|
if ctf.remove_player(name) then
|
||||||
ctf.player(name).auth = false
|
ctf.player(name).auth = false
|
||||||
ctf.player(name).recuiter = false
|
ctf.player(name).recuiter = false
|
||||||
ctf.team(team).power = ctf.team(team).power - 1
|
|
||||||
-- Disband if there are zero players lefted on team
|
-- Disband if there are zero players lefted on team
|
||||||
local disband = true
|
local disband = true
|
||||||
local teamdata = ctf.team(team)
|
local teamdata = ctf.team(team)
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
local r = ctf.setting("flag.nobuild_radius")
|
local r = ctf.setting("flag.nobuild_radius")
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
|
local function elementsInTable(t)
|
||||||
|
local n = 0
|
||||||
|
for _ in pairs(t) do n = n + 1 end
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
|
||||||
local function can_place_flag(pos)
|
local function can_place_flag(pos)
|
||||||
local lpos = pos
|
local lpos = pos
|
||||||
local pos1 = {x=lpos.x-r+1,y=lpos.y,z=lpos.z-r+1}
|
local pos1 = {x=lpos.x-r+1,y=lpos.y,z=lpos.z-r+1}
|
||||||
@ -210,7 +216,7 @@ ctf_flag = {
|
|||||||
minetest.chat_send_player(name, "You are at peace with this team!")
|
minetest.chat_send_player(name, "You are at peace with this team!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local g_pos = players_glitching[name]
|
local g_pos = players_glitching[name]
|
||||||
if g_pos then
|
if g_pos then
|
||||||
minetest.get_player_by_name(name):set_pos(g_pos)
|
minetest.get_player_by_name(name):set_pos(g_pos)
|
||||||
@ -288,13 +294,14 @@ ctf_flag = {
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if ctf.team(tplayer.team).power and ctf.team(tplayer.team).power < 1 then
|
local tname = tplayer.team
|
||||||
minetest.chat_send_player(name, "You need more members to be-able to place more flags.")
|
local team = ctf.team(tplayer.team)
|
||||||
|
|
||||||
|
if elementsInTable(team.players) <= elementsInTable(team.flags) then
|
||||||
|
minetest.chat_send_player(name, "You need more members to be able to place more flags.")
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local tname = tplayer.team
|
|
||||||
local team = ctf.team(tplayer.team)
|
|
||||||
meta:set_string("infotext", tname .. "'s flag")
|
meta:set_string("infotext", tname .. "'s flag")
|
||||||
|
|
||||||
-- add flag
|
-- add flag
|
||||||
@ -333,10 +340,6 @@ ctf_flag = {
|
|||||||
local meta2 = minetest.get_meta(pos2)
|
local meta2 = minetest.get_meta(pos2)
|
||||||
meta2:set_string("infotext", tname.."'s flag")
|
meta2:set_string("infotext", tname.."'s flag")
|
||||||
|
|
||||||
if ctf.team(tplayer.team).power then
|
|
||||||
ctf.team(tplayer.team).power = ctf.team(tplayer.team).power - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
else
|
else
|
||||||
|
@ -158,10 +158,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ctf_flag.delete(team,pos)
|
ctf_flag.delete(team,pos)
|
||||||
|
|
||||||
if ctf.team(team).power then
|
|
||||||
ctf.team(team).power = ctf.team(team).power + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.set_node(pos,{name="air"})
|
minetest.set_node(pos,{name="air"})
|
||||||
pos.y=pos.y+1
|
pos.y=pos.y+1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user