Updates n stuff (Should be playable now)
BIN
menu/header.png
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 50 KiB |
BIN
menu/icon.png
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,38 @@
|
|||
function main.spawn_rand_drop()
|
||||
local drops = main.current_mode.mode.drops
|
||||
|
||||
if not drops then return end
|
||||
|
||||
local itemspawns = main.current_mode.itemspawns
|
||||
local spawnpos = itemspawns[math.random(1, #itemspawns)]
|
||||
|
||||
for item, chance in pairs(drops) do
|
||||
if item ~= "default" then
|
||||
if math.random(1, chance) == 1 then
|
||||
minetest.log("action", "Dropped "..dump(item).." at "..minetest.pos_to_string(spawnpos))
|
||||
minetest.add_item(spawnpos, item)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if drops.default then
|
||||
minetest.add_item(spawnpos, drops.default)
|
||||
end
|
||||
end
|
||||
|
||||
local dropstep = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if not main.current_mode then return end
|
||||
|
||||
local dropint = main.current_mode.mode.drop_interval
|
||||
local online_players = #minetest.get_connected_players()
|
||||
|
||||
if dropstep >= dropint/online_players and online_players >= 2 then
|
||||
dropstep = 0
|
||||
|
||||
main.spawn_rand_drop()
|
||||
else
|
||||
dropstep = dropstep + dtime
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,83 @@
|
|||
main = {
|
||||
modes = {},
|
||||
default_drops = {
|
||||
default = "shooter_guns:ammo",
|
||||
["shooter_guns:pistol_loaded"] = 10,
|
||||
["shooter_guns:rifle_loaded"] = 18,
|
||||
["shooter_guns:machine_gun_loaded"] = 30,
|
||||
["shooter_guns:shotgun_loaded"] = 30,
|
||||
},
|
||||
default_drop_interval = 40
|
||||
}
|
||||
|
||||
function main.register_mode(name, def)
|
||||
main.modes[name] = def
|
||||
end
|
||||
|
||||
function main.start_mode(name)
|
||||
local map = maps.get_rand_map()
|
||||
|
||||
if not map then
|
||||
minetest.log("error", "No maps to play on! Create one with /maps new")
|
||||
return
|
||||
end
|
||||
|
||||
local mapdef = maps.load_map(map)
|
||||
main.current_mode = {
|
||||
name = name,
|
||||
mode = main.modes[name],
|
||||
itemspawns = mapdef.itemspawns,
|
||||
playerspawns = mapdef.playerspawns,
|
||||
}
|
||||
|
||||
for _, p in ipairs(minetest.get_connected_players()) do
|
||||
p:set_pos(main.current_mode.playerspawns[math.random(1, #main.current_mode.playerspawns)])
|
||||
end
|
||||
|
||||
minetest.chat_send_all(minetest.colorize("yellow", "[Voxel Combat] ").."Current mode: "..name..
|
||||
". Current map (By "..mapdef.creator.."): "..mapdef.name)
|
||||
end
|
||||
|
||||
--
|
||||
--- Player join/leave/die/damage taken
|
||||
--
|
||||
|
||||
minetest.register_on_joinplayer(function(p)
|
||||
p:set_hp(20, {type = "set_hp"})
|
||||
|
||||
if #minetest.get_connected_players() == 1 then
|
||||
main.start_mode("default")
|
||||
else
|
||||
p:set_pos(main.current_mode.playerspawns[math.random(1, #main.current_mode.playerspawns)])
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(p)
|
||||
p:set_pos(main.current_mode.playerspawns[math.random(1, #main.current_mode.playerspawns)])
|
||||
|
||||
return true
|
||||
end)
|
||||
|
||||
minetest.register_on_player_hpchange(function(_, hp_change, reason)
|
||||
if reason.type == "fall" then
|
||||
return 0
|
||||
else
|
||||
return hp_change
|
||||
end
|
||||
end, true)
|
||||
|
||||
--
|
||||
--- Misc
|
||||
--
|
||||
|
||||
function minetest.item_drop() -- Prevent picking up/dropping items
|
||||
return
|
||||
end
|
||||
|
||||
minetest.set_mapgen_setting("mg_name", "singlenode", true) -- Set mapgen to singlenode
|
||||
|
||||
dofile(minetest.get_modpath("main").."/modes.lua")
|
||||
dofile(minetest.get_modpath("main").."/drops.lua")
|
||||
dofile(minetest.get_modpath("main").."/inv.lua")
|
||||
dofile(minetest.get_modpath("main").."/sprint.lua")
|
||||
dofile(minetest.get_modpath("main").."/item_pickup.lua")
|
|
@ -0,0 +1,19 @@
|
|||
minetest.register_on_joinplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
|
||||
if not minetest.check_player_privs(player, {map_maker = true}) then
|
||||
inv:set_size("main", 8*2)
|
||||
player:hud_set_hotbar_itemcount(6)
|
||||
player:hud_set_hotbar_image("hotbar_6.png")
|
||||
else
|
||||
inv:set_size("main", 8*4)
|
||||
player:hud_set_hotbar_itemcount(8)
|
||||
player:hud_set_hotbar_image("hotbar_8.png")
|
||||
end
|
||||
|
||||
player:hud_set_flags({healthbar = true, breathbar = true})
|
||||
|
||||
for _, s in ipairs(inv:get_list("main")) do
|
||||
inv:remove_item("main", s)
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,31 @@
|
|||
local function can_pickup(item)
|
||||
for i in pairs(main.current_mode.mode.drops) do
|
||||
if item:sub(1, i:len()) == i then return true end
|
||||
end
|
||||
|
||||
if item:find("shooter_guns:ammo") then return true end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
if player:get_hp() > 0 then
|
||||
local pos = player:get_pos()
|
||||
local inv = player:get_inventory()
|
||||
|
||||
for _, object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
local self = object:get_luaentity()
|
||||
|
||||
if not object:is_player() and self and self.name == "__builtin:item" and
|
||||
self.itemstring ~= "" then
|
||||
if inv and can_pickup(self.itemstring) then
|
||||
inv:add_item("main", ItemStack(self.itemstring))
|
||||
self._removed = true
|
||||
object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,2 @@
|
|||
name = main
|
||||
depends = maps
|
|
@ -0,0 +1,6 @@
|
|||
main.register_mode("default", {
|
||||
full_name = "PvP Party",
|
||||
min_players = 1,
|
||||
drops = main.default_drops,
|
||||
drop_interval = main.default_drop_interval,
|
||||
})
|
|
@ -0,0 +1,18 @@
|
|||
local sprint_step = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
sprint_step = sprint_step + dtime
|
||||
|
||||
if sprint_step >= 0.35 then
|
||||
sprint_step = 0
|
||||
|
||||
for _, p in ipairs(minetest.get_connected_players()) do
|
||||
if p:get_player_control().aux1 == true then
|
||||
p:set_physics_override({speed = 2})
|
||||
else
|
||||
if p:get_physics_override().speed ~= 1 then
|
||||
p:set_physics_override({speed = 1})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.4 KiB |
|
@ -0,0 +1,207 @@
|
|||
local function S(txt)
|
||||
return txt
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("maps").."/nodes.lua")
|
||||
|
||||
maps = {}
|
||||
|
||||
maps.mappath = minetest.get_worldpath().."/maps/" -- minetest.get_modpath("maps").."/maps/"
|
||||
|
||||
local editing_map = false
|
||||
local editing
|
||||
|
||||
minetest.register_privilege("map_maker", {
|
||||
description = S("Allows use of the map making commands/tools"),
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("maps", {
|
||||
description = S("Maps command. Run /maps <h/help> for a list of subcommands"),
|
||||
privs = {map_maker = true},
|
||||
func = function(name, params)
|
||||
params = string.split(params, " ")
|
||||
|
||||
if not params then return end
|
||||
|
||||
if params[1] == "h" or params[1] == "help" then
|
||||
return true, "Options: help/h | new | edit <mapname> | save [mapname (Only needed for new maps])"
|
||||
end
|
||||
|
||||
if params[1] == "new" then
|
||||
if not editing_map then
|
||||
return true, maps.new_map(name)
|
||||
else
|
||||
return false, "A map is already being edited!"
|
||||
end
|
||||
elseif params[1] == "edit" and params[2] then
|
||||
if not editing_map then
|
||||
return true, maps.edit_map(name, params[2])
|
||||
else
|
||||
return false, "A map is already being edited!"
|
||||
end
|
||||
elseif params[1] == "save" then
|
||||
return true, maps.save_map(name, params[2])
|
||||
else
|
||||
return false, "Options: help/h | new | edit <mapname> | save [mapname (Only needed for new maps])"
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function maps.new_map(pname)
|
||||
local player = minetest.get_player_by_name(pname)
|
||||
local mpos = vector.new(0, 777, 0)
|
||||
|
||||
editing_map = true
|
||||
|
||||
minetest.emerge_area(vector.subtract(mpos, vector.new(20, 0, 20)), vector.add(mpos, vector.new(20, 16, 20)))
|
||||
minetest.place_schematic(mpos, minetest.get_modpath("maps").."/schems/base.mts", 0, {}, true,
|
||||
{place_center_x = true, place_center_y=false, place_center_z=true})
|
||||
|
||||
player:set_pos(vector.new(0, 778, 0))
|
||||
|
||||
return "Map container placed, build away!"
|
||||
end
|
||||
|
||||
function maps.save_map(pname, mname)
|
||||
if not mname and editing then
|
||||
mname = editing
|
||||
end
|
||||
mname = mname:gsub(" ", "_")
|
||||
|
||||
local path = maps.mappath..mname.."/"
|
||||
minetest.mkdir(path)
|
||||
local conf, error = io.open(path.."map.conf", "w")
|
||||
local startpos = vector.new(0, 777+8, 0)
|
||||
|
||||
if not minetest.find_node_near(startpos, 20, "maps:spawnpoint", true) then
|
||||
return "You must place at least one player spawner first!"
|
||||
end
|
||||
|
||||
if not conf then return error end
|
||||
if maps.map_exists(mname) and editing and editing ~= mname then
|
||||
return "There is already a map with this name!"
|
||||
end
|
||||
|
||||
conf:write("name = <"..mname..">")
|
||||
conf:write("\ncreator = <"..pname..">")
|
||||
|
||||
for finame, item in pairs({pspawns = "maps:spawnpoint", ispawns = "maps:itemspawner"}) do
|
||||
local pos = minetest.find_node_near(startpos, 20, item, true)
|
||||
local positions = {}
|
||||
|
||||
while pos do
|
||||
local rpos = vector.new(pos.x, pos.y-777, pos.z)
|
||||
table.insert(positions, rpos)
|
||||
minetest.remove_node(pos)
|
||||
pos = minetest.find_node_near(startpos, 20, item, true)
|
||||
end
|
||||
|
||||
if positions then
|
||||
conf:write("\n"..finame.." = <"..minetest.serialize(positions)..">")
|
||||
end
|
||||
end
|
||||
|
||||
conf:close()
|
||||
|
||||
local r = minetest.create_schematic(vector.new(-19, 778, -19), vector.new(19, 778+14, 19), {}, path.."map.mts", {})
|
||||
|
||||
if r then
|
||||
maps.new_map(pname)
|
||||
|
||||
editing_map = false
|
||||
editing = nil
|
||||
|
||||
return "Saved map!"
|
||||
end
|
||||
|
||||
return "Failed to create map schematic"
|
||||
end
|
||||
|
||||
function maps.edit_map(pname, mname)
|
||||
local player = minetest.get_player_by_name(pname)
|
||||
local mpos = vector.new(0, 777, 0)
|
||||
local mpos_up = vector.new(0, 778, 0)
|
||||
|
||||
if not maps.map_exists(mname) then return "No such map!" end
|
||||
|
||||
editing_map = true
|
||||
editing = mname
|
||||
|
||||
minetest.emerge_area(vector.subtract(mpos, vector.new(20, 0, 20)), vector.add(mpos, vector.new(20, 16, 20)))
|
||||
minetest.place_schematic(mpos, minetest.get_modpath("maps").."/schems/base.mts", 0, {}, true,
|
||||
{place_center_x = true, place_center_y=false, place_center_z=true})
|
||||
minetest.place_schematic(mpos_up, maps.mappath..mname.."/map.mts", 0, {}, true,
|
||||
{place_center_x = true, place_center_y=false, place_center_z=true})
|
||||
|
||||
local conf, error = io.open(maps.mappath..mname.."/map.conf")
|
||||
|
||||
if not conf then return error end
|
||||
|
||||
local cfile = conf:read("*all")
|
||||
|
||||
local playerspawns = minetest.deserialize(cfile:match("pspawns = <.->"):sub(12, -2))
|
||||
local itemspawns = minetest.deserialize(cfile:match("ispawns = <.->"):sub(12, -2))
|
||||
|
||||
conf:close()
|
||||
|
||||
while playerspawns and playerspawns[1] do
|
||||
playerspawns[1].y = playerspawns[1].y + 777
|
||||
minetest.set_node(playerspawns[1], {name = "maps:spawnpoint"})
|
||||
table.remove(playerspawns, 1)
|
||||
end
|
||||
|
||||
while itemspawns and itemspawns[1] do
|
||||
itemspawns[1].y = itemspawns[1].y + 777
|
||||
minetest.set_node(itemspawns[1], {name = "maps:itemspawner"})
|
||||
table.remove(itemspawns, 1)
|
||||
end
|
||||
|
||||
while minetest.get_node(mpos_up).name ~= "air" do
|
||||
mpos_up.y = mpos_up.y + 1
|
||||
end
|
||||
|
||||
player:set_pos(mpos_up)
|
||||
|
||||
return "Map placed, edit away!"
|
||||
end
|
||||
|
||||
function maps.map_exists(name)
|
||||
for _, n in pairs(minetest.get_dir_list(minetest.get_worldpath().."/maps/", true)) do
|
||||
if n == name then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function maps.get_rand_map(name)
|
||||
local list = minetest.get_dir_list(minetest.get_worldpath().."/maps/", true)
|
||||
|
||||
if not list or #list == 0 then return end
|
||||
|
||||
return list[math.random(1, #list)]
|
||||
end
|
||||
|
||||
function maps.load_map(name)
|
||||
local pos = vector.new(0, 0, 0)
|
||||
local conf, error = io.open(maps.mappath..name.."/map.conf")
|
||||
local mapdef = {}
|
||||
|
||||
if not conf then return error end
|
||||
local cfile = conf:read("*all")
|
||||
|
||||
mapdef.name = cfile:match("name = <.->"):sub(9, -2)
|
||||
mapdef.creator = cfile:match("creator = <.->"):sub(12, -2)
|
||||
mapdef.playerspawns = minetest.deserialize(cfile:match("pspawns = <.->"):sub(12, -2))
|
||||
mapdef.itemspawns = minetest.deserialize(cfile:match("ispawns = <.->"):sub(12, -2))
|
||||
|
||||
conf:close()
|
||||
|
||||
minetest.place_schematic(pos, maps.mappath..name.."/map.mts", 0, {}, true,
|
||||
{place_center_x = true, place_center_y=false, place_center_z=true})
|
||||
|
||||
return mapdef
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
minetest.register_node("maps:spawnpoint", {
|
||||
description = "Spawnpoint",
|
||||
tiles = {"air.png"},
|
||||
groups = {unbreakable = 1},
|
||||
walkable = true,
|
||||
pointable = true,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
})
|
||||
|
||||
minetest.register_node("maps:itemspawner", {
|
||||
description = "Item Spawner",
|
||||
tiles = {"default_mese_crystal.png"},
|
||||
groups = {unbreakable = 1},
|
||||
walkable = true,
|
||||
pointable = true,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
})
|
||||
|
||||
minetest.register_node("maps:light", {
|
||||
drawtype = "airlike",
|
||||
description = "Invisible Light",
|
||||
inventory_image = "default_meselamp.png^air.png",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
})
|
|
@ -1 +1 @@
|
|||
Subproject commit 63ca8472aee5feae1c428b406ecb3dce5c7b6a66
|
||||
Subproject commit 8caadbab5e2d04771c10b022ac1da2e5bea89766
|
|
@ -0,0 +1,11 @@
|
|||
for name, def in pairs(minetest.registered_nodes) do
|
||||
local newdef = {groups = def.groups}
|
||||
|
||||
newdef.groups.unbreakable = 1
|
||||
newdef.groups.snappy = nil
|
||||
newdef.groups.oddly_breakable_by_hand = nil
|
||||
newdef.groups.crumbly = nil
|
||||
newdef.groups.dig_immediate = nil
|
||||
|
||||
minetest.override_item(name, newdef)
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
name = unbreakable_nodes
|
||||
depends = default, wool, xpanes, farming, flowers, fire, doors, beds
|