ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/item-rate-limited-converter.ext
Revision: 1.2
Committed: Tue May 4 21:45:42 2010 UTC (14 years ago) by root
Branch: MAIN
CVS Tags: rel-3_1, rel-3_0, HEAD
Changes since 1.1: +0 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 elmex 1.1 #! perl
2    
3     # this module implements a rate limited converter, the hp attribute
4     # will stop the player for hp seconds. And the player is just able to drop 1 item
5     # on it at a time.
6    
7     our %TIMED_CONV_TIMERS;
8    
9     cf::object->attach (
10     type => cf::CONVERTER,
11     subtype => 2,
12     on_drop_on => sub {
13     my ($table, $obj, $orig) = @_;
14    
15     return unless $obj->number_of > 0;
16    
17     if ($obj->number_of > 1) {
18     my $rest = $obj->split ($obj->number_of - 1);
19     $orig->insert ($rest);
20     }
21     $orig->speed_left ($orig->speed_left - ($table->stats->hp * (8 * $orig->speed)));
22     $orig->message (
23     "You work hard changing items while the " . $table->name . " does it's work."
24     . "H<You are delayed around " . $table->stats->hp . " seconds.>",
25     cf::NDI_UNIQUE | cf::NDI_REPLY);
26     },
27     on_move_trigger => sub {
28     my ($trap, $vict, $orig) = @_;
29    
30     # make the converter not work when the player is not at the same spot:
31     unless ($orig->x == $trap->x
32     && $orig->y == $trap->y
33     && $orig->is_player
34     && $vict->number_of == 1) {
35     cf::override 1;
36     return;
37     }
38     },
39     );
40