Fix bug on duplicated GUI settings, remove non-essential mods from CTF PvP Engine

master
rubenwardy 2015-07-17 18:09:44 +01:00
parent 9d15991768
commit 17e7a2b529
9 changed files with 4 additions and 283 deletions

View File

@ -18,6 +18,10 @@ function ctf.gui.register_tab(name, title, func)
title = title,
func = func
}
if ctf._defsettings and ctf._defsettings["gui.tab." .. name] == nil then
ctf._set("gui.tab." .. name, true)
end
end
function ctf.gui.show(name, tab, team)

View File

@ -5,7 +5,6 @@ ctf.register_on_init(function()
ctf._set("flag.capture_take", false)
ctf._set("flag.names", true)
ctf._set("flag.protect_distance", 25)
ctf._set("gui.tab.flags", true)
ctf._set("gui.team.teleport_to_flag", true)
ctf._set("gui.team.teleport_to_spawn", false)
ctf._set("flag.capture_mode", "take")

View File

@ -1,2 +0,0 @@
ctf
ctf_flag

View File

@ -1,131 +0,0 @@
ctf.register_on_init(function()
ctf._set("endgame.destroy_team", false)
ctf._set("endgame.break_alliances", true)
ctf._set("endgame.reset_on_winner", false)
ctf._set("newgame.teams", "")
ctf._set("newgame.clear_inv", false)
end)
ctf_flag.register_on_capture(function(attname, flag)
if not ctf.setting("endgame.destroy_team") then
return
end
local fl_team = ctf.team(flag.team)
if fl_team and #fl_team.flags == 0 then
ctf.action("endgame", flag.team .. " was defeated.")
ctf.remove_team(flag.team)
minetest.chat_send_all(flag.team .. " has been defeated!")
end
if ctf.setting("endgame.reset_on_winner") then
local winner = nil
for name, team in pairs(ctf.teams) do
if winner then
return
end
winner = name
end
-- Only one team left!
ctf.action("endgame", winner .. " won!")
minetest.chat_send_all("Team " .. winner .. " won!")
minetest.chat_send_all("Resetting the map, this may take a few moments...")
minetest.after(0.5, function()
--minetest.delete_area(vector.new(-16*4, -16*4, -16*4), vector.new(16*4, 16*4, 16*4))
minetest.after(1, function()
ctf.reset()
end)
end)
end
end)
local function safe_place(pos, node)
ctf.log("flash", "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("flash", "failed to place node, retrying...")
minetest.after(0.5, function()
safe_place(pos, node)
end)
end
end
local claimed = ctf_flag.collect_claimed()
for i, flag in pairs(claimed) do
flag.claimed = nil
end
ctf.register_on_new_game(function()
local teams = ctf.setting("newgame.teams")
if teams:trim() == "" then
return
end
ctf.log("flash", "Setting up new game!")
teams = teams:split(";")
local pos = {}
for i, v in pairs(teams) do
local team = v:split(",")
if #team == 5 then
local name = team[1]:trim()
local color = team[2]:trim()
local x = tonumber(team[3]:trim())
local y = tonumber(team[4]:trim())
local z = tonumber(team[5]:trim())
pos[name] = {
x = x,
y = y,
z = z
}
ctf.team({
name=name,
color=color,
add_team=true
})
ctf_flag.add(name, pos[name])
else
ctf.warning("flash", "Invalid team setup: " .. dump(v))
end
end
minetest.after(0, function()
for name, p in pairs(pos) do
safe_place(p, {name="ctf_flag:flag"})
ctf_flag.update(p)
end
end)
for i, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local alloc_mode = tonumber(ctf.setting("allocate_mode"))
local team = ctf.autoalloc(name, alloc_mode)
if alloc_mode ~= 0 and team then
ctf.log("autoalloc", name .. " was allocated to " .. team)
ctf.join(name, team)
end
team = ctf.player(name).team
if ctf.team(team) then
local spawn = ctf.get_spawn(team)
if spawn then
player:moveto(spawn, false)
end
end
if ctf.setting("newgame.clear_inv") then
local inv = player:get_inventory()
inv:set_list("main", {})
inv:set_list("craft", {})
give_initial_stuff(player)
end
player:set_hp(20)
end
minetest.chat_send_all("Next round!")
end)

View File

@ -1 +0,0 @@
ctf

View File

@ -1,147 +0,0 @@
ctf.register_on_init(function()
ctf.log("turrets", "Initialising...")
ctf._set("turrets", true)
end)
if ctf.setting("turrets") then
ARROW_DAMAGE = 2
ARROW_VELOCITY = 2
minetest.register_node("ctf_turret:turret", {
description = "Team Turret",
tiles = {
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
},
drawtype="nodebox",
groups={attached_node=1},
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,0.000000,0.500000}, --NodeBox 1
{-0.437500,0.000000,-0.437500,0.431250,0.187500,0.431250}, --NodeBox 2
{-0.187500,0.187500,-0.187500,0.187500,0.500000,0.187500}, --NodeBox 3
}
},
groups = {cracky=3, stone=1},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Unowned turret")
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
if meta and ctf.players and ctf.player(placer:get_player_name()) and ctf.player(placer:get_player_name()).team then
local team = ctf.player(placer:get_player_name()).team
meta:set_string("team", team)
meta:set_string("infotext", "Owned by "..team)
else
minetest.set_node(pos,{name="air"})
end
end
})
minetest.register_abm({
nodenames = {"ctf_turret:turret"},
interval = 0.25,
chance = 4,
action = function(pos, node)
local meta = minetest.get_meta(pos)
if not meta then
return
end
local team = meta:get_string("team")
if not team then
return
end
local app = ctf.get_territory_owner(pos)
if app and app~=team then
team = app
meta:set_string("team",team)
meta:set_string("infotext", "Owned by "..team)
end
if not team then
return
end
local objects = minetest.get_objects_inside_radius(pos, 15)
for _,obj in ipairs(objects) do
if (
obj:is_player() and
ctf.players and
ctf.player(obj:get_player_name()) and
ctf.player(obj:get_player_name()).team ~= team
)then
-- Calculate stuff
local obj_p = obj:getpos()
local calc = {
x=obj_p.x - pos.x,
y=obj_p.y+1 - pos.y,
z=obj_p.z - pos.z
}
-- Create bullet entity
local bullet=minetest.add_entity({x=pos.x,y=pos.y+0.5,z=pos.z}, "ctf_turret:arrow_entity")
-- Set velocity
bullet:setvelocity({x=calc.x * ARROW_VELOCITY,y=calc.y * ARROW_VELOCITY,z=calc.z * ARROW_VELOCITY})
-- Play sound
minetest.sound_play("laser", {pos = pos, gain = 1.0, max_hear_distance = 50,})
end
end
end
})
-- The Arrow Entity
THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual_size = {x=0.2, y=0.2},
textures = {"bullet.png"},
lastpos={},
collisionbox = {-0.17,-0.17,-0.17,0.17,0.17,0.17},
on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
if self.timer > 2 then
self.object:remove()
end
if self.timer > 0.2 then
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
for k, obj in pairs(objs) do
if obj:is_player() then
obj:set_hp(obj:get_hp() - ARROW_DAMAGE)
self.object:remove()
end
end
end
local node = minetest.get_node(pos)
if node.name ~= "air" and node.name ~= "ctf_turret:turret" then
--minetest.add_item(self.lastpos, "throwing:arrow")
self.object:remove()
end
end
}
minetest.register_entity("ctf_turret:arrow_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = "ctf_turret:turret",
recipe = {
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"},
{"default:gold_ingot", "default:mese_crystal", "default:gold_ingot"},
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"}
}
})
end

View File

@ -1 +0,0 @@
http://freesound.org/people/aust_paul/sounds/30935/

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B