ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/util/grep_for_player_skills
Revision: 1.1
Committed: Thu Feb 1 00:49:00 2007 UTC (17 years, 4 months ago) by elmex
Branch: MAIN
CVS Tags: rel-2_2, rel-2_0, rel-2_1, HEAD
Log Message:
added script for player skill level grepping. changed gen_worldmap to
use the gridmap and plt files.

File Contents

# User Rev Content
1 elmex 1.1 #!/opt/bin/perl
2    
3     # this script walks '.' recursively and will find all archetypes
4     # that can be found and will look for face and state info in them
5     # and return a json hash to stdout with the following key/value format:
6     #
7     # "<uuid><state>":"<face>"
8     #
9     # see also json_conv_old_faces for instructions on how to convert the facenames
10     #
11    
12     use strict;
13     use File::Find;
14    
15     *name = *File::Find::name;
16     *dir = *File::Find::dir;
17    
18     my $first = 1; # marks the first key/value (don't print too many ','s)
19    
20     sub getarch {
21     my ($file, $lines, $outarchs) = @_;
22    
23     my $inarch = 0;
24     my $at_end = 0;
25    
26     my $archlines = [];
27     do {
28     my $line = shift @$lines;
29     if ($line =~ m/^arch\s*(\S+)\s*$/) {
30     if ($inarch) {
31     unshift @$lines, $line;
32     getarch ($file, $lines, $outarchs);
33     } else {
34     $inarch = 1;
35     push @$archlines, $line;
36     }
37     } elsif ($line =~ m/^end\s*$/) {
38     push @$archlines, $line;
39     push @$outarchs, $archlines;
40     $archlines = [];
41     $at_end = 1;
42     } else {
43     push @$archlines, $line if $inarch;
44     }
45     } while (not ($at_end) && @$lines);
46    
47     if ($inarch and not $at_end) {
48     die "mismatched archetype in $file!";
49     }
50     }
51    
52     sub wanted {
53     my $file = $_;
54     -f $file or return;
55    
56     next if $file =~ /\.pst$/;
57    
58     open my $fh, "<$file" or return;
59     my $map = do { local $/; <$fh> };
60    
61     my $found_magic_ear;
62     my $found_npc;
63    
64     my @lines = split /\r?\n/, $map;
65    
66     my $archs = [];
67     getarch ($file, \@lines, $archs) while @lines;
68    
69     for my $archlines (@$archs) {
70     my $arch;
71     my $lev;
72     my $exp;
73    
74     for (@$archlines) {
75     if (/^arch\s*skill_(\S+)\s*$/) {
76     $arch = $1;
77     }
78     if (/^level\s*(\S+)\s*$/) {
79     $lev = $1;
80     }
81     if (/^exp\s*(\S+)\s*$/) {
82     $exp = $1;
83     }
84     }
85    
86     next if $arch eq 'map';
87    
88     if ($arch && $lev) {
89     printf "%-30s: %30s %3d\n", $file, $arch, $lev;
90     }
91     }
92     }
93    
94     find { no_chdir => 1, wanted => \&wanted }, ".";