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.23 by root, Fri Jul 21 08:22:02 2006 UTC vs.
Revision 1.29 by elmex, Wed Aug 2 16:59:47 2006 UTC

47}; 47};
48 48
49cf::register_command say => 0, sub { 49cf::register_command say => 0, sub {
50 my ($who, $msg) = @_; 50 my ($who, $msg) = @_;
51 51
52 utf8::decode $msg;
53
52 if ($msg) { 54 if ($msg) {
53 my $name = $who->name; 55 my $name = $who->name;
54 56
57 utf8::encode $msg; # ->message not yet utf8-ified
55 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 58 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
56 for grep $who->on_same_map_as ($_->ob), cf::player::list; 59 for grep $who->on_same_map_as ($_->ob), cf::player::list;
60 utf8::decode $msg;
57 61
58 # npcs, magic_ears etc. 62 # npcs, magic_ears etc.
59 # first find all objects and their inventories within a 5x5 square 63 # first find all objects and their inventories within a 5x5 square
60 # that have something resembling dialogue 64 # that have something resembling dialogue
61 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 65 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2);
69 ) { 73 ) {
70 # if some listener teleported us somewhere else, stop right here 74 # if some listener teleported us somewhere else, stop right here
71 last unless $map->path == $who->map->path; 75 last unless $map->path == $who->map->path;
72 76
73 my $dialog = new NPC_Dialogue ob => $who, npc => $npc; 77 my $dialog = new NPC_Dialogue ob => $who, npc => $npc;
74 my $reply = $dialog->tell ($msg); 78 my ($reply, @kw) = $dialog->tell ($msg);
75 79
76 if (defined $reply) { 80 if (defined $reply) {
77 if ($npc->type == cf::MAGIC_EAR) { 81 if ($npc->type == cf::MAGIC_EAR) {
78 if (length $reply) { 82 if (length $reply) {
79 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) 83 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE)
85 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) 89 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE)
86 for grep $who->on_same_map_as ($_->ob), cf::player::list; 90 for grep $who->on_same_map_as ($_->ob), cf::player::list;
87 } 91 }
88 } 92 }
89 } 93 }
94
95 if (@kw) {
96 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE)
97 for grep $who->on_same_map_as ($_->ob), cf::player::list;
98 }
90 } 99 }
91 100
92 } else { 101 } else {
93 $who->message ("What do you want to say?", cf::NDI_UNIQUE); 102 $who->message ("What do you want to say?", cf::NDI_UNIQUE);
94 } 103 }
95}; 104};
96 105
97cf::register_command chat => 0, sub { 106cf::register_command chat => 0, sub {
98 my ($who, $msg) = @_; 107 my ($who, $msg) = @_;
108
109 utf8::decode $msg;
99 110
100 if ($msg) { 111 if ($msg) {
101 my $name = $who->name; 112 my $name = $who->name;
102 my $NOW = time; 113 my $NOW = time;
103 114
115 utf8::encode $msg; # ->message not yet utf8-ified
104 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 116 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
117 cf::ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg);
105 118
106 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 119 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
107 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 120 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
108 121
109 } else { 122 } else {
111 } 124 }
112}; 125};
113 126
114cf::register_command shout => 0, sub { 127cf::register_command shout => 0, sub {
115 my ($who, $msg) = @_; 128 my ($who, $msg) = @_;
129
130 utf8::decode $msg;
116 131
117 if ($msg) { 132 if ($msg) {
118 my $NOW = time; 133 my $NOW = time;
119 my $name = $who->name; 134 my $name = $who->name;
120 135
121 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 136 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
137 cf::ext::schmorp_irc::do_notice (sprintf "{%s} %s\n", $name, $msg);
122 138
139 utf8::encode $msg; # ->message not yet utf8-ified
123 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 140 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
124 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 141 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
125 142
126 } else { 143 } else {
127 $who->message ("Shout what?", cf::NDI_UNIQUE); 144 $who->message ("Shout what?", cf::NDI_UNIQUE);
130}; 147};
131 148
132cf::register_command tell => 0, sub { 149cf::register_command tell => 0, sub {
133 my ($who, $args) = @_; 150 my ($who, $args) = @_;
134 my ($target, $msg) = split /\s+/, $args, 2; 151 my ($target, $msg) = split /\s+/, $args, 2;
152
153 utf8::decode $msg;
135 154
136 my $name = $who->name; 155 my $name = $who->name;
137 156
138 if (my $other = cf::player::find $target) { 157 if (my $other = cf::player::find $target) {
139 158
141 if ($target eq $name) { 160 if ($target eq $name) {
142 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 161 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
143 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 162 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
144 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 163 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
145 } else { 164 } else {
165 utf8::encode $msg; # ->message not yet utf8-ified
146 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 166 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
147 167
148 $who->message ("You tell $target: $msg"); 168 $who->message ("You tell $target: $msg");
149 $other->ob->message ("$name tells you: $msg"); 169 $other->ob->message ("$name tells you: $msg");
150 $other->ob->{ext_last_tell} = $name; 170 $other->ob->{ext_last_tell} = $name;
160 180
161cf::register_command reply => 0, sub { 181cf::register_command reply => 0, sub {
162 my ($who, $args) = @_; 182 my ($who, $args) = @_;
163 my $name = $who->name; 183 my $name = $who->name;
164 184
185 utf8::decode $args;
186
165 if (my $other = cf::player::find $who->{ext_last_tell}) { 187 if (my $other = cf::player::find $who->{ext_last_tell}) {
166 if ($args) { 188 if ($args) {
167 189
168 $other->ob->{ext_ignore_tell}{$name} >= time 190 $other->ob->{ext_ignore_tell}{$name} >= time
169 or delete $other->ob->{ext_ignore_tell}{$name}; 191 or delete $other->ob->{ext_ignore_tell}{$name};
170 192
171 if ($other->ob->{ext_ignore_tell}{$name} < time) { 193 if ($other->ob->{ext_ignore_tell}{$name} < time) {
194 utf8::encode $args; # ->message not yet utf8-ified
172 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 195 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
173 196
174 $who->message ("You tell " . $other->ob->name . ": $args"); 197 $who->message ("You tell " . $other->ob->name . ": $args");
175 $other->ob->message ("$name tells you: $args"); 198 $other->ob->message ("$name tells you: $args");
176 $who->{ext_last_tell} = $other->ob->name; 199 $who->{ext_last_tell} = $other->ob->name;
271 294
272cf::register_command seen => 0, sub { 295cf::register_command seen => 0, sub {
273 my ($who, $args) = @_; 296 my ($who, $args) = @_;
274 297
275 if (my ($login) = $args =~ /(\S+)/) { 298 if (my ($login) = $args =~ /(\S+)/) {
299 if ($login eq $who->name) {
300 $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE);
276 if (cf::player::find $login) { 301 } elsif (cf::player::find $login) {
277 $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); 302 $who->message ("$login is right here on this server!", cf::NDI_UNIQUE);
278 } elsif (cf::player::exists $login 303 } elsif (cf::player::exists $login
279 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { 304 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) {
280 my $time = (stat _)[9]; 305 my $time = (stat _)[9];
281 306
282 $who->message ("$login was last seen here on " 307 $who->message ("$login was last seen here "
283 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 308 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
284 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); 309 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE);
285 } else { 310 } else {
286 $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); 311 $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE);
287 } 312 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines