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