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