Skip to content

Instantly share code, notes, and snippets.

@Xymph
Last active January 30, 2024 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xymph/8e2ebc7dbe69166b6045ce7464d4aa69 to your computer and use it in GitHub Desktop.
Save Xymph/8e2ebc7dbe69166b6045ce7464d4aa69 to your computer and use it in GitHub Desktop.
Omgifol (https://doomwiki.org/wiki/Omgifol) script to search linedefs/things in maps for an action special and ID; for DoomWiki.org
#!/usr/bin/python3
# search maps for linedefs and things invoking specials, by Frans P. de Vries (Xymph)
import sys
from omg import *
def searchmap(wad, name, special, theid):
try:
edit = UMapEditor(wad.udmfmaps[name])
except KeyError:
edit = UMapEditor(wad.maps[name])
i = 0
for line in edit.linedefs:
if (special == 0 or line.special == special) and line.arg0 == theid:
# show ACS_Execute params
if (special == 80):
print("Found linedef %d : map %d, args %d, %d, %d" % (i, line.arg1, line.arg2, line.arg3, line.arg4))
else:
print("Found linedef %d" % i)
i += 1
i = 0
for thing in edit.things:
if (special == 0 or thing.special == special) and thing.arg0 == theid:
# show ACS_Execute params
if (special == 80):
print("Found thing %d : map %d, args %d, %d, %d" % (i, thing.arg1, thing.arg2, thing.arg3, thing.arg4))
else:
print("Found thing %d" % i)
i += 1
if len(sys.argv) != 5:
print("\n Omgifol script: search map(s)' linedefs/things for action special\n")
print(" Usage:")
print(" searchSpecial.py source.wad pattern special ID")
print(" Examples:")
print(" searchSpecial.py source.wad pattern 80 scriptnum (ACS_Execute)")
print(" searchSpecial.py source.wad pattern 121 lineid (Line_SetIdentification)\n")
print(" Search all maps whose names match the given pattern (eg E?M4 or MAP*)")
print(" for linedefs and things invoking the special action and argument.")
print(" If special is 0, search all actions for the ID.")
print(" If special is 80, show ACS_Execute parameters.")
print(" See https://doomwiki.org/wiki/Action_specials")
print(" and https://zdoom.org/wiki/Action_specials\n")
else:
# load WAD and draw map(s)
print("Loading %s..." % sys.argv[1])
inwad = WAD()
inwad.from_file(sys.argv[1])
for name in inwad.maps.find(sys.argv[2]) + inwad.udmfmaps.find(sys.argv[2]):
print("Searching %s" % name)
searchmap(inwad, name, int(sys.argv[3]), int(sys.argv[4]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment