Fandom

Wikihack

Source:SLASH'EM 0.0.7E7F2/sounds.c

2,034pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Below is the full text to sounds.c from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/sounds.c#line123]], for example.

The latest source code for vanilla NetHack is at Source code.


The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)sounds.c	3.4	2002/05/06	*/
2.    /*	Copyright (c) 1989 Janet Walz, Mike Threepoint */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #include "hack.h"
6.    #include "edog.h"
7.    #ifdef USER_SOUNDS
8.    # ifdef USER_SOUNDS_REGEX
9.    #include <regex.h>
10.   # endif
11.   #endif
12.   
13.   /* Hmm.... in working on SHOUT I started thinking about things.
14.    * I think something like this should be set up:
15.    *  You_hear_mon(mon,loud, msg) - You_hear(msg); monnoise(mon,loud);
16.    *  monnoise(mon,loud) - wake_nearto(mon->mx,mon->my,mon->data->mlevel*loud)
17.    *				and stuff like that
18.    *  mon_say(mon,loud,msg) - verbalize(msg); sayeffects(mon,loud,msg);
19.    *  sayeffects(mon,loud,msg) - monnoise(mon,loud); + the pet stuff et al
20.    * In fact, I think will set this up, but as a diff, not actually modifying the
21.    * files.
22.    * If I knew something about branches I might do that.
23.    * But anyway, I should be working on petcommands now... maybe later...
24.    * -- JRN
25.    */
26.   
27.   #ifdef OVLB
28.   
29.   static int FDECL(domonnoise,(struct monst *));
30.   static int NDECL(dochat);
31.   static const char *FDECL(yelp_sound,(struct monst *));
32.   static const char *FDECL(whimper_sound,(struct monst *));
33.   
34.   #endif /* OVLB */
35.   
36.   #ifdef OVL0
37.   
38.   #ifdef DUMB
39.   static int FDECL(mon_in_room, (struct monst *,int));
40.   
41.   /* this easily could be a macro, but it might overtax dumb compilers */
42.   static int
43.   mon_in_room(mon, rmtyp)
44.   struct monst *mon;
45.   int rmtyp;
46.   {
47.       int rno = levl[mon->mx][mon->my].roomno;
48.   
49.       return rooms[rno - ROOMOFFSET].rtype == rmtyp;
50.   }
51.   #else
52.   /* JRN: converted above to macro */
53.   # define mon_in_room(mon,rmtype) (rooms[ levl[(mon)->mx][(mon)->my].roomno \
54.   					- ROOMOFFSET].rtype == (rmtype))
55.   #endif
56.   
57.   void
58.   dosounds()
59.   {
60.       register struct mkroom *sroom;
61.       register int hallu, vx, vy;
62.   #if defined(AMIGA) && defined(AZTEC_C_WORKAROUND)
63.       int xx;
64.   #endif
65.       struct monst *mtmp;
66.   
67.       if (!flags.soundok || u.uswallow || Underwater) return;
68.   
69.       hallu = Hallucination ? 1 : 0;
70.   
71.       if (level.flags.nfountains && !rn2(400)) {
72.   	static const char * const fountain_msg[4] = {
73.   		"bubbling water.",
74.   		"water falling on coins.",
75.   		"the splashing of a naiad.",
76.   		"a soda fountain!",
77.   	};
78.   	You_hear(fountain_msg[rn2(3)+hallu]);
79.       }
80.   #ifdef SINK
81.       if (level.flags.nsinks && !rn2(300)) {
82.   	static const char * const sink_msg[3] = {
83.   		"a slow drip.",
84.   		"a gurgling noise.",
85.   		"dishes being washed!",
86.   	};
87.   	You_hear(sink_msg[rn2(2)+hallu]);
88.       }
89.   #endif
90.       if (level.flags.has_court && !rn2(200)) {
91.   	static const char * const throne_msg[4] = {
92.   		"the tones of courtly conversation.",
93.   		"a sceptre pounded in judgment.",
94.   		"Someone shouts \"Off with %s head!\"",
95.   		"Queen Beruthiel's cats!",
96.   	};
97.   	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
98.   	    if (DEADMONSTER(mtmp)) continue;
99.   	    if ((mtmp->msleeping ||
100.  			is_lord(mtmp->data) || is_prince(mtmp->data)) &&
101.  		!is_animal(mtmp->data) &&
102.  		mon_in_room(mtmp, COURT)) {
103.  		/* finding one is enough, at least for now */
104.  		int which = rn2(3)+hallu;
105.  
106.  		if (which != 2) You_hear(throne_msg[which]);
107.  		else		pline(throne_msg[2], uhis());
108.  		return;
109.  	    }
110.  	}
111.      }
112.      if (level.flags.has_swamp && !rn2(200)) {
113.  	static const char * const swamp_msg[3] = {
114.  		"hear mosquitoes!",
115.  		"smell marsh gas!",	/* so it's a smell...*/
116.  		"hear Donald Duck!",
117.  	};
118.  	You(swamp_msg[rn2(2)+hallu]);
119.  	return;
120.      }
121.      if (level.flags.spooky && !rn2(200)) {
122.  	static const char *spooky_msg[24] = {
123.  		"hear screaming in the distance!",
124.  		"hear a faint whisper: \"Please leave your measurements for your custom-made coffin.\"",
125.  		"hear a door creak ominously.",
126.  		"hear hard breathing just a few steps behind you!",
127.  		"hear dragging footsteps coming closer!",
128.  		"hear anguished moaning and groaning coming out of the walls!",
129.  		"hear mad giggling directly behind you!",
130.  		"smell rotting corpses.",
131.  		"smell chloroform!",
132.  		"feel ice cold fingers stroking your neck.",
133.  		"feel a ghostly touch caressing your face.",
134.  		"feel somebody dancing on your grave.",
135.  		"feel something breathing down your neck.",
136.  		"feel as if the walls were closing in on you.",
137.  		"just stepped on something squishy.",
138.  		"hear a strong voice pronouncing: \"There can only be one!\"",
139.  		"hear a voice booming all around you: \"Warning: self-destruction sequence activated!\"",
140.  		"smell your mother-in-law's cooking!",
141.  		"smell horse dung.",
142.  		"hear someone shouting: \"Who ordered the burger?\"",
143.  		"can faintly hear the Twilight Zone theme.",
144.  		"hear an outraged customer complaining: \"I'll be back!\"",
145.  		"hear someone praising your valor!",
146.  		"hear someone singing: \"Jingle bells, jingle bells...\"",
147.  	};
148.  	You(spooky_msg[rn2(15)+hallu*9]);
149.  	return;
150.      }
151.      if (level.flags.has_vault && !rn2(200)) {
152.  	if (!(sroom = search_special(VAULT))) {
153.  	    /* strange ... */
154.  	    level.flags.has_vault = 0;
155.  	    return;
156.  	}
157.  	if(gd_sound())
158.  	    switch (rn2(2)+hallu) {
159.  		case 1: {
160.  		    boolean gold_in_vault = FALSE;
161.  
162.  		    for (vx = sroom->lx;vx <= sroom->hx; vx++)
163.  			for (vy = sroom->ly; vy <= sroom->hy; vy++)
164.  			    if (g_at(vx, vy))
165.  				gold_in_vault = TRUE;
166.  #if defined(AMIGA) && defined(AZTEC_C_WORKAROUND)
167.  		    /* Bug in aztec assembler here. Workaround below */
168.  		    xx = ROOM_INDEX(sroom) + ROOMOFFSET;
169.  		    xx = (xx != vault_occupied(u.urooms));
170.  		    if(xx)
171.  #else
172.  		    if (vault_occupied(u.urooms) !=
173.  			 (ROOM_INDEX(sroom) + ROOMOFFSET))
174.  #endif /* AZTEC_C_WORKAROUND */
175.  		    {
176.  			if (gold_in_vault)
177.  			    You_hear(!hallu ? "someone counting money." :
178.  				"the quarterback calling the play.");
179.  			else
180.  			    You_hear("someone searching.");
181.  			break;
182.  		    }
183.  		    /* fall into... (yes, even for hallucination) */
184.  		}
185.  		case 0:
186.  		    You_hear("the footsteps of a guard on patrol.");
187.  		    break;
188.  		case 2:
189.  		    You_hear("Ebenezer Scrooge!");
190.  		    break;
191.  	    }
192.  	return;
193.      }
194.      if (level.flags.has_beehive && !rn2(200)) {
195.  	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
196.  	    if (DEADMONSTER(mtmp)) continue;
197.  	    if ((mtmp->data->mlet == S_ANT && is_flyer(mtmp->data)) &&
198.  		mon_in_room(mtmp, BEEHIVE)) {
199.  		switch (rn2(2)+hallu) {
200.  		    case 0:
201.  			You_hear("a low buzzing.");
202.  			break;
203.  		    case 1:
204.  			You_hear("an angry drone.");
205.  			break;
206.  		    case 2:
207.  			You_hear("bees in your %sbonnet!",
208.  			    uarmh ? "" : "(nonexistent) ");
209.  			break;
210.  		}
211.  		return;
212.  	    }
213.  	}
214.      }
215.      if (level.flags.has_morgue && !rn2(200)) {
216.  	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
217.  	    if (DEADMONSTER(mtmp)) continue;
218.  	    if (is_undead(mtmp->data) &&
219.  		mon_in_room(mtmp, MORGUE)) {
220.  		switch (rn2(2)+hallu) {
221.  		    case 0:
222.  			You("suddenly realize it is unnaturally quiet.");
223.  			break;
224.  		    case 1:
225.  			pline_The("%s on the back of your %s stands up.",
226.  				body_part(HAIR), body_part(NECK));
227.  			break;
228.  		    case 2:
229.  			pline_The("%s on your %s seems to stand up.",
230.  				body_part(HAIR), body_part(HEAD));
231.  			break;
232.  		}
233.  		return;
234.  	    }
235.  	}
236.      }
237.      if (level.flags.has_barracks && !rn2(200)) {
238.  	static const char * const barracks_msg[4] = {
239.  		"blades being honed.",
240.  		"loud snoring.",
241.  		"dice being thrown.",
242.  		"General MacArthur!",
243.  	};
244.  	int count = 0;
245.  
246.  	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
247.  	    if (DEADMONSTER(mtmp)) continue;
248.  	    if (is_mercenary(mtmp->data) &&
249.  #if 0		/* don't bother excluding these */
250.  		!strstri(mtmp->data->mname, "watch") &&
251.  		!strstri(mtmp->data->mname, "guard") &&
252.  #endif
253.  		mon_in_room(mtmp, BARRACKS) &&
254.  		/* sleeping implies not-yet-disturbed (usually) */
255.  		(mtmp->msleeping || ++count > 5)) {
256.  		You_hear(barracks_msg[rn2(3)+hallu]);
257.  		return;
258.  	    }
259.  	}
260.      }
261.      if (level.flags.has_zoo && !rn2(200)) {
262.  	static const char * const zoo_msg[3] = {
263.  		"a sound reminiscent of an elephant stepping on a peanut.",
264.  		"a sound reminiscent of a seal barking.",
265.  		"Doctor Doolittle!",
266.  	};
267.  	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
268.  	    if (DEADMONSTER(mtmp)) continue;
269.  	    if ((mtmp->msleeping || is_animal(mtmp->data)) &&
270.  		    mon_in_room(mtmp, ZOO)) {
271.  		You_hear(zoo_msg[rn2(2)+hallu]);
272.  		return;
273.  	    }
274.  	}
275.      }
276.      if (level.flags.has_shop && !rn2(200)) {
277.  	if (!(sroom = search_special(ANY_SHOP))) {
278.  	    /* strange... */
279.  	    level.flags.has_shop = 0;
280.  	    return;
281.  	}
282.  	if (tended_shop(sroom) &&
283.  		!index(u.ushops, ROOM_INDEX(sroom) + ROOMOFFSET)) {
284.  	    static const char * const shop_msg[3] = {
285.  		    "someone cursing shoplifters.",
286.  		    "the chime of a cash register.",
287.  		    "Neiman and Marcus arguing!",
288.  	    };
289.  	    You_hear(shop_msg[rn2(2)+hallu]);
290.  	}
291.  	return;
292.      }
293.      if (Is_oracle_level(&u.uz) && !rn2(400)) {
294.  	/* make sure the Oracle is still here */
295.  	for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
296.  	    if (!DEADMONSTER(mtmp) && mtmp->data == &mons[PM_ORACLE])
297.  		break;
298.  	/* and don't produce silly effects when she's clearly visible */
299.  	if (mtmp && (hallu || !canseemon(mtmp))) {
300.  	    static const char * const ora_msg[5] = {
301.  		    "a strange wind.",		/* Jupiter at Dodona */
302.  		    "convulsive ravings.",	/* Apollo at Delphi */
303.  		    "snoring snakes.",		/* AEsculapius at Epidaurus */
304.  		    "someone say \"No more woodchucks!\"",
305.  		    "a loud ZOT!"		/* both rec.humor.oracle */
306.  	    };
307.  	    /* KMH -- Give funny messages on Groundhog Day */
308.  	    if (flags.groundhogday) hallu = 1;
309.  	    You_hear(ora_msg[rn2(3)+hallu*2]);
310.  	}
311.  	return;
312.      }
313.  #ifdef BLACKMARKET
314.      if (!Is_blackmarket(&u.uz) && at_dgn_entrance("One-eyed Sam's Market") &&
315.          !rn2(200)) {
316.        static const char *blkmar_msg[3] = {
317.          "You hear someone complaining about the prices.",
318.          "Somebody whispers: \"Food rations? Only 900 zorkmids.\"",
319.          "You feel like searching for more gold.",
320.        };
321.        pline(blkmar_msg[rn2(2)+hallu]);
322.      }
323.  #endif /* BLACKMARKET */
324.  }
325.  
326.  #endif /* OVL0 */
327.  #ifdef OVLB
328.  
329.  static const char * const h_sounds[] = {
330.      "beep", "boing", "sing", "belche", "creak", "cough", "rattle",
331.      "ululate", "pop", "jingle", "sniffle", "tinkle", "eep"
332.  };
333.  
334.  /* make the sounds of a pet in any level of distress */
335.  /* (1 = "whimper", 2 = "yelp", 3 = "growl") */
336.  void
337.  pet_distress(mtmp, lev)
338.  register struct monst *mtmp;
339.  int lev;
340.  {
341.      const char *verb;
342.      if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound)
343.  	return;
344.      /* presumably nearness and soundok checks have already been made */
345.  
346.      if (Hallucination)
347.  	verb = h_sounds[rn2(SIZE(h_sounds))];
348.      else if (lev == 3)
349.  	verb = growl_sound(mtmp);
350.      else if (lev == 2)
351.  	verb = yelp_sound(mtmp);
352.      else if (lev == 1)
353.  	verb = whimper_sound(mtmp);
354.      else
355.  	panic("strange level of distress");
356.  
357.      if (verb) {
358.  	pline("%s %s%c", Monnam(mtmp), vtense((char *)0, verb),
359.  		lev>1?'!':'.');
360.  	if (flags.run) nomul(0);
361.  	wake_nearto(mtmp->mx,mtmp->my,mtmp->data->mlevel*6*lev);
362.      }
363.  }
364.  
365.  /* the sounds of a seriously abused pet, including player attacking it */
366.  /* in extern.h: #define growl(mon) pet_distess((mon),3) */
367.  
368.  const char *
369.  growl_sound(mtmp)
370.  register struct monst *mtmp;
371.  {
372.  	const char *ret;
373.  
374.  	switch (mtmp->data->msound) {
375.  	case MS_MEW:
376.  	case MS_HISS:
377.  	    ret = "hiss";
378.  	    break;
379.  	case MS_BARK:
380.  	case MS_GROWL:
381.  	    ret = "growl";
382.  	    break;
383.  	case MS_ROAR:
384.  	    ret = "roar";
385.  	    break;
386.  	case MS_BUZZ:
387.  	    ret = "buzz";
388.  	    break;
389.  	case MS_SQEEK:
390.  	    ret = "squeal";
391.  	    break;
392.  	case MS_SQAWK:
393.  	    ret = "screech";
394.  	    break;
395.  	case MS_NEIGH:
396.  	    ret = "neigh";
397.  	    break;
398.  	case MS_WAIL:
399.  	    ret = "wail";
400.  	    break;
401.  	case MS_SILENT:
402.  		ret = "commotion";
403.  		break;
404.  	case MS_PARROT:
405.  	    ret = "squaark";
406.  	    break;
407.  	default:
408.  		ret = "scream";
409.  	}
410.  	return ret;
411.  }
412.  
413.  /* the sounds of mistreated pets */
414.  /* in extern.h: #define yelp(mon) pet_distress((mon),2) */
415.  
416.  static
417.  const char *
418.  yelp_sound(mtmp)
419.  register struct monst *mtmp;
420.  {
421.      const char *ret;
422.  
423.      switch(mtmp->data->msound) {
424.  	case MS_MEW:
425.  	ret = "yowl";
426.  	    break;
427.  	case MS_BARK:
428.  	case MS_GROWL:
429.  	ret = "yelp";
430.  	    break;
431.  	case MS_ROAR:
432.  	ret = "snarl";
433.  	    break;
434.  	case MS_SQEEK:
435.  	ret = "squeal";
436.  	    break;
437.  	case MS_SQAWK:
438.  	ret = "screak";
439.  	    break;
440.  	case MS_WAIL:
441.  	ret = "wail";
442.  	    break;
443.      default:
444.  	ret = (const char*) 0;
445.      }
446.      return ret;
447.  }
448.  
449.  /* the sounds of distressed pets */
450.  /* in extern.h: #define whimper(mon) pet_distress((mon),1) */
451.  
452.  static
453.  const char *
454.  whimper_sound(mtmp)
455.  register struct monst *mtmp;
456.  {
457.      const char *ret;
458.  
459.      switch (mtmp->data->msound) {
460.  	case MS_MEW:
461.  	case MS_GROWL:
462.  	ret = "whimper";
463.  	    break;
464.  	case MS_BARK:
465.  	ret = "whine";
466.  	    break;
467.  	case MS_SQEEK:
468.  	ret = "squeal";
469.  	    break;
470.      default:
471.  	ret = (const char *)0;
472.      }
473.      return ret;
474.  }
475.  
476.  /* pet makes "I'm hungry" noises */
477.  void
478.  beg(mtmp)
479.  register struct monst *mtmp;
480.  {
481.      if (mtmp->msleeping || !mtmp->mcanmove ||
482.  	    !(carnivorous(mtmp->data) || herbivorous(mtmp->data)))
483.  	return;
484.  
485.      /* presumably nearness and soundok checks have already been made */
486.      if (!is_silent(mtmp->data) && mtmp->data->msound <= MS_ANIMAL)
487.  	(void) domonnoise(mtmp);
488.      else if (mtmp->data->msound >= MS_HUMANOID) {
489.  	if (!canspotmon(mtmp))
490.  	    map_invisible(mtmp->mx, mtmp->my);
491.  	verbalize("I'm hungry.");
492.  }
493.  }
494.  
495.  static int
496.  domonnoise(mtmp)
497.  register struct monst *mtmp;
498.  {
499.      register const char *pline_msg = 0,	/* Monnam(mtmp) will be prepended */
500.  			*verbl_msg = 0;	/* verbalize() */
501.      struct permonst *ptr = mtmp->data;
502.      char verbuf[BUFSZ];
503.  
504.      /* presumably nearness and sleep checks have already been made */
505.      if (!flags.soundok) return(0);
506.      if (is_silent(ptr)) return(0);
507.  
508.      /* Make sure its your role's quest quardian; adjust if not */
509.      if (ptr->msound == MS_GUARDIAN && ptr != &mons[urole.guardnum]) {
510.      	int mndx = monsndx(ptr);
511.      	ptr = &mons[genus(mndx,1)];
512.      }
513.  
514.      /* be sure to do this before talking; the monster might teleport away, in
515.       * which case we want to check its pre-teleport position
516.       */
517.      if (!canspotmon(mtmp))
518.  	map_invisible(mtmp->mx, mtmp->my);
519.  
520.      switch (ptr->msound) {
521.  	case MS_ORACLE:
522.  	    return doconsult(mtmp);
523.  	case MS_PRIEST:
524.  	    priest_talk(mtmp);
525.  	    break;
526.  	case MS_LEADER:
527.  	case MS_NEMESIS:
528.  	case MS_GUARDIAN:
529.  	    quest_chat(mtmp);
530.  	    break;
531.  	case MS_SELL: /* pitch, pay, total */
532.  	    shk_chat(mtmp);
533.  	    break;
534.  	case MS_VAMPIRE:
535.  	    {
536.  	    /* vampire messages are varied by tameness, peacefulness, and time of night */
537.  		boolean isnight = night();
538.  		boolean kindred = maybe_polyd(u.umonnum == PM_VAMPIRE ||
539.  				    u.umonnum == PM_VAMPIRE_LORD ||
540.  				    u.umonnum == PM_VAMPIRE_MAGE,
541.  				    Race_if(PM_VAMPIRE));
542.  		boolean nightchild = (Upolyd && (u.umonnum == PM_WOLF ||
543.  				       u.umonnum == PM_SHADOW_WOLF ||
544.  				       u.umonnum == PM_MIST_WOLF ||
545.  				       u.umonnum == PM_WINTER_WOLF ||
546.  	    			       u.umonnum == PM_WINTER_WOLF_CUB));
547.  		const char *racenoun = (flags.female && urace.individual.f) ?
548.  					urace.individual.f : (urace.individual.m) ?
549.  					urace.individual.m : urace.noun;
550.  
551.  		if (mtmp->mtame) {
552.  			if (kindred) {
553.  				Sprintf(verbuf, "Good %s to you Master%s",
554.  					isnight ? "evening" : "day",
555.  					isnight ? "!" : ".  Why do we not rest?");
556.  				verbl_msg = verbuf;
557.  		    	} else {
558.  		    	    Sprintf(verbuf,"%s%s",
559.  				nightchild ? "Child of the night, " : "",
560.  				midnight() ?
561.  					"I can stand this craving no longer!" :
562.  				isnight ?
563.  					"I beg you, help me satisfy this growing craving!" :
564.  					"I find myself growing a little weary.");
565.  				verbl_msg = verbuf;
566.  			}
567.  		} else if (mtmp->mpeaceful) {
568.  			if (kindred && isnight) {
569.  				Sprintf(verbuf, "Good feeding %s!",
570.  	    				flags.female ? "sister" : "brother");
571.  				verbl_msg = verbuf;
572.   			} else if (nightchild && isnight) {
573.  				Sprintf(verbuf,
574.  				    "How nice to hear you, child of the night!");
575.  				verbl_msg = verbuf;
576.  	    		} else
577.  		    		verbl_msg = "I only drink... potions.";
578.      	        } else {
579.  			int vampindex;
580.  	    		static const char * const vampmsg[] = {
581.  			       /* These first two (0 and 1) are specially handled below */
582.  	    			"I vant to suck your %s!",
583.  	    			"I vill come after %s without regret!",
584.  		    	       /* other famous vampire quotes can follow here if desired */
585.  	    		};
586.  			if (kindred)
587.  			    verbl_msg = "This is my hunting ground that you dare to prowl!";
588.  			else if (youmonst.data == &mons[PM_SILVER_DRAGON] ||
589.  				 youmonst.data == &mons[PM_BABY_SILVER_DRAGON]) {
590.  			    /* Silver dragons are silver in color, not made of silver */
591.  			    Sprintf(verbuf, "%s! Your silver sheen does not frighten me!",
592.  					youmonst.data == &mons[PM_SILVER_DRAGON] ?
593.  					"Fool" : "Young Fool");
594.  			    verbl_msg = verbuf; 
595.  			} else {
596.  			    vampindex = rn2(SIZE(vampmsg));
597.  			    if (vampindex == 0) {
598.  				Sprintf(verbuf, vampmsg[vampindex], body_part(BLOOD));
599.  	    			verbl_msg = verbuf;
600.  			    } else if (vampindex == 1) {
601.  				Sprintf(verbuf, vampmsg[vampindex],
602.  					Upolyd ? an(mons[u.umonnum].mname) : an(racenoun));
603.  	    			verbl_msg = verbuf;
604.  		    	    } else
605.  			    	verbl_msg = vampmsg[vampindex];
606.  			}
607.  	        }
608.  	    }
609.  	    break;
610.  	case MS_WERE:
611.  	    if (flags.moonphase == FULL_MOON && (night() ^ !rn2(13))) {
612.  		pline("%s throws back %s head and lets out a blood curdling %s!",
613.  		      Monnam(mtmp), mhis(mtmp),
614.  		      ptr == &mons[PM_HUMAN_WERERAT] ? "shriek" : "howl");
615.  		wake_nearto(mtmp->mx, mtmp->my, 11*11);
616.  	    } else
617.  		pline_msg =
618.  		     "whispers inaudibly.  All you can make out is \"moon\".";
619.  	    break;
620.  	case MS_BARK:
621.  	    if (flags.moonphase == FULL_MOON && night()) {
622.  		pline_msg = "howls.";
623.  	    } else if (mtmp->mpeaceful) {
624.  		if (mtmp->mtame &&
625.  			(mtmp->mconf || mtmp->mflee || mtmp->mtrapped ||
626.  			 moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5))
627.  		    pline_msg = "whines.";
628.  		else if (mtmp->mtame && EDOG(mtmp)->hungrytime > moves + 1000)
629.  		    pline_msg = "yips.";
630.  		else {
631.  		    if (mtmp->data != &mons[PM_DINGO])	/* dingos do not actually bark */
632.  			    pline_msg = "barks.";
633.  		}
634.  	    } else {
635.  		pline_msg = "growls.";
636.  	    }
637.  	    break;
638.  	case MS_MEW:
639.  	    if (mtmp->mtame) {
640.  		if (mtmp->mconf || mtmp->mflee || mtmp->mtrapped ||
641.  			mtmp->mtame < 5)
642.  		    pline_msg = "yowls.";
643.  		else if (moves > EDOG(mtmp)->hungrytime)
644.  		    pline_msg = "meows.";
645.  		else if (EDOG(mtmp)->hungrytime > moves + 1000)
646.  		    pline_msg = "purrs.";
647.  		else
648.  		    pline_msg = "mews.";
649.  		break;
650.  	    } /* else FALLTHRU */
651.  	case MS_GROWL:
652.  	    pline_msg = mtmp->mpeaceful ? "snarls." : "growls!";
653.  	    break;
654.  	case MS_ROAR:
655.  	    pline_msg = mtmp->mpeaceful ? "snarls." : "roars!";
656.  	    break;
657.  	case MS_SQEEK:
658.  	    pline_msg = "squeaks.";
659.  	    break;
660.  	case MS_PARROT:
661.  	    switch (rn2(8)) {
662.  		default:
663.  		case 0:
664.  		    pline_msg = "squaarks louldly!";
665.  		    break;
666.  		case 1:
667.  		    pline_msg = "says 'Polly want a lembas wafer!'";
668.  		    break;
669.  		case 2:
670.  		    pline_msg = "says 'Nobody expects the Spanish Inquisition!'";
671.  		    break;
672.  		case 3:
673.  		    pline_msg = "says 'Who's a good boy, then?'";
674.  		    break;
675.  		case 4:
676.  		    pline_msg = "says 'Show us yer knickers!'";
677.  		    break;
678.  		case 5:
679.  		    pline_msg = "says 'You'll never make it!'";
680.  		    break;
681.  		case 6:
682.  		    pline_msg = "whistles suggestively!";
683.  		    break;
684.  		case 7:
685.  		    pline_msg = "says 'What sort of a sword do you call that!'";
686.  		    break;
687.  	    }
688.  	    break;
689.  	case MS_SQAWK:
690.  	    if (ptr == &mons[PM_RAVEN] && !mtmp->mpeaceful)
691.  	    	verbl_msg = "Nevermore!";
692.  	    else
693.  	    	pline_msg = "squawks.";
694.  	    break;
695.  	case MS_HISS:
696.  	    if (!mtmp->mpeaceful)
697.  		pline_msg = "hisses!";
698.  	    else return 0;	/* no sound */
699.  	    break;
700.  	case MS_BUZZ:
701.  	    pline_msg = mtmp->mpeaceful ? "drones." : "buzzes angrily.";
702.  	    break;
703.  	case MS_GRUNT:
704.  	    pline_msg = "grunts.";
705.  	    break;
706.  	case MS_NEIGH:
707.  	    if (mtmp->mtame < 5)
708.  		pline_msg = "neighs.";
709.  	    else if (moves > EDOG(mtmp)->hungrytime)
710.  		pline_msg = "whinnies.";
711.  	    else
712.  		pline_msg = "whickers.";
713.  	    break;
714.  	case MS_WAIL:
715.  	    pline_msg = "wails mournfully.";
716.  	    break;
717.  	case MS_GURGLE:
718.  	    pline_msg = "gurgles.";
719.  	    break;
720.  	case MS_BURBLE:
721.  	    pline_msg = "burbles.";
722.  	    break;
723.  	case MS_SHRIEK:
724.  	    pline_msg = "shrieks.";
725.  	    aggravate();
726.  	    break;
727.  	case MS_IMITATE:
728.  	    pline_msg = "imitates you.";
729.  	    break;
730.  	case MS_SHEEP:
731.  	    pline_msg = "baaaas.";
732.  	    break;
733.  	case MS_CHICKEN:
734.  	    pline_msg = "clucks.";
735.  	    break;
736.  	case MS_COW:
737.  	    pline_msg = "bellows.";
738.  	    break;
739.  	case MS_BONES:
740.  	    pline("%s rattles noisily.", Monnam(mtmp));
741.  	    You("freeze for a moment.");
742.  	    nomul(-2);
743.  	    nomovemsg = 0;
744.  	    break;
745.  	case MS_LAUGH:
746.  	    {
747.  		static const char * const laugh_msg[4] = {
748.  		    "giggles.", "chuckles.", "snickers.", "laughs.",
749.  		};
750.  		pline_msg = laugh_msg[rn2(4)];
751.  	    }
752.  	    break;
753.  	case MS_MUMBLE:
754.  	    pline_msg = "mumbles incomprehensibly.";
755.  	    break;
756.  	case MS_DJINNI:
757.  	    if (mtmp->mtame) {
758.  		verbl_msg = "Sorry, I'm all out of wishes.";
759.  	    } else if (mtmp->mpeaceful) {
760.  		if (ptr == &mons[PM_WATER_DEMON])
761.  		    pline_msg = "gurgles.";
762.  		else
763.  		    verbl_msg = "I'm free!";
764.  	    } else verbl_msg = "This will teach you not to disturb me!";
765.  	    break;
766.  	case MS_BOAST:	/* giants */
767.  	    if (!mtmp->mpeaceful) {
768.  		switch (rn2(4)) {
769.  		case 0: pline("%s boasts about %s gem collection.",
770.  			      Monnam(mtmp), mhis(mtmp));
771.  			break;
772.  		case 1: pline_msg = "complains about a diet of mutton.";
773.  			break;
774.  	       default: pline_msg = "shouts \"Fee Fie Foe Foo!\" and guffaws.";
775.  			wake_nearto(mtmp->mx, mtmp->my, 7*7);
776.  			break;
777.  		}
778.  		break;
779.  	    }
780.  	    /* else FALLTHRU */
781.  	case MS_HUMANOID:
782.  	    if (!mtmp->mpeaceful) {
783.  		if (In_endgame(&u.uz) && is_mplayer(ptr)) {
784.  		    mplayer_talk(mtmp);
785.  		    break;
786.  		} else return 0;	/* no sound */
787.  	    }
788.  	    /* Generic peaceful humanoid behaviour. */
789.  	    if (mtmp->mflee)
790.  		pline_msg = "wants nothing to do with you.";
791.  	    else if (mtmp->mhp < mtmp->mhpmax/4)
792.  		pline_msg = "moans.";
793.  	    else if (mtmp->mconf || mtmp->mstun)
794.  		verbl_msg = !rn2(3) ? "Huh?" : rn2(2) ? "What?" : "Eh?";
795.  	    else if (!mtmp->mcansee)
796.  		verbl_msg = "I can't see!";
797.  	    else if (mtmp->mtrapped) {
798.  		struct trap *t = t_at(mtmp->mx, mtmp->my);
799.  
800.  		if (t) t->tseen = 1;
801.  		verbl_msg = "I'm trapped!";
802.  	    } else if (mtmp->mhp < mtmp->mhpmax/2)
803.  		pline_msg = "asks for a potion of healing.";
804.  	    else if (mtmp->mtame && !mtmp->isminion &&
805.  						moves > EDOG(mtmp)->hungrytime)
806.  		verbl_msg = "I'm hungry.";
807.  	    /* Specific monsters' interests */
808.  	    else if (is_elf(ptr))
809.  		pline_msg = "curses orcs.";
810.  	    else if (is_dwarf(ptr))
811.  		pline_msg = "talks about mining.";
812.  	    else if (likes_magic(ptr))
813.  		pline_msg = "talks about spellcraft.";
814.  	    else if (ptr->mlet == S_CENTAUR)
815.  		pline_msg = "discusses hunting.";
816.  	    else switch (monsndx(ptr)) {
817.  		case PM_HOBBIT:
818.  		    pline_msg = (mtmp->mhpmax - mtmp->mhp >= 10) ?
819.  				"complains about unpleasant dungeon conditions."
820.  				: "asks you about the One Ring.";
821.  		    break;
822.  #if 0	/* OBSOLETE */
823.  		case PM_FARMER_MAGGOT:
824.  			pline_msg = "mumbles something about Morgoth.";
825.  			break;
826.  #endif
827.  		case PM_ARCHEOLOGIST:
828.      pline_msg = "describes a recent article in \"Spelunker Today\" magazine.";
829.  		    break;
830.  #ifdef TOURIST
831.  		case PM_TOURIST:
832.  		    verbl_msg = "Aloha.";
833.  		    break;
834.  #endif
835.  		default:
836.  		    pline_msg = "discusses dungeon exploration.";
837.  		    break;
838.  	    }
839.  	    break;
840.  	case MS_SEDUCE:
841.  #ifdef SEDUCE
842.  	    if (ptr->mlet != S_NYMPH &&
843.  		could_seduce(mtmp, &youmonst, (struct attack *)0) == 1) {
844.  			(void) doseduce(mtmp);
845.  			break;
846.  	    }
847.  	    switch ((poly_gender() != (int) mtmp->female) ? rn2(3) : 0)
848.  #else
849.  	    switch ((poly_gender() == 0) ? rn2(3) : 0)
850.  #endif
851.  	    {
852.  		case 2:
853.  			verbl_msg = "Hello, sailor.";
854.  			break;
855.  		case 1:
856.  			pline_msg = "comes on to you.";
857.  			break;
858.  		default:
859.  			pline_msg = "cajoles you.";
860.  	    }
861.  	    break;
862.  #ifdef KOPS
863.  	case MS_ARREST:
864.  	    if (mtmp->mpeaceful)
865.  		verbalize("Just the facts, %s.",
866.  		      flags.female ? "Ma'am" : "Sir");
867.  	    else {
868.  		static const char * const arrest_msg[3] = {
869.  		    "Anything you say can be used against you.",
870.  		    "You're under arrest!",
871.  		    "Stop in the name of the Law!",
872.  		};
873.  		verbl_msg = arrest_msg[rn2(3)];
874.  	    }
875.  	    break;
876.  #endif
877.  	case MS_BRIBE:
878.  	    if (mtmp->mpeaceful && !mtmp->mtame) {
879.  		(void) demon_talk(mtmp);
880.  		break;
881.  	    }
882.  	    /* fall through */
883.  	case MS_CUSS:
884.  	    if (!mtmp->mpeaceful)
885.  		cuss(mtmp);
886.  	    break;
887.  	case MS_GYPSY:	/* KMH */
888.  		if (mtmp->mpeaceful) {
889.  			gypsy_chat(mtmp);
890.  			break;
891.  		}
892.  		/* fall through */
893.  	case MS_SPELL:
894.  	    /* deliberately vague, since it's not actually casting any spell */
895.  	    pline_msg = "seems to mutter a cantrip.";
896.  	    break;
897.  	case MS_NURSE:
898.  	    if (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
899.  		|| (u.twoweap && uswapwep && (uswapwep->oclass == WEAPON_CLASS
900.  		|| is_weptool(uswapwep))))
901.  		verbl_msg = "Put that weapon away before you hurt someone!";
902.  	    else if (uarmc || uarm || uarmh || uarms || uarmg || uarmf)
903.  		verbl_msg = Role_if(PM_HEALER) ?
904.  			  "Doc, I can't help you unless you cooperate." :
905.  			  "Please undress so I can examine you.";
906.  #ifdef TOURIST
907.  	    else if (uarmu)
908.  		verbl_msg = "Take off your shirt, please.";
909.  #endif
910.  	    else verbl_msg = "Relax, this won't hurt a bit.";
911.  	    break;
912.  	case MS_GUARD:
913.  #ifndef GOLDOBJ
914.  	    if (u.ugold)
915.  #else
916.  	    if (money_cnt(invent))
917.  #endif
918.  		verbl_msg = "Please drop that gold and follow me.";
919.  	    else
920.  		verbl_msg = "Please follow me.";
921.  	    break;
922.  	case MS_SOLDIER:
923.  	    {
924.  		static const char * const soldier_foe_msg[3] = {
925.  		    "Resistance is useless!",
926.  		    "You're dog meat!",
927.  		    "Surrender!",
928.  		},		  * const soldier_pax_msg[3] = {
929.  		    "What lousy pay we're getting here!",
930.  		    "The food's not fit for Orcs!",
931.  		    "My feet hurt, I've been on them all day!",
932.  		};
933.  		verbl_msg = mtmp->mpeaceful ? soldier_pax_msg[rn2(3)]
934.  					    : soldier_foe_msg[rn2(3)];
935.  	    }
936.  	    break;
937.  	case MS_RIDER:
938.  	    if (ptr == &mons[PM_DEATH] && !rn2(10))
939.  		pline_msg = "is busy reading a copy of Sandman #8.";
940.  	    else verbl_msg = "Who do you think you are, War?";
941.  	    break;
942.      }
943.  
944.      if (pline_msg) pline("%s %s", Monnam(mtmp), pline_msg);
945.      else if (verbl_msg) verbalize(verbl_msg);
946.      return(1);
947.  }
948.  
949.  
950.  int
951.  dotalk()
952.  {
953.      int result;
954.      boolean save_soundok = flags.soundok;
955.      flags.soundok = 1;	/* always allow sounds while chatting */
956.      result = dochat();
957.      flags.soundok = save_soundok;
958.      return result;
959.  }
960.  
961.  static int
962.  dochat()
963.  {
964.      register struct monst *mtmp;
965.      register int tx,ty;
966.      struct obj *otmp;
967.  
968.      if (is_silent(youmonst.data)) {
969.  	pline("As %s, you cannot speak.", an(youmonst.data->mname));
970.  	return(0);
971.      }
972.      if (Strangled) {
973.  	You_cant("speak.  You're choking!");
974.  	return(0);
975.      }
976.      if (u.uswallow) {
977.  	pline("They won't hear you out there.");
978.  	return(0);
979.      }
980.      if (Underwater) {
981.  	Your("speech is unintelligible underwater.");
982.  	return(0);
983.      }
984.  
985.      if (!Blind && (otmp = shop_object(u.ux, u.uy)) != (struct obj *)0) {
986.  	/* standing on something in a shop and chatting causes the shopkeeper
987.  	   to describe the price(s).  This can inhibit other chatting inside
988.  	   a shop, but that shouldn't matter much.  shop_object() returns an
989.  	   object iff inside a shop and the shopkeeper is present and willing
990.  	   (not angry) and able (not asleep) to speak and the position contains
991.  	   any objects other than just gold.
992.  	*/
993.  	price_quote(otmp);
994.  	return(1);
995.      }
996.  
997.      if (!getdir("Talk to whom? (in what direction)")) {
998.  	/* decided not to chat */
999.  	return(0);
1000.     }
1001. 
1002. #ifdef STEED
1003.     if (u.usteed && u.dz > 0)
1004. 	return (domonnoise(u.usteed));
1005. #endif
1006.     if (u.dz) {
1007. 	pline("They won't hear you %s there.", u.dz < 0 ? "up" : "down");
1008. 	return(0);
1009.     }
1010. 
1011.     if (u.dx == 0 && u.dy == 0) {
1012. /*
1013.  * Let's not include this.  It raises all sorts of questions: can you wear
1014.  * 2 helmets, 2 amulets, 3 pairs of gloves or 6 rings as a marilith,
1015.  * etc...  --KAA
1016. 	if (u.umonnum == PM_ETTIN) {
1017. 	    You("discover that your other head makes boring conversation.");
1018. 	    return(1);
1019. 	}
1020. */
1021. 	pline("Talking to yourself is a bad habit for a dungeoneer.");
1022. 	return(0);
1023.     }
1024. 
1025.     tx = u.ux+u.dx; ty = u.uy+u.dy;
1026.     mtmp = m_at(tx, ty);
1027. 
1028.     if (!mtmp || mtmp->mundetected ||
1029. 		mtmp->m_ap_type == M_AP_FURNITURE ||
1030. 		mtmp->m_ap_type == M_AP_OBJECT)
1031. 	return(0);
1032. 
1033.     /* sleeping monsters won't talk, except priests (who wake up) */
1034.     if ((!mtmp->mcanmove || mtmp->msleeping) && !mtmp->ispriest) {
1035. 	/* If it is unseen, the player can't tell the difference between
1036. 	   not noticing him and just not existing, so skip the message. */
1037. 	if (canspotmon(mtmp))
1038. 	    pline("%s seems not to notice you.", Monnam(mtmp));
1039. 	return(0);
1040.     }
1041. 
1042.     /* if this monster is waiting for something, prod it into action */
1043.     mtmp->mstrategy &= ~STRAT_WAITMASK;
1044. 
1045.     if (mtmp->mtame && mtmp->meating) {
1046. 	if (!canspotmon(mtmp))
1047. 	    map_invisible(mtmp->mx, mtmp->my);
1048. 	pline("%s is eating noisily.", Monnam(mtmp));
1049. 	return (0);
1050.     }
1051. 
1052.     return domonnoise(mtmp);
1053. }
1054. 
1055. #ifdef USER_SOUNDS
1056. 
1057. extern void FDECL(play_usersound, (const char*, int));
1058. 
1059. typedef struct audio_mapping_rec {
1060. #ifdef USER_SOUNDS_REGEX
1061. 	struct re_pattern_buffer regex;
1062. #else
1063. 	char *pattern;
1064. #endif
1065. 	char *filename;
1066. 	int volume;
1067. 	struct audio_mapping_rec *next;
1068. } audio_mapping;
1069. 
1070. static audio_mapping *soundmap = 0;
1071. 
1072. char* sounddir = ".";
1073. 
1074. /* adds a sound file mapping, returns 0 on failure, 1 on success */
1075. int
1076. add_sound_mapping(mapping)
1077. const char *mapping;
1078. {
1079. 	char text[256];
1080. 	char filename[256];
1081. 	char filespec[256];
1082. 	int volume;
1083. 
1084. 	if (sscanf(mapping, "MESG \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d",
1085. 		   text, filename, &volume) == 3) {
1086. 	    const char *err;
1087. 	    audio_mapping *new_map;
1088. 
1089. 	    if (strlen(sounddir) + strlen(filename) > 254) {
1090. 		raw_print("sound file name too long");
1091. 		return 0;
1092. 	    }
1093. 	    Sprintf(filespec, "%s/%s", sounddir, filename);
1094. 
1095. 	    if (can_read_file(filespec)) {
1096. 		new_map = (audio_mapping *)alloc(sizeof(audio_mapping));
1097. #ifdef USER_SOUNDS_REGEX
1098. 		new_map->regex.translate = 0;
1099. 		new_map->regex.fastmap = 0;
1100. 		new_map->regex.buffer = 0;
1101. 		new_map->regex.allocated = 0;
1102. 		new_map->regex.regs_allocated = REGS_FIXED;
1103. #else
1104. 		new_map->pattern = (char *)alloc(strlen(text) + 1);
1105. 		Strcpy(new_map->pattern, text);
1106. #endif
1107. 		new_map->filename = strdup(filespec);
1108. 		new_map->volume = volume;
1109. 		new_map->next = soundmap;
1110. 
1111. #ifdef USER_SOUNDS_REGEX
1112. 		err = re_compile_pattern(text, strlen(text), &new_map->regex);
1113. #else
1114. 		err = 0;
1115. #endif
1116. 		if (err) {
1117. 		    raw_print(err);
1118. 		    free(new_map->filename);
1119. 		    free(new_map);
1120. 		    return 0;
1121. 		} else {
1122. 		    soundmap = new_map;
1123. 		}
1124. 	    } else {
1125. 		Sprintf(text, "cannot read %.243s", filespec);
1126. 		raw_print(text);
1127. 		return 0;
1128. 	    }
1129. 	} else {
1130. 	    raw_print("syntax error in SOUND");
1131. 	    return 0;
1132. 	}
1133. 
1134. 	return 1;
1135. }
1136. 
1137. void
1138. play_sound_for_message(msg)
1139. const char* msg;
1140. {
1141. 	audio_mapping* cursor = soundmap;
1142. 
1143. 	while (cursor) {
1144. #ifdef USER_SOUNDS_REGEX
1145. 	    if (re_search(&cursor->regex, msg, strlen(msg), 0, 9999, 0) >= 0) {
1146. #else
1147. 	    if (pmatch(cursor->pattern, msg)) {
1148. #endif
1149. 		play_usersound(cursor->filename, cursor->volume);
1150. 	    }
1151. 	    cursor = cursor->next;
1152. 	}
1153. }
1154. 
1155. #endif /* USER_SOUNDS */
1156. 
1157. #endif /* OVLB */
1158. 
1159. /*sounds.c*/

Also on Fandom

Random Wiki