IRC bOt - NukeZone
Apr 24 2009 NukeZone Programming

This irssi perl IRC script calculates various game information that is useful to have at hand.
There's a usage post on this site if you're interested.  

#!/usr/bin/perl
# e dziewa august 2007, february 2008, november 2008

use warnings;
use strict;
use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add_last );
use ETDNukezoneData5;

$VERSION = '3';
%IRSSI = (
    authors        => 'E. Dziewa',
    contact        => 'eric@dziewa.com',
    name       => 'Nukezone Calculator',
    description    => 'Calculates useful NZ stats',
    license        => 'GNU GPL 3',
    restriction    => 'Open Source operating systems',
    url            => 'http://eric.dziewa.com'
);

our @timenow = 0;

sub private_query {
        my ( $server, $msg, $nick, $address ) = @_;
        nw__calc($server, $msg, $nick, $nick, $address );
}

sub public_query {

        my ($server, $msg, $nick, $address, $target) = @_;
        nw__calc($server, $msg, $nick, $target, $address );

}
sub nw__calc {
        our ($server, $msg, $nick, $target, $address ) = @_;

    ### lag/flood delay
    push(@timenow, time());
    if ( (( $timenow[-1] - $timenow[0] ) < 4 ) &&
        ( $msg =~ /^!testA|^![Aa][Tt]{2}[Aa][Cc][Kk]|^![Hh][Ee][Ll][Pp]|^![Tt][Oo][Pp]100|
            ^![Rr][Aa][Nn][Gg][Ee]|^![Ff][Pp]|^![Mm](?:[Pp]|[Dd])|^![Ss][Tt][Aa][Tt][Ss]|
            ^![Nn][Ww]|^![Pp][Oo][Ww][Ee][Rr]|^![Tt][Aa][Rr][Gg][Ee][Tt]|^![Ww][Oo][Rr][Kk][Ee][Rr]|
            ^![Ss][Cc][Aa][Nn]|^![Oo][Ww][Nn][Ss][Cc][Aa][Nn]|^![Cc][Oo][Ss][Tt]|^![Hh][Ii][Vv][Ee]/x ) ) {
        $server->command("notice $nick wait 3 seconds between commands $nick");
        return;
    }

unless ( $msg =~ /^!testA|^![Aa][Tt]{2}[Aa][Cc][Kk]|^![Hh][Ee][Ll][Pp]|^![Tt][Oo][Pp]100|
    ^![Rr][Aa][Nn][Gg][Ee]|^![Ff][Pp]|^![Mm](?:[Pp]|[Dd])|^![Ss][Tt][Aa][Tt][Ss]|^![Nn][Ww]|
    ^![Pp][Oo][Ww][Ee][Rr]|^![Tt][Aa][Rr][Gg][Ee][Tt]|^![Ww][Oo][Rr][Kk][Ee][Rr]|^![Ss][Cc][Aa][Nn]|
    ^![Oo][Ww][Nn][Ss][Cc][Aa][Nn]|^![Cc][Oo][Ss][Tt]|^![Hh][Ii][Vv][Ee]/x ) {
    return;
}

    @timenow = $timenow[-1];
    $_ = $msg;

if ( /^!testA$/ ) { # just for testing color output
    my %irc_colorsA = (
    'bold'         => "0",    # bold
    'black'            => "1",   #
    'blue'         => "2",    #
    'green'            => "3",   #
    'bold_red'     => "4",     #
    'red'          => "5",     #
    'purple'       => "6",  # named magenta purple
    'yellow'       => "7",  # named orange, i see yellow
    'bold_yellow'  => "8",  # bold
    'bold_green'   => "9",  # bold
    'brown'            => "10", # cyan
    'bold_cyan'        => "11", # bold
    'bold_blue'        => "12", # bold
    'bold_magenta' => "13", # bold
    'bold_gray'        => "14", # magenta #blah black
    'gray'         => "15"  # light gray
    );

    my @colorsA = (
    'bold','black','blue','green','bold_red','red','purple',
    'yellow','bold_yellow','bold_green','brown','bold_cyan','bold_blue','bold_magenta','bold_gray','gray'
    );

    my $string = "";
    foreach ( @colorsA ) {
        $string .= sprintf(" \cC%02d##\co\cC0,%02d$irc_colorsA{$_}\c_\cVR\co", $irc_colorsA{$_}, $irc_colorsA{$_});
    }
    $server->command("msg $target $string");
}

elsif ( /^![Aa][Tt]{2}[Aa][Cc][Kk]$/ ) {
    $server->command("msg $target !attack -> Returns kills, and networth damage dealt. Example -> !attack 100 sub with 100 stealth boat air and sea");
}

elsif ( /^![Aa][Tt]{2}[Aa][Cc][Kk]\s+\d+\s+[-\/ A-Za-z0-9]+\s+[Ww][Ii][Tt][Hh]\s+\d+\s+[-\/ A-Za-z0-9]+
    (?:\s+[Aa][Gg]{1,2}[Rr][Ee][Ss]{1,2}[Ii][Vv][Ee]?|\s+[Aa][Ii][Rr]\s*[Aa][Nn][Dd]\s*[Ss][Ee][Aa]|
    \s+[Gg][Rr][Oo][Uu][Nn][Dd])?$/x ) {
    my $extramodifier = 1; our $types;
    if ( ( /[Aa][Gg]{1,2}[Rr][Ee][Ss]{1,2}[Ii][Vv][Ee]/ ) &&
        ( /[Aa][Ii][Rr]\s*[Aa][Nn][Dd]\s*[Ss][Ee][Aa]|[Gg][Rr][Oo][Uu][Nn][Dd]/ ) ) {
        $extramodifier = 1.5;
        if ( /[Aa][Ii][Rr]\s*[Aa][Nn][Dd]\s*[Ss][Ee][Aa]/ ) { $types = '( Aggressive, Air & Sea )' }
        else { $types = '( Aggressive, Ground )' }
    }
    elsif ( ( /[Aa][Gg]{1,2}[Rr][Ee][Ss]{1,2}[Ii][Vv][Ee]/ ) ) {
        $extramodifier = 1.35;
        $types = '( Regular, Aggressive )';
    }
    elsif ( ( /[Aa][Ii][Rr]\s*[Aa][Nn][Dd]\s*[Ss][Ee][Aa]|[Gg][Rr][Oo][Uu][Nn][Dd]/ ) ) {
        $extramodifier = 1.15;
        if ( /[Aa][Ii][Rr]\s*[Aa][Nn][Dd]\s*[Ss][Ee][Aa]/ ) { $types = '( Air & Sea )' }
        else { $types = '( Ground )' }
    }
    else { $types = '( Regular )' }

    my @array = $_ =~ /^![Aa][Tt]{2}[Aa][Cc][Kk]\s+(\d+)\s+([-\/ A-Za-z0-9]+)\s+
        [Ww][Ii][Tt][Hh]\s+(\d+)\s+([-\/ A-Za-z0-9]+)
    (?:\s+[Aa][Gg]{1,2}[Rr][Ee][Ss]{1,2}[Ii][Vv][Ee]?|\s+[Aa][Ii][Rr]\s*
    [Aa][Nn][Dd]\s*[Ss][Ee][Aa]|\s+[Gg][Rr][Oo][Uu][Nn][Dd])?$/x;

    if ( $array[2] =~ /^0/ or $array[0] =~ /^0/ ) {
        $server->command("msg $target Don't try to crash the bOt $nick");
        return;
    }
    elsif ( $array[0] > 1000000 or $array[2] > 1000000 ) {
        $server->command("msg $target 1,000,000 is the max $nick");
        return;
    }
    else { ; }

    our ( $newship, $handle, $newshipcolor, $newship2, $handle2, $newship2color ) = ();
    our ( $retval, $retval2 ) = ();
    our ( $argument, $argument2, $number_of, $number_of2, $idlemultiplier, $mod ) = ();

    do_work( $array[3], $array[1], $array[2], $array[0], $server, $target, $extramodifier );

    sub do_work {
        $argument = shift;
        $argument2 = shift;
        $number_of = shift;
        $number_of2 = shift;
        $server = shift;
        $target = shift;
        $mod = shift;
    
        $newship = ETDNukezoneData5->get_regexes( $argument );
        if ( ! $newship ) { $server->command("msg $target Syntax error. No such unit \"$argument\", $nick"); return; }
        ($handle) = keys %$newship;
        $newshipcolor = ETDNukezoneData5->irc_color( $$newship{$handle}[17] );

        $newship2 = ETDNukezoneData5->get_regexes( $argument2 );
        if ( ! $newship2 ) { $server->command("msg $target Syntax error. No such unit \"$argument2\", $nick"); return; }
        ($handle2) = keys %$newship2;
        $newship2color = ETDNukezoneData5->irc_color( $$newship2{$handle2}[17] );

    if ( $types =~ /Air/ and $$newship{$handle}[8] ne 1 ) {
        my $string = sprintf("\003%02d$handle\003 can't use \cBair & sea\co attack $nick", $$newshipcolor );
        $server->command("msg $target $string");
        return;
    }
    elsif ( $types =~ /Ground/ and $$newship{$handle}[9] ne 1 ) {
        my $string = sprintf("\003%02d$handle\003 can't use \cBground\co attack $nick", $$newshipcolor );
        $server->command("msg $target $string");
        return;
    }
    elsif ( $types =~ /Regular/ and $$newship{$handle}[10] ne 1 and $$newship{$handle}[11] !~ /M|O/ ) {
        my $string = sprintf("\003%02d$handle\003 can't use \cBregular\co attack $nick", $$newshipcolor );
        $server->command("msg $target $string");
        return;
    }
    else { ; }

        my ( $targettype, $searchin, $targettype2 ) = ();
        our $searchin2 = ();
        ### $targettype is type of defender, $targettype2 is type of attacker
        $targettype = $$newship2{$handle2}[11];
        $targettype2 = $$newship{$handle}[11];

    { no warnings;
    ### defender type
    ( $targettype =~ /S/ ) ? ( $searchin = '3' ) :
    ( $targettype =~ /A/ ) ? ( $searchin = '4' ) :
    ( $targettype =~ /V/ ) ? ( $searchin = '5' ) :
    ( $targettype =~ /I/ ) ? ( $searchin = '6' ) :
    ( $targettype =~ /B/ ) ? ( $searchin = '7' ) :
    "";
    ### attacker type
    ( $targettype2 =~ /S/ ) ? ( $searchin2 = '3' ) :
    ( $targettype2 =~ /A/ ) ? ( $searchin2 = '4' ) :
    ( $targettype2 =~ /V/ ) ? ( $searchin2 = '5' ) :
    ( $targettype2 =~ /I/ ) ? ( $searchin2 = '6' ) :
    ( $targettype2 =~ /B/ ) ? ( $searchin2 = '7' ) :
    "";
    };


if ( $$newship{$handle}[11] =~ /M|O/ and $$newship{$handle}[$searchin] == 1 ) { # missile|orbital && a defined valid target
### the freakn warning uninitialized variable in array element is driving me nuts, !attack 1 laser with 1 laser

        my $string = (); $string = 'V I C T O R Y  ';
        $string .= &you_win;
        $server->command("msg $target $string")
}

elsif ( $$newship{$handle}[$searchin] == 1 ) {# the ship is targetted
    if ( $$newship2{$handle2}[$searchin2] == 1 ) { # does attack back?
        if ( ($number_of * $$newship{$handle}[1]) > ($number_of2 * $$newship2{$handle2}[1]) ) { # win a double
            my $string = (); $string = 'V I C T O R Y  ';
            $string .= &you_win;
            $string .= &counter_attack; $string .= " $types";
            $server->command("msg $target $string");
            return;
        }
        else { # lose a double
            my $string = (); $string = 'D E F E A T  ';
            $string .= &counter_attack; $string .= " $types";
            $server->command("msg $target $string");
            return;
        }
    }
    else { # win a single
        my $string = (); $string = 'V I C T O R Y  ';
        $string .= &you_win; $string .= " $types";
        $server->command("msg $target $string");
        return;
    }
}

elsif ( $$newship2{$handle2}[$searchin2] == 1 && $$newship2{$handle2}[11] !~ /M|O/ ) { # you don't target, neither do defensive missiles/satellites
    my $string = ();
    $string = sprintf("D E F E A T  \( \003%02d$handle\003 do not target \003%02d$handle2\003 \) ", $$newshipcolor, $$newship2color );
    $string .= &counter_attack; $string .= " $types";
    $server->command("msg $target $string");
    return;
}

else { # neither target
    my $string = sprintf("D E F E A T  \( \003%02d$handle\003 do not target \003%02d$handle2\003 \) ", $$newshipcolor, $$newship2color );
    $server->command("msg $target $string $nick");
    return;
}

sub counter_attack {
    my $number = sprintf("%.2f", ( $number_of2 * $$newship2{$handle2}[1] / $$newship{$handle}[2] * 0.0289794204115918 ) * $mod );
    my $nw = sprintf("%.2f", ( $$newship{$handle}[0] * $$newship{$handle}[12] ) * ( $number_of2 * $$newship2{$handle2}[1] / $$newship{$handle}[2] * 0.0289794204115918 ) * $mod );

    if ( $number > $number_of ) {
        $number = commie($number_of);
        $nw = commie( sprintf("%.2f", $$newship{$handle}[0] * $$newship{$handle}[12] * $number_of ) );
    }
    else {
        $number = commie($number);
        $nw = commie($nw);
    }
    $retval = sprintf("\( %s \003%02d$handle2\003 kill -> $number \003%02d$handle\003 \)-\( \$$nw \) ", commie($number_of2), $$newship2color,
        $$newshipcolor,
            );
    return $retval;
}

sub you_win {
    if ( $$newship{$handle}[11] =~ /M/ ) {
        if ( $handle =~ /Nuclear Missile/ ) { # A / D / 3 * magicnum * magic nuke number ~ 0.9
            my $number = sprintf("%.1f", $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] / 3 * 0.0289794204115918 * 0.88659793814433 );
            my $nw = sprintf("%.2f", ( $$newship2{$handle2}[0] * $$newship2{$handle2}[12] ) * ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] / 3 * 0.0289794204115918 * 0.88659793814433 ) );
            if ( $number > $number_of2 ) {
                $number = commie($number_of2);
                $nw = commie( sprintf("%.2f", $$newship2{$handle2}[0] * $$newship2{$handle2}[12] * $number_of2 ) );
            }
            else {
                $number = commie($number);
                $nw = commie($nw);
            }
            $retval2 = sprintf("\( %s \003%02d$handle\003 kill -> $number \003%02d$handle2\003 \)-\( \$$nw \)", commie($number_of), $$newshipcolor, $$newship2color );
        }
        elsif ( $handle =~ /Biochemical Missile/ ) { # A / D * magicnum
            my $number = sprintf("%.1f", $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.0289794204115918 );
            my $nw = sprintf("%.2f", ( $$newship2{$handle2}[0] * $$newship2{$handle2}[12] ) * ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.0289794204115918 ) );
            if ( $number > $number_of2 ) {
                $number = commie($number_of2);
                $nw = commie( sprintf("%.2f", $$newship2{$handle2}[0] * $$newship2{$handle2}[12] * $number_of2 ) );
            }
            else {
                $number = commie($number);
                $nw = commie($nw);
            }
            $retval2 = sprintf("\( %s \003%02d$handle\003 kill -> $number \003%02d$handle2\003 \)-\( \$$nw \)", commie($number_of), $$newshipcolor, $$newship2color );
        }
        elsif ( $handle =~ /Chemical Missile/ ) { # A / D / 2 / magicnum
            my $number = sprintf("%.1f", $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.0289794204115918 );
            my $nw = sprintf("%.2f", ( $$newship2{$handle2}[0] * $$newship2{$handle2}[12] ) * ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.028979420411591 ) );
            if ( $number > $number_of2 ) {
                $number = commie($number_of2);
                $nw = commie( sprintf("%.2f", $$newship2{$handle2}[0] * $$newship2{$handle2}[12] * $number_of2 ) );
            }
            else {
                $number = commie($number);
                $nw = commie($nw);
            }
            $retval2 = sprintf("\( %s \003%02d$handle\003 kill -> $number \003%02d$handle2\003 \)-\( \$$nw \)", commie($number_of), $$newshipcolor, $$newship2color );
        }
        elsif ( $handle =~ /Tomahawk/ ) { # A / D * 0.4 * magicnum NEW:: * $idlemultiplier
            my $number = sprintf("%.1f", $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.4 * 0.0289794204115918 / 2 );
            my $nw = sprintf("%.2f", ( $$newship2{$handle2}[0] * $$newship2{$handle2}[12] ) * ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.4 * 0.0289794204115918 / 2 ) );
            if ( $number > $number_of2 ) {
                $number = commie($number_of2);
                $nw = commie( sprintf("%.2f", $$newship2{$handle2}[0] * $$newship2{$handle2}[12] * $number_of2 ) );
            }
            else {
                $number = commie($number);
                $nw = commie($nw);
            }
            $retval2 = sprintf("\( %s \003%02d$handle\003 kill -> $number \003%02d$handle2\003 \)-\( \$$nw \)", commie($number_of), $$newshipcolor, $$newship2color )
        }
        else {
            Irssi::print "Missile silo's empty";
            return;
        }
    }
    else {
        my ( $L, $R );
        if (
            ### air & sea && defender doesn't participate
            ( $types =~ /Air/ && $$newship2{$handle2}[13] !~ /1/ ) ||
            ### same for ground
            ( $types =~ /Gro/ && $$newship2{$handle2}[14] !~ /1/ ) ||
            ### and so on
            ( $types =~ /Reg/ && $$newship2{$handle2}[15] !~ /1/ )
        ) {
            $idlemultiplier = '.4';
            ( $types = $types ) =~ s/\((.+)\)/\[$1\]/g;
            $L = '['; $R = ']';
        }
        else {
            $idlemultiplier = '1'; $L = '('; $R = ')';
        }

            if ( $handle =~ /Laser Beam Satellite/ ) { # A / D / 3
                my $number = sprintf("%.1f", $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] / 3 );
                my $nw = sprintf("%.2f", ( $$newship2{$handle2}[0] * $$newship2{$handle2}[12] ) * ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] / 3 ) );

                if ( $number > $number_of2 ) {
                    $number = commie($number_of2);
                    $nw = commie( sprintf("%.2f", $$newship2{$handle2}[0] * $$newship2{$handle2}[12] * $number_of2 ) );
                }
                else {
                    $number = commie($number);
                    $nw = commie($nw);
                }
                $retval2 = sprintf("\( %s \003%02d$handle\003 kill -> $number \003%02d$handle2\003 \)-\( \$$nw \)", commie($number_of), $$newshipcolor, $$newship2color );
            }
            else {
                my $number = sprintf("%.2f", ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.0289794204115918)  * $idlemultiplier * $mod );
                my $nw = sprintf("%.2f", ( $$newship2{$handle2}[0] * $$newship2{$handle2}[12] ) * ( $number_of * $$newship{$handle}[1] / $$newship2{$handle2}[2] * 0.0289794204115918 ) * $idlemultiplier * $mod);
                if ( $number > $number_of2 ) {
                    $number = commie($number_of2);
                    $nw = commie( sprintf("%.2f", $$newship2{$handle2}[0] * $$newship2{$handle2}[12] * $number_of2 ) );
                }
                else {
                    $number = commie($number);
                    $nw = commie($nw);
                }
                $retval2 = sprintf("\( %s \003%02d$handle\003 kill -> $number \003%02d$handle2\003 \)-$L \$$nw $R ", commie($number_of), $$newshipcolor, $$newship2color );
            }
    }
    return $retval2;
}

return;

}

}

### end ###

    elsif ( /^![Aa][Tt]{2}[Aa][Cc][Kk]\s[A-Za-z0-9_ ]+$/ ) {
        if ( my ( $slot_a, $slot_b ) = /^![Aa][Tt]{2}[Aa][Cc][Kk] (.+)? with (.+)$/ ) {
            my $var = sprintf("%1.2f", rand(1) );

            if ( $slot_a =~ /armor(?:attak|bot)/i ) {
                $server->command("msg $target D E F E A T :)");
                return;
            }
            elsif ( $slot_b =~ /armor(?:attak|bot)/i ) {
                $server->command("msg $target V I C T O R Y :)");
                return;
            }
            elsif ( int(rand(2)) == 1 ) {
                $server->command("msg $target V I C T O R Y \cB$slot_b\co kill -> $var \cB$slot_a\co");
                return;
            }
            else {
                $server->command("msg $target D E F E A T \cB$slot_a\co kill -> $var \cB$slot_b\co");
                return;
            }
        }
        else {
            $server->command("msg $target syntax error. Type \"!attack\" without any parameters for help.");
            return;
        }
    }

    elsif ( /^![Aa][Tt]{2}[Aa][Cc][Kk].+$/ ) {
        $server->command("msg $target syntax error. Type \"!attack\" without any parameters for help.");
        return;
    }

    elsif ( /^![Hh][Ee][Ll][Pp]$/ ) {
        $server->command("msg $target Nukezone commands are -> !fp, !nw, !md, !stats, !range, !attack, !power, !mp, and !top100. Type a command alone for an example. " );
    }

    elsif ( /^![Tt][Oo][Pp]100$/ ) {
        $server->command("msg $target Top 100 commands are -> !networth, !points, !combo, !province, !worst, !topcombo, and !toppoints. Type a trigger without any parameters for examples." );
    }

    elsif ( /^![Rr][Aa][Nn][Gg][Ee]$/ ) {
        $server->command("msg $target !range -> Returns attack range of given score. Example -> !range 500000 " );
    }

    elsif ( /^![Rr][Aa][Nn][Gg][Ee].+$/ ) {
        if ( my ($selection) = /^![Rr][Aa][Nn][Gg][Ee]\s+(\d+)$/ ) {

            if ( $selection > 1000000000 ) { $server->command("msg $target 1,000,000,000 max $nick"); return; }
            if ( $selection =~ /^0/ ) { $server->command("msg $target Don't try to crash the bOt $nick"); return; }

        my $low = int( $selection * 0.714285714285714 );
        my $high = int( $selection * 1.4 );
        $server->command('msg '.$target.' Attack range of $'.commie($selection).'  -> $'.commie($low).'  $'.commie($high) ) ;
        }
        else {
            $server->command("msg $target syntax error. Type \"!range\" without any parameters for help.");
            return;
        }
    }

    elsif ( /^![Ff][Pp]$/ ) {
        $server->command("msg $target !fp -> Returns firepower of units and buildings. Supposedly, whomever has the higher fp wins the battle. Example -> !fp 100 Torpedo Launchers  " );
    }

    elsif ( /^![Ff][Pp].+$/ ) {
        if ( my ( $number, $unit ) = /^![Ff][Pp]\s+(\d+)\s(.+)$/ ) {
            if ( $number > 1000000 ) { $server->command("msg $target 1,000,000 max $nick"); return; }
            if ( $number =~ /^0/ ) { $server->command("msg $target Don't try to crash the bOt $nick"); return; }
            if ( my $object = ETDNukezoneData5->get_fp( $unit, $number ) ) {
                my ($handle) = keys %$object;
                my $temp = ETDNukezoneData5->get_regexes( $handle );
                my $objectcolor = ETDNukezoneData5->irc_color( $$temp{$handle}[17] );
                $number = commie($number);
                my $string = sprintf("Firepower of $number \003%02d$handle\003 -> %s", $$objectcolor, commie($$object{$handle}) );
                $server->command("msg $target $string");
                return;
            }
            else {
                $server->command("msg $target Syntax error. No such unit \"$unit\", $nick");
                return;
            }
        }
        else {
            $server->command("msg $target Syntax error. Type \"!fp\" without any parameters for help.");
            return;
        }
    }

    elsif ( /^![Mm][Pp]$/ ) {
        $server->command("msg $target !mp -> Returns the market price of given unit. Example -> !mp 100 T-2000 Hovercrafts " );
    }

    elsif ( /^![Mm][Pp] .+$/ ) {
        my $selection;
        unless ( ($selection) = /^![Mm][Pp] \d+ (.+)$/ ) { ; }
        my $amount;
        unless ( ($amount) = /^![Mm][Pp] (\d+) .+$/ ) { $server->command("msg $target syntax error. Type \"!mp\" without any paramaters for help $nick"); return; }
    if ( $amount > 1000000 ) { $server->command("msg $target 1,000,000 max $nick"); return; }
    if ( $amount =~ /^0/ ) { $server->command("msg $target Don't try to crash the bOt $nick"); return; }

    my $object = ETDNukezoneData5->get_m_p( $selection, $amount );
    if ( ! $object ) { $server->command("msg $target syntax error. No such unit \"$selection\" $nick"); return; }
    my ($handle) = keys %$object;
    my $temp = ETDNukezoneData5->get_regexes( $handle );
    my $objectcolor = ETDNukezoneData5->irc_color( $$temp{$handle}[17] );
    $amount = commie($amount);
    my $string = sprintf("Market price of $amount \003%02d$handle\003 -> \$%s \( 15%% -> \$%s \) \( 30%% -> \$%s \) \( 40%% -> \$%s\ )", $$objectcolor,
            commie( $$object{$handle} ), commie( int ($$object{$handle} * .85) ), commie( int ($$object{$handle} * .7) ), commie( int ($$object{$handle} * .6) ) );
    $server->command("msg $target $string");  
    }

    elsif ( /^![Mm][Dd]$/ ) {
        $server->command("msg $target !md -> Returns % of missile defense. Example -> !md 10000L 100A " );
        return 0;
    }

    elsif ( /^![Mm][Dd] .+$/ ) {
        my ($land, $AMS) = /^![Mm][Dd] (\d+)[Ll] (\d+)[Aa]$/;
        my $toggle = 0;
        unless ( ($AMS) && ($land) ) { $server->command("msg $nick syntax error. Type \"!md\" without any parameters for help."); return }
        if ( $AMS > 1000000 or $land > 1000000 ) { $server->command("msg $target 1,000,000 max $nick"); return; }
        if ( $AMS =~ /^0/ or $land =~ /^0/ ) { $server->command("msg $target Don't try to crash the bOt $nick"); return; }

            if ( $AMS > $land ) {
                $server->command("msg $target Impossible more Anti Missile Systems than land $nick. " );
                $toggle = 1;
            }
            if ( $land > $AMS ) {
                my $cland = commie($land); my $cams = commie($AMS);
                $server->command('msg '.$target.' '.sprintf("Missle defense of $cams \003%02dAnti Missile Systems\003 on $cland used land -> %%%.2f", 15, (( $AMS / $land ) * 6700 ) ) );
                $toggle = 1;
            }
            if ( $toggle == 0 ) {
                $server->command("msg $nick syntax error. Type \"!md\" without any parameters for help.");
            }
    }

    elsif ( /^![Ss][Tt][Aa][Tt][Ss]$/ ) {
    $server->command("msg $target !stats -> Returns some simple stats. Example -> !stats Heavy Artillery "  );
    }

    elsif ( /^![Ss][Tt][Aa][Tt][Ss] [Aa][Ll][Ll]$/ ) {
        my $string = sprintf("\003%02d%-24s\003 %6s %7s %6s %4s %7s %7s %-11s", "0", 'Unit', 'Cost', 'Att', 'C/A', 'Def', 'C/D ', 'C/(A+D)', 'Targets' );
        $server->command("msg $target $string");
            foreach (
    'Rocket Soldier', 'RAH-66 Comanche', 'M1 Abrams Tank', 'Destroyer',
    'Navy Seal', 'M270 MLRS Tank', 'F-22 Raptor', 'Armored Infantry', 'EF-2000 Typhoon',
    'F-35 JSF', 'Humvee', 'Submarine', 'Cruiser',
    'Grenade Soldier', 'SH-60 Sea Hawk', 'Sam Tank', 'Stealth Boat', 'Paratrooper', 'Battleship'
                ) {

                my $ship = ETDNukezoneData5->get_regexes( $_ );
                my ($handle) = keys %$ship;
                my $shipcolor = ETDNukezoneData5->irc_color( $$ship{$handle}[17] );

                my $string = sprintf("\003%02d%-24s\003 %6d %7d %6.2f %4d %6.2f %7.2f",
                $$shipcolor, $handle,
                $$ship{$handle}[0], $$ship{$handle}[1], $$ship{$handle}[0] / $$ship{$handle}[1], $$ship{$handle}[2],
                (( $$ship{$handle}[2] =~ /^0$/ ) ? 0 : $$ship{$handle}[0] / $$ship{$handle}[2]),
                $$ship{$handle}[0] / ( $$ship{$handle}[1] + $$ship{$handle}[2] )
                );

                $string .= get_targets( $$ship{$handle} );
                $server->command("msg $target $string");
            }
    }

    elsif ( /^![Ss][Tt][Aa][Tt][Ss] .+$/ ) {
        my ($arg) = /^![Ss][Tt][Aa][Tt][Ss] (.+)$/;
            my $ship = ETDNukezoneData5->get_regexes( $arg );
            if ( ! $ship ) { $server->command("msg $target syntax error. No such unit \"$arg\" $nick"); return; }
            my $string = sprintf("\003%02d%-24s\003 %6s %7s %6s %4s %7s %7s %-11s", "0", 'Unit', 'Cost', 'Att', 'C/A', 'Def', 'C/D ', 'C/(A+D)', 'Targets' );

            my ($handle) = keys %$ship;
            $server->command("msg $target $string");

            my $shipcolor = ETDNukezoneData5->irc_color( $$ship{$handle}[17] );
            my $string2 = sprintf("\003%02d%-24s\003 %6d %7d %6.2f %4d %6.2f %7.2f",
                    $$shipcolor, $handle,
                    $$ship{$handle}[0], $$ship{$handle}[1], $$ship{$handle}[0] / $$ship{$handle}[1], $$ship{$handle}[2],
                    (( $$ship{$handle}[2] =~ /^0$/ ) ? 0 : $$ship{$handle}[0] / $$ship{$handle}[2]),
                    $$ship{$handle}[0] / ( $$ship{$handle}[1] + $$ship{$handle}[2] )
                    );
            $string2 .= get_targets( $$ship{$handle} );
            $server->command("msg $target $string2");
    }

    elsif ( /^![Nn][Ww]$/ ) {
        $server->command("msg $target !nw -> Returns networth of units, buildings, research, walls, and land. Example -> !nw 666 Humvee");
        }

    elsif ( /^![Nn][Ww] .*$/ ) {
        my ($selection) = /^![Nn][Ww] (?:\d+)? (.+)$/;
        my $amount;
        unless ( ($amount) = /^![Nn][Ww] (\d+) .+$/ ) { $server->command("msg $target syntax error. Type \"!nw\" without any paramaters for help $nick"); return; }
        if ( $amount > 1000000 ) { $server->command("msg $target 1,000,000 max $nick"); return; }
        if ( $amount =~ /^0/ ) { $server->command("msg $target Don't try to crash the bOt $nick"); return; }


    my $object = ETDNukezoneData5->get_nw( $selection, $amount );
    if ( ! $object ) { $server->command("msg $target syntax error. No such unit \"$selection\" $nick"); return; }
    my ($handle) = keys %$object;

    my $temp = ETDNukezoneData5->get_regexes( $handle ) || '';
    my $objectcolor = ETDNukezoneData5->irc_color( $$temp{$handle}[17] );
    
    my $string = sprintf("Networth of %s \003%02d$handle\003 -> \$%s", commie($amount), $$objectcolor, commie($$object{$handle}) );
    $server->command("msg $target $string");
    }

    elsif ( /^![Pp][Oo][Ww][Ee][Rr]$/ ) {
        $server->command("msg $target !power -> Returns total of buildings power. Example -> !power 50 app");
        }

    elsif ( /^![Pp][Oo][Ww][Ee][Rr] .*$/ ) {
        my ($selection) = /^![Pp][Oo][Ww][Ee][Rr] (?:\d+) (.+)$/;
        my $amount;
        unless ( ($amount) = /^![Pp][Oo][Ww][Ee][Rr] (\d+) .+$/ ) { $server->command("msg $target syntax error. Type \"!power\" without any paramaters for help $nick"); return; }
        if ( $amount > 1000000 ) { $server->command("msg $target 1,000,000 max $nick"); return; }
        if ( $amount =~ /^0/ ) { $server->command("msg $target Don't try to crash the bOt $nick"); return; }

        my $object = ETDNukezoneData5->get_power( $selection, $amount );
        if ( ! $object ) { $server->command("msg $target syntax error. No such building \"$selection\" $nick"); return; }
        my ($handle) = keys %$object;
        my $temp = ETDNukezoneData5->get_regexes( $handle );
        my $objectcolor = ETDNukezoneData5->irc_color( $$temp{$handle}[17] );
        my $string = sprintf("Power %s of %s \003%02d$handle\003 -> %s", ( $$object{$handle} >= 0 ) ? 'generation' : 'consumption', commie($amount), $$objectcolor, commie($$object{$handle}) );
        $server->command("msg $target $string");
    }
    else { return; }
}

sub get_targets {
    my $retval = "  ";
    my $shipref = shift;
    if ($shipref->[3] == 1) { $retval .= sprintf("\003%02dS ", 2); }   else { $retval .= "  " }#sea
    if ($shipref->[4] == 1) { $retval .= sprintf("\003%02dA ", 7); }   else { $retval .= "  " }#air
    if ($shipref->[5] == 1) { $retval .= sprintf("\003%02dV ", 3); }   else { $retval .= "  " }#veh
    if ($shipref->[6] == 1) { $retval .= sprintf("\003%02dI ", 10); }  else { $retval .= "  " }#inf
    if ($shipref->[7] == 1) { $retval .= sprintf("\003%02dB ", 15); }  else { $retval .= "  " }#building
    return $retval;
}

sub commie {
    my $txt = reverse $_[0];
    $txt =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
    return scalar reverse $txt;
}

signal_add_last("message public", "public_query");
signal_add_last("message private", "private_query");

Download

Companion ← Perl Module. ( Not fit for browser rendering. )

   
Comments
May 12 2014
Comment #1 posted by Ion Nemerenco at 7:07 am

Ion Nemerenco
Unless you're a freegan and have found a way to live entirely off the grid, you probably need some sort of steady income in order to survive. The traditional way to earn money, of course, is by having a job. You work for a company or start your own, and the work you do earns you money, which you spend on things like a mortgage, rent, food, clothing, utilities and entertainment.
Most people typically work from their company's central location, a physical space where everyone from that organization gathers to exchange ideas and organize their efforts.
But a few lucky souls have found ways to make money within the comfort of their own home. With the Internet, an ever-changing arena for businesses, some people looking to earn money are finding ways to do so. Some forms are best for part-time endeavors for those looking to make a little extra money on the side, while others can lead to full-time jobs and Internet success stories.
Ion Nemerenco put together a list of our top 10 ways to make money on the Internet, in no particular order. On the next page, we'll start with an old favorite.

May 13 2014
Comment #2 posted by IonNemerenconyg at 6:05 am

Ion Nemerenco
Unless you're a freegan and have found a way to live entirely off the grid, you probably need some sort of steady income in order to survive. The traditional way to earn money, of course, is by having a job. You work for a company or start your own, and the work you do earns you money, which you spend on things like a mortgage, rent, food, clothing, utilities and entertainment.
Most people typically work from their company's central location, a physical space where everyone from that organization gathers to exchange ideas and organize their efforts.
But a few lucky souls have found ways to make money within the comfort of their own home. With the Internet, an ever-changing arena for businesses, some people looking to earn money are finding ways to do so. Some forms are best for part-time endeavors for those looking to make a little extra money on the side, while others can lead to full-time jobs and Internet success stories.
Ion Nemerenco put together a list of our top 10 ways to make money on the Internet, in no particular order. On the next page, we'll start with an old favorite.

May 15 2014
Comment #3 posted by Ion-Nemerenco at 6:08 pm

Ion Nemerenco
Unless you're a freegan and have found a way to live entirely off the grid, you probably need some sort of steady income in order to survive. The traditional way to earn money, of course, is by having a job. You work for a company or start your own, and the work you do earns you money, which you spend on things like a mortgage, rent, food, clothing, utilities and entertainment.
Most people typically work from their company's central location, a physical space where everyone from that organization gathers to exchange ideas and organize their efforts.
But a few lucky souls have found ways to make money within the comfort of their own home. With the Internet, an ever-changing arena for businesses, some people looking to earn money are finding ways to do so. Some forms are best for part-time endeavors for those looking to make a little extra money on the side, while others can lead to full-time jobs and Internet success stories.
Ion Nemerenco put together a list of our top 10 ways to make money on the Internet, in no particular order. On the next page, we'll start with an old favorite.

May 19 2014
Comment #4 posted by zasagbrv at 11:41 am

West (cigarette) – wikipedia, the free encyclopedia

May 22 2014
Comment #6 posted by gurmaqbz at 5:43 am

Marlboro black nxt regular cigarettes – reviews for marlboro cigarettes online

May 23 2014
Comment #7 posted by waqwejvq at 5:12 am

Marlboro man – wikipedia, the free encyclopedia

Jul 9 2014
Comment #8 posted by ratedllg at 6:12 pm

Coupons for basic brand cigarettes

Jul 24 2014
Comment #10 posted by polikhym at 9:34 am

Discount cigarettes – wilson, nc – tobacco store

Jun 9 2015
Comment #11 posted by hdpuffsotd at 2:56 am

hdpuffs.net
Battery-powered e-cigarettes were initially revered as a healthier alternative and method of therapy to help the addicted quit smoking, but according to research presented at this year's American Thoracic Society International Conference, there is little evidence these devices are effective in helping people quit nicotine for good. Even worse, many young people who were educated about the deadliness of a cigarette habit have started vaping since it's been deemed a "healthier" option, and the numbers of new users are staggering. According to the CDC, e-cigarette use among middle school students tripled between 2013 and 2014. hdpuffs.net

Comments for this entry available via RSS.
Comment Area
Your Name
Your Email (will not be published)
Your Website
Your Comment
Profanity is Prohibited
eric.dziewa.com is running WordPress.
WhiteSpace theme designed by E. Dziewa.
All content © E. Dziewa.
Thanks for stopping by.