1 | #! perl # depends=irc mandatory |
1 | #! perl # depends=irc mandatory |
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 commands |
4 | # adds ignore/unignore functionality |
4 | # adds ignore/unignore functionality |
5 | |
5 | |
6 | use NPC_Dialogue; |
6 | use NPC_Dialogue; |
7 | use POSIX (); # for strftime only |
7 | use POSIX (); # for strftime only |
8 | |
|
|
9 | our $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 | |
|
|
16 | our $CHAT_CHANNEL = { |
|
|
17 | id => "chat", |
|
|
18 | title => "Chat", |
|
|
19 | reply => "chat ", |
|
|
20 | tooltip => "Player chat and shouts, global to the server.", |
|
|
21 | }; |
|
|
22 | |
8 | |
23 | sub tell_channel($) { |
9 | sub tell_channel($) { |
24 | my ($target) = @_; |
10 | my ($target) = @_; |
25 | |
11 | |
26 | { |
12 | { |
27 | id => "tell-$target", |
13 | id => "tell-$target", |
28 | title => "$target", |
14 | title => "$target", |
29 | reply => "tell $target ", |
15 | reply => "tell $target ", |
30 | tooltip => "Private messages from/to $target", |
16 | tooltip => "Private messages from/to $target", |
31 | } |
17 | } |
|
|
18 | } |
|
|
19 | |
|
|
20 | sub send_msg($$$$$) { |
|
|
21 | my ($pl, $channel, $msg, $flags, $sound) = @_; |
|
|
22 | $pl->play_sound (cf::sound::find $sound) if defined $sound; |
|
|
23 | $pl->send_msg ($channel, $msg, $flags); |
|
|
24 | () |
32 | } |
25 | } |
33 | |
26 | |
34 | sub clean_timeouts($) { |
27 | sub clean_timeouts($) { |
35 | my ($player) = @_; |
28 | my ($player) = @_; |
36 | my $NOW = time; |
29 | my $NOW = time; |
… | |
… | |
62 | prio => -1000, |
55 | prio => -1000, |
63 | on_login => sub { |
56 | on_login => sub { |
64 | my ($pl) = @_; |
57 | my ($pl) = @_; |
65 | |
58 | |
66 | clean_timeouts $pl->ob; |
59 | clean_timeouts $pl->ob; |
|
|
60 | |
67 | $pl->ns->send_msg ($SAY_CHANNEL); |
61 | $pl->send_msg ($cf::SAY_CHANNEL); |
68 | $pl->ns->send_msg ($CHAT_CHANNEL); |
62 | $pl->send_msg ($cf::CHAT_CHANNEL); |
69 | }, |
63 | }, |
70 | ); |
64 | ); |
71 | |
65 | |
|
|
66 | # TODO: remove once safe |
72 | cf::register_command listen => sub { |
67 | cf::register_command listen => sub { |
73 | my ($pl, $msg) = @_; |
|
|
74 | my $player = cf::player::find_active $pl->name; |
|
|
75 | |
|
|
76 | if ($msg ne "") { |
|
|
77 | $msg = 10 if $msg > 10; |
|
|
78 | |
|
|
79 | my $prev_listen = $player->listening; |
|
|
80 | $player->listening ($msg); |
|
|
81 | if ($prev_listen == $player->listening) { |
|
|
82 | $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_REPLY); |
|
|
83 | } else { |
|
|
84 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_REPLY); |
|
|
85 | } |
|
|
86 | } else { |
|
|
87 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_REPLY); |
|
|
88 | } |
|
|
89 | }; |
68 | }; |
90 | |
69 | |
91 | cf::register_command cointoss => sub { |
70 | cf::register_command cointoss => sub { |
92 | my ($ob, $msg) = @_; |
71 | my ($ob, $msg) = @_; |
93 | |
72 | |
94 | my $pl = $ob->contr; |
73 | my $pl = $ob->contr; |
95 | my $name = $ob->name; |
74 | my $name = $ob->name; |
96 | |
75 | |
97 | my $coin = int rand 2 ? "Heads" : "Tails"; |
76 | my $coin = int rand 2 ? "Heads" : "Tails"; |
98 | |
77 | |
99 | $_->ns->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) |
78 | send_msg $_, $cf::SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" |
100 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
79 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
101 | |
80 | |
102 | $pl->ns->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
81 | $pl->send_msg ($cf::SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
103 | }; |
82 | }; |
104 | |
83 | |
105 | cf::register_command orcknuckle => sub { |
84 | cf::register_command orcknuckle => sub { |
106 | my ($ob, $msg) = @_; |
85 | my ($ob, $msg) = @_; |
107 | |
86 | |
… | |
… | |
110 | |
89 | |
111 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
90 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
112 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
91 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
113 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
92 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
114 | |
93 | |
115 | $_->ns->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) |
94 | send_msg $_, $cf::SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" |
116 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
95 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
117 | |
96 | |
118 | $pl->ns->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
97 | $pl->send_msg ($cf::SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
119 | }; |
98 | }; |
120 | |
99 | |
121 | my $emotes = { |
100 | my $emotes = { |
122 | growl => { |
101 | growl => { |
123 | noparams => { |
102 | noparams => { |
… | |
… | |
169 | self => { |
148 | self => { |
170 | }, |
149 | }, |
171 | }, |
150 | }, |
172 | scream => { |
151 | scream => { |
173 | noparams => { |
152 | noparams => { |
174 | other => "<self> screams at the top of his lungs!", |
153 | other => "<self> screams at the top of G<his|her> lungs!", |
175 | self => "ARRRRRRRRRRGH!!!!!", |
154 | self => "ARRRRRRRRRRGH!!!!!", |
176 | }, |
155 | }, |
177 | params => { |
156 | params => { |
178 | }, |
157 | }, |
179 | self => { |
158 | self => { |
… | |
… | |
188 | target => "<self> pukes on your clothes!", |
167 | target => "<self> pukes on your clothes!", |
189 | other => "<self> pukes on <other>.", |
168 | other => "<self> pukes on <other>.", |
190 | self => "You puke on <other>.", |
169 | self => "You puke on <other>.", |
191 | }, |
170 | }, |
192 | self => { |
171 | self => { |
193 | other => "<self> pukes on his clothes.", |
172 | other => "<self> pukes on G<his|her> clothes.", |
194 | self => "You puke on yourself.", |
173 | self => "You puke on yourself.", |
195 | }, |
174 | }, |
196 | }, |
175 | }, |
197 | strut => { |
176 | strut => { |
198 | noparams => { |
177 | noparams => { |
… | |
… | |
247 | self => "You kiss <other>.", |
226 | self => "You kiss <other>.", |
248 | }, |
227 | }, |
249 | self => { |
228 | self => { |
250 | }, |
229 | }, |
251 | }, |
230 | }, |
|
|
231 | smother => { |
|
|
232 | noparams => { |
|
|
233 | other => "<self> makes weird facial contortions", |
|
|
234 | self => "All the lonely people..", |
|
|
235 | }, |
|
|
236 | params => { |
|
|
237 | target => "<self> smothers you with kisses.", |
|
|
238 | other => "<self> smothers <other> with kisses.", |
|
|
239 | self => "You smother <other> with kisses.", |
|
|
240 | }, |
|
|
241 | self => { |
|
|
242 | }, |
|
|
243 | }, |
252 | wink => { |
244 | wink => { |
253 | noparams => { |
245 | noparams => { |
254 | other => "<self> winks suggestively.", |
246 | other => "<self> winks suggestively.", |
255 | self => "Have you got something in your eye?", |
247 | self => "Have you got something in your eye?", |
256 | }, |
248 | }, |
… | |
… | |
258 | target => "<self> winks at you.", |
250 | target => "<self> winks at you.", |
259 | other => "<self> winks at <other>.", |
251 | other => "<self> winks at <other>.", |
260 | self => "You wink suggestively at <other>.", |
252 | self => "You wink suggestively at <other>.", |
261 | }, |
253 | }, |
262 | self => { |
254 | self => { |
263 | other => "<self> winks at himself - something strange is going on...", |
255 | other => "<self> winks at G<him|her>self - something strange is going on...", |
264 | self => "You wink at yourself?? What are you up to?", |
256 | self => "You wink at yourself?? What are you up to?", |
265 | }, |
257 | }, |
266 | }, |
258 | }, |
267 | pout => { |
259 | pout => { |
268 | noparams => { |
260 | noparams => { |
… | |
… | |
274 | self => { |
266 | self => { |
275 | }, |
267 | }, |
276 | }, |
268 | }, |
277 | cackle => { |
269 | cackle => { |
278 | noparams => { |
270 | noparams => { |
279 | other => "<self> throws back his head and cackles with insane glee!", |
271 | other => "<self> throws back G<his|her> head and cackles with insane glee!", |
280 | self => "You cackle gleefully.", |
272 | self => "You cackle gleefully.", |
281 | }, |
273 | }, |
282 | params => { |
274 | params => { |
283 | }, |
275 | }, |
284 | self => { |
276 | self => { |
… | |
… | |
293 | target => "<self> sniffs you.", |
285 | target => "<self> sniffs you.", |
294 | other => "<self> sniffs <other>", |
286 | other => "<self> sniffs <other>", |
295 | self => "You sniff <other>.", |
287 | self => "You sniff <other>.", |
296 | }, |
288 | }, |
297 | self => { |
289 | self => { |
298 | other => "<self> sniffs himself.", |
290 | other => "<self> sniffs G<him|her>self.", |
299 | self => "You sniff yourself.", |
291 | self => "You sniff yourself.", |
300 | }, |
292 | }, |
301 | }, |
293 | }, |
302 | nod => { |
294 | nod => { |
303 | noparams => { |
295 | noparams => { |
304 | other => "<self> nods solemnly.", |
296 | other => "<self> nods solemnly.", |
305 | self => "You nod solemnly.", |
297 | self => "You nod solemnly.", |
306 | }, |
298 | }, |
307 | params => { |
299 | params => { |
308 | target => "<self> nods solemnly to you.", |
300 | target => "<self> nods solemnly at you.", |
309 | other => "<self> nods solemnly to <other>.", |
301 | other => "<self> nods solemnly at <other>.", |
310 | self => "You nod solemnly to <other>.", |
302 | self => "You nod solemnly at <other>.", |
311 | }, |
303 | }, |
312 | self => { |
304 | self => { |
313 | }, |
305 | }, |
314 | }, |
306 | }, |
315 | frown => { |
307 | frown => { |
… | |
… | |
321 | target => "<self> frowns darkly at you.", |
313 | target => "<self> frowns darkly at you.", |
322 | other => "<self> frowns darkly at <other>.", |
314 | other => "<self> frowns darkly at <other>.", |
323 | self => "You frown darkly at <other>.", |
315 | self => "You frown darkly at <other>.", |
324 | }, |
316 | }, |
325 | self => { |
317 | self => { |
326 | other => "<self> frowns at himself.", |
318 | other => "<self> frowns at G<him|her>self.", |
327 | self => "You frown at yourself.", |
319 | self => "You frown at yourself.", |
328 | }, |
320 | }, |
329 | }, |
321 | }, |
330 | snicker => { |
322 | snicker => { |
331 | noparams => { |
323 | noparams => { |
… | |
… | |
354 | noparams => { |
346 | noparams => { |
355 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
347 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
356 | self => "You bleed all over your nice new armour.", |
348 | self => "You bleed all over your nice new armour.", |
357 | }, |
349 | }, |
358 | params => { |
350 | params => { |
359 | target => "<self> slashes his wrist and bleeds all over you.", |
351 | target => "<self> slashes G<his|her> wrist and bleeds all over you.", |
360 | other => "<self> slashes his wrist and bleeds all over <other>.", |
352 | other => "<self> slashes G<his|her> wrist and bleeds all over <other>.", |
361 | self => "You slash your wrist and bleed all over <other>", |
353 | self => "You slash your wrist and bleed all over <other>", |
362 | }, |
354 | }, |
363 | self => { |
355 | self => { |
364 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
356 | other => "<self> performs some satanic ritual while wiping G<his|her> blood on G<him|her>self.", |
365 | self => "Very impressive! You wipe your blood all over yourself.", |
357 | self => "Very impressive! You wipe your blood all over yourself.", |
366 | }, |
358 | }, |
367 | }, |
359 | }, |
368 | twiddle => { |
360 | twiddle => { |
369 | noparams => { |
361 | noparams => { |
370 | other => "<self> patiently twiddles his thumbs.", |
362 | other => "<self> patiently twiddles G<his|her> thumbs.", |
371 | self => "You patiently twiddle your thumbs.", |
363 | self => "You patiently twiddle your thumbs.", |
372 | }, |
364 | }, |
373 | params => { |
365 | params => { |
374 | }, |
366 | }, |
375 | self => { |
367 | self => { |
376 | }, |
368 | }, |
377 | }, |
369 | }, |
378 | spit => { |
370 | spit => { |
379 | noparams => { |
371 | noparams => { |
380 | other => "<self> spits over his left shoulder.", |
372 | other => "<self> spits over G<his|her> left shoulder.", |
381 | self => "You spit over your left shoulder.", |
373 | self => "You spit over your left shoulder.", |
382 | }, |
374 | }, |
383 | params => { |
375 | params => { |
384 | target => "<self> spits in your face!", |
376 | target => "<self> spits in your face!", |
385 | other => "<self> spits in <other>'s face.", |
377 | other => "<self> spits in <other>'s face.", |
386 | self => "You spit on <other>.", |
378 | self => "You spit on <other>.", |
387 | }, |
379 | }, |
388 | self => { |
380 | self => { |
389 | other => "<self> drools all over himself.", |
381 | other => "<self> drools all over G<him|her>self.", |
390 | self => "You drool all over yourself.", |
382 | self => "You drool all over yourself.", |
391 | }, |
383 | }, |
392 | }, |
384 | }, |
393 | glare => { |
385 | glare => { |
394 | noparams => { |
386 | noparams => { |
395 | other => "<self> glares around him.", |
387 | other => "<self> glares around G<him|her>.", |
396 | self => "You glare at nothing in particular.", |
388 | self => "You glare at nothing in particular.", |
397 | }, |
389 | }, |
398 | params => { |
390 | params => { |
399 | target => "<self> glares icily at you, you feel cold to your bones.", |
391 | target => "<self> glares icily at you, you feel cold to your bones.", |
400 | other => "<self> glares at <other>.", |
392 | other => "<self> glares at <other>.", |
401 | self => "You glare icily at <other>.", |
393 | self => "You glare icily at <other>.", |
402 | }, |
394 | }, |
403 | self => { |
395 | self => { |
404 | other => "<self> glares at his feet, what is bothering him?", |
396 | other => "<self> glares at G<his|her> feet, what is bothering G<him|her>?", |
405 | self => "You glare icily at your feet, they are suddenly very cold.", |
397 | self => "You glare icily at your feet, they are suddenly very cold.", |
406 | }, |
398 | }, |
407 | }, |
399 | }, |
408 | bow => { |
400 | bow => { |
409 | noparams => { |
401 | noparams => { |
… | |
… | |
414 | target => "<self> bows before you.", |
406 | target => "<self> bows before you.", |
415 | other => "<self> bows before <other>.", |
407 | other => "<self> bows before <other>.", |
416 | self => "You bow before <other>.", |
408 | self => "You bow before <other>.", |
417 | }, |
409 | }, |
418 | self => { |
410 | self => { |
419 | other => "<self> folds up like a jackknife and kisses his own toes.", |
411 | other => "<self> folds up like a jackknife and kisses G<his|her> own toes.", |
420 | self => "You kiss your toes.", |
412 | self => "You kiss your toes.", |
421 | }, |
413 | }, |
422 | }, |
414 | }, |
423 | dance => { |
415 | dance => { |
424 | noparams => { |
416 | noparams => { |
425 | other => "<self> expresses himself through interpretive dance.", |
417 | other => "<self> expresses G<him|her>self through interpretive dance.", |
426 | self => "You dance with glee.", |
418 | self => "You dance with glee.", |
427 | }, |
419 | }, |
428 | params => { |
420 | params => { |
429 | target => "<self> grabs you, and begins dancing!", |
421 | target => "<self> grabs you, and begins dancing!", |
430 | other => "Yipe! <self> and <other> are doing the Macarena!", |
422 | other => "Yipe! <self> and <other> are doing the Macarena!", |
431 | self => "You grab <other> and begin doing the Cha-Cha!", |
423 | self => "You grab <other> and begin doing the Cha-Cha!", |
432 | }, |
424 | }, |
433 | self => { |
425 | self => { |
434 | other => "<self> embraces himself and begins to dance!", |
426 | other => "<self> embraces G<him|her>self and begins to dance!", |
435 | self => "You skip and dance around by yourself.", |
427 | self => "You skip and dance around by yourself.", |
436 | }, |
428 | }, |
437 | }, |
429 | }, |
438 | snore => { |
430 | snore => { |
439 | noparams => { |
431 | noparams => { |
… | |
… | |
455 | self => { |
447 | self => { |
456 | }, |
448 | }, |
457 | }, |
449 | }, |
458 | snap => { |
450 | snap => { |
459 | noparams => { |
451 | noparams => { |
460 | other => "<self> snaps his fingers.", |
452 | other => "<self> snaps G<his|her> fingers.", |
461 | self => "PRONTO! you snap your fingers.", |
453 | self => "PRONTO! you snap your fingers.", |
462 | }, |
454 | }, |
463 | params => { |
455 | params => { |
464 | }, |
456 | }, |
465 | self => { |
457 | self => { |
… | |
… | |
474 | target => "<self> waves goodbye to you. Have a good journey.", |
466 | target => "<self> waves goodbye to you. Have a good journey.", |
475 | other => "<self> waves goodbye to <other>.", |
467 | other => "<self> waves goodbye to <other>.", |
476 | self => "You wave goodbye to <other>.", |
468 | self => "You wave goodbye to <other>.", |
477 | }, |
469 | }, |
478 | self => { |
470 | self => { |
479 | other => "<self> waves goodbye to himself.", |
471 | other => "<self> waves goodbye to G<him|her>self.", |
480 | self => "Are you going on adventures as well??", |
472 | self => "Are you going on adventures as well??", |
481 | }, |
473 | }, |
482 | }, |
474 | }, |
483 | smile => { |
475 | smile => { |
484 | noparams => { |
476 | noparams => { |
… | |
… | |
498 | other => "<self> sneezes.", |
490 | other => "<self> sneezes.", |
499 | self => "Gesundheit!", |
491 | self => "Gesundheit!", |
500 | }, |
492 | }, |
501 | params => { |
493 | params => { |
502 | target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", |
494 | target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", |
503 | other => "<self> sneezes on <other> and a film of snot covers him.", |
495 | other => "<self> sneezes on <other> and a film of snot covers G<him|her>.", |
504 | self => "You sneeze at <other> and a film of snot shoots onto him.", |
496 | self => "You sneeze at <other> and a film of snot shoots onto G<him|her>.", |
505 | }, |
497 | }, |
506 | self => { |
498 | self => { |
507 | other => "<self> sneezes, and covers himself in a slimy substance.", |
499 | other => "<self> sneezes, and covers G<him|her>self in a slimy substance.", |
508 | self => "You sneeze on yourself, what a mess!", |
500 | self => "You sneeze on yourself, what a mess!", |
509 | }, |
501 | }, |
510 | }, |
502 | }, |
511 | bounce => { |
503 | bounce => { |
512 | noparams => { |
504 | noparams => { |
… | |
… | |
521 | self => { |
513 | self => { |
522 | }, |
514 | }, |
523 | }, |
515 | }, |
524 | shake => { |
516 | shake => { |
525 | noparams => { |
517 | noparams => { |
526 | other => "<self> shakes his head.", |
518 | other => "<self> shakes G<his|her> head.", |
527 | self => "You shake your head.", |
519 | self => "You shake your head.", |
528 | }, |
520 | }, |
529 | params => { |
521 | params => { |
530 | target => "<self> shakes your hand.", |
522 | target => "<self> shakes your hand.", |
531 | other => "<self> shakes <other>'s hand.", |
523 | other => "<self> shakes <other>'s hand.", |
… | |
… | |
536 | self => "You are shaken by yourself.", |
528 | self => "You are shaken by yourself.", |
537 | }, |
529 | }, |
538 | }, |
530 | }, |
539 | lick => { |
531 | lick => { |
540 | noparams => { |
532 | noparams => { |
541 | other => "<self> licks his mouth and smiles.", |
533 | other => "<self> licks G<his|her> mouth and smiles.", |
542 | self => "You lick your mouth and smile.", |
534 | self => "You lick your mouth and smile.", |
543 | }, |
535 | }, |
544 | params => { |
536 | params => { |
545 | target => "<self> licks you.", |
537 | target => "<self> licks you.", |
546 | other => "<self> licks <other>.", |
538 | other => "<self> licks <other>.", |
547 | self => "You lick <other>.", |
539 | self => "You lick <other>.", |
548 | }, |
540 | }, |
549 | self => { |
541 | self => { |
550 | other => "<self> licks himself - YUCK.", |
542 | other => "<self> licks G<him|her>self - YUCK.", |
551 | self => "You lick yourself.", |
543 | self => "You lick yourself.", |
552 | }, |
544 | }, |
553 | }, |
545 | }, |
554 | flip => { |
546 | flip => { |
555 | noparams => { |
547 | noparams => { |
… | |
… | |
561 | self => { |
553 | self => { |
562 | }, |
554 | }, |
563 | }, |
555 | }, |
564 | think => { |
556 | think => { |
565 | noparams => { |
557 | noparams => { |
566 | other => "<self> closes his eyes and thinks really hard.", |
558 | other => "<self> closes G<his|her> eyes and thinks really hard.", |
567 | self => "Anything in particular that you'd care to think about?", |
559 | self => "Anything in particular that you'd care to think about?", |
568 | }, |
560 | }, |
569 | params => { |
561 | params => { |
570 | }, |
562 | }, |
571 | self => { |
563 | self => { |
… | |
… | |
635 | target => "<self> cries on your shoulder.", |
627 | target => "<self> cries on your shoulder.", |
636 | other => "<self> cries on <other>'s shoulder.", |
628 | other => "<self> cries on <other>'s shoulder.", |
637 | self => "You cry on <other>'s shoulder.", |
629 | self => "You cry on <other>'s shoulder.", |
638 | }, |
630 | }, |
639 | self => { |
631 | self => { |
640 | other => "<self> sobs quietly to himself.", |
632 | other => "<self> sobs quietly to G<him|her>self.", |
641 | self => "You cry to yourself.", |
633 | self => "You cry to yourself.", |
642 | }, |
634 | }, |
643 | }, |
635 | }, |
644 | sulk => { |
636 | sulk => { |
645 | noparams => { |
637 | noparams => { |
… | |
… | |
659 | params => { |
651 | params => { |
660 | target => "<self> whistles at <other>.", |
652 | target => "<self> whistles at <other>.", |
661 | self => "You whistle at <other>.", |
653 | self => "You whistle at <other>.", |
662 | }, |
654 | }, |
663 | self => { |
655 | self => { |
664 | other => "<self> whistles to himself in boredom.", |
656 | other => "<self> whistles to G<him|her>self in boredom.", |
665 | self => "You whistle while you work.", |
657 | self => "You whistle while you work.", |
666 | }, |
658 | }, |
667 | }, |
659 | }, |
668 | groan => { |
660 | groan => { |
669 | noparams => { |
661 | noparams => { |
… | |
… | |
706 | |
698 | |
707 | my $pl = $ob->contr; |
699 | my $pl = $ob->contr; |
708 | |
700 | |
709 | cf::async { |
701 | cf::async { |
710 | my $name = $ob->name; |
702 | my $name = $ob->name; |
|
|
703 | $Coro::current->{desc} = "emote handler for $name"; |
711 | |
704 | |
712 | if ($tname eq $name) { |
705 | if ($tname eq $name) { |
713 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
706 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
714 | |
707 | |
715 | $emote{other} ||= "You look away from <self>."; |
708 | $emote{other} ||= "You look away from <self>."; |
716 | $emote{self} ||= "My god! Is that LEGAL?"; |
709 | $emote{self} ||= "My god! Is that LEGAL?"; |
717 | |
710 | |
718 | $emote{other} =~ s/<self>/$name/; |
711 | $emote{other} =~ s/<self>/$name/; |
|
|
712 | |
|
|
713 | $_ = $pl->expand_cfpod ($_) |
|
|
714 | for values %emote; |
719 | |
715 | |
720 | $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
716 | send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat" |
721 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
717 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
722 | |
718 | |
723 | $pl->ns->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
719 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); |
724 | } elsif ($tname) { |
720 | } elsif ($tname) { |
725 | my $target = cf::player::find $tname |
721 | my $target = cf::player::find $tname |
726 | or return $pl->ns->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); |
722 | or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; |
727 | |
723 | |
728 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
724 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
729 | |
725 | |
730 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
726 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
731 | $emote{self} ||= "You are still nuts."; |
727 | $emote{self} ||= "You are still nuts."; |
732 | $emote{target} ||= "You get the distinct feeling that <other> is nuts."; |
728 | $emote{target} ||= "You get the distinct feeling that <self> is nuts."; |
733 | |
729 | |
734 | $emote{self} =~ s/<other>/$tname/; |
730 | $emote{self} =~ s/<other>/$tname/; |
735 | $emote{target} =~ s/<self>/$name/; |
731 | $emote{target} =~ s/<self>/$name/; |
736 | $emote{other} =~ s/<other>/$tname/; |
732 | $emote{other} =~ s/<other>/$tname/; |
737 | $emote{other} =~ s/<self>/$name/; |
733 | $emote{other} =~ s/<self>/$name/; |
738 | |
734 | |
739 | $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
735 | $_ = $pl->expand_cfpod ($_) |
|
|
736 | for values %emote; |
|
|
737 | |
|
|
738 | send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat" |
740 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
739 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
741 | |
740 | |
742 | $target->ns->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); |
741 | send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout"; |
743 | $pl->ns->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
742 | $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); |
744 | } else { |
743 | } else { |
745 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
744 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
746 | |
745 | |
747 | $emote{other} ||= "<self> dances with glee."; |
746 | $emote{other} ||= "<self> dances with glee."; |
748 | $emote{self} ||= "You are a nut."; |
747 | $emote{self} ||= "You are a nut."; |
749 | |
748 | |
750 | $emote{other} =~ s/<self>/$name/; |
749 | $emote{other} =~ s/<self>/$name/; |
751 | |
750 | |
752 | $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
751 | $_ = $pl->expand_cfpod ($_) |
|
|
752 | for values %emote; |
|
|
753 | |
|
|
754 | send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat" |
753 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
755 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
754 | |
756 | |
755 | $pl->ns->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
757 | $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); |
756 | } |
758 | } |
757 | }; |
759 | }; |
758 | }; |
760 | }; |
759 | } |
761 | } |
760 | |
762 | |
761 | cf::register_command me => sub { |
763 | cf::register_command me => sub { |
762 | my ($pl, $msg) = @_; |
764 | my ($pl, $msg) = @_; |
763 | |
765 | |
764 | my $name = $pl->name; |
766 | my $name = $pl->name; |
765 | |
767 | |
766 | $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
768 | send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" |
767 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
769 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
768 | }; |
770 | }; |
769 | |
771 | |
770 | cf::register_command say => sub { |
772 | cf::register_command say => sub { |
771 | my ($ob, $msg) = @_; |
773 | my ($ob, $msg) = @_; |
… | |
… | |
776 | |
778 | |
777 | if ($msg) { |
779 | if ($msg) { |
778 | my $name = $ob->name; |
780 | my $name = $ob->name; |
779 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
781 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
780 | |
782 | |
|
|
783 | send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" |
|
|
784 | for grep $_ != $ob->contr, @plonmap; |
781 | $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob ? cf::NDI_REPLY : 0)) |
785 | $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); |
782 | for @plonmap; |
|
|
783 | |
786 | |
784 | # npcs, magic_ears etc. |
787 | # npcs, magic_ears etc. |
785 | # first find all objects and their first-level inventories |
788 | # first find all objects and their first-level inventories |
786 | # within a 5x5 square that have something resembling |
789 | # within a 5x5 square that have something resembling |
787 | # dialogue or support on_say. |
790 | # dialogue or support on_say. |
788 | my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); |
791 | my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); |
789 | |
792 | |
790 | for my $npc ( |
793 | for my $npc ( |
791 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
794 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue, |
792 | map +($_, $_->inv), |
795 | map +($_, $_->inv), |
793 | grep $_, |
796 | grep $_, |
794 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
797 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
795 | 0..24 |
798 | 0..24 |
796 | ) { |
799 | ) { |
… | |
… | |
801 | my ($reply, @kw) = $dialog->tell ($msg); |
804 | my ($reply, @kw) = $dialog->tell ($msg); |
802 | |
805 | |
803 | if (defined $reply) { |
806 | if (defined $reply) { |
804 | if ($npc->type == cf::MAGIC_EAR) { |
807 | if ($npc->type == cf::MAGIC_EAR) { |
805 | if (length $reply) { |
808 | if (length $reply) { |
806 | $_->ns->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
809 | send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
807 | for @plonmap; |
810 | for @plonmap; |
808 | } |
811 | } |
809 | $npc->use_trigger; |
812 | $npc->use_trigger; |
810 | } else { |
813 | } else { |
811 | if (length $reply) { |
814 | if (length $reply) { |
812 | $_->ns->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) |
815 | send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
813 | for @plonmap; |
816 | for @plonmap; |
814 | } |
817 | } |
815 | } |
818 | } |
816 | } |
819 | } |
817 | |
820 | |
818 | if (@kw) { |
821 | if (@kw) { |
819 | $_->ns->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
822 | $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
820 | for @plonmap; |
823 | for @plonmap; |
821 | } |
824 | } |
822 | } |
825 | } |
823 | |
826 | |
824 | } else { |
827 | } else { |
825 | $ob->contr->ns->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
828 | $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
826 | } |
829 | } |
827 | }; |
830 | }; |
828 | |
831 | |
829 | cf::register_command chat => sub { |
832 | cf::register_command chat => sub { |
830 | my ($ob, $msg) = @_; |
833 | my ($ob, $msg) = @_; |
… | |
… | |
840 | my $NOW = time; |
843 | my $NOW = time; |
841 | |
844 | |
842 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
845 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
843 | send_irc ("[%s] %s", $name, $msg); |
846 | send_irc ("[%s] %s", $name, $msg); |
844 | |
847 | |
845 | $_->ns->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
848 | send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" |
846 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
849 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list; |
847 | |
850 | |
848 | } else { |
851 | } else { |
849 | $pl->ns->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
852 | $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
850 | } |
853 | } |
851 | }; |
854 | }; |
852 | |
855 | |
853 | cf::register_command shout => sub { |
856 | cf::register_command shout => sub { |
854 | my ($ob, $msg) = @_; |
857 | my ($ob, $msg) = @_; |
… | |
… | |
864 | my $name = $ob->name; |
867 | my $name = $ob->name; |
865 | |
868 | |
866 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
869 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
867 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
870 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
868 | |
871 | |
869 | $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
872 | send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" |
870 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
873 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list; |
871 | |
874 | |
872 | } else { |
875 | } else { |
873 | $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
876 | $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
874 | } |
877 | } |
875 | }; |
878 | }; |
876 | |
879 | |
877 | cf::register_command tell => sub { |
880 | cf::register_command tell => sub { |
878 | my ($ob, $args) = @_; |
881 | my ($ob, $args) = @_; |
… | |
… | |
905 | } else { |
908 | } else { |
906 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
909 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
907 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
910 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
908 | |
911 | |
909 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
912 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
910 | $other->ns->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); |
913 | send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell"; |
911 | } |
914 | } |
912 | } else { |
915 | } else { |
913 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
916 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
914 | } |
917 | } |
915 | |
918 | |