… | |
… | |
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"); |
|
|
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"; |
103 | $exp = 0; |
104 | $exp = 0; |
104 | } |
105 | } |
105 | |
106 | |
106 | my $ring_ob = $ring->to_object; |
107 | my $ring_ob = $ring->to_object; |
107 | |
108 | |
|
|
109 | $ring_ob->kv_set (ext_jeweler_maker => $pl->name); |
|
|
110 | |
108 | { # some audit info calculation |
111 | { # some audit info calculation |
109 | my $sklvl = cf::exp_to_level ($sk->stats->exp); |
112 | my $sklvl = cf::exp_to_level ($sk->stats->exp); |
110 | |
113 | |
111 | my $make_info = sprintf |
114 | my $make_info = sprintf |
112 | "JEWELER AUDIT: '%s' made '%s' (%s) (sk lvl %d, ring lvl %d, got %d exp): %s", |
115 | "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, |
116 | $pl->name, $ring->to_string, $ring_ob->uuid, $sklvl, |
114 | $ring->power_to_level, $exp, $make_status; |
117 | $ring->power_to_level, $exp, $make_status; |
115 | |
118 | |
|
|
119 | cf::debug "$make_info\n" |
116 | warn "$make_info\n" if $make_status eq 'succeeded'; |
120 | if $make_status eq 'succeeded'; |
117 | } |
121 | } |
118 | |
122 | |
119 | $chdl->put ($ring_ob); |
123 | $chdl->put ($ring_ob); |
120 | } |
124 | } |
121 | |
125 | |
… | |
… | |
127 | return |
131 | return |
128 | } elsif ($@ =~ /unidentified/) { |
132 | } elsif ($@ =~ /unidentified/) { |
129 | $pl->message ("There are unidentified items in the workbench, identify them before you do anything."). |
133 | $pl->message ("There are unidentified items in the workbench, identify them before you do anything."). |
130 | return |
134 | return |
131 | } elsif ($@) { |
135 | } elsif ($@) { |
132 | warn "error in jeweler ingredient extraction: $@"; |
136 | cf::error "error in jeweler ingredient extraction: $@"; |
133 | return; |
137 | return; |
134 | } |
138 | } |
135 | $ingred; |
139 | $ingred; |
136 | } |
140 | } |
137 | |
141 | |
… | |
… | |
194 | unless ($Jeweler::CFG->{conversions}->{lc $1}) { |
198 | unless ($Jeweler::CFG->{conversions}->{lc $1}) { |
195 | $pl->message ("You don't know how to make '$1', is does such a thing even exist?"); |
199 | $pl->message ("You don't know how to make '$1', is does such a thing even exist?"); |
196 | return |
200 | return |
197 | } |
201 | } |
198 | |
202 | |
199 | Jeweler::simple_converter ($player, $ingred, $chdl, $1); |
203 | Jeweler::simple_converter ( |
|
|
204 | $player, $ingred, $chdl, $1, |
|
|
205 | cf::exp_to_level ($sk->stats->exp)); |
200 | |
206 | |
201 | } elsif ($msg =~ m/^\s*merge\s*analy[sz]e\s*$/i) { |
207 | } elsif ($msg =~ m/^\s*merge\s*analy[sz]e\s*$/i) { |
202 | merge ($chdl, $sk, $pl, 1); |
208 | merge ($chdl, $sk, $pl, 1); |
203 | |
209 | |
204 | } elsif ($msg =~ m/^\s*merge\s*$/i) { |
210 | } elsif ($msg =~ m/^\s*merge\s*$/i) { |
… | |
… | |
266 | } else { |
272 | } else { |
267 | $pl->message ("You've got no idea what you are planning to do!"); |
273 | $pl->message ("You've got no idea what you are planning to do!"); |
268 | } |
274 | } |
269 | } |
275 | } |
270 | }; |
276 | }; |
271 | $@ and warn "ERROR: $@\n"; |
277 | $@ and cf::error "$@\n"; |
272 | } |
278 | } |
273 | ); |
279 | ); |
274 | |
280 | |
275 | Jeweler::read_config "res/jeweler.yaml"; |
281 | Jeweler::load_config; |
276 | |
282 | |