#!/usr/bin/perl
use IO::Socket;
$server = "irc.euirc.net";
$port = 6666;
@owners = ("ra","Madison",);
$nick = "sr_dice";
$verbose = 1;
$version = "0.73a"; #24.11.2012
$m = 50;
$ident= 0;
$to = 600000;
$sortdice = 0;
$sys = 0;
$shortdes = 0;
$join = 0;
$pings = 0;
$partmsg = "Bye chummers!\n";
$welcomemsg = "Hoi chummers!\n";
$config = "./srwb.cnf";
open(TMP,$config) || print "Kann Configfile $config nicht lesen : $!\n";
@cfile = <TMP>;
close ($TMP);
chomp(@cfile);
for ($i=0; $i < @cfile; $i++) {
@cline = split(/\ /,$cfile[$i]);
if ($cline[0] eq "server") {
$server=$cline[1];
}
if ($cline[0] eq "port") {
$port=$cline[1];
}
if ($cline[0] eq "nick") {
$nick=$cline[1];
}
if ($cline[0] eq "verbose") {
$v=$cline[1];
}
if ($cline[0] eq "max") {
$m=$cline[1];
}
if ($cline[0] eq "sortdice") {
$sortdice=$cline[1];
}
if ($cline[0] eq "welcomemsg") {
$welcomemsg = "";
for ($a=1;$a < @cline;$a++) {
$welcomemsg .= $cline[$a] . " ";
}
}
if ($cline[0] eq "partmsg") {
$partmsg = "";
for ($a=1;$a < @cline;$a++) {
$partmsg .= $cline[$a] . " ";
}
}
if ($cline[0] eq "owners") {
@owners=$cline[1];
for ($a=2;$a < @cline;$a++) {
push (@owners,$cline[$a]);
}
}
if ($cline[0] eq "system") {
$sys=$cline[1];
}
if ($cline[0] eq "shortdes") {
$shortdes=$cline[1];
}
if ($cline[0] eq "join") {
$join=$cline[1];
}
}
for ($i=0;$i < @ARGV; $i++) {
if ($ARGV[$i] eq "h") {
print "\n";
print "s <server>\n";
print "p <port>\n";
print "o <owner>\n";
print "n <nick>\n";
print "q quite\n";
print "m <maxdice>\n";
print "j <channel>\n";
print "i <identify>\n";
print "sys <system>\n";
exit;
}
if ($ARGV[$i] eq "j") {
$join = $ARGV[$i+1];
}
if ($ARGV[$i] eq "s") {
$server = $ARGV[$i+1];
}
if ($ARGV[$i] eq "i") {
$ident = $ARGV[$i+1];
}
if ($ARGV[$i] eq "p") {
$port = $ARGV[$i+1];
}
if ($ARGV[$i] eq "c") {
$channel = $ARGV[$i+1];
}
if ($ARGV[$i] eq "n") {
$nick = $ARGV[$i+1];
}
if ($ARGV[$i] eq "m") {
$m = $ARGV[$i+1];
}
if ($ARGV[$i] eq "sys") {
$sys = $ARGV[$i+1];
}
if ($ARGV[$i] eq "q") {
$v = 0;
}
}
$lastping = time();
print "Server : $server Port : $port Nick : $nick \nVerbinde...";
my $sock = new IO::Socket::INET (
PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp',
); die "Kann keinen Socket erstellen: $!\n" unless $sock;
$sock->autoflush;
print "Verbunden\n";
print $sock "USER $nick localhost $server $nick\n";
print "--> USER $nick localhost $server $nick\n";
print $sock "NICK $nick\n";
print "--> NICK $nick\n";
while (1) {
if (($ident ne 0) && ($pings > 0)) {
print $sock "PRIVMSG Nickserv :identify $ident\n";
print "--> PRIVMSG Nickserv :identify $ident\n";
$ident = 0;
}
if (($join ne 0) && ($pings > 0)) {
print $sock "JOIN $join \n";
print "--> Joining $join \n";
print $sock "PRIVMSG $join :$welcomemsg\n";
$join = 0;
}
$line = <$sock>;
if (($v ne 0) && ($line ne "")) { print "<-- $line"; }
if ($line =~ /$nick :Nickname is already in use./) {
print "Nick schon vergeben\n";
exit;
}
if ($line =~ /PING/) {
$pings++;
$line =~ s/PING/PONG/g;
$lastping = time();
print $sock $line;
print "--> $line";
} else {
if ($line =~ /PRIVMSG $nick/) {
$type = 1;
@tmp = split(/!/,$line);
$sender = $tmp[0];
$sender =~ s/\://g;
@tmp = split(/:/,$line);
$msg = $tmp[2];
for ($a=3;$a < @tmp; $a++) {
$msg .= ":". $tmp[$a];
}
&check_adm;
if ($msg =~ "SHOWVERSION") {
print $sock "PRIVMSG $sender :Lloyd - SR Wuerfelbot $version by Robert Altschaffel - owner : @owners\n";
}
if ($adm eq 0) {
print "<$sender> $msg";
$channel = $sender;
&chk_dice;
} else {
print "+$sender+ $msg";
&admin;
}
} else {
if ($line =~ /PRIVMSG/) {
$type = 2;
@tmp = split(/!/,$line);
$sender = $tmp[0];
$sender =~ s/\://g;
@tmp = split(/:/,$line);
$msg = $tmp[2];
for ($a=3;$a < @tmp; $a++) {
$msg .= ":". $tmp[$a];
}
@tmp = split(/\ /,$line);
$channel = $tmp[2];
print "<$sender : $channel> $msg";
if ($msg eq "help\n") {$channel=$sender; &dice_help;}
&chk_dice;
}
}
}
}
sub chk_dice {
#System 0 - Standart Dx ohne weiterwuerfeln
#System 1 - Standart Dx mit weiterwuerfeln
#System 2 - Mechwarrior
#mode 0 - unset
#mode 1 - offener Wurf
#mode 2 - Wurf mit MW
#mode 3 - MW Wurf (MW?)
#mode 4 - festen Wert addieren (?)
#mode 5 - festen Wert auf alle addieren (MW?)
#mode 6 - MW Wurf - Schadenslokalisation, toadd : 0 - Front, 1 - Left, 2 - Right
#mode 7 - MW Wurf - Cluster Hit Table, toadd : 0 - Front, 1 - Left, 2 - Right, 3 - kein Schaden
#mode 8 - MW Wurf - Schadenslokalisation Punch, toadd : 0 - Front, 1 - Left, 2 - Right
#mode 9 - MW Wurf - Schadenslokalisation Kick, toadd : 0 - Front, 1 - Left, 2 - Right
#mode 10 - Abenteueridee
#mode 11 - Karte ziehen
# if($msg =~ /^[0-9]+[wW][0-9mflrcpkat][flrd]*[0-9+* ]*$/) {
if($msg =~ /^[0-9]*[.]*[0-9]+[wW][0-9mflrcpkat][flrd]*[0-9+* ]*$/) {
$msg =~ s/D/W/g;
$msg =~ s/W/w/g;
$msg =~ s/d/w/g;
chomp($msg);
@tmp=split(/w/,$msg);
$dices = $tmp[0];
$modeline = $tmp[1];
chomp($modeline);
$toadd = 0;
$tomult = 0;
$mw = 0;
$mode = 0;
$sides = 0;
if ($modeline =~ /\+/) {
$mode = 4;
@linex=split(/\+/,$modeline);
$toadd = $linex[1];
$sides = $linex[0];
@linex=split(/\ /,$toadd);
$toadd = $linex[0];
if ($sides == "t") { $sides = 10; $tomult=10;}
}
if ($modeline =~ /\*/) {
$mode = 5;
@linex=split(/\*/,$modeline);
$tomult = $linex[1];
$sides = $linex[0];
}
@linex=split(/\ /,$modeline);
if ($sides == 0) {
$sides = $linex[0];
}
if ($mode == 4 || $mode == 5) {
if ($linex[1] == "") {
$mw = 0;
} else {
$mw = $linex[1];
}
}
if ($linex[0] eq "m") {
$mode = 3;
$sides = 6;
if ($linex[1] == "") {
$mw = 0;
} else {
$mw = $linex[1];
}
}
if ($linex[0] eq "a") {
$mode = 10;
$sides = 6;
if ($linex[1] == "") {
$mw = 0;
} else {
$mw = $linex[1];
}
}
if ($linex[0] eq "k") {
$mode = 11;
$sides = 6;
}
if ($linex[0] eq "td") {
$mode = 11;
$sides = 6;
}
if ($linex[0] eq "f") {
$toadd = 0;
$mode = 6;
$sides = 6;
}
if ($linex[0] eq "l") {
$toadd = 1;
$mode = 6;
$sides = 6;
}
if ($linex[0] eq "r") {
$toadd = 2;
$mode = 6;
$sides = 6;
}
if ($linex[0] eq "c") {
$mode = 7;
$sides = 6;
$mw = $linex[1];
$toadd = 3;
}
if ($linex[0] eq "cf") {
$mode = 7;
$sides = 6;
$mw = $linex[1];
$toadd = 0;
}
if ($linex[0] eq "cl") {
$mode = 7;
$sides = 6;
$mw = $linex[1];
$toadd = 1;
}
if ($linex[0] eq "cr") {
$mode = 7;
$sides = 6;
$mw = $linex[1];
$toadd = 2;
}
if ($linex[0] eq "pf") {
$mode = 8;
$sides = 6;
$mw = $linex[1];
$toadd = 0;
}
if ($linex[0] eq "pl") {
$mode = 8;
$sides = 6;
$mw = $linex[1];
$toadd = 1;
}
if ($linex[0] eq "pr") {
$mode = 8;
$sides = 6;
$mw = $linex[1];
$toadd = 2;
}
if ($linex[0] eq "kf") {
$mode = 9;
$sides = 6;
$mw = $linex[1];
$toadd = 0;
}
if ($linex[0] eq "kl") {
$mode = 9;
$sides = 6;
$mw = $linex[1];
$toadd = 1;
}
if ($linex[0] eq "kr") {
$mode = 9;
$sides = 6;
$mw = $linex[1];
$toadd = 2;
}
if ($mode == 0) {
if ($linex[1] == "") {
$mode = 1;
} else {
$mw = $linex[1];
$mode = 2;
}
}
if ($sides < 2) {
$sides = 2;
}
print "mode : $mode, dices : $dices, sides : $sides, mw : $mw, toadd : $toadd, tomult : $tomult, modeline : $modeline\n";
if ($mode == 1) {
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1);
push (@diceres,$td);
}
$out = "PRIVMSG $channel :Werfe $dices\W$sides fuer $sender : [ @diceres ]\n";
print $sock $out;
}
if ($mode == 2) {
if ($dices > $m) { $dices = $m;}
@diceres = ();
$suc = 0;
for ($i = 0; $i < $dices; $i++) {
$td = 0;
while ($td % $sides eq 0) {
$td += int(rand($sides)+1);
}
if ($td >= $mw) {$suc++; }
push (@diceres,$td);
}
if ($suc == 1) {
$out = "PRIVMSG $channel :Werfe $dices\W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolg\n";
} else {
$out = "PRIVMSG $channel :Werfe $dices\W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolge\n";
}
print $sock $out;
}
if ($mode == 3) {
if ($mw > 0) { $suc = 0;}
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1) + int(rand($sides)+1);
if ($td >= $mw) {$suc++;}
push (@diceres,$td);
}
if ($mw > 0) {
if ($suc == 1) {
$out = "PRIVMSG $channel :Werfe $dices\*2W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolg \n";
} else {
$out = "PRIVMSG $channel :Werfe $dices\*2W$sides gegen $mw fuer $sender : [ @diceres ] => $suc Erfolge \n";
}
} else {
$out = "PRIVMSG $channel :Werfe $dices\*2W$sides fuer $sender : [ @diceres ]\n";
}
print $sock $out;
}
if ($mode == 4) {
if ($dices > $m) { $dices = $m;}
if ($dices =~ /\./) {
@linex=split(/\./,$dices);
$dices = $linex[1];
$tmp = $linex[0];
# print "dices $dices | tmp $tmp \n";
if ($dices < 1) {$dices = 1;}
if ($tmp < 1) {$tmp = 1;}
if ($mw > 0) {$suc = 0;}
# print "dices $dices | tmp $tmp \n";
if ($tomult == 10) {$dices++};
$dicestr = "";
$resstr = "[";
@diceres = ();
for ($j = 0; $j < $tmp; $j++) {
$ressum = 0;
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1);
push (@diceres,$td);
$ressum = $ressum + $td;
}
$ressum = $ressum + $toadd;
if ($tomult == 10) {
my $min = (sort { $a <=> $b } @diceres)[0];
$ressum -= $min;
}
if ($ressum >= $mw) {$suc++};
$dicestr = $dicestr."[ @diceres ] ";
$resstr .= " $ressum";
undef @diceres;
}
$resstr .= " ]";
if ($tomult == 10) { $dices .= "T"; }
if ($mw > 0) {
if ($dices == 1) {
if ($suc == 1) {
$out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $resstr => $suc Erfolg \n";
} else {
$out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $resstr => $suc Erfolge \n";
}
} else {
if ($suc == 1) {
$out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $dicestr => $resstr => $suc Erfolg \n";
} else {
$out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd gegen $mw fuer $sender : $dicestr => $resstr => $suc Erfolge \n";
}
}
} else {
if ($dices == 1) {
$out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd fuer $sender : $resstr \n";
} else {
$out = "PRIVMSG $channel :Werfe $tmp * $dices\W$sides\+$toadd fuer $sender : $dicestr => $resstr \n";
}
}
} else {
if ($tomult == 10) {$dices++};
@diceres = ();
$ressum = 0;
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1);
push (@diceres,$td);
$ressum = $ressum + $td;
}
$ressum = $ressum + $toadd;
if ($tomult == 10) {
my $min = (sort { $a <=> $b } @diceres)[0];
$ressum -= $min;
$dices .= "T";
}
$out = "PRIVMSG $channel :Werfe $dices\W$sides\+$toadd fuer $sender : [ @diceres ] => $ressum\n";
}
print $sock $out;
}
if ($mode == 5) {
if ($mw > 0) {$suc = 0;}
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1);
$td += $tomult;
if ($td >= $mw) {$suc++;}
push (@diceres,$td);
}
if ($mw > 0) {
if ($suc == 1) {
$out = "PRIVMSG $channel :Werfe $dices\W$sides\+$tomult gegen $mw fuer $sender : [ @diceres ] => $suc Erfolg \n";
} else {
$out = "PRIVMSG $channel :Werfe $dices\W$sides\+$tomult gegen $mw fuer $sender : [ @diceres ] => $suc Erfolge \n";
}
} else {
$out = "PRIVMSG $channel :Werfe $dices\W$sides\+$tomult fuer $sender : [ @diceres ]\n";
}
print $sock $out;
}
if ($mode == 6) {
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1) + int(rand($sides)+1);
push (@diceres,$td);
}
$dmgfrom = $toadd;
$dirname = &give_direction();
$out = "PRIVMSG $channel :Werfe $dices Trefferzonen von $dirname fuer $sender : [ @diceres ]\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
foreach (@diceres) {
$location = $_;
$zone = &give_location();
$out .= "[ $location ] => $zone ";
$intcnt++;
if ($intcnt == 5) {
$out .= "\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
}
}
$out .= "\n";
print $sock $out;
}
if ($mode == 7) {
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1) + int(rand($sides)+1);
push (@diceres,$td);
}
$out = "PRIVMSG $channel :Werfe $dices Trefferzahlen fuer $sender : [ @diceres ]\n";
print $sock $out;
if ($toadd == 3) {
$intcnt = 0;
$out = "PRIVMSG $channel :";
foreach (@diceres) {
$clusterhit = $_;
$clustersize = $mw;
$clusterdamage = &get_cluster();
$out .= "[ $clusterhit ] => $clusterdamage ";
$intcnt++;
if ($intcnt == 5) {
$out .= "\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
}
}
if ($intcnt != 0) {
$out .= "\n";
print $sock $out;
}
} else {
$dmgfrom = $toadd;
$clusttype = 0;
$weapname = "unbekannt";
$clustersize = $mw;
if ((($clustersize == 2) || ($clustersize == 4)) || ($clustersize == 6)) {
$clusttype = 1;
$weapname = "SRM";
};
if (((($clustersize == 5) || ($clustersize == 10)) || ($clustersize == 15)) || ($clustersize == 20)) {
$clusttype = 2;
$weapname = "LRM";
}
$dirname = &give_direction();
foreach(@diceres) {
$clusterhit = $_;
$clusterdamage = &get_cluster();
$out = "PRIVMSG $channel :Schadenszone fuer $weapname $clustersize von $dirname - $clusterdamage Treffer\n";
print $sock $out;
if ($clusttype == 0) {
$out = "PRIVMSG $channel :";
for ($i = 0; $i < $clusterdamage; $i++) {
$location = int(rand($sides)+1) + int(rand($sides)+1);
$zone = &give_location();
$out .= "[ $location ] => 1 an $zone ";
}
}
if ($clusttype == 1) {
$out = "PRIVMSG $channel :";
for ($i = 0; $i < $clusterdamage; $i++) {
$location = int(rand($sides)+1) + int(rand($sides)+1);
$zone = &give_location();
$out .= "[ $location ] => 2 an $zone ";
}
}
if ($clusttype == 2) {
$out = "PRIVMSG $channel :";
while ($clusterdamage > 0) {
$location = int(rand($sides)+1) + int(rand($sides)+1);
$zone = &give_location();
if ($clusterdamage >= 5) {
$clusterdamage -= 5;
$donedam = 5;
} else {
$donedam = $clusterdamage;
$clusterdamage = 0;
}
$out .= "[ $location ] => $donedam an $zone ";
}
}
$out .= "\n";
print $sock $out;
}
}
}
if ($mode == 8) {
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1);
push (@diceres,$td);
}
$dmgfrom = $toadd;
$dirname = &give_direction();
$out = "PRIVMSG $channel :Werfe $dices Trefferzonen (Punch) von $dirname fuer $sender : [ @diceres ]\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
foreach (@diceres) {
$location = $_;
$zone = &give_punchlocation();
$out .= "[ $location ] => $zone ";
$intcnt++;
if ($intcnt == 5) {
$out .= "\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
}
}
$out .= "\n";
print $sock $out;
}
if ($mode == 9) {
if ($dices > $m) { $dices = $m;}
@diceres = ();
for ($i = 0; $i < $dices; $i++) {
$td = int(rand($sides)+1);
push (@diceres,$td);
}
$dmgfrom = $toadd;
$dirname = &give_direction();
$out = "PRIVMSG $channel :Werfe $dices Trefferzonen (Kick) von $dirname fuer $sender : [ @diceres ]\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
foreach (@diceres) {
$location = $_;
$zone = &give_kicklocation();
$out .= "[ $location ] => $zone ";
$intcnt++;
if ($intcnt == 5) {
$out .= "\n";
print $sock $out;
$intcnt = 0;
$out = "PRIVMSG $channel :";
}
}
$out .= "\n";
print $sock $out;
}
if ($mode == 10) {
$sysset = 0;
if ($dices > $m) { $dices = $m;}
if ($mw == 1) {
$sysset = 1;
$sys = "DSA";
@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");
}
if ($mw == 2) {
$sysset = 1;
$sys = "DH";
@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");
}
if ($mw == 3) {
$sysset = 1;
$sys = "SR";
@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");
}
if ($mw == 99) {
$sysset = 1;
$sys = "System";
@things=("SR3","SR4","D&D","DW","DH","DSA","Etwas seltsames aus Bernd's Schrank");
}
if ($sysset == 0) {
$sys = "Generisch";
@things=("Graeber","Verfluchter Gegenstand","Gift","Meuchelmord","Geister","Soeldner","Verwuestete Siedlung","Grossstadt");
}
$out = "PRIVMSG $channel :Werfe $dices Ideen ($sys) fuer $sender : \n";
print $sock $out;
for ($i = 0; $i < $dices; $i++) {
$td = int(rand(@things));
$what = $things[$td];
$out = "PRIVMSG $channel :$what\n";
print $sock $out;
}
}
if ($mode == 11) {
if ($dices > $m) { $dices = $m;}
for ($i = 0; $i < $dices; $i++) {
@things=("Herz","Pik","Karo","Kreuz");
$td = int(rand(@things));
$what = $things[$td];
@things=("Ass", "Zehn","König","Dame","Bube","Neun","Acht","Sieben");
$td = int(rand(@things));
$what .= " ". $things[$td];
$out = "PRIVMSG $channel :$what\n";
print $sock $out;
}
}
}
}
sub check_adm {
$adm = 0;
for ($i = 0; $i < @owners; $i++) {
if ($owners[$i] eq $sender) {
$adm = 1;
}
}
}
sub dice_help {
print $sock "PRIVMSG $channel :Wuerfel :\n";
print $sock "PRIVMSG $channel :4w6 - Werfe 4w6\n";
print $sock "PRIVMSG $channel :2w6 10 - Werfe 2w6 gegen 10\n";
print $sock "PRIVMSG $channel :3w6+10 - Werfe 3w6 und addiere 10 (Init)\n";
print $sock "PRIVMSG $channel :3w6+10 25 - Werfe 3w6 und addiere 10 - maximum 25 (Init mit TAKC - SR2)\n";
print $sock "PRIVMSG $channel :3.4w6+5 - Werfe 3 mal 4w6 und addiere dabei 5 auf jeden Gruppe\n";
print $sock "PRIVMSG $channel :5.4w6+4 6 - Werfe 5 mal 4w6 und addiere dabei 4 auf jede Gruppe, Mindestwurf ist 6\n";
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";
print $sock "PRIVMSG $channel :3wm - Werfe 3 mal jeweils 2w6 und addiere die Augenzahlen der beiden Wuerfe\n";
print $sock "PRIVMSG $channel :2wm 5 - Werfe 2 mal jeweils 2w6 gegen 5, addiere dabei die Augenzahlen der beiden Wuerfe \n";
print $sock "PRIVMSG $channel :2wa - Werfe 2 Ideen\n";
print $sock "PRIVMSG $channel :4wk - Ziehe 4 Karten\n";
print $sock "PRIVMSG $channel :1w[flr] - BT Schadenslokation Front/Links/Rechts\n";
print $sock "PRIVMSG $channel :1wc[flr] 15 - BT Clustertreffer von 15 Geschossen Front/Links/Rechts\n";
print $sock "PRIVMSG $channel :1wp[flr] - BT Schlag Front/Links/Rechts\n";
print $sock "PRIVMSG $channel :1wk[flr] - BT Tritt Front/Links/Rechts\n";
}
sub admin {
@tmp = split(/\ /,$msg);
$chan = $tmp[1];
chomp($chan);
$omsg = $msg;
$msg = $tmp[0];
chomp($msg);
if ($msg eq "help") {
print $sock "PRIVMSG $sender :SR Wuerfelbot $version by Robert Altschaffel\n";
print $sock "PRIVMSG $sender :Befehle :\n";
print $sock "PRIVMSG $sender :JOIN channel\n";
print $sock "PRIVMSG $sender :PART channel\n";
print $sock "PRIVMSG $sender :RAW command\n";
print $sock "PRIVMSG $sender :SAY to what\n";
print $sock "PRIVMSG $sender :MAX value\n";
print $sock "PRIVMSG $sender :SHORT value\n";
print $sock "PRIVMSG $sender :NICK nick\n";
print $sock "PRIVMSG $sender :ADD owner\n";
print $sock "PRIVMSG $sender :LIST\n";
print $sock "PRIVMSG $sender :DROP owner\n";
print $sock "PRIVMSG $sender :IDENT passwort\n";
print $sock "PRIVMSG $sender :QUIT\n";
$channel=$sender;
&dice_help;
}
if ($msg eq "ADD") {
push (@owners,$chan);
print $sock "PRIVMSG $sender :$chan als Owner hinzugefuegt\n";
}
if ($msg eq "LIST") {
for ($i = 0; $i < @owners; $i++) {
print $sock "PRIVMSG $sender :$i - $owners[$i]\n";
}
}
if ($msg eq "DROP") {
print $sock "PRIVMSG $sender :$owners[$chan] geloescht\n";
$owners[$chan] = $owners[@owners-1];
pop(@owners);
}
if ($msg eq "JOIN") {
print $sock "JOIN $chan\n";
print $sock "PRIVMSG $chan :$welcomemsg\n";
}
if ($msg eq "PART") {
print $sock "PRIVMSG $chan :$partmsg\n";
print $sock "PART $chan\n";
}
if ($msg eq "QUIT") {
print $sock "PRIVMSG $sender :$partmsg !\n";
print $sock "QUIT\n";
exit;
}
if ($msg eq "NICK") {
$nick = $chan;
print $sock "NICK $chan\n";
}
if ($msg eq "MAX") {
$m = $chan;
print $sock "PRIVMSG $sender :Maxdice auf $chan gesetzt\n";
}
if ($msg eq "SHORT") {
$shortdes = $chan;
print $sock "PRIVMSG $sender :Shortdes auf $chan gesetzt\n";
}
if ($msg eq "SYS") {
$sys = $chan;
print $sock "PRIVMSG $sender :System auf $chan gesetzt\n";
}
if ($msg eq "IDENT") {
print $sock "PRIVMSG Nickserv: identify $chan\n";
}
if ($msg eq "SAY") {
$cmd = "";
for ($i = 2; $i < @tmp; $i++) {
$cmd .= "$tmp[$i] ";
}
print $sock "PRIVMSG $chan :$cmd\n";
}
if ($msg eq "RAW") {
$cmd = "";
for ($i = 1; $i < @tmp; $i++) {
$cmd .= " $tmp[$i]";
}
print $sock "$cmd\n";
}
$channel = $sender;
$msg = $omsg;
&chk_dice;
}
sub conirc {
close ($sock);
print "Server : $server Port : $port Nick : $nick \nVerbinde...";
my $sock = new IO::Socket::INET (
PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp',
); die "Kann keinen Socket erstellen: $!\n" unless $sock;
print "Verbunden\n";
print $sock "USER $nick localhost $server $nick\n";
print "--> USER $nick localhost $server $nick\n";
print $sock "NICK $nick\n";
print "--> NICK $nick\n";
if ($ident ne 0) {
print $sock "PRIVMSG Nickserv :identify $ident\n";
print "--> PRIVMSG Nickserv :identify $ident\n";
}
}
sub give_direction {
if ($dmgfrom == 0) {
return ("Frontal");
}
if ($dmgfrom == 1) {
return ("Links");
}
if ($dmgfrom == 2) {
return ("Rechts");
}
}
sub give_punchlocation {
if ($dmgfrom == 0) {
if ($location == 1) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 2) { $zone = "Linker Torso"; $zones = "LT";}
if ($location == 3) { $zone = "Zentraler Torso"; $zones = "CT";}
if ($location == 4) { $zone = "Rechter Torso"; $zones = "RT";}
if ($location == 5) { $zone = "Rechter Torso"; $zones = "RA";}
if ($location == 6) { $zone = "Kopf"; $zones = "HD";}
}
if ($dmgfrom == 1) {
if ($location == 1) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 2) { $zone = "Linker Torso"; $zones = "LT";}
if ($location == 3) { $zone = "Zentraler Torso"; $zones = "CT";}
if ($location == 4) { $zone = "Rechter Torso"; $zones = "RT";}
if ($location == 5) { $zone = "Rechter Torso"; $zones = "RA";}
if ($location == 6) { $zone = "Kopf"; $zones = "HD";}
}
if ($dmgfrom == 1) {
if ($location == 1) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 2) { $zone = "Linker Torso"; $zones = "LT";}
if ($location == 3) { $zone = "Zentraler Torso"; $zones = "CT";}
if ($location == 4) { $zone = "Rechter Torso"; $zones = "RT";}
if ($location == 5) { $zone = "Rechter Torso"; $zones = "RA";}
if ($location == 6) { $zone = "Kopf"; $zones = "HD";}
}
if ($shortdes == 0) {
return ($zone);
} else {
return ($zones);
}
}
sub give_kicklocation {
if ($dmgfrom == 0) {
$zone = "Rechtes Bein"; $zones = "RL";
if ($location > 3) {
$zone = "Linker Bein"; $zones = "LL";
}
}
if ($dmgfrom == 1) {
$zone = "Linker Bein"; $zones = "LL";
}
if ($dmgfrom == 1) {
$zone = "Rechtes Bein"; $zones = "RL";
}
if ($shortdes == 0) {
return ($zone);
} else {
return ($zones);
}
}
sub give_location {
if ($dmgfrom == 0) {
if ($location == 2) { $zone = "Zentraler Torso, kritisch"; $zones = "CT*";}
if ($location == 3) { $zone = "Rechter Arm"; $zones = "RA";}
if ($location == 4) { $zone = "Rechter Arm"; $zones = "RA";}
if ($location == 5) { $zone = "Rechtes Bein"; $zones = "RL";}
if ($location == 6) { $zone = "Rechter Torso"; $zones = "RT";}
if ($location == 7) { $zone = "Zentraler Torso"; $zones = "ZT";}
if ($location == 8) { $zone = "Linker Torso"; $zones = "LT";}
if ($location == 9) { $zone = "Linkes Bein"; $zones = "LL";}
if ($location == 10) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 11) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 12) { $zone = "Kopf"; $zones = "HD";}
}
if ($dmgfrom == 1) {
if ($location == 2) { $zone = "Linker Torso, kritisch"; $zones = "LT*";}
if ($location == 3) { $zone = "Linkes Bein"; $zones = "LL";}
if ($location == 4) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 5) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 6) { $zone = "Linkes Bein"; $zones = "LB";}
if ($location == 7) { $zone = "Linker Torso"; $zones = "LT";}
if ($location == 8) { $zone = "Zentraler Torso"; $zones = "ZT";}
if ($location == 9) { $zone = "Rechter Torso"; $zones = "RT";}
if ($location == 10) { $zone = "Rechter Arm"; $zones = "RA";}
if ($location == 11) { $zone = "Rechtes Bein"; $zones = "RB";}
if ($location == 12) { $zone = "Kopf"; $zones = "HD";}
}
if ($dmgfrom == 2) {
if ($location == 2) { $zone = "Rechter Torso, kritisch"; $zones = "RT*";}
if ($location == 3) { $zone = "Rechtes Bein"; $zones = "RL";}
if ($location == 4) { $zone = "Rechter Arm"; $zones = "RA";}
if ($location == 5) { $zone = "Rechter Arm"; $zones = "RA";}
if ($location == 6) { $zone = "Rechtes Bein"; $zones = "RL";}
if ($location == 7) { $zone = "Rechter Torso"; $zones = "RT";}
if ($location == 8) { $zone = "Zentraler Torso"; $zones = "CT";}
if ($location == 9) { $zone = "Linker Torso"; $zones = "LT";}
if ($location == 10) { $zone = "Linker Arm"; $zones = "LA";}
if ($location == 11) { $zone = "Linkes Bein"; $zones = "LL";}
if ($location == 12) { $zone = "Kopf"; $zones = "HD";}
}
if ($shortdes == 0) {
return ($zone);
} else {
return ($zones);
}
}
sub get_cluster {
$clusterdamage = 1;
if ($clustersize == 2) {
if ($clusterhit > 7) { $clusterdamage = 2; }
}
if ($clustersize == 3) {
if ($clusterhit > 4) { $clusterdamage = 2; }
if ($clusterhit > 9) { $clusterdamage = 3; }
}
if ($clustersize == 4) {
if ($clusterhit > 2) { $clusterdamage = 2; }
if ($clusterhit > 6) { $clusterdamage = 3; }
if ($clusterhit > 10) { $clusterdamage = 4; }
}
if ($clustersize == 5) {
if ($clusterhit > 2) { $clusterdamage = 2; }
if ($clusterhit > 4) { $clusterdamage = 3; }
if ($clusterhit > 8) { $clusterdamage = 4; }
if ($clusterhit > 10) { $clusterdamage = 5; }
}
if ($clustersize == 6) {
$clusterdamage = 2;
if ($clusterhit > 3) { $clusterdamage = 3; }
if ($clusterhit > 5) { $clusterdamage = 4; }
if ($clusterhit > 8) { $clusterdamage = 5; }
if ($clusterhit > 10) { $clusterdamage = 6; }
}
if ($clustersize == 9) {
$clusterdamage = 3;
if ($clusterhit > 3) { $clusterdamage = 4; }
if ($clusterhit > 4) { $clusterdamage = 5; }
if ($clusterhit > 8) { $clusterdamage = 7; }
if ($clusterhit > 10) { $clusterdamage = 9; }
}
if ($clustersize == 10) {
$clusterdamage = 3;
if ($clusterhit > 3) { $clusterdamage = 4; }
if ($clusterhit > 4) { $clusterdamage = 6; }
if ($clusterhit > 8) { $clusterdamage = 8; }
if ($clusterhit > 10) { $clusterdamage = 10; }
}
if ($clustersize == 12) {
$clusterdamage = 4;
if ($clusterhit > 3) { $clusterdamage = 5; }
if ($clusterhit > 4) { $clusterdamage = 8; }
if ($clusterhit > 8) { $clusterdamage = 10; }
if ($clusterhit > 10) { $clusterdamage = 12; }
}
if ($clustersize == 15) {
$clusterdamage = 5;
if ($clusterhit > 3) { $clusterdamage = 6; }
if ($clusterhit > 4) { $clusterdamage = 9; }
if ($clusterhit > 8) { $clusterdamage = 12; }
if ($clusterhit > 10) { $clusterdamage = 15; }
}
if ($clustersize == 20) {
$clusterdamage = 6;
if ($clusterhit > 3) { $clusterdamage = 9; }
if ($clusterhit > 4) { $clusterdamage = 12; }
if ($clusterhit > 8) { $clusterdamage = 16; }
if ($clusterhit > 10) { $clusterdamage = 20; }
}
return ($clusterdamage);
}
Comments
0 B
|👍
/👎