About: Source:NetHack 3.4.0/engrave.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 engrave.c from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.0/engrave.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/engrave.c
rdfs:comment
  • Below is the full text to engrave.c from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.0/engrave.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 engrave.c from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.0/engrave.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)engrave.c 3.4 2001/11/04 */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #include "hack.h" 6. #include "lev.h" 7. #include 8. 9. STATIC_VAR NEARDATA struct engr *head_engr; 10. 11. #ifdef OVLB 12. /* random engravings */ 13. static const char *random_mesg[] = { 14. "Elbereth", 15. /* trap engravings */ 16. "Vlad was here", "ad aerarium", 17. /* take-offs and other famous engravings */ 18. "Owlbreath", "Galadriel", 19. "Kilroy was here", 20. "A.S. ->", "<- A.S.", /* Journey to the Center of the Earth */ 21. "You won't get it up the steps", /* Adventure */ 22. "Lasciate ogni speranza o voi ch'entrate.", /* Inferno */ 23. "Well Come", /* Prisoner */ 24. "We apologize for the inconvenience.", /* So Long... */ 25. "See you next Wednesday", /* Thriller */ 26. "notary sojak", /* Smokey Stover */ 27. "For a good time call 8?7-5309", 28. "Please don't feed the animals.", /* Various zoos around the world */ 29. "Madam, in Eden, I'm Adam.", /* A palindrome */ 30. "Two thumbs up!", /* Siskel & Ebert */ 31. "Hello, World!", /* The First C Program */ 32. #ifdef MAIL 33. "You've got mail!", /* AOL */ 34. #endif 35. "As if!", /* Clueless */ 36. }; 37. 38. char * 39. random_engraving(outbuf) 40. char *outbuf; 41. { 42. const char *rumor; 43. 44. /* a random engraving may come from the "rumors" file, 45. or from the list above */ 46. if (!rn2(4) || !(rumor = getrumor(0, outbuf, TRUE)) || !*rumor) 47. Strcpy(outbuf, random_mesg[rn2(SIZE(random_mesg))]); 48. 49. wipeout_text(outbuf, (int)(strlen(outbuf) / 4), 0); 50. return outbuf; 51. } 52. 53. /* Partial rubouts for engraving characters. -3. */ 54. static const struct { 55. char wipefrom; 56. const char * wipeto; 57. } rubouts[] = { 58. {'A', "^"}, {'B', "Pb["}, {'C', "("}, {'D', "|)["}, 59. {'E', "|FL[_"}, {'F', "|-"}, {'G', "C("}, {'H', "|-"}, 60. {'I', "|"}, {'K', "|<"}, {'L', "|_"}, {'M', "|"}, 61. {'N', "|\\"}, {'O', "C("}, {'P', "F"}, {'Q', "C("}, 62. {'R', "PF"}, {'T', "|"}, {'U', "J"}, {'V', "/\\"}, 63. {'W', "V/\\"}, {'Z', "/"}, 64. {'b', "|"}, {'d', "c|"}, {'e', "c"}, {'g', "c"}, 65. {'h', "n"}, {'j', "i"}, {'k', "|"}, {'l', "|"}, 66. {'m', "nr"}, {'n', "r"}, {'o', "c"}, {'q', "c"}, 67. {'w', "v"}, {'y', "v"}, 68. {':', "."}, {';', ","}, 69. {'0', "C("}, {'1', "|"}, {'6', "o"}, {'7', "/"}, 70. {'8', "3o"} 71. }; 72. 73. void 74. wipeout_text(engr, cnt, seed) 75. char *engr; 76. int cnt; 77. unsigned seed; /* for semi-controlled randomization */ 78. { 79. char *s; 80. int i, j, nxt, use_rubout, lth = (int)strlen(engr); 81. 82. if (lth && cnt > 0) { 83. while (cnt--) { 84. /* pick next character */ 85. if (!seed) { 86. /* random */ 87. nxt = rn2(lth); 88. use_rubout = rn2(4); 89. } else { 90. /* predictable; caller can reproduce the same sequence by 91. supplying the same arguments later, or a pseudo-random 92. sequence by varying any of them */ 93. nxt = seed % lth; 94. seed *= 31, seed %= (BUFSZ-1); 95. use_rubout = seed & 3; 96. } 97. s = &engr[nxt]; 98. if (*s == ' ') continue; 99. 100. /* rub out unreadable & small punctuation marks */ 101. if (index("?.,'`-|_", *s)) { 102. *s = ' '; 103. continue; 104. } 105. 106. if (!use_rubout) 107. i = SIZE(rubouts); 108. else 109. for (i = 0; i < SIZE(rubouts); i++) 110. if (*s == rubouts[i].wipefrom) { 111. /* 112. * Pick one of the substitutes at random. 113. */ 114. if (!seed) 115. j = rn2(strlen(rubouts[i].wipeto)); 116. else { 117. seed *= 31, seed %= (BUFSZ-1); 118. j = seed % (strlen(rubouts[i].wipeto)); 119. } 120. *s = rubouts[i].wipeto[j]; 121. break; 122. } 123. 124. /* didn't pick rubout; use '?' for unreadable character */ 125. if (i == SIZE(rubouts)) *s = '?'; 126. } 127. } 128. 129. /* trim trailing spaces */ 130. while (lth && engr[lth-1] == ' ') engr[--lth] = 0; 131. } 132. 133. boolean 134. can_reach_floor() 135. { 136. return (boolean)(!u.uswallow && 137. #ifdef STEED 138. /* Restricted/unskilled riders can't reach the floor */ 139. !(u.usteed && P_SKILL(P_RIDING) < P_BASIC) && 140. #endif 141. (!Levitation || 142. Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))); 143. } 144. #endif /* OVLB */ 145. #ifdef OVL0 146. 147. const char * 148. surface(x, y) 149. register int x, y; 150. { 151. register struct rm *lev = &levl[x][y]; 152. 153. if ((x == u.ux) && (y == u.uy) && u.uswallow && 154. is_animal(u.ustuck->data)) 155. return "maw"; 156. else if (IS_AIR(lev->typ) && Is_airlevel(&u.uz)) 157. return "air"; 158. else if (is_pool(x,y)) 159. return "water"; 160. else if (is_ice(x,y)) 161. return "ice"; 162. else if (is_lava(x,y)) 163. return "lava"; 164. else if (lev->typ == DRAWBRIDGE_DOWN) 165. return "bridge"; 166. else if(IS_ALTAR(levl[x][y].typ)) 167. return "altar"; 168. else if(IS_GRAVE(levl[x][y].typ)) 169. return "headstone"; 170. else if(IS_FOUNTAIN(levl[x][y].typ)) 171. return "fountain"; 172. else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz)) || 173. IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR) 174. return "floor"; 175. else 176. return "ground"; 177. } 178. 179. const char * 180. ceiling(x, y) 181. register int x, y; 182. { 183. register struct rm *lev = &levl[x][y]; 184. const char *what; 185. 186. /* other room types will no longer exist when we're interested -- 187. * see check_special_room() 188. */ 189. if (*in_rooms(x,y,VAULT)) 190. what = "vault's ceiling"; 191. else if (*in_rooms(x,y,TEMPLE)) 192. what = "temple's ceiling"; 193. else if (*in_rooms(x,y,SHOPBASE)) 194. what = "shop's ceiling"; 195. else if (IS_AIR(lev->typ)) 196. what = "sky"; 197. else if (Underwater) 198. what = "water's surface"; 199. else if ((IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz)) || 200. IS_WALL(lev->typ) || IS_DOOR(lev->typ) || lev->typ == SDOOR) 201. what = "ceiling"; 202. else 203. what = "rock above"; 204. 205. return what; 206. } 207. 208. struct engr * 209. engr_at(x, y) 210. xchar x, y; 211. { 212. register struct engr *ep = head_engr; 213. 214. while(ep) { 215. if(x == ep->engr_x && y == ep->engr_y) 216. return(ep); 217. ep = ep->nxt_engr; 218. } 219. return((struct engr *) 0); 220. } 221. 222. #ifdef ELBERETH 223. /* Decide whether a particular string is engraved at a specified 224. * location; a case-insensitive substring match used. 225. * Ignore headstones, in case the player names herself "Elbereth". 226. */ 227. int 228. sengr_at(s, x, y) 229. const char *s; 230. xchar x, y; 231. { 232. register struct engr *ep = engr_at(x,y); 233. 234. return (ep && ep->engr_type != HEADSTONE && 235. ep->engr_time <= moves && strstri(ep->engr_txt, s) != 0); 236. } 237. #endif /* ELBERETH */ 238. 239. #endif /* OVL0 */ 240. #ifdef OVL2 241. 242. void 243. u_wipe_engr(cnt) 244. register int cnt; 245. { 246. if (can_reach_floor()) 247. wipe_engr_at(u.ux, u.uy, cnt); 248. } 249. 250. #endif /* OVL2 */ 251. #ifdef OVL1 252. 253. void 254. wipe_engr_at(x,y,cnt) 255. register xchar x,y,cnt; 256. { 257. register struct engr *ep = engr_at(x,y); 258. 259. /* Headstones are indelible */ 260. if(ep && ep->engr_type != HEADSTONE){ 261. if(ep->engr_type != BURN || is_ice(x,y)) { 262. if(ep->engr_type != DUST && ep->engr_type != ENGR_BLOOD) { 263. cnt = rn2(1 + 50/(cnt+1)) ? 0 : 1; 264. } 265. wipeout_text(ep->engr_txt, (int)cnt, 0); 266. while(ep->engr_txt[0] == ' ') 267. ep->engr_txt++; 268. if(!ep->engr_txt[0]) del_engr(ep); 269. } 270. } 271. } 272. 273. #endif /* OVL1 */ 274. #ifdef OVL2 275. 276. void 277. read_engr_at(x,y) 278. register int x,y; 279. { 280. register struct engr *ep = engr_at(x,y); 281. register int sensed = 0; 282. char buf[BUFSZ]; 283. 284. /* Sensing an engraving does not require sight, 285. * nor does it necessarily imply comprehension (literacy). 286. */ 287. if(ep && ep->engr_txt[0]) { 288. switch(ep->engr_type) { 289. case DUST: 290. if(!Blind) { 291. sensed = 1; 292. pline("%s is written here in the %s.", Something, 293. is_ice(x,y) ? "frost" : "dust"); 294. } 295. break; 296. case ENGRAVE: 297. case HEADSTONE: 298. if (!Blind || can_reach_floor()) { 299. sensed = 1; 300. pline("%s is engraved here on the %s.", 301. Something, 302. surface(x,y)); 303. } 304. break; 305. case BURN: 306. if (!Blind || can_reach_floor()) { 307. sensed = 1; 308. pline("Some text has been %s into the %s here.", 309. is_ice(x,y) ? "melted" : "burned", 310. surface(x,y)); 311. } 312. break; 313. case MARK: 314. if(!Blind) { 315. sensed = 1; 316. pline("There's some graffiti on the %s here.", 317. surface(x,y)); 318. } 319. break; 320. case ENGR_BLOOD: 321. /* "It's a message! Scrawled in blood!" 322. * "What's it say?" 323. * "It says... `See you next Wednesday.'" -- Thriller 324. */ 325. if(!Blind) { 326. sensed = 1; 327. You("see a message scrawled in blood here."); 328. } 329. break; 330. default: 331. impossible("%s is written in a very strange way.", 332. Something); 333. sensed = 1; 334. } 335. if (sensed) { 336. char *et; 337. unsigned maxelen = BUFSZ - sizeof("You feel the words: \"\". "); 338. if (strlen(ep->engr_txt) > maxelen) { 339. (void) strncpy(buf, ep->engr_txt, (int)maxelen); 340. buf[maxelen] = '\0'; 341. et = buf; 342. } else 343. et = ep->engr_txt; 344. You("%s: \"%s\".", 345. (Blind) ? "feel the words" : "read", et); 346. if(flags.run > 1) nomul(0); 347. } 348. } 349. } 350. 351. #endif /* OVL2 */ 352. #ifdef OVLB 353. 354. void 355. make_engr_at(x,y,s,e_time,e_type) 356. register int x,y; 357. register const char *s; 358. register long e_time; 359. register xchar e_type; 360. { 361. register struct engr *ep; 362. 363. if ((ep = engr_at(x,y)) != 0) 364. del_engr(ep); 365. ep = newengr(strlen(s) + 1); 366. ep->nxt_engr = head_engr; 367. head_engr = ep; 368. ep->engr_x = x; 369. ep->engr_y = y; 370. ep->engr_txt = (char *)(ep + 1); 371. Strcpy(ep->engr_txt, s); 372. /* engraving Elbereth shows wisdom */ 373. if(!strcmp(s, "Elbereth")) exercise(A_WIS, TRUE); 374. ep->engr_time = e_time; 375. ep->engr_type = e_type > 0 ? e_type : rnd(N_ENGRAVE-1); 376. ep->engr_lth = strlen(s) + 1; 377. } 378. 379. /* delete any engraving at location */ 380. void 381. del_engr_at(x, y) 382. int x, y; 383. { 384. register struct engr *ep = engr_at(x, y); 385. 386. if (ep) del_engr(ep); 387. } 388. 389. /* 390. * freehand - returns true if player has a free hand 391. */ 392. int 393. freehand() 394. { 395. return(!uwep || !welded(uwep) || 396. (!bimanual(uwep) && (!uarms || !uarms->cursed))); 397. /* if ((uwep && bimanual(uwep)) || 398. (uwep && uarms)) 399. return(0); 400. else 401. return(1);*/ 402. } 403. 404. static NEARDATA const char styluses[] = 405. { ALL_CLASSES, ALLOW_NONE, TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 406. GEM_CLASS, RING_CLASS, 0 }; 407. 408. /* Mohs' Hardness Scale: 409. * 1 - Talc 6 - Orthoclase 410. * 2 - Gypsum 7 - Quartz 411. * 3 - Calcite 8 - Topaz 412. * 4 - Fluorite 9 - Corundum 413. * 5 - Apatite 10 - Diamond 414. * 415. * Since granite is a igneous rock hardness ~ 7, anything >= 8 should 416. * probably be able to scratch the rock. 417. * Devaluation of less hard gems is not easily possible because obj struct 418. * does not contain individual oc_cost currently. 7/91 419. * 420. * steel - 5-8.5 (usu. weapon) 421. * diamond - 10 * jade - 5-6 (nephrite) 422. * ruby - 9 (corundum) * turquoise - 5-6 423. * sapphire - 9 (corundum) * opal - 5-6 424. * topaz - 8 * glass - ~5.5 425. * emerald - 7.5-8 (beryl) * dilithium - 4-5?? 426. * aquamarine - 7.5-8 (beryl) * iron - 4-5 427. * garnet - 7.25 (var. 6.5-8) * fluorite - 4 428. * agate - 7 (quartz) * brass - 3-4 429. * amethyst - 7 (quartz) * gold - 2.5-3 430. * jasper - 7 (quartz) * silver - 2.5-3 431. * onyx - 7 (quartz) * copper - 2.5-3 432. * moonstone - 6 (orthoclase) * amber - 2-2.5 433. */ 434. 435. /* return 1 if action took 1 (or more) moves, 0 if error or aborted */ 436. int 437. doengrave() 438. { 439. boolean dengr = FALSE; /* TRUE if we wipe out the current engraving */ 440. boolean doblind = FALSE;/* TRUE if engraving blinds the player */ 441. boolean doknown = FALSE;/* TRUE if we identify the stylus */ 442. boolean eow = FALSE; /* TRUE if we are overwriting oep */ 443. boolean jello = FALSE; /* TRUE if we are engraving in slime */ 444. boolean ptext = TRUE; /* TRUE if we must prompt for engrave text */ 445. boolean teleengr =FALSE;/* TRUE if we move the old engraving */ 446. boolean zapwand = FALSE;/* TRUE if we remove a wand charge */ 447. xchar type = DUST; /* Type of engraving made */ 448. char buf[BUFSZ]; /* Buffer for final/poly engraving text */ 449. char ebuf[BUFSZ]; /* Buffer for initial engraving text */ 450. char qbuf[QBUFSZ]; /* Buffer for query text */ 451. char post_engr_text[BUFSZ]; /* Text displayed after engraving prompt */ 452. const char *everb; /* Present tense of engraving type */ 453. const char *eloc; /* Where the engraving is (ie dust/floor/...) */ 454. char *sp; /* Place holder for space count of engr text */ 455. int len; /* # of nonspace chars of new engraving text */ 456. int maxelen; /* Max allowable length of engraving text */ 457. struct engr *oep = engr_at(u.ux,u.uy); 458. /* The current engraving */ 459. struct obj *otmp; /* Object selected with which to engrave */ 460. char *writer; 461. 462. multi = 0; /* moves consumed */ 463. nomovemsg = (char *)0; /* occupation end message */ 464. 465. buf[0] = (char)0; 466. ebuf[0] = (char)0; 467. post_engr_text[0] = (char)0; 468. maxelen = BUFSZ - 1; 469. if (is_demon(youmonst.data) || youmonst.data->mlet == S_VAMPIRE) 470. type = ENGR_BLOOD; 471. 472. /* Can the adventurer engrave at all? */ 473. 474. if(u.uswallow) { 475. if (is_animal(u.ustuck->data)) { 476. pline("What would you write? \"Jonah was here\"?"); 477. return(0); 478. } else if (is_whirly(u.ustuck->data)) { 479. You_cant("reach the %s.", surface(u.ux,u.uy)); 480. return(0); 481. } else 482. jello = TRUE; 483. } else if (is_lava(u.ux, u.uy)) { 484. You_cant("write on the lava!"); 485. return(0); 486. } else if (is_pool(u.ux,u.uy) || IS_FOUNTAIN(levl[u.ux][u.uy].typ)) { 487. You_cant("write on the water!"); 488. return(0); 489. } 490. if(Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)/* in bubble */) { 491. You_cant("write in thin air!"); 492. return(0); 493. } 494. if (cantwield(youmonst.data)) { 495. You_cant("even hold anything!"); 496. return(0); 497. } 498. if (check_capacity((char *)0)) return (0); 499. 500. /* One may write with finger, or weapon, or wand, or..., or... 501. * Edited by GAN 10/20/86 so as not to change weapon wielded. 502. */ 503. 504. otmp = getobj(styluses, "write with"); 505. if(!otmp) return(0); /* otmp == zeroobj if fingers */ 506. 507. if (otmp == &zeroobj) writer = makeplural(body_part(FINGER)); 508. else writer = xname(otmp); 509. 510. /* There's no reason you should be able to write with a wand 511. * while both your hands are tied up. 512. */ 513. if (!freehand() && otmp != uwep && !otmp->owornmask) { 514. You("have no free %s to write with!", body_part(HAND)); 515. return(0); 516. } 517. 518. if (jello) { 519. You("tickle %s with your %s.", mon_nam(u.ustuck), writer); 520. Your("message dissolves..."); 521. return(0); 522. } 523. if (otmp->oclass != WAND_CLASS && !can_reach_floor()) { 524. You_cant("reach the %s!", surface(u.ux,u.uy)); 525. return(0); 526. } 527. if (IS_ALTAR(levl[u.ux][u.uy].typ)) { 528. You("make a motion towards the altar with your %s.", writer); 529. altar_wrath(u.ux, u.uy); 530. return(0); 531. } 532. if (IS_GRAVE(levl[u.ux][u.uy].typ)) { 533. if (!levl[u.ux][u.uy].disturbed) { 534. You("disturb the undead!"); 535. levl[u.ux][u.uy].disturbed = 1; 536. (void) makemon(&mons[PM_GHOUL], u.ux, u.uy, NO_MM_FLAGS); 537. exercise(A_WIS, FALSE); 538. return(1); 539. } 540. } 541. 542. /* SPFX for items */ 543. 544. switch (otmp->oclass) { 545. default: 546. case AMULET_CLASS: 547. case CHAIN_CLASS: 548. case POTION_CLASS: 549. case GOLD_CLASS: 550. break; 551. 552. case RING_CLASS: 553. /* "diamond" rings and others should work */ 554. case GEM_CLASS: 555. /* diamonds & other hard gems should work */ 556. if (objects[otmp->otyp].oc_tough) { 557. type = ENGRAVE; 558. break; 559. } 560. break; 561. 562. case ARMOR_CLASS: 563. if (is_boots(otmp)) { 564. type = DUST; 565. break; 566. } 567. /* fall through */ 568. /* Objects too large to engrave with */ 569. case BALL_CLASS: 570. case ROCK_CLASS: 571. You_cant("engrave with such a large object!"); 572. ptext = FALSE; 573. break; 574. 575. /* Objects too silly to engrave with */ 576. case FOOD_CLASS: 577. case SCROLL_CLASS: 578. case SPBOOK_CLASS: 579. Your("%s would get %s.", xname(otmp), 580. is_ice(u.ux,u.uy) ? "all frosty" : "too dirty"); 581. ptext = FALSE; 582. break; 583. 584. case RANDOM_CLASS: /* This should mean fingers */ 585. break; 586. 587. /* The charge is removed from the wand before prompting for 588. * the engraving text, because all kinds of setup decisions 589. * and pre-engraving messages are based upon knowing what type 590. * of engraving the wand is going to do. Also, the player 591. * will have potentially seen "You wrest .." message, and 592. * therefore will know they are using a charge. 593. */ 594. case WAND_CLASS: 595. if (zappable(otmp)) { 596. check_unpaid(otmp); 597. zapwand = TRUE; 598. if (Levitation) ptext = FALSE; 599. 600. switch (otmp->otyp) { 601. /* DUST wands */ 602. default: 603. break; 604. 605. /* NODIR wands */ 606. case WAN_LIGHT: 607. case WAN_SECRET_DOOR_DETECTION: 608. case WAN_CREATE_MONSTER: 609. case WAN_WISHING: 610. case WAN_ENLIGHTENMENT: 611. zapnodir(otmp); 612. break; 613. 614. /* IMMEDIATE wands */ 615. /* If wand is "IMMEDIATE", remember to affect the 616. * previous engraving even if turning to dust. 617. */ 618. case WAN_STRIKING: 619. Strcpy(post_engr_text, 620. "The wand unsuccessfully fights your attempt to write!" 621. ); 622. break; 623. case WAN_SLOW_MONSTER: 624. if (!Blind) { 625. Sprintf(post_engr_text, 626. "The bugs on the %s slow down!", 627. surface(u.ux, u.uy)); 628. } 629. break; 630. case WAN_SPEED_MONSTER: 631. if (!Blind) { 632. Sprintf(post_engr_text, 633. "The bugs on the %s speed up!", 634. surface(u.ux, u.uy)); 635. } 636. break; 637. case WAN_POLYMORPH: 638. if(oep) { 639. if (!Blind) { 640. type = (xchar)0; /* random */ 641. (void) random_engraving(buf); 642. } 643. dengr = TRUE; 644. } 645. break; 646. case WAN_NOTHING: 647. case WAN_UNDEAD_TURNING: 648. case WAN_OPENING: 649. case WAN_LOCKING: 650. case WAN_PROBING: 651. break; 652. 653. /* RAY wands */ 654. case WAN_MAGIC_MISSILE: 655. ptext = TRUE; 656. if (!Blind) { 657. Sprintf(post_engr_text, 658. "The %s is riddled by bullet holes!", 659. surface(u.ux, u.uy)); 660. } 661. break; 662. 663. /* can't tell sleep from death - Eric Backus */ 664. case WAN_SLEEP: 665. case WAN_DEATH: 666. if (!Blind) { 667. Sprintf(post_engr_text, 668. "The bugs on the %s stop moving!", 669. surface(u.ux, u.uy)); 670. } 671. break; 672. 673. case WAN_COLD: 674. if (!Blind) 675. Strcpy(post_engr_text, 676. "A few ice cubes drop from the wand."); 677. if(!oep || (oep->engr_type != BURN)) 678. break; 679. case WAN_CANCELLATION: 680. case WAN_MAKE_INVISIBLE: 681. if (oep && oep->engr_type != HEADSTONE) { 682. if (!Blind) 683. pline_The("engraving on the %s vanishes!", 684. surface(u.ux,u.uy)); 685. dengr = TRUE; 686. } 687. break; 688. case WAN_TELEPORTATION: 689. if (oep && oep->engr_type != HEADSTONE) { 690. if (!Blind) 691. pline_The("engraving on the %s vanishes!", 692. surface(u.ux,u.uy)); 693. teleengr = TRUE; 694. } 695. break; 696. 697. /* type = ENGRAVE wands */ 698. case WAN_DIGGING: 699. ptext = TRUE; 700. type = ENGRAVE; 701. if(!objects[otmp->otyp].oc_name_known) { 702. if (flags.verbose) 703. pline("This %s is a wand of digging!", 704. xname(otmp)); 705. doknown = TRUE; 706. } 707. if (!Blind) 708. Strcpy(post_engr_text, 709. is_ice(u.ux,u.uy) ? 710. "Ice chips fly up from the ice surface!" : 711. "Gravel flies up from the floor."); 712. else 713. Strcpy(post_engr_text, "You hear drilling!"); 714. break; 715. 716. /* type = BURN wands */ 717. case WAN_FIRE: 718. ptext = TRUE; 719. type = BURN; 720. if(!objects[otmp->otyp].oc_name_known) { 721. if (flags.verbose) 722. pline("This %s is a wand of fire!", xname(otmp)); 723. doknown = TRUE; 724. } 725. Strcpy(post_engr_text, 726. Blind ? "You feel the wand heat up." : 727. "Flames fly from the wand."); 728. break; 729. case WAN_LIGHTNING: 730. ptext = TRUE; 731. type = BURN; 732. if(!objects[otmp->otyp].oc_name_known) { 733. if (flags.verbose) 734. pline("This %s is a wand of lightning!", 735. xname(otmp)); 736. doknown = TRUE; 737. } 738. if (!Blind) { 739. Strcpy(post_engr_text, 740. "Lightning arcs from the wand."); 741. doblind = TRUE; 742. } else 743. Strcpy(post_engr_text, "You hear crackling!"); 744. break; 745. 746. /* type = MARK wands */ 747. /* type = ENGR_BLOOD wands */ 748. } 749. } else /* end if zappable */ 750. if (!can_reach_floor()) { 751. You_cant("reach the %s!", surface(u.ux,u.uy)); 752. return(0); 753. } 754. break; 755. 756. case WEAPON_CLASS: 757. if (is_blade(otmp)) { 758. if ((int)otmp->spe > -3) 759. type = ENGRAVE; 760. else 761. Your("%s too dull for engraving.", aobjnam(otmp,"are")); 762. } 763. break; 764. 765. case TOOL_CLASS: 766. if(otmp == ublindf) { 767. pline( 768. "That is a bit difficult to engrave with, don't you think?"); 769. return(0); 770. } 771. switch (otmp->otyp) { 772. case MAGIC_MARKER: 773. if (otmp->spe <= 0) 774. Your("marker has dried out."); 775. else 776. type = MARK; 777. break; 778. case TOWEL: 779. /* Can't really engrave with a towel */ 780. ptext = FALSE; 781. if (oep) 782. if ((oep->engr_type == DUST ) || 783. (oep->engr_type == ENGR_BLOOD) || 784. (oep->engr_type == MARK )) { 785. if (!Blind) 786. You("wipe out the message here."); 787. else 788. Your("%s %s %s.", xname(otmp), 789. otense(otmp, "get"), 790. is_ice(u.ux,u.uy) ? 791. "frosty" : "dusty"); 792. dengr = TRUE; 793. } else 794. Your("%s can't wipe out this engraving.", 795. xname(otmp)); 796. else 797. Your("%s %s %s.", xname(otmp), otense(otmp, "get"), 798. is_ice(u.ux,u.uy) ? "frosty" : "dusty"); 799. break; 800. default: 801. break; 802. } 803. break; 804. 805. case VENOM_CLASS: 806. #ifdef WIZARD 807. if (wizard) { 808. pline("Writing a poison pen letter??"); 809. break; 810. } 811. #endif 812. case ILLOBJ_CLASS: 813. impossible("You're engraving with an illegal object!"); 814. break; 815. } 816. 817. if (IS_GRAVE(levl[u.ux][u.uy].typ)) { 818. if (type == ENGRAVE || type == 0) 819. type = HEADSTONE; 820. else { 821. /* ensures the "cannot wipe out" case */ 822. type = DUST; 823. dengr = FALSE; 824. teleengr = FALSE; 825. buf[0] = (char)0; 826. } 827. } 828. 829. /* End of implement setup */ 830. 831. /* Identify stylus */ 832. if (doknown) { 833. makeknown(otmp->otyp); 834. more_experienced(0,10); 835. } 836. 837. if (teleengr) { 838. rloc_engr(oep); 839. oep = (struct engr *)0; 840. } 841. 842. if (dengr) { 843. del_engr(oep); 844. oep = (struct engr *)0; 845. } 846. 847. /* Something has changed the engraving here */ 848. if (*buf) { 849. make_engr_at(u.ux, u.uy, buf, moves, type); 850. pline_The("engraving now reads: \"%s\".", buf); 851. ptext = FALSE; 852. } 853. 854. if (zapwand && (otmp->spe < 0)) { 855. pline("%s %sturns to dust.", 856. The(xname(otmp)), Blind ? "" : "glows violently, then "); 857. if (!IS_GRAVE(levl[u.ux][u.uy].typ)) 858. You("are not going to get anywhere trying to write in the %s with your dust.", 859. is_ice(u.ux,u.uy) ? "frost" : "dust"); 860. useup(otmp); 861. ptext = FALSE; 862. } 863. 864. if (!ptext) { /* Early exit for some implements. */ 865. if (otmp->oclass == WAND_CLASS && !can_reach_floor()) 866. You_cant("reach the %s!", surface(u.ux,u.uy)); 867. return(1); 868. } 869. 870. /* Special effects should have deleted the current engraving (if 871. * possible) by now. 872. */ 873. 874. if (oep) { 875. register char c = 'n'; 876. 877. /* Give player the choice to add to engraving. */ 878. 879. if (type == HEADSTONE) { 880. /* no choice, only append */ 881. c = 'y'; 882. } else if ( (type == oep->engr_type) && (!Blind || 883. (oep->engr_type == BURN) || (oep->engr_type == ENGRAVE)) ) { 884. c = yn_function("Do you want to add to the current engraving?", 885. ynqchars, 'y'); 886. if (c == 'q') { 887. pline(Never_mind); 888. return(0); 889. } 890. } 891. 892. if (c == 'n' || Blind) { 893. 894. if( (oep->engr_type == DUST) || (oep->engr_type == ENGR_BLOOD) || 895. (oep->engr_type == MARK) ) { 896. if (!Blind) { 897. You("wipe out the message that was %s here.", 898. ((oep->engr_type == DUST) ? "written in the dust" : 899. ((oep->engr_type == ENGR_BLOOD) ? "scrawled in blood" : 900. "written"))); 901. del_engr(oep); 902. oep = (struct engr *)0; 903. } else 904. /* Don't delete engr until after we *know* we're engraving */ 905. eow = TRUE; 906. } else 907. if ( (type == DUST) || (type == MARK) || (type == ENGR_BLOOD) ) { 908. You( 909. "cannot wipe out the message that is %s the %s here.", 910. oep->engr_type == BURN ? 911. (is_ice(u.ux,u.uy) ? "melted into" : "burned into") : 912. "engraved in", surface(u.ux,u.uy)); 913. return(1); 914. } else 915. if ( (type != oep->engr_type) || (c == 'n') ) { 916. if (!Blind || can_reach_floor()) 917. You("will overwrite the current message."); 918. eow = TRUE; 919. } 920. } 921. } 922. 923. eloc = surface(u.ux,u.uy); 924. switch(type){ 925. default: 926. everb = (oep && !eow ? "add to the weird writing on" : 927. "write strangely on"); 928. break; 929. case DUST: 930. everb = (oep && !eow ? "add to the writing in" : 931. "write in"); 932. eloc = is_ice(u.ux,u.uy) ? "frost" : "dust"; 933. break; 934. case ENGRAVE: 935. everb = (oep && !eow ? "add to the engraving in" : 936. "engrave in"); 937. break; 938. case BURN: 939. everb = (oep && !eow ? 940. ( is_ice(u.ux,u.uy) ? "add to the text melted into" : 941. "add to the text burned into") : 942. ( is_ice(u.ux,u.uy) ? "melt into" : "burn into")); 943. break; 944. case MARK: 945. everb = (oep && !eow ? "add to the graffiti on" : 946. "scribble on"); 947. break; 948. case ENGR_BLOOD: 949. everb = (oep && !eow ? "add to the scrawl on" : 950. "scrawl on"); 951. break; 952. } 953. 954. /* Tell adventurer what is going on */ 955. if (otmp != &zeroobj) 956. You("%s the %s with %s.", everb, eloc, doname(otmp)); 957. else 958. You("%s the %s with your %s.", everb, eloc, 959. makeplural(body_part(FINGER))); 960. 961. /* Prompt for engraving! */ 962. Sprintf(qbuf,"What do you want to %s the %s here?", everb, eloc); 963. getlin(qbuf, ebuf); 964. 965. /* Count the actual # of chars engraved not including spaces */ 966. len = strlen(ebuf); 967. for (sp = ebuf; *sp; sp++) if (isspace(*sp)) len -= 1; 968. 969. if (len == 0 || index(ebuf, '\033')) { 970. if (zapwand) { 971. if (!Blind) 972. pline("%s, then %s.", 973. Tobjnam(otmp, "glow"), otense(otmp, "fade")); 974. return(1); 975. } else { 976. pline(Never_mind); 977. return(0); 978. } 979. } 980. 981. /* A single `x' is the traditional signature of an illiterate person */ 982. if (len != 1 || (!index(ebuf, 'x') && !index(ebuf, 'X'))) 983. u.uconduct.literate++; 984. 985. /* Mix up engraving if surface or state of mind is unsound. 986. Note: this won't add or remove any spaces. */ 987. for (sp = ebuf; *sp; sp++) { 988. if (isspace(*sp)) continue; 989. if (((type == DUST || type == ENGR_BLOOD) && !rn2(25)) || 990. (Blind && !rn2(11)) || (Confusion && !rn2(7)) || 991. (Stunned && !rn2(4)) || (Hallucination && !rn2(2))) 992. *sp = ' ' + rnd(96 - 2); /* ASCII '!' thru '~' 993. (excludes ' ' and DEL) */ 994. } 995. 996. /* Previous engraving is overwritten */ 997. if (eow) { 998. del_engr(oep); 999. oep = (struct engr *)0; 1000. } 1001. 1002. /* Figure out how long it took to engrave, and if player has 1003. * engraved too much. 1004. */ 1005. switch(type){ 1006. default: 1007. multi = -(len/10); 1008. if (multi) nomovemsg = "You finish your weird engraving."; 1009. break; 1010. case DUST: 1011. multi = -(len/10); 1012. if (multi) nomovemsg = "You finish writing in the dust."; 1013. break; 1014. case ENGRAVE: 1015. multi = -(len/10); 1016. if ((otmp->oclass == WEAPON_CLASS) && 1017. ((otmp->otyp != ATHAME) || otmp->cursed)) { 1018. multi = -len; 1019. maxelen = ((otmp->spe + 3) * 2) + 1; 1020. /* -2 = 3, -1 = 5, 0 = 7, +1 = 9, +2 = 11 1021. * Note: this does not allow a +0 anything (except 1022. * an athame) to engrave "Elbereth" all at once. 1023. * However, you could now engrave "Elb", then 1024. * "ere", then "th". 1025. */ 1026. Your("%s dull.", aobjnam(otmp, "get")); 1027. if (otmp->unpaid) { 1028. struct monst *shkp = shop_keeper(*u.ushops); 1029. if (shkp) { 1030. You("damage it, you pay for it!"); 1031. bill_dummy_object(otmp); 1032. } 1033. } 1034. if (len > maxelen) { 1035. multi = -maxelen; 1036. otmp->spe = -3; 1037. } else if (len > 1) 1038. otmp->spe -= len >> 1; 1039. else otmp->spe -= 1; /* Prevent infinite engraving */ 1040. } else 1041. if ( (otmp->oclass == RING_CLASS) || 1042. (otmp->oclass == GEM_CLASS) ) 1043. multi = -len; 1044. if (multi) nomovemsg = "You finish engraving."; 1045. break; 1046. case BURN: 1047. multi = -(len/10); 1048. if (multi) 1049. nomovemsg = is_ice(u.ux,u.uy) ? 1050. "You finish melting your message into the ice.": 1051. "You finish burning your message into the floor."; 1052. break; 1053. case MARK: 1054. multi = -(len/10); 1055. if ((otmp->oclass == TOOL_CLASS) && 1056. (otmp->otyp == MAGIC_MARKER)) { 1057. maxelen = (otmp->spe) * 2; /* one charge / 2 letters */ 1058. if (len > maxelen) { 1059. Your("marker dries out."); 1060. otmp->spe = 0; 1061. multi = -(maxelen/10); 1062. } else 1063. if (len > 1) otmp->spe -= len >> 1; 1064. else otmp->spe -= 1; /* Prevent infinite grafitti */ 1065. } 1066. if (multi) nomovemsg = "You finish defacing the dungeon."; 1067. break; 1068. case ENGR_BLOOD: 1069. multi = -(len/10); 1070. if (multi) nomovemsg = "You finish scrawling."; 1071. break; 1072. } 1073. 1074. /* Chop engraving down to size if necessary */ 1075. if (len > maxelen) { 1076. for (sp = ebuf; (maxelen && *sp); sp++) 1077. if (!isspace(*sp)) maxelen--; 1078. if (!maxelen && *sp) { 1079. *sp = (char)0; 1080. if (multi) nomovemsg = "You cannot write any more."; 1081. You("only are able to write \"%s\"", ebuf); 1082. } 1083. } 1084. 1085. /* Add to existing engraving */ 1086. if (oep) Strcpy(buf, oep->engr_txt); 1087. 1088. (void) strncat(buf, ebuf, (BUFSZ - (int)strlen(buf) - 1)); 1089. 1090. make_engr_at(u.ux, u.uy, buf, (moves - multi), type); 1091. 1092. if (post_engr_text[0]) pline(post_engr_text); 1093. 1094. if (doblind && !resists_blnd(&youmonst)) { 1095. You("are blinded by the flash!"); 1096. make_blinded((long)rnd(50),FALSE); 1097. if (!Blind) Your(vision_clears); 1098. } 1099. 1100. return(1); 1101. } 1102. 1103. void 1104. save_engravings(fd, mode) 1105. int fd, mode; 1106. { 1107. register struct engr *ep = head_engr; 1108. register struct engr *ep2; 1109. unsigned no_more_engr = 0; 1110. 1111. while (ep) { 1112. ep2 = ep->nxt_engr; 1113. if (ep->engr_lth && ep->engr_txt[0] && perform_bwrite(mode)) { 1114. bwrite(fd, (genericptr_t)&(ep->engr_lth), sizeof(ep->engr_lth)); 1115. bwrite(fd, (genericptr_t)ep, sizeof(struct engr) + ep->engr_lth); 1116. } 1117. if (release_data(mode)) 1118. dealloc_engr(ep); 1119. ep = ep2; 1120. } 1121. if (perform_bwrite(mode)) 1122. bwrite(fd, (genericptr_t)&no_more_engr, sizeof no_more_engr); 1123. if (release_data(mode)) 1124. head_engr = 0; 1125. } 1126. 1127. void 1128. rest_engravings(fd) 1129. int fd; 1130. { 1131. register struct engr *ep; 1132. unsigned lth; 1133. 1134. head_engr = 0; 1135. while(1) { 1136. mread(fd, (genericptr_t) &lth, sizeof(unsigned)); 1137. if(lth == 0) return; 1138. ep = newengr(lth); 1139. mread(fd, (genericptr_t) ep, sizeof(struct engr) + lth); 1140. ep->nxt_engr = head_engr; 1141. head_engr = ep; 1142. ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */ 1143. /* mark as finished for bones levels -- no problem for 1144. * normal levels as the player must have finished engraving 1145. * to be able to move again */ 1146. ep->engr_time = moves; 1147. } 1148. } 1149. 1150. void 1151. del_engr(ep) 1152. register struct engr *ep; 1153. { 1154. if (ep == head_engr) { 1155. head_engr = ep->nxt_engr; 1156. } else { 1157. register struct engr *ept; 1158. 1159. for (ept = head_engr; ept; ept = ept->nxt_engr) 1160. if (ept->nxt_engr == ep) { 1161. ept->nxt_engr = ep->nxt_engr; 1162. break; 1163. } 1164. if (!ept) { 1165. impossible("Error in del_engr?"); 1166. return; 1167. } 1168. } 1169. dealloc_engr(ep); 1170. } 1171. 1172. /* randomly relocate an engraving */ 1173. void 1174. rloc_engr(ep) 1175. struct engr *ep; 1176. { 1177. int tx, ty, tryct = 200; 1178. 1179. do { 1180. if (--tryct < 0) return; 1181. tx = rn1(COLNO-3,2); 1182. ty = rn2(ROWNO); 1183. } while (engr_at(tx, ty) || 1184. !goodpos(tx, ty, (struct monst *)0)); 1185. 1186. ep->engr_x = tx; 1187. ep->engr_y = ty; 1188. } 1189. 1190. 1191. /* Epitaphs for random headstones */ 1192. static const char *epitaphs[] = { 1193. "Rest in peace", 1194. "R.I.P.", 1195. "Rest In Pieces", 1196. "Note -- there are NO valuable items in this grave", 1197. "1994-1995. The Longest-Lived Hacker Ever", 1198. "The Grave of the Unknown Hacker", 1199. "We weren't sure who this was, but we buried him here anyway", 1200. "Sparky -- he was a very good dog", 1201. "Beware of Electric Third Rail", 1202. "Made in Taiwan", 1203. "Og friend. Og good dude. Og died. Og now food", 1204. "Beetlejuice Beetlejuice Beetlejuice", 1205. "Look out below!", 1206. "Please don't dig me up. I'm perfectly happy down here. -- Resident", 1207. "Postman, please note forwarding address: Gehennom, Asmodeus's Fortress, fifth lemure on the left", 1208. "Mary had a little lamb/Its fleece was white as snow/When Mary was in trouble/The lamb was first to go", 1209. "Be careful, or this could happen to you!", 1210. "Soon you'll join this fellow in hell! -- the Wizard of Yendor", 1211. "Caution! This grave contains toxic waste", 1212. "Sum quod eris", 1213. "Here lies an Atheist, all dressed up and no place to go", 1214. "Here lies Ezekiel, age 102. The good die young.", 1215. "Here lies my wife: Here let her lie! Now she's at rest and so am I.", 1216. "Here lies Johnny Yeast. Pardon me for not rising.", 1217. "He always lied while on the earth and now he's lying in it", 1218. "I made an ash of myself", 1219. "Soon ripe. Soon rotten. Soon gone. But not forgotten.", 1220. "Here lies the body of Jonathan Blake. Stepped on the gas instead of the brake.", 1221. "Go away!" 1222. }; 1223. 1224. /* Create a headstone at the given location. 1225. * The caller is responsible for newsym(x, y). 1226. */ 1227. void 1228. make_grave(x, y, str) 1229. int x, y; 1230. const char *str; 1231. { 1232. /* Can we put a grave here? */ 1233. if ((levl[x][y].typ != ROOM && levl[x][y].typ != GRAVE) || t_at(x,y)) return; 1234. 1235. /* Make the grave */ 1236. levl[x][y].typ = GRAVE; 1237. 1238. /* Engrave the headstone */ 1239. if (!str) str = epitaphs[rn2(SIZE(epitaphs))]; 1240. del_engr_at(x, y); 1241. make_engr_at(x, y, str, 0L, HEADSTONE); 1242. return; 1243. } 1244. 1245. 1246. #endif /* OVLB */ 1247. 1248. /*engrave.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