Last active
August 21, 2022 10:43
-
-
Save Xymph/4f5358b168de308cbcd3922316979d3a to your computer and use it in GitHub Desktop.
Omgifol (https://doomwiki.org/wiki/Omgifol) script to search maps with no monsters nor secret sectors; 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 no monsters nor secret sectors, by Frans P. de Vries (Xymph) | |
import sys | |
from omg import * | |
def searchmap(wad, name): | |
try: | |
edit = UMapEditor(wad.udmfmaps[name]) | |
except KeyError: | |
edit = UMapEditor(wad.maps[name]) | |
# normal type & generic flags | |
stdsecret = 9 | |
if edit.namespace.lower() in ('zdoom', 'hexen'): | |
gensecret = 0x0400 | |
else: | |
gensecret = 0x0080 | |
# Doom monsters | |
monsters = [ 3004, 9, 65, 3001, 3006, 3002, 58, 66, 3005, 894, 71, 69, 3003, 68, 67, 64, 7, 16, 84, 72, 88, 89, | |
# stealth monsters | |
9061, 9060, 9054, 9057, 9055, 9059, 9053, 9056, 9052, 9050, 9058, 9051, | |
# scripted marines | |
9100, 9101, 9102, 9103, 9104, 9105, 9106, 9107, 9108, 9109, 9110, 9111 ] | |
i = 0 | |
for thing in edit.things: | |
# check SP is on (not-SP flag is off) | |
if thing.type in monsters and thing.single: | |
#print("monster %d single %s" % (i, thing.single)) | |
return True | |
i += 1 | |
i = 0 | |
for sector in edit.sectors: | |
if sector.special == stdsecret: | |
#print("sector std %d" % i) | |
return True | |
if (sector.special & gensecret) == gensecret: | |
#print("sector gen %d" % i) | |
return True | |
i += 1 | |
return False | |
if len(sys.argv) != 3: | |
print("\n Omgifol script: search map(s) for no monsters & secrets\n") | |
print(" Usage:") | |
print(" searchMonstSecr.py source.wad pattern\n") | |
print(" Search all maps whose names match the given pattern (eg E?M4 or MAP*)") | |
print(" for no monsters nor secret sectors") | |
else: | |
# load WAD and draw map(s) | |
print("Loading %s..." % sys.argv[1]) | |
inwad = WAD() | |
inwad.from_file(sys.argv[1]) | |
custom = [] | |
for name in inwad.maps.find(sys.argv[2]) + inwad.udmfmaps.find(sys.argv[2]): | |
result = searchmap(inwad, name) | |
if not result: | |
print("No monsters/secrets in %s" % name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment