ra84

srwb

Apr 3rd, 2018
3,477
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 31.26 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use IO::Socket;
  4.  
  5. $server = "irc.euirc.net";
  6. $port = 6666;
  7. @owners = ("ra","Madison",);
  8. $nick = "sr_dice";
  9. $verbose = 1;
  10. $version = "0.73a"; #24.11.2012
  11. $m = 50;
  12. $ident= 0;
  13. $to = 600000;
  14. $sortdice = 0;
  15. $sys = 0;
  16. $shortdes = 0;
  17. $join = 0;
  18. $pings = 0;
  19.  
  20. $partmsg = "Bye chummers!\n";
  21. $welcomemsg = "Hoi chummers!\n";
  22.  
  23. $config = "./srwb.cnf";
  24.  
  25. open(TMP,$config) || print "Kann Configfile $config nicht lesen : $!\n";
  26. @cfile = <TMP>;
  27. close ($TMP);
  28. chomp(@cfile);
  29.  
  30. for ($i=0; $i < @cfile; $i++) {
  31.     @cline = split(/\ /,$cfile[$i]);
  32.     if ($cline[0] eq "server") {
  33.         $server=$cline[1];
  34.     }
  35.     if ($cline[0] eq "port") {
  36.         $port=$cline[1];
  37.     }
  38.     if ($cline[0] eq "nick") {
  39.         $nick=$cline[1];
  40.     }
  41.     if ($cline[0] eq "verbose") {
  42.         $v=$cline[1];
  43.     }
  44.     if ($cline[0] eq "max") {
  45.         $m=$cline[1];
  46.     }
  47.     if ($cline[0] eq "sortdice") {
  48.         $sortdice=$cline[1];
  49.     }
  50.     if ($cline[0] eq "welcomemsg") {
  51.         $welcomemsg = "";
  52.         for ($a=1;$a < @cline;$a++) {
  53.             $welcomemsg .= $cline[$a] . " ";
  54.         }
  55.     }
  56.     if ($cline[0] eq "partmsg") {
  57.         $partmsg = "";
  58.         for ($a=1;$a < @cline;$a++) {
  59.             $partmsg .= $cline[$a] . " ";
  60.         }
  61.     }
  62.  
  63.     if ($cline[0] eq "owners") {
  64.         @owners=$cline[1];
  65.         for ($a=2;$a < @cline;$a++) {
  66.             push (@owners,$cline[$a]);
  67.         }
  68.     }
  69.     if ($cline[0] eq "system") {
  70.         $sys=$cline[1];
  71.     }
  72.     if ($cline[0] eq "shortdes") {
  73.         $shortdes=$cline[1];
  74.     }
  75.     if ($cline[0] eq "join") {
  76.         $join=$cline[1];
  77.     }
  78. }
  79.  
  80.  
  81.  
  82. for ($i=0;$i < @ARGV; $i++) {
  83.     if ($ARGV[$i] eq "h") {
  84.         print "\n";
  85.         print "s <server>\n";
  86.         print "p <port>\n";
  87.         print "o <owner>\n";
  88.         print "n <nick>\n";
  89.         print "q quite\n";
  90.         print "m <maxdice>\n";
  91.         print "j <channel>\n";
  92.         print "i <identify>\n";
  93.         print "sys <system>\n";
  94.         exit;
  95.     }
  96.     if ($ARGV[$i] eq "j") {
  97.         $join = $ARGV[$i+1];
  98.     }
  99.     if ($ARGV[$i] eq "s") {
  100.         $server = $ARGV[$i+1];
  101.     }
  102.     if ($ARGV[$i] eq "i") {
  103.         $ident = $ARGV[$i+1];
  104.     }
  105.     if ($ARGV[$i] eq "p") {
  106.         $port = $ARGV[$i+1];
  107.     }
  108.     if ($ARGV[$i] eq "c") {
  109.         $channel = $ARGV[$i+1];
  110.     }
  111.     if ($ARGV[$i] eq "n") {
  112.         $nick = $ARGV[$i+1];
  113.     }
  114.     if ($ARGV[$i] eq "m") {
  115.         $m = $ARGV[$i+1];
  116.     }
  117.     if ($ARGV[$i] eq "sys") {
  118.         $sys = $ARGV[$i+1];
  119.     }
  120.     if ($ARGV[$i] eq "q") {
  121.         $v = 0;
  122.     }
  123. }
  124.  
  125. $lastping = time();
  126.  
  127. print "Server : $server Port : $port Nick : $nick \nVerbinde...";
  128. my $sock = new IO::Socket::INET (
  129.     PeerAddr => $server,
  130.     PeerPort => $port,
  131.     Proto => 'tcp',
  132. ); die "Kann keinen Socket erstellen: $!\n" unless $sock;
  133. $sock->autoflush;
  134.  
  135. print "Verbunden\n";
  136. print $sock "USER $nick localhost $server $nick\n";
  137. print "--> USER $nick localhost $server $nick\n";
  138. print $sock "NICK $nick\n";
  139. print "--> NICK $nick\n";
  140.  
  141. while (1) {
  142.  
  143.     if (($ident ne 0) && ($pings > 0)) {
  144.         print $sock "PRIVMSG Nickserv :identify $ident\n";
  145.         print "--> PRIVMSG Nickserv :identify $ident\n";
  146.         $ident = 0;
  147.     }
  148.  
  149.     if (($join ne 0) && ($pings > 0)) {
  150.         print $sock "JOIN $join \n";
  151.         print "--> Joining $join \n";
  152.         print $sock "PRIVMSG $join :$welcomemsg\n";
  153.         $join = 0;
  154.     }
  155.  
  156.     $line = <$sock>;
  157.  
  158.     if (($v ne 0) && ($line ne "")) { print "<-- $line"; }
  159.     if ($line =~ /$nick :Nickname is already in use./) {
  160.         print "Nick schon vergeben\n";
  161.         exit;
  162.     }
  163.     if ($line =~ /PING/) {
  164.         $pings++;
  165.         $line =~ s/PING/PONG/g;
  166.         $lastping = time();
  167.         print $sock $line;
  168.         print "--> $line";
  169.     } else {
  170.         if ($line =~ /PRIVMSG $nick/) {
  171.             $type = 1;
  172.             @tmp = split(/!/,$line);
  173.             $sender = $tmp[0];
  174.             $sender =~ s/\://g;
  175.             @tmp = split(/:/,$line);
  176.             $msg = $tmp[2];
  177.             for ($a=3;$a < @tmp; $a++) {
  178.                 $msg .= ":". $tmp[$a];
  179.             }
  180.             &check_adm;
  181.             if ($msg =~ "SHOWVERSION") {
  182.                 print $sock "PRIVMSG $sender :Lloyd - SR Wuerfelbot $version by Robert Altschaffel - owner : @owners\n";
  183.             }
  184.             if ($adm eq 0) {
  185.                 print "<$sender> $msg";
  186.                 $channel = $sender;
  187.                 &chk_dice;
  188.             } else {
  189.                 print "+$sender+ $msg";
  190.                 &admin;
  191.             }
  192.         } else {
  193.             if ($line =~ /PRIVMSG/) {
  194.                 $type = 2;
  195.                 @tmp = split(/!/,$line);
  196.                 $sender = $tmp[0];
  197.                 $sender =~ s/\://g;
  198.                 @tmp = split(/:/,$line);
  199.                 $msg = $tmp[2];
  200.                 for ($a=3;$a < @tmp; $a++) {
  201.                     $msg .= ":". $tmp[$a];
  202.                 }
  203.                 @tmp = split(/\ /,$line);
  204.                 $channel = $tmp[2];
  205.                 print "<$sender : $channel> $msg";
  206.                 if ($msg eq "help\n") {$channel=$sender; &dice_help;}
  207.                 &chk_dice;
  208.             }
  209.         }
  210.     }
  211. }
  212.  
  213. sub chk_dice {
  214.     #System 0   - Standart Dx ohne weiterwuerfeln
  215.     #System 1   - Standart Dx mit weiterwuerfeln
  216.     #System 2   - Mechwarrior
  217.  
  218.     #mode 0     - unset
  219.     #mode 1     - offener Wurf
  220.     #mode 2     - Wurf mit MW  
  221.     #mode 3     - MW Wurf (MW?)
  222.     #mode 4     - festen Wert addieren (?)
  223.     #mode 5     - festen Wert auf alle addieren (MW?)
  224.     #mode 6     - MW Wurf - Schadenslokalisation, toadd : 0 - Front, 1 - Left, 2 - Right
  225.     #mode 7     - MW Wurf - Cluster Hit Table, toadd : 0 - Front, 1 - Left, 2 - Right, 3 - kein Schaden
  226.     #mode 8     - MW Wurf - Schadenslokalisation Punch, toadd : 0 - Front, 1 - Left, 2 - Right
  227.     #mode 9     - MW Wurf - Schadenslokalisation Kick, toadd : 0 - Front, 1 - Left, 2 - Right
  228.     #mode 10    - Abenteueridee
  229.     #mode 11    - Karte ziehen
  230.    
  231. #   if($msg =~ /^[0-9]+[wW][0-9mflrcpkat][flrd]*[0-9+* ]*$/) {
  232.     if($msg =~ /^[0-9]*[.]*[0-9]+[wW][0-9mflrcpkat][flrd]*[0-9+* ]*$/) {
  233.  
  234.         $msg =~ s/D/W/g;
  235.         $msg =~ s/W/w/g;
  236.         $msg =~ s/d/w/g;
  237.         chomp($msg);
  238.  
  239.         @tmp=split(/w/,$msg);
  240.         $dices = $tmp[0];
  241.         $modeline = $tmp[1];
  242.         chomp($modeline);
  243.  
  244.         $toadd = 0;
  245.         $tomult = 0;
  246.         $mw = 0;
  247.         $mode = 0;
  248.         $sides = 0;
  249.    
  250.         if ($modeline =~ /\+/) {
  251.             $mode = 4;
  252.             @linex=split(/\+/,$modeline);
  253.             $toadd = $linex[1];
  254.             $sides = $linex[0];
  255.             @linex=split(/\ /,$toadd);
  256.             $toadd = $linex[0];
  257.             if ($sides == "t") { $sides = 10; $tomult=10;}     
  258.         }
  259.  
  260.         if ($modeline =~ /\*/) {
  261.             $mode = 5;
  262.             @linex=split(/\*/,$modeline);
  263.             $tomult = $linex[1];
  264.             $sides = $linex[0];
  265.         }
  266.  
  267.         @linex=split(/\ /,$modeline);
  268.  
  269.         if ($sides == 0) {
  270.             $sides = $linex[0];
  271.         }
  272.  
  273.         if ($mode == 4 || $mode == 5) {
  274.             if ($linex[1] == "") {
  275.                 $mw = 0;
  276.             } else {
  277.                 $mw = $linex[1];
  278.             }
  279.         }
  280.  
  281.         if ($linex[0] eq "m") {
  282.             $mode = 3;
  283.             $sides = 6;
  284.             if ($linex[1] == "") {
  285.                 $mw = 0;
  286.             } else {
  287.                 $mw = $linex[1];
  288.             }
  289.         }
  290.  
  291.         if ($linex[0] eq "a") {
  292.             $mode = 10;
  293.             $sides = 6;
  294.             if ($linex[1] == "") {
  295.                 $mw = 0;
  296.             } else {
  297.                 $mw = $linex[1];
  298.             }
  299.         }
  300.  
  301.         if ($linex[0] eq "k") {
  302.             $mode = 11;
  303.             $sides = 6;
  304.         }
  305.  
  306.         if ($linex[0] eq "td") {
  307.             $mode = 11;
  308.             $sides = 6;
  309.         }
  310.  
  311.         if ($linex[0] eq "f") {
  312.             $toadd = 0;
  313.             $mode = 6;
  314.             $sides = 6;
  315.         }
  316.  
  317.         if ($linex[0] eq "l") {
  318.             $toadd = 1;
  319.             $mode = 6;
  320.             $sides = 6;
  321.         }
  322.  
  323.         if ($linex[0] eq "r") {
  324.             $toadd = 2;
  325.             $mode = 6;
  326.             $sides = 6;
  327.         }
  328.  
  329.         if ($linex[0] eq "c") {
  330.             $mode = 7;
  331.             $sides = 6;
  332.             $mw = $linex[1];
  333.             $toadd = 3;
  334.         }
  335.  
  336.         if ($linex[0] eq "cf") {
  337.             $mode = 7;
  338.             $sides = 6;
  339.             $mw = $linex[1];
  340.             $toadd = 0;
  341.         }
  342.  
  343.         if ($linex[0] eq "cl") {
  344.             $mode = 7;
  345.             $sides = 6;
  346.             $mw = $linex[1];
  347.             $toadd = 1;
  348.         }
  349.  
  350.         if ($linex[0] eq "cr") {
  351.             $mode = 7;
  352.             $sides = 6;
  353.             $mw = $linex[1];
  354.             $toadd = 2;
  355.         }
  356.  
  357.         if ($linex[0] eq "pf") {
  358.             $mode = 8;
  359.             $sides = 6;
  360.             $mw = $linex[1];
  361.             $toadd = 0;
  362.         }
  363.  
  364.         if ($linex[0] eq "pl") {
  365.             $mode = 8;
  366.             $sides = 6;
  367.             $mw = $linex[1];
  368.             $toadd = 1;
  369.         }
  370.  
  371.         if ($linex[0] eq "pr") {
  372.             $mode = 8;
  373.             $sides = 6;
  374.             $mw = $linex[1];
  375.             $toadd = 2;
  376.         }
  377.  
  378.         if ($linex[0] eq "kf") {
  379.             $mode = 9;
  380.             $sides = 6;
  381.             $mw = $linex[1];
  382.             $toadd = 0;
  383.         }
  384.  
  385.         if ($linex[0] eq "kl") {
  386.             $mode = 9;
  387.             $sides = 6;
  388.             $mw = $linex[1];
  389.             $toadd = 1;
  390.         }
  391.  
  392.         if ($linex[0] eq "kr") {
  393.             $mode = 9;
  394.             $sides = 6;
  395.             $mw = $linex[1];
  396.             $toadd = 2;
  397.         }
  398.         if ($mode == 0) {
  399.             if ($linex[1] == "") {
  400.                 $mode = 1;
  401.             } else {
  402.                 $mw = $linex[1];
  403.                 $mode = 2;
  404.             }
  405.         }
  406.  
  407.                 if ($sides < 2) {
  408.                         $sides = 2;
  409.                 }
  410.  
  411.         print "mode : $mode, dices : $dices, sides : $sides, mw : $mw, toadd : $toadd, tomult : $tomult, modeline : $modeline\n";
  412.  
  413.  
  414.         if ($mode == 1) {
  415.             if ($dices > $m) { $dices = $m;}
  416.             @diceres = ();
  417.             for ($i = 0; $i < $dices; $i++) {
  418.                 $td = int(rand($sides)+1);
  419.                 push (@diceres,$td);
  420.             }
  421.             $out = "PRIVMSG $channel :Werfe $dices\W$sides fuer $sender : [ @diceres ]\n";
  422.             print $sock $out;
  423.         }
  424.  
  425.         if ($mode == 2) {
  426.             if ($dices > $m) { $dices = $m;}
  427.             @diceres = ();
  428.             $suc = 0;
  429.             for ($i = 0; $i < $dices; $i++) {
  430.                 $td = 0;
  431.                 while ($td % $sides eq 0) {
  432.                     $td += int(rand($sides)+1);
  433.                 }
  434.                 if ($td >= $mw) {$suc++; }
  435.                 push (@diceres,$td);
  436.             }
  437.             if ($suc == 1) {
  438.                 $out = "PRIVMSG $channel :Werfe $dices\W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolg\n";
  439.             } else {
  440.                 $out = "PRIVMSG $channel :Werfe $dices\W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolge\n";
  441.             }
  442.             print $sock $out;
  443.         }
  444.  
  445.         if ($mode == 3) {
  446.             if ($mw > 0) { $suc = 0;}
  447.             if ($dices > $m) { $dices = $m;}
  448.             @diceres = ();
  449.             for ($i = 0; $i < $dices; $i++) {
  450.                 $td = int(rand($sides)+1) + int(rand($sides)+1);
  451.                 if ($td >= $mw) {$suc++;}
  452.                 push (@diceres,$td);
  453.             }
  454.             if ($mw > 0) {
  455.                 if ($suc == 1) {
  456.                     $out = "PRIVMSG $channel :Werfe $dices\*2W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolg \n";
  457.                 } else {
  458.                     $out = "PRIVMSG $channel :Werfe $dices\*2W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolge \n";
  459.                 }
  460.             } else {
  461.                 $out = "PRIVMSG $channel :Werfe $dices\*2W$sides fuer $sender : [ @diceres ]\n";
  462.             }
  463.             print $sock $out;
  464.         }
  465.  
  466.         if ($mode == 4) {
  467.             if ($dices > $m) { $dices = $m;}
  468.             if ($dices =~ /\./) {
  469.                 @linex=split(/\./,$dices);
  470.                 $dices = $linex[1];
  471.                 $tmp = $linex[0];
  472.                 # print "dices $dices | tmp $tmp \n";
  473.                 if ($dices < 1) {$dices = 1;}
  474.                 if ($tmp < 1) {$tmp = 1;}
  475.                 if ($mw > 0) {$suc = 0;}
  476.                 # print "dices $dices | tmp $tmp \n";
  477.                 if ($tomult == 10) {$dices++};
  478.                 $dicestr = "";
  479.                 $resstr = "[";
  480.                 @diceres = ();
  481.                 for ($j = 0; $j < $tmp; $j++) {
  482.                     $ressum = 0;
  483.                     for ($i = 0; $i < $dices; $i++) {
  484.                         $td = int(rand($sides)+1);
  485.                         push (@diceres,$td);
  486.                         $ressum = $ressum + $td;
  487.                     }
  488.                     $ressum = $ressum + $toadd;
  489.                     if ($tomult == 10) {
  490.                         my $min = (sort { $a <=> $b } @diceres)[0];
  491.                         $ressum -= $min;
  492.                     }
  493.                     if ($ressum >= $mw) {$suc++};
  494.                     $dicestr = $dicestr."[ @diceres ] ";
  495.                     $resstr .= " $ressum";
  496.                     undef @diceres;
  497.                 }
  498.                 $resstr .= " ]";
  499.                 if ($tomult == 10) { $dices .= "T"; }
  500.                 if ($mw > 0) { 
  501.                     if ($dices == 1) {
  502.                         if ($suc == 1) {
  503.                             $out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $resstr => $suc Erfolg \n";
  504.                         } else {
  505.                             $out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $resstr => $suc Erfolge \n";
  506.                         }                  
  507.                     } else {
  508.                         if ($suc == 1) {
  509.                             $out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $dicestr => $resstr => $suc Erfolg \n";
  510.                         } else {
  511.                             $out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $dicestr => $resstr => $suc Erfolge \n";
  512.                         }  
  513.                     }
  514.                 } else {   
  515.                     if ($dices == 1) { 
  516.                         $out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd fuer $sender : $resstr \n";                  
  517.                     } else {   
  518.                         $out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd fuer $sender : $dicestr => $resstr \n";
  519.                     }
  520.                 }      
  521.             } else {
  522.                 if ($tomult == 10) {$dices++};
  523.                 @diceres = ();
  524.                 $ressum = 0;
  525.                 for ($i = 0; $i < $dices; $i++) {
  526.                     $td = int(rand($sides)+1);
  527.                     push (@diceres,$td);
  528.                     $ressum = $ressum + $td;
  529.                 }
  530.                 $ressum = $ressum + $toadd;
  531.                 if ($tomult == 10) {
  532.                     my $min = (sort { $a <=> $b } @diceres)[0];
  533.                     $ressum -= $min;
  534.                     $dices .= "T";
  535.                 }
  536.                 $out = "PRIVMSG $channel :Werfe $dices\W$sides\+$toadd fuer $sender : [ @diceres ] => $ressum\n";
  537.             }
  538.             print $sock $out;
  539.         }
  540.  
  541.         if ($mode == 5) {
  542.             if ($mw > 0) {$suc = 0;}
  543.             if ($dices > $m) { $dices = $m;}
  544.             @diceres = ();
  545.             for ($i = 0; $i < $dices; $i++) {
  546.                 $td = int(rand($sides)+1);
  547.                 $td += $tomult;
  548.                 if ($td >= $mw) {$suc++;}
  549.                 push (@diceres,$td);
  550.             }
  551.             if ($mw > 0) {
  552.                 if ($suc == 1) {
  553.                     $out = "PRIVMSG $channel :Werfe $dices\W$sides\+$tomult gegen $mw fuer $sender : [ @diceres ] => $suc Erfolg \n";
  554.                 } else {
  555.                     $out = "PRIVMSG $channel :Werfe $dices\W$sides\+$tomult gegen $mw fuer $sender : [ @diceres ] => $suc Erfolge \n";
  556.                 }
  557.             } else {
  558.                 $out = "PRIVMSG $channel :Werfe $dices\W$sides\+$tomult fuer $sender : [ @diceres ]\n";
  559.             }  
  560.             print $sock $out;
  561.         }
  562.  
  563.         if ($mode == 6) {
  564.             if ($dices > $m) { $dices = $m;}
  565.             @diceres = ();
  566.             for ($i = 0; $i < $dices; $i++) {
  567.                 $td = int(rand($sides)+1) + int(rand($sides)+1);
  568.                 push (@diceres,$td);
  569.             }
  570.             $dmgfrom = $toadd;
  571.             $dirname = &give_direction();
  572.  
  573.             $out = "PRIVMSG $channel :Werfe $dices Trefferzonen von $dirname fuer $sender : [ @diceres ]\n";
  574.             print $sock $out;
  575.             $intcnt = 0;
  576.             $out = "PRIVMSG $channel :";
  577.             foreach (@diceres) {
  578.                 $location = $_;
  579.                 $zone = &give_location();
  580.                 $out .= "[ $location ] => $zone ";
  581.                 $intcnt++;
  582.                 if ($intcnt == 5) {
  583.                     $out .= "\n";
  584.                     print $sock $out;
  585.                     $intcnt = 0;
  586.                     $out = "PRIVMSG $channel :";
  587.                 }
  588.             }
  589.             $out .= "\n";
  590.             print $sock $out;
  591.         }
  592.  
  593.         if ($mode == 7) {
  594.             if ($dices > $m) { $dices = $m;}
  595.             @diceres = ();
  596.             for ($i = 0; $i < $dices; $i++) {
  597.                 $td = int(rand($sides)+1) + int(rand($sides)+1);
  598.                 push (@diceres,$td);
  599.             }
  600.             $out = "PRIVMSG $channel :Werfe $dices Trefferzahlen fuer $sender : [ @diceres ]\n";
  601.             print $sock $out;
  602.             if ($toadd == 3) {
  603.                 $intcnt = 0;
  604.                 $out = "PRIVMSG $channel :";
  605.                 foreach (@diceres) {
  606.                     $clusterhit = $_;
  607.                     $clustersize = $mw;
  608.                     $clusterdamage = &get_cluster();
  609.                     $out .= "[ $clusterhit ] => $clusterdamage ";
  610.                     $intcnt++;
  611.                     if ($intcnt == 5) {
  612.                         $out .= "\n";
  613.                         print $sock $out;
  614.                         $intcnt = 0;
  615.                         $out = "PRIVMSG $channel :";
  616.                     }
  617.                 }
  618.                 if ($intcnt != 0) {
  619.                     $out .= "\n";
  620.                     print $sock $out;
  621.                 }
  622.             } else {
  623.                 $dmgfrom = $toadd;
  624.                 $clusttype = 0;
  625.                 $weapname = "unbekannt";
  626.                 $clustersize = $mw;
  627.                 if ((($clustersize == 2) || ($clustersize == 4)) || ($clustersize == 6)) {
  628.                     $clusttype = 1;
  629.                     $weapname = "SRM";
  630.                 };
  631.                 if (((($clustersize == 5) || ($clustersize == 10)) || ($clustersize == 15)) || ($clustersize == 20)) {
  632.                     $clusttype = 2;
  633.                     $weapname = "LRM";
  634.                 }
  635.                 $dirname = &give_direction();
  636.  
  637.                 foreach(@diceres) {
  638.                     $clusterhit = $_;
  639.                     $clusterdamage = &get_cluster();
  640.                     $out = "PRIVMSG $channel :Schadenszone fuer $weapname $clustersize von $dirname - $clusterdamage Treffer\n";
  641.                     print $sock $out;
  642.                     if ($clusttype == 0) {
  643.                         $out = "PRIVMSG $channel :";
  644.                         for ($i = 0; $i < $clusterdamage; $i++) {
  645.                             $location = int(rand($sides)+1) + int(rand($sides)+1);
  646.                             $zone = &give_location();
  647.                             $out .= "[ $location ] => 1 an $zone ";
  648.                         }
  649.                     }
  650.                     if ($clusttype == 1) {
  651.                         $out = "PRIVMSG $channel :";
  652.                         for ($i = 0; $i < $clusterdamage; $i++) {
  653.                             $location = int(rand($sides)+1) + int(rand($sides)+1);
  654.                             $zone = &give_location();
  655.                             $out .= "[ $location ] => 2 an $zone ";
  656.                         }
  657.                     }
  658.                     if ($clusttype == 2) {
  659.                         $out = "PRIVMSG $channel :";
  660.                         while ($clusterdamage > 0) {
  661.                             $location = int(rand($sides)+1) + int(rand($sides)+1);
  662.                             $zone = &give_location();
  663.                             if ($clusterdamage >= 5) {
  664.                                 $clusterdamage -= 5;
  665.                                 $donedam = 5;
  666.                             } else {
  667.                                 $donedam = $clusterdamage;
  668.                                 $clusterdamage = 0;
  669.                             }
  670.                             $out .= "[ $location ] => $donedam an $zone ";
  671.                         }
  672.                     }
  673.                     $out .= "\n";
  674.                     print $sock $out;
  675.                 }
  676.             }
  677.         }
  678.  
  679.         if ($mode == 8) {
  680.             if ($dices > $m) { $dices = $m;}
  681.             @diceres = ();
  682.             for ($i = 0; $i < $dices; $i++) {
  683.                 $td = int(rand($sides)+1);
  684.                 push (@diceres,$td);
  685.             }
  686.             $dmgfrom = $toadd;
  687.             $dirname = &give_direction();
  688.  
  689.             $out = "PRIVMSG $channel :Werfe $dices Trefferzonen (Punch) von $dirname fuer $sender : [ @diceres ]\n";
  690.             print $sock $out;
  691.             $intcnt = 0;
  692.             $out = "PRIVMSG $channel :";
  693.             foreach (@diceres) {
  694.                 $location = $_;
  695.                 $zone = &give_punchlocation();
  696.                 $out .= "[ $location ] => $zone ";
  697.                 $intcnt++;
  698.                 if ($intcnt == 5) {
  699.                     $out .= "\n";
  700.                     print $sock $out;
  701.                     $intcnt = 0;
  702.                     $out = "PRIVMSG $channel :";
  703.                 }
  704.             }
  705.             $out .= "\n";
  706.             print $sock $out;
  707.         }
  708.  
  709.         if ($mode == 9) {
  710.             if ($dices > $m) { $dices = $m;}
  711.             @diceres = ();
  712.             for ($i = 0; $i < $dices; $i++) {
  713.                 $td = int(rand($sides)+1);
  714.                 push (@diceres,$td);
  715.             }
  716.             $dmgfrom = $toadd;
  717.             $dirname = &give_direction();
  718.  
  719.             $out = "PRIVMSG $channel :Werfe $dices Trefferzonen (Kick) von $dirname fuer $sender : [ @diceres ]\n";
  720.             print $sock $out;
  721.             $intcnt = 0;
  722.             $out = "PRIVMSG $channel :";
  723.             foreach (@diceres) {
  724.                 $location = $_;
  725.                 $zone = &give_kicklocation();
  726.                 $out .= "[ $location ] => $zone ";
  727.                 $intcnt++;
  728.                 if ($intcnt == 5) {
  729.                     $out .= "\n";
  730.                     print $sock $out;
  731.                     $intcnt = 0;
  732.                     $out = "PRIVMSG $channel :";
  733.                 }
  734.             }
  735.             $out .= "\n";
  736.             print $sock $out;
  737.         }
  738.  
  739.         if ($mode == 10) {
  740.             $sysset = 0;
  741.             if ($dices > $m) { $dices = $m;}
  742.             if ($mw == 1) {
  743.                 $sysset = 1;
  744.                 $sys = "DSA";
  745.                 @things=("Drachen","Meuchelmord","Gift","Untote","Horasier","Vinsalt","Elementargeister","Kristalle","Edelsteine","Schaetze","Graeber","Thorwaler","Novadi","Amazonen","Niederbrennendes Dorf","Der hohe Norden","Sommer","Schwert","Verfluchter Gegenstand","Blutige Rituale","Magier","Illusionen","Hexen","Druiden","Gareth","Festum","Winter","Artefakt","Verfluchtes Artefakt","Soeldner","Orks","Elfen","Zwerge","Ritter","Andergast","Weiden","Goblins","Gold","Silber","Geister","Daemonen","Barbaren","Berge","Wasser","Kampfmagier","Druiden","Sümpfe","Urwald","Echsen","Al Anfa","Bauern","Woelfe","Verliesse","Gruftasseln","Mindorium","Punin","Der tiefe Sueden","Turnier", "Schwarzer Ritter","Bergwerk");
  746.             }
  747.             if ($mw == 2) {
  748.                 $sysset = 1;
  749.                 $sys = "DH";
  750.                 @things=("Ganger","Makropolen","Radikale Irre","Tau","Eldar","Dark Eldar","Orks","Ecclesiarchy","Adeptus Mechanicus","Hereteks","Adeptus Astartes","Imperiale Armee","Imperiale Flotte","Bergwerk","Handelsstation","Freihaendler","Minenstation","Mond","Schmiedewelt","Makropolwelt","Feudalwelt","Todeswelt","Artefakt","Daemonen","Xenos","Mutanten","Kultisten","Redemptionisten","Soeldnergilde","Kopfgeldjaeger","Tzeentch","Khorne","Nurgle","Slaanesh","Adlige","Verwuestete Siedlung","Space Hulk","Piraten","Monodominate","Logiker","Dschungelwelt");
  751.             }
  752.             if ($mw == 3) {
  753.                 $sysset = 1;
  754.                 $sys = "SR";       
  755.                 @things=("Orks","Trolle","Elfen","Norms","Zwerge","Ganger","Redmond Barrens","Downtown","Renton","Tacoma","Einbruch","Konzernexec","Wissenschaftler","Taliskraemer","Ares","Aztech","Saeder-Krupp", "Extraktion", "Verrat", "Critter", "Mitsuhama", "Kurier", "Fernsehen", "Drogen", "Rassisten", "Lone Star", "DocWagon", "Konkurrenz", "toter Johnson", "Geheimdienst", "Regierung", "Zufallsereignis Magie", "GoGang", "Schreckhahn", "Militär", "Mafia", "Yakuza", "Tong", "Rotlicht", "Bestrafung", "Fischhalle","Vory y Zakone","Yamatetsu","Renraku", "Wuxing","Elfenstaat", "Versicherungsbetrug","Wetwork", "Bauernopfer","Hoellenhund","Portland","Chicago","Renrakru","Knight Errant","Hard Corps","Wolverine Security","Buechsenmacher","Schmuggler","Snohomish","Auburn","Pullyalup","Everett");
  756.             }
  757.             if ($mw == 99) {
  758.                 $sysset = 1;
  759.                 $sys = "System";       
  760.                 @things=("SR3","SR4","D&D","DW","DH","DSA","Etwas seltsames aus Bernd's Schrank");
  761.             }  
  762.             if ($sysset == 0) {
  763.                 $sys = "Generisch";
  764.                 @things=("Graeber","Verfluchter Gegenstand","Gift","Meuchelmord","Geister","Soeldner","Verwuestete Siedlung","Grossstadt");
  765.             }          
  766.             $out = "PRIVMSG $channel :Werfe $dices Ideen ($sys) fuer $sender : \n";
  767.             print $sock $out;      
  768.            
  769.             for ($i = 0; $i < $dices; $i++) {          
  770.                 $td = int(rand(@things));
  771.                 $what = $things[$td];
  772.                 $out = "PRIVMSG $channel :$what\n";
  773.                 print $sock $out;
  774.             }
  775.         }
  776.        
  777.         if ($mode == 11) {
  778.             if ($dices > $m) { $dices = $m;}
  779.             for ($i = 0; $i < $dices; $i++) {
  780.  
  781.                 @things=("Herz","Pik","Karo","Kreuz");
  782.                 $td = int(rand(@things));
  783.                 $what = $things[$td];
  784.  
  785.                 @things=("Ass", "Zehn","König","Dame","Bube","Neun","Acht","Sieben");
  786.                 $td = int(rand(@things));
  787.                 $what .= " ". $things[$td];
  788.  
  789.                 $out = "PRIVMSG $channel :$what\n";
  790.                 print $sock $out;
  791.             }
  792.         }
  793.     }
  794. }
  795.  
  796. sub check_adm {
  797.     $adm = 0;
  798.     for ($i = 0; $i < @owners; $i++)  {
  799.         if ($owners[$i] eq $sender) {
  800.             $adm = 1;
  801.         }
  802.     }
  803. }
  804.  
  805. sub dice_help {
  806.     print $sock "PRIVMSG $channel :Wuerfel :\n";
  807.     print $sock "PRIVMSG $channel :4w6 - Werfe 4w6\n";
  808.     print $sock "PRIVMSG $channel :2w6 10 - Werfe 2w6 gegen 10\n";
  809.     print $sock "PRIVMSG $channel :3w6+10 - Werfe 3w6 und addiere 10 (Init)\n";
  810.     print $sock "PRIVMSG $channel :3w6+10 25 - Werfe 3w6 und addiere 10 - maximum 25 (Init mit TAKC - SR2)\n";
  811.     print $sock "PRIVMSG $channel :3.4w6+5 - Werfe 3 mal 4w6 und addiere dabei 5 auf jeden Gruppe\n";  
  812.     print $sock "PRIVMSG $channel :5.4w6+4 6 - Werfe 5 mal 4w6 und addiere dabei 4 auf jede Gruppe, Mindestwurf ist 6\n";  
  813.     print $sock "PRIVMSG $channel :2.1wt+4 6 - Werfe 2 mal 2w10, ignoriere den niedrigens Wurf und addiere dabei 4 auf jede Gruppe, Mindestwurf ist 6\n";          
  814.     print $sock "PRIVMSG $channel :3wm - Werfe 3 mal jeweils 2w6 und addiere die Augenzahlen der beiden Wuerfe\n";
  815.     print $sock "PRIVMSG $channel :2wm 5 - Werfe 2 mal jeweils 2w6 gegen 5, addiere dabei die Augenzahlen der beiden Wuerfe \n";
  816.     print $sock "PRIVMSG $channel :2wa - Werfe 2 Ideen\n";
  817.     print $sock "PRIVMSG $channel :4wk - Ziehe 4 Karten\n";
  818.     print $sock "PRIVMSG $channel :1w[flr] - BT Schadenslokation Front/Links/Rechts\n";
  819.     print $sock "PRIVMSG $channel :1wc[flr] 15 - BT Clustertreffer von 15 Geschossen Front/Links/Rechts\n";
  820.     print $sock "PRIVMSG $channel :1wp[flr] - BT Schlag Front/Links/Rechts\n";
  821.     print $sock "PRIVMSG $channel :1wk[flr] - BT Tritt Front/Links/Rechts\n";
  822. }
  823.  
  824. sub admin {
  825.     @tmp = split(/\ /,$msg);
  826.     $chan = $tmp[1];
  827.     chomp($chan);
  828.     $omsg = $msg;
  829.     $msg = $tmp[0];
  830.     chomp($msg);
  831.     if ($msg eq "help") {
  832.         print $sock "PRIVMSG $sender :SR Wuerfelbot $version by Robert Altschaffel\n";
  833.         print $sock "PRIVMSG $sender :Befehle :\n";
  834.         print $sock "PRIVMSG $sender :JOIN channel\n";
  835.         print $sock "PRIVMSG $sender :PART channel\n";
  836.         print $sock "PRIVMSG $sender :RAW command\n";
  837.         print $sock "PRIVMSG $sender :SAY to what\n";
  838.         print $sock "PRIVMSG $sender :MAX value\n";
  839.         print $sock "PRIVMSG $sender :SHORT value\n";
  840.         print $sock "PRIVMSG $sender :NICK nick\n";
  841.         print $sock "PRIVMSG $sender :ADD owner\n";
  842.         print $sock "PRIVMSG $sender :LIST\n";
  843.         print $sock "PRIVMSG $sender :DROP owner\n";
  844.         print $sock "PRIVMSG $sender :IDENT passwort\n";
  845.         print $sock "PRIVMSG $sender :QUIT\n";
  846.         $channel=$sender;
  847.         &dice_help;
  848.     }
  849.     if ($msg eq "ADD") {
  850.         push (@owners,$chan);
  851.         print $sock "PRIVMSG $sender :$chan als Owner hinzugefuegt\n";
  852.     }
  853.     if ($msg eq "LIST") {
  854.         for ($i = 0; $i < @owners; $i++) {
  855.             print $sock "PRIVMSG $sender :$i - $owners[$i]\n";
  856.         }
  857.     }
  858.     if ($msg eq "DROP") {
  859.         print $sock "PRIVMSG $sender :$owners[$chan] geloescht\n";
  860.         $owners[$chan] = $owners[@owners-1];
  861.         pop(@owners);
  862.     }
  863.     if ($msg eq "JOIN") {
  864.         print $sock "JOIN $chan\n";
  865.         print $sock "PRIVMSG $chan :$welcomemsg\n";
  866.     }
  867.     if ($msg eq "PART") {
  868.         print $sock "PRIVMSG $chan :$partmsg\n";
  869.         print $sock "PART $chan\n";
  870.     }
  871.     if ($msg eq "QUIT") {
  872.         print $sock "PRIVMSG $sender :$partmsg !\n";
  873.         print $sock "QUIT\n";
  874.         exit;
  875.     }
  876.     if ($msg eq "NICK") {
  877.         $nick = $chan;
  878.         print $sock "NICK $chan\n";
  879.     }
  880.     if ($msg eq "MAX") {
  881.         $m = $chan;
  882.         print $sock "PRIVMSG $sender :Maxdice auf $chan gesetzt\n";
  883.     }
  884.     if ($msg eq "SHORT") {
  885.         $shortdes = $chan;
  886.         print $sock "PRIVMSG $sender :Shortdes auf $chan gesetzt\n";
  887.     }
  888.     if ($msg eq "SYS") {
  889.         $sys = $chan;
  890.         print $sock "PRIVMSG $sender :System auf $chan gesetzt\n";
  891.     }
  892.     if ($msg eq "IDENT") {
  893.         print $sock "PRIVMSG Nickserv: identify $chan\n";
  894.     }
  895.     if ($msg eq "SAY") {
  896.         $cmd = "";
  897.         for ($i = 2; $i < @tmp; $i++) {
  898.             $cmd .= "$tmp[$i] ";
  899.         }
  900.         print $sock "PRIVMSG $chan :$cmd\n";
  901.     }
  902.     if ($msg eq "RAW") {
  903.         $cmd = "";
  904.         for ($i = 1; $i < @tmp; $i++) {
  905.             $cmd .= " $tmp[$i]";
  906.         }
  907.         print $sock "$cmd\n";
  908.     }
  909.     $channel = $sender;
  910.     $msg = $omsg;
  911.     &chk_dice;
  912. }
  913.  
  914. sub conirc {
  915.     close ($sock);
  916.     print "Server : $server Port : $port Nick : $nick \nVerbinde...";
  917.     my $sock = new IO::Socket::INET (
  918.         PeerAddr => $server,
  919.         PeerPort => $port,
  920.         Proto => 'tcp',
  921.     ); die "Kann keinen Socket erstellen: $!\n" unless $sock;
  922.  
  923.     print "Verbunden\n";
  924.     print $sock "USER $nick localhost $server $nick\n";
  925.     print "--> USER $nick localhost $server $nick\n";
  926.     print $sock "NICK $nick\n";
  927.     print "--> NICK $nick\n";
  928.     if ($ident ne 0) {
  929.         print $sock "PRIVMSG Nickserv :identify $ident\n";
  930.         print "--> PRIVMSG Nickserv :identify $ident\n";
  931.     }
  932. }
  933.  
  934. sub give_direction {
  935.     if ($dmgfrom == 0) {
  936.         return ("Frontal");
  937.     }
  938.     if ($dmgfrom == 1) {
  939.         return ("Links");
  940.     }
  941.     if ($dmgfrom == 2) {
  942.         return ("Rechts");
  943.     }
  944. }
  945.  
  946. sub give_punchlocation {
  947.     if ($dmgfrom == 0) {
  948.         if ($location == 1) { $zone = "Linker Arm"; $zones = "LA";}
  949.         if ($location == 2) { $zone = "Linker Torso"; $zones = "LT";}
  950.         if ($location == 3) { $zone = "Zentraler Torso"; $zones = "CT";}
  951.         if ($location == 4) { $zone = "Rechter Torso"; $zones = "RT";}
  952.         if ($location == 5) { $zone = "Rechter Torso"; $zones = "RA";}
  953.         if ($location == 6) { $zone = "Kopf"; $zones = "HD";}
  954.     }
  955.     if ($dmgfrom == 1) {
  956.         if ($location == 1) { $zone = "Linker Arm"; $zones = "LA";}
  957.         if ($location == 2) { $zone = "Linker Torso"; $zones = "LT";}
  958.         if ($location == 3) { $zone = "Zentraler Torso"; $zones = "CT";}
  959.         if ($location == 4) { $zone = "Rechter Torso"; $zones = "RT";}
  960.         if ($location == 5) { $zone = "Rechter Torso"; $zones = "RA";}
  961.         if ($location == 6) { $zone = "Kopf"; $zones = "HD";}
  962.     }
  963.     if ($dmgfrom == 1) {
  964.         if ($location == 1) { $zone = "Linker Arm"; $zones = "LA";}
  965.         if ($location == 2) { $zone = "Linker Torso"; $zones = "LT";}
  966.         if ($location == 3) { $zone = "Zentraler Torso"; $zones = "CT";}
  967.         if ($location == 4) { $zone = "Rechter Torso"; $zones = "RT";}
  968.         if ($location == 5) { $zone = "Rechter Torso"; $zones = "RA";}
  969.         if ($location == 6) { $zone = "Kopf"; $zones = "HD";}
  970.     }
  971.     if ($shortdes == 0) {
  972.         return ($zone);
  973.     } else {
  974.         return ($zones);
  975.     }
  976. }
  977.  
  978. sub give_kicklocation {
  979.     if ($dmgfrom == 0) {
  980.         $zone = "Rechtes Bein"; $zones = "RL";
  981.         if ($location > 3) {
  982.             $zone = "Linker Bein"; $zones = "LL";
  983.         }
  984.     }
  985.     if ($dmgfrom == 1) {
  986.         $zone = "Linker Bein"; $zones = "LL";
  987.     }
  988.     if ($dmgfrom == 1) {
  989.         $zone = "Rechtes Bein"; $zones = "RL";
  990.     }
  991.     if ($shortdes == 0) {
  992.         return ($zone);
  993.     } else {
  994.         return ($zones);
  995.     }
  996. }
  997.  
  998.  
  999. sub give_location {
  1000.     if ($dmgfrom == 0) {
  1001.         if ($location == 2) { $zone = "Zentraler Torso, kritisch"; $zones = "CT*";}
  1002.         if ($location == 3) { $zone = "Rechter Arm"; $zones = "RA";}
  1003.         if ($location == 4) { $zone = "Rechter Arm"; $zones = "RA";}
  1004.         if ($location == 5) { $zone = "Rechtes Bein"; $zones = "RL";}
  1005.         if ($location == 6) { $zone = "Rechter Torso"; $zones = "RT";}
  1006.         if ($location == 7) { $zone = "Zentraler Torso"; $zones = "ZT";}
  1007.         if ($location == 8) { $zone = "Linker Torso"; $zones = "LT";}
  1008.         if ($location == 9) { $zone = "Linkes Bein"; $zones = "LL";}
  1009.         if ($location == 10) { $zone = "Linker Arm"; $zones = "LA";}
  1010.         if ($location == 11) { $zone = "Linker Arm"; $zones = "LA";}
  1011.         if ($location == 12) { $zone = "Kopf"; $zones = "HD";}
  1012.     }  
  1013.     if ($dmgfrom == 1) {
  1014.         if ($location == 2) { $zone = "Linker Torso, kritisch"; $zones = "LT*";}
  1015.         if ($location == 3) { $zone = "Linkes Bein"; $zones = "LL";}
  1016.         if ($location == 4) { $zone = "Linker Arm"; $zones = "LA";}
  1017.         if ($location == 5) { $zone = "Linker Arm"; $zones = "LA";}
  1018.         if ($location == 6) { $zone = "Linkes Bein"; $zones = "LB";}
  1019.         if ($location == 7) { $zone = "Linker Torso"; $zones = "LT";}
  1020.         if ($location == 8) { $zone = "Zentraler Torso"; $zones = "ZT";}
  1021.         if ($location == 9) { $zone = "Rechter Torso"; $zones = "RT";}
  1022.         if ($location == 10) { $zone = "Rechter Arm"; $zones = "RA";}
  1023.         if ($location == 11) { $zone = "Rechtes Bein"; $zones = "RB";}
  1024.         if ($location == 12) { $zone = "Kopf"; $zones = "HD";}
  1025.     }
  1026.     if ($dmgfrom == 2) {
  1027.         if ($location == 2) { $zone = "Rechter Torso, kritisch"; $zones = "RT*";}
  1028.         if ($location == 3) { $zone = "Rechtes Bein"; $zones = "RL";}
  1029.         if ($location == 4) { $zone = "Rechter Arm"; $zones = "RA";}
  1030.         if ($location == 5) { $zone = "Rechter Arm"; $zones = "RA";}
  1031.         if ($location == 6) { $zone = "Rechtes Bein"; $zones = "RL";}
  1032.         if ($location == 7) { $zone = "Rechter Torso"; $zones = "RT";}
  1033.         if ($location == 8) { $zone = "Zentraler Torso"; $zones = "CT";}
  1034.         if ($location == 9) { $zone = "Linker Torso"; $zones = "LT";}
  1035.         if ($location == 10) { $zone = "Linker Arm"; $zones = "LA";}
  1036.         if ($location == 11) { $zone = "Linkes Bein"; $zones = "LL";}
  1037.         if ($location == 12) { $zone = "Kopf"; $zones = "HD";}
  1038.     }
  1039.     if ($shortdes == 0) {
  1040.         return ($zone);
  1041.     } else {
  1042.         return ($zones);
  1043.     }
  1044. }
  1045.  
  1046. sub get_cluster {
  1047.     $clusterdamage = 1;
  1048.     if ($clustersize == 2) {
  1049.         if ($clusterhit > 7) { $clusterdamage = 2; }
  1050.     }
  1051.     if ($clustersize == 3) {
  1052.         if ($clusterhit > 4) { $clusterdamage = 2; }
  1053.         if ($clusterhit > 9) { $clusterdamage = 3; }
  1054.     }
  1055.     if ($clustersize == 4) {
  1056.         if ($clusterhit > 2) { $clusterdamage = 2; }
  1057.         if ($clusterhit > 6) { $clusterdamage = 3; }
  1058.         if ($clusterhit > 10) { $clusterdamage = 4; }
  1059.     }
  1060.     if ($clustersize == 5) {
  1061.         if ($clusterhit > 2) { $clusterdamage = 2; }
  1062.         if ($clusterhit > 4) { $clusterdamage = 3; }
  1063.         if ($clusterhit > 8) { $clusterdamage = 4; }
  1064.         if ($clusterhit > 10) { $clusterdamage = 5; }
  1065.     }
  1066.     if ($clustersize == 6) {
  1067.         $clusterdamage = 2;
  1068.         if ($clusterhit > 3) { $clusterdamage = 3; }
  1069.         if ($clusterhit > 5) { $clusterdamage = 4; }
  1070.         if ($clusterhit > 8) { $clusterdamage = 5; }
  1071.         if ($clusterhit > 10) { $clusterdamage = 6; }
  1072.     }
  1073.     if ($clustersize == 9) {
  1074.         $clusterdamage = 3;
  1075.         if ($clusterhit > 3) { $clusterdamage = 4; }
  1076.         if ($clusterhit > 4) { $clusterdamage = 5; }
  1077.         if ($clusterhit > 8) { $clusterdamage = 7; }
  1078.         if ($clusterhit > 10) { $clusterdamage = 9; }
  1079.     }
  1080.     if ($clustersize == 10) {
  1081.         $clusterdamage = 3;
  1082.         if ($clusterhit > 3) { $clusterdamage = 4; }
  1083.         if ($clusterhit > 4) { $clusterdamage = 6; }
  1084.         if ($clusterhit > 8) { $clusterdamage = 8; }
  1085.         if ($clusterhit > 10) { $clusterdamage = 10; }
  1086.     }
  1087.     if ($clustersize == 12) {
  1088.         $clusterdamage = 4;
  1089.         if ($clusterhit > 3) { $clusterdamage = 5; }
  1090.         if ($clusterhit > 4) { $clusterdamage = 8; }
  1091.         if ($clusterhit > 8) { $clusterdamage = 10; }
  1092.         if ($clusterhit > 10) { $clusterdamage = 12; }
  1093.     }
  1094.     if ($clustersize == 15) {
  1095.         $clusterdamage = 5;
  1096.         if ($clusterhit > 3) { $clusterdamage = 6; }
  1097.         if ($clusterhit > 4) { $clusterdamage = 9; }
  1098.         if ($clusterhit > 8) { $clusterdamage = 12; }
  1099.         if ($clusterhit > 10) { $clusterdamage = 15; }
  1100.     }
  1101.     if ($clustersize == 20) {
  1102.         $clusterdamage = 6;
  1103.         if ($clusterhit > 3) { $clusterdamage = 9; }
  1104.         if ($clusterhit > 4) { $clusterdamage = 12; }
  1105.         if ($clusterhit > 8) { $clusterdamage = 16; }
  1106.         if ($clusterhit > 10) { $clusterdamage = 20; }
  1107.     }
  1108.     return ($clusterdamage);
  1109. }
Advertisement