Remove the ability for enemies to access a team's chest
This commit is contained in:
parent
970160afdb
commit
a7d2b5961f
3 changed files with 41 additions and 12 deletions
|
@ -6,14 +6,12 @@ local items = {
|
||||||
"* Look for guns, grenades and other resources in chests.",
|
"* Look for guns, grenades and other resources in chests.",
|
||||||
"* Guns can destroy blocks.",
|
"* Guns can destroy blocks.",
|
||||||
"* Good swords do more damage than guns, but need to be used at close range.",
|
"* Good swords do more damage than guns, but need to be used at close range.",
|
||||||
"* If the match is getting boring, type /vote, then /yes to vote yes.",
|
|
||||||
"* Use apples to replenish health.",
|
"* Use apples to replenish health.",
|
||||||
"",
|
"",
|
||||||
|
|
||||||
minetest.colorize("#66a0ff", "Team Co-op"),
|
minetest.colorize("#66a0ff", "Team Co-op"),
|
||||||
"",
|
"",
|
||||||
"* Your team has a chest near your flag.",
|
"* Your team has a chest near your flag.",
|
||||||
" Be warned that other teams can steal from it.",
|
|
||||||
"* Your team name is displayed in the top left.",
|
"* Your team name is displayed in the top left.",
|
||||||
" to talk with only your team, type: /t message",
|
" to talk with only your team, type: /t message",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -70,12 +70,19 @@ for _, color in pairs(colors) do
|
||||||
inv:set_size("pro", 3*4)
|
inv:set_size("pro", 3*4)
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, player)
|
on_rightclick = function(pos, node, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owning_team = meta:get_string("owner_team")
|
||||||
|
if owning_team ~= ctf.player(player:get_player_name()).team then
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "You're not on team " .. owning_team)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local chestinv = "nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z
|
local chestinv = "nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z
|
||||||
local is_pro = get_is_player_pro(player)
|
local is_pro = get_is_player_pro(player)
|
||||||
|
|
||||||
local formspec =
|
local formspec =
|
||||||
"size[8,9]" ..
|
"size[8,9]" ..
|
||||||
"label[0,-0.2;" .. minetest.formspec_escape("Any player can take from here, including enemies") .. "]" ..
|
"label[0,-0.2;" .. minetest.formspec_escape("Any team member can take from here") .. "]" ..
|
||||||
default.gui_bg ..
|
default.gui_bg ..
|
||||||
default.gui_bg_img ..
|
default.gui_bg_img ..
|
||||||
default.gui_slots ..
|
default.gui_slots ..
|
||||||
|
@ -103,6 +110,13 @@ for _, color in pairs(colors) do
|
||||||
|
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||||
to_list, to_index, count, player)
|
to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owning_team = meta:get_string("owner_team")
|
||||||
|
if owning_team ~= ctf.player(player:get_player_name()).team then
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "You're not on team " .. owning_team)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
if (from_list ~= "pro" and to_list ~= "pro") or get_is_player_pro(player) then
|
if (from_list ~= "pro" and to_list ~= "pro") or get_is_player_pro(player) then
|
||||||
return count
|
return count
|
||||||
else
|
else
|
||||||
|
@ -110,6 +124,13 @@ for _, color in pairs(colors) do
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owning_team = meta:get_string("owner_team")
|
||||||
|
if owning_team ~= ctf.player(player:get_player_name()).team then
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "You're not on team " .. owning_team)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
if listname ~= "pro" or get_is_player_pro(player) then
|
if listname ~= "pro" or get_is_player_pro(player) then
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
else
|
else
|
||||||
|
@ -117,6 +138,13 @@ for _, color in pairs(colors) do
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owning_team = meta:get_string("owner_team")
|
||||||
|
if owning_team ~= ctf.player(player:get_player_name()).team then
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "You're not on team " .. owning_team)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
if listname ~= "pro" or get_is_player_pro(player) then
|
if listname ~= "pro" or get_is_player_pro(player) then
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
else
|
else
|
||||||
|
@ -178,11 +206,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
z = flag.z + dz
|
z = flag.z + dz
|
||||||
}
|
}
|
||||||
minetest.set_node(pos, chest)
|
minetest.set_node(pos, chest)
|
||||||
local inv = minetest.get_inventory({type = "node", pos=pos})
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner_team", tname)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
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:cobble 99"))
|
inv:add_item("main", ItemStack("default:cobble 99"))
|
||||||
inv:add_item("main", ItemStack("default:wood 99"))
|
inv:add_item("main", ItemStack("default:wood 99"))
|
||||||
inv:add_item("main", ItemStack("default:glass 10"))
|
inv:add_item("main", ItemStack("default:glass 5"))
|
||||||
inv:add_item("main", ItemStack("default:torch 10"))
|
inv:add_item("main", ItemStack("default:torch 10"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,9 +48,9 @@ end
|
||||||
function random_messages.read_messages()
|
function random_messages.read_messages()
|
||||||
random_messages.messages = {
|
random_messages.messages = {
|
||||||
"To talk to only your team, start your messages with /t. For example, /t Hello team!",
|
"To talk to only your team, start your messages with /t. For example, /t Hello team!",
|
||||||
"If the map is ruined, use /vote to start a new vote to skip the current match.",
|
|
||||||
"Eat apples to restore health quickly.",
|
"Eat apples to restore health quickly.",
|
||||||
"You can steal items from the other team's chest."
|
"Steel swords do more damage than guns, but you need to be up close.",
|
||||||
|
"Gain more score by killing more than you die, or by capturing the flag."
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,11 +84,11 @@ function random_messages.add_message(t)
|
||||||
end
|
end
|
||||||
|
|
||||||
function random_messages.save_messages()
|
function random_messages.save_messages()
|
||||||
local output = io.open(minetest.get_worldpath().."/random_messages","w")
|
local output = io.open(minetest.get_worldpath().."/random_messages","w")
|
||||||
for k,v in pairs(random_messages.messages) do
|
for k,v in pairs(random_messages.messages) do
|
||||||
output:write(v .. "\n")
|
output:write(v .. "\n")
|
||||||
end
|
end
|
||||||
io.close(output)
|
io.close(output)
|
||||||
end
|
end
|
||||||
|
|
||||||
--When server starts:
|
--When server starts:
|
||||||
|
|
Loading…
Reference in a new issue