Mercurial > hg > batmud > misc
changeset 239:b35c643a64d9 misc
Gender support.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 24 Feb 2013 19:28:02 +0200 |
parents | 47fbc8471110 |
children | c79dd30a368f |
files | log2template.pl |
diffstat | 1 files changed, 34 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/log2template.pl Sun Feb 24 19:21:15 2013 +0200 +++ b/log2template.pl Sun Feb 24 19:28:02 2013 +0200 @@ -15,7 +15,7 @@ # 5) Fight and kill monster. # 6) run log2template.pl < logfile.log > output.txt # -# 7) command id say say -ID-;blook at $*;say -%-;weigh $*;say -#-;look at $*;say -!-;cast identify at $* +# 7) command id say -ID-;blook at $*;say -%-;weigh $*;say -#-;look at $*;say -!-;cast identify at $* # # Notes # ===== @@ -81,6 +81,13 @@ "Ocp west" => { "name" => "Old Central Park in Arelium", "continent" => "Laenor" }, ); + +my %genderMappings = ( + "it" => "n", + "she" => "f", + "he" => "m", +); + # Stat name translations my @statTransTable = ( sub { return $_[0] =~ s/^ability at the (skill|spell) (.+)$/$2/ }, @@ -219,6 +226,23 @@ } +sub check_gender($$) +{ + my ($mob, $s) = @_; + + if ($s =~ /^(He|She|It) +\[[a-z]+\] \([0-9-]+\%\)$/o || + $s =~ /^(He|She|It) is (in (a )?)?(excellent shape|good shape|slightly hurt|noticeably hurt|not in a good shape|bad shape|very bad shape|near death)/o) { + my $gender = lc($1); + if (defined($genderMappings{$gender})) { + $$mob{"gender"} = $genderMappings{$gender}; + } else { + print STDERR "ERROR($line): Invalid gender '$gender'\n"; + } + return 1; + } + return 0; +} + sub parse_npc($) { my ($s) = @_; @@ -258,7 +282,7 @@ # Mostly just grab shortdesc here if ($s =~ /^You $sayregex '(-==-|-=-=-=-=-=-=-=-=-)\.'$/o) { set_state(3, $s); - } elsif ($s =~ /^(He|She|It) +\[[a-z]+\] \([0-9-]+\%\)/o) { + } elsif (check_gender($mob, $s)) { set_state(-1, $s); } elsif ($s =~ /^You $sayregex /o) { set_state(-1, $s); @@ -270,8 +294,7 @@ if ($s =~ /^ +([a-zA-Z ,-]+?)'s equipment:$/o) { # End of long desc set_state(4, $s); - } elsif ($s =~ /^(He|She|It) +\[[a-z]+\] \([0-9-]+\%\)$/o || - $s =~ /^(He|She|It) is (in (a )?)?(excellent shape|good shape|slightly hurt|noticeably hurt|not in a good shape|bad shape|very bad shape|near death)/o) { + } elsif (check_gender($mob, $s)) { # End of long desc set_state(4, $s); } elsif ($s =~ /^You $sayregex /o) { @@ -821,6 +844,13 @@ | GAP = | PAP = | kerbholz = +| gender = "; + + if (defined($$mob{"gender"})) { + print $$mob{"gender"}; + } + +print " | other = }} ---------------------