Debian Codegraph @

server/c_chat.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * Crossfire -- cooperative multi-player graphical RPG and adventure game
3 *
4 * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5 * Copyright (c) 1992 Frank Tore Johansen
6 *
7 * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8 * welcome to redistribute it under certain conditions. For details, please
9 * see COPYING and LICENSE.
10 *
11 * The authors can be reached via e-mail at <[email protected]>.
12 */
13
14 /**
15 * @file
16 * All player communication commands, except the 'gsay' one.
17 */
18
19 #include "global.h"
20
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "loader.h"
25 #include "sproto.h"
26
27 /**
28 * 'say' command.
29 * @param op
30 * player.
31 * @param params
32 * message.
33 */
34 void command_say(object *op, const char *params) {
35 if (*params == '\0')
36 return;
37 monster_communicate(op, params);
38 }
39
40 /**
41 * 'me' command.
42 * @param op
43 * player.
44 * @param params
45 * message.
46 */
47 void command_me(object *op, const char *params) {
48 char buf[MAX_BUF];
49
50 if (*params == '\0')
51 return;
52 snprintf(buf, sizeof(buf), "%s %s", op->name, params);
53 ext_info_map(NDI_UNIQUE|NDI_BLUE, op->map, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_ME,
54 buf);
55 }
56
57 /**
58 * 'cointoss' command.
59 * @param op
60 * player.
61 * @param params
62 * message.
63 */
64 void command_cointoss(object *op, const char *params) {
65 char buf[MAX_BUF];
66 const char *result;
67
68 result = rndm(1, 2) == 1 ? "Heads" : "Tails";
69
70 draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_RANDOM,
71 "You flip a coin.... %s!",
72 result);
73
74 snprintf(buf, sizeof(buf), "%s flips a coin.... %s!", op->name, result);
75 ext_info_map_except(NDI_WHITE, op->map, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_RANDOM,
76 buf);
77 }
78
79 /** Results for the "orcknucle" game. */
80 static const char *const orcknuckle[7] = {
81 "none",
82 "beholder",
83 "ghost",
84 "knight",
85 "princess",
86 "dragon",
87 "orc"
88 };
89
90 #define DICE 4 /**< How many dice to roll for orcknuckle. */
91
92 /**
93 * Plays the "orcknucke" game.
94 *
95 * If there is an "dice" archetype in server arches, this command will
96 * require the player to have at least 4 dice to play. There is a 5%
97 * chance to lose one dice at each play. Dice can be made through alchemy
98 * (finding the recipe is left as an exercice to the player).
99 * Note that the check is on the name 'dice', so you can have multiple
100 * archetypes for that name, they'll be all taken into account.
101 *
102 * @param op
103 * player who plays.
104 * @param params
105 * string sent by the player. Ignored.
106 */
107 void command_orcknuckle(object *op, const char *params) {
108 char buf[MAX_BUF];
109 char buf2[MAX_BUF];
110 object *dice[DICE];
111 int i, j, k, l, dice_count, number_dice;
112 const char *name;
113
114 /* We only use dice if the archetype is present ingame. */
115 name = find_string("dice");
116 if (name) {
117 for (dice_count = 0; dice_count < DICE; dice_count++)
118 dice[dice_count] = NULL;
119 dice_count = 0;
120 number_dice = 0;
121
122 FOR_INV_PREPARE(op, ob) {
123 if (dice_count >= DICE || number_dice >= DICE)
124 break;
125 if (ob->name == name) {
126 number_dice += ob->nrof;
127 dice[dice_count++] = ob;
128 }
129 } FOR_INV_FINISH();
130
131 if (number_dice < DICE) {
132 draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_RANDOM,
133 "You need at least %d dice to play orcknuckle!", DICE);
134 return;
135 }
136 } else {
137 dice_count = 0;
138 }
139
140 i = rndm(1, 5);
141 j = rndm(1, 5);
142 k = rndm(1, 5);
143 l = rndm(1, 6);
144
145 snprintf(buf2, sizeof(buf2), "%s rolls %s, %s, %s, %s!", op->name, orcknuckle[i], orcknuckle[j], orcknuckle[k], orcknuckle[l]);
146 snprintf(buf, sizeof(buf), "You roll %s, %s, %s, %s!", orcknuckle[i], orcknuckle[j], orcknuckle[k], orcknuckle[l]);
147
148 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_RANDOM,
149 buf);
150 ext_info_map_except(NDI_UNIQUE, op->map, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_RANDOM,
151 buf2);
152
153 if (name) {
154 /* Randomly lose dice */
155 if (die_roll(1, 100, op, 1) < 5) {
156 /* Lose one randomly. */
157 object_decrease_nrof_by_one(dice[rndm(1, dice_count)-1]);
158 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_RANDOM,
159 "Oops, you lost a die!");
160 }
161 }
162 #undef DICE
163 }
164
165 /**
166 * Utility function for chat or shout.
167 *
168 * @param op
169 * player.
170 * @param params
171 * message.
172 * @param pri
173 * message priority.
174 * @param color
175 * message color.
176 * @param subtype
177 * message subtype.
178 * @param desc
179 * 'chat' or 'shouts', will be appened after the player's name and before a :.
180 */
181 static void command_tell_all(object *op, const char *params, int pri, int color, int subtype, const char *desc) {
182 if (op->contr->no_shout == 1) {
183 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
184 "You are no longer allowed to shout or chat.");
185 return;
186 }
187
188 if (*params == '\0') {
189 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
190 "Shout/Chat what?");
191 return;
192 }
193
194 draw_ext_info_format(NDI_UNIQUE|NDI_ALL|color, pri, NULL, MSG_TYPE_COMMUNICATION, subtype,
195 "%s %s: %s",
196 op->name, desc, params);
197
198 /* Lauwenmark : Here we handle the SHOUT global event */
199 execute_global_event(EVENT_SHOUT, op, params, pri);
200 }
201
202 /**
203 * 'shout' command.
204 * @param op
205 * player.
206 * @param params
207 * message.
208 */
209 void command_shout(object *op, const char *params) {
210 command_tell_all(op, params, 1, NDI_RED, MSG_TYPE_COMMUNICATION_SHOUT, "shouts");
211 }
212
213 /**
214 * 'chat' command.
215 * @param op
216 * player.
217 * @param params
218 * message.
219 */
220 void command_chat(object *op, const char *params) {
221 command_tell_all(op, params, 9, NDI_BLUE, MSG_TYPE_COMMUNICATION_CHAT, "chats");
222 }
223
224 /**
225 * Actual function sending a private message.
226 *
227 * @param op
228 * player trying to tell something to someone.
229 * @param params
230 * who to tell, and message
231 * @param adjust_listen
232 * if non-zero, recipient can't ignore the message through 'listen' levels.
233 */
234 static void do_tell(object *op, const char *params, int adjust_listen) {
235 char buf[MAX_BUF], name[MAX_BUF];
236 char *msg = NULL;
237 player *pl;
238 uint8_t original_listen;
239
240 strlcpy(name, params, sizeof(name));
241
242 msg = strchr(name, ' ');
243 if (msg) {
244 (*msg) = '\0';
245 msg++;
246 if ((*msg) == '\0')
247 msg = NULL;
248 }
249
250 if (strlen(name) == 0) {
251 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
252 "Tell whom what?");
253 return;
254 }
255
256 if (msg == NULL) {
257 draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
258 "Tell %s what?",
259 name);
260 return;
261 }
262
263 snprintf(buf, sizeof(buf), "%s tells you: %s", op->name, msg);
264
265 pl = find_player_partial_name(name);
266 if (pl) {
267 if (adjust_listen) {
268 original_listen = pl->listening;
269 pl->listening = 10;
270 } else {
271 original_listen = 0;
272 }
273
274 execute_global_event(EVENT_TELL, op, msg, pl->ob);
275
276 draw_ext_info(NDI_UNIQUE|NDI_ORANGE, 0, pl->ob, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_TELL,
277 buf);
278
279 if (adjust_listen)
280 pl->listening = original_listen;
281
282 /* Update last_tell value [mids 01/14/2002] */
283 strlcpy(pl->last_tell, op->name, sizeof(pl->last_tell));
284
285 /* Hidden DMs get the message, but player should think DM isn't online. */
286 if (!pl->hidden || QUERY_FLAG(op, FLAG_WIZ)) {
287 draw_ext_info_format(NDI_UNIQUE|NDI_ORANGE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_TELL,
288 "You tell %s: %s",
289 pl->ob->name, msg);
290
291 return;
292 }
293 }
294
295 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
296 "No such player or ambiguous name.");
297 }
298
299 /**
300 * Private communication.
301 *
302 * @param op
303 * player trying to tell something to someone.
304 * @param params
305 * who to tell, and message.
306 */
307 void command_tell(object *op, const char *params) {
308 do_tell(op, params, 0);
309 }
310
311 /**
312 * Private communication, by a DM (can't be ignored by player).
313 *
314 * @param op
315 * player trying to tell something to someone.
316 * @param params
317 * who to tell, and message.
318 */
319 void command_dmtell(object *op, const char *params) {
320 do_tell(op, params, 1);
321 }
322
323 /**
324 * Reply to last person who told you something [mids 01/14/2002]
325 *
326 * Must have been told something by someone first.
327 *
328 * @param op
329 * who is telling.
330 * @param params
331 * message to say.
332 * @return
333 * 1.
334 */
335 void command_reply(object *op, const char *params) {
336 player *pl;
337
338 if (*params == '\0') {
339 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
340 "Reply what?");
341 return;
342 }
343
344 if (op->contr->last_tell[0] == '\0') {
345 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
346 "You can't reply to nobody.");
347 return;
348 }
349
350 /* Find player object of player to reply to and check if player still exists */
351 pl = find_player(op->contr->last_tell);
352 if (pl == NULL) {
353 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
354 "You can't reply, this player left.");
355 return;
356 }
357
358 /* Update last_tell value */
359 safe_strncpy(pl->last_tell, op->name, MAX_NAME);
360
361 draw_ext_info_format(NDI_UNIQUE|NDI_ORANGE, 0, pl->ob, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_TELL,
362 "%s tells you: %s",
363 op->name, params);
364
365 if (pl->hidden && !QUERY_FLAG(op, FLAG_WIZ)) {
366 draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,
367 "You can't reply, this player left.");
368 return;
369 }
370
371 draw_ext_info_format(NDI_UNIQUE|NDI_ORANGE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_TELL,
372 "You tell to %s: %s",
373 pl->ob->name, params);
374 }
375
376 /**
377 * @defgroup EMOTE_xxx Emotes players can use to communicate
378 */
379 /*@{*/
380 #define EMOTE_FIRST 0
381 #define EMOTE_NOD 1
382 #define EMOTE_DANCE 2
383 #define EMOTE_KISS 3
384 #define EMOTE_BOUNCE 4
385 #define EMOTE_SMILE 5
386 #define EMOTE_CACKLE 6
387 #define EMOTE_LAUGH 7
388 #define EMOTE_GIGGLE 8
389 #define EMOTE_SHAKE 9
390 #define EMOTE_PUKE 10
391 #define EMOTE_GROWL 11
392 #define EMOTE_SCREAM 12
393 #define EMOTE_SIGH 13
394 #define EMOTE_SULK 14
395 #define EMOTE_HUG 15
396 #define EMOTE_CRY 16
397 #define EMOTE_POKE 17
398 #define EMOTE_ACCUSE 18
399 #define EMOTE_GRIN 19
400 #define EMOTE_BOW 20
401 #define EMOTE_CLAP 21
402 #define EMOTE_BLUSH 22
403 #define EMOTE_BURP 23
404 #define EMOTE_CHUCKLE 24
405 #define EMOTE_COUGH 25
406 #define EMOTE_FLIP 26
407 #define EMOTE_FROWN 27
408 #define EMOTE_GASP 28
409 #define EMOTE_GLARE 29
410 #define EMOTE_GROAN 30
411 #define EMOTE_HICCUP 31
412 #define EMOTE_LICK 32
413 #define EMOTE_POUT 33
414 #define EMOTE_SHIVER 34
415 #define EMOTE_SHRUG 35
416 #define EMOTE_SLAP 36
417 #define EMOTE_SMIRK 37
418 #define EMOTE_SNAP 38
419 #define EMOTE_SNEEZE 39
420 #define EMOTE_SNICKER 40
421 #define EMOTE_SNIFF 41
422 #define EMOTE_SNORE 42
423 #define EMOTE_SPIT 43
424 #define EMOTE_STRUT 44
425 #define EMOTE_THANK 45
426 #define EMOTE_TWIDDLE 46
427 #define EMOTE_WAVE 47
428 #define EMOTE_WHISTLE 48
429 #define EMOTE_WINK 49
430 #define EMOTE_YAWN 50
431 #define EMOTE_BEG 51
432 #define EMOTE_BLEED 52
433 #define EMOTE_CRINGE 53
434 #define EMOTE_THINK 54
435 #define EMOTE_LAST 55
436 /*@}*/
437
438 /**
439 * Emote texts when the player does not specify who to apply the emote.
440 * Two strings, first is sent to the player herself, second to other players (must contain %s).
441 * The @ref EMOTE_xxx "emotes" will be seeked at the index of their value minus 1.
442 * If an entry is NULL, then a default text will be used.
443 */
444 static const char* single_emotes[EMOTE_LAST - 1][2] = {
445 { "You nod solemnly.", "%s nods solemnly." },
446 { "You dance with glee.", "%s expresses himself through interpretive dance." },
447 { "All the lonely people...", "%s makes a weird facial contortion" },
448 { "BOIINNNNNNGG!", "%s bounces around." },
449 { "You smile happily.", "%s smiles happily." },
450 { "You cackle gleefully.", "%s throws back his head and cackles with insane glee!" },
451 { "You fall down laughing.", "%s falls down laughing." },
452 { "You giggle.", "%s giggles." },
453 { "You shake your head.", "%s shakes his head." },
454 { "Bleaaaaaghhhhhhh!", "%s pukes." },
455 { "Grrrrrrrrr....", "%s growls." },
456 { "ARRRRRRRRRRGH!!!!!", "%s screams at the top of his lungs!" },
457 { "You sigh.", "%s sighs loudly." },
458 { "You sulk.", "%s sulks in the corner." },
459 { NULL, NULL },
460 { "Waaaaaaahhh...", "%s bursts into tears." },
461 { NULL, NULL },
462 { NULL, NULL },
463 { "You grin evilly.", "%s grins evilly." },
464 { "You bow deeply.", "%s bows deeply." },
465 { "Clap, clap, clap.", "%s gives a round of applause." },
466 { "Your cheeks are burning.", "%s blushes." },
467 { "You burp loudly.", "%s burps loudly." },
468 { "You chuckle politely", "%s chuckles politely." },
469 { "Yuck, try to cover your mouth next time!", "%s coughs loudly." },
470 { "You flip head over heels.", "%s flips head over heels." },
471 { "What's bothering you?", "%s frowns." },
472 { "You gasp in astonishment.", "%s gasps in astonishment." },
473 { "You glare at nothing in particular.", "%s glares around him." },
474 { "You groan loudly.", "%s groans loudly." },
475 { "*HIC*", "%s hiccups." },
476 { "You lick your mouth and smile.", "%s licks his mouth and smiles." },
477 { "Aww, don't take it so hard.", "%s pouts." },
478 { "Brrrrrrrrr.", "%s shivers uncomfortably." },
479 { "You shrug.", "%s shrugs helplessly." },
480 { NULL, NULL },
481 { "You smirk.", "%s smirks." },
482 { "PRONTO! You snap your fingers.", "%s snaps his fingers." },
483 { "Gesundheit!", "%s sneezes." },
484 { "You snicker softly.", "%s snickers softly." },
485 { "You sniff sadly. *SNIFF*", "%s sniffs sadly." },
486 { "Zzzzzzzzzzzzzzz.", "%s snores loudly." },
487 { "You spit over your left shoulder.", "%s spits over his left shoulder." },
488 { "Strut your stuff.", "%s struts proudly." },
489 { NULL, NULL },
490 { "You patiently twiddle your thumbs.", "%s patiently twiddles his thumbs." },
491 { "You wave.", "%s waves happily." },
492 { "You whistle appreciatively.", "%s whistles appreciatively." },
493 { "Have you got something in your eye?", "%s winks suggestively." },
494 { "You open up your yap and let out a big breeze of stale air.", "%s yawns sleepily." },
495 { NULL, NULL },
496 { "You bleed all over your nice new armour.", "%s is bleeding all over the carpet - got a spare tourniquet?" },
497 { "You cringe in terror.", "%s cringes in terror!" },
498 { "Anything in particular that you'd care to think about?", "%s closes his eyes and thinks really hard." },
499 };
500 /**
501 * Emote texts when the player applies the emote to herself.
502 * Two strings, first is sent to the player, second to other players (must contain %s).
503 * The @ref EMOTE_xxx "emotes" will be seeked at the index of their value minus 1.
504 * If an entry is NULL, then a default text will be used.
505 */
506 static const char* self_emotes[EMOTE_LAST - 1][2] = {
507 { "My god! is that LEGAL?", "You look away from %s." },
508 { "You skip and dance around by yourself.", "%s embraces himself and begins to dance!"},
509 { NULL, NULL },
510 { NULL, NULL },
511 { NULL, NULL },
512 { NULL, NULL },
513 { "Laugh at yourself all you want, the others won't understand." "%s is laughing at something." },
514 { NULL, NULL },
515 { "You are shaken by yourself.", "%s shakes and quivers like a bowlful of jelly." },
516 { "You puke on yourself.", "%s pukes on his clothes." },
517 { NULL, NULL },
518 { NULL, NULL },
519 { NULL, NULL },
520 { NULL, NULL },
521 { "You hug yourself.", "%s hugs himself." },
522 { "You cry to yourself.", "%s sobs quietly to himself." },
523 { "You poke yourself in the ribs, feeling very silly.", "%s pokes himself in the ribs, looking very sheepish." },
524 { "You accuse yourself.", "%s seems to have a bad conscience." },
525 { NULL, NULL },
526 { "You kiss your toes.", "%s folds up like a jackknife and kisses his own toes." },
527 { NULL, NULL },
528 { NULL, NULL },
529 { NULL, NULL },
530 { NULL, NULL },
531 { NULL, NULL },
532 { NULL, NULL },
533 { "You frown at yourself.", "%s frowns at himself." },
534 { NULL, NULL },
535 { "You glare icily at your feet, they are suddenly very cold.", "%s glares at his feet, what is bothering him?" },
536 { NULL, NULL },
537 { NULL, NULL },
538 { "You lick yourself.", "%s licks himself - YUCK." },
539 { NULL, NULL },
540 { NULL, NULL },
541 { NULL, NULL },
542 { "You slap yourself, silly you.", "%s slaps himself, really strange..." },
543 { NULL, NULL },
544 { NULL, NULL },
545 { "You sneeze on yourself, what a mess!", "%s sneezes, and covers himself in a slimy substance." },
546 { NULL, NULL },
547 { "You sniff yourself.", "%s sniffs himself." },
548 { NULL, NULL },
549 { "You drool all over yourself.", "%s drools all over himself." },
550 { NULL, NULL },
551 { "You thank yourself since nobody else wants to!", "%s thanks himself since you won't." },
552 { NULL, NULL },
553 { "Are you going on adventures as well??", "%s waves goodbye to himself."},
554 { "You whistle while you work.", "%s whistles to himself in boredom." },
555 { "You wink at yourself?? What are you up to?", "%s winks at himself - something strange is going on..." },
556 { NULL, NULL },
557 { NULL, NULL },
558 { "Very impressive! You wipe your blood all over yourself.", "%s performs some satanic ritual while wiping his blood on himself." },
559 { NULL, NULL },
560 { NULL, NULL },
561 };
562 /**
563 * Emote texts when the player applies the emote to someone else.
564 * Three strings, first is sent to the player, second to the recipient, third to others.
565 * The first two must contain %s (player's name), second must contain 2 %s (player
566 * and victim's name).
567 * The @ref EMOTE_xxx "emotes" will be seeked at the index of their value minus 1.
568 * If an entry is NULL, then a default text will be used.
569 */
570 static const char* other_emotes[EMOTE_LAST - 1][3] = {
571 { "You nod solemnly to %s.", "%s nods solemnly to you.", "%s nods solemnly to %s." },
572 { "You grab %s and begin doing the Cha-Cha!", "%s grabs you, and begins dancing!", "Yipe! %s and %s are doing the Macarena!" },
573 { "You kiss %s.", "%s kisses you.", "%s kisses %s." },
574 { "You bounce around the room with %s.", "%s bounces around the room with you.", "%s bounces around the room with %s." },
575 { "You smile at %s.", "%s smiles at you.", "%s beams a smile at %s." },
576 { NULL, NULL, NULL },
577 { "You take one look at %s and fall down laughing.", "%s looks at you and falls down on the ground laughing.", "%s looks at %s and falls down on the ground laughing." },
578 { NULL, NULL, NULL },
579 { "You shake %s's hand.", "%s shakes your hand.", "%s shakes %s's hand." },
580 { "You puke on %s.", "%s pukes on your clothes!", "%s pukes on %s." },
581 { NULL, NULL, NULL },
582 { NULL, NULL, NULL },
583 { NULL, NULL, NULL },
584 { NULL, NULL, NULL },
585 { "You hug %s.", "%s hugs you.", "%s hugs %s." },
586 { "You cry on %s's shoulder.", "%s cries on your shoulder.", "%s cries on %s's shoulder." },
587 { "You poke %s in the ribs.", "%s pokes you in the ribs.", "%s pokes %s in the ribs." },
588 { "You look accusingly at %s.", "%s looks accusingly at you.", "%s looks accusingly at %s." },
589 { "You grin at %s.", "%s grins evilly at you.", "%s grins evilly at %s." },
590 { "You bow before %s.", "%s bows before you.", "%s bows before %s." },
591 { NULL, NULL, NULL },
592 { NULL, NULL, NULL },
593 { NULL, NULL, NULL },
594 { NULL, NULL, NULL },
595 { NULL, NULL, NULL },
596 { NULL, NULL, NULL },
597 { "You frown darkly at %s.", "%s frowns darkly at you.", "%s frowns darkly at %s." },
598 { NULL, NULL, NULL },
599 { "You glare icily at %s.", "%s glares icily at you, you feel cold to your bones.", "%s glares at %s." },
600 { NULL, NULL, NULL },
601 { NULL, NULL, NULL },
602 { "You lick %s.", "%s licks you.", "%s licks %s." },
603 { NULL, NULL, NULL },
604 { NULL, NULL, NULL },
605 { "You shrug at %s.", "%s shrugs at you.", "%s shrugs at %s." },
606 { "You slap %s.", "You are slapped by %s.", "%s slaps %s." },
607 { NULL, NULL, NULL },
608 { NULL, NULL, NULL },
609 { "You sneeze at %s and a film of snot shoots onto him.", "%s sneezes on you, you feel the snot cover you. EEEEEEW.", "%s sneezes on %s and a film of snot covers him." },
610 { NULL, NULL, NULL },
611 { "You sniff %s.", "%s sniffs you.", "%s sniffs %s" },
612 { NULL, NULL, NULL },
613 { "You spit on %s.", "%s spits in your face!", "%s spits in %s's face." },
614 { NULL, NULL, NULL },
615 { "You thank %s heartily.", "%s thanks you heartily.", "%s thanks %s heartily." },
616 { NULL, NULL, NULL },
617 { "You wave goodbye to %s.", "%s waves goodbye to you. Have a good journey.", "%s waves goodbye to %s." },
618 { "You whistle at %s.", "%s whistles at you.", "%s whistles at %s." },
619 { "You wink suggestively at %s.", "%s winks suggestively at you.", "%s winks at %s." },
620 { NULL, NULL, NULL },
621 { "You beg %s for mercy.", "%s begs you for mercy! Show no quarter!", "%s begs %s for mercy!" },
622 { "You slash your wrist and bleed all over %s", "%s slashes his wrist and bleeds all over you.", "%s slashes his wrist and bleeds all over %s." },
623 { "You cringe away from %s.", "%s cringes away from you.", "%s cringes away from %s in mortal terror." },
624 { NULL, NULL, NULL },
625 };
626
627 /**
628 * This function covers basic emotions a player can have. An emotion can be
629 * one of three things currently. Directed at oneself, directed at someone,
630 * or directed at nobody. The first set is nobody, the second at someone, and
631 * the third is directed at oneself. Every emotion does not have to be
632 * filled out in every category. The default case will take care of the ones
633 * that are not. Helper functions will call basic_emote with the proper
634 * arguments, translating them into commands. Adding a new emotion can be
635 * done by editing command.c and command.h.
636 * [garbled 09-25-2001]
637 *
638 * @param op
639 * player.
640 * @param params
641 * message.
642 * @param emotion
643 * emotion code, one of @ref EMOTE_xxx "EMOTE_xxx".
644 * @todo simplify function (indexed array, for instance).
645 */
646 static void basic_emote(object *op, const char *params, int emotion) {
647 char buf[MAX_BUF], buf2[MAX_BUF], buf3[MAX_BUF];
648 player *pl;
649
650 if (*params == '\0') {
651 const char *self_reply;
652 if (emotion > EMOTE_FIRST && emotion < EMOTE_LAST && single_emotes[emotion - 1][0] != NULL) {
653 self_reply = single_emotes[emotion - 1][0];
•654 snprintf(buf2, sizeof(buf2), "%s", single_emotes[emotion - 1][1], op->name);
655 } else {
656 self_reply = "You are a nut.";
657 snprintf(buf2, sizeof(buf2), "%s dances with glee.", op->name);
658 }
659
660 draw_ext_info(NDI_UNIQUE|NDI_WHITE, 0, op, MSG_TYPE_COMMUNICATION,
661 MSG_TYPE_COMMUNICATION_EMOTE, self_reply);
662 ext_info_map_except(NDI_WHITE, op->map, op, MSG_TYPE_COMMUNICATION,
663 MSG_TYPE_COMMUNICATION_EMOTE, buf2);
664 return;
665 }
666
667 pl = find_player_options(params, FIND_PLAYER_NO_HIDDEN_DM | FIND_PLAYER_PARTIAL_NAME, op->map);
668 if (pl == NULL) {
669 draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND,
670 MSG_TYPE_COMMAND_ERROR, "%s is not around.", params);
671 return;
672 }
673
674 if (pl->ob == op) {
675 /* Player doing self-emote. */
676 const char *self_reply;
677 if (emotion > EMOTE_FIRST && emotion < EMOTE_LAST && self_emotes[emotion - 1][0] != NULL) {
678 self_reply = self_emotes[emotion - 1][0];
679 snprintf(buf2, sizeof(buf2), self_emotes[emotion - 1][1], op->name);
680 } else {
681 self_reply = "My god! is that LEGAL?";
682 snprintf(buf2, sizeof(buf2), "You look away from %s.", op->name);
683 }
684
685 draw_ext_info(NDI_UNIQUE|NDI_WHITE, 0, op, MSG_TYPE_COMMUNICATION,
686 MSG_TYPE_COMMUNICATION_EMOTE, self_reply);
687 ext_info_map_except(NDI_WHITE, op->map, op, MSG_TYPE_COMMUNICATION,
688 MSG_TYPE_COMMUNICATION_EMOTE, buf2);
689 return;
690 }
691
692 if (emotion > EMOTE_FIRST && emotion < EMOTE_LAST && other_emotes[emotion - 1][0] != NULL) {
693 snprintf(buf, sizeof(buf), other_emotes[emotion - 1][0], pl->ob->name);
694 snprintf(buf2, sizeof(buf2), other_emotes[emotion - 1][1], op->name);
695 snprintf(buf3, sizeof(buf3), other_emotes[emotion - 1][2], op->name, pl->ob->name);
696 } else {
697 snprintf(buf, sizeof(buf), "You are still nuts.");
698 snprintf(buf2, sizeof(buf2), "You get the distinct feeling that %s is nuts.", op->name);
699 snprintf(buf3, sizeof(buf3), "%s is eyeing %s quizzically.", pl->ob->name, op->name);
700 }
701
702 draw_ext_info(NDI_UNIQUE|NDI_WHITE, 0, op, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_EMOTE,
703 buf);
704 draw_ext_info(NDI_UNIQUE|NDI_WHITE, 0, pl->ob, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_EMOTE,
705 buf2);
706 ext_info_map_except2(NDI_WHITE, op->map, op, pl->ob, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_EMOTE,
707 buf3);
708 }
709
710 /*
711 * everything from here on out are just wrapper calls to basic_emote
712 */
713
714 /**
715 * 'nod' command.
716 * @param op
717 * player.
718 * @param params
719 * message.
720 */
721 void command_nod(object *op, const char *params) {
722 basic_emote(op, params, EMOTE_NOD);
723 }
724
725 /**
726 * 'dance' command.
727 * @param op
728 * player.
729 * @param params
730 * message.
731 */
732 void command_dance(object *op, const char *params) {
733 basic_emote(op, params, EMOTE_DANCE);
734 }
735
736 /**
737 * 'kiss' command.
738 * @param op
739 * player.
740 * @param params
741 * message.
742 */
743 void command_kiss(object *op, const char *params) {
744 basic_emote(op, params, EMOTE_KISS);
745 }
746
747 /**
748 * 'bounce' command.
749 * @param op
750 * player.
751 * @param params
752 * message.
753 */
754 void command_bounce(object *op, const char *params) {
755 basic_emote(op, params, EMOTE_BOUNCE);
756 }
757
758 /**
759 * 'smile' command.
760 * @param op
761 * player.
762 * @param params
763 * message.
764 */
765 void command_smile(object *op, const char *params) {
766 basic_emote(op, params, EMOTE_SMILE);
767 }
768
769 /**
770 * 'cackle' command.
771 * @param op
772 * player.
773 * @param params
774 * message.
775 */
776 void command_cackle(object *op, const char *params) {
777 basic_emote(op, params, EMOTE_CACKLE);
778 }
779
780 /**
781 * 'laugh' command.
782 * @param op
783 * player.
784 * @param params
785 * message.
786 */
787 void command_laugh(object *op, const char *params) {
788 basic_emote(op, params, EMOTE_LAUGH);
789 }
790
791 /**
792 * 'giggle' command.
793 * @param op
794 * player.
795 * @param params
796 * message.
797 */
798 void command_giggle(object *op, const char *params) {
799 basic_emote(op, params, EMOTE_GIGGLE);
800 }
801
802 /**
803 * 'shake' command.
804 * @param op
805 * player.
806 * @param params
807 * message.
808 */
809 void command_shake(object *op, const char *params) {
810 basic_emote(op, params, EMOTE_SHAKE);
811 }
812
813 /**
814 * 'puke' command.
815 * @param op
816 * player.
817 * @param params
818 * message.
819 */
820 void command_puke(object *op, const char *params) {
821 basic_emote(op, params, EMOTE_PUKE);
822 }
823
824 /**
825 * 'growl' command.
826 * @param op
827 * player.
828 * @param params
829 * message.
830 */
831 void command_growl(object *op, const char *params) {
832 basic_emote(op, params, EMOTE_GROWL);
833 }
834
835 /**
836 * 'scream' command.
837 * @param op
838 * player.
839 * @param params
840 * message.
841 */
842 void command_scream(object *op, const char *params) {
843 basic_emote(op, params, EMOTE_SCREAM);
844 }
845
846 /**
847 * 'sigh' command.
848 * @param op
849 * player.
850 * @param params
851 * message.
852 */
853 void command_sigh(object *op, const char *params) {
854 basic_emote(op, params, EMOTE_SIGH);
855 }
856
857 /**
858 * 'sulk' command.
859 * @param op
860 * player.
861 * @param params
862 * message.
863 */
864 void command_sulk(object *op, const char *params) {
865 basic_emote(op, params, EMOTE_SULK);
866 }
867
868 /**
869 * 'hug' command.
870 * @param op
871 * player.
872 * @param params
873 * message.
874 */
875 void command_hug(object *op, const char *params) {
876 basic_emote(op, params, EMOTE_HUG);
877 }
878
879 /**
880 * 'cry' command.
881 * @param op
882 * player.
883 * @param params
884 * message.
885 */
886 void command_cry(object *op, const char *params) {
887 basic_emote(op, params, EMOTE_CRY);
888 }
889
890 /**
891 * 'poke' command.
892 * @param op
893 * player.
894 * @param params
895 * message.
896 */
897 void command_poke(object *op, const char *params) {
898 basic_emote(op, params, EMOTE_POKE);
899 }
900
901 /**
902 * 'accuse' command.
903 * @param op
904 * player.
905 * @param params
906 * message.
907 */
908 void command_accuse(object *op, const char *params) {
909 basic_emote(op, params, EMOTE_ACCUSE);
910 }
911
912 /**
913 * 'grin' command.
914 * @param op
915 * player.
916 * @param params
917 * message.
918 */
919 void command_grin(object *op, const char *params) {
920 basic_emote(op, params, EMOTE_GRIN);
921 }
922
923 /**
924 * 'bow' command.
925 * @param op
926 * player.
927 * @param params
928 * message.
929 */
930 void command_bow(object *op, const char *params) {
931 basic_emote(op, params, EMOTE_BOW);
932 }
933
934 /**
935 * 'clap' command.
936 * @param op
937 * player.
938 * @param params
939 * message.
940 */
941 void command_clap(object *op, const char *params) {
942 basic_emote(op, params, EMOTE_CLAP);
943 }
944
945 /**
946 * 'blush' command.
947 * @param op
948 * player.
949 * @param params
950 * message.
951 */
952 void command_blush(object *op, const char *params) {
953 basic_emote(op, params, EMOTE_BLUSH);
954 }
955
956 /**
957 * 'burp' command.
958 * @param op
959 * player.
960 * @param params
961 * message.
962 */
963 void command_burp(object *op, const char *params) {
964 basic_emote(op, params, EMOTE_BURP);
965 }
966
967 /**
968 * 'chuckle' command.
969 * @param op
970 * player.
971 * @param params
972 * message.
973 */
974 void command_chuckle(object *op, const char *params) {
975 basic_emote(op, params, EMOTE_CHUCKLE);
976 }
977
978 /**
979 * 'cough' command.
980 * @param op
981 * player.
982 * @param params
983 * message.
984 */
985 void command_cough(object *op, const char *params) {
986 basic_emote(op, params, EMOTE_COUGH);
987 }
988
989 /**
990 * 'flip' command.
991 * @param op
992 * player.
993 * @param params
994 * message.
995 */
996 void command_flip(object *op, const char *params) {
997 basic_emote(op, params, EMOTE_FLIP);
998 }
999
1000 /**
1001 * 'frown' command.
1002 * @param op
1003 * player.
1004 * @param params
1005 * message.
1006 */
1007 void command_frown(object *op, const char *params) {
1008 basic_emote(op, params, EMOTE_FROWN);
1009 }
1010
1011 /**
1012 * 'gasp' command.
1013 * @param op
1014 * player.
1015 * @param params
1016 * message.
1017 */
1018 void command_gasp(object *op, const char *params) {
1019 basic_emote(op, params, EMOTE_GASP);
1020 }
1021
1022 /**
1023 * 'glare' command.
1024 * @param op
1025 * player.
1026 * @param params
1027 * message.
1028 */
1029 void command_glare(object *op, const char *params) {
1030 basic_emote(op, params, EMOTE_GLARE);
1031 }
1032
1033 /**
1034 * 'groan' command.
1035 * @param op
1036 * player.
1037 * @param params
1038 * message.
1039 */
1040 void command_groan(object *op, const char *params) {
1041 basic_emote(op, params, EMOTE_GROAN);
1042 }
1043
1044 /**
1045 * 'hiccup' command.
1046 * @param op
1047 * player.
1048 * @param params
1049 * message.
1050 */
1051 void command_hiccup(object *op, const char *params) {
1052 basic_emote(op, params, EMOTE_HICCUP);
1053 }
1054
1055 /**
1056 * 'lick' command.
1057 * @param op
1058 * player.
1059 * @param params
1060 * message.
1061 */
1062 void command_lick(object *op, const char *params) {
1063 basic_emote(op, params, EMOTE_LICK);
1064 }
1065
1066 /**
1067 * 'pout' command.
1068 * @param op
1069 * player.
1070 * @param params
1071 * message.
1072 */
1073 void command_pout(object *op, const char *params) {
1074 basic_emote(op, params, EMOTE_POUT);
1075 }
1076
1077 /**
1078 * 'shiver' command.
1079 * @param op
1080 * player.
1081 * @param params
1082 * message.
1083 */
1084 void command_shiver(object *op, const char *params) {
1085 basic_emote(op, params, EMOTE_SHIVER);
1086 }
1087
1088 /**
1089 * 'shrug' command.
1090 * @param op
1091 * player.
1092 * @param params
1093 * message.
1094 */
1095 void command_shrug(object *op, const char *params) {
1096 basic_emote(op, params, EMOTE_SHRUG);
1097 }
1098
1099 /**
1100 * 'slap' command.
1101 * @param op
1102 * player.
1103 * @param params
1104 * message.
1105 */
1106 void command_slap(object *op, const char *params) {
1107 basic_emote(op, params, EMOTE_SLAP);
1108 }
1109
1110 /**
1111 * 'smirk' command.
1112 * @param op
1113 * player.
1114 * @param params
1115 * message.
1116 */
1117 void command_smirk(object *op, const char *params) {
1118 basic_emote(op, params, EMOTE_SMIRK);
1119 }
1120
1121 /**
1122 * 'snap' command.
1123 * @param op
1124 * player.
1125 * @param params
1126 * message.
1127 */
1128 void command_snap(object *op, const char *params) {
1129 basic_emote(op, params, EMOTE_SNAP);
1130 }
1131
1132 /**
1133 * 'sneeze' command.
1134 * @param op
1135 * player.
1136 * @param params
1137 * message.
1138 */
1139 void command_sneeze(object *op, const char *params) {
1140 basic_emote(op, params, EMOTE_SNEEZE);
1141 }
1142
1143 /**
1144 * 'snicker' command.
1145 * @param op
1146 * player.
1147 * @param params
1148 * message.
1149 */
1150 void command_snicker(object *op, const char *params) {
1151 basic_emote(op, params, EMOTE_SNICKER);
1152 }
1153
1154 /**
1155 * 'sniff' command.
1156 * @param op
1157 * player.
1158 * @param params
1159 * message.
1160 */
1161 void command_sniff(object *op, const char *params) {
1162 basic_emote(op, params, EMOTE_SNIFF);
1163 }
1164
1165 /**
1166 * 'snore' command.
1167 * @param op
1168 * player.
1169 * @param params
1170 * message.
1171 */
1172 void command_snore(object *op, const char *params) {
1173 basic_emote(op, params, EMOTE_SNORE);
1174 }
1175
1176 /**
1177 * 'spit' command.
1178 * @param op
1179 * player.
1180 * @param params
1181 * message.
1182 */
1183 void command_spit(object *op, const char *params) {
1184 basic_emote(op, params, EMOTE_SPIT);
1185 }
1186
1187 /**
1188 * 'strut' command.
1189 * @param op
1190 * player.
1191 * @param params
1192 * message.
1193 */
1194 void command_strut(object *op, const char *params) {
1195 basic_emote(op, params, EMOTE_STRUT);
1196 }
1197
1198 /**
1199 * 'thank' command.
1200 * @param op
1201 * player.
1202 * @param params
1203 * message.
1204 */
1205 void command_thank(object *op, const char *params) {
1206 basic_emote(op, params, EMOTE_THANK);
1207 }
1208
1209 /**
1210 * 'twiddle' command.
1211 * @param op
1212 * player.
1213 * @param params
1214 * message.
1215 */
1216 void command_twiddle(object *op, const char *params) {
1217 basic_emote(op, params, EMOTE_TWIDDLE);
1218 }
1219
1220 /**
1221 * 'wave' command.
1222 * @param op
1223 * player.
1224 * @param params
1225 * message.
1226 */
1227 void command_wave(object *op, const char *params) {
1228 basic_emote(op, params, EMOTE_WAVE);
1229 }
1230
1231 /**
1232 * 'whistle' command.
1233 * @param op
1234 * player.
1235 * @param params
1236 * message.
1237 */
1238 void command_whistle(object *op, const char *params) {
1239 basic_emote(op, params, EMOTE_WHISTLE);
1240 }
1241
1242 /**
1243 * 'wink' command.
1244 * @param op
1245 * player.
1246 * @param params
1247 * message.
1248 */
1249 void command_wink(object *op, const char *params) {
1250 basic_emote(op, params, EMOTE_WINK);
1251 }
1252
1253 /**
1254 * 'yawn' command.
1255 * @param op
1256 * player.
1257 * @param params
1258 * message.
1259 */
1260 void command_yawn(object *op, const char *params) {
1261 basic_emote(op, params, EMOTE_YAWN);
1262 }
1263
1264 /**
1265 * 'beg' command.
1266 * @param op
1267 * player.
1268 * @param params
1269 * message.
1270 */
1271 void command_beg(object *op, const char *params) {
1272 basic_emote(op, params, EMOTE_BEG);
1273 }
1274
1275 /**
1276 * 'bleed' command.
1277 * @param op
1278 * player.
1279 * @param params
1280 * message.
1281 */
1282 void command_bleed(object *op, const char *params) {
1283 basic_emote(op, params, EMOTE_BLEED);
1284 }
1285
1286 /**
1287 * 'cringe' command.
1288 * @param op
1289 * player.
1290 * @param params
1291 * message.
1292 */
1293 void command_cringe(object *op, const char *params) {
1294 basic_emote(op, params, EMOTE_CRINGE);
1295 }
1296
1297 /**
1298 * 'think' command.
1299 * @param op
1300 * player.
1301 * @param params
1302 * message.
1303 */
1304 void command_think(object *op, const char *params) {
1305 basic_emote(op, params, EMOTE_THINK);
1306 }