ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/jeweler.ext
(Generate patch)

Comparing deliantra/server/ext/jeweler.ext (file contents):
Revision 1.12 by elmex, Tue Jul 31 09:40:15 2007 UTC vs.
Revision 1.21 by elmex, Mon Apr 19 12:03:50 2010 UTC

1#! perl 1#! perl
2 2
3use Data::Dumper; 3use strict;
4
4use Jeweler; 5use Jeweler;
5use List::Util qw/max min sum/; 6use List::Util qw/max min sum/;
6use strict;
7 7
8sub ingred_alias { 8sub ingred_alias {
9 my ($ing) = @_; 9 my ($ing) = @_;
10 10
11 my %aliases = ( 11 my %aliases = (
48 48
49 my @ring = $ingred->get_ring; 49 my @ring = $ingred->get_ring;
50 my @rings = map { Jeweler::Object->new (object => $_) } @ring; 50 my @rings = map { Jeweler::Object->new (object => $_) } @ring;
51 51
52 @rings >= 2 52 @rings >= 2
53 or return $pl->reply (undef, "You slap yourself, you forgot to put at least 2 jewels in!"); 53 or return $pl->message ("You slap yourself, you forgot to put at least 2 jewels in!");
54 54
55 my $input_level = 0; 55 my $input_level = 0;
56 my $value; 56 my $value;
57 for (@rings) { 57 for (@rings) {
58 $input_level = max ($_->power_to_level, $input_level); 58 $input_level = max ($_->power_to_level, $input_level);
61 61
62 my $ring = shift @rings; 62 my $ring = shift @rings;
63 $ring->improve_by_ring (@rings); 63 $ring->improve_by_ring (@rings);
64 64
65 if ($do_analyze) { 65 if ($do_analyze) {
66 $pl->reply (undef, "You want to make a " . $ring->to_string . ": " . $ring->analyze ($sk, $pl, $input_level)); 66 $pl->message ("You want to make a " . $ring->to_string . ": " . $ring->analyze ($sk, $pl, $input_level));
67 $ring->wiz_analyze ($pl) 67 $ring->wiz_analyze ($pl)
68 if $pl->flag (cf::FLAG_WIZ); 68 if $pl->flag (cf::FLAG_WIZ);
69 return; 69 return;
70 } 70 }
71 71
80 $ingred->remove ('ammys'); 80 $ingred->remove ('ammys');
81 } 81 }
82 82
83 my $ch = $ring->get_chance_perc ($sk); 83 my $ch = $ring->get_chance_perc ($sk);
84 my $succ = 0; 84 my $succ = 0;
85 my $r = cf::random_roll (0, 100, $pl, cf::PREFER_HIGH); 85 my $r = cf::random_roll (0, 100, $pl, cf::PREFER_LOW);
86 86
87 my $make_status; 87 my $make_status;
88 my $exp; 88 my $exp;
89 89
90 if ($r <= $ch or $pl->flag (cf::FLAG_WIZ)) { 90 if ($r <= $ch or $pl->flag (cf::FLAG_WIZ)) {
91 $exp = $ring->projected_exp ($input_level); 91 $exp = $ring->projected_exp ($input_level);
92 92
93 $pl->change_exp ($exp, "jeweler", cf::SK_EXP_SKILL_ONLY); 93 $pl->change_exp ($exp, "jeweler", cf::SK_EXP_SKILL_ONLY);
94 $pl->message (
94 $pl->message ("You succeed and get $exp experience points."); 95 "You succeed and get " . int ($exp) . " experience points.");
95 $make_status = "succeeded"; 96 $make_status = "succeeded";
96 97
97 $ring->set_value ($value * 0.8); # 20% of the input values will vanish 98 $ring->set_value ($value);
98 99
99 } else { 100 } else {
100 $pl->message ("You fail!"); 101 $pl->message ("You fail!");
101 $ring->negate; 102 $ring->negate;
102 $make_status = "fail"; 103 $make_status = "fail";
112 "JEWELER AUDIT: '%s' made '%s' (%s) (sk lvl %d, ring lvl %d, got %d exp): %s", 113 "JEWELER AUDIT: '%s' made '%s' (%s) (sk lvl %d, ring lvl %d, got %d exp): %s",
113 $pl->name, $ring->to_string, $ring_ob->uuid, $sklvl, 114 $pl->name, $ring->to_string, $ring_ob->uuid, $sklvl,
114 $ring->power_to_level, $exp, $make_status; 115 $ring->power_to_level, $exp, $make_status;
115 116
116 warn "$make_info\n" if $make_status eq 'succeeded'; 117 warn "$make_info\n" if $make_status eq 'succeeded';
117
118 $ring_ob->set_ob_key_value (ext_jeweler_made_by => $pl->name);
119 $ring_ob->set_ob_key_value (ext_jeweler_make_info => $make_info);
120 } 118 }
121 119
122 $chdl->put ($ring_ob); 120 $chdl->put ($ring_ob);
123} 121}
124 122
152 if ($ringo->has_resist ($1)) { 150 if ($ringo->has_resist ($1)) {
153 $self->map->trigger ( 151 $self->map->trigger (
154 $cfg->{connection}, 152 $cfg->{connection},
155 $cfg->{state} 153 $cfg->{state}
156 ); 154 );
155 $obj->decrease (1);
157 cf::override; 156 cf::override;
158 } 157 }
159 } 158 }
160 } 159 }
161 } 160 }
196 unless ($Jeweler::CFG->{conversions}->{lc $1}) { 195 unless ($Jeweler::CFG->{conversions}->{lc $1}) {
197 $pl->message ("You don't know how to make '$1', is does such a thing even exist?"); 196 $pl->message ("You don't know how to make '$1', is does such a thing even exist?");
198 return 197 return
199 } 198 }
200 199
201 Jeweler::simple_converter ($player, $ingred, $chdl, $1); 200 Jeweler::simple_converter (
201 $player, $ingred, $chdl, $1,
202 cf::exp_to_level ($sk->stats->exp));
202 203
203 } elsif ($msg =~ m/^\s*merge\s*analy[sz]e\s*$/i) { 204 } elsif ($msg =~ m/^\s*merge\s*analy[sz]e\s*$/i) {
204 merge ($chdl, $sk, $pl, 1); 205 merge ($chdl, $sk, $pl, 1);
205 206
206 } elsif ($msg =~ m/^\s*merge\s*$/i) { 207 } elsif ($msg =~ m/^\s*merge\s*$/i) {
212 my $plan = $ingred->get_plan; 213 my $plan = $ingred->get_plan;
213 214
214 if ($plan) { 215 if ($plan) {
215 my @ring = $ingred->get_ring; 216 my @ring = $ingred->get_ring;
216 217
218 if (!@ring) {
219 # actually the algorithm cant
220 $pl->message ("You slap yourself, you forgot the jewelery!");
221 return;
222
217 if ((@ring > 1) || ($ring[0]->nrof > 1)) { 223 } elsif ((@ring > 1) || (grep { $_->nrof > 1 } @ring)) {
218 # actually the algorithm cant handle more than one improvement at a time 224 # actually the algorithm cant handle more than one improvement at a time
219 $pl->message ("You can't manage to improve more than one thing at a time!"); 225 $pl->message ("You can't manage to improve more than one thing at a time!");
220 return; 226 return;
221
222 } elsif (@ring < 1) {
223 # actually the algorithm cant
224 $pl->message ("You slap yourself, you forgot the jewelery!");
225 return;
226
227 } else { 227 } else {
228 my $ringo = Jeweler::Object->new (object => $ring[0]); 228 my $ringo = Jeweler::Object->new (object => $ring[0]);
229 my $iring = $ingred->improve_ring_by_plan ($plan, $ringo); 229 my $iring = $ingred->improve_ring_by_plan ($plan, $ringo);
230 my $c1 = $ringo->calc_costs; 230 my $c1 = $ringo->calc_costs;
231 my $c2 = $iring->calc_costs; 231 my $c2 = $iring->calc_costs;
273 }; 273 };
274 $@ and warn "ERROR: $@\n"; 274 $@ and warn "ERROR: $@\n";
275 } 275 }
276); 276);
277 277
278Jeweler::read_config "$DATADIR/jeweler.yaml"; 278Jeweler::read_config "res/jeweler.yaml";
279 279

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines