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

Comparing deliantra/server/ext/chat.ext (file contents):
Revision 1.4 by pippijn, Wed Feb 28 19:13:23 2007 UTC vs.
Revision 1.38 by root, Sun Jan 13 09:50:40 2008 UTC

1#! perl 1#! perl # depends=irc mandatory
2#CONVERSION: PARTIAL
3 2
4# 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
5# adds ignore/unignore functionality 4# adds ignore/unignore functionality
6 5
7use NPC_Dialogue; 6use NPC_Dialogue;
8use POSIX (); # for strftime only 7use POSIX (); # for strftime only
8
9our $SAY_CHANNEL = {
10 id => "say",
11 title => "Map",
12 reply => "say ",
13 tooltip => "Things said to and replied from npcs near you and other players on the same map only.",
14};
15
16our $CHAT_CHANNEL = {
17 id => "chat",
18 title => "Chat",
19 reply => "chat ",
20 tooltip => "Player chat and shouts, global to the server.",
21};
22
23sub tell_channel($) {
24 my ($target) = @_;
25
26 {
27 id => "tell-$target",
28 title => "$target",
29 reply => "tell $target ",
30 tooltip => "Private messages from/to $target",
31 }
32}
33
34sub send_msg($$$$$) {
35 my ($pl, $channel, $msg, $flags, $sound) = @_;
36 $pl->play_sound (cf::sound::find $sound) if defined $sound;
37 $pl->send_msg ($channel, $msg, $flags);
38 ()
39}
9 40
10sub clean_timeouts($) { 41sub clean_timeouts($) {
11 my ($player) = @_; 42 my ($player) = @_;
12 my $NOW = time; 43 my $NOW = time;
13 44
14 for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) { 45 for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) {
15 while (my ($k, $v) = each %$hash) { 46 while (my ($k, $v) = each %$hash) {
16 if ($v < $NOW) { 47 if ($v < $NOW) {
17 $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN | cf::NDI_UNIQUE); 48 $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN);
18 delete $hash->{$k}; 49 delete $hash->{$k};
19 } elsif (!cf::player::exists $k) { 50 } elsif (!cf::player::exists $k) {
20 $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN | cf::NDI_UNIQUE); 51 $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN);
21 delete $hash->{$k}; 52 delete $hash->{$k};
22 } 53 }
23 } 54 }
24 } 55 }
25} 56}
26 57
58# send_irc ($format, @args, $msg)
59# make sure the last argument is the message!
60sub send_irc {
61 my ($format, @args) = @_;
62 my $msg = pop @args;
63 for (split /\n/, $msg) {
64 ext::irc::do_notice (sprintf $format, @args, $_)
65 }
66}
67
27cf::player->attach ( 68cf::player->attach (
28 prio => -1000, 69 prio => -1000,
29 on_login => sub { 70 on_login => sub {
30 my ($pl) = @_; 71 my ($pl) = @_;
31 72
32 clean_timeouts $pl->ob; 73 clean_timeouts $pl->ob;
33 },
34 74
35 1 75 $pl->send_msg ($SAY_CHANNEL);
76 $pl->send_msg ($CHAT_CHANNEL);
77 },
36); 78);
37 79
38cf::register_command listen => sub { 80cf::register_command listen => sub {
39 my ($who, $msg) = @_; 81 my ($pl, $msg) = @_;
40 my $player = cf::player::find_active $who->name; 82 my $player = cf::player::find_active $pl->name;
41 83
42 if ($msg ne "") { 84 if ($msg ne "") {
85 $msg = 10 if $msg > 10;
86
43 my $prev_listen = $player->listening; 87 my $prev_listen = $player->listening;
44 $player->listening ($msg); 88 $player->listening ($msg);
45 if ($prev_listen == $player->listening) { 89 if ($prev_listen == $player->listening) {
46 $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); 90 $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_REPLY);
47 } else { 91 } else {
48 $who->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); 92 $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_REPLY);
49 } 93 }
50 } else { 94 } else {
51 $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); 95 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_REPLY);
52 } 96 }
97};
53 98
99cf::register_command cointoss => sub {
100 my ($ob, $msg) = @_;
101
102 my $pl = $ob->contr;
103 my $name = $ob->name;
104
105 my $coin = int rand 2 ? "Heads" : "Tails";
106
107 send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say"
108 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
54 1 109
110 $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY);
111};
112
113cf::register_command orcknuckle => sub {
114 my ($ob, $msg) = @_;
115
116 my $pl = $ob->contr;
117 my $name = $ob->name;
118
119 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
120 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6);
121 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
122
123 send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say"
124 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
125
126 $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY);
55}; 127};
56 128
57my $emotes = { 129my $emotes = {
58 growl => { 130 growl => {
59 noparams => { 131 noparams => {
60 other => "<self> growls." 132 other => "<self> growls.",
61 self => "Grrrrrrrrr...." 133 self => "Grrrrrrrrr....",
62 }, 134 },
63 params => { 135 params => {
64 }, 136 },
65 self => { 137 self => {
66 }, 138 },
67 }, 139 },
68 giggle => { 140 giggle => {
69 noparams => { 141 noparams => {
70 other => "<self> giggles." 142 other => "<self> giggles.",
71 self => "You giggle." 143 self => "You giggle.",
72 }, 144 },
73 params => { 145 params => {
74 }, 146 },
75 self => { 147 self => {
76 }, 148 },
77 }, 149 },
78 shiver => { 150 shiver => {
79 noparams => { 151 noparams => {
80 other => "<self> shivers uncomfortably." 152 other => "<self> shivers uncomfortably.",
81 self => "Brrrrrrrrr." 153 self => "Brrrrrrrrr.",
82 }, 154 },
83 params => { 155 params => {
84 }, 156 },
85 self => { 157 self => {
86 }, 158 },
87 }, 159 },
88 chuckle => { 160 chuckle => {
89 noparams => { 161 noparams => {
90 other => "<self> chuckles politely." 162 other => "<self> chuckles politely.",
91 self => "You chuckle politely" 163 self => "You chuckle politely",
92 }, 164 },
93 params => { 165 params => {
94 }, 166 },
95 self => { 167 self => {
96 }, 168 },
97 }, 169 },
98 sigh => { 170 sigh => {
99 noparams => { 171 noparams => {
100 other => "<self> sighs loudly." 172 other => "<self> sighs loudly.",
101 self => "You sigh." 173 self => "You sigh.",
102 }, 174 },
103 params => { 175 params => {
104 }, 176 },
105 self => { 177 self => {
106 }, 178 },
107 }, 179 },
108 scream => { 180 scream => {
109 noparams => { 181 noparams => {
110 other => "<self> screams at the top of his lungs!" 182 other => "<self> screams at the top of his lungs!",
111 self => "ARRRRRRRRRRGH!!!!!" 183 self => "ARRRRRRRRRRGH!!!!!",
112 }, 184 },
113 params => { 185 params => {
114 }, 186 },
115 self => { 187 self => {
116 }, 188 },
117 }, 189 },
118 puke => { 190 puke => {
119 noparams => { 191 noparams => {
120 other => "<self> pukes." 192 other => "<self> pukes.",
121 self => "Bleaaaaaghhhhhhh!" 193 self => "Bleaaaaaghhhhhhh!",
122 }, 194 },
123 params => { 195 params => {
124 target => "<self> pukes on your clothes!" 196 target => "<self> pukes on your clothes!",
125 other => "<self> pukes on <other>." 197 other => "<self> pukes on <other>.",
126 self => "You puke on <other>." 198 self => "You puke on <other>.",
127 }, 199 },
128 self => { 200 self => {
129 other => "<self> pukes on his clothes." 201 other => "<self> pukes on his clothes.",
130 self => "You puke on yourself." 202 self => "You puke on yourself.",
131 }, 203 },
132 }, 204 },
133 strut => { 205 strut => {
134 noparams => { 206 noparams => {
135 other => "<self> struts proudly." 207 other => "<self> struts proudly.",
136 self => "Strut your stuff." 208 self => "Strut your stuff.",
137 }, 209 },
138 params => { 210 params => {
139 }, 211 },
140 self => { 212 self => {
141 }, 213 },
142 }, 214 },
143 cringe => { 215 cringe => {
144 noparams => { 216 noparams => {
145 other => "<self> cringes in terror!" 217 other => "<self> cringes in terror!",
146 self => "You cringe in terror." 218 self => "You cringe in terror.",
147 }, 219 },
148 params => { 220 params => {
149 target => "<self> cringes away from <other> in mortal terror." 221 target => "<self> cringes away from <other> in mortal terror.",
150 self => "You cringe away from <other>." 222 self => "You cringe away from <other>.",
151 }, 223 },
152 self => { 224 self => {
153 }, 225 },
154 }, 226 },
155 hiccup => { 227 hiccup => {
156 noparams => { 228 noparams => {
157 other => "<self> hiccups." 229 other => "<self> hiccups.",
158 self => "*HIC*" 230 self => "*HIC*",
159 }, 231 },
160 params => { 232 params => {
161 }, 233 },
162 self => { 234 self => {
163 }, 235 },
164 }, 236 },
165 clap => { 237 clap => {
166 noparams => { 238 noparams => {
167 other => "<self> gives a round of applause." 239 other => "<self> gives a round of applause.",
168 self => "Clap, clap, clap." 240 self => "Clap, clap, clap.",
169 }, 241 },
170 params => { 242 params => {
171 }, 243 },
172 self => { 244 self => {
173 }, 245 },
174 }, 246 },
175 kiss => { 247 kiss => {
176 noparams => { 248 noparams => {
177 other => "<self> makes a weird facial contortion" 249 other => "<self> makes a weird facial contortion",
178 self => "All the lonely people.." 250 self => "All the lonely people..",
179 }, 251 },
180 params => { 252 params => {
181 target => "<self> kisses you." 253 target => "<self> kisses you.",
182 other => "<self> kisses <other>." 254 other => "<self> kisses <other>.",
183 self => "You kiss <other>." 255 self => "You kiss <other>.",
256 },
257 self => {
258 },
259 },
260 smother => {
261 noparams => {
262 other => "<self> makes weird facial contortions",
263 self => "All the lonely people..",
264 },
265 params => {
266 target => "<self> smothers you with kisses.",
267 other => "<self> smothers <other> with kisses.",
268 self => "You smother <other> with kisses.",
184 }, 269 },
185 self => { 270 self => {
186 }, 271 },
187 }, 272 },
188 wink => { 273 wink => {
189 noparams => { 274 noparams => {
190 other => "<self> winks suggestively." 275 other => "<self> winks suggestively.",
191 self => "Have you got something in your eye?" 276 self => "Have you got something in your eye?",
192 }, 277 },
193 params => { 278 params => {
279 target => "<self> winks at you.",
194 target => "<self> winks at <other>." 280 other => "<self> winks at <other>.",
195 self => "You wink suggestively at <other>." 281 self => "You wink suggestively at <other>.",
196 }, 282 },
197 self => { 283 self => {
198 other => "<self> winks at himself - something strange is going on..." 284 other => "<self> winks at himself - something strange is going on...",
199 self => "You wink at yourself?? What are you up to?" 285 self => "You wink at yourself?? What are you up to?",
200 }, 286 },
201 }, 287 },
202 pout => { 288 pout => {
203 noparams => { 289 noparams => {
204 other => "<self> pouts." 290 other => "<self> pouts.",
205 self => "Aww, don't take it so hard." 291 self => "Aww, don't take it so hard.",
206 }, 292 },
207 params => { 293 params => {
208 }, 294 },
209 self => { 295 self => {
210 }, 296 },
211 }, 297 },
212 cackle => { 298 cackle => {
213 noparams => { 299 noparams => {
214 other => "<self> throws back his head and cackles with insane glee!" 300 other => "<self> throws back his head and cackles with insane glee!",
215 self => "You cackle gleefully." 301 self => "You cackle gleefully.",
216 }, 302 },
217 params => { 303 params => {
218 }, 304 },
219 self => { 305 self => {
220 }, 306 },
221 }, 307 },
222 sniff => { 308 sniff => {
223 noparams => { 309 noparams => {
224 other => "<self> sniffs sadly." 310 other => "<self> sniffs sadly.",
225 self => "You sniff sadly. *SNIFF*" 311 self => "You sniff sadly. *SNIFF*",
226 }, 312 },
227 params => { 313 params => {
228 target => "<self> sniffs you." 314 target => "<self> sniffs you.",
229 other => "<self> sniffs <other>" 315 other => "<self> sniffs <other>",
230 self => "You sniff <other>." 316 self => "You sniff <other>.",
231 }, 317 },
232 self => { 318 self => {
233 other => "<self> sniffs himself." 319 other => "<self> sniffs himself.",
234 self => "You sniff yourself." 320 self => "You sniff yourself.",
235 }, 321 },
236 }, 322 },
237 nod => { 323 nod => {
238 noparams => { 324 noparams => {
239 other => "<self> nods solemnly." 325 other => "<self> nods solemnly.",
240 self => "You nod solemnly." 326 self => "You nod solemnly.",
241 }, 327 },
242 params => { 328 params => {
243 target => "<self> nods solemnly to you." 329 target => "<self> nods solemnly to you.",
244 other => "<self> nods solemnly to <other>." 330 other => "<self> nods solemnly to <other>.",
245 self => "You nod solemnly to <other>." 331 self => "You nod solemnly to <other>.",
246 }, 332 },
247 self => { 333 self => {
248 }, 334 },
249 }, 335 },
250 frown => { 336 frown => {
251 noparams => { 337 noparams => {
252 other => "<self> frowns." 338 other => "<self> frowns.",
253 self => "What's bothering you?" 339 self => "What's bothering you?",
254 }, 340 },
255 params => { 341 params => {
256 target => "<self> frowns darkly at you." 342 target => "<self> frowns darkly at you.",
257 other => "<self> frowns darkly at <other>." 343 other => "<self> frowns darkly at <other>.",
258 self => "You frown darkly at <other>." 344 self => "You frown darkly at <other>.",
259 }, 345 },
260 self => { 346 self => {
261 other => "<self> frowns at himself." 347 other => "<self> frowns at himself.",
262 self => "You frown at yourself." 348 self => "You frown at yourself.",
263 }, 349 },
264 }, 350 },
265 snicker => { 351 snicker => {
266 noparams => { 352 noparams => {
267 other => "<self> snickers softly." 353 other => "<self> snickers softly.",
268 self => "You snicker softly." 354 self => "You snicker softly.",
269 }, 355 },
270 params => { 356 params => {
271 }, 357 },
272 self => { 358 self => {
273 }, 359 },
274 }, 360 },
275 shrug => { 361 shrug => {
276 noparams => { 362 noparams => {
277 other => "<self> shrugs helplessly." 363 other => "<self> shrugs helplessly.",
278 self => "You shrug." 364 self => "You shrug.",
279 }, 365 },
280 params => { 366 params => {
281 target => "<self> shrugs at you." 367 target => "<self> shrugs at you.",
282 other => "<self> shrugs at <other>." 368 other => "<self> shrugs at <other>.",
283 self => "You shrug at <other>." 369 self => "You shrug at <other>.",
284 }, 370 },
285 self => { 371 self => {
286 }, 372 },
287 }, 373 },
288 bleed => { 374 bleed => {
289 noparams => { 375 noparams => {
290 other => "<self> is bleeding all over the carpet - got a spare tourniquet?" 376 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
291 self => "You bleed all over your nice new armour." 377 self => "You bleed all over your nice new armour.",
292 }, 378 },
293 params => { 379 params => {
380 target => "<self> slashes his wrist and bleeds all over you.",
294 target => "<self> slashes his wrist and bleeds all over <other>." 381 other => "<self> slashes his wrist and bleeds all over <other>.",
295 self => "You slash your wrist and bleed all over <other>" 382 self => "You slash your wrist and bleed all over <other>",
296 }, 383 },
297 self => { 384 self => {
298 other => "<self> performs some satanic ritual while wiping his blood on himself." 385 other => "<self> performs some satanic ritual while wiping his blood on himself.",
299 self => "Very impressive! You wipe your blood all over yourself." 386 self => "Very impressive! You wipe your blood all over yourself.",
300 }, 387 },
301 }, 388 },
302 twiddle => { 389 twiddle => {
303 noparams => { 390 noparams => {
304 other => "<self> patiently twiddles his thumbs." 391 other => "<self> patiently twiddles his thumbs.",
305 self => "You patiently twiddle your thumbs." 392 self => "You patiently twiddle your thumbs.",
306 }, 393 },
307 params => { 394 params => {
308 }, 395 },
309 self => { 396 self => {
310 }, 397 },
311 }, 398 },
312 spit => { 399 spit => {
313 noparams => { 400 noparams => {
314 other => "<self> spits over his left shoulder." 401 other => "<self> spits over his left shoulder.",
315 self => "You spit over your left shoulder." 402 self => "You spit over your left shoulder.",
316 }, 403 },
317 params => { 404 params => {
318 target => "<self> spits in your face!" 405 target => "<self> spits in your face!",
319 other => "<self> spits in <other>'s face." 406 other => "<self> spits in <other>'s face.",
320 self => "You spit on <other>." 407 self => "You spit on <other>.",
321 }, 408 },
322 self => { 409 self => {
323 other => "<self> drools all over himself." 410 other => "<self> drools all over himself.",
324 self => "You drool all over yourself." 411 self => "You drool all over yourself.",
325 }, 412 },
326 }, 413 },
327 glare => { 414 glare => {
328 noparams => { 415 noparams => {
329 other => "<self> glares around him." 416 other => "<self> glares around him.",
330 self => "You glare at nothing in particular." 417 self => "You glare at nothing in particular.",
331 }, 418 },
332 params => { 419 params => {
333 target => "<self> glares icily at you, you feel cold to your bones." 420 target => "<self> glares icily at you, you feel cold to your bones.",
334 other => "<self> glares at <other>." 421 other => "<self> glares at <other>.",
335 self => "You glare icily at <other>." 422 self => "You glare icily at <other>.",
336 }, 423 },
337 self => { 424 self => {
338 other => "<self> glares at his feet, what is bothering him?" 425 other => "<self> glares at his feet, what is bothering him?",
339 self => "You glare icily at your feet, they are suddenly very cold." 426 self => "You glare icily at your feet, they are suddenly very cold.",
340 }, 427 },
341 }, 428 },
342 bow => { 429 bow => {
343 noparams => { 430 noparams => {
344 other => "<self> bows deeply." 431 other => "<self> bows deeply.",
345 self => "You bow deeply." 432 self => "You bow deeply.",
346 }, 433 },
347 params => { 434 params => {
348 target => "<self> bows before you." 435 target => "<self> bows before you.",
349 other => "<self> bows before <other>." 436 other => "<self> bows before <other>.",
350 self => "You bow before <other>." 437 self => "You bow before <other>.",
351 }, 438 },
352 self => { 439 self => {
353 other => "<self> folds up like a jackknife and kisses his own toes." 440 other => "<self> folds up like a jackknife and kisses his own toes.",
354 self => "You kiss your toes." 441 self => "You kiss your toes.",
355 }, 442 },
356 }, 443 },
357 dance => { 444 dance => {
358 noparams => { 445 noparams => {
359 other => "<self> expresses himself through interpretive dance." 446 other => "<self> expresses himself through interpretive dance.",
360 self => "You dance with glee." 447 self => "You dance with glee.",
361 }, 448 },
362 params => { 449 params => {
363 target => "<self> grabs you, and begins dancing!" 450 target => "<self> grabs you, and begins dancing!",
364 other => "Yipe! <self> and <other> are doing the Macarena!" 451 other => "Yipe! <self> and <other> are doing the Macarena!",
365 self => "You grab <other> and begin doing the Cha-Cha!" 452 self => "You grab <other> and begin doing the Cha-Cha!",
366 }, 453 },
367 self => { 454 self => {
368 other => "<self> embraces himself and begins to dance!" 455 other => "<self> embraces himself and begins to dance!",
369 self => "You skip and dance around by yourself." 456 self => "You skip and dance around by yourself.",
370 },
371 },
372 other => {
373 noparams => {
374 other => "<self> dances with glee."
375 self => "You are a nut."
376 },
377 params => {
378 target => "You get the distinct feeling that <other> is nuts."
379 other => "<self> is eyeing <other> quizzically."
380 self => "You are still nuts."
381 },
382 self => {
383 other => "You look away from <self>."
384 self => "My god! Is that LEGAL?"
385 }, 457 },
386 }, 458 },
387 snore => { 459 snore => {
388 noparams => { 460 noparams => {
389 other => "<self> snores loudly." 461 other => "<self> snores loudly.",
390 self => "Zzzzzzzzzzzzzzz." 462 self => "Zzzzzzzzzzzzzzz.",
391 }, 463 },
392 params => { 464 params => {
393 }, 465 },
394 self => { 466 self => {
395 }, 467 },
396 }, 468 },
397 blush => { 469 blush => {
398 noparams => { 470 noparams => {
399 other => "<self> blushes." 471 other => "<self> blushes.",
400 self => "Your cheeks are burning." 472 self => "Your cheeks are burning.",
401 }, 473 },
402 params => { 474 params => {
403 }, 475 },
404 self => { 476 self => {
405 }, 477 },
406 }, 478 },
407 snap => { 479 snap => {
408 noparams => { 480 noparams => {
409 other => "<self> snaps his fingers." 481 other => "<self> snaps his fingers.",
410 self => "PRONTO! you snap your fingers." 482 self => "PRONTO! you snap your fingers.",
411 }, 483 },
412 params => { 484 params => {
413 }, 485 },
414 self => { 486 self => {
415 }, 487 },
416 }, 488 },
417 wave => { 489 wave => {
418 noparams => { 490 noparams => {
419 other => "<self> waves happily." 491 other => "<self> waves happily.",
420 self => "You wave." 492 self => "You wave.",
421 }, 493 },
422 params => { 494 params => {
423 target => "<self> waves goodbye to you. Have a good journey." 495 target => "<self> waves goodbye to you. Have a good journey.",
424 other => "<self> waves goodbye to <other>." 496 other => "<self> waves goodbye to <other>.",
425 self => "You wave goodbye to <other>." 497 self => "You wave goodbye to <other>.",
426 }, 498 },
427 self => { 499 self => {
428 other => "<self> waves goodbye to himself." 500 other => "<self> waves goodbye to himself.",
429 self => "Are you going on adventures as well??" 501 self => "Are you going on adventures as well??",
430 }, 502 },
431 }, 503 },
432 smile => { 504 smile => {
433 noparams => { 505 noparams => {
434 other => "<self> smiles happily." 506 other => "<self> smiles happily.",
435 self => "You smile happily." 507 self => "You smile happily.",
436 }, 508 },
437 params => { 509 params => {
438 target => "<self> smiles at you." 510 target => "<self> smiles at you.",
439 other => "<self> beams a smile at <other>." 511 other => "<self> beams a smile at <other>.",
440 self => "You smile at <other>." 512 self => "You smile at <other>.",
441 }, 513 },
442 self => { 514 self => {
443 }, 515 },
444 }, 516 },
445 sneeze => { 517 sneeze => {
446 noparams => { 518 noparams => {
447 other => "<self> sneezes." 519 other => "<self> sneezes.",
448 self => "Gesundheit!" 520 self => "Gesundheit!",
449 }, 521 },
450 params => { 522 params => {
451 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW." 523 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.",
452 other => "<self> sneezes on <other> and a film of snot covers him." 524 other => "<self> sneezes on <other> and a film of snot covers him.",
453 self => "You sneeze at <other> and a film of snot shoots onto him." 525 self => "You sneeze at <other> and a film of snot shoots onto him.",
454 }, 526 },
455 self => { 527 self => {
456 other => "<self> sneezes, and covers himself in a slimy substance." 528 other => "<self> sneezes, and covers himself in a slimy substance.",
457 self => "You sneeze on yourself, what a mess!" 529 self => "You sneeze on yourself, what a mess!",
458 }, 530 },
459 }, 531 },
460 bounce => { 532 bounce => {
461 noparams => { 533 noparams => {
462 other => "<self> bounces around." 534 other => "<self> bounces around.",
463 self => "BOIINNNNNNGG!" 535 self => "BOIINNNNNNGG!",
464 }, 536 },
465 params => { 537 params => {
466 target => "<self> bounces around the room with you." 538 target => "<self> bounces around the room with you.",
467 other => "<self> bounces around the room with <other>." 539 other => "<self> bounces around the room with <other>.",
468 self => "You bounce around the room with <other>." 540 self => "You bounce around the room with <other>.",
469 }, 541 },
470 self => { 542 self => {
471 }, 543 },
472 }, 544 },
473 shake => { 545 shake => {
474 noparams => { 546 noparams => {
475 other => "<self> shakes his head." 547 other => "<self> shakes his head.",
476 self => "You shake your head." 548 self => "You shake your head.",
477 }, 549 },
478 params => { 550 params => {
479 target => "<self> shakes your hand." 551 target => "<self> shakes your hand.",
480 other => "<self> shakes <other>'s hand." 552 other => "<self> shakes <other>'s hand.",
481 self => "You shake <other>'s hand." 553 self => "You shake <other>'s hand.",
482 }, 554 },
483 self => { 555 self => {
484 other => "<self> shakes and quivers like a bowlful of jelly." 556 other => "<self> shakes and quivers like a bowlful of jelly.",
485 self => "You are shaken by yourself." 557 self => "You are shaken by yourself.",
486 }, 558 },
487 }, 559 },
488 lick => { 560 lick => {
489 noparams => { 561 noparams => {
490 other => "<self> licks his mouth and smiles." 562 other => "<self> licks his mouth and smiles.",
491 self => "You lick your mouth and smile." 563 self => "You lick your mouth and smile.",
492 }, 564 },
493 params => { 565 params => {
494 target => "<self> licks you." 566 target => "<self> licks you.",
495 other => "<self> licks <other>." 567 other => "<self> licks <other>.",
496 self => "You lick <other>." 568 self => "You lick <other>.",
497 }, 569 },
498 self => { 570 self => {
499 other => "<self> licks himself - YUCK." 571 other => "<self> licks himself - YUCK.",
500 self => "You lick yourself." 572 self => "You lick yourself.",
501 }, 573 },
502 }, 574 },
503 flip => { 575 flip => {
504 noparams => { 576 noparams => {
505 other => "<self> flips head over heels." 577 other => "<self> flips head over heels.",
506 self => "You flip head over heels." 578 self => "You flip head over heels.",
507 }, 579 },
508 params => { 580 params => {
509 }, 581 },
510 self => { 582 self => {
511 }, 583 },
512 }, 584 },
513 think => { 585 think => {
514 noparams => { 586 noparams => {
515 other => "<self> closes his eyes and thinks really hard." 587 other => "<self> closes his eyes and thinks really hard.",
516 self => "Anything in particular that you'd care to think about?" 588 self => "Anything in particular that you'd care to think about?",
517 }, 589 },
518 params => { 590 params => {
519 }, 591 },
520 self => { 592 self => {
521 }, 593 },
522 }, 594 },
523 yawn => { 595 yawn => {
524 noparams => { 596 noparams => {
525 other => "<self> yawns sleepily." 597 other => "<self> yawns sleepily.",
526 self => "You open up your yap and let out a big breeze of stale air." 598 self => "You open up your yap and let out a big breeze of stale air.",
527 }, 599 },
528 params => { 600 params => {
529 }, 601 },
530 self => { 602 self => {
531 }, 603 },
532 }, 604 },
533 laugh => { 605 laugh => {
534 noparams => { 606 noparams => {
535 other => "<self> falls down laughing." 607 other => "<self> falls down laughing.",
536 self => "You fall down laughing." 608 self => "You fall down laughing.",
537 }, 609 },
538 params => { 610 params => {
539 target => "<self> looks at you and falls down on the ground laughing." 611 target => "<self> looks at you and falls down on the ground laughing.",
540 other => "<self> looks at <other> and falls down on the ground laughing." 612 other => "<self> looks at <other> and falls down on the ground laughing.",
541 self => "You take one look at <other> and fall down laughing." 613 self => "You take one look at <other> and fall down laughing.",
542 }, 614 },
543 self => { 615 self => {
544 other => "<self> is laughing at something." 616 other => "<self> is laughing at something.",
545 self => "Laugh at yourself all you want, the others won't understand." 617 self => "Laugh at yourself all you want, the others won't understand.",
546 }, 618 },
547 }, 619 },
548 burp => { 620 burp => {
549 noparams => { 621 noparams => {
550 other => "<self> burps loudly." 622 other => "<self> burps loudly.",
551 self => "You burp loudly." 623 self => "You burp loudly.",
552 }, 624 },
553 params => { 625 params => {
554 }, 626 },
555 self => { 627 self => {
556 }, 628 },
557 }, 629 },
558 gasp => { 630 gasp => {
559 noparams => { 631 noparams => {
560 other => "<self> gasps in astonishment." 632 other => "<self> gasps in astonishment.",
561 self => "You gasp in astonishment." 633 self => "You gasp in astonishment.",
562 }, 634 },
563 params => { 635 params => {
564 }, 636 },
565 self => { 637 self => {
566 }, 638 },
567 }, 639 },
568 smirk => { 640 smirk => {
569 noparams => { 641 noparams => {
570 other => "<self> smirks." 642 other => "<self> smirks.",
571 self => "You smirk." 643 self => "You smirk.",
572 }, 644 },
573 params => { 645 params => {
574 }, 646 },
575 self => { 647 self => {
576 }, 648 },
577 }, 649 },
578 cry => { 650 cry => {
579 noparams => { 651 noparams => {
580 other => "<self> bursts into tears." 652 other => "<self> bursts into tears.",
581 self => "Waaaaaaahhh.." 653 self => "Waaaaaaahhh..",
582 }, 654 },
583 params => { 655 params => {
584 target => "<self> cries on your shoulder." 656 target => "<self> cries on your shoulder.",
585 other => "<self> cries on <other>'s shoulder." 657 other => "<self> cries on <other>'s shoulder.",
586 self => "You cry on <other>'s shoulder." 658 self => "You cry on <other>'s shoulder.",
587 }, 659 },
588 self => { 660 self => {
589 other => "<self> sobs quietly to himself." 661 other => "<self> sobs quietly to himself.",
590 self => "You cry to yourself." 662 self => "You cry to yourself.",
591 }, 663 },
592 }, 664 },
593 sulk => { 665 sulk => {
594 noparams => { 666 noparams => {
595 other => "<self> sulks in the corner." 667 other => "<self> sulks in the corner.",
596 self => "You sulk." 668 self => "You sulk.",
597 }, 669 },
598 params => { 670 params => {
599 }, 671 },
600 self => { 672 self => {
601 }, 673 },
602 }, 674 },
603 whistle => { 675 whistle => {
604 noparams => { 676 noparams => {
605 other => "<self> whistles appreciatively." 677 other => "<self> whistles appreciatively.",
606 self => "You whistle appreciatively." 678 self => "You whistle appreciatively.",
607 }, 679 },
608 params => { 680 params => {
609 target => "<self> whistles at <other>." 681 target => "<self> whistles at <other>.",
610 self => "You whistle at <other>." 682 self => "You whistle at <other>.",
611 }, 683 },
612 self => { 684 self => {
613 other => "<self> whistles to himself in boredom." 685 other => "<self> whistles to himself in boredom.",
614 self => "You whistle while you work." 686 self => "You whistle while you work.",
615 }, 687 },
616 }, 688 },
617 groan => { 689 groan => {
618 noparams => { 690 noparams => {
619 other => "<self> groans loudly." 691 other => "<self> groans loudly.",
620 self => "You groan loudly." 692 self => "You groan loudly.",
621 }, 693 },
622 params => { 694 params => {
623 }, 695 },
624 self => { 696 self => {
625 }, 697 },
626 }, 698 },
627 cough => { 699 cough => {
628 noparams => { 700 noparams => {
629 other => "<self> coughs loudly." 701 other => "<self> coughs loudly.",
630 self => "Yuck, try to cover your mouth next time!" 702 self => "Yuck, try to cover your mouth next time!",
631 }, 703 },
632 params => { 704 params => {
633 }, 705 },
634 self => { 706 self => {
635 }, 707 },
636 }, 708 },
637 grin => { 709 grin => {
638 noparams => { 710 noparams => {
639 other => "<self> grins evilly." 711 other => "<self> grins evilly.",
640 self => "You grin evilly." 712 self => "You grin evilly.",
641 }, 713 },
642 params => { 714 params => {
643 target => "<self> grins evilly at you." 715 target => "<self> grins evilly at you.",
644 other => "<self> grins evilly at <other>." 716 other => "<self> grins evilly at <other>.",
645 self => "You grin at <other>." 717 self => "You grin at <other>.",
646 },
647 self => {
648 },
649 }, 718 },
719 self => {
720 },
721 },
650}; 722};
723
651for my $emotion (keys %$emotes) { 724for my $emotion (keys %$emotes) {
652 cf::register_command $emotion => sub { 725 cf::register_command $emotion => sub {
653 my ($ob, $tname) = @_; 726 my ($ob, $tname) = @_;
727
728 my $pl = $ob->contr;
654 729
655 cf::async { 730 cf::async {
656 my $name = $ob->name; 731 my $name = $ob->name;
732 $Coro::current->{desc} = "emote handler for $name";
657 733
658 if ($tname eq $name) { 734 if ($tname eq $name) {
659 my $emote = $emotes->{$emotion}->{self}; 735 my %emote = %{ $emotes->{$emotion}->{self} || {} };
736
737 $emote{other} ||= "You look away from <self>.";
738 $emote{self} ||= "My god! Is that LEGAL?";
739
660 $emote->{other} =~ s/<self>/$name/; 740 $emote{other} =~ s/<self>/$name/;
661 741
742 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat"
662 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 743 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
663 next
664 if $other->ob == $ob;
665 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
666 }
667 744
668 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 745 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
669 } elsif ($tname) { 746 } elsif ($tname) {
670 my $target = cf::player::find $tname 747 my $target = cf::player::find $tname
671 or return $ob->reply (undef, "$tname is not around."); 748 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
672 749
673 my $emote = $emotes->{$emotion}->{params}; 750 my %emote = %{ $emotes->{$emotion}->{params} || {} };
751
752 $emote{other} ||= "<self> is eyeing <other> quizzically.";
753 $emote{self} ||= "You are still nuts.";
754 $emote{target} ||= "You get the distinct feeling that <self> is nuts.";
755
674 $emote->{self} =~ s/<other>/$tname/; 756 $emote{self} =~ s/<other>/$tname/;
675 $emote->{target} =~ s/<self>/$name/; 757 $emote{target} =~ s/<self>/$name/;
676 $emote->{other} =~ s/<other>/$tname/; 758 $emote{other} =~ s/<other>/$tname/;
677 $emote->{other} =~ s/<self>/$name/; 759 $emote{other} =~ s/<self>/$name/;
678 760
679 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 761 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat"
680 next 762 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
681 if $other->ob == $ob or $other == $target;
682 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
683 }
684 763
685 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE); 764 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout";
686 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 765 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
687 } else { 766 } else {
688 my $emote = $emotes->{$emotion}->{noparams}; 767 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
689 $emote->{other} =~ s/<self>/$name/; 768
769 $emote{other} ||= "<self> dances with glee.";
770 $emote{self} ||= "You are a nut.";
690 771
772 $emote{other} =~ s/<self>/$name/;
773
774 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat"
691 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 775 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
692 next
693 if $other->ob == $ob;
694 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
695 }
696 776
697 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 777 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
698 } 778 }
699 }; 779 };
700
701 1
702 }; 780 };
703} 781}
704 782
783cf::register_command me => sub {
784 my ($pl, $msg) = @_;
785
786 my $name = $pl->name;
787
788 send_msg $_, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say"
789 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
790};
791
705cf::register_command say => sub { 792cf::register_command say => sub {
706 my ($who, $msg) = @_; 793 my ($ob, $msg) = @_;
707 794
708 utf8::decode $msg; 795 utf8::decode $msg;
709 796
710 return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 797 return if $ob->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
711 798
712 if ($msg) { 799 if ($msg) {
713 my $name = $who->name; 800 my $name = $ob->name;
714
715 utf8::encode $msg; # ->message not yet utf8-ified
716 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
717 for grep $who->on_same_map_as ($_->ob), cf::player::list; 801 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
718 utf8::decode $msg; 802
803 send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
804 for grep $_ != $ob->contr, @plonmap;
805 $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
719 806
720 # npcs, magic_ears etc. 807 # npcs, magic_ears etc.
721 # first find all objects and theirt-level inventories 808 # first find all objects and their first-level inventories
722 # within a 5x5 square # that have something resembling 809 # within a 5x5 square that have something resembling
723 # dialogue or support on_say. 810 # dialogue or support on_say.
724 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 811 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
725 812
726 for my $npc ( 813 for my $npc (
727 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 814 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
728 map +($_, $_->inv), 815 map +($_, $_->inv),
729 grep $_, 816 grep $_,
730 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 817 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
731 0..24 818 0..24
732 ) { 819 ) {
733 # if some listener teleported us somewhere else, stop right here 820 # if some listener teleported us somewhere else, stop right here
734 last unless $map->path == $who->map->path; 821 last unless $map->path == $ob->map->path;
735 822
736 my $dialog = new NPC_Dialogue ob => $who, npc => $npc; 823 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
737 my ($reply, @kw) = $dialog->tell ($msg); 824 my ($reply, @kw) = $dialog->tell ($msg);
738 825
739 if (defined $reply) { 826 if (defined $reply) {
740 if ($npc->type == cf::MAGIC_EAR) { 827 if ($npc->type == cf::MAGIC_EAR) {
741 if (length $reply) { 828 if (length $reply) {
742 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) 829 send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
743 for grep $who->on_same_map_as ($_->ob), cf::player::list; 830 for @plonmap;
744 } 831 }
745 $npc->use_trigger; 832 $npc->use_trigger;
746 } else { 833 } else {
747 if (length $reply) { 834 if (length $reply) {
748 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) 835 send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
749 for grep $who->on_same_map_as ($_->ob), cf::player::list; 836 for @plonmap;
750 } 837 }
751 } 838 }
752 } 839 }
753 840
754 if (@kw) { 841 if (@kw) {
755 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) 842 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
756 for grep $who->on_same_map_as ($_->ob), cf::player::list; 843 for @plonmap;
757 } 844 }
758 } 845 }
759 846
760 } else { 847 } else {
761 $who->message ("What do you want to say?", cf::NDI_UNIQUE); 848 $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
762 } 849 }
763
764 1
765}; 850};
766 851
767cf::register_command chat => sub { 852cf::register_command chat => sub {
768 my ($who, $msg) = @_; 853 my ($ob, $msg) = @_;
769 854
770 utf8::decode $msg; 855 utf8::decode $msg;
771 856
857 my $pl = $ob->contr;
858
772 return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); 859 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg);
773 860
774 if ($msg) { 861 if ($msg) {
775 my $name = $who->name; 862 my $name = $ob->name;
776 my $NOW = time; 863 my $NOW = time;
777 864
778 utf8::encode $msg; # ->message not yet utf8-ified
779 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 865 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
780 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 866 send_irc ("[%s] %s", $name, $msg);
781 867
782 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 868 send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
783 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 869 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
784 870
785 } else { 871 } else {
786 $who->message ("Chat what?", cf::NDI_UNIQUE); 872 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
787 } 873 }
788
789 1
790}; 874};
791 875
792cf::register_command shout => sub { 876cf::register_command shout => sub {
793 my ($who, $msg) = @_; 877 my ($ob, $msg) = @_;
794 878
795 utf8::decode $msg; 879 utf8::decode $msg;
796 880
881 my $pl = $ob->contr;
882
797 return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); 883 return if $pl->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
798 884
799 if ($msg) { 885 if ($msg) {
800 my $NOW = time; 886 my $NOW = time;
801 my $name = $who->name; 887 my $name = $ob->name;
802 888
803 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 889 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
804 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); 890 send_irc ("\007\0034{%s} %s\n", $name, $msg);
805 891
806 utf8::encode $msg; # ->message not yet utf8-ified 892 send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
807 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
808 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 893 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
809 894
810 } else { 895 } else {
811 $who->message ("Shout what?", cf::NDI_UNIQUE); 896 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
812 } 897 }
813
814 1
815}; 898};
816 899
817cf::register_command tell => sub { 900cf::register_command tell => sub {
818 my ($who, $args) = @_; 901 my ($ob, $args) = @_;
819 my ($target, $msg) = split /\s+/, $args, 2; 902 my ($target, $msg) = split /\s+/, $args, 2;
820 903
821 utf8::decode $msg; 904 utf8::decode $msg;
822 905
823 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); 906 my $pl = $ob->contr;
824 907 my $ns = $pl->ns
908 or return;
825 my $name = $who->name; 909 my $name = $ob->name;
910
911 return if $pl->invoke (cf::EVENT_PLAYER_TELL, $target, $msg);
912
913 my $pl_channel = tell_channel $target;
826 914
827 if ($target =~ /irc\//) { 915 if ($target =~ /irc\//) {
828 my (undef, $nick) = split /\//, $target, 2; 916 my (undef, $nick) = split /\//, $target, 2;
829 $who->message ("You tell $target: $args"); 917 $ns->send_msg ($pl_channel => "You tell $target: $args", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
830 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); 918 send_irc ("(%s) %s: %s\n", $name, $nick, $msg);
919
831 } elsif (my $other = cf::player::find_active $target) { 920 } elsif (my $other = cf::player::find_active $target) {
921 my $other_channel = tell_channel $name;
832 922
833 if ($msg) { 923 if ($msg) {
834 if ($target eq $name) { 924 if ($target eq $name) {
835 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 925 $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
836 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 926 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
837 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 927 $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
838 } else { 928 } else {
839 utf8::encode $msg; # ->message not yet utf8-ified 929 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
840 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 930 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
841 931
842 $who->message ("You tell $target: $msg"); 932 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
843 $other->ob->message ("$name tells you: $msg"); 933 send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell";
844 $other->ob->{ext_last_tell} = $name;
845 } 934 }
846 } else { 935 } else {
847 $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); 936 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
848 } 937 }
849 938
850 } else { 939 } else {
851 $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); 940 $ns->send_msg ($pl_channel => "No such player. Your message: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
852 } 941 }
853
854 1
855}; 942};
856 943
857cf::register_command reply => sub { 944cf::register_command ignore => sub {
858 my ($who, $args) = @_; 945 my ($pl, $args) = @_;
859 my $name = $who->name; 946 my ($target, $type, $timeout) = split /\s+/, $args;
860 947
861 utf8::decode $args; 948 if ($args eq "list") {
949 clean_timeouts $pl;
862 950
863 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); 951 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
952 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
953 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
954 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY);
955 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
956 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY);
957 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY);
958 } else {
959 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
960 }
864 961
865 if ($who->{ext_last_tell} =~ /irc\//) { 962 } elsif ($target && $type) {
866 my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2;
867 $who->message ("You tell " . $who->{ext_last_tell} . ": $args");
868 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args);
869 } elsif (my $other = cf::player::find_active $who->{ext_last_tell}) {
870 963
871 if ($args) { 964 $timeout ne "" or $timeout = 24;
872 $other->ob->{ext_ignore_tell}{$name} >= time 965 my $absolute_timeout = time + $timeout * 3600;
873 or delete $other->ob->{ext_ignore_tell}{$name};
874 966
875 if ($other->ob->{ext_ignore_tell}{$name} < time) { 967 if (cf::player::exists $target) {
876 utf8::encode $args; # ->message not yet utf8-ified 968 if ($type eq "tell") {
877 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 969 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
878 970 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
879 $who->message ("You tell " . $other->ob->name . ": $args"); 971 } elsif ($type eq "shout") {
880 $other->ob->message ("$name tells you: $args"); 972 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
881 $who->{ext_last_tell} = $other->ob->name; 973 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
974 } elsif ($type eq "all") {
975 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
976 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
977 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
882 } else { 978 } else {
883 $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); 979 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
884 } 980 }
885 } else { 981 } else {
886 $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); 982 $pl->message ("No such player: $target", cf::NDI_REPLY);
887 } 983 }
888 984
889 } else { 985 } else {
890 $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE);
891 }
892
893 1
894};
895
896cf::register_command ignore => sub {
897 my ($who, $args) = @_;
898 my ($target, $type, $timeout) = split /\s+/, $args;
899
900 if ($args eq "list") {
901 clean_timeouts $who;
902
903 if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}})
904 + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) {
905 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
906 $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE);
907 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
908 $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE);
909 $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE);
910 } else {
911 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE);
912 }
913
914 } elsif ($target && $type) {
915
916 $timeout ne "" or $timeout = 24;
917 my $absolute_timeout = time + $timeout * 3600;
918
919 if (cf::player::exists $target) {
920 if ($type eq "tell") {
921 $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE);
922 $who->{ext_ignore_tell}{$target} = $absolute_timeout;
923 } elsif ($type eq "shout") {
924 $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE);
925 $who->{ext_ignore_shout}{$target} = $absolute_timeout;
926 } elsif ($type eq "all") {
927 $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE);
928 $who->{ext_ignore_tell}{$target} = $absolute_timeout;
929 $who->{ext_ignore_shout}{$target} = $absolute_timeout;
930 } else {
931 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
932 }
933 } else {
934 $who->message ("No such player: $target", cf::NDI_UNIQUE);
935 }
936
937 } else {
938 $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" 986 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
939 . "will ignore a player for <timeout> hours.\n" 987 . "will ignore a player for <timeout> hours.\n"
940 . "Usage: ignore list\n" 988 . "Usage: ignore list\n"
941 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); 989 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
942 } 990 }
943
944 1
945}; 991};
946 992
947cf::register_command unignore => sub { 993cf::register_command unignore => sub {
948 my ($who, $args) = @_; 994 my ($pl, $args) = @_;
949 my ($target, $type) = split /\s+/, $args; 995 my ($target, $type) = split /\s+/, $args;
950 996
951 if ($args eq "") { 997 if ($args eq "") {
952 if ($who->{ext_ignore_tell}) { 998 if ($pl->{ext_ignore_tell}) {
953 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 999 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
954 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); 1000 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY);
955 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 1001 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
956 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); 1002 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY);
957 } else { 1003 } else {
958 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 1004 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
959 } 1005 }
960 } else { 1006 } else {
961 if (cf::player::exists $target) { 1007 if (cf::player::exists $target) {
962 if ($type eq "tell") { 1008 if ($type eq "tell") {
963 $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); 1009 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
964 delete $who->{ext_ignore_tell} {$target}; 1010 delete $pl->{ext_ignore_tell} {$target};
965 } elsif ($type eq "shout") { 1011 } elsif ($type eq "shout") {
966 $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); 1012 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
967 delete $who->{ext_ignore_shout}{$target}; 1013 delete $pl->{ext_ignore_shout}{$target};
968 } elsif ($type eq "all") { 1014 } elsif ($type eq "all") {
969 $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); 1015 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
970 delete $who->{ext_ignore_tell} {$target}; 1016 delete $pl->{ext_ignore_tell} {$target};
971 delete $who->{ext_ignore_shout}{$target}; 1017 delete $pl->{ext_ignore_shout}{$target};
972 } else { 1018 } else {
973 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 1019 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
974 } 1020 }
975 } else { 1021 } else {
976 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 1022 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY);
977 } 1023 }
978 } 1024 }
979
980 1
981}; 1025};
982 1026
983cf::register_command seen => sub {
984 my ($who, $args) = @_;
985
986 if (my ($login) = $args =~ /(\S+)/) {
987 if ($login eq $who->name) {
988 $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE);
989 } elsif (cf::player::find_active $login) {
990 $who->message ("$login is right here on this server!", cf::NDI_UNIQUE);
991 } elsif (cf::player::exists $login
992 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) {
993 my $time = (stat _)[9];
994
995 $who->message ("$login was last seen here "
996 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
997 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE);
998 } else {
999 $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE);
1000 }
1001 } else {
1002 $who->message ("Usage: seen <player>", cf::NDI_UNIQUE);
1003 }
1004
1005 1
1006};
1007

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines