About: Source:NetHack 3.4.0/sounds.c   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Below is the full text to sounds.c from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.0/sounds.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code

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