mirror of
https://github.com/a-bad-dev/simple-shooter-game.git
synced 2026-06-08 20:12:11 +00:00
Add a lot of new stuff
This commit is contained in:
parent
caaf2481d2
commit
948040e47b
13 changed files with 163 additions and 141 deletions
|
|
@ -28,7 +28,7 @@ core.register_chatcommand("stop", {
|
|||
privs = {match_manager = true},
|
||||
description = "Terminate the match",
|
||||
func = function()
|
||||
if match_state ~= "pre_match" and match_state ~= "post_match" and match_state ~= "not_started" then
|
||||
if match_state ~= "post_match" and match_state ~= "not_started" then
|
||||
core.chat_send_all(core.colorize("red", "Match terminated."))
|
||||
end_match()
|
||||
|
||||
|
|
@ -38,3 +38,17 @@ core.register_chatcommand("stop", {
|
|||
return false, "Match cannot be terminated at the moment."
|
||||
end
|
||||
})
|
||||
|
||||
core.register_chatcommand("list_maps", {
|
||||
params = "",
|
||||
privs = {match_manager = true},
|
||||
description = "List all maps",
|
||||
func = function()
|
||||
local maps = core.get_dir_list(core.get_modpath("maps") .. "/maps", true)
|
||||
local map_list = "Available maps:\n"
|
||||
for _, map in pairs(maps) do
|
||||
map_list = map_list .. map .. "\n"
|
||||
end
|
||||
return true, map_list .. "\nUse /start <map> to start a match."
|
||||
end
|
||||
})
|
||||
|
|
@ -1,3 +1,18 @@
|
|||
match_start_job = nil
|
||||
loading_tips = {
|
||||
"Open the inventory to change class!",
|
||||
"Short-range is good for small/dense maps!",
|
||||
"Mid-range is good on maps with long tunnels or open areas!",
|
||||
"Long-range is good for maps with really open and large areas!",
|
||||
"Ambushing can be powerful assuming your not found!",
|
||||
"Players may sneak up on you from behind!",
|
||||
"You *can't* be shot under water!",
|
||||
"The Short-range class can one-shot from 6 to 7 nodes away!",
|
||||
"Using torches may allow enemies to sneak up on you in the dark!",
|
||||
"Turns out if you get a sniper and zoom with it. you can zoom no matter what after that...", -- how
|
||||
"e s p i o n a g e",
|
||||
}
|
||||
|
||||
-- Functions for SSG
|
||||
function make_player_invisible(player) -- Hide a player (pre-match and spectator)
|
||||
save_player_data(player)
|
||||
|
|
@ -127,30 +142,45 @@ function start_match(map) -- Start the match
|
|||
for _, player in pairs(core.get_connected_players()) do
|
||||
set_player_mode(player, "pre_match")
|
||||
|
||||
map_loading_images[player:get_player_name()] = player:hud_add({
|
||||
type = "image",
|
||||
position = {x=0.5, y=0.5},
|
||||
image_scale = 100,
|
||||
text = "map_loading.png",
|
||||
scale = {x=-100, y=-100},
|
||||
z_index = 1000,
|
||||
})
|
||||
map_loading_images[player:get_player_name()] = {
|
||||
loading = player:hud_add({
|
||||
type = "image",
|
||||
position = {x=0.5, y=0.5},
|
||||
image_scale = 100,
|
||||
text = "map_loading.png",
|
||||
scale = {x=-100, y=-100},
|
||||
z_index = 1000,
|
||||
}),
|
||||
|
||||
info = player:hud_add({
|
||||
type = "text",
|
||||
position = {x=0.5, y=0.7},
|
||||
text = loading_tips[math.random(1, #loading_tips)],
|
||||
number = 0xFFFFFF,
|
||||
z_index = 1000,
|
||||
})
|
||||
}
|
||||
|
||||
give_player_items(player)
|
||||
|
||||
player:set_pos({x = map_data.spawn_x, y = map_data.spawn_y, z = map_data.spawn_z})
|
||||
player:set_pos(map_data.spawn)
|
||||
|
||||
player:set_hp(20)
|
||||
end
|
||||
|
||||
core.after(3, function()
|
||||
for _, player in pairs(core.get_connected_players()) do
|
||||
player:set_pos({x = map_data.spawn_x, y = map_data.spawn_y, z = map_data.spawn_z})
|
||||
player:hud_remove(map_loading_images[player:get_player_name()])
|
||||
player:set_pos(map_data.spawn)
|
||||
|
||||
for _, id in pairs(map_loading_images[player:get_player_name()]) do
|
||||
player:hud_remove(id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
assert(loadstring(map_data.scripts.on_start or ""))()
|
||||
if map_data.on_start then
|
||||
map_data.on_start()
|
||||
end
|
||||
|
||||
core.chat_send_all(core.colorize("#b011f9", string.format("Match about to start in %d seconds!\nOpen inventory to change class!", map_data.start_time)))
|
||||
|
||||
|
|
@ -160,11 +190,12 @@ function start_match(map) -- Start the match
|
|||
end)
|
||||
end
|
||||
|
||||
core.after(map_data.start_time, function()
|
||||
match_start_job = core.after(map_data.start_time, function()
|
||||
match_start_job = nil
|
||||
set_match_state("in_progress")
|
||||
core.chat_send_all(core.colorize("green", "Match started!"))
|
||||
|
||||
remove_barrier(map_data.size_x, map_data.barrier_level, map_data.size_z)
|
||||
remove_barrier()
|
||||
|
||||
alive_players = {}
|
||||
|
||||
|
|
@ -190,6 +221,14 @@ end
|
|||
function end_match() -- End the match
|
||||
set_match_state("not_started")
|
||||
|
||||
if match_start_job ~= nil then
|
||||
match_start_job:cancel()
|
||||
end
|
||||
|
||||
if map_data.on_end then
|
||||
map_data.on_end()
|
||||
end
|
||||
|
||||
for _, player in pairs(core.get_connected_players()) do
|
||||
player:set_pos(spawn_pos)
|
||||
player:get_inventory():set_list("main", {})
|
||||
|
|
@ -250,8 +289,6 @@ function kill_player(player, reason) -- Handle killed/disconnected players prope
|
|||
if #alive_player_names == 1 then
|
||||
local winner_name = alive_player_names[1]
|
||||
core.chat_send_all(core.colorize("green", winner_name .. " is the winner!"))
|
||||
|
||||
assert(loadstring(map_data.scripts.on_end or ""))()
|
||||
|
||||
set_match_state("post_match")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
function place_map(map)
|
||||
local map_path = core.get_modpath("maps") .. "/maps/"
|
||||
local map_list = core.get_dir_list(map_path, true)
|
||||
local map_pos = vector.new(0, 0, 0)
|
||||
|
||||
for i = 1, #map_list do
|
||||
if map_list[i] == map then
|
||||
map_pos = vector.new(1000 * (i - 1), 0, 0)
|
||||
break
|
||||
elseif i == #map_list then
|
||||
return "nope :("
|
||||
|
|
@ -12,12 +14,11 @@ function place_map(map)
|
|||
end
|
||||
|
||||
local map_data = dofile(map_path .. map .. "/map.lua")
|
||||
core.place_schematic({x=0, y=0, z=0}, map_path .. map .. "/map.mts", 0, nil, true)
|
||||
map_data.pos = map_pos
|
||||
core.place_schematic(map_pos, map_path .. map .. "/map.mts", 0, nil, true)
|
||||
|
||||
if map_data.spawn_x == nil or map_data.spawn_y == nil or map_data.spawn_z == nil then -- set a default spawnpoint if not set
|
||||
map_data.spawn_x = map_data.size_x / 2
|
||||
map_data.spawn_y = map_data.barrier_level + 1
|
||||
map_data.spawn_z = map_data.size_z / 2
|
||||
if not map_data.spawn then -- set a default spawnpoint if not set
|
||||
map_data.spawn = vector.new(map_data.size.x / 2, map_data.barrier_level + 1, map_data.size.z / 2) + map_pos
|
||||
end
|
||||
|
||||
if map_data.start_time == nil or map_data.start_time <= 0 then
|
||||
|
|
@ -50,12 +51,15 @@ function place_map(map)
|
|||
return map_data
|
||||
end
|
||||
|
||||
function remove_barrier(x, y, z)
|
||||
function remove_barrier()
|
||||
for node_x = 1, x - 2 do
|
||||
for node_z = 1, z - 2 do
|
||||
core.set_node({x = node_x, y = y - 1, z = node_z}, {name = "air"}) -- account for the fact that lua counts starting at 1... i think.... whatever, it works \_('_')_/
|
||||
end
|
||||
end
|
||||
assert(loadstring(map_data.scripts.on_barrier_remove or ""))()
|
||||
if map_data.on_barrier_remove then
|
||||
map_data.on_barrier_remove()
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,22 +1,14 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "1v1",
|
||||
size_x = 41,
|
||||
size_y = 31,
|
||||
size_z = 38,
|
||||
size = vector.new(41, 31, 38),
|
||||
|
||||
barrier_level = 27,
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 15,
|
||||
|
||||
scripts = {
|
||||
on_start = "for x=0, 40 do\nfor y=0, 17 do\nfor z=0, 37 do\ncore.set_node({x=x,y=31+y,z=z}, {name=\"default:glass\"})\nend\nend\nend",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
}
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,14 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "forest-2",
|
||||
size_x = 189,
|
||||
size_y = 71,
|
||||
size_z = 102,
|
||||
|
||||
size = vector.new(189, 71, 102),
|
||||
|
||||
barrier_level = 67, -- <- Y level of the barrier
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 45,
|
||||
|
||||
scripts = { -- "temporary" hack to ensure there's nothing on top of the map
|
||||
on_start = "for x=0, 188 do\nfor y=0, 4 do\nfor z=0, 101 do\ncore.set_node({x=x,y=71+y,z=z}, {name=\"air\"})\nend\nend\nend",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
}
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,14 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "forest-3",
|
||||
size_x = 537,
|
||||
size_y = 117,
|
||||
size_z = 244,
|
||||
size = vector.new(537, 117, 244),
|
||||
|
||||
barrier_level = 113, -- <- Y level of the barrier
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 60,
|
||||
|
||||
scripts = {
|
||||
on_start = "",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
}
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,16 @@
|
|||
local map_data = {
|
||||
name = "forest-4",
|
||||
size_x = 190,
|
||||
size_y = 69,
|
||||
size_z = 155,
|
||||
return {
|
||||
name = "forest-4",
|
||||
size = vector.new(190, 69, 155),
|
||||
|
||||
barrier_level = 65,
|
||||
barrier_level = 65,
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 30,
|
||||
start_time = 30,
|
||||
|
||||
scripts = {
|
||||
on_start = "for x=0, 189 do\nfor y=0, 10 do\nfor z=0, 154 do\ncore.set_node({x=x,y=69+y,z=z}, {name=\"air\"})\nend\nend\nend",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
},
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
|
||||
classes = {
|
||||
class_1 = {
|
||||
|
|
@ -35,5 +29,3 @@ local map_data = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,16 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "forest",
|
||||
size_x = 155,
|
||||
size_y = 53,
|
||||
size_z = 147,
|
||||
|
||||
size = vector.new(155, 53, 147),
|
||||
|
||||
barrier_level = 49, -- <- Y level of the barrier
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 30,
|
||||
|
||||
scripts = { -- "temporary" hack to ensure there's nothing on top of the map
|
||||
on_start = "for x=0, 154 do\nfor y=0, 16 do\nfor z=0, 146 do\ncore.set_node({x=x,y=53+y,z=z}, {name=\"air\"})\nend\nend\nend",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
},
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
|
||||
classes = {
|
||||
class_1 = {
|
||||
|
|
@ -35,5 +29,3 @@ local map_data = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,14 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "mini-map",
|
||||
size_x = 8,
|
||||
size_y = 19,
|
||||
size_z = 8,
|
||||
size = vector.new(8, 19, 8),
|
||||
|
||||
barrier_level = 15,
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 15,
|
||||
|
||||
scripts = {
|
||||
on_start = "",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
}
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,14 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "pine",
|
||||
size_x = 111,
|
||||
size_y = 64,
|
||||
size_z = 107,
|
||||
size = vector.new(111, 64, 107),
|
||||
|
||||
barrier_level = 60, -- <- Y level of the barrier
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 30,
|
||||
|
||||
scripts = {
|
||||
on_start = "",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
}
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
|
|
@ -1,22 +1,14 @@
|
|||
local map_data = {
|
||||
return {
|
||||
name = "savanna",
|
||||
size_x = 341,
|
||||
size_y = 83,
|
||||
size_z = 188,
|
||||
size = vector.new(341, 83, 188),
|
||||
|
||||
barrier_level = 79, -- <- Y level of the barrier
|
||||
|
||||
spawn_x = nil,
|
||||
spawn_y = nil,
|
||||
spawn_z = nil,
|
||||
spawn = nil,
|
||||
|
||||
start_time = 45,
|
||||
|
||||
scripts = {
|
||||
on_start = "",
|
||||
on_barrier_remove = "",
|
||||
on_end = ""
|
||||
}
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
}
|
||||
|
||||
return map_data
|
||||
|
|
|
|||
31
mods/game/maps/maps/snow/map.lua
Normal file
31
mods/game/maps/maps/snow/map.lua
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
return {
|
||||
name = "snow",
|
||||
size = vector.new(267, 100, 335),
|
||||
|
||||
barrier_level = 97, -- <- Y level of the barrier
|
||||
|
||||
spawn = nil,
|
||||
|
||||
start_time = 45,
|
||||
|
||||
on_start = nil,
|
||||
on_end = nil,
|
||||
on_barrier_remove = nil,
|
||||
|
||||
classes = {
|
||||
class_1 = {
|
||||
name = "Long-range",
|
||||
initial_items = {"ctf_ranged:m200_loaded", "default:sword_stone", "ctf_ranged:ammo 99", "default:torch 1"}
|
||||
},
|
||||
|
||||
class_2 = {
|
||||
name = "Mid-ranged",
|
||||
initial_items = {"ctf_ranged:ak47_loaded", "ctf_ranged:glock17_loaded", "ctf_ranged:ammo 99", "default:torch 1"}
|
||||
},
|
||||
|
||||
class_3 = {
|
||||
name = "Short-range",
|
||||
initial_items = {"ctf_ranged:benelli_loaded", "ctf_ranged:glock17_loaded", "ctf_ranged:ammo 99", "default:torch 1"}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
mods/game/maps/maps/snow/map.mts
Normal file
BIN
mods/game/maps/maps/snow/map.mts
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue