1 | #! perl |
1 | #! perl |
2 | |
|
|
3 | my $price_fact = 50; |
|
|
4 | |
2 | |
5 | sub set_package { |
3 | sub set_package { |
6 | my ($pkg, $from, $to, $bagname, $weight) = @_; |
4 | my ($pkg, $from, $to, $bagname, $weight) = @_; |
7 | |
5 | |
8 | $pkg->name ("$bagname T: $to F: $from"); |
6 | $pkg->name ("$bagname T: $to F: $from"); |
9 | $pkg->weight_limit ($weight); |
7 | $pkg->weight_limit ($weight); |
10 | $pkg->stats->Str (0); |
8 | $pkg->stats->Str (0); |
11 | } |
9 | } |
12 | |
10 | |
13 | # prices in plat. |
11 | # prices [in silver] |
14 | my %prices = ( |
12 | my %prices = ( |
15 | pen => [ |
13 | pen => [ |
16 | 40, 'stylus', |
14 | 10000, 'stylus', |
17 | sub { $_[0]->name ('IPO Writing Pen'); $_[0]->value (0); } |
15 | sub { $_[0]->name ('IPO Writing Pen'); $_[0]->value (0); } |
18 | ], |
16 | ], |
19 | literacy => [ |
17 | literacy => [ |
20 | 1000, 'scroll_literacy', |
18 | 10000, 'scroll_literacy', |
21 | sub { $_[0]->value (0) } |
19 | sub { $_[0]->value (0) } |
22 | ], |
20 | ], |
23 | mailscroll => [ |
21 | mailscroll => [ |
24 | 1, 'mailscroll_empty', |
22 | 50, 'mailscroll_empty', |
25 | sub { |
23 | sub { |
26 | $_[0]->name ("mailscroll T: $_[2] F: $_[1]"); |
24 | $_[0]->name ("mailscroll T: $_[2] F: $_[1]"); |
27 | $_[0]->name_pl ("mailscrolls T: $_[2] F: $_[1]"); |
25 | $_[0]->name_pl ("mailscrolls T: $_[2] F: $_[1]"); |
28 | $_[0]->value (0); |
26 | $_[0]->value (0); |
29 | }, |
27 | }, |
30 | 'plarg' |
28 | 'plarg' |
31 | ], |
29 | ], |
32 | bag => [ 1, 'r_sack', sub { set_package (@_, bag => 5000) }, 'plarg' ], |
30 | bag => [ 100, 'r_sack', sub { set_package (@_, bag => 5000) }, 'plarg' ], |
33 | package => [ 5, 'r_sack', sub { set_package (@_, package => 50000) }, 'plarg' ], |
31 | package => [ 1000, 'r_sack', sub { set_package (@_, package => 50000) }, 'plarg' ], |
34 | carton => [10, 'r_sack', sub { set_package (@_, carton => 100000) }, 'plarg' ], |
32 | carton => [ 2000, 'r_sack', sub { set_package (@_, carton => 100000) }, 'plarg' ], |
35 | mailwarning => [ |
33 | mailwarning => [ |
36 | 0, 'diploma', |
34 | 0, 'diploma', |
37 | sub { |
35 | sub { |
38 | $_[0]->name ("mailwarning T: $_[2] F: $_[1]"); |
36 | $_[0]->name ("mailwarning T: $_[2] F: $_[1]"); |
39 | $_[0]->name_pl ("mailwarnings T: $_[2] F: $_[1]"); |
37 | $_[0]->name_pl ("mailwarnings T: $_[2] F: $_[1]"); |
… | |
… | |
175 | if (my $pr = $prices{$cmd}) { |
173 | if (my $pr = $prices{$cmd}) { |
176 | if ($cmd eq 'mailwarning' and !$who->flag (cf::FLAG_WIZ)) { |
174 | if ($cmd eq 'mailwarning' and !$who->flag (cf::FLAG_WIZ)) { |
177 | return 1; |
175 | return 1; |
178 | } |
176 | } |
179 | |
177 | |
180 | if ($who->pay_amount ($pr->[0] * $price_fact)) { |
178 | if ($who->pay_amount ($pr->[0])) { |
|
|
179 | cf::async { |
181 | if ($pr->[3] && not cf::player::exists $arguments) { |
180 | if ($pr->[3] && not cf::player::exists $arguments) { |
182 | $who->reply ($npc, "Sorry, there is no '$arguments'"); |
181 | $who->reply ($npc, "Sorry, there is no '$arguments'"); |
183 | } else { |
182 | } else { |
184 | create_object ($pr->[1], $who->map, $x, $y, $pr->[2], $who->name, $arguments); |
183 | create_object ($pr->[1], $who->map, $x, $y, $pr->[2], $who->name, $arguments); |
185 | $who->reply ($npc, "Here is your $cmd"); |
184 | $who->reply ($npc, "Here is your $cmd"); |
|
|
185 | } |
186 | } |
186 | } |
187 | } else { |
187 | } else { |
188 | $who->reply ($npc, "Sorry, you don't have enough money."); |
188 | $who->reply ($npc, "Sorry, you don't have enough money."); |
189 | } |
189 | } |
190 | |
190 | |
… | |
… | |
234 | my $cnt; |
234 | my $cnt; |
235 | for ($who->inv) { |
235 | for ($who->inv) { |
236 | if ($_->name () =~ /^(bag|package|carton) T: \Q$arguments\E F: (\S+)$/) { |
236 | if ($_->name () =~ /^(bag|package|carton) T: \Q$arguments\E F: (\S+)$/) { |
237 | $_->name ("$1 F: $2 T: $arguments"); |
237 | $_->name ("$1 F: $2 T: $arguments"); |
238 | $storage->insert ($_, 2, 2); |
238 | $storage->insert ($_, 2, 2); |
239 | $who->esrv_del_item ($_->count); |
|
|
240 | $cnt++; |
239 | $cnt++; |
241 | } |
240 | } |
242 | } |
241 | } |
243 | |
242 | |
244 | if ($cnt) { |
243 | if ($cnt) { |
… | |
… | |
252 | |
251 | |
253 | } else { |
252 | } else { |
254 | $who->reply ($npc, |
253 | $who->reply ($npc, |
255 | sprintf "How can I help you?\n" |
254 | sprintf "How can I help you?\n" |
256 | . "Here is a quick list of commands I understand:\n\n" |
255 | . "Here is a quick list of commands I understand:\n\n" |
257 | . "- pen (%s platinum)\n" |
256 | . " - pen (%s)\n" |
258 | . "- literacy (%s platinum)\n" |
257 | . " - literacy (%s)\n" |
259 | . "- mailscroll <friend> (%s platinum)\n" |
258 | . " - mailscroll <friend> (%s)\n" |
260 | . "- bag <friend> (%s platinum)\n" |
259 | . " - bag <friend> (%s)\n" |
261 | . "- package <friend> (%s platinum)\n" |
260 | . " - package <friend> (%s)\n" |
262 | . "- carton <friend> (%s platinum)\n" |
261 | . " - carton <friend> (%s)\n" |
263 | . "- send <friend> (send bags/packages/cartons)\n" |
262 | . " - send <friend> (send bags/packages/cartons)\n" |
264 | . "- receive (to receive packages for you)\n" |
263 | . " - receive (to receive packages for you)\n" |
265 | . ($who->flag (cf::FLAG_WIZ) ? "- mailwarning <player>" : ""), |
264 | . ($who->flag (cf::FLAG_WIZ) ? " - mailwarning <player>\n" : ""), |
266 | 40, 1000, 1, 1, 5, 10 |
265 | cf::cost_string_from_value($prices{'pen'}[0]), |
|
|
266 | cf::cost_string_from_value($prices{'literacy'}[0]), |
|
|
267 | cf::cost_string_from_value($prices{'mailscroll'}[0]), |
|
|
268 | cf::cost_string_from_value($prices{'bag'}[0]), |
|
|
269 | cf::cost_string_from_value($prices{'package'}[0]), |
|
|
270 | cf::cost_string_from_value($prices{'carton'}[0]) |
267 | ); |
271 | ); |
268 | } |
272 | } |
269 | 1 |
273 | 1 |
270 | }; |
274 | }; |
271 | |
275 | |
… | |
… | |
294 | } |
298 | } |
295 | |
299 | |
296 | sub send_mail { |
300 | sub send_mail { |
297 | my ($type, $toname, $fromname, $message) = @_; |
301 | my ($type, $toname, $fromname, $message) = @_; |
298 | my $time = strftime ("%a, %d %b %Y %H:%M:%S CEST", localtime (time)); |
302 | my $time = strftime ("%a, %d %b %Y %H:%M:%S CEST", localtime (time)); |
299 | my $msg = "From: $fromname\nTo: $toname\nDate: $time\n\n$message\n"; |
303 | my $msg = "From: $fromname\rTo: $toname\rDate: $time\n\n$message\n"; |
300 | store_mail ($type, $toname, $fromname, $msg); |
304 | store_mail ($type, $toname, $fromname, $msg); |
301 | } |
305 | } |
302 | |
306 | |
303 | 1; |
307 | 1; |
|
|
308 | |