--- deliantra/server/ext/jeweler.ext 2007/02/04 11:17:52 1.7 +++ deliantra/server/ext/jeweler.ext 2010/04/09 18:29:19 1.20 @@ -1,9 +1,9 @@ #! perl -use Data::Dumper; +use strict; + use Jeweler; use List::Util qw/max min sum/; -use strict; sub ingred_alias { my ($ing) = @_; @@ -50,9 +50,9 @@ my @rings = map { Jeweler::Object->new (object => $_) } @ring; @rings >= 2 - or return $pl->reply (undef, "You slap yourself, you forgot to put at least 2 jewels in!"); + or return $pl->message ("You slap yourself, you forgot to put at least 2 jewels in!"); - my $input_level; + my $input_level = 0; my $value; for (@rings) { $input_level = max ($_->power_to_level, $input_level); @@ -63,7 +63,7 @@ $ring->improve_by_ring (@rings); if ($do_analyze) { - $pl->reply (undef, "You want to make a " . $ring->to_string . ": " . $ring->analyze ($sk, $pl)); + $pl->message ("You want to make a " . $ring->to_string . ": " . $ring->analyze ($sk, $pl, $input_level)); $ring->wiz_analyze ($pl) if $pl->flag (cf::FLAG_WIZ); return; @@ -82,26 +82,17 @@ my $ch = $ring->get_chance_perc ($sk); my $succ = 0; - my $r = cf::random_roll (0, 100, $pl, cf::PREFER_HIGH); + my $r = cf::random_roll (0, 100, $pl, cf::PREFER_LOW); my $make_status; my $exp; if ($r <= $ch or $pl->flag (cf::FLAG_WIZ)) { - my $lvl = max ($ring->power_to_level, 1); - $exp = (cf::level_to_min_exp ($lvl) - cf::level_to_min_exp ($lvl - 1)) / 100; - - if (defined $input_level) { - my $subexp = - (cf::level_to_min_exp ($input_level) - - cf::level_to_min_exp ($input_level - 1)) - / 100; - $exp -= $subexp; - $exp = max ($exp, 0); - } + $exp = $ring->projected_exp ($input_level); $pl->change_exp ($exp, "jeweler", cf::SK_EXP_SKILL_ONLY); - $pl->message ("You succeed and get $exp experience points."); + $pl->message ( + "You succeed and get " . int ($exp) . " experience points."); $make_status = "succeeded"; $ring->set_value ($value * 0.8); # 20% of the input values will vanish @@ -124,9 +115,6 @@ $ring->power_to_level, $exp, $make_status; warn "$make_info\n" if $make_status eq 'succeeded'; - - $ring_ob->set_ob_key_value (ext_jeweler_made_by => $pl->name); - $ring_ob->set_ob_key_value (ext_jeweler_make_info => $make_info); } $chdl->put ($ring_ob); @@ -164,6 +152,7 @@ $cfg->{connection}, $cfg->{state} ); + $obj->decrease (1); cf::override; } } @@ -208,7 +197,9 @@ return } - Jeweler::simple_converter ($player, $ingred, $chdl, $1); + Jeweler::simple_converter ( + $player, $ingred, $chdl, $1, + cf::exp_to_level ($sk->stats->exp)); } elsif ($msg =~ m/^\s*merge\s*analy[sz]e\s*$/i) { merge ($chdl, $sk, $pl, 1); @@ -224,16 +215,15 @@ if ($plan) { my @ring = $ingred->get_ring; - if ((@ring > 1) || ($ring[0]->nrof > 1)) { - # actually the algorithm cant handle more than one improvement at a time - $pl->message ("You can't manage to improve more than one thing at a time!"); - return; - - } elsif (@ring < 1) { + if (!@ring) { # actually the algorithm cant $pl->message ("You slap yourself, you forgot the jewelery!"); return; + } elsif ((@ring > 1) || (grep { $_->nrof > 1 } @ring)) { + # actually the algorithm cant handle more than one improvement at a time + $pl->message ("You can't manage to improve more than one thing at a time!"); + return; } else { my $ringo = Jeweler::Object->new (object => $ring[0]); my $iring = $ingred->improve_ring_by_plan ($plan, $ringo); @@ -241,6 +231,12 @@ my $c2 = $iring->calc_costs; my $value = $iring->calc_value_from_cost ($c2); + if ((not defined $c1) || (not defined $c2)) { + $pl->message ("The jewel has or will become a resistancy above 99%,\n" + ."that is completly impossible to make!"); + return; + } + my %keys; my %cdiff; for (keys %$c1, keys %$c2) { $keys{$_} = 1 } @@ -279,4 +275,5 @@ } ); -Jeweler::read_config (cf::datadir . '/jeweler.yaml'); +Jeweler::read_config "res/jeweler.yaml"; +