-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.py
executable file
·61 lines (49 loc) · 1.79 KB
/
play.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
#!/usr/bin/env python3
"""
Given a WAD, it'll detect if it's for DOOM1 or 2 (based on map names) and
run GZDoom with the right iwad arg
"""
import argparse
import os
import wad
import subprocess
import dero_config
parser = argparse.ArgumentParser()
parser.add_argument('--pwad', type=str, required=True, help='Path to the PWAD to play')
parser.add_argument('--nomons', action='store_true', default=False)
parser.add_argument('--voxels', action=argparse.BooleanOptionalAction, default=True)
parser.add_argument('--map', type=str, default=None)
parser.add_argument('--savegame', type=str, default=None)
args = parser.parse_args()
def main():
iwad = dero_config.DOOM2_WAD_PATH
for name in wad.enum_map_names(args.pwad):
print(f'First map name: {name}')
if name[0] == 'E' and name[2] == 'M':
print('..looks like DOOM 1')
iwad = dero_config.DOOM1_WAD_PATH
else:
print('..looks like DOOM 2')
break
print(f'Assumed IWAD: {os.path.basename(iwad)}')
pwad_dir = os.path.dirname(args.pwad)
# Find all WADs and PK3's in this folder and load them.
wadpaths = []
for file in os.listdir(pwad_dir):
if file.lower().endswith('.wad') or file.lower().endswith('.pk3'):
wadpaths.append(os.path.join(pwad_dir, file))
if args.voxels:
wadpaths.append('/Users/stevenan/dooming/wads/cheello_voxels.zip')
gzdoom_path = '/Applications/GZDoom.app/Contents/MacOS/gzdoom'
call_args = [gzdoom_path] + wadpaths + [
'-iwad', iwad,
'-savedir', pwad_dir,
'-shotdir', pwad_dir,
]
if args.nomons: call_args.append('-nomonsters')
if args.map: call_args += ['+map', args.map, '+skill', '1']
if args.savegame: call_args += ['-loadgame', args.savegame]
print('final args:', call_args)
subprocess.check_call(call_args)
if __name__ == '__main__':
main()