#!/usr/bin/perl
#
# halfStats:  A half-life log parsing program
# Location:   http://www.uwm.edu/~zachkarp/halfStats
# Author:     Zachary Karpinski
# Email:      zachkarp@csd.uwm.edu

# NOTICE!!!
# Looking for the configuration variables?
# Check 'halfStats.cfg' in the directory you decompressed halfStats into.
# As of version 0.93 the configuration is in an external file.

# Need to set your header? (server name)
# Edit a file called "servername.txt" in the directory
# that halfStats resides.

#------------------------------------------------------#
# *** Warning ***
# This script is the result of programming late at night
# and with no driving purpose other than "I can do this"
#
# Point?  Stuff below isnt commented and may not be the best 
# coding technique in the world.  I'm sure you've read
# that before, otherwise you wouldnt be digging this
# deep in the file :)
#------------------------------------------------------#

my %settings = ();
$settings = &parseConfig();

my $logDir = $settings->{'logDir'};
my $htmlDir = $settings->{'htmlDir'};
my $listMax = $settings->{'listMax'};
my $bgColor = $settings->{'bgColor'};
my $fgColor = $settings->{'fgColor'};
my $linkColor = $settings->{'linkColor'};



# This just double checks to make sure the paths are not at
# the default settings
&checkPaths($settings);

# grabs the number of seconds since 1970
my $start =  `date +%s`;
chomp($start);

# reads in a list of log files to use
my @fileList = `ls -1 $logDir/*.log`;

# temporary data file for kills
my $dataFile = "/tmp/datafile$$.dat";

# temporary data file for suicides
my $suicideFile = "/tmp/suicidefile$$.dat";

# this is where we store player data
my $playerDir = "$htmlDir/players";

# hmmm..  20/20?
my $tmpFile = "/tmp/temporaryfile$$.dat";

# get the pertinent data from each logfile
foreach $file (@fileList)
{
    chomp($file);
    system("cat $file | grep 'killed' >> $dataFile");
}

# put the suicides and worldspawn deaths into the suicide file
system("cat $dataFile | grep 'killed self' > $suicideFile");
system("cat $dataFile | grep 'killed by world' >> $suicideFile");

# remove suicides from the normal data
system("cat $dataFile | grep -v 'killed self' > $tmpFile");
system("cat $tmpFile | grep -v 'killed by world' >> $dataFile");
#system("mv $tmpFile $dataFile");

# switch 'self' to '"name of killer"'
&processSuicides($suicideFile);

# put the processed suicides back into the normal data
system("cat $suicideFile >> $dataFile");

#
# Sample entry from our $dataFile
#
# L 08/23/1999 - 23:20:42: "crimrOw<2>" killed "Rock Hudson<1>" with grenade
#
#

my ($front, $midMinute, $midSecond, $end) = ();
my ($L, $date, $dash, $hour) =  ();
my ($month, $day, $year) = ();
my ($nothing, $attacker, $killed, $target, $with) = ();
my ($part1, $part2, $part3) = ();
my ($part4, $part5) = ();
my ($wordWith, $weapon) = ();

# this month
my $curMonth = `date +%m`;

# this year
my $curYear = `date +%Y`;
chomp($curMonth);chomp($curYear);

# this array holds all the deaths
my @obitArray = ();

# counting variable
my $count = 0;

# keep track of all deaths
my $totalObits = 0;

my $parsedKiller = "NULL";
my $parsedKilled = "NULL";
my %stats = ();
my $self = "";
my $victims = "";

# open our data file 
open(FILE, "$dataFile") || die "\nError ($!): $dataFile\n\n";
my @logArray = <FILE>;
close(FILE);


foreach $line (@logArray)
{
    ($front, $midMinute, $midSecond, $end) = split(/\:/, $line); 
    ($L, $date, $dash, $hour) = split(" ", $front);
    ($month, $day, $year) = split("/", $date);
    if($year == $curYear && $month == $curMonth)
    {
	chomp($end);
	$obitArray[$count] = "$end";
	$count++;
    }
}

$totalObits = $count;
$count = 0;

foreach $obit (@obitArray)
{
    ($nothing, $attacker, $killed, $target, $with) = split(/\"/, $obit);
    ($part1, $part2, $part3) = split(/\</, "$attacker$target"); 
    ($part4, $part5) = split(/\>/, "$part2");
    $parsedKiller = "$part1";
    $parsedKilled = "$part5";

    ($wordWith, $weapon) = split(" ", $with);
    
    if($parsedKilled ne "")
    {
	if($parsedKilled eq "self")
	{
	    $parsedKilled = $parsedKiller;
	}
	$stats->{$parsedKiller}{$parsedKilled}{'times'} = $stats->{$parsedKiller}{$parsedKilled}{'times'} + 1;
	$stats->{$parsedKiller}{$parsedKilled}{$weapon}{'times'} = $stats->{$parsedKiller}{$parsedKilled}{$weapon}{'times'} + 1;
    }
}

# We are creating the html now
# first a header and such
&startPage("$htmlDir/index.html", $settings);

# now we create stats for each player
# This is the most complex part of this script
&createPlayerPages($playerDir, $stats, $settings);

# now the main index that houses the simple stats
&createList("$htmlDir/index.html", $stats, $settings);

# calculate and display the interesting weapon awards
&createWeaponAwards("$htmlDir/index.html", $stats, $settings);

# we are done, so print the exit stuff
&endPage("$htmlDir/index.html", $logDir, $start);

# cleanup
system("rm -f $dataFile");
system("rm -f $tmpFile");
system("rm -f $suicideFile");

sub createList
{
    my $file = $_[0];
    my $hash = $_[1];
    my $settings = $_[2];
    my $listMax = $settings->{'listMax'};
    my $bgColor = $settings->{'bgColor'};
    my $fgColor = $settings->{'fgColor'};
    my $linkColor = $settings->{'linkColor'};

    my $kills = 0;
    my $deaths = 0;

    my @ranking = ();
    my @rawKills = ();

    open(FILE, ">>$file") || die "ERROR opening $file: $!\n\n";

    print FILE "<br><br><br>\n";
    print FILE "<table width='50%' border='1'>\n";
    print FILE "<tr bgcolor='$fgColor'><td>\n";
    print FILE "<font size='+2' face='helvetica' color='$bgColor'>\n";
    print FILE "<center><b>Statistical breakdown of players</b></center>\n";
    print FILE "</font></td></td></table>\n";
    print FILE "<br><br>\n";

    print FILE "<table border='0' width='50%'>\n";
    print FILE "<tr bgcolor='#444444'>\n";
    print FILE "<td><font color='white'><b>Rank</b></font></td>\n";
    print FILE "<td><font color='white'><b>Player name</b></font></td>\n";
    print FILE "<td><font color='white'><b>Total Kills</b></font></td>\n";
    print FILE "<td><font color='white'><b>Total Deaths</b></font></td>\n";
    print FILE "<td><font color='white'><b>Efficiency</b></font></td>\n";
    print FILE "</tr>\n";


    foreach $player (keys(%$hash))
    {
	$kills = &getTotalKills($player, $hash);
	$deaths = &getDeaths($player, $hash);
	if($deaths > 0)
	{
	    $effic = $kills / $deaths;
	}
	else
	{
	    $effic = "(*N/A*)";
	}
	$effic = sprintf("%.2f", $effic);
	$ranking[$count] = "$effic;.;.;$kills;.;.;$deaths;.;.;$player";
	$count++; 
    }
    @ranking = sort {$b <=> $a} @ranking;

    $count = 1;
    foreach $line (@ranking)
    {
	if($count <= $listMax)
	{
	    ($effic, $kills, $deaths, $player) = split(";.;.;", $line);
	    
	    $playerFileName = &removeJunk($player);
	    
	    print FILE "<tr>\n";
	    print FILE "<td>$count</td>\n";
	    print FILE "<td><a href='players/$playerFileName.html'>$player</a></td>\n";
	    print FILE "<td>$kills</td>\n";
	    print FILE "<td>$deaths</td>\n";
	    print FILE "<td>$effic</td>\n";
	    $count++;
	}
    }
     
    print FILE "</table>\n";
    close(FILE);
}

sub removeJunk
{
    my $string = $_[0];
    $string =~ s/(\W)/_/g;
    return($string);
}

sub processSuicides
{
    my $suicides = $_[0];
    my @array = ();
    my $line = "NULL";

    open(FILE, "<$suicides");
    @array = <FILE>;
    close(FILE);

    foreach $line (@array)
    {
	$line =~ s/killed self/killed \"self<00>\"/g;
	$line =~ s/killed by world/killed \"self<00>\"/g;
    }

    open(FILE, ">$suicides");
    foreach $line (@array)
    {
	print FILE "$line";
    }
    close(FILE);
}

sub endPage
{
    my $file = $_[0];
    my $logDir = $_[1];
    my $start = $_[2];

    my $duText = `du -h $logDir`;
    chomp($duText);

    my ($size, $dot) = split(" ", $duText);

    my $now = `date +%s`;
    chomp($now);

    my $time = $now - $start;

    open(FILE,">>$file") || die "ERROR opening $file: $!\n\n";
    print FILE "<br><br><br>$size of log files processed in $time seconds<br><br>\n";   
    print FILE "<a href='http://www.uwm.edu/~zachkarp/halfStats'>halfStats</a> was written by <a href='MAILTO:zachkarp\@csd.uwm.edu'>Zach Karpinski</a><br><br><br>\n";
    print FILE "</center></body></html>\n";
    close(FILE);
}

sub startPage
{
    my $file = $_[0];
    my $settings = $_[1];

    my $bgColor = $settings->{'bgColor'};
    my $fgColor = $settings->{'fgColor'};
    my $linkColor = $settings->{'linkColor'};

    my $servfile = `pwd`;
    chomp($servfile);
    $servfile = "$servfile/servername.txt";

    my $hostname = `cat $servfile`;
    chomp($hostname);
    
    if($hostname eq "")
    {
	$hostname = `/bin/hostname`;
	chomp($hostname);
    }
    
    open(FILE,">$file") || die "ERROR opening $file: ($!)\n\n";
    print FILE "<html><head>\n";
    print FILE "<meta http-equiv='refresh' content='900'>\n";
    print FILE "<title>Welcome to halfStats..</title></head>\n";
    print FILE "<body bgcolor='$bgColor' text='$fgColor' link='$linkColor' vlink='$linkColor' alink='$linkColor'>\n";
    print FILE "<center><br><br><br>\n";
    print FILE "<font face='times' size='+2'>$hostname</font>\n";
    print FILE "<br><br><br>\n";
    close(FILE);
}

sub getTotalKills
{
    my $name = $_[0];
    my $hash = $_[1];
    my $times = 0;
    my $key = ();

    foreach $key (keys(%$hash))
    {
	if($key eq "$name")
	{
	    my $victims = $hash->{$key};
	    foreach $victName (keys(%$victims))
	    {
		$times = $times + $hash->{$key}{$victName}{'times'} ;
	    }
	}
    }
    return($times);
}

sub getDeaths
{
    my $name = $_[0];
    my $hash = $_[1];
    my $key = ();

    my $deaths = 0;

    foreach $key (keys(%$hash))
    {
	$deaths = $deaths + $hash->{$key}{$name}{'times'};
    }
    return($deaths);
}

sub createPlayerPages
{
    my $dir = $_[0];
    my $hash = $_[1];
    my $settings = $_[2];
    my $bgColor = $settings->{'bgColor'};
    my $fgColor = $settings->{'fgColor'};
    my $linkColor = $settings->{'linkColor'};

    my $name = "NULL";
    my $goodName = "NULL";
    my $victims = "";
    my $victim = "";
    my $favTargFrags = 0;
    my $favTarg = "";
    my $fraggedMost = 0;
    my $fraggedMeMost = "";
    my $hardTarg = "";
    my $hardTargFrags = 9999999999;
    my $fraggedLeast = 9999999999;
    my $fraggedMeLeast = "";
    my $kills = 0;
    my $deaths = 0;
    my $suicides = 0;
    my %weaponHash = ();
    my %weapons = ();
    my $weapon = "";
    my %myWeapons = ();
    my %opponents = ();
    my $linkName = "";


    foreach $name (keys(%$hash))
    {
	$opponents = $hash->{$name};
	
	$goodName = &removeJunk($name);
	open(FILE, ">$dir/$goodName.html");
	print FILE "<html><head>\n";
	print FILE "<title>Statistics for $name..</title></head>\n";
	print FILE "<body bgcolor='$bgColor' text='$fgColor' link='$linkColor' vlink='$linkColor'>\n";
	print FILE "<br><br><br>\n";
	print FILE "<center>\n";
	print FILE "<table width='80%' border='0'><tr><td>\n";
	print FILE "<font face='helvetica' size='+1'>\n";
	print FILE "Individual statistics for</font>\n";
	print FILE "<font face='times' size='+2'><i>$name</i>\n";
	print FILE "</font></td></tr></table>\n";

	print FILE "<br><br><br>\n";
	
	$kills = &getTotalKills($name, $hash);
	$deaths = &getDeaths($name, $hash);
	$suicides = $hash->{$name}{$name}{'times'};

	print FILE "<table width='400' border='0'>\n";
	print FILE "<tr bgcolor='$fgColor'>\n";
	print FILE "<td><font color='$bgColor' face='helvetica'>\n";
	print FILE "<center><i><b>Kill Total: </i></b> $kills</center>\n";
	print FILE "</font></td>\n";
	print FILE "<td><font color='$bgColor' face='helvetica'>\n";
	print FILE "<center><i><b>Death Total: </i></b> $deaths</center>\n";
        print FILE "</font></td>\n";
	print FILE "<td><font color='$bgColor' face='helvetica'>\n";
        print FILE "<center><i><b>Suicide Total: </i></b> $suicides</center>\n";
        print FILE "</font></td>\n";
	print FILE "</tr></table>\n";

	print FILE "<br><br>\n";

	print FILE "<table width='60%' border='1'>\n";
        print FILE "<font face='arial' size='+2'>\n";

	$victims = $hash->{$name};
	
	foreach $victim (keys(%$victims))
	{
 	    #print "Who: $name\n";
	    #print "\t$victims->{$victim}{'times'} = $victim\n"; 

	    if($victims->{$victim}{'times'} eq "") 
	    {$victims->{$victim}{'times'} = 0;}

	    if($victims->{$victim}{'times'} > 0)
	    {
		if($victims->{$victim}{'times'} > $favTargFrags)
		{
		    $favTargFrags = $victims->{$victim}{'times'};
		    $favTarg = $victim;
		}
		
		if($victims->{$victim}{'times'} < $hardTargFrags)
		{
		    $hardTargFrags = $victims->{$victim}{'times'};
		    $hardTarg = $victim;
		}
	    }
	}

	print FILE "<tr bgcolor='#000044'>\n";
	print FILE "<td><b><font color='white'>$name found it easiest to kill:</font></b> </td>\n";
	print FILE "<td><font color='white' size='+1'>$favTarg</font></td>\n";
 	print FILE "<td><font size='+2' color='yellow'>$favTargFrags</font></td>\n";
	print FILE "</tr>\n";

	print FILE "<tr bgcolor='#440000'>\n";
	print FILE "<td><b><font color='white'>$name found it hardest to kill:</font></b> </td>\n";
	print FILE "<td><font color='white' size='+1'>$hardTarg</font></td>\n";
	print FILE "<td><font size='+2' color='yellow'>$hardTargFrags</font></td>\n";
	print FILE "</tr>\n";

	$hardTarg = "";
	$hardTargFrags = 9999999999;
	$favTarg = "";
	$favTargFrags = 0;

	foreach $attacker (keys(%$hash))
	{

	    if($hash->{$attacker}{$name}{'times'} eq "")
	    {$hash->{$attacker}{$name}{'times'} = 0;}

	    if($hash->{$attacker}{$name}{'times'} > 0)
	    {
		if($hash->{$attacker}{$name}{'times'} < $fraggedLeast)
		{
		    $fraggedLeast = $hash->{$attacker}{$name}{'times'};
		    $fraggedMeLeast = $attacker;
		}
		
		if($hash->{$attacker}{$name}{'times'} > $fraggedMost)
		{
		    $fraggedMost = $hash->{$attacker}{$name}{'times'};
		    $fraggedMeMost = $attacker;
		}
	    }
	}
	
	print FILE "<tr bgcolor='#000055'>\n";
	print FILE "<td><b><font color='white'>$name was killed least by</b>:</font> </td>\n";
	print FILE "<td><font color='white' size='+1'>$fraggedMeLeast</font></td>\n";
	print FILE "<td><font size='+2' color='yellow'>$fraggedLeast</font></td>";
	print FILE "</tr>\n";

	print FILE "<tr bgcolor='#550000'>\n";
	print FILE "<td><b><font color='white'>$name was killed most by</b>:</font> </td>\n";
	print FILE "<td><font color='white' size='+1'>$fraggedMeMost</font></td>\n";
        print FILE "<td><font size='+2' color='yellow'>$fraggedMost</font></td>\n";
	print FILE "</tr>\n";

	$fraggedLeast = 9999999999;
	$fraggedMeLeast = "";
	$fraggedMost = 0;
 	$fraggedMeMost = "";

 	print FILE "</table>\n";

	foreach $victim (keys(%$victims))
        {
	    $weapons = $hash->{$name}{$victim};
	    foreach $weapon (keys(%$weapons))
	    {
		if($weapon ne "times")
		{
		    $weaponHash->{$name}{$weapon}[0] = $weaponHash->{$name}{$weapon}[0] + $weapons->{$weapon}{'times'};
		}
	    }
	}

	print FILE "<br><br>\n";
	print FILE "<table width='60%' border='1'>\n";
	print FILE "<tr bgcolor='#555555'>\n";
	print FILE "<td><b><font color='white'>Rank:</font></b></td>\n";
	print FILE "<td><b><font color='white'>Weapon:</font></b></td>\n";
	print FILE "<td><b><font color='white'>Number of uses:</font></b></td>\n";
	print FILE "<td><b><font color='white'>Percentage of kills:</font></b></td>\n";
	print FILE "</tr>\n"; 

	$myWeapons = $weaponHash->{$name};
	$weapcount = 1;
	
	foreach $weapon (sort {$myWeapons->{$b}[0] <=> $myWeapons-> {$a}[0] } keys %$myWeapons )
	{
	    if($weapon ne "times"
	       && $weapon ne "door"
	       && $weapon ne "rotating"
	       && $weapon ne "trigger_hurt"
	       && $weapon ne "plat"
	       && $weapon ne "worldspawn")
	    {
		$percent = sprintf("%.3f", $myWeapons->{$weapon}[0]/$kills);
		$percent = $percent * 100;
		print FILE "<tr bgcolor='$bgColor'>\n";
		print FILE "<td><font color='$fgColor'>$weapcount</font></td>\n";
		print FILE "<td><font color='$fgColor'>$weapon</font></td>\n";
		print FILE "<td><font color='$fgColor'>$myWeapons->{$weapon}[0]</font></td>\n";
		print FILE "<td><font color='$fgColor'>$percent\%:</font></td>\n";
		print FILE "</tr>\n";
		$weapcount++;
	    }
	}
	print FILE "</table>\n";

        print FILE "<br><br>\n";
        print FILE "<table width='60%' border='1'>\n";
        print FILE "<tr bgcolor='#555555'>\n";
        print FILE "<td><b><font color='white'>Name:</font></b></td>\n";
	print FILE "<td><b><font color='white'>Killed by $name:</font></b></td>\n";
        print FILE "<td><b><font color='white'>Killed $name:</font></b></td>\n";
	print FILE "<td><b><font color='white'>Kills per death</font></b></td>\n";
	print FILE "</tr>\n";
	
	foreach $opponent (sort {$opponents->{$b}{'times'} <=> $opponents->{$a}{'times'} } keys %$opponents )
	{
	    if($opponent ne $name)
	    {
		if($hash->{$name}{$opponent}{'times'} != 0)
		{
		    $linkName = &removeJunk($opponent);
		    print FILE "<tr bgcolor='$bgColor'>\n";
		    print FILE "<td><a href='$linkName.html'>$opponent</a></td>\n";
		    print FILE "<td>$hash->{$name}{$opponent}{'times'}</td>\n";
		    print FILE "<td>$hash->{$opponent}{$name}{'times'}</td>\n";
		    if($hash->{$opponent}{$name}{'times'} != 0)
		    {
			$percent = sprintf("%.2f", 
					   $hash->{$name}{$opponent}{'times'}
					   /
					   $hash->{$opponent}{$name}{'times'}
					   );
			$percent = "$percent";
		    }
		    else
		    {
			$percent = "N/A";
		    }
		    print FILE "<td>$percent</td>\n";

		    print FILE "</tr>\n";
		}
	    }
	}

	print FILE "</table>\n";


	print FILE "</center><br><br><br>\n";
	print FILE "<a href='../index.html'>Back to HalfStats Summary</a><br>\n";
  	print FILE "</body></html>\n";

    }    
}

sub checkPaths
{
    my $settings = $_[0];
    if($settings->{'logDir'} eq "/path/to/halflife/log/files")
    {
	die "\n*** ERROR ***\n\tYou have not editted your halfStats paths yet..\n*** ERROR ***\n\n";
    }
    elsif($settings->{'htmlDir'} eq "/path/to/html/directory")
    {
	die "\n*** ERROR ***\n\tYou have not editted your halfStats paths yet..\n*** ERROR ***\n\n";
    }
}

sub parseConfig
{
    my $configFile = "./halfStats.cfg";
    my @fileContents = ();
    my ($variable, $value) = ();
    my %config = ();


    open(FILE, "<$configFile") || die "\n\n*** ERROR: $! for $configFile\n\n";
    @fileContents = <FILE>;
    close(FILE);

    foreach $line (@fileContents)
    {
	$line =~ /^.{0}(.)/;
	if($1 ne "#" && $1 ne "")
	{
	    chomp($line);
	    ($variable, $value) = split(/\=/, $line);
	    $config->{$variable} = $value;
	}
	else
	{
	    # do nothing, this is a comment
	}
    }
    return($config);
}
#&createWeaponAwards("$htmlDir/index.html", $stats, $settings);
sub createWeaponAwards
{
    my $index = $_[0];
    my $stats = $_[1];
    my $settings = $_[2];

    my $name = "";

    my %victims = ();
    my $victim = "";
  
    my %weapons = ();
    my $weapon = "";

    my %high = ();
    $high->{'crowbar'}{'uses'} = 0;
    $high->{'crossbow'}{'uses'} = 0;
    $high->{'gluon'}{'uses'} = 0;

    my $crowbarCount = 0;
    my $crossbowCount = 0;
    my $gluonCount = 0;

    foreach $name (keys(%$stats))
    {
	$crowbarCount = 0;
	$crossbowCount = 0;
	$gluonCount = 0;
	if($name ne "")
	{ 
	    $victims = $stats->{$name};
	    foreach $victim (keys(%$victims))
	    {
		$crowbarCount = $crowbarCount + $stats->{$name}{$victim}{'crowbar'}{'times'};
		$crossbowCount = $crossbowCount + $stats->{$name}{$victim}{'crossbow'}{'times'};
		$gluonCount = $gluonCount + $stats->{$name}{$victim}{'gluon'}{'times'};
	    }
	    if($crowbarCount > $high->{'crowbar'}{'uses'})
	    {
		$high->{'crowbar'}{'uses'} = $crowbarCount;
		$high->{'crowbar'}{'name'} = $name;
	    }
	    if($crossbowCount > $high->{'crossbow'}{'uses'})
            {
                $high->{'crossbow'}{'uses'} = $crossbowCount;
                $high->{'crossbow'}{'name'} = $name;
            }
            if($gluonCount > $high->{'gluon'}{'uses'})
            {
                $high->{'gluon'}{'uses'} = $gluonCount;
                $high->{'gluon'}{'name'} = $name;
            }

	}
    }
    
    open(FILE, ">>$index");
    print FILE "<br><br><br><br>\n";
    print FILE "<table border='1' width='50%'>\n";
    print FILE "<tr bgcolor='$settings->{'fgColor'}'><td align='center'>\n";
    print FILE "<font color='$settings->{'bgColor'}' size='+2'>\n";
    print FILE "Individual Awards for Highest Usage of <b>'THOSE'</b> Weapons\n";
    print FILE "</font></td></tr></table><br>\n";

    print FILE "<table border='0' width='50%'>\n";
#    print FILE "<tr bgcolor='#444444'>\n";
#    print FILE "<td><font color='white'><b>Award:</b></font></td>\n";
#    print FILE "<td><font color='white'><b>Name:</b></font></td>\n";
#    print FILE "<td><font color='white'><b>Score:</b></font></td>\n";
#    print FILE "</tr>\n";

    print FILE "<tr>\n";
    print FILE "<td><i><font face='helvetica' size='+1'>\n";
    print FILE "Gone Clubbin award</font></i><br>\n";
    print FILE "<font size='-1'>(most kills with crowbar)</font></td>\n";
    print FILE "<td>$high->{'crowbar'}{'name'}</td>\n";
    print FILE "<td><font color='yellow'><b>$high->{'crowbar'}{'uses'}</b></font></td>\n";
    print FILE "</tr>\n";

    print FILE "<tr>\n";
    print FILE "<td><i><font face='helvetica' size='+1'>\n";
    print FILE "Sit \& Snipe award</font></i><br>\n";
    print FILE "<font size='-1'>(most kills with crossbow)</font></td>\n";
    print FILE "<td>$high->{'crossbow'}{'name'}</td>\n";
    print FILE "<td><font color='yellow'><b>$high->{'crossbow'}{'uses'}</b></font></td>\n";
    print FILE "</tr>\n";

    print FILE "<tr>\n";
    print FILE "<td><i><font face='helvetica' size='+1'>\n";
    print FILE "Glue whOre award</font></i><br>\n";
    print FILE "<font size='-1'>(most kills with gluon gun)</font></td>\n";
    print FILE "<td>$high->{'gluon'}{'name'}</td>\n";
    print FILE "<td><font color='yellow'><b>$high->{'gluon'}{'uses'}</b></font></td>\n";
    print FILE "</tr>\n";
    print FILE "</table>\n";

    close(FILE); 
}

