-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.py
95 lines (93 loc) · 3.12 KB
/
map.py
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
import randomambience
import configobj
import console
import doors
import globals as g
randomambs=list()
from AGK.speech import auto
tiles=dict()
rooms=dict()
door=list()
consoles=list()
def spawn_tile(minx, maxx, miny, maxy, minz, maxz, type):
for x in range(minx,maxx+1):
for y in range(miny,maxy-1, -1):
for z in range(minz,maxz+1):
tiles[str(x)+":"+str(y)+":"+str(z)]=type
def mytile():
if "%d:%d:%d"%(int(g.me.x), int(g.me.y), int(g.me.z)) in tiles:
temps=tiles["%d:%d:%d"%(int(g.me.x),int(g.me.y),int(g.me.z))]
return temps
return ''
def spawn_room(minx, maxx, miny, maxy, minz, maxz, sound):
for x in range(minx,maxx+1):
for y in range(miny,maxy-1, -1):
for z in range(minz,maxz+1):
rooms[str(x)+":"+str(y)+":"+str(z)]=sound
def myroom():
if "%d:%d:%d"%(int(g.me.x), int(g.me.y), int(g.me.z)) in rooms:
temps=rooms["%d:%d:%d"%(int(g.me.x),int(g.me.y),int(g.me.z))]
return temps
return ''
def tile(x, y, z):
if "%d:%d:%d"%(int(x), int(y), int(z)) in tiles:
temps=str(tiles["%d:%d:%d"%(int(x),int(y),int(z))])
return temps
return ''
def parsedata(mapname):
config=None
try:
config=configobj.ConfigObj("maps/"+mapname+".map")
for m in config:
if m[0:7] == "console":
x=int(config[m]["x"])
y=int(config[m]["y"])
z=int(config[m]["z"])
name=config[m]["name"]
stations=config[m]["stations"].split(",")
consoles.append(console.console(x, y, z, name, stations))
if m[0:4] == "door":
x=int(config[m]["x"])
y=int(config[m]["y"])
z=int(config[m]["z"])
opensound=config[m]["opensound"]
closesound=config[m]["closesound"]
door.append(doors.door(x, y, z, opensound, closesound))
if m[0:4] == "wall":
x=int(config[m]["x"])
y=int(config[m]["y"])
z=int(config[m]["z"])
length=int(config[m]["length"])
side=int(config[m]["side"])
depth=int(config[m]["depth"])
spawn_tile(x, (x+side-1), y, (y+-(length)+1), z, (z+depth), "wall")
if m[0:9] == "randomamb":
x=int(config[m]["x"])
y=int(config[m]["y"])
z=int(config[m]["z"])
sp=config[m]["sounds"].split(",")
time=int(config[m]["time"])
reference_distance=1.0
rolloff_factor=1.0
if "reference_distance" in config[m]:
reference_distance=float(config[m]["reference_distance"])
if "rolloff_factor" in config[m]:
rolloff_factor=float(config[m]["rolloff_factor"])
randomambs.append(randomambience.RandomAmbience(x, y, z, sp, time, reference_distance, rolloff_factor))
if m[0:4] == "room":
roomx=int(config[m]["x"])
roomy=int(config[m]["y"])
roomz=int(config[m]["z"])
roomsound=config[m]["sound"]
roomtype=config[m]["type"]
roomlengthx=int(config[m]["lengthx"])
roomlengthy=int(config[m]["lengthy"])
roomdepth=int(config[m]["depth"])
if "description" in config[m]:
roomdesc=config[m]["description"]
spawn_room(roomx, (roomx+roomlengthx-1), roomy, (roomy+-(roomlengthy)+1), roomz, (roomz+roomdepth), roomsound)
spawn_tile(roomx, (roomx+roomlengthx-1), roomy, (roomy+-(roomlengthy)+1), roomz, (roomz+roomdepth), roomtype)
g.mapname=mapname
g.loaded=True
except Exception as e:
auto.speak("Error on parsing data: "+str(e))