Mercurial > hg > batmud > maputils
changeset 81:dba45b586541
Added mapping helpers and log filtering utilities
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 16 Dec 2006 10:13:53 +0000 |
parents | 16e4674264c2 |
children | 394c55b9bc07 |
files | tf/filterwalk.pl tf/mapship.tf tf/mapwalk.tf |
diffstat | 3 files changed, 127 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tf/filterwalk.pl Sat Dec 16 10:13:53 2006 +0000 @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w +# +# Filter crud from logfiles produced with 'mapwalk.tf' +# Usage: filterwalk.pl < bat-logfile.log > filtered.raw +# + +my $nlines = 13; + +while (<STDIN>) { + chomp; + if (/^[A-Z][a-z]+ .report.: !!PLR: (-?[0-9]+),(-?[0-9]+)$/) { + $s = sprintf("!!PLR: %d,%d\n", $1, $2); + defined($_ = <STDIN>) or die("Unexpected end of data.\n"); + if (/^You glance around.$/) { + $n = 0; + while (defined($_ = <STDIN>) && $n < $nlines) { + chomp; + # SSSSSSSSSScSSSSS~~~~~ + if (/^(.....................)$/) { + $s .= $1."\n" + } + $n++; + } + if ($n >= $nlines) { + print $s."\n"; + } else { + print "!!ERROR: Broken block!\n"; + } + } else { + print "!!ERROR: No data or other error in log!\n"; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tf/mapship.tf Sat Dec 16 10:13:53 2006 +0000 @@ -0,0 +1,43 @@ +;; +;; Mapping helper for a ship +;; + +;; Report location +/def -i prreportloc =\ + /send @party report !!PLR: %{plr_x},%{plr_y};map + + +;;----------------------------------------------------------------------------- +;; Update coordinates +/def -i prmyupdate =\ + /if ({1}=~"nw"|{1}=~"northwest") /test plr_y+={2}%;/test plr_x-={2}%;\ + /elseif ({1}=~"n"|{1}=~"north") /test plr_y+={2}%;\ + /elseif ({1}=~"ne"|{1}=~"northeast") /test plr_y+={2}%;/test plr_x+={2}%;\ + /elseif ({1}=~"w"|{1}=~"west") /test plr_x-={2}%;\ + /elseif ({1}=~"e"|{1}=~"east") /test plr_x+={2}%;\ + /elseif ({1}=~"sw"|{1}=~"southwest") /test plr_y-={2}%;/test plr_x-={2}%;\ + /elseif ({1}=~"s"|{1}=~"south") /test plr_y-={2}%;\ + /elseif ({1}=~"se"|{1}=~"southeast") /test plr_y-={2}%;/test plr_x+={2}%;\ + /endif + +;; Update coordinates, move, report location+map +/def -i prmymove =\ + /test prmyupdate({1},{2})%;/send @%{2} %{1}%;/prreportloc + +;; Report location when ship moves +/def -i -F -mregexp -t"^The ship sails (.+)\.$" ship_move =\ + /test prmyupdate({P1},1)%;/prreportloc + +;; Reset position to 0,0, start a new logfile +/def -i preset =\ + /echo -p @{BCgreen}Position reset!@{n}%;\ + /eval /log mapping-$[ftime("%F_%H-%M")].log%;\ + /set plr_x=0%;/set plr_y=0%;/prreportloc + +;; Report position +/def -i pos =\ + /echo -p @{BCgreen}Position{n}: @{BCwhite}%{plr_x},%{plr_y}@{n} + +;; Initialize +/preset +/move walk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tf/mapwalk.tf Sat Dec 16 10:13:53 2006 +0000 @@ -0,0 +1,51 @@ +;; +;; Mapping helper for a walking +;; + +;; Report location +/def -i prreportloc =\ + /send @party report !!PLR: %{plr_x},%{plr_y};map + + +;;----------------------------------------------------------------------------- +;; Update coordinates +/def -i prmyupdate =\ + /if ({1}=~"nw"|{1}=~"northwest") /test plr_y+={2}%;/test plr_x-={2}%;\ + /elseif ({1}=~"n"|{1}=~"north") /test plr_y+={2}%;\ + /elseif ({1}=~"ne"|{1}=~"northeast") /test plr_y+={2}%;/test plr_x+={2}%;\ + /elseif ({1}=~"w"|{1}=~"west") /test plr_x-={2}%;\ + /elseif ({1}=~"e"|{1}=~"east") /test plr_x+={2}%;\ + /elseif ({1}=~"sw"|{1}=~"southwest") /test plr_y-={2}%;/test plr_x-={2}%;\ + /elseif ({1}=~"s"|{1}=~"south") /test plr_y-={2}%;\ + /elseif ({1}=~"se"|{1}=~"southeast") /test plr_y-={2}%;/test plr_x+={2}%;\ + /endif + +;; Update coordinates, move, report location+map +/def -i prmymove =\ + /test prmyupdate({1},{2})%;/send @%{2} %{1}%;/prreportloc + +;; This is for GgrTF's numpad movement +/def -i prmove_walk =\ + /set prmove_last=%{1}%;/gstatus_update%;/test prmymove({1},1) + +;; Catch movement commands (hopefully) +/def -i -p1 -mregexp -h'send ^([0-9]+)? ?(n|s|e|w|ne|sw|nw|se|u|d)$' prmove_send =\ + /if ({P1}!~"") /test prmymove({P2},{P1})%;/else /test prmymove({P2},1)%;/endif + +;; Prevent from running with N/E/etc +/def -i -p99999 -mregexp -h'send ^([0-9]+)? ?(N|S|E|W|NE|SW|NW|SE)$' prmove_send2 =\ + /echo -p @{BCred}No you wont!@{n} + +;; Reset position to 0,0, start a new logfile +/def -i preset =\ + /echo -p @{BCgreen}Position reset!@{n}%;\ + /eval /log mapping-$[ftime("%F_%H-%M")].log%;\ + /set plr_x=0%;/set plr_y=0%;/prreportloc + +;; Report position +/def -i pos =\ + /echo -p @{BCgreen}Position{n}: @{BCwhite}%{plr_x},%{plr_y}@{n} + +;; Initialize +/preset +/move walk