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