Source:NetHack 3.0.0/sounds.c

Below is the full text to sounds.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/sounds.c#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

1.   /*	SCCS Id: @(#)sounds.c	3.0	88/06/19 */ 2.   /* NetHack may be freely redistributed. See license for details. */ 3.    /* Copyright (c) 1989 Janet Walz, Mike Threepoint */ 4.    5.    /* block some unused #defines to avoid overloading some cpp's */ 6.    7.    #define ONAMES_H 8.   #include "hack.h"  9.    #include "edog.h"  10. 11.  void 12.  verbalize(str) 13.  register char *str; 14.  {  15.   	if(flags.soundok) pline("\"%s\"", str); 16.  }  17.    18.   #ifdef SOUNDS 19.   20.   void 21.  dosounds 22.  {  23.       register xchar hallu; 24.      register struct mkroom *sroom; 25.      register xchar roomtype; 26.      register int croomno; 27.   28.       hallu = Hallucination ? 1 : 0; 29.    30.       if(!flags.soundok || u.uswallow) return; 31.   32.       if (fountsound && !rn2(400)) 33.  	switch (rn2(3)+hallu) { 34.  	    case 0: 35.  		You("hear bubbling water."); 36.  		break; 37.  	    case 1: 38.  		You("hear water falling on coins..."); 39.  		break; 40.  	    case 2: 41.  		You("hear the splashing of a naiad."); 42.  		break; 43.  	    case 3: 44.  		You("seem to hear a soda fountain!"); 45.  		break; 46.  	}  47.       if (sinksound && !rn2(300)) 48.  	switch (rn2(2)+hallu) { 49.  	    case 0: 50.  		You("hear a slow drip."); 51.  		break; 52.  	    case 1: 53.  		You("hear a gurgling noise."); 54.  		break; 55.  	    case 2: 56.  		You("seem to hear dishes being washed!"); 57.  		break; 58.  	}  59.       if (!rn2(300)) { 60.  	roomtype = OROOM; 61.  	for (sroom = &rooms[0]; ; sroom++) {	/* find any special room */ 62.  	    if (sroom->hx < 0) break;		/* no more rooms */ 63.  	    if (sroom->rtype != OROOM) { 64.  		if (sroom->rtype < SHOPBASE) 65.  		    roomtype = sroom->rtype; 66.  		else { 67.  		    croomno = inroom(u.ux,u.uy); 68.  		    if (croomno == -1 || sroom != &rooms[croomno]) 69.  			/* player not presently in shop */ 70.  			/* other special room types disappear when player 71.  			   enters */ 72.  			roomtype = SHOPBASE; 73.  		}  74.   		break; 75.  	    }  76.   	}  77.   	switch (roomtype) { 78.  #ifdef THRONES 79.  	    case COURT: 80.  		switch (rn2(3)+hallu) { 81.  		    case 0: 82.  			You("hear the tones of courtly conversation."); 83.  			break; 84.  		    case 1: 85.  			You("hear a sceptre being pounded in judgement."); 86.  			break; 87.  		    case 2: 88.  			pline("Someone just shouted \"Off with %s head!\"",  89.   			    flags.female ? "her" : "his"); 90.  			break; 91.  		    case 3: 92.  			You("seem to hear Queen Beruthiel's cats!"); 93.  			break; 94.  		}  95.   		break; 96.  #endif 97.  	    case SWAMP: 98.  		switch (rn2(2)+hallu) { 99.  		    case 0: 100. 			You("hear mosquitoes!"); 101. 			break; 102. 		    case 1: 103. 			You("smell marsh gas!");	/* so it's a smell...*/ 104. 			break; 105. 		    case 2: 106. 			You("seem to hear Donald Duck."); 107. 			break; 108. 		}  109.  		break; 110. 	    case VAULT: 111. 		switch (rn2(2)+hallu) { 112. 		    case 0: 113. 			You("hear someone counting money."); 114. 			break; 115. 		    case 1: 116. 			You("hear the footsteps of a guard on patrol."); 117. 			break; 118. 		    case 2: 119. 			You("seem to hear Ebenezer Scrooge!"); 120. 			break; 121. 		}  122.  		break; 123. 	    case BEEHIVE: 124. 		switch (rn2(2)+hallu) { 125. 		    case 0: 126. 			You("hear a low buzzing."); 127. 			break; 128. 		    case 1: 129. 			You("hear an angry drone."); 130. 			break; 131. 		    case 2: 132. 			You("seem to hear bees in your %shelmet!",  133.  			    uarmh ? "" : "(nonexistent) "); 134. 			break; 135. 		}  136.  		break; 137. 	    case MORGUE: 138. 		switch (rn2(2)+hallu) { 139. 		    case 0: 140. 		    You("suddenly realize it is unnaturally quiet."); 141. 			break; 142. 		    case 1: 143. 			pline("The hair on the back of your %s stands up.",  144.  				body_part(NECK)); 145. 			break; 146. 		    case 2: 147. 			pline("The hair on your %s seems to stand up.",  148.  				body_part(HEAD)); 149. 			break; 150. 		}  151.  		break; 152. 	    case BARRACKS: 153. 		switch (rn2(3)+hallu) { 154. 		    case 0: 155. 			You("hear dice being thrown."); 156. 			break; 157. 		    case 1: 158. 			You("hear blades being honed."); 159. 			break; 160. 		    case 2: 161. 			You("hear loud snoring."); 162. 			break; 163. 		    case 3: 164. 			You("seem to hear General MacArthur!"); 165. 			break; 166. 		}  167.  		break; 168. 	    case ZOO: 169. 		switch (rn2(2)+hallu) { 170. 		    case 0: 171. You("hear a sound reminding you of an elephant stepping on a peanut."); 172. 			break; 173. 		    case 1: 174. 		    You("hear a sound reminding you of a trained seal."); 175. 			break; 176. 		    case 2: 177. 			You("seem to hear Doctor Doolittle!"); 178. 			break; 179. 		}  180.  		break; 181. 	    case SHOPBASE: 182. 		switch (rn2(2)+hallu) { 183. 		    case 0: 184. 			You("hear the chime of a cash register."); 185. 			break; 186. 		    case 1: 187. 			You("hear someone cursing shoplifters."); 188. 			break; 189. 		    case 2: 190. 			You("seem to hear Neiman and Marcus arguing!"); 191. 			break; 192. 		}  193.  		break; 194. 	    default: 195. 		break; 196. 	}  197.      }  198.  }  199.   200.   201.  #include "eshk.h"  202. 203. #define NOTANGRY(mon)	mon->mpeaceful 204. #define ANGRY(mon)	!NOTANGRY(mon) 205.  206.  void 207. growl(mtmp) 208. register struct monst *mtmp; 209. {  210.      /* presumably nearness and soundok checks have already been made */ 211.     switch (mtmp->data->msound) { 212. 	case MS_SILENT: 213. 	    break; 214. 	case MS_MEW: 215. 	case MS_HISS: 216. 	    pline("%s hisses!", Monnam(mtmp)); 217. 	    break; 218. 	case MS_BARK: 219. 	case MS_GROWL: 220. 	    pline("%s growls!", Monnam(mtmp)); 221. 	    break; 222. 	case MS_ROAR: 223. 	    pline("%s roars!", Monnam(mtmp)); 224. 	    break; 225. 	case MS_BUZZ: 226. 	    kludge("%s buzzes!", Monnam(mtmp)); 227. 	    break; 228. 	case MS_SQEEK: 229. 	    kludge("%s squeals!", Monnam(mtmp)); 230. 	    break; 231. 	case MS_SQAWK: 232. 	    kludge("%s screeches!", Monnam(mtmp)); 233. 	    break; 234. 	case MS_NEIGH: 235. 	    kludge("%s neighs!", Monnam(mtmp)); 236. 	    break; 237.     }  238.  }  239.   240.  void 241. yelp(mtmp) 242. register struct monst *mtmp; 243. /* the sounds of mistreated pets */ 244. {  245.      /* presumably nearness and soundok checks have already been made */ 246.     switch (mtmp->data->msound) { 247. 	case MS_MEW: 248. 	    pline("%s yowls!", Monnam(mtmp)); 249. 	    break; 250. 	case MS_BARK: 251. 	case MS_GROWL: 252. 	    pline("%s yelps!", Monnam(mtmp)); 253. 	    break; 254. 	case MS_ROAR: 255. 	    kludge("%s snarls!", Monnam(mtmp)); 256. 	    break; 257. 	case MS_SQEEK: 258. 	    kludge("%s squeals!", Monnam(mtmp)); 259. 	    break; 260. 	case MS_SQAWK: 261. 	    kludge("%s screaks!", Monnam(mtmp)); 262. 	    break; 263.     }  264.  }  265.   266.  void 267. whimper(mtmp) 268. register struct monst *mtmp; 269. /* the sounds of distressed pets */ 270. {  271.      /* presumably nearness and soundok checks have already been made */ 272.     switch (mtmp->data->msound) { 273. 	case MS_MEW: 274. 	case MS_GROWL: 275. 	    pline("%s whimpers.", Monnam(mtmp)); 276. 	    break; 277. 	case MS_BARK: 278. 	    pline("%s whines.", Monnam(mtmp)); 279. 	    break; 280. 	case MS_SQEEK: 281. 	    kludge("%s squeals.", Monnam(mtmp)); 282. 	    break; 283.     }  284.  }  285.  #endif /* SOUNDS */ 286.  287.   288.  static int 289. domonnoise(mtmp) 290. register struct monst *mtmp; 291. {  292.      /* presumably nearness checks have already been made */ 293.     if (!flags.soundok) return(0); 294.     switch (mtmp->data->msound) { 295. #ifdef ORACLE 296. 	case MS_ORACLE: 297. 	    return doconsult(mtmp); 298. #endif 299. #if defined(ALTARS) && defined(THEOLOGY) 300. 	case MS_PRIEST: 301. 	    priest_talk(mtmp); 302. 	    break; 303. #endif 304. #ifdef SOUNDS 305. 	case MS_SILENT: 306. 	    break; 307. 	case MS_SQEEK: 308. 	    kludge("%s squeaks.", Monnam(mtmp)); 309. 	    break; 310. 	case MS_SQAWK: 311. 	    kludge("%s squawks.", Monnam(mtmp)); 312. 	    break; 313. 	case MS_MEW: 314. 	    if (mtmp->mtame) { 315. 		if (mtmp->mconf || mtmp->mflee || mtmp->mtrapped ||  316.  		    moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5) 317. 		    kludge("%s yowls.", Monnam(mtmp)); 318. 		else if (EDOG(mtmp)->hungrytime > moves + 1000) 319. 		    kludge("%s purrs.", Monnam(mtmp)); 320. 		else 321. 		    kludge("%s mews.", Monnam(mtmp)); 322. 	    }  323.  	case MS_HISS: 324. 	    if (!mtmp->mpeaceful && !mtmp->mtame) 325. 		kludge("%s hisses!", Monnam(mtmp)); 326. 	    break; 327. 	case MS_BUZZ: 328. 	    if (!mtmp->mpeaceful && !mtmp->mtame) 329. 		kludge("%s buzzes angrily.", Monnam(mtmp)); 330. 	    break; 331. 	case MS_GRUNT: 332. 	    kludge("%s grunts.", Monnam(mtmp)); 333. 	    break; 334. 	case MS_BARK: 335. 	    if (flags.moonphase == FULL_MOON && night) { 336. 		kludge("%s howls.", Monnam(mtmp)); 337. 		break; 338. 	    } else if (mtmp->mtame || mtmp->mpeaceful) { 339. 		if (mtmp->mtame &&  340.  		    (mtmp->mconf || mtmp->mflee || mtmp->mtrapped || 341. 		     moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5)) 342. 		    kludge("%s whines.", Monnam(mtmp)); 343. 		else if (EDOG(mtmp)->hungrytime > moves + 1000) 344. 		    kludge("%s yips.", Monnam(mtmp)); 345. 		else 346. 		    kludge("%s barks.", Monnam(mtmp)); 347. 		break; 348. 	    }  349.  	case MS_GROWL: 350. 	    if (!mtmp->mpeaceful && !mtmp->mtame) 351. 		kludge("%s growls!", Monnam(mtmp)); 352. 	    break; 353. 	case MS_ROAR: 354. 	    if (!mtmp->mpeaceful && !mtmp->mtame) 355. 		kludge("%s roars!", Monnam(mtmp)); 356. 	    break; 357. 	case MS_NEIGH: 358. 	    kludge("%s neighs.", Monnam(mtmp)); 359. 	    break; 360. 	case MS_WAIL: 361. 	    kludge("%s wails mournfully.", Monnam(mtmp)); 362. 	    break; 363. 	case MS_GURGLE: 364. 	    kludge("%s gurgles.", Monnam(mtmp)); 365. 	    break; 366. 	case MS_SHRIEK: 367. 	    kludge("%s shrieks.", Monnam(mtmp)); 368. 	    aggravate; 369. 	    break; 370. 	case MS_IMITATE: 371. 	    kludge("%s imitates you.", Monnam(mtmp)); 372. 	    break; 373. 	case MS_DJINNI: 374. 	    if (mtmp->mtame) verbalize("Thank you for freeing me!"); 375. 	    else if (mtmp->mpeaceful) verbalize("I'm free!"); 376. 	    else verbalize("This will teach you not to disturb me!"); 377. 	    break; 378. 	case MS_MUMBLE: 379. 	    kludge("%s mumbles incomprehensibly.", Monnam(mtmp)); 380. 	    break; 381. 	case MS_HUMANOID: 382. 	    /* Generic humanoid behaviour. */ 383.  	    if (!mtmp->mpeaceful || !mtmp->mtame) break; 384. 	    if (mtmp->mhp < 10) 385. 		kludge("%s moans.", Monnam(mtmp)); 386. 	    else if (mtmp->mflee) 387. 		kludge("%s wants nothing to do with you.", Monnam(mtmp)); 388. 	    else if (mtmp->mconf || mtmp->mstun) 389. 		verbalize(!rn2(3) ? "Huh?" : rn2(2) ? "What?" : "Eh?"); 390. 	    else if (mtmp->mblinded) 391. 		verbalize("I can't see!"); 392. 	    else if (mtmp->mtrapped) 393. 		verbalize("I'm trapped!"); 394. 	    else if (mtmp->mhp < mtmp->mhpmax/2) 395. 		kludge("%s asks for a potion of healing.", Monnam(mtmp)); 396. 	    /* Specific monster's interests */ 397. 	    else if (is_elf(mtmp->data)) 398. 		kludge("%s complains about orcs.", Monnam(mtmp)); 399. 	    else if (is_dwarf(mtmp->data)) 400. 		kludge("%s talks about mining.", Monnam(mtmp)); 401. 	    else if (likes_magic(mtmp->data)) 402. 		kludge("%s talks about spellcraft.", Monnam(mtmp)); 403. 	    else if (carnivorous(mtmp->data)) 404. 		kludge("%s discusses what kinds of meat are safe to eat.", Monnam(mtmp)); 405. 	    else switch (monsndx(mtmp->data)){ 406. # ifdef TOLKIEN 407. 		case PM_HOBBIT: 408. 		    if (mtmp->mhpmax - mtmp->mhp >= 10) 409. kludge("%s complains about unpleasant dungeon conditions.", Monnam(mtmp)); 410. 		    else 411. 		    	kludge("%s asks you about the One Ring.", Monnam(mtmp)); 412. 		    break; 413. # endif 414. 		case PM_ARCHEOLOGIST: 415. kludge("%s describes a recent article in \"Spelunker Today\" magazine.", Monnam(mtmp)); 416. 		    break; 417. 		default: 418. 		    kludge("%s discusses dungeon exploration.", Monnam(mtmp)); 419. 	    }  420.  	    break; 421. 	case MS_SEDUCE: 422. # ifdef SEDUCE 423. 	    if ((mtmp->data==&mons[PM_SUCCUBUS] || 424. 		mtmp->data==&mons[PM_INCUBUS])) { 425. 		doseduce(mtmp); 426. 		break; 427. 	    }  428.  # endif 429. 	    switch (poly_gender == 0 ? rn2(3) : 0) { 430. 		case 2: 431. 			verbalize("Hello, sailor."); 432. 			break; 433. 		case 1: 434. 			kludge("%s comes on to you.", Monnam(mtmp)); 435. 			break; 436. 		default: 437. 			kludge("%s cajoles you.", Monnam(mtmp)); 438. 	    }  439.  	    break; 440. # ifdef KOPS 441. 	case MS_ARREST: 442. 	    if (mtmp->mpeaceful) 443. 		pline("\"Just the facts, %s.\"",  444.  		      flags.female ? "Ma'am" : "Sir"); 445. 	    else switch (rn2(3)) { 446. 		case 1: 447. 		    verbalize("Anything you say can be used against you."); 448. 		    break; 449. 		case 2: 450. 		    verbalize("You're under arrest!"); 451. 		    break; 452. 		default: 453. 		    verbalize("Stop in the name of the Law!"); 454. 	    }  455.  	    break; 456. # endif 457. 	case MS_LAUGH: 458. 	    switch (rn2(4)) { 459. 		case 1: 460. 		    kludge("%s giggles.", Monnam(mtmp)); 461. 		    break; 462. 		case 2: 463. 		    kludge("%s chuckles.", Monnam(mtmp)); 464. 		    break; 465. 		case 3: 466. 		    kludge("%s snickers.", Monnam(mtmp)); 467. 		    break; 468. 		default: 469. 		    kludge("%s laughs.", Monnam(mtmp)); 470. 	    }  471.  	    break; 472. # ifdef HARD 473. 	case MS_BRIBE: 474. 	    if (mtmp->mpeaceful && !mtmp->mtame) { 475. 		(void) demon_talk(mtmp); 476. 		break; 477. 	    }  478.  # endif 479. 	case MS_JEER: 480. 	    kludge("%s jeers at you.", Monnam(mtmp)); 481. 	    break; 482. 	case MS_CUSS: 483. 	    cuss(mtmp); 484. 	    break; 485. 	case MS_GUARD: 486. 	    if (u.ugold) 487. 		verbalize("Please drop that gold and follow me."); 488. 	    else 489. 		verbalize("Please follow me."); 490. 	    break; 491. 	case MS_NURSE: 492. 	    if (uwep) 493. 		verbalize("Put that weapon away before you hurt someone!"); 494. 	    else if (uarmc || uarm || uarmh || uarms || uarmg || uarmf) 495. 		if (pl_character[0] == 'H') 496. 		    verbalize("Doc, I can't help you unless you cooperate."); 497. 		else 498. 		    verbalize("Please undress so I can examine you."); 499. # ifdef SHIRT 500. 	    else if (uarmu) 501. 		verbalize("Take off your shirt, please."); 502. # endif 503. 	    else verbalize("Relax, this won't hurt a bit."); 504. 	    break; 505. 	case MS_SELL: /* pitch, pay, total */ 506. 	    if (ANGRY(mtmp)) 507. 		kludge("%s mentions how much %s dislikes %s customers.",  508.  			ESHK(mtmp)->shknam,  509.  			ESHK(mtmp)->ismale ? "he" : "she",  510.  			ESHK(mtmp)->robbed ? "non-paying" : "rude"); 511. 	    else if (ESHK(mtmp)->following) 512. 		if (strncmp(ESHK(mtmp)->customer, plname, PL_NSIZ)) { 513. 		    pline("\"Hello %s!  I was looking for %s.\"",  514.  			    plname, ESHK(mtmp)->customer); 515. 		    ESHK(mtmp)->following = 0; 516. 		} else { 517. 		    pline("\"Hello %s!  Didn't you forget to pay?\"",  518.  			    plname); 519. 		}  520.  	    else if (ESHK(mtmp)->robbed) 521. 		kludge("%s complains about a recent robbery.", ESHK(mtmp)->shknam); 522. 	    else if (ESHK(mtmp)->billct) 523. 		kludge("%s reminds you that you haven't paid yet.", ESHK(mtmp)->shknam); 524. 	    else if (mtmp->mgold < 50) 525. 		kludge("%s complains that business is bad.", ESHK(mtmp)->shknam); 526. 	    else if (mtmp->mgold > 4000) 527. 		kludge("%s says that business is good.", ESHK(mtmp)->shknam); 528. 	    else 529. 		kludge("%s talks about the problem of shoplifters.", ESHK(mtmp)->shknam); 530. 	    break; 531. # ifdef ARMY 532. 	case MS_SOLDIER: 533. 	    if (!mtmp->mpeaceful) 534. 	    switch (rn2(3)) { 535. 		case 2: 536. 		    verbalize("Resistance is useless!"); 537. 		    break; 538. 		case 1: 539. 		    verbalize("You're dog meat!"); 540. 		    break; 541. 		default: 542. 		    verbalize("Surrender!"); 543. 	    }  544.  	    break; 545. # endif 546. #endif /* SOUNDS */ 547.     }  548.      return(1); 549. }  550.   551.   552.  int 553. dotalk 554. {  555.      register struct monst *mtmp; 556.     register int tx,ty; 557.  558.      if (u.uswallow) { 559. 	pline("They won't hear you out there."); 560. 	return(0); 561.     }  562.   563.      pline("Talk to whom? [in what direction] "); 564.     (void) getdir(0); 565.  566.      if (u.dz) { 567. 	pline("They won't hear you %s there.", u.dz < 0 ? "up" : "down"); 568. 	return(0); 569.     }  570.   571.      if (u.dx == 0 && u.dy == 0) { 572. /*  573.   * Let's not include this. It raises all sorts of questions: can you wear 574.  * 2 helmets, 2 amulets, 3 pairs of gloves or 6 rings as a marilith, 575.  * etc... --KAA 576. #ifdef POLYSELF 577. 	if (u.umonnum == PM_ETTIN) { 578. 	    You("discover that your other head makes boring conversation."); 579. 	    return(1); 580. 	}  581.  #endif 582. */  583.  	pline("Talking to yourself is a bad habit for a dungeoneer."); 584. 	return(0); 585.     }  586.   587.      tx = u.ux+u.dx; ty = u.uy+u.dy; 588.     if (!cansee(tx,ty) || !levl[tx][ty].mmask || (mtmp = m_at(tx, ty))->mimic) { 589. 	pline("I see nobody there."); 590. 	return(0); 591.     }  592.      if (mtmp->mfroz || mtmp->msleep) { 593. 	kludge("%s seems not to notice you.", Monnam(mtmp)); 594. 	return 0; 595.     }  596.   597.      return domonnoise(mtmp); 598. }