Source:NetHack 3.6.5/src/sounds.c
Jump to navigation
Jump to search
Below is the full text to sounds.c from the source code of NetHack 3.6.5. To link to a particular line, write [[Source:NetHack 3.6.5/src/sounds.c#line12]], for example.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* NetHack 3.6 sounds.c $NHDT-Date: 1570844005 2019/10/12 01:33:25 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.83 $ */ 2. /* Copyright (c) 1989 Janet Walz, Mike Threepoint */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #include "hack.h" 6. 7. STATIC_DCL boolean FDECL(mon_is_gecko, (struct monst *)); 8. STATIC_DCL int FDECL(domonnoise, (struct monst *)); 9. STATIC_DCL int NDECL(dochat); 10. STATIC_DCL int FDECL(mon_in_room, (struct monst *, int)); 11. 12. /* this easily could be a macro, but it might overtax dumb compilers */ 13. STATIC_OVL int 14. mon_in_room(mon, rmtyp) 15. struct monst *mon; 16. int rmtyp; 17. { 18. int rno = levl[mon->mx][mon->my].roomno; 19. if (rno >= ROOMOFFSET) 20. return rooms[rno - ROOMOFFSET].rtype == rmtyp; 21. return FALSE; 22. } 23. 24. void 25. dosounds() 26. { 27. register struct mkroom *sroom; 28. register int hallu, vx, vy; 29. #if defined(AMIGA) && defined(AZTEC_C_WORKAROUND) 30. int xx; 31. #endif 32. struct monst *mtmp; 33. 34. if (Deaf || !flags.acoustics || u.uswallow || Underwater) 35. return; 36. 37. hallu = Hallucination ? 1 : 0; 38. 39. if (level.flags.nfountains && !rn2(400)) { 40. static const char *const fountain_msg[4] = { 41. "bubbling water.", "water falling on coins.", 42. "the splashing of a naiad.", "a soda fountain!", 43. }; 44. You_hear1(fountain_msg[rn2(3) + hallu]); 45. } 46. if (level.flags.nsinks && !rn2(300)) { 47. static const char *const sink_msg[3] = { 48. "a slow drip.", "a gurgling noise.", "dishes being washed!", 49. }; 50. You_hear1(sink_msg[rn2(2) + hallu]); 51. } 52. if (level.flags.has_court && !rn2(200)) { 53. static const char *const throne_msg[4] = { 54. "the tones of courtly conversation.", 55. "a sceptre pounded in judgment.", 56. "Someone shouts \"Off with %s head!\"", "Queen Beruthiel's cats!", 57. }; 58. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 59. if (DEADMONSTER(mtmp)) 60. continue; 61. if ((mtmp->msleeping || is_lord(mtmp->data) 62. || is_prince(mtmp->data)) && !is_animal(mtmp->data) 63. && mon_in_room(mtmp, COURT)) { 64. /* finding one is enough, at least for now */ 65. int which = rn2(3) + hallu; 66. 67. if (which != 2) 68. You_hear1(throne_msg[which]); 69. else 70. pline(throne_msg[2], uhis()); 71. return; 72. } 73. } 74. } 75. if (level.flags.has_swamp && !rn2(200)) { 76. static const char *const swamp_msg[3] = { 77. "hear mosquitoes!", "smell marsh gas!", /* so it's a smell...*/ 78. "hear Donald Duck!", 79. }; 80. You1(swamp_msg[rn2(2) + hallu]); 81. return; 82. } 83. if (level.flags.has_vault && !rn2(200)) { 84. if (!(sroom = search_special(VAULT))) { 85. /* strange ... */ 86. level.flags.has_vault = 0; 87. return; 88. } 89. if (gd_sound()) 90. switch (rn2(2) + hallu) { 91. case 1: { 92. boolean gold_in_vault = FALSE; 93. 94. for (vx = sroom->lx; vx <= sroom->hx; vx++) 95. for (vy = sroom->ly; vy <= sroom->hy; vy++) 96. if (g_at(vx, vy)) 97. gold_in_vault = TRUE; 98. #if defined(AMIGA) && defined(AZTEC_C_WORKAROUND) 99. /* Bug in aztec assembler here. Workaround below */ 100. xx = ROOM_INDEX(sroom) + ROOMOFFSET; 101. xx = (xx != vault_occupied(u.urooms)); 102. if (xx) 103. #else 104. if (vault_occupied(u.urooms) 105. != (ROOM_INDEX(sroom) + ROOMOFFSET)) 106. #endif /* AZTEC_C_WORKAROUND */ 107. { 108. if (gold_in_vault) 109. You_hear(!hallu 110. ? "someone counting money." 111. : "the quarterback calling the play."); 112. else 113. You_hear("someone searching."); 114. break; 115. } 116. } 117. /*FALLTHRU*/ 118. case 0: 119. You_hear("the footsteps of a guard on patrol."); 120. break; 121. case 2: 122. You_hear("Ebenezer Scrooge!"); 123. break; 124. } 125. return; 126. } 127. if (level.flags.has_beehive && !rn2(200)) { 128. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 129. if (DEADMONSTER(mtmp)) 130. continue; 131. if ((mtmp->data->mlet == S_ANT && is_flyer(mtmp->data)) 132. && mon_in_room(mtmp, BEEHIVE)) { 133. switch (rn2(2) + hallu) { 134. case 0: 135. You_hear("a low buzzing."); 136. break; 137. case 1: 138. You_hear("an angry drone."); 139. break; 140. case 2: 141. You_hear("bees in your %sbonnet!", 142. uarmh ? "" : "(nonexistent) "); 143. break; 144. } 145. return; 146. } 147. } 148. } 149. if (level.flags.has_morgue && !rn2(200)) { 150. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 151. if (DEADMONSTER(mtmp)) 152. continue; 153. if ((is_undead(mtmp->data) || is_vampshifter(mtmp)) 154. && mon_in_room(mtmp, MORGUE)) { 155. const char *hair = body_part(HAIR); /* hair/fur/scales */ 156. 157. switch (rn2(2) + hallu) { 158. case 0: 159. You("suddenly realize it is unnaturally quiet."); 160. break; 161. case 1: 162. pline_The("%s on the back of your %s %s up.", hair, 163. body_part(NECK), vtense(hair, "stand")); 164. break; 165. case 2: 166. pline_The("%s on your %s %s to stand up.", hair, 167. body_part(HEAD), vtense(hair, "seem")); 168. break; 169. } 170. return; 171. } 172. } 173. } 174. if (level.flags.has_barracks && !rn2(200)) { 175. static const char *const barracks_msg[4] = { 176. "blades being honed.", "loud snoring.", "dice being thrown.", 177. "General MacArthur!", 178. }; 179. int count = 0; 180. 181. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 182. if (DEADMONSTER(mtmp)) 183. continue; 184. if (is_mercenary(mtmp->data) 185. #if 0 /* don't bother excluding these */ 186. && !strstri(mtmp->data->mname, "watch") 187. && !strstri(mtmp->data->mname, "guard") 188. #endif 189. && mon_in_room(mtmp, BARRACKS) 190. /* sleeping implies not-yet-disturbed (usually) */ 191. && (mtmp->msleeping || ++count > 5)) { 192. You_hear1(barracks_msg[rn2(3) + hallu]); 193. return; 194. } 195. } 196. } 197. if (level.flags.has_zoo && !rn2(200)) { 198. static const char *const zoo_msg[3] = { 199. "a sound reminiscent of an elephant stepping on a peanut.", 200. "a sound reminiscent of a seal barking.", "Doctor Dolittle!", 201. }; 202. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 203. if (DEADMONSTER(mtmp)) 204. continue; 205. if ((mtmp->msleeping || is_animal(mtmp->data)) 206. && mon_in_room(mtmp, ZOO)) { 207. You_hear1(zoo_msg[rn2(2) + hallu]); 208. return; 209. } 210. } 211. } 212. if (level.flags.has_shop && !rn2(200)) { 213. if (!(sroom = search_special(ANY_SHOP))) { 214. /* strange... */ 215. level.flags.has_shop = 0; 216. return; 217. } 218. if (tended_shop(sroom) 219. && !index(u.ushops, (int) (ROOM_INDEX(sroom) + ROOMOFFSET))) { 220. static const char *const shop_msg[3] = { 221. "someone cursing shoplifters.", 222. "the chime of a cash register.", "Neiman and Marcus arguing!", 223. }; 224. You_hear1(shop_msg[rn2(2) + hallu]); 225. } 226. return; 227. } 228. if (level.flags.has_temple && !rn2(200) 229. && !(Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) { 230. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 231. if (DEADMONSTER(mtmp)) 232. continue; 233. if (mtmp->ispriest && inhistemple(mtmp) 234. /* priest must be active */ 235. && mtmp->mcanmove && !mtmp->msleeping 236. /* hero must be outside this temple */ 237. && temple_occupied(u.urooms) != EPRI(mtmp)->shroom) 238. break; 239. } 240. if (mtmp) { 241. /* Generic temple messages; no attempt to match topic or tone 242. to the pantheon involved, let alone to the specific deity. 243. These are assumed to be coming from the attending priest; 244. asterisk means that the priest must be capable of speech; 245. pound sign (octathorpe,&c--don't go there) means that the 246. priest and the altar must not be directly visible (we don't 247. care if telepathy or extended detection reveals that the 248. priest is not currently standing on the altar; he's mobile). */ 249. static const char *const temple_msg[] = { 250. "*someone praising %s.", "*someone beseeching %s.", 251. "#an animal carcass being offered in sacrifice.", 252. "*a strident plea for donations.", 253. }; 254. const char *msg; 255. int trycount = 0, ax = EPRI(mtmp)->shrpos.x, 256. ay = EPRI(mtmp)->shrpos.y; 257. boolean speechless = (mtmp->data->msound <= MS_ANIMAL), 258. in_sight = canseemon(mtmp) || cansee(ax, ay); 259. 260. do { 261. msg = temple_msg[rn2(SIZE(temple_msg) - 1 + hallu)]; 262. if (index(msg, '*') && speechless) 263. continue; 264. if (index(msg, '#') && in_sight) 265. continue; 266. break; /* msg is acceptable */ 267. } while (++trycount < 50); 268. while (!letter(*msg)) 269. ++msg; /* skip control flags */ 270. if (index(msg, '%')) 271. You_hear(msg, halu_gname(EPRI(mtmp)->shralign)); 272. else 273. You_hear1(msg); 274. return; 275. } 276. } 277. if (Is_oracle_level(&u.uz) && !rn2(400)) { 278. /* make sure the Oracle is still here */ 279. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 280. if (DEADMONSTER(mtmp)) 281. continue; 282. if (mtmp->data == &mons[PM_ORACLE]) 283. break; 284. } 285. /* and don't produce silly effects when she's clearly visible */ 286. if (mtmp && (hallu || !canseemon(mtmp))) { 287. static const char *const ora_msg[5] = { 288. "a strange wind.", /* Jupiter at Dodona */ 289. "convulsive ravings.", /* Apollo at Delphi */ 290. "snoring snakes.", /* AEsculapius at Epidaurus */ 291. "someone say \"No more woodchucks!\"", 292. "a loud ZOT!" /* both rec.humor.oracle */ 293. }; 294. You_hear1(ora_msg[rn2(3) + hallu * 2]); 295. } 296. return; 297. } 298. } 299. 300. static const char *const h_sounds[] = { 301. "beep", "boing", "sing", "belche", "creak", "cough", 302. "rattle", "ululate", "pop", "jingle", "sniffle", "tinkle", 303. "eep", "clatter", "hum", "sizzle", "twitter", "wheeze", 304. "rustle", "honk", "lisp", "yodel", "coo", "burp", 305. "moo", "boom", "murmur", "oink", "quack", "rumble", 306. "twang", "bellow", "toot", "gargle", "hoot", "warble" 307. }; 308. 309. const char * 310. growl_sound(mtmp) 311. register struct monst *mtmp; 312. { 313. const char *ret; 314. 315. switch (mtmp->data->msound) { 316. case MS_MEW: 317. case MS_HISS: 318. ret = "hiss"; 319. break; 320. case MS_BARK: 321. case MS_GROWL: 322. ret = "growl"; 323. break; 324. case MS_ROAR: 325. ret = "roar"; 326. break; 327. case MS_BUZZ: 328. ret = "buzz"; 329. break; 330. case MS_SQEEK: 331. ret = "squeal"; 332. break; 333. case MS_SQAWK: 334. ret = "screech"; 335. break; 336. case MS_NEIGH: 337. ret = "neigh"; 338. break; 339. case MS_WAIL: 340. ret = "wail"; 341. break; 342. case MS_SILENT: 343. ret = "commotion"; 344. break; 345. default: 346. ret = "scream"; 347. } 348. return ret; 349. } 350. 351. /* the sounds of a seriously abused pet, including player attacking it */ 352. void 353. growl(mtmp) 354. register struct monst *mtmp; 355. { 356. register const char *growl_verb = 0; 357. 358. if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound) 359. return; 360. 361. /* presumably nearness and soundok checks have already been made */ 362. if (Hallucination) 363. growl_verb = h_sounds[rn2(SIZE(h_sounds))]; 364. else 365. growl_verb = growl_sound(mtmp); 366. if (growl_verb) { 367. pline("%s %s!", Monnam(mtmp), vtense((char *) 0, growl_verb)); 368. if (context.run) 369. nomul(0); 370. wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 18); 371. } 372. } 373. 374. /* the sounds of mistreated pets */ 375. void 376. yelp(mtmp) 377. register struct monst *mtmp; 378. { 379. register const char *yelp_verb = 0; 380. 381. if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound) 382. return; 383. 384. /* presumably nearness and soundok checks have already been made */ 385. if (Hallucination) 386. yelp_verb = h_sounds[rn2(SIZE(h_sounds))]; 387. else 388. switch (mtmp->data->msound) { 389. case MS_MEW: 390. yelp_verb = (!Deaf) ? "yowl" : "arch"; 391. break; 392. case MS_BARK: 393. case MS_GROWL: 394. yelp_verb = (!Deaf) ? "yelp" : "recoil"; 395. break; 396. case MS_ROAR: 397. yelp_verb = (!Deaf) ? "snarl" : "bluff"; 398. break; 399. case MS_SQEEK: 400. yelp_verb = (!Deaf) ? "squeal" : "quiver"; 401. break; 402. case MS_SQAWK: 403. yelp_verb = (!Deaf) ? "screak" : "thrash"; 404. break; 405. case MS_WAIL: 406. yelp_verb = (!Deaf) ? "wail" : "cringe"; 407. break; 408. } 409. if (yelp_verb) { 410. pline("%s %s!", Monnam(mtmp), vtense((char *) 0, yelp_verb)); 411. if (context.run) 412. nomul(0); 413. wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 12); 414. } 415. } 416. 417. /* the sounds of distressed pets */ 418. void 419. whimper(mtmp) 420. register struct monst *mtmp; 421. { 422. register const char *whimper_verb = 0; 423. 424. if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound) 425. return; 426. 427. /* presumably nearness and soundok checks have already been made */ 428. if (Hallucination) 429. whimper_verb = h_sounds[rn2(SIZE(h_sounds))]; 430. else 431. switch (mtmp->data->msound) { 432. case MS_MEW: 433. case MS_GROWL: 434. whimper_verb = "whimper"; 435. break; 436. case MS_BARK: 437. whimper_verb = "whine"; 438. break; 439. case MS_SQEEK: 440. whimper_verb = "squeal"; 441. break; 442. } 443. if (whimper_verb) { 444. pline("%s %s.", Monnam(mtmp), vtense((char *) 0, whimper_verb)); 445. if (context.run) 446. nomul(0); 447. wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 6); 448. } 449. } 450. 451. /* pet makes "I'm hungry" noises */ 452. void 453. beg(mtmp) 454. register struct monst *mtmp; 455. { 456. if (mtmp->msleeping || !mtmp->mcanmove 457. || !(carnivorous(mtmp->data) || herbivorous(mtmp->data))) 458. return; 459. 460. /* presumably nearness and soundok checks have already been made */ 461. if (!is_silent(mtmp->data) && mtmp->data->msound <= MS_ANIMAL) 462. (void) domonnoise(mtmp); 463. else if (mtmp->data->msound >= MS_HUMANOID) { 464. if (!canspotmon(mtmp)) 465. map_invisible(mtmp->mx, mtmp->my); 466. verbalize("I'm hungry."); 467. } 468. } 469. 470. /* return True if mon is a gecko or seems to look like one (hallucination) */ 471. STATIC_OVL boolean 472. mon_is_gecko(mon) 473. struct monst *mon; 474. { 475. int glyph; 476. 477. /* return True if it is actually a gecko */ 478. if (mon->data == &mons[PM_GECKO]) 479. return TRUE; 480. /* return False if it is a long worm; we might be chatting to its tail 481. (not strictly needed; long worms are MS_SILENT so won't get here) */ 482. if (mon->data == &mons[PM_LONG_WORM]) 483. return FALSE; 484. /* result depends upon whether map spot shows a gecko, which will 485. be due to hallucination or to mimickery since mon isn't one */ 486. glyph = glyph_at(mon->mx, mon->my); 487. return (boolean) (glyph_to_mon(glyph) == PM_GECKO); 488. } 489. 490. STATIC_OVL int 491. domonnoise(mtmp) 492. register struct monst *mtmp; 493. { 494. char verbuf[BUFSZ]; 495. register const char *pline_msg = 0, /* Monnam(mtmp) will be prepended */ 496. *verbl_msg = 0, /* verbalize() */ 497. *verbl_msg_mcan = 0; /* verbalize() if cancelled */ 498. struct permonst *ptr = mtmp->data; 499. int msound = ptr->msound, gnomeplan = 0; 500. 501. /* presumably nearness and sleep checks have already been made */ 502. if (Deaf) 503. return 0; 504. if (is_silent(ptr)) 505. return 0; 506. 507. /* leader might be poly'd; if he can still speak, give leader speech */ 508. if (mtmp->m_id == quest_status.leader_m_id && msound > MS_ANIMAL) 509. msound = MS_LEADER; 510. /* make sure it's your role's quest guardian; adjust if not */ 511. else if (msound == MS_GUARDIAN && ptr != &mons[urole.guardnum]) 512. msound = mons[genus(monsndx(ptr), 1)].msound; 513. /* some normally non-speaking types can/will speak if hero is similar */ 514. else if (msound == MS_ORC /* note: MS_ORC is same as MS_GRUNT */ 515. && ((same_race(ptr, youmonst.data) /* current form, */ 516. || same_race(ptr, &mons[Race_switch])) /* unpoly'd form */ 517. || Hallucination)) 518. msound = MS_HUMANOID; 519. /* silliness, with slight chance to interfere with shopping */ 520. else if (Hallucination && mon_is_gecko(mtmp)) 521. msound = MS_SELL; 522. 523. /* be sure to do this before talking; the monster might teleport away, in 524. * which case we want to check its pre-teleport position 525. */ 526. if (!canspotmon(mtmp)) 527. map_invisible(mtmp->mx, mtmp->my); 528. 529. switch (msound) { 530. case MS_ORACLE: 531. return doconsult(mtmp); 532. case MS_PRIEST: 533. priest_talk(mtmp); 534. break; 535. case MS_LEADER: 536. case MS_NEMESIS: 537. case MS_GUARDIAN: 538. quest_chat(mtmp); 539. break; 540. case MS_SELL: /* pitch, pay, total */ 541. if (!Hallucination || (mtmp->isshk && !rn2(2))) { 542. shk_chat(mtmp); 543. } else { 544. /* approximation of GEICO's advertising slogan (it actually 545. concludes with "save you 15% or more on car insurance.") */ 546. Sprintf(verbuf, "15 minutes could save you 15 %s.", 547. currency(15L)); /* "zorkmids" */ 548. verbl_msg = verbuf; 549. } 550. break; 551. case MS_VAMPIRE: { 552. /* vampire messages are varied by tameness, peacefulness, and time of 553. * night */ 554. boolean isnight = night(); 555. boolean kindred = (Upolyd && (u.umonnum == PM_VAMPIRE 556. || u.umonnum == PM_VAMPIRE_LORD)); 557. boolean nightchild = 558. (Upolyd && (u.umonnum == PM_WOLF || u.umonnum == PM_WINTER_WOLF 559. || u.umonnum == PM_WINTER_WOLF_CUB)); 560. const char *racenoun = 561. (flags.female && urace.individual.f) 562. ? urace.individual.f 563. : (urace.individual.m) ? urace.individual.m : urace.noun; 564. 565. if (mtmp->mtame) { 566. if (kindred) { 567. Sprintf(verbuf, "Good %s to you Master%s", 568. isnight ? "evening" : "day", 569. isnight ? "!" : ". Why do we not rest?"); 570. verbl_msg = verbuf; 571. } else { 572. Sprintf(verbuf, "%s%s", 573. nightchild ? "Child of the night, " : "", 574. midnight() 575. ? "I can stand this craving no longer!" 576. : isnight 577. ? "I beg you, help me satisfy this growing craving!" 578. : "I find myself growing a little weary."); 579. verbl_msg = verbuf; 580. } 581. } else if (mtmp->mpeaceful) { 582. if (kindred && isnight) { 583. Sprintf(verbuf, "Good feeding %s!", 584. flags.female ? "sister" : "brother"); 585. verbl_msg = verbuf; 586. } else if (nightchild && isnight) { 587. Sprintf(verbuf, "How nice to hear you, child of the night!"); 588. verbl_msg = verbuf; 589. } else 590. verbl_msg = "I only drink... potions."; 591. } else { 592. static const char *const vampmsg[] = { 593. /* These first two (0 and 1) are specially handled below */ 594. "I vant to suck your %s!", 595. "I vill come after %s without regret!", 596. /* other famous vampire quotes can follow here if desired */ 597. }; 598. int vampindex; 599. 600. if (kindred) 601. verbl_msg = 602. "This is my hunting ground that you dare to prowl!"; 603. else if (youmonst.data == &mons[PM_SILVER_DRAGON] 604. || youmonst.data == &mons[PM_BABY_SILVER_DRAGON]) { 605. /* Silver dragons are silver in color, not made of silver */ 606. Sprintf(verbuf, "%s! Your silver sheen does not frighten me!", 607. youmonst.data == &mons[PM_SILVER_DRAGON] 608. ? "Fool" 609. : "Young Fool"); 610. verbl_msg = verbuf; 611. } else { 612. vampindex = rn2(SIZE(vampmsg)); 613. if (vampindex == 0) { 614. Sprintf(verbuf, vampmsg[vampindex], body_part(BLOOD)); 615. verbl_msg = verbuf; 616. } else if (vampindex == 1) { 617. Sprintf(verbuf, vampmsg[vampindex], 618. Upolyd ? an(mons[u.umonnum].mname) 619. : an(racenoun)); 620. verbl_msg = verbuf; 621. } else 622. verbl_msg = vampmsg[vampindex]; 623. } 624. } 625. } break; 626. case MS_WERE: 627. if (flags.moonphase == FULL_MOON && (night() ^ !rn2(13))) { 628. pline("%s throws back %s head and lets out a blood curdling %s!", 629. Monnam(mtmp), mhis(mtmp), 630. ptr == &mons[PM_HUMAN_WERERAT] ? "shriek" : "howl"); 631. wake_nearto(mtmp->mx, mtmp->my, 11 * 11); 632. } else 633. pline_msg = 634. "whispers inaudibly. All you can make out is \"moon\"."; 635. break; 636. case MS_BARK: 637. if (flags.moonphase == FULL_MOON && night()) { 638. pline_msg = "howls."; 639. } else if (mtmp->mpeaceful) { 640. if (mtmp->mtame 641. && (mtmp->mconf || mtmp->mflee || mtmp->mtrapped 642. || moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5)) 643. pline_msg = "whines."; 644. else if (mtmp->mtame && EDOG(mtmp)->hungrytime > moves + 1000) 645. pline_msg = "yips."; 646. else { 647. if (mtmp->data 648. != &mons[PM_DINGO]) /* dingos do not actually bark */ 649. pline_msg = "barks."; 650. } 651. } else { 652. pline_msg = "growls."; 653. } 654. break; 655. case MS_MEW: 656. if (mtmp->mtame) { 657. if (mtmp->mconf || mtmp->mflee || mtmp->mtrapped 658. || mtmp->mtame < 5) 659. pline_msg = "yowls."; 660. else if (moves > EDOG(mtmp)->hungrytime) 661. pline_msg = "meows."; 662. else if (EDOG(mtmp)->hungrytime > moves + 1000) 663. pline_msg = "purrs."; 664. else 665. pline_msg = "mews."; 666. break; 667. } 668. /*FALLTHRU*/ 669. case MS_GROWL: 670. pline_msg = mtmp->mpeaceful ? "snarls." : "growls!"; 671. break; 672. case MS_ROAR: 673. pline_msg = mtmp->mpeaceful ? "snarls." : "roars!"; 674. break; 675. case MS_SQEEK: 676. pline_msg = "squeaks."; 677. break; 678. case MS_SQAWK: 679. if (ptr == &mons[PM_RAVEN] && !mtmp->mpeaceful) 680. verbl_msg = "Nevermore!"; 681. else 682. pline_msg = "squawks."; 683. break; 684. case MS_HISS: 685. if (!mtmp->mpeaceful) 686. pline_msg = "hisses!"; 687. else 688. return 0; /* no sound */ 689. break; 690. case MS_BUZZ: 691. pline_msg = mtmp->mpeaceful ? "drones." : "buzzes angrily."; 692. break; 693. case MS_GRUNT: 694. pline_msg = "grunts."; 695. break; 696. case MS_NEIGH: 697. if (mtmp->mtame < 5) 698. pline_msg = "neighs."; 699. else if (moves > EDOG(mtmp)->hungrytime) 700. pline_msg = "whinnies."; 701. else 702. pline_msg = "whickers."; 703. break; 704. case MS_WAIL: 705. pline_msg = "wails mournfully."; 706. break; 707. case MS_GURGLE: 708. pline_msg = "gurgles."; 709. break; 710. case MS_BURBLE: 711. pline_msg = "burbles."; 712. break; 713. case MS_SHRIEK: 714. pline_msg = "shrieks."; 715. aggravate(); 716. break; 717. case MS_IMITATE: 718. pline_msg = "imitates you."; 719. break; 720. case MS_BONES: 721. pline("%s rattles noisily.", Monnam(mtmp)); 722. You("freeze for a moment."); 723. nomul(-2); 724. multi_reason = "scared by rattling"; 725. nomovemsg = 0; 726. break; 727. case MS_LAUGH: { 728. static const char *const laugh_msg[4] = { 729. "giggles.", "chuckles.", "snickers.", "laughs.", 730. }; 731. pline_msg = laugh_msg[rn2(4)]; 732. } break; 733. case MS_MUMBLE: 734. pline_msg = "mumbles incomprehensibly."; 735. break; 736. case MS_DJINNI: 737. if (mtmp->mtame) { 738. verbl_msg = "Sorry, I'm all out of wishes."; 739. } else if (mtmp->mpeaceful) { 740. if (ptr == &mons[PM_WATER_DEMON]) 741. pline_msg = "gurgles."; 742. else 743. verbl_msg = "I'm free!"; 744. } else { 745. if (ptr != &mons[PM_PRISONER]) 746. verbl_msg = "This will teach you not to disturb me!"; 747. #if 0 748. else 749. verbl_msg = "??????????"; 750. #endif 751. } 752. break; 753. case MS_BOAST: /* giants */ 754. if (!mtmp->mpeaceful) { 755. switch (rn2(4)) { 756. case 0: 757. pline("%s boasts about %s gem collection.", Monnam(mtmp), 758. mhis(mtmp)); 759. break; 760. case 1: 761. pline_msg = "complains about a diet of mutton."; 762. break; 763. default: 764. pline_msg = "shouts \"Fee Fie Foe Foo!\" and guffaws."; 765. wake_nearto(mtmp->mx, mtmp->my, 7 * 7); 766. break; 767. } 768. break; 769. } 770. /*FALLTHRU*/ 771. case MS_HUMANOID: 772. if (!mtmp->mpeaceful) { 773. if (In_endgame(&u.uz) && is_mplayer(ptr)) 774. mplayer_talk(mtmp); 775. else 776. pline_msg = "threatens you."; 777. break; 778. } 779. /* Generic peaceful humanoid behaviour. */ 780. if (mtmp->mflee) 781. pline_msg = "wants nothing to do with you."; 782. else if (mtmp->mhp < mtmp->mhpmax / 4) 783. pline_msg = "moans."; 784. else if (mtmp->mconf || mtmp->mstun) 785. verbl_msg = !rn2(3) ? "Huh?" : rn2(2) ? "What?" : "Eh?"; 786. else if (!mtmp->mcansee) 787. verbl_msg = "I can't see!"; 788. else if (mtmp->mtrapped) { 789. struct trap *t = t_at(mtmp->mx, mtmp->my); 790. 791. if (t) 792. t->tseen = 1; 793. verbl_msg = "I'm trapped!"; 794. } else if (mtmp->mhp < mtmp->mhpmax / 2) 795. pline_msg = "asks for a potion of healing."; 796. else if (mtmp->mtame && !mtmp->isminion 797. && moves > EDOG(mtmp)->hungrytime) 798. verbl_msg = "I'm hungry."; 799. /* Specific monsters' interests */ 800. else if (is_elf(ptr)) 801. pline_msg = "curses orcs."; 802. else if (is_dwarf(ptr)) 803. pline_msg = "talks about mining."; 804. else if (likes_magic(ptr)) 805. pline_msg = "talks about spellcraft."; 806. else if (ptr->mlet == S_CENTAUR) 807. pline_msg = "discusses hunting."; 808. else if (is_gnome(ptr) && Hallucination && (gnomeplan = rn2(4)) % 2) 809. /* skipped for rn2(4) result of 0 or 2; 810. gag from an early episode of South Park called "Gnomes"; 811. initially, Tweek (introduced in that episode) is the only 812. one aware of the tiny gnomes after spotting them sneaking 813. about; they are embarked upon a three-step business plan; 814. a diagram of the plan shows: 815. Phase 1 Phase 2 Phase 3 816. Collect underpants ? Profit 817. and they never verbalize step 2 so we don't either */ 818. verbl_msg = (gnomeplan == 1) ? "Phase one, collect underpants." 819. : "Phase three, profit!"; 820. else 821. switch (monsndx(ptr)) { 822. case PM_HOBBIT: 823. pline_msg = 824. (mtmp->mhpmax - mtmp->mhp >= 10) 825. ? "complains about unpleasant dungeon conditions." 826. : "asks you about the One Ring."; 827. break; 828. case PM_ARCHEOLOGIST: 829. pline_msg = 830. "describes a recent article in \"Spelunker Today\" magazine."; 831. break; 832. case PM_TOURIST: 833. verbl_msg = "Aloha."; 834. break; 835. default: 836. pline_msg = "discusses dungeon exploration."; 837. break; 838. } 839. break; 840. case MS_SEDUCE: { 841. int swval; 842. 843. if (SYSOPT_SEDUCE) { 844. if (ptr->mlet != S_NYMPH 845. && could_seduce(mtmp, &youmonst, (struct attack *) 0) == 1) { 846. (void) doseduce(mtmp); 847. break; 848. } 849. swval = ((poly_gender() != (int) mtmp->female) ? rn2(3) : 0); 850. } else 851. swval = ((poly_gender() == 0) ? rn2(3) : 0); 852. switch (swval) { 853. case 2: 854. verbl_msg = "Hello, sailor."; 855. break; 856. case 1: 857. pline_msg = "comes on to you."; 858. break; 859. default: 860. pline_msg = "cajoles you."; 861. } 862. } break; 863. case MS_ARREST: 864. if (mtmp->mpeaceful) 865. verbalize("Just the facts, %s.", flags.female ? "Ma'am" : "Sir"); 866. else { 867. static const char *const arrest_msg[3] = { 868. "Anything you say can be used against you.", 869. "You're under arrest!", "Stop in the name of the Law!", 870. }; 871. verbl_msg = arrest_msg[rn2(3)]; 872. } 873. break; 874. case MS_BRIBE: 875. if (mtmp->mpeaceful && !mtmp->mtame) { 876. (void) demon_talk(mtmp); 877. break; 878. } 879. /* fall through */ 880. case MS_CUSS: 881. if (!mtmp->mpeaceful) 882. cuss(mtmp); 883. else if (is_lminion(mtmp)) 884. verbl_msg = "It's not too late."; 885. else 886. verbl_msg = "We're all doomed."; 887. break; 888. case MS_SPELL: 889. /* deliberately vague, since it's not actually casting any spell */ 890. pline_msg = "seems to mutter a cantrip."; 891. break; 892. case MS_NURSE: 893. verbl_msg_mcan = "I hate this job!"; 894. if (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))) 895. verbl_msg = "Put that weapon away before you hurt someone!"; 896. else if (uarmc || uarm || uarmh || uarms || uarmg || uarmf) 897. verbl_msg = Role_if(PM_HEALER) 898. ? "Doc, I can't help you unless you cooperate." 899. : "Please undress so I can examine you."; 900. else if (uarmu) 901. verbl_msg = "Take off your shirt, please."; 902. else 903. verbl_msg = "Relax, this won't hurt a bit."; 904. break; 905. case MS_GUARD: 906. if (money_cnt(invent)) 907. verbl_msg = "Please drop that gold and follow me."; 908. else 909. verbl_msg = "Please follow me."; 910. break; 911. case MS_SOLDIER: { 912. static const char 913. *const soldier_foe_msg[3] = 914. { 915. "Resistance is useless!", "You're dog meat!", "Surrender!", 916. }, 917. *const soldier_pax_msg[3] = { 918. "What lousy pay we're getting here!", 919. "The food's not fit for Orcs!", 920. "My feet hurt, I've been on them all day!", 921. }; 922. verbl_msg = mtmp->mpeaceful ? soldier_pax_msg[rn2(3)] 923. : soldier_foe_msg[rn2(3)]; 924. break; 925. } 926. case MS_RIDER: { 927. const char *tribtitle; 928. struct obj *book = 0; 929. boolean ms_Death = (ptr == &mons[PM_DEATH]); 930. 931. /* 3.6 tribute */ 932. if (ms_Death && !context.tribute.Deathnotice 933. && (book = u_have_novel()) != 0) { 934. if ((tribtitle = noveltitle(&book->novelidx)) != 0) { 935. Sprintf(verbuf, "Ah, so you have a copy of /%s/.", tribtitle); 936. /* no Death featured in these two, so exclude them */ 937. if (strcmpi(tribtitle, "Snuff") 938. && strcmpi(tribtitle, "The Wee Free Men")) 939. Strcat(verbuf, " I may have been misquoted there."); 940. verbl_msg = verbuf; 941. } 942. context.tribute.Deathnotice = 1; 943. } else if (ms_Death && rn2(3) && Death_quote(verbuf, sizeof verbuf)) { 944. verbl_msg = verbuf; 945. /* end of tribute addition */ 946. 947. } else if (ms_Death && !rn2(10)) { 948. pline_msg = "is busy reading a copy of Sandman #8."; 949. } else 950. verbl_msg = "Who do you think you are, War?"; 951. break; 952. } /* case MS_RIDER */ 953. } /* switch */ 954. 955. if (pline_msg) { 956. pline("%s %s", Monnam(mtmp), pline_msg); 957. } else if (mtmp->mcan && verbl_msg_mcan) { 958. verbalize1(verbl_msg_mcan); 959. } else if (verbl_msg) { 960. /* more 3.6 tribute */ 961. if (ptr == &mons[PM_DEATH]) { 962. /* Death talks in CAPITAL LETTERS 963. and without quotation marks */ 964. char tmpbuf[BUFSZ]; 965. 966. pline1(ucase(strcpy(tmpbuf, verbl_msg))); 967. } else { 968. verbalize1(verbl_msg); 969. } 970. } 971. return 1; 972. } 973. 974. /* #chat command */ 975. int 976. dotalk() 977. { 978. int result; 979. 980. result = dochat(); 981. return result; 982. } 983. 984. STATIC_OVL int 985. dochat() 986. { 987. struct monst *mtmp; 988. int tx, ty; 989. struct obj *otmp; 990. 991. if (is_silent(youmonst.data)) { 992. pline("As %s, you cannot speak.", an(youmonst.data->mname)); 993. return 0; 994. } 995. if (Strangled) { 996. You_cant("speak. You're choking!"); 997. return 0; 998. } 999. if (u.uswallow) { 1000. pline("They won't hear you out there."); 1001. return 0; 1002. } 1003. if (Underwater) { 1004. Your("speech is unintelligible underwater."); 1005. return 0; 1006. } 1007. if (Deaf) { 1008. pline("How can you hold a conversation when you cannot hear?"); 1009. return 0; 1010. } 1011. 1012. if (!Blind && (otmp = shop_object(u.ux, u.uy)) != (struct obj *) 0) { 1013. /* standing on something in a shop and chatting causes the shopkeeper 1014. to describe the price(s). This can inhibit other chatting inside 1015. a shop, but that shouldn't matter much. shop_object() returns an 1016. object iff inside a shop and the shopkeeper is present and willing 1017. (not angry) and able (not asleep) to speak and the position 1018. contains any objects other than just gold. 1019. */ 1020. price_quote(otmp); 1021. return 1; 1022. } 1023. 1024. if (!getdir("Talk to whom? (in what direction)")) { 1025. /* decided not to chat */ 1026. return 0; 1027. } 1028. 1029. if (u.usteed && u.dz > 0) { 1030. if (!u.usteed->mcanmove || u.usteed->msleeping) { 1031. pline("%s seems not to notice you.", Monnam(u.usteed)); 1032. return 1; 1033. } else 1034. return domonnoise(u.usteed); 1035. } 1036. 1037. if (u.dz) { 1038. pline("They won't hear you %s there.", u.dz < 0 ? "up" : "down"); 1039. return 0; 1040. } 1041. 1042. if (u.dx == 0 && u.dy == 0) { 1043. /* 1044. * Let's not include this. 1045. * It raises all sorts of questions: can you wear 1046. * 2 helmets, 2 amulets, 3 pairs of gloves or 6 rings as a marilith, 1047. * etc... --KAA 1048. if (u.umonnum == PM_ETTIN) { 1049. You("discover that your other head makes boring conversation."); 1050. return 1; 1051. } 1052. */ 1053. pline("Talking to yourself is a bad habit for a dungeoneer."); 1054. return 0; 1055. } 1056. 1057. tx = u.ux + u.dx; 1058. ty = u.uy + u.dy; 1059. 1060. if (!isok(tx, ty)) 1061. return 0; 1062. 1063. mtmp = m_at(tx, ty); 1064. 1065. if ((!mtmp || mtmp->mundetected) 1066. && (otmp = vobj_at(tx, ty)) != 0 && otmp->otyp == STATUE) { 1067. /* Talking to a statue */ 1068. if (!Blind) { 1069. pline_The("%s seems not to notice you.", 1070. /* if hallucinating, you can't tell it's a statue */ 1071. Hallucination ? rndmonnam((char *) 0) : "statue"); 1072. } 1073. return 0; 1074. } 1075. 1076. if (!mtmp || mtmp->mundetected || M_AP_TYPE(mtmp) == M_AP_FURNITURE 1077. || M_AP_TYPE(mtmp) == M_AP_OBJECT) 1078. return 0; 1079. 1080. /* sleeping monsters won't talk, except priests (who wake up) */ 1081. if ((!mtmp->mcanmove || mtmp->msleeping) && !mtmp->ispriest) { 1082. /* If it is unseen, the player can't tell the difference between 1083. not noticing him and just not existing, so skip the message. */ 1084. if (canspotmon(mtmp)) 1085. pline("%s seems not to notice you.", Monnam(mtmp)); 1086. return 0; 1087. } 1088. 1089. /* if this monster is waiting for something, prod it into action */ 1090. mtmp->mstrategy &= ~STRAT_WAITMASK; 1091. 1092. if (mtmp->mtame && mtmp->meating) { 1093. if (!canspotmon(mtmp)) 1094. map_invisible(mtmp->mx, mtmp->my); 1095. pline("%s is eating noisily.", Monnam(mtmp)); 1096. return 0; 1097. } 1098. 1099. return domonnoise(mtmp); 1100. } 1101. 1102. #ifdef USER_SOUNDS 1103. 1104. extern void FDECL(play_usersound, (const char *, int)); 1105. 1106. typedef struct audio_mapping_rec { 1107. struct nhregex *regex; 1108. char *filename; 1109. int volume; 1110. struct audio_mapping_rec *next; 1111. } audio_mapping; 1112. 1113. static audio_mapping *soundmap = 0; 1114. 1115. char *sounddir = "."; 1116. 1117. /* adds a sound file mapping, returns 0 on failure, 1 on success */ 1118. int 1119. add_sound_mapping(mapping) 1120. const char *mapping; 1121. { 1122. char text[256]; 1123. char filename[256]; 1124. char filespec[256]; 1125. int volume; 1126. 1127. if (sscanf(mapping, "MESG \"%255[^\"]\"%*[\t ]\"%255[^\"]\" %d", text, 1128. filename, &volume) == 3) { 1129. audio_mapping *new_map; 1130. 1131. if (strlen(sounddir) + strlen(filename) > 254) { 1132. raw_print("sound file name too long"); 1133. return 0; 1134. } 1135. Sprintf(filespec, "%s/%s", sounddir, filename); 1136. 1137. if (can_read_file(filespec)) { 1138. new_map = (audio_mapping *) alloc(sizeof(audio_mapping)); 1139. new_map->regex = regex_init(); 1140. new_map->filename = dupstr(filespec); 1141. new_map->volume = volume; 1142. new_map->next = soundmap; 1143. 1144. if (!regex_compile(text, new_map->regex)) { 1145. raw_print(regex_error_desc(new_map->regex)); 1146. regex_free(new_map->regex); 1147. free(new_map->filename); 1148. free(new_map); 1149. return 0; 1150. } else { 1151. soundmap = new_map; 1152. } 1153. } else { 1154. Sprintf(text, "cannot read %.243s", filespec); 1155. raw_print(text); 1156. return 0; 1157. } 1158. } else { 1159. raw_print("syntax error in SOUND"); 1160. return 0; 1161. } 1162. 1163. return 1; 1164. } 1165. 1166. void 1167. play_sound_for_message(msg) 1168. const char *msg; 1169. { 1170. audio_mapping *cursor = soundmap; 1171. 1172. while (cursor) { 1173. if (regex_match(msg, cursor->regex)) { 1174. play_usersound(cursor->filename, cursor->volume); 1175. } 1176. cursor = cursor->next; 1177. } 1178. } 1179. 1180. #endif /* USER_SOUNDS */ 1181. 1182. /*sounds.c*/