Last active
August 21, 2022 10:43
-
-
Save Xymph/8f494ace5b83ac19d0deccab4d20d036 to your computer and use it in GitHub Desktop.
Omgifol (https://doomwiki.org/wiki/Omgifol) script to search for secret exit linedefs in maps and show their number/type; for DoomWiki.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# search maps for secret exit linedefs, by Frans P. de Vries (Xymph) | |
import sys, getopt | |
from omg import * | |
def searchmap(wad, name, alwys): | |
try: | |
edit = UMapEditor(wad.udmfmaps[name]) | |
except KeyError: | |
edit = UMapEditor(wad.maps[name]) | |
# set linedef types | |
if edit.namespace.lower() in ('zdoom', 'hexen'): | |
normal = [243] | |
secret = [244] | |
else: | |
normal = [11, 52, 197] | |
secret = [51, 124, 198] | |
i = 0 | |
fndnorm = [] | |
fndsecr = [] | |
for line in edit.linedefs: | |
if line.special in normal: | |
fndnorm.append([i, line.special]) | |
if line.special in secret: | |
fndsecr.append([i, line.special]) | |
#if line.special != 0: | |
# print("line %4d type %d" % (i, line.special)) | |
i += 1 | |
if alwys: | |
return fndsecr | |
else: | |
if fndnorm: | |
return fndsecr | |
else: | |
return [] | |
if len(sys.argv) != 3 and len(sys.argv) != 4: | |
print("\n Omgifol script: search map(s)' secret exit linedefs\n") | |
print(" Usage:") | |
print(" searchSecrExit.py [-a] source.wad pattern\n") | |
print(" Search all maps whose names match the given pattern (eg E?M4 or MAP*)") | |
print(" for secret exit linedefs 51, 124 and 198,") | |
print(" if normal exit linedefs are present (11, 52 and 197),") | |
print(" or always with flag '-a'") | |
else: | |
# process optional flag | |
always = False | |
try: | |
opts, args = getopt.getopt(sys.argv[1:], 'a') | |
for o, a in opts: | |
if o == '-a': | |
always = True | |
except getopt.GetoptError as err: | |
print(str(err)) | |
sys.exit(2) | |
# load WAD and draw map(s) | |
print("Loading %s..." % args[0]) | |
inwad = WAD() | |
inwad.from_file(args[0]) | |
for name in inwad.maps.find(args[1]) + inwad.udmfmaps.find(args[1]): | |
lines = searchmap(inwad, name, always) | |
if lines: | |
print("Found in %s" % name) | |
for line in lines: | |
print("%6d:\t%d" % (line[0], line[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment