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