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