164 lines
5.0 KiB
Lua
164 lines
5.0 KiB
Lua
local S = minetest.get_translator("the_bridge")
|
|
|
|
local function set_player_inventory(player)
|
|
local stonestack = ItemStack("default:stone 99")
|
|
local pickstack = ItemStack("the_bridge:diapick")
|
|
local swordstack = ItemStack("the_bridge:stonesword")
|
|
local gapplestack = ItemStack("the_bridge:gapple 16")
|
|
|
|
local inv = player:get_inventory()
|
|
local hotbar = {swordstack,pickstack,gapplestack,stonestack,stonestack,stonestack}
|
|
inv:set_list("main", hotbar)
|
|
end
|
|
|
|
function after_goal(arena) --global because its called once outside of this file
|
|
restore_map(arena)
|
|
local players_team_red = arena_lib.get_players_in_team(arena, team_id_red, true)
|
|
local players_team_blue = arena_lib.get_players_in_team(arena, team_id_blue, true)
|
|
|
|
for player_index in ipairs(players_team_red) do
|
|
local player = players_team_red[player_index]
|
|
set_player_inventory(player)
|
|
player:set_hp(20)
|
|
player:set_pos(arena_lib.get_random_spawner(arena, team_id_red))
|
|
update_huds(arena,player)
|
|
end
|
|
|
|
for player_index in ipairs(players_team_blue) do
|
|
local player = players_team_blue[player_index]
|
|
set_player_inventory(player)
|
|
player:set_hp(20)
|
|
player:set_pos(arena_lib.get_random_spawner(arena, team_id_blue))
|
|
update_huds(arena,player)
|
|
end
|
|
end
|
|
|
|
local goalfunc = function(pos, node, player)
|
|
if not player then return end
|
|
arena = arena_lib.get_arena_by_player(player:get_player_name())
|
|
if not arena then return end
|
|
|
|
nodename = node.name
|
|
if nodename == "the_bridge:goal_area_red" then
|
|
arena.teams[team_id_red].goals = arena.teams[team_id_red].goals +1
|
|
if arena.teams[team_id_red].goals >= 5 and arena.in_game then
|
|
if arena.finished then return end
|
|
arena.finished = true
|
|
arena_lib.load_celebration("the_bridge", arena, team_id_red)
|
|
return
|
|
end
|
|
after_goal(arena)
|
|
|
|
elseif nodename == "the_bridge:goal_area_blue" then
|
|
arena.teams[team_id_blue].goals = arena.teams[team_id_blue].goals +1
|
|
if arena.teams[team_id_blue].goals >= 5 and arena.in_game then
|
|
if arena.finished then return end
|
|
arena.finished = true
|
|
arena_lib.load_celebration("the_bridge", arena, team_id_blue)
|
|
return
|
|
end
|
|
after_goal(arena)
|
|
end
|
|
end
|
|
|
|
arena_lib.on_death("the_bridge", function(arena, p_name, reason)
|
|
local players_team_red = arena_lib.get_players_in_team(arena, team_id_red, false)
|
|
local players_team_blue = arena_lib.get_players_in_team(arena, team_id_blue, false)
|
|
|
|
for player_index in ipairs(players_team_red) do
|
|
if players_team_red[player_index] == p_name then
|
|
minetest.get_player_by_name(p_name):set_pos(arena_lib.get_random_spawner(arena, team_id_red))
|
|
end
|
|
end
|
|
|
|
for player_index in ipairs(players_team_blue) do
|
|
if players_team_blue[player_index] == p_name then
|
|
minetest.get_player_by_name(p_name):set_pos(arena_lib.get_random_spawner(arena, team_id_blue))
|
|
end
|
|
end
|
|
|
|
set_player_inventory(minetest.get_player_by_name(p_name))
|
|
minetest.get_player_by_name(p_name):set_hp(20)
|
|
end)
|
|
|
|
arena_lib.on_celebration("the_bridge", function(arena, winners)
|
|
remove_all_huds(arena)
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_node("the_bridge:goal_area_red",{
|
|
description = S("Red Goal"),
|
|
drawtype = "glasslike",
|
|
tiles = {"^[colorize:#d9405e"},
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
|
|
walkable = true,
|
|
pointable = true,
|
|
diggable = false,
|
|
buildable_to = false,
|
|
drop = "",
|
|
on_walk_over=goalfunc,
|
|
})
|
|
|
|
minetest.register_node("the_bridge:goal_area_blue",{
|
|
description = S("Blue Goal"),
|
|
drawtype = "glasslike",
|
|
tiles = {"^[colorize:#3548da"},
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
|
|
walkable = true,
|
|
pointable = true,
|
|
diggable = false,
|
|
buildable_to = false,
|
|
drop = "",
|
|
on_walk_over=goalfunc,
|
|
})
|
|
|
|
minetest.register_node("the_bridge:void", {
|
|
description = S("The Bridge void"),
|
|
drawtype = "airlike",
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
walkable = true,
|
|
pointable = true,
|
|
diggable = false,
|
|
buildable_to = false,
|
|
drop = "",
|
|
damage_per_second = 40,
|
|
})
|
|
|
|
minetest.register_tool("the_bridge:stonesword", {
|
|
description = S("Stone Sword"),
|
|
inventory_image = "default_tool_stonesword.png",
|
|
tool_capabilities = {
|
|
full_punch_interval = 1.2,
|
|
max_drop_level=0,
|
|
damage_groups = {fleshy=8},
|
|
},
|
|
})
|
|
|
|
minetest.register_tool("the_bridge:diapick", {
|
|
description = S("Diamond Pickaxe"),
|
|
inventory_image = "default_tool_diamondpick.png",
|
|
tool_capabilities = {
|
|
full_punch_interval = 0.9,
|
|
max_drop_level=3,
|
|
groupcaps={
|
|
cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=0, maxlevel=3},
|
|
},
|
|
},
|
|
})
|
|
|
|
|
|
local gappleeat = minetest.item_eat(8,"")
|
|
minetest.register_craftitem("the_bridge:gapple",{
|
|
on_place = gappleeat,
|
|
on_secondary_use = gappleeat,
|
|
description = S("Golden Apple"),
|
|
inventory_image = "default_apple.png^[colorize:#ead535",
|
|
}) |