ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/chat.ext
(Generate patch)

Comparing deliantra/maps/perl/chat.ext (file contents):
Revision 1.16 by pippijn, Mon May 8 17:27:42 2006 UTC vs.
Revision 1.19 by root, Fri Jun 9 04:18:02 2006 UTC

2 2
3# implement a replacement for the built-in say/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
6sub valid_user($) { 6sub valid_user($) {
7 cf::player::find $_[0]
7 -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; 8 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2;
8} 9}
9 10
10sub clean_timeouts($) { 11sub clean_timeouts($) {
11 my ($player) = @_; 12 my ($player) = @_;
12 my $NOW = time; 13 my $NOW = time;
32 33
33cf::register_command listen => 0, sub { 34cf::register_command listen => 0, sub {
34 my ($who, $msg) = @_; 35 my ($who, $msg) = @_;
35 my $player = cf::player::find $who->name; 36 my $player = cf::player::find $who->name;
36 37
37 if ($msg) { 38 if ($msg ne "") {
38 my $prev_listen = $player->listening; 39 my $prev_listen = $player->listening;
39 $player->listening ($msg); 40 $player->listening ($msg);
40 if ($prev_listen == $player->listening) { 41 if ($prev_listen == $player->listening) {
41 $who->message ("Your verbose level stayed ".$prev_listen.".", cf::NDI_UNIQUE); 42 $who->message ("Your verbose level stayed ".$prev_listen.".", cf::NDI_UNIQUE);
42 } else { 43 } else {
64 65
65 if ($msg) { 66 if ($msg) {
66 my $name = $who->name; 67 my $name = $who->name;
67 my $NOW = time; 68 my $NOW = time;
68 69
70 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
71
69 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 72 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
70 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 73 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
71 74
72 } else { 75 } else {
73 $who->message ("Chat what?", cf::NDI_UNIQUE); 76 $who->message ("Chat what?", cf::NDI_UNIQUE);
78 my ($who, $msg) = @_; 81 my ($who, $msg) = @_;
79 82
80 if ($msg) { 83 if ($msg) {
81 my $NOW = time; 84 my $NOW = time;
82 my $name = $who->name; 85 my $name = $who->name;
86
87 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
83 88
84 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 89 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
85 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 90 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
86 91
87 } else { 92 } else {
102 if ($target eq $name) { 107 if ($target eq $name) {
103 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 108 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
104 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 109 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
105 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 110 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
106 } else { 111 } else {
112 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
113
107 $who->message ("You tell $target: $msg"); 114 $who->message ("You tell $target: $msg");
108 $other->ob->message ("$name tells you: $msg"); 115 $other->ob->message ("$name tells you: $msg");
109 $other->ob->{ext_last_tell} = $name; 116 $other->ob->{ext_last_tell} = $name;
110 } 117 }
111 } else { 118 } else {
126 133
127 $other->ob->{ext_ignore_tell}{$name} >= time 134 $other->ob->{ext_ignore_tell}{$name} >= time
128 or delete $other->ob->{ext_ignore_tell}{$name}; 135 or delete $other->ob->{ext_ignore_tell}{$name};
129 136
130 if ($other->ob->{ext_ignore_tell}{$name} < time) { 137 if ($other->ob->{ext_ignore_tell}{$name} < time) {
138 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
139
131 $who->message ("You tell " . $other->ob->name . ": $args"); 140 $who->message ("You tell " . $other->ob->name . ": $args");
132 $other->ob->message ("$name tells you: $args"); 141 $other->ob->message ("$name tells you: $args");
133 $who->{ext_last_tell} = $other->ob->name; 142 $who->{ext_last_tell} = $other->ob->name;
134 } else { 143 } else {
135 $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); 144 $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines