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