-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathzlevel.dm
79 lines (65 loc) · 2.28 KB
/
zlevel.dm
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
// How much "space" we give the edge of the map
GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "awaymissionconfig.txt"))
GLOBAL_LIST_INIT(potentialConfigRandomZlevels, generate_map_list_from_directory(directory = "[global.config.directory]/away_missions/"))
/proc/createRandomZlevel(config_gateway = FALSE)
var/map
if(config_gateway && GLOB.potentialConfigRandomZlevels?.len)
map = pick_n_take(GLOB.potentialConfigRandomZlevels)
else if(GLOB.potentialRandomZlevels?.len)
map = pick_n_take(GLOB.potentialRandomZlevels)
else
return to_chat(world, span_boldannounce("No valid away mission files, loading aborted."))
to_chat(world, span_boldannounce("Loading away mission..."))
var/loaded = load_new_z_level(map, "Away Mission", config_gateway)
to_chat(world, span_boldannounce("Away mission [loaded ? "loaded" : "aborted due to errors"]."))
if(!loaded)
message_admins("Away mission [map] loading failed due to errors.")
log_admin("Away mission [map] loading failed due to errors.")
createRandomZlevel(config_gateway)
/proc/reset_gateway_spawns(reset = FALSE)
for(var/obj/machinery/gateway/G in world)
if(reset)
G.randomspawns = GLOB.awaydestinations
else
G.randomspawns.Add(GLOB.awaydestinations)
/obj/effect/landmark/awaystart
name = "away mission spawn"
desc = "Randomly picked away mission spawn points."
/obj/effect/landmark/awaystart/New()
GLOB.awaydestinations += src
..()
/obj/effect/landmark/awaystart/Destroy()
GLOB.awaydestinations -= src
return ..()
/proc/generateMapList(filename)
. = list()
filename = "[global.config.directory]/[SANITIZE_FILENAME(filename)]"
var/list/Lines = world.file2list(filename)
if(!Lines.len)
return
for (var/t in Lines)
if (!t)
continue
t = trim(t)
if (length(t) == 0)
continue
else if (t[1] == "#")
continue
var/pos = findtext(t, " ")
var/name = null
if (pos)
name = lowertext(copytext(t, 1, pos))
else
name = lowertext(t)
if (!name)
continue
. += t
/// Returns a list of all maps to be found in the directory that is passed in.
/proc/generate_map_list_from_directory(directory)
var/list/config_maps = list()
var/list/maps = flist(directory)
for(var/map_file in maps)
if(!findtext(map_file, ".dmm"))
continue
config_maps += (directory + map_file)
return config_maps