-
Notifications
You must be signed in to change notification settings - Fork 0
/
dm_ctf.lua
137 lines (94 loc) · 2.7 KB
/
dm_ctf.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
------------------------------------------------------------------------
-- DEATH-MATCH / CAPTURE THE FLAG
------------------------------------------------------------------------
--
-- Oblige Level Maker
--
-- Copyright (C) 2015 Andrew Apted
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
------------------------------------------------------------------------
function Multiplayer_create_zones()
--
-- In competitive multiplayer maps we only need a single zone.
--
local Z = Zone_new()
each R in LEVEL.rooms do
R.zone = Z
each A in R.areas do
A.zone = Z
end
end
Area_spread_zones()
end
function Multiplayer_flag_rooms()
--
-- pick the flag rooms for CTF mode
--
local function eval_flag_room(R)
-- never in a hallway
if R.kind == "hallway" then return -1 end
local score = 300
-- too big?
if R.svolume > 20 then score = score - 100 end
-- too small?
if R.svolume < 6 then score = score - 200 end
-- tie breaker
return score + gui.random()
end
local function setup_room(R, team)
R.is_flag_room = true
local GOAL =
{
kind = "FLAG"
item = "ctf_" .. team .. "_flag"
team = team
}
table.insert(R.goals, GOAL)
end
---| Multiplayer_flag_rooms |---
local best
local best_score = 0
each R in LEVEL.rooms do
local A1 = R.areas[1]
if not (A1.team == "blue" and R.sister) then continue end
local score = eval_flag_room(R)
stderrf("trying %s : team:%s sister:%s --> %1.2f\n",
R.name, A1.team or "???", tostring(R.sister), score)
if score > best_score then
best = R
best_score = score
end
end
if not best then
error("CTF failure, no usable room for the flag")
end
setup_room(best, "blue")
setup_room(best.sister, "red")
LEVEL.blue_base = best
LEVEL. red_base = best.sister
gui.printf("CTF Blue Flag @ %s\n", LEVEL.blue_base.name)
gui.printf("CTF Red Flag @ %s\n", LEVEL. red_base.name)
end
function Multiplayer_add_items()
-- TODO
end
function Multiplayer_setup_level()
Multiplayer_create_zones()
Quest_choose_themes()
Quest_select_textures()
if OB_CONFIG.playmode == "ctf" then
Multiplayer_flag_rooms()
end
-- FIXME : player starts
-- FIXME : weapons
end