some changes
This commit is contained in:
parent
12d361e670
commit
e994b5aa1d
16
config.lua
16
config.lua
|
@ -1,11 +1,12 @@
|
|||
local S = ctf.S
|
||||
return {
|
||||
teams = {
|
||||
red = {colorstr="#FF0000",colornum=0xFF0000,desc = "Fire"},
|
||||
green = {colorstr="#00FF00",colornum=0x00FF00,desc = "Flora"},
|
||||
blue = {colorstr="#0000FF",colornum=0x0000FF,desc = "Water"},
|
||||
cyan = {colorstr="#00FFFF",colornum=0x00FFFF,desc = "Sky"},
|
||||
magenta = {colorstr="#FF00FF",colornum=0xFF00FF,desc = "Magic"},
|
||||
yellow = {colorstr="#FFFF00",colornum=0xFFFF00,desc = "Sun"},
|
||||
red = {colorstr="#FF0000",colornum=0xFF0000,desc = S"Fire"},
|
||||
green = {colorstr="#00FF00",colornum=0x00FF00,desc = S"Earth"},
|
||||
blue = {colorstr="#0000FF",colornum=0x0000FF,desc = S"Water"},
|
||||
cyan = {colorstr="#00FFFF",colornum=0x00FFFF,desc = S"Sky"},
|
||||
magenta = {colorstr="#FF00FF",colornum=0xFF00FF,desc = S"Magic"},
|
||||
yellow = {colorstr="#FFFF00",colornum=0xFFFF00,desc = S"Sun"},
|
||||
},
|
||||
CRYSTALS_PER_TEAM = 4,
|
||||
PLAYERS_PER_TEAM = 5,
|
||||
|
@ -15,7 +16,8 @@ return {
|
|||
BORDER_RADIUS = 5,
|
||||
SPAWN_DIST = 20000,
|
||||
TEAM_DIST = 50,
|
||||
TELEPORT_ROOM = {x=0,y=20000,z=0},
|
||||
TELEPORT_ROOM = {x=7.5,y=20000+7.5,z=7.5},
|
||||
TELEPORT_ROOM_RADIUS = 64,
|
||||
PLAYER_DIST = 3,
|
||||
SPAWNFALL_LIMIT = 128
|
||||
}
|
114
init.lua
114
init.lua
|
@ -8,6 +8,8 @@ local S = minetest.get_translator(modname)
|
|||
|
||||
ctf = {}
|
||||
|
||||
ctf.S = S
|
||||
|
||||
local cfg = include("config")
|
||||
local teams = cfg.teams
|
||||
|
||||
|
@ -22,6 +24,7 @@ local TEAM_DIST = cfg.TEAM_DIST
|
|||
local PLAYER_DIST = cfg.PLAYER_DIST
|
||||
local SPAWNFALL_LIMIT = cfg.SPAWNFALL_LIMIT
|
||||
local TELEPORT_ROOM = cfg.TELEPORT_ROOM
|
||||
local TELEPORT_ROOM_RADIUS = cfg.TELEPORT_ROOM_RADIUS
|
||||
|
||||
ctf.player_count = 0
|
||||
ctf.voted_count = 0
|
||||
|
@ -41,18 +44,38 @@ end
|
|||
|
||||
function ctf.spawn(name,pos,call)
|
||||
local ref = minetest.get_player_by_name(name)
|
||||
ref:set_pos(TELEPORT_ROOM)
|
||||
local over = ref:get_physics_override()
|
||||
do
|
||||
ref:set_physics_override({
|
||||
gravity = 0,
|
||||
})
|
||||
ref:set_sky(0x000000, "plain", nil, false)
|
||||
local r = TELEPORT_ROOM_RADIUS
|
||||
local tr = TELEPORT_ROOM
|
||||
local v = {x=r,y=r,z=r}
|
||||
local p1,p2 = vector.subtract(tr,v),vector.add(tr,v)
|
||||
p1 = {x=f(p1.x/16),y=f(p1.y/16),z=f(p1.z/16)}
|
||||
p2 = {x=f(p2.x/16),y=f(p2.y/16),z=f(p2.z/16)}
|
||||
for x=p1.x,p2.x do
|
||||
for y=p1.y,p2.y do
|
||||
for z=p1.z,p2.z do
|
||||
ref:send_mapblock({x=x,y=y,z=z})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ref:set_pos(vector.add(TELEPORT_ROOM,{x=math.random(-8,8),y=math.random(-2,2),z=math.random(-8,8)}))
|
||||
local n = math.random()
|
||||
local pl = ctf.players[name]
|
||||
if pl.transid then
|
||||
minetest.chat_send_player(S"<TELEPORT> Cancelling previous transportation")
|
||||
minetest.chat_send_player(name,S"<TELEPORT> Cancelling previous transportation")
|
||||
end
|
||||
pl.transid = n
|
||||
pos = {x=f(pos.x),y=f(pos.y),z=f(pos.z)}
|
||||
call = call or function()end
|
||||
local limit = SPAWNFALL_LIMIT
|
||||
minetest.chat_send_player(name,S"<TELEPORT> Configuring transportation processor...")
|
||||
--minetest.after(30,function()
|
||||
minetest.after(10,function()
|
||||
minetest.emerge_area({x=pos.x,y=pos.y-limit,z=pos.z},{x=pos.x,y=pos.y+limit,z=pos.z},function(bp,act,crem)
|
||||
if crem > 0 then return end
|
||||
pl = ctf.players[name]
|
||||
|
@ -62,6 +85,8 @@ function ctf.spawn(name,pos,call)
|
|||
end
|
||||
pl.transid = nil
|
||||
minetest.chat_send_player(name,S"<TELEPORT> Done. Sending transport coordinates...")
|
||||
ref:set_sky(0x000000, "regular")
|
||||
ref:set_physics_override(over)
|
||||
local off = 0
|
||||
while off > -limit do
|
||||
if minetest.get_node({x=pos.x,y=pos.y+off,z=pos.z}).name ~= "air" then
|
||||
|
@ -83,7 +108,7 @@ function ctf.spawn(name,pos,call)
|
|||
call(ref,apos)
|
||||
end
|
||||
end)
|
||||
--end)
|
||||
end)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -138,7 +163,6 @@ include("node")
|
|||
ctf.crystals(teams)
|
||||
|
||||
local bar_c = minetest.get_content_id(modname..":barrier")
|
||||
local hbar_c = minetest.get_content_id(modname..":barrier_hole")
|
||||
local tbar_c = minetest.get_content_id(modname..":telebarrier")
|
||||
local air_c = minetest.get_content_id("air")
|
||||
|
||||
|
@ -146,52 +170,37 @@ local abs = math.abs
|
|||
local function distance(a,b)
|
||||
return math.max(abs(a.x-b.x),abs(a.z-b.z))
|
||||
end
|
||||
local function rdistance(a,b)
|
||||
return math.max(abs(a.x-b.x),abs(a.z-b.z),abs(a.y-b.y))
|
||||
end
|
||||
local f = math.floor
|
||||
|
||||
minetest.register_on_generated(function(minp,maxp,seed)
|
||||
local vm,mip,map = minetest.get_mapgen_object("voxelmanip")
|
||||
local d = vm:get_data()
|
||||
local ar = VoxelArea:new{MinEdge=mip,MaxEdge=map}
|
||||
if vector.distance(TELEPORT_ROOM,vector.divide(vector.add(minp,maxp),2)) < 4000 then
|
||||
local tr = TELEPORT_ROOM
|
||||
for x=minp.x,maxp.x do
|
||||
for y=minp.y,maxp.y do
|
||||
for z=minp.z,maxp.z do
|
||||
local i = ar:index(x,y,z)
|
||||
if vector.distance({x=x,y=y,z=z},TELEPORT_ROOM) > 12 then
|
||||
d[i] = bar_c
|
||||
if tr.y-y > 32 or
|
||||
(f(y/16) < f(tr.y/16) and rdistance({x=x,y=0,z=z},{x=tr.x,y=0,z=tr.z}) <= (f(tr.y/16)-f(y/16)+0.5)*16)then
|
||||
d[i] = tbar_c
|
||||
else
|
||||
d[i] = air_c
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for x=minp.x,maxp.x do
|
||||
for y=minp.y,maxp.y do
|
||||
for z=minp.z,maxp.z do
|
||||
local i = ar:index(x,y,z)
|
||||
local c = false
|
||||
for x1=x-1,x+1 do
|
||||
for y1=y-1,y+1 do
|
||||
for z1=z-1,z+1 do
|
||||
if ar:contains(x1,y1,z1) and d[ar:index(x1,y1,z1)] == air_c then
|
||||
if d[i] == bar_c then
|
||||
d[i] = (x%3 == 0 or y%3 == 0 or z%3 == 0) and tbar_c or bar_c
|
||||
c=true
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if distance(vector.divide(vector.add(minp,maxp),2),ctf.spawnpoint) > FIELD_RADIUS then
|
||||
for x=minp.x,maxp.x do
|
||||
for y=minp.y,maxp.y do
|
||||
for z=minp.z,maxp.z do
|
||||
local i = ar:index(x,y,z)
|
||||
d[i] = math.random(3) == 1 and hbar_c or bar_c
|
||||
d[i] = bar_c
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -206,7 +215,6 @@ function ctf.set_team_text(name)
|
|||
local pl = ctf.players[name]
|
||||
assert(pl)
|
||||
local team = teams[pl.team]
|
||||
print(pl.team,team)
|
||||
ctf.set_text(name,S("You're member of @1 team",tostring(team.desc)).."\n"..S"/vote to end the game",team.colornum)
|
||||
end
|
||||
|
||||
|
@ -239,7 +247,7 @@ minetest.register_on_joinplayer(function(ref)
|
|||
local name = ref:get_player_name()
|
||||
local id = ref:hud_add{
|
||||
name = "stat",
|
||||
text = S"The game hasn't started yet".."\n"..S"/vote to end the game",
|
||||
text = S"The game hasn't started yet".."\n"..S"/vote to start the game",
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=-1,y=1},
|
||||
offset = {x=-20,y=20},
|
||||
|
@ -319,7 +327,10 @@ do
|
|||
end
|
||||
|
||||
function ctf.start()
|
||||
if ctf.starting and (ctf.voted_count/ctf.player_count) < 0.5 then
|
||||
if ctf.ended or ctf.started then
|
||||
return
|
||||
end
|
||||
if ctf.starting and ctf.starting ~= -math.huge and (ctf.voted_count/ctf.player_count) < 0.5 then
|
||||
minetest.chat_send_all(S"<INFO + DEMOCRACY> Aborting")
|
||||
ctf.starting = -math.huge
|
||||
return
|
||||
|
@ -377,7 +388,7 @@ function ctf.start()
|
|||
ctf.teams = {}
|
||||
for k,v in pairs(ctf.players) do
|
||||
v.team = nil
|
||||
ctf.set_text(k,S"The game hasn't started yet".."\n"..S"/vote to end the game")
|
||||
ctf.set_text(k,S"The game hasn't started yet".."\n"..S"/vote to start the game")
|
||||
end
|
||||
ctf.starting = false
|
||||
ctf.started = false
|
||||
|
@ -432,8 +443,35 @@ end
|
|||
|
||||
do
|
||||
local f
|
||||
local emerging = false
|
||||
local t = {
|
||||
[minetest.EMERGE_CANCELLED]="CANCEL",
|
||||
[minetest.EMERGE_ERRORED]="ERROR",
|
||||
[minetest.EMERGE_FROM_MEMORY]="MEMORY",
|
||||
[minetest.EMERGE_FROM_DISK]="DISK",
|
||||
[minetest.EMERGE_GENERATED]="GENERATED",
|
||||
}
|
||||
function f()
|
||||
minetest.emerge_area(vector.subtract(TELEPORT_ROOM,{x=20,y=20,z=20}),vector.add(TELEPORT_ROOM,{x=20,y=20,z=20}))
|
||||
local r = TELEPORT_ROOM_RADIUS
|
||||
local tr = TELEPORT_ROOM
|
||||
local v = {x=r,y=r,z=r}
|
||||
if not emerging then
|
||||
emerging = true
|
||||
local gen = false
|
||||
minetest.emerge_area(vector.subtract(tr,v),vector.add(tr,v),function(bp,act,crem)
|
||||
if crem == 0 then
|
||||
if gen then
|
||||
--print("loaded teleport_room "..(t[act] or "UNK"))
|
||||
end
|
||||
emerging = false
|
||||
else
|
||||
if t[act] ~= "MEMORY" and not gen then
|
||||
--print("loading teleport_room "..(t[act] or "UNK"))
|
||||
gen = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
if #minetest.get_connected_players() == 0 and not (ctf.started or ctf.ended or ctf.starting) then
|
||||
local z = SPAWN_DIST
|
||||
local pos = vector.add(SPAWNPOINT,{x=ur(z),y=0,z=ur(z)})
|
||||
|
@ -441,7 +479,7 @@ do
|
|||
end
|
||||
minetest.after(5,f)
|
||||
end
|
||||
f()
|
||||
minetest.after(0,f)
|
||||
end
|
||||
|
||||
do
|
||||
|
@ -481,7 +519,7 @@ function ctf.check_win()
|
|||
for pname,pl in pairs(team.players) do
|
||||
ctf.set_text(pname,S":(".."\n"..S"Your team lost.",teams[name].colornum)
|
||||
end
|
||||
minetest.chat_send_all("<INFO> "..teams[name].desc.." team lost!")
|
||||
minetest.chat_send_all(S("<INFO> Team @1 lost!",teams[name].desc))
|
||||
end
|
||||
end
|
||||
local c = 0
|
||||
|
@ -491,7 +529,7 @@ function ctf.check_win()
|
|||
ctf.ended = true
|
||||
if c == 1 then
|
||||
local name,team = next(ctf.teams)
|
||||
minetest.chat_send_all("<INFO> "..teams[name].desc.." team won!")
|
||||
minetest.chat_send_all(S("<INFO> Team @1 won!",teams[name].desc))
|
||||
for pname,pl in pairs(team.players) do
|
||||
ctf.set_text(pname,S":D".."\n"..S"Your team won!",teams[name].colornum)
|
||||
end
|
||||
|
@ -501,7 +539,6 @@ function ctf.check_win()
|
|||
ctf.set_text(k,S"The game hasn't started yet".."\n"..S"/vote to end the game")
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all(S"<INFO> The game is over")
|
||||
ctf.teams = {}
|
||||
do
|
||||
local z = SPAWN_DIST
|
||||
|
@ -518,6 +555,7 @@ function ctf.check_win()
|
|||
ctf.spawn(k,vector.add(ctf.spawnpoint,SPAWN_OFFSET))
|
||||
end
|
||||
minetest.after(5,function()
|
||||
minetest.chat_send_all(S"<INFO> The game is over")
|
||||
ctf.started = false
|
||||
ctf.ended = false
|
||||
end)
|
||||
|
|
|
@ -11,6 +11,7 @@ Vote to do things=Vote to do things
|
|||
<DEMOCRACY> You vote to NOT start the game=<DEMOCRACY> You vote to NOT start the game
|
||||
You're member of @1 team=You're member of @1 team
|
||||
/vote to end the game=/vote to end the game
|
||||
/vote to start the game=/vote to start the game
|
||||
The game hasn't started yet=The game hasn't started yet
|
||||
<INFO + DEMOCRACY> Aborting=<INFO + DEMOCRACY> Aborting
|
||||
<INFO + DEMOCRACY> Most players are ready. Starting the game in 10...=<INFO + DEMOCRACY> Most players are ready. Starting the game in 10...
|
||||
|
@ -24,4 +25,12 @@ The game hasn't started yet=The game hasn't started yet
|
|||
Your team lost.=Your team lost.
|
||||
Your team won!=Your team won!
|
||||
<INFO> Majority of players voted to end the game=<INFO> Majority of players voted to end the game
|
||||
<INFO> The game is over=<INFO> The game is over
|
||||
<INFO> The game is over=<INFO> The game is over
|
||||
<INFO> Team @1 won!=<INFO> Team @1 won!
|
||||
<INFO> Team @1 lost!=<INFO> Team @1 lost!
|
||||
Fire=Fire
|
||||
Earth=Earth
|
||||
Water=Water
|
||||
Air=Air
|
||||
Magic=Magic
|
||||
Sun=Sun
|
|
@ -11,6 +11,7 @@ Vote to do things=Голосовать за всякие штуки
|
|||
<DEMOCRACY> You vote to NOT start the game=<DEMOCRACY> Вы голосуете против начала игры
|
||||
You're member of @1 team=Вы состоите в команде @1
|
||||
/vote to end the game=/vote чтобы закончить игру
|
||||
/vote to start the game=/vote чтобы начать игру
|
||||
The game hasn't started yet=Игра еще не началась
|
||||
<INFO + DEMOCRACY> Aborting=<INFO + DEMOCRACY> Отмена
|
||||
<INFO + DEMOCRACY> Most players are ready. Starting the game in 10...=<INFO + DEMOCRACY> Многие игроки готовы. Начало игры через 10...
|
||||
|
@ -25,3 +26,11 @@ Your team lost.=Ваша команда проиграла.
|
|||
Your team won!=Ваша команда выиграла!
|
||||
<INFO> Majority of players voted to end the game=<INFO> Многие игроки проголосовали закончить эту игру
|
||||
<INFO> The game is over=<INFO> Игра окончена
|
||||
<INFO> Team @1 won!=<INFO> Команда @1 победила!
|
||||
<INFO> Team @1 lost!=<INFO> Команда @1 потерпела поражение!
|
||||
Fire=Огня
|
||||
Earth=Земли
|
||||
Water=Воды
|
||||
Sky=Небя
|
||||
Magic=Магии
|
||||
Sun=Солнца
|
||||
|
|
18
node.lua
18
node.lua
|
@ -93,24 +93,20 @@ minetest.register_node(modname..":telebarrier",{
|
|||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
|
||||
length = 0.25,
|
||||
}
|
||||
length = 3,
|
||||
},
|
||||
align_style = "world",
|
||||
scale=16
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node(modname..":barrier_hole",{
|
||||
drawtype="normal",
|
||||
use_texture_alpha=true,
|
||||
pointable = false,
|
||||
tiles = {"nc_ctf_barrier_hole.png"},
|
||||
})
|
||||
|
||||
minetest.register_node(modname..":barrier",{
|
||||
light_source = 14,
|
||||
paramtype = "light",
|
||||
drawtype="normal",
|
||||
pointable = false,
|
||||
use_texture_alpha=true,
|
||||
tiles = {
|
||||
{name = "nc_ctf_barrier.png",
|
||||
animation={
|
||||
|
@ -120,7 +116,9 @@ minetest.register_node(modname..":barrier",{
|
|||
aspect_h = 16,
|
||||
|
||||
length = 3,
|
||||
}
|
||||
},
|
||||
align_style = "world",
|
||||
scale=16
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 97 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 98 KiB |
Loading…
Reference in New Issue