--- deliantra/server/ext/jeweler.ext 2007/02/02 12:05:28 1.6 +++ deliantra/server/ext/jeweler.ext 2007/02/04 11:17:52 1.7 @@ -16,6 +16,7 @@ dex => 'dexterity', con => 'constitution', str => 'strength', + gem => 'diamond', ); if ($ing =~ m/resist_(\S+)/) { @@ -30,6 +31,9 @@ my $a = $aliases{lc $1} || $1; "something for the ". lc ($a). "' special"; + } elsif ($aliases{$ing}) { + $aliases{$ing} + } else { $ing } @@ -49,7 +53,11 @@ or return $pl->reply (undef, "You slap yourself, you forgot to put at least 2 jewels in!"); my $input_level; - $input_level = max ($_->power_to_level, $input_level) for @rings; + my $value; + for (@rings) { + $input_level = max ($_->power_to_level, $input_level); + $value += $_->{hash}->{value}; + } my $ring = shift @rings; $ring->improve_by_ring (@rings); @@ -61,11 +69,11 @@ return; } - make_ring ($chdl, $ingred, $ring, $sk, $pl, $input_level); + make_ring ($chdl, $ingred, $ring, $value, $sk, $pl, $input_level); } sub make_ring { - my ($chdl, $ingred, $ring, $sk, $pl, $input_level) = @_; + my ($chdl, $ingred, $ring, $value, $sk, $pl, $input_level) = @_; if (!$pl->flag (cf::FLAG_WIZ)) { $ingred->remove ('rings'); @@ -76,27 +84,52 @@ my $succ = 0; my $r = cf::random_roll (0, 100, $pl, cf::PREFER_HIGH); + my $make_status; + my $exp; + if ($r <= $ch or $pl->flag (cf::FLAG_WIZ)) { my $lvl = max ($ring->power_to_level, 1); - my $exp = (cf::level_to_min_exp ($lvl) - cf::level_to_min_exp ($lvl - 1)) / 100; + $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; - warn "INPUT: $lvl <-> $input_level ($exp <-> $subexp)\n"; $exp -= $subexp; $exp = max ($exp, 0); } $pl->change_exp ($exp, "jeweler", cf::SK_EXP_SKILL_ONLY); - $pl->message ("You succeed and get $exp experience."); + $pl->message ("You succeed and get $exp experience points."); + $make_status = "succeeded"; + + $ring->set_value ($value * 0.8); # 20% of the input values will vanish + } else { $pl->message ("You fail!"); $ring->negate; + $make_status = "fail"; + $exp = 0; + } + + my $ring_ob = $ring->to_object; + + { # some audit info calculation + my $sklvl = cf::exp_to_level ($sk->stats->exp); + + my $make_info = sprintf + "JEWELER AUDIT: '%s' made '%s' (%s) (sk lvl %d, ring lvl %d, got %d exp): %s", + $pl->name, $ring->to_string, $ring_ob->uuid, $sklvl, + $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->to_object); + + $chdl->put ($ring_ob); } sub get_ingred { @@ -204,13 +237,14 @@ } else { my $ringo = Jeweler::Object->new (object => $ring[0]); my $iring = $ingred->improve_ring_by_plan ($plan, $ringo); - my $c1 = $ringo->calc_costs; - my $c2 = $iring->calc_costs; + my $c1 = $ringo->calc_costs; + my $c2 = $iring->calc_costs; + my $value = $iring->calc_value_from_cost ($c2); my %keys; my %cdiff; for (keys %$c1, keys %$c2) { $keys{$_} = 1 } - for (keys %keys) { $cdiff{$_} = $c2->{$_} - $c1->{$_}; warn "$_: $c2->{$_} | $c1->{$_}\n"; } + for (keys %keys) { $cdiff{$_} = $c2->{$_} - $c1->{$_}; } unless ($iring->is_better_than ($ringo)) { $pl->message ("This plan doesn't improve anything, you find yourself puzzled about what you missed..."); @@ -233,7 +267,7 @@ if (!$pl->flag (cf::FLAG_WIZ)) { $ingred->check_costs (\%cdiff, 1); } - make_ring ($chdl, $ingred, $iring, $sk, $pl); + make_ring ($chdl, $ingred, $iring, $value, $sk, $pl); } } } else {