diff --git a/Irpg/Action.pm b/Irpg/Action.pm index 9aba1627274e9ec1f8896301795d2219870ef925..98cd520e99cfbde5b18d4bee562dc591b327acfe 100644 --- a/Irpg/Action.pm +++ b/Irpg/Action.pm @@ -5,6 +5,7 @@ use warnings; use POSIX; use Irpg::Utils qw(:text); use Irpg::Irc qw(:interaction); +use List::Util qw(min); use Exporter qw(import); our @EXPORT = qw(&choose_action &itemsum &challenge_opp &collision_action &team_battle); @@ -144,19 +145,22 @@ sub mystic_result { if ($win) { #my $gain = int($rps->{$p2}{level}/8); #$gain = 5 if $gain < 5; - my $gain = perc_victory($rps->{$p2}{level} - $rps->{$p1}{level})*0.70; - $gain *= 1.2 if ($wanted); - $gain = int(($gain/100)*$rps->{$p1}{next}); - $gain = -$rps->{$p1}{class}->real_gain(-$gain); - $rps->{$p1}{next} = $gain >= $rps->{$p1}{next} ? 0 : $rps->{$p1}{next} - $gain; - $rps->{$p2}{next} += $gain; + my $perc = perc_victory($rps->{$p2}{level} - $rps->{$p1}{level})*0.60; + $perc *= 1.2 if ($wanted); + my $gain_p1 = int(($perc/100)*$rps->{$p1}{next}); + my $gain_p2 = min($gain_p1, int(($perc/100)*$rps->{$p2}{next})); + $gain_p1 = -$rps->{$p1}{class}->real_gain(-$gain_p1); + $gain_p2 = $rps->{$p2}{class}->real_gain($gain_p2); + $rps->{$p1}{next} = $gain_p1 >= $rps->{$p1}{next} ? + 0 : $rps->{$p1}{next} - $gain_p1; + $rps->{$p2}{next} += $gain_p2; push(@queue, - "$p1 transfers ".duration($gain)." from ". - pronoun(2, $rps->{$p1}{gender})." clock to $p2\'s. ". + "$p1 transmutes ".duration($gain_p1)." from ".pronoun(2, $rps->{$p1}{gender}). + " clock to ".duration($gain_p2)." for $p2\'s. ". "$p1 reaches next level in\x033 ".duration($rps->{$p1}{next})."\x03. ". "$p2 reaches next level in\x035 ".duration($rps->{$p2}{next})."\x03."); if ($win == 2) { - $gain = int(0.05*$rps->{$p1}{next}); + my $gain = int(0.05*$rps->{$p1}{next}); $gain *= $rps->{$p1}{class}->{MOD_CRT}; $gain = -$rps->{$p2}{class}->real_gain(-$gain); $rps->{$p1}{next} = $gain >= $rps->{$p1}{next} ? 0 : $rps->{$p1}{next} - $gain; @@ -170,15 +174,18 @@ sub mystic_result { else { #my $gain = $rps->{$p2}{level}/10; #$gain = 5 if $gain < 5; - my $gain = perc_defeat($rps->{$p2}{level} - $rps->{$p1}{level})*0.70; - $gain *= 1.2 if ($wanted); - $gain = int(($gain/100)*$rps->{$p1}{next}); - $gain = $rps->{$p1}{class}->real_gain($gain); - $rps->{$p1}{next} += $gain; - $rps->{$p2}{next} = $gain >= $rps->{$p2}{next} ? 0 : $rps->{$p2}{next} - $gain; + my $perc = perc_defeat($rps->{$p2}{level} - $rps->{$p1}{level})*0.60; + $perc *= 1.2 if ($wanted); + my $gain_p2 = int(($perc/100)*$rps->{$p2}{next}); + my $gain_p1 = min($gain_p2, int(($perc/100)*$rps->{$p1}{next})); + $gain_p1 = $rps->{$p1}{class}->real_gain($gain_p1); + $gain_p2 = -$rps->{$p2}{class}->real_gain(-$gain_p2); + $rps->{$p1}{next} += $gain_p1; + $rps->{$p2}{next} = $gain_p2 >= $rps->{$p2}{next} ? + 0 : $rps->{$p2}{next} - $gain_p2; push(@queue, - "$p1 transfers ".duration($gain)." from ". - "${p2}'s clock to ".pronoun(2, $rps->{$p1}{gender})." own. ". + "$p1 transmutes ".duration($gain_p2)." from ${p2}'s clock to ". + duration($gain_p1)." on ".pronoun(2, $rps->{$p1}{gender})." own. ". "$p1 reaches next level in\x035 ".duration($rps->{$p1}{next})."\x03. ". "$p2 reaches next level in\x033 ".duration($rps->{$p2}{next})."\x03."); } @@ -592,12 +599,12 @@ our $commands = { action => {ref => \&do_action, adm => 0, prv => 1, pub => 1, hlp => 'ACTION [-t <type>] [<char name>]: perform an action '. '(fight/mystic/steal) with someone. With no type specified, '. - 'The action is chosen at random, '. - 'with more chance for the one you are the better at.'}, + 'The action is chosen at random, '. + 'with more chance for the one you are the better at.'}, actions => {ref => \&do_actions, adm => 0, prv => 1, pub => 1, hlp => 'ACTIONS [-t <type>] [<char name>]: perform all available actions '. 'with someone. With no type spcified, the actions are chosen '. - 'at random, with more chance for the one you are the better at.'} + 'at random, with more chance for the one you are the better at.'} }; 1; diff --git a/Irpg/Classes/Farmer.pm b/Irpg/Classes/Farmer.pm index b936cb372658e35d9d81755737bfaca5e7060d5e..be4e60e48c6379d773d80b2eef09916b0494926e 100644 --- a/Irpg/Classes/Farmer.pm +++ b/Irpg/Classes/Farmer.pm @@ -82,7 +82,7 @@ sub steal_def { sub real_gain { # to apply on TTL modificators my ($self, $time) = @_; - return unless ($time =~ m/^-?\d+(?:\.\d+$)?/); + return unless ($time =~ m/^-?\d+(?:\.\d+)?$/); $time = $time >= 0 ? $time*(1-($self->cha()-1)/50): # add less time $time*(1+($self->cha()-1)/50); # remove more time diff --git a/Irpg/Event.pm b/Irpg/Event.pm index e04eed2c28ad8ff113e3a50a7b6147634f77908f..a781d8e5888aee039f7a7aca6429434e1ede416d 100644 --- a/Irpg/Event.pm +++ b/Irpg/Event.pm @@ -398,7 +398,7 @@ sub evilchase { return unless (@opps && rand(5) < 1); my $opp = $opps[int(rand(@opps))]; Irpg::Irc::chanmsg(Irpg::Utils::clog( - "$player, full of hatred and disdain for ". + "$player, full of hatred and disdain for ". pronoun(2, $rps->{$player}{gender})." kind, has chased ". "after $opp who passed by.")); collision_action($player, $opp); @@ -417,8 +417,10 @@ sub goodness { "evil men poison them. Together have they prayed to their ". "God, and it is his light that now shines upon them. $gain\% ". "of their time is removed from their clocks.")); - $rps->{$players[0]}{next} += int($rps->{$players[0]}{class}->real_gain(-$gain/100)); - $rps->{$players[1]}{next} += int($rps->{$players[1]}{class}->real_gain(-$gain/100)); + $gain = int(($gain/100)*$rps->{$players[0]}{next}); + $rps->{$players[0]}{next} += int($rps->{$players[0]}{class}->real_gain(-$gain)); + $gain = int(($gain/100)*$rps->{$players[1]}{next}); + $rps->{$players[1]}{next} += int($rps->{$players[1]}{class}->real_gain(-$gain)); Irpg::Irc::chanmsg("$players[0] reaches next level in ". duration($rps->{$players[0]}{next})."."); Irpg::Irc::chanmsg("$players[1] reaches next level in ". diff --git a/Irpg/Main.pm b/Irpg/Main.pm index 0cf90c1f2d2d6da7a2d57f95bcd434cdf26ddc24..99d77c582526397e43d00feee4b951612261dc68 100644 --- a/Irpg/Main.pm +++ b/Irpg/Main.pm @@ -158,7 +158,10 @@ sub penalize { $pen_key = 'pen_title'; } elsif ($type eq "chclass") { - $pen = int($opts->{rpbase} * ($opts->{rppenstep}**$rps->{$username}{level})); + $pen = $rps->{$username}{level} <= 60 ? + int( $opts->{rpbase} * ($opts->{rpstep}**$rps->{$username}{level})) : + int(($opts->{rpbase} * ($opts->{rpstep}**60)) + + (86400*($rps->{$username}{level} - 60))); $reason = 'training'; $pen_key = 'pen_class'; } @@ -577,7 +580,7 @@ sub parse { } else { Irpg::Irc::notice("You don't have access to ".uc($arg[3]).".", $usernick); } - } else { + } elsif ($msgtype eq 'pub') { # the message is not a command penalize($username,"privmsg",length("@arg[3..$#arg]")); }