1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # implement a replacement for the built-in chat/shout/tell/reply commands |
3 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
4 | # adds ignore/unignore functionality |
4 | # adds ignore/unignore functionality |
5 | |
5 | |
6 | sub valid_user($) { |
6 | sub valid_user($) { |
7 | -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; |
7 | -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; |
8 | } |
8 | } |
… | |
… | |
28 | my ($pl, $host) = @_; |
28 | my ($pl, $host) = @_; |
29 | |
29 | |
30 | clean_timeouts $pl->ob; |
30 | clean_timeouts $pl->ob; |
31 | } |
31 | } |
32 | |
32 | |
|
|
33 | cf::register_command listen => 0, sub { |
|
|
34 | my ($who, $msg) = @_; |
|
|
35 | my $player = cf::player::find $who->name; |
|
|
36 | |
|
|
37 | if ($msg) { |
|
|
38 | my $prev_listen = $player->listening; |
|
|
39 | $player->listening ($msg); |
|
|
40 | if ($prev_listen == $player->listening) { |
|
|
41 | $who->message ("Your verbose level stayed ".$prev_listen.".", cf::NDI_UNIQUE); |
|
|
42 | } else { |
|
|
43 | $who->message ("Your verbose level is now ".$player->listening.". (previously: ".$prev_listen.")", cf::NDI_UNIQUE); |
|
|
44 | } |
|
|
45 | } else { |
|
|
46 | $who->message ("Your verbose level is ".$player->listening.".", cf::NDI_UNIQUE); |
|
|
47 | } |
|
|
48 | }; |
|
|
49 | |
|
|
50 | cf::register_command say => 0, sub { |
|
|
51 | my ($who, $msg) = @_; |
|
|
52 | |
|
|
53 | if ($msg) { |
|
|
54 | my $name = $who->name; |
|
|
55 | $_->ob->message ("$name says: $msg", cf::NDI_WHITE) |
|
|
56 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
|
|
57 | } else { |
|
|
58 | $who->message ("What do you want to say?", cf::NDI_UNIQUE); |
|
|
59 | } |
|
|
60 | }; |
|
|
61 | |
33 | cf::register_command chat => 0, sub { |
62 | cf::register_command chat => 0, sub { |
34 | my ($who, $msg) = @_; |
63 | my ($who, $msg) = @_; |
35 | |
64 | |
36 | if ($msg) { |
65 | if ($msg) { |
37 | my $name = $who->name; |
66 | my $name = $who->name; |
38 | my $NOW = time; |
67 | my $NOW = time; |
39 | |
68 | |
40 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
69 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
41 | for grep $_->ob->{ext_ignore_shout}{$name} < $NOW, cf::player::list; |
70 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
42 | |
71 | |
43 | } else { |
72 | } else { |
44 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
73 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
45 | } |
74 | } |
46 | }; |
75 | }; |
… | |
… | |
51 | if ($msg) { |
80 | if ($msg) { |
52 | my $NOW = time; |
81 | my $NOW = time; |
53 | my $name = $who->name; |
82 | my $name = $who->name; |
54 | |
83 | |
55 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
84 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
56 | for grep $_->ob->{ext_ignore_shout}{$name} < $NOW, cf::player::list; |
85 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
57 | |
86 | |
58 | } else { |
87 | } else { |
59 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
88 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
60 | } |
89 | } |
61 | |
90 | |