kill.awk
code/scripts/kill.awk · 5.1 KB
From the archive Copper2-code.tar.gz
Download the archive « Back to the archive contents
# kill.awk
# A program to scan the killlog and summarize
# Now scans for new players too
# Author: Linh Ngo
# Date: June 12, 1992
# Modification History:
# 6/29/92 Added scanning for new players
#
# Array setup
BEGIN {
invalid = "~~~~~~~~~~~~~~~~~~~~~~"
killed[invalid] = 0;
killer[invalid] = 0;
count = 0;
new[invalid] = 0;
conn[invalid] = 0;
eof = 0;
drops[invalid] = 0;
gives[invalid] = 0;
load[invalid] = 0;
}
# killed & killer arrays filled by scanning the log which looks like:
#
#Wed Jun 17 16:18:46 1992 :: Flip killed by Baalzebul at Castle Tower
#Wed Jun 17 17:12:35 1992 :: Chumlee killed by the Elite Red Guard at...
#Wed Jun 17 21:16:27 1992 :: Toidi killed by Princess at Breakfast Nook
# 1 2 3 4 5 6 7 8 9 10 11 12 13
( $8 == "killed" && $9 == "by" ) {
killed[$7] ++;
if( $10 != "the" && $10 != "The" && $10 != "a" && $10 != "A" ) {
name = $10;
if( name >= "A" && name <= "Z") {
killer[$10] ++;
}
}
count ++;
}
# Scan for new players. Example of log looks like this:
#Sun Jun 28 19:00:50 1992 :: WIZ: Leia [hydra.gatech.edu] new player.
#Sun Jun 28 19:15:20 1992 :: WIZ: Guardian [bugs.mty.itesm.mx] new player.
#Mon Jun 29 16:54:01 1992 :: WIZ: Larin [wpi.WPI.EDU] new player.
#Mon Jun 29 17:57:47 1992 :: WIZ: Solta [cory.Berkeley.EDU] new player.
#Mon Jun 29 18:01:05 1992 :: WIZ: RH [gold.ucs.indiana.edu] new player.
# 1 2 3 4 5 6 7 8 9 10 11
( $10 == "new" && $11 == "player.") {
new[$8] = $9
}
# Connections
#Sun Jun 28 19:00:14 1992 :: Baq[spot.Colorado.EDU] has connected.
#Sun Jun 28 19:00:14 1992 :: Alexander[l_ecn09.icaen.uiowa.edu] has connected.
#Sun Jun 28 19:00:14 1992 :: CrystalDeath[tramp.cc.utexas.edu] has connected.
#Sun Jun 28 19:00:17 1992 :: Wint[rose.ucs.indiana.edu] has connected.
# 1 2 3 4 5 6 7 8 9
( $8 == "has" && $9 == "connected." ) {
conn[$7] ++;
}
# EOF
#Sun Jun 28 19:05:48 1992 :: EOF encountered on socket read.
#Sun Jun 28 19:07:35 1992 :: EOF encountered on socket read.
#Sun Jun 28 19:07:58 1992 :: EOF encountered on socket read.
#Sun Jun 28 19:11:32 1992 :: EOF encountered on socket read.
#Sun Jun 28 19:16:41 1992 :: EOF encountered on socket read.
# 1 2 3 4 5 6 7 8 9 10 11
( $7 == "EOF" && $10 == "socket" && $11 == "read." ) {
eof ++;
}
#Sun Jun 28 19:08:13 1992 :: WIZINFO: (Alexander) load obj 3902
#Sun Jun 28 19:08:45 1992 :: WIZINFO: (Dbra) load o 3099
# 1 2 3 4 5 6 7 8 9 10 11
( $7 == "WIZINFO:" && $9 == "load" ) {
load[$8] ++
}
#Wed Sep 2 03:31:41 1992 :: WIZ: Large transaction: Isaiah drops 1160850 coins
# 1 2 3 4 5 6 7 8 9 10 11 12 13
( $8 == "Large" && $9 == "transaction:" && $11 == "drops" ) {
drops[$10] += $12;
}
#Wed Sep 2 03:31:49 1992 :: WIZ: Large transaction: Kryal gives 129180 coins to Foo
# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
( $8 == "Large" && $9 == "transaction:" && $11 == "gives" ) {
gives[$10 " to " $15 ] += $12;
}
END {
printf("----------------------------\n")
printf("WIZARD LOADS\n\n")
for (var in load) {
if(load[var]){
printf("%-15s %5d\n", var, load[var])
}
}
printf("----------------------------\n")
printf ("EOF encountered on socket read: %d\n", eof)
printf("----------------------------\n")
printf("Total kills %d\n", count);
printf("----------------------------\n")
printf("Large transactions: DROPS\n");
for ( var in drops ) {
if(drops[var]){
printf("%15s %-9d\n", var, drops[var])
}
}
printf("----------------------------\n")
printf("Large transactions: GIVES\n");
for ( var in gives ) {
if(gives[var]){
printf("%25s %-9d\n", var, gives[var])
}
}
printf("----------------------------\n")
printf("PLAYER KILLERS (could be an NPC):\n\n");
#
# Search for the largest element, print it out, then set it to zero.
# Break out of infinite while loop when all elements are zero.
#
while (1){
largest=0
for (var in killer){
if (killer[var] >largest){
largest=killer[var]
keepvar=var
}
}
if(largest!=0){
printf("%-15s %7d\n", keepvar, killer[keepvar])
killer[keepvar]=0
} else {
break
}
}
printf("----------------------------\n")
printf("PLAYERS KILLED (only PC's):\n\n");
#
# Search for the largest element, print it out, then set it to zero.
# Break out of infinite while loop when all elements are zero.
#
while (1){
largest=0
for (var in killed){
if (killed[var] >largest){
largest=killed[var]
keepvar=var
}
}
if(largest!=0){
printf("%-15s %7d\n", keepvar, killed[keepvar])
killed[keepvar]=0
} else {
break
}
}
printf("----------------------------\n")
printf("NEW PLAYERS\n\n")
for (var in new) {
if( new[var] != 0){
printf("%-25s %s\n", var, new[var])
}
}
printf("----------------------------\n")
printf("CONNECTIONS\n\n")
while (1){
largest=0
for (var in conn){
if (conn[var] >largest){
largest=conn[var]
keepvar=var
}
}
if(largest!=0){
printf("%7d %s\n", conn[keepvar], keepvar)
conn[keepvar]=0
} else {
break
}
}
}