| 1 |
#!/usr/bin/perl |
| 2 |
# |
| 3 |
# Usage: archsearch.pl file |
| 4 |
# |
| 5 |
# This script searches a file (either archetypes or maps) for certain |
| 6 |
# desired values. It is better than grep in that it keeps track of the |
| 7 |
# the archetype it occurs in and does smarter searches (ie, certain |
| 8 |
# bitmask values you can search for specific bit sets, which is not |
| 9 |
# easy to do with grep) |
| 10 |
# |
| 11 |
# Originally written to find all the creatures that use ghosthit. |
| 12 |
# Modified to find all object types that are being set invisible |
| 13 |
# in pupland |
| 14 |
# |
| 15 |
|
| 16 |
|
| 17 |
die("Usage: archsearch.pl file\n") if ($#ARGV < 0); |
| 18 |
|
| 19 |
for ($file=0; $file<=$#ARGV; $file++) { |
| 20 |
# print "Proccessing $ARGV[$file]\n"; |
| 21 |
if (!open(INFILE, "<$ARGV[$file]")) { |
| 22 |
print "Can not open $ARGV[$file] - skipping\n"; |
| 23 |
next; |
| 24 |
} |
| 25 |
while (<INFILE>) { |
| 26 |
if (/^Object (\S+)/ || /^arch (\S+)/) { |
| 27 |
$obname = $1; |
| 28 |
$invisible=0; |
| 29 |
$type=-1; |
| 30 |
$x = -1; |
| 31 |
$y = -1; |
| 32 |
$title=""; |
| 33 |
} |
| 34 |
$object .= $_; |
| 35 |
$type = $1 if (/^type (\S+)/); |
| 36 |
$title = $1 if (/^title (\S+)/); |
| 37 |
$invisible = $1 if (/^invisible (\S+)/); |
| 38 |
$x = $1 if (/^x (\S+)/); |
| 39 |
$y = $1 if (/^y (\S+)/); |
| 40 |
if (/^end$/ ) { |
| 41 |
if ($obname =~ /^altar/ && $title ne "") { |
| 42 |
print "$ARGV[$file]\n$object"; |
| 43 |
} |
| 44 |
# print "Object $obname (type $type) @ $x, $y is invisible\n"; |
| 45 |
$object=""; |
| 46 |
} |
| 47 |
# This is what we are searching for. value will be put in $1 |
| 48 |
# Note that multile searches are certainly possible. |
| 49 |
# elsif (/^attacktype (\S+)/) { |
| 50 |
# if ($1 & 0x200) { |
| 51 |
# print "Found match, object $obname, line $.\n"; |
| 52 |
# } |
| 53 |
# } |
| 54 |
|
| 55 |
} # While loop |
| 56 |
} |