About: Source:NetHack 3.1.0/objnam.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 objnam.c from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/objnam.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.1.0/objnam.c
rdfs:comment
  • Below is the full text to objnam.c from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/objnam.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 objnam.c from the source code of NetHack 3.1.0. To link to a particular line, write [[NetHack 3.1.0/objnam.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)objnam.c 3.1 92/12/13 */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #include "hack.h" 6. 7. /* "an uncursed partly eaten guardian naga hatchling corpse" */ 8. #define PREFIX 50 9. #define SCHAR_LIM 127 10. 11. STATIC_DCL char *FDECL(strprepend,(char *,const char *)); 12. 13. struct Jitem { 14. int item; 15. const char *name; 16. }; 17. 18. #ifndef OVLB 19. 20. STATIC_DCL struct Jitem Japanese_items[]; 21. 22. #else /* OVLB */ 23. 24. STATIC_OVL struct Jitem Japanese_items[] = { 25. { SHORT_SWORD, "wakizashi" }, 26. { BROADSWORD, "ninja-to" }, 27. { GLAIVE, "naginata" }, 28. { LOCK_PICK, "osaku" }, 29. {0, "" } 30. }; 31. 32. #endif /* OVLB */ 33. 34. STATIC_DCL const char *FDECL(Japanese_item_name,(int i)); 35. 36. #ifdef OVL1 37. 38. STATIC_OVL char * 39. strprepend(s,pref) 40. register char *s; 41. register const char *pref; { 42. register int i = strlen(pref); 43. if(i > PREFIX) { 44. pline("WARNING: prefix too short."); 45. return(s); 46. } 47. s -= i; 48. (void) strncpy(s, pref, i); /* do not copy trailing 0 */ 49. return(s); 50. } 51. 52. #endif /* OVL1 */ 53. #ifdef OVLB 54. 55. char * 56. typename(otyp) 57. register int otyp; 58. { 59. #ifdef LINT /* static char buf[BUFSZ]; */ 60. char buf[BUFSZ]; 61. #else 62. static char NEARDATA buf[BUFSZ]; 63. #endif 64. register struct objclass *ocl = &objects[otyp]; 65. register const char *actualn = OBJ_NAME(*ocl); 66. register const char *dn = OBJ_DESCR(*ocl); 67. register const char *un = ocl->oc_uname; 68. register int nn = ocl->oc_name_known; 69. 70. if (pl_character[0] == 'S' && Japanese_item_name(otyp)) 71. actualn = Japanese_item_name(otyp); 72. switch(ocl->oc_class) { 73. case GOLD_CLASS: 74. Strcpy(buf, "coin"); 75. break; 76. case POTION_CLASS: 77. Strcpy(buf, "potion"); 78. break; 79. case SCROLL_CLASS: 80. Strcpy(buf, "scroll"); 81. break; 82. case WAND_CLASS: 83. Strcpy(buf, "wand"); 84. break; 85. case SPBOOK_CLASS: 86. Strcpy(buf, "spellbook"); 87. break; 88. case RING_CLASS: 89. Strcpy(buf, "ring"); 90. break; 91. case AMULET_CLASS: 92. if(nn) 93. Strcpy(buf,actualn); 94. else 95. Strcpy(buf,"amulet"); 96. if(un) 97. Sprintf(eos(buf)," called %s",un); 98. if(dn) 99. Sprintf(eos(buf)," (%s)",dn); 100. return(buf); 101. default: 102. if(nn) { 103. Strcpy(buf, actualn); 104. if(otyp >= TURQUOISE && otyp <= JADE) 105. Strcat(buf, " stone"); 106. if(un) 107. Sprintf(eos(buf), " called %s", un); 108. if(dn) 109. Sprintf(eos(buf), " (%s)", dn); 110. } else { 111. Strcpy(buf, dn ? dn : actualn); 112. if(ocl->oc_class == GEM_CLASS) { 113. if (otyp == LOADSTONE || otyp == LUCKSTONE) 114. Strcat(buf, " stone"); 115. else 116. Strcat(buf, " gem"); 117. } 118. if(un) 119. Sprintf(eos(buf), " called %s", un); 120. } 121. return(buf); 122. } 123. /* here for ring/scroll/potion/wand */ 124. if(nn) 125. Sprintf(eos(buf), " of %s", actualn); 126. if(un) 127. Sprintf(eos(buf), " called %s", un); 128. if(dn) 129. Sprintf(eos(buf), " (%s)", dn); 130. return(buf); 131. } 132. 133. boolean 134. obj_is_pname(obj) 135. register struct obj *obj; 136. { 137. return (obj->dknown && obj->known && obj->onamelth && obj->oartifact && 138. !objects[obj->otyp].oc_unique); 139. } 140. 141. /* Give the name of an object seen at a distance. Unlike xname/doname, 142. * we don't want to set dknown if it's not set already. The kludge used is 143. * to temporarily set Blind so that xname() skips the dknown setting. This 144. * assumes that we don't want to do this too often; if this function becomes 145. * frequently used, it'd probably be better to pass a parameter to xname() 146. * or doname() instead. 147. */ 148. char * 149. distant_name(obj, func) 150. register struct obj *obj; 151. char *FDECL((*func), (OBJ_P)); 152. { 153. char *str; 154. 155. long save_Blinded = Blinded; 156. Blinded = 1; 157. str = (*func)(obj); 158. Blinded = save_Blinded; 159. return str; 160. } 161. 162. #endif /* OVLB */ 163. #ifdef OVL1 164. 165. char * 166. xname(obj) 167. register struct obj *obj; 168. { 169. #ifdef LINT /* lint may handle static decl poorly -- static char bufr[]; */ 170. char bufr[BUFSZ]; 171. #else 172. static char bufr[BUFSZ]; 173. #endif 174. register char *buf = &(bufr[PREFIX]); /* leave room for "17 -3 " */ 175. register int typ = obj->otyp; 176. register int nn = objects[typ].oc_name_known; 177. register const char *actualn = OBJ_NAME(objects[typ]); 178. register const char *dn = OBJ_DESCR(objects[typ]); 179. register const char *un = objects[typ].oc_uname; 180. 181. if (pl_character[0] == 'S' && Japanese_item_name(typ)) 182. actualn = Japanese_item_name(typ); 183. 184. buf[0] = '\0'; 185. if (!Blind) obj->dknown=1; 186. if (obj_is_pname(obj)) 187. goto nameit; 188. switch (obj->oclass) { 189. case AMULET_CLASS: 190. if (!obj->dknown) 191. Strcpy(buf, "amulet"); 192. else if (typ == FAKE_AMULET_OF_YENDOR) 193. /* each must be identified individually */ 194. Strcpy(buf, obj->known ? actualn : dn); 195. else if (nn) /* should be true for the Amulet of Yendor */ 196. Strcpy(buf, actualn); 197. else if (un) 198. Sprintf(buf,"amulet called %s", un); 199. else 200. Sprintf(buf,"%s amulet", dn); 201. break; 202. case WEAPON_CLASS: 203. if (typ <= SHURIKEN && obj->opoisoned) 204. Strcpy(buf, "poisoned "); 205. case VENOM_CLASS: 206. case TOOL_CLASS: 207. if(un) { 208. /* un must come first here. If it does not, they could 209. * tell objects apart by seeing which ones refuse to 210. * accept names. 211. */ 212. Sprintf(buf, "%s called %s", 213. nn ? actualn : dn, un); 214. } else if(nn) 215. Strcat(buf, actualn); 216. else 217. Strcat(buf, dn); 218. /* If we use an() here we'd have to remember never to use */ 219. /* it whenever calling doname() or xname(). */ 220. if (typ == FIGURINE) 221. Sprintf(eos(buf), " of a%s %s", 222. index(vowels,*(mons[obj->corpsenm].mname)) ? "n" : "", 223. mons[obj->corpsenm].mname); 224. break; 225. case ARMOR_CLASS: 226. /* depends on order of the dragon scales objects */ 227. if (typ >= GRAY_DRAGON_SCALES && typ <= YELLOW_DRAGON_SCALES) { 228. Sprintf(buf, "set of %s", OBJ_NAME(objects[typ])); 229. break; 230. } 231. if(is_boots(obj) || is_gloves(obj)) Strcpy(buf,"pair of "); 232. 233. if(nn) Strcat(buf, actualn); 234. else if(un) { 235. if(is_boots(obj)) 236. Strcat(buf,"boots"); 237. else if(is_gloves(obj)) 238. Strcat(buf,"gloves"); 239. else if(is_cloak(obj)) 240. Strcpy(buf,"cloak"); 241. else if(is_helmet(obj)) 242. Strcpy(buf,"helmet"); 243. else if(is_shield(obj)) 244. Strcpy(buf,"shield"); 245. else 246. Strcpy(buf,"armor"); 247. Strcat(buf, " called "); 248. Strcat(buf, un); 249. } else Strcat(buf, dn); 250. break; 251. case FOOD_CLASS: 252. #ifdef TUTTI_FRUTTI 253. if (typ == SLIME_MOLD) { 254. register struct fruit *f; 255. 256. for(f=ffruit; f; f = f->nextf) { 257. if(f->fid == obj->spe) { 258. Strcpy(buf, f->fname); 259. break; 260. } 261. } 262. if (!f) impossible("Bad fruit #%d?", obj->spe); 263. break; 264. } 265. #endif 266. Strcpy(buf, actualn); 267. if (typ == TIN && obj->known) { 268. if(obj->spe > 0) 269. Strcat(buf, " of spinach"); 270. else if (obj->corpsenm < 0) 271. Strcpy(buf, "empty tin"); 272. else if (is_meaty(&mons[obj->corpsenm])) 273. Sprintf(eos(buf), " of %s meat", mons[obj->corpsenm].mname); 274. else 275. Sprintf(eos(buf), " of %s", mons[obj->corpsenm].mname); 276. } 277. break; 278. case GOLD_CLASS: 279. case CHAIN_CLASS: 280. Strcpy(buf, actualn); 281. break; 282. case ROCK_CLASS: 283. if (typ == STATUE) 284. Sprintf(buf, "%s of %s%s", actualn, 285. type_is_pname(&mons[obj->corpsenm]) ? "" : 286. (index(vowels,*(mons[obj->corpsenm].mname)) ? 287. "an " : "a "), 288. mons[obj->corpsenm].mname); 289. else Strcpy(buf, actualn); 290. break; 291. case BALL_CLASS: 292. Sprintf(buf, "%sheavy iron ball", 293. (obj->owt > objects[typ].oc_weight) ? "very " : ""); 294. break; 295. case POTION_CLASS: 296. if(nn || un || !obj->dknown) { 297. Strcpy(buf, "potion"); 298. if(!obj->dknown) break; 299. if(nn) { 300. Strcat(buf, " of "); 301. if (typ == POT_WATER && 302. objects[POT_WATER].oc_name_known && 303. (obj->bknown || pl_character[0] == 'P') && 304. (obj->blessed || obj->cursed)) { 305. Strcat(buf, obj->blessed ? "holy " : "unholy "); 306. } 307. Strcat(buf, actualn); 308. } else { 309. Strcat(buf, " called "); 310. Strcat(buf, un); 311. } 312. } else { 313. Strcpy(buf, dn); 314. Strcat(buf, " potion"); 315. } 316. break; 317. case SCROLL_CLASS: 318. Strcpy(buf, "scroll"); 319. if(!obj->dknown) break; 320. if(nn) { 321. Strcat(buf, " of "); 322. Strcat(buf, actualn); 323. } else if(un) { 324. Strcat(buf, " called "); 325. Strcat(buf, un); 326. } else if (objects[typ].oc_magic) { 327. Strcat(buf, " labeled "); 328. Strcat(buf, dn); 329. } else { 330. Strcpy(buf, dn); 331. Strcat(buf, " scroll"); 332. } 333. break; 334. case WAND_CLASS: 335. if(!obj->dknown) 336. Strcpy(buf, "wand"); 337. else if(nn) 338. Sprintf(buf, "wand of %s", actualn); 339. else if(un) 340. Sprintf(buf, "wand called %s", un); 341. else 342. Sprintf(buf, "%s wand", dn); 343. break; 344. case SPBOOK_CLASS: 345. if (!obj->dknown) { 346. Strcpy(buf, "spellbook"); 347. } else if (nn) { 348. if (typ != SPE_BOOK_OF_THE_DEAD) 349. Strcpy(buf, "spellbook of "); 350. Strcat(buf, actualn); 351. } else if (un) { 352. Sprintf(buf, "spellbook called %s", un); 353. } else 354. Sprintf(buf, "%s spellbook", dn); 355. break; 356. case RING_CLASS: 357. if(!obj->dknown) 358. Strcpy(buf, "ring"); 359. else if(nn) 360. Sprintf(buf, "ring of %s", actualn); 361. else if(un) 362. Sprintf(buf, "ring called %s", un); 363. else 364. Sprintf(buf, "%s ring", dn); 365. break; 366. case GEM_CLASS: 367. if(!obj->dknown) { 368. if (typ == ROCK || typ == LOADSTONE || typ == LUCKSTONE) 369. Strcpy(buf, "stone"); 370. else 371. Strcpy(buf, "gem"); 372. break; 373. } 374. if(!nn) { 375. const char *rock = 376. (typ==LOADSTONE || typ==LUCKSTONE) ? "stone" : "gem"; 377. if(un) Sprintf(buf,"%s called %s", rock, un); 378. else Sprintf(buf, "%s %s", dn, rock); 379. break; 380. } 381. Strcpy(buf, actualn); 382. if(typ >= TURQUOISE && typ <= JADE) 383. Strcat(buf, " stone"); 384. break; 385. default: 386. Sprintf(buf,"glorkum %d %d %d", obj->oclass, typ, obj->spe); 387. } 388. if(obj->quan != 1L) Strcpy(buf, makeplural(buf)); 389. 390. if(obj->onamelth && 391. (!obj->oartifact || !objects[obj->otyp].oc_unique)) { 392. Strcat(buf, " named "); 393. nameit: 394. Strcat(buf, ONAME(obj)); 395. } 396. return(buf); 397. } 398. 399. #endif /* OVL1 */ 400. #ifdef OVL0 401. 402. char * 403. doname(obj) 404. register struct obj *obj; 405. { 406. boolean ispoisoned = FALSE; 407. char prefix[PREFIX]; 408. char tmpbuf[PREFIX+1]; 409. /* when we have to add something at the start of prefix instead of the 410. * end (Strcat is used on the end) 411. */ 412. register char *bp = xname(obj); 413. /* When using xname, we want "poisoned arrow", and when using 414. * doname, we want "poisoned +0 arrow". This kludge is about the only 415. * way to do it, at least until someone overhauls xname() and doname(), 416. * combining both into one function taking a parameter. 417. */ 418. if (!strncmp(bp, "poisoned ", 9)) { 419. bp += 9; 420. ispoisoned = TRUE; 421. } 422. 423. if(obj->quan != 1L) 424. Sprintf(prefix, "%ld ", obj->quan); 425. else if(obj_is_pname(obj)) { 426. if (!strncmpi(bp, "the ", 4)) 427. bp += 4; 428. Strcpy(prefix, "the "); 429. } else 430. Strcpy(prefix, "a "); 431. if((obj->bknown || pl_character[0] == 'P') && 432. (obj->otyp != POT_WATER || !objects[POT_WATER].oc_name_known 433. || (!obj->cursed && !obj->blessed))) { 434. /* allow 'blessed clear potion' if we don't know it's holy water; 435. * always allow "uncursed potion of water" 436. */ 437. if(obj->cursed) 438. Strcat(prefix, "cursed "); 439. else if(obj->blessed) 440. Strcat(prefix, "blessed "); 441. else if (((obj->oclass != ARMOR_CLASS 442. && obj->oclass != WAND_CLASS 443. && obj->oclass != WEAPON_CLASS 444. && ((obj->oclass != TOOL_CLASS && 445. obj->oclass != RING_CLASS) || 446. !objects[obj->otyp].oc_charged)) 447. || !obj->known) 448. /* For items with charges or +/-, knowing the +/- means that 449. * the item has been totally identified, and therefore there 450. * is no doubt as to the object being uncursed if it's 451. * not described as "blessed" or "cursed". 452. * 453. * If the +/- isn't known, "uncursed" must be printed to 454. * avoid ambiguity between an item whose curse status is 455. * unknown, and an item known to be uncursed. 456. */ 457. #ifdef MAIL 458. && obj->otyp != SCR_MAIL 459. #endif 460. && obj->otyp != FAKE_AMULET_OF_YENDOR 461. && obj->otyp != AMULET_OF_YENDOR 462. && pl_character[0] != 'P') 463. Strcat(prefix, "uncursed "); 464. } 465. if(obj->greased) Strcat(prefix, "greased "); 466. switch(obj->oclass) { 467. case AMULET_CLASS: 468. if(obj->otyp == FAKE_AMULET_OF_YENDOR || 469. obj->otyp == AMULET_OF_YENDOR) 470. if(strncmp(bp, "cheap ", 6)) { 471. Strcpy(tmpbuf, "the "); 472. Strcat(tmpbuf, prefix+2); /* skip the "a " */ 473. Strcpy(prefix, tmpbuf); 474. } 475. if(obj->owornmask & W_AMUL) 476. Strcat(bp, " (being worn)"); 477. break; 478. case WEAPON_CLASS: 479. if(ispoisoned) 480. Strcat(prefix, "poisoned "); 481. plus: 482. if (obj->oeroded) { 483. switch (obj->oeroded) { 484. case 2: Strcat(prefix, "very "); break; 485. case 3: Strcat(prefix, "thoroughly "); break; 486. } 487. Strcat(prefix, 488. is_rustprone(obj) ? "rusty " : 489. is_corrodeable(obj) ? "corroded " : 490. is_flammable(obj) ? "burnt " : ""); 491. } else if (obj->rknown && obj->oerodeproof) 492. Strcat(prefix, 493. is_rustprone(obj) ? "rustproof " : 494. is_corrodeable(obj) ? "corrodeproof " : /* "stainless"? */ 495. is_flammable(obj) ? "fireproof " : ""); 496. if(obj->known) { 497. Strcat(prefix, sitoa(obj->spe)); 498. Strcat(prefix, " "); 499. } 500. break; 501. case ARMOR_CLASS: 502. if(obj->owornmask & W_ARMOR) 503. Strcat(bp, 504. #ifdef POLYSELF 505. (obj == uskin) ? " (embedded in your skin)" : 506. #endif 507. " (being worn)"); 508. goto plus; 509. case TOOL_CLASS: /* temp. hack by GAN 11/18/86 */ 510. if(obj->owornmask & W_TOOL) { /* blindfold */ 511. Strcat(bp, " (being worn)"); 512. break; 513. } 514. #ifdef WALKIES 515. if(obj->otyp == LEASH && obj->leashmon != 0) { 516. Strcat(bp, " (in use)"); 517. break; 518. } 519. #endif 520. if(obj->otyp == PICK_AXE || obj->otyp == UNICORN_HORN) 521. goto plus; 522. if (Is_candle(obj) && 523. obj->age < 20L * (long)objects[obj->otyp].oc_cost) 524. Sprintf(eos(prefix), "partly used "); 525. if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || 526. obj->otyp == BRASS_LANTERN || 527. Is_candle(obj) || obj->otyp == CANDELABRUM_OF_INVOCATION) { 528. if(obj->lamplit) 529. Sprintf(eos(bp), " (lit)"); 530. break; 531. } 532. if(!objects[obj->otyp].oc_charged) break; 533. /* if special tool, fall through to show charges */ 534. case WAND_CLASS: 535. if(obj->known) 536. Sprintf(eos(bp), " (%d)", obj->spe); 537. break; 538. case RING_CLASS: 539. if(obj->owornmask & W_RINGR) Strcat(bp, " (on right "); 540. if(obj->owornmask & W_RINGL) Strcat(bp, " (on left "); 541. if(obj->owornmask & W_RING) { 542. Strcat(bp, body_part(HAND)); 543. Strcat(bp, ")"); 544. } 545. if(obj->known && objects[obj->otyp].oc_charged) { 546. Strcat(prefix, sitoa(obj->spe)); 547. Strcat(prefix, " "); 548. } 549. break; 550. case FOOD_CLASS: 551. if (obj->oeaten) 552. Strcat(prefix, "partly eaten "); 553. if (obj->otyp == CORPSE) { 554. if (type_is_pname(&mons[obj->corpsenm])) { 555. Sprintf(prefix, "%s ", 556. s_suffix(mons[obj->corpsenm].mname)); 557. if (obj->oeaten) Strcat(prefix, "partly eaten "); 558. } else { 559. Strcat(prefix, mons[obj->corpsenm].mname); 560. Strcat(prefix, " "); 561. } 562. } else if (obj->otyp == EGG && obj->known) { 563. if (obj->corpsenm >= 0) { 564. Strcat(prefix, mons[obj->corpsenm].mname); 565. Strcat(prefix, " "); 566. #ifdef POLYSELF 567. if (obj->spe) 568. Strcat(bp, " (laid by you)"); 569. #endif 570. } 571. } 572. break; 573. case BALL_CLASS: 574. if(obj->owornmask & W_BALL) 575. Strcat(bp, " (chained to you)"); 576. break; 577. } 578. 579. if((obj->owornmask & W_WEP) && !mrg_to_wielded) { 580. if (obj->quan != 1L) 581. Strcat(bp, " (wielded)"); 582. else { 583. Strcat(bp, " (weapon in "); 584. Strcat(bp, body_part(HAND)); 585. Strcat(bp, ")"); 586. } 587. } 588. if(obj->unpaid) 589. Strcat(bp, " (unpaid)"); 590. if (!strncmp(prefix, "a ", 2) && 591. index(vowels, *(prefix+2) ? *(prefix+2) : *bp) 592. && (*(prefix+2) || (strncmp(bp, "uranium", 7) 593. && strncmp(bp, "unicorn", 7)))) { 594. Strcpy(tmpbuf, prefix); 595. Strcpy(prefix, "an "); 596. Strcpy(prefix+3, tmpbuf+2); 597. } 598. bp = strprepend(bp, prefix); 599. return(bp); 600. } 601. 602. #endif /* OVL0 */ 603. #ifdef OVLB 604. 605. /* 606. * Used if only one of a collection of objects is named (e.g. in eat.c). 607. */ 608. 609. char * 610. singular(otmp, func) 611. register struct obj *otmp; 612. char *FDECL((*func), (OBJ_P)); 613. { 614. long savequan; 615. char *nam; 616. 617. /* Note: using xname for corpses will not give the monster type */ 618. if (otmp->otyp == CORPSE && func == xname) { 619. static char NEARDATA buf[31]; 620. 621. Sprintf(buf, "%s corpse", mons[otmp->corpsenm].mname); 622. return buf; 623. } 624. savequan = otmp->quan; 625. otmp->quan = 1L; 626. nam = (*func)(otmp); 627. otmp->quan = savequan; 628. return nam; 629. } 630. 631. char * 632. an(str) 633. register const char *str; 634. { 635. static char NEARDATA buf[BUFSZ]; 636. 637. buf[0] = '\0'; 638. 639. if (strncmpi(str, "the ", 4) && 640. strcmp(str, "molten lava") && 641. strcmp(str, "ice")) 642. if (index(vowels, *str) && 643. strncmp(str, "useful", 6) && 644. strncmp(str, "unicorn", 7) && 645. strncmp(str, "uranium", 7)) 646. Strcpy(buf, "an "); 647. else 648. Strcpy(buf, "a "); 649. 650. Strcat(buf, str); 651. return buf; 652. } 653. 654. char * 655. An(str) 656. const char *str; 657. { 658. register char *tmp = an(str); 659. *tmp = highc(*tmp); 660. return tmp; 661. } 662. 663. /* 664. * Prepend "the" if necessary; assumes str is a subject derived from xname. 665. * Use type_is_pname() for monster names, not the(). the() is idempotent. 666. */ 667. char * 668. the(str) 669. const char *str; 670. { 671. static char NEARDATA buf[BUFSZ]; 672. 673. if (!strncmpi(str, "the ", 4)) { 674. buf[0] = lowc(*str); 675. Strcpy(&buf[1], str+1); 676. return buf; 677. } else if (*str < 'A' || *str > 'Z') { 678. /* not a proper name, needs an article */ 679. Strcpy(buf, "the "); 680. } else { 681. /* Probably a proper name, might not need an article */ 682. register char *tmp; 683. 684. buf[0] = 0; 685. 686. /* some objects have capitalized adjectives in their names */ 687. if(((tmp = rindex(str, ' ')) || (tmp = rindex(str, '-'))) && 688. (tmp[1] < 'A' || tmp[1] > 'Z')) 689. Strcpy(buf, "the "); 690. else if (tmp && (tmp = index(str, ' ')) != NULL) { 691. /* it needs an article if the name contains "of" */ 692. while(tmp && strncmp(++tmp, "of ", 3)) 693. tmp = index(tmp, ' '); 694. if (tmp) /* found an "of" */ 695. Strcpy(buf, "the "); 696. } 697. } 698. Strcat(buf, str); 699. 700. return buf; 701. } 702. 703. char * 704. The(str) 705. const char *str; 706. { 707. register char *tmp = the(str); 708. *tmp = highc(*tmp); 709. return tmp; 710. } 711. 712. char * 713. aobjnam(otmp,verb) 714. register struct obj *otmp; 715. register const char *verb; 716. { 717. register char *bp = xname(otmp); 718. char prefix[PREFIX]; 719. 720. if(otmp->quan != 1L) { 721. Sprintf(prefix, "%ld ", otmp->quan); 722. bp = strprepend(bp, prefix); 723. } 724. 725. if(verb) { 726. /* verb is given in plural (without trailing s) */ 727. Strcat(bp, " "); 728. if(otmp->quan != 1L) 729. Strcat(bp, verb); 730. else if(!strcmp(verb, "are")) 731. Strcat(bp, "is"); 732. else { 733. Strcat(bp, verb); 734. Strcat(bp, "s"); 735. } 736. } 737. return(bp); 738. } 739. 740. char * 741. Doname2(obj) 742. register struct obj *obj; 743. { 744. register char *s = doname(obj); 745. 746. if('a' <= *s && *s <= 'z') *s -= ('a' - 'A'); 747. return(s); 748. } 749. 750. static const char *wrp[] = { 751. "wand", "ring", "potion", "scroll", "gem", "amulet", 752. "spellbook", "spell book", 753. /* for non-specific wishes */ 754. "weapon", "armor", "tool", "food", "comestible", 755. }; 756. static const char wrpsym[] = { 757. WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, GEM_CLASS, 758. AMULET_CLASS, SPBOOK_CLASS, SPBOOK_CLASS, 759. WEAPON_CLASS, ARMOR_CLASS, TOOL_CLASS, FOOD_CLASS, FOOD_CLASS 760. }; 761. 762. #endif /* OVLB */ 763. #ifdef OVL0 764. 765. /* Plural routine; chiefly used for user-defined fruits. We have to try to 766. * account for everything reasonable the player has; something unreasonable 767. * can still break the code. However, it's still a lot more accurate than 768. * "just add an s at the end", which Rogue uses... 769. * 770. * Also used for plural monster names ("Wiped out all homunculi.") 771. * and body parts. 772. * 773. * Also misused by muse.c to convert 1st person present verbs to 2nd person. 774. */ 775. char * 776. makeplural(oldstr) 777. const char *oldstr; 778. { 779. /* Note: cannot use strcmpi here -- it'd give MATZot, CAVEMeN,... */ 780. register char *spot; 781. static char NEARDATA str[BUFSZ]; 782. const char *excess; 783. int len; 784. 785. while (*oldstr==' ') oldstr++; 786. if (!oldstr || !*oldstr) { 787. impossible("plural of null?"); 788. Strcpy(str, "s"); 789. return str; 790. } 791. Strcpy(str, oldstr); 792. 793. /* Search for common compounds, ex. lump of royal jelly */ 794. for(excess=(char *)0, spot=str; *spot; spot++) { 795. if (!strncmp(spot, " of ", 4) 796. || !strncmp(spot, " labeled ", 9) 797. || !strncmp(spot, " called ", 8) 798. || !strncmp(spot, " named ", 7) 799. || !strcmp(spot, " above") /* lurkers above */ 800. || !strncmp(spot, " versus ", 8) 801. #ifdef TUTTI_FRUTTI 802. || !strncmp(spot, " from ", 6) 803. || !strncmp(spot, " in ", 4) 804. || !strncmp(spot, " on ", 4) 805. || !strncmp(spot, " a la ", 6) 806. || !strncmp(spot, " with", 5) /* " with "? */ 807. || !strncmp(spot, " de ", 4) 808. || !strncmp(spot, " d'", 3) 809. || !strncmp(spot, " du ", 4) 810. #endif 811. ) { 812. excess = oldstr + (int) (spot - str); 813. *spot = 0; 814. break; 815. } 816. } 817. spot--; 818. while (*spot==' ') spot--; /* Strip blanks from end */ 819. *(spot+1) = 0; 820. /* Now spot is the last character of the string */ 821. 822. len = strlen(str); 823. #ifdef TUTTI_FRUTTI 824. /* Single letters */ 825. if (len==1 || !letter(*spot)) { 826. Strcpy(spot+1, "'s"); 827. goto bottom; 828. } 829. #endif 830. 831. /* man/men ("Wiped out all cavemen.") */ 832. if (len >= 3 && !strcmp(spot-2, "man") && 833. (len<6 || strcmp(spot-5, "shaman")) && 834. (len<5 || strcmp(spot-4, "human"))) { 835. *(spot-1) = 'e'; 836. goto bottom; 837. } 838. 839. /* tooth/teeth */ 840. if (len >= 5 && !strcmp(spot-4, "tooth")) { 841. Strcpy(spot-3, "eeth"); 842. goto bottom; 843. } 844. 845. /* knife/knives, etc... */ 846. if (!strcmp(spot-1, "fe")) 847. *(spot-1) = 'v'; 848. else if (*spot == 'f') 849. if (index("lr", *(spot-1)) || index(vowels, *(spot-1))) 850. *spot = 'v'; 851. else if (len >= 5 && !strncmp(spot-4, "staf", 4)) 852. Strcpy(spot-1, "ve"); 853. 854. /* foot/feet (body part) */ 855. if (len >= 4 && !strcmp(spot-3, "foot")) { 856. Strcpy(spot-2, "eet"); 857. goto bottom; 858. } 859. 860. /* ium/ia (mycelia, baluchitheria) */ 861. if (len >= 3 && !strcmp(spot-2, "ium")) { 862. *(spot--) = (char)0; 863. *spot = 'a'; 864. goto bottom; 865. } 866. 867. /* algae, larvae, hyphae (another fungus part) */ 868. #ifdef TUTTI_FRUTTI 869. if ((len >= 4 && !strcmp(spot-3, "alga")) || 870. (len >= 5 && 871. (!strcmp(spot-4, "hypha") || !strcmp(spot-4, "larva")))) 872. #else 873. if (len >= 5 && (!strcmp(spot-4, "hypha"))) 874. #endif 875. { 876. Strcpy(spot, "ae"); 877. goto bottom; 878. } 879. 880. /* fungus/fungi, homunculus/homunculi, but wumpuses */ 881. if (!strcmp(spot-1, "us") && (len < 6 || strcmp(spot-5, "wumpus"))) { 882. *(spot--) = (char)0; 883. *spot = 'i'; 884. goto bottom; 885. } 886. 887. /* vortex/vortices */ 888. if (len >= 6 && !strcmp(spot-3, "rtex")) { 889. Strcpy(spot-1, "ices"); 890. goto bottom; 891. } 892. 893. /* djinni/djinn (note: also efreeti/efreet) */ 894. if (len >= 6 && !strcmp(spot-5, "djinni")) { 895. *spot = (char)0; 896. goto bottom; 897. } 898. 899. /* mumak/mumakil */ 900. if (len >= 5 && !strcmp(spot-4, "mumak")) { 901. Strcpy(spot, "il"); 902. goto bottom; 903. } 904. 905. /* same singular and plural */ 906. /* note: also swine, trout, grouse */ 907. if ((len >= 7 && !strcmp(spot-6, "samurai")) || 908. #ifdef TUTTI_FRUTTI 909. (len >= 5 && 910. (!strcmp(spot-4, "manes") || !strcmp(spot-4, "sheep"))) || 911. (len >= 4 && 912. (!strcmp(spot-3, "fish") || !strcmp(spot-3, "tuna") || 913. !strcmp(spot-3, "deer"))) 914. #else 915. (len >= 5 && !strcmp(spot-4, "manes")) 916. #endif 917. ) goto bottom; 918. 919. /* sis/ses (nemesis) */ 920. if (len >= 3 && !strcmp(spot-2, "sis")) { 921. *(spot-1) = 'e'; 922. goto bottom; 923. } 924. 925. #ifdef TUTTI_FRUTTI 926. /* mouse/mice,louse/lice (not a monster, but possible in food names) */ 927. if (len >= 5 && !strcmp(spot-3, "ouse") && index("MmLl", *(spot-4))) { 928. Strcpy(spot-3, "ice"); 929. goto bottom; 930. } 931. 932. /* matzoh/matzot, possible food name */ 933. if (len >= 6 && (!strcmp(spot-5, "matzoh") 934. || !strcmp(spot-5, "matzah"))) { 935. Strcpy(spot-1, "ot"); 936. goto bottom; 937. } 938. if (len >= 5 && (!strcmp(spot-4, "matzo") 939. || !strcmp(spot-5, "matza"))) { 940. Strcpy(spot, "ot"); 941. goto bottom; 942. } 943. 944. /* child/children (for wise guys who give their food funny names) */ 945. if (len >= 5 && !strcmp(spot-4, "child")) { 946. Strcpy(spot, "dren"); 947. goto bottom; 948. } 949. 950. /* note: -eau/-eaux (gateau, bordeau...) */ 951. /* note: ox/oxen, VAX/VAXen, goose/geese */ 952. #endif 953. 954. /* Ends in z, x, s, ch, sh; add an "es" */ 955. if (index("zxsv", *spot) 956. || (len >= 2 && *spot=='h' && index("cs", *(spot-1))) 957. #ifdef TUTTI_FRUTTI 958. /* Kludge to get "tomatoes" and "potatoes" right */ 959. || (len >= 4 && !strcmp(spot-2, "ato")) 960. #endif 961. ) { 962. Strcpy(spot+1, "es"); 963. goto bottom; 964. } 965. 966. /* Ends in y preceded by consonant (note: also "qu") change to "ies" */ 967. if (*spot == 'y' && 968. (!index(vowels, *(spot-1)))) { 969. Strcpy(spot, "ies"); 970. goto bottom; 971. } 972. 973. /* Japanese words: plurals are the same as singlar */ 974. if (len == 2 && !strcmp(str, "ya")) 975. goto bottom; 976. 977. /* Default: append an 's' */ 978. Strcpy(spot+1, "s"); 979. 980. bottom: if (excess) Strcpy(eos(str), excess); 981. return str; 982. } 983. 984. #endif /* OVL0 */ 985. 986. struct o_range { 987. const char *name, osym; 988. int f_o_range, l_o_range; 989. }; 990. 991. #ifndef OVLB 992. 993. STATIC_DCL const struct o_range o_ranges[]; 994. 995. #else /* OVLB */ 996. 997. /* wishable subranges of objects */ 998. STATIC_OVL const struct o_range NEARDATA o_ranges[] = { 999. { "bag", TOOL_CLASS, SACK, BAG_OF_TRICKS }, 1000. { "candle", TOOL_CLASS, TALLOW_CANDLE, WAX_CANDLE }, 1001. { "horn", TOOL_CLASS, TOOLED_HORN, HORN_OF_PLENTY }, 1002. { "gloves", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY }, 1003. { "gauntlets", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY }, 1004. { "boots", ARMOR_CLASS, LOW_BOOTS, LEVITATION_BOOTS }, 1005. { "shoes", ARMOR_CLASS, LOW_BOOTS, IRON_SHOES }, 1006. { "cloak", ARMOR_CLASS, MUMMY_WRAPPING, CLOAK_OF_DISPLACEMENT }, 1007. { "shield", ARMOR_CLASS, SMALL_SHIELD, SHIELD_OF_REFLECTION }, 1008. { "helm", ARMOR_CLASS, ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY }, 1009. { "dragon scales", 1010. ARMOR_CLASS, GRAY_DRAGON_SCALES, YELLOW_DRAGON_SCALES }, 1011. { "dragon scale mail", 1012. ARMOR_CLASS, GRAY_DRAGON_SCALE_MAIL, YELLOW_DRAGON_SCALE_MAIL }, 1013. { "sword", WEAPON_CLASS, SHORT_SWORD, KATANA }, 1014. #ifdef WIZARD 1015. { "venom", VENOM_CLASS, BLINDING_VENOM, ACID_VENOM }, 1016. #endif 1017. }; 1018. 1019. #define BSTRCMP(base,ptr,string) ((ptr) < base || strcmp((ptr),string)) 1020. #define BSTRCMPI(base,ptr,string) ((ptr) < base || strcmpi((ptr),string)) 1021. #define BSTRNCMP(base,ptr,string,num) ((ptr) 1022. 1023. /* 1024. * Singularize a string the user typed in; this helps reduce the complexity 1025. * of readobjnam, and is also used in pager.c to singularize the string 1026. * for which help is sought. 1027. */ 1028. 1029. char * 1030. makesingular(oldstr) 1031. const char *oldstr; 1032. { 1033. register char *p, *bp; 1034. static char NEARDATA str[BUFSZ]; 1035. 1036. if (!oldstr || !*oldstr) { 1037. impossible("singular of null?"); 1038. str[0] = 0; return str; 1039. } 1040. Strcpy(str, oldstr); 1041. bp = str; 1042. 1043. while (*bp == ' ') bp++; 1044. /* find "cloves of garlic", "worthless pieces of blue glass" */ 1045. if ((p = strstri(bp, "s of ")) != 0) { 1046. /* but don't singularize "gauntlets" */ 1047. if (BSTRNCMP(bp, p-8, "gauntlet", 8)) 1048. while ((*p = *(p+1)) != 0) p++; 1049. return bp; 1050. } 1051. 1052. /* remove -s or -es (boxes) or -ies (rubies) */ 1053. p = eos(bp); 1054. if (p >= bp+1 && p[-1] == 's') { 1055. if (p >= bp+2 && p[-2] == 'e') { 1056. if (p >= bp+3 && p[-3] == 'i') { 1057. if(!BSTRCMP(bp, p-7, "cookies") || 1058. !BSTRCMP(bp, p-4, "pies")) 1059. goto mins; 1060. Strcpy(p-3, "y"); 1061. return bp; 1062. } 1063. 1064. /* note: cloves / knives from clove / knife */ 1065. if(!BSTRCMP(bp, p-6, "knives")) { 1066. Strcpy(p-3, "fe"); 1067. return bp; 1068. } 1069. 1070. if(!BSTRCMP(bp, p-6, "staves")) { 1071. Strcpy(p-3, "ff"); 1072. return bp; 1073. } 1074. 1075. /* note: nurses, axes but boxes */ 1076. if(!BSTRCMP(bp, p-5, "boxes")) { 1077. p[-2] = 0; 1078. return bp; 1079. } 1080. if (!BSTRCMP(bp, p-6, "gloves") || 1081. !BSTRCMP(bp, p-5, "shoes") || 1082. !BSTRCMP(bp, p-6, "scales")) 1083. return bp; 1084. } else if (!BSTRCMP(bp, p-5, "boots") || 1085. !BSTRCMP(bp, p-6, "tricks") || 1086. !BSTRCMP(bp, p-9, "paralysis") || 1087. !BSTRCMP(bp, p-5, "glass") || 1088. !BSTRCMP(bp, p-4, "ness") || 1089. !BSTRCMP(bp, p-14, "shape changers") || 1090. !BSTRCMP(bp, p-15, "detect monsters") || 1091. !BSTRCMPI(bp, p-11, "Aesculapius")) /* staff */ 1092. return bp; 1093. mins: 1094. p[-1] = 0; 1095. } else { 1096. if(!BSTRCMP(bp, p-5, "teeth")) { 1097. Strcpy(p-5, "tooth"); 1098. return bp; 1099. } 1100. /* here we cannot find the plural suffix */ 1101. } 1102. return bp; 1103. } 1104. 1105. /* alternate spellings: extra space, space instead of hyphen, etc */ 1106. struct alt_spellings { 1107. const char *sp; 1108. int ob; 1109. } spellings[] = { 1110. { "two handed sword", TWO_HANDED_SWORD }, 1111. { "battle axe", BATTLE_AXE }, 1112. { "lockpick", LOCK_PICK }, 1113. { "pick axe", PICK_AXE }, 1114. { "luck stone", LUCKSTONE }, 1115. { "load stone", LOADSTONE }, 1116. { "broad sword", BROADSWORD }, 1117. { "elven broad sword", ELVEN_BROADSWORD }, 1118. { "longsword", LONG_SWORD }, 1119. { "shortsword", SHORT_SWORD }, 1120. { "elven shortsword", ELVEN_SHORT_SWORD }, 1121. { "dwarvish shortsword", DWARVISH_SHORT_SWORD }, 1122. { "orcish shortsword", ORCISH_SHORT_SWORD }, 1123. { "warhammer", WAR_HAMMER }, 1124. { "grey dragon scale mail", GRAY_DRAGON_SCALE_MAIL }, 1125. { "grey dragon scales", GRAY_DRAGON_SCALES }, 1126. { "iron ball", HEAVY_IRON_BALL }, 1127. { "stone", ROCK }, 1128. { (const char *)0, 0 }, 1129. }; 1130. 1131. /* Return something wished for. If not an object, return &zeroobj; if an error 1132. * (no matching object), return (struct obj *)0. Giving readobjnam() a null 1133. * pointer skips the error return and creates a random object instead. 1134. */ 1135. struct obj * 1136. readobjnam(bp) 1137. register char *bp; 1138. { 1139. register char *p; 1140. register int i; 1141. register struct obj *otmp; 1142. int cnt, spe, spesgn, typ, very; 1143. int blessed, uncursed, iscursed, ispoisoned; 1144. int eroded, erodeproof; 1145. int halfeaten, mntmp, contents; 1146. int islit, unlabeled; 1147. #ifdef TUTTI_FRUTTI 1148. struct fruit *f; 1149. int ftype = current_fruit; 1150. char fruitbuf[BUFSZ]; 1151. /* We want to check for fruits last so that, for example, someone 1152. * who names their fruit "katana" and wishes for a katana gets a real 1153. * one. But, we have to keep around the old buf since in the meantime 1154. * we have deleted "empty", "+6", etc... 1155. */ 1156. #endif 1157. char let; 1158. char *un, *dn, *actualn; 1159. const char *name=0; 1160. 1161. cnt = spe = spesgn = typ = very = blessed = uncursed = 1162. iscursed = ispoisoned = eroded = erodeproof = halfeaten = 1163. islit = unlabeled = 0; 1164. mntmp = -1; 1165. #define UNDEFINED 0 1166. #define EMPTY 1 1167. #define SPINACH 2 1168. contents = UNDEFINED; 1169. let = 0; 1170. actualn = dn = un = 0; 1171. 1172. /* first, remove extra whitespace they may have typed */ 1173. if (bp) { 1174. char c, *p2; 1175. boolean was_space = TRUE; 1176. 1177. for (p = p2 = bp; (c = *p) != '\0'; p++) { 1178. /* if (c == ' ') c = ' '; */ 1179. if (c != ' ' || !was_space) *p2++ = c; 1180. was_space = (c == ' '); 1181. } 1182. if (was_space && p2 > bp) p2--; 1183. *p2 = '\0'; 1184. } 1185. 1186. for(;;) { 1187. register int l; 1188. 1189. if (!bp || !*bp) goto any; 1190. if (!strncmpi(bp, "an ", l=3) || 1191. !strncmpi(bp, "a ", l=2)) { 1192. cnt = 1; 1193. } else if (!strncmpi(bp, "the ", l=4)) { 1194. ; /* just increment `bp' by `l' below */ 1195. } else if (!cnt && digit(*bp)) { 1196. cnt = atoi(bp); 1197. while(digit(*bp)) bp++; 1198. while(*bp == ' ') bp++; 1199. l = 0; 1200. } else if (!strncmpi(bp, "blessed ", l=8) || 1201. !strncmpi(bp, "holy ", l=5)) { 1202. blessed = 1; 1203. } else if (!strncmpi(bp, "cursed ", l=7) || 1204. !strncmpi(bp, "unholy ", l=7)) { 1205. iscursed = 1; 1206. } else if (!strncmpi(bp, "uncursed ", l=9)) { 1207. uncursed = 1; 1208. } else if (!strncmp(bp, "rustproof ", l=10) || 1209. !strncmp(bp, "erodeproof ", l=11) || 1210. !strncmp(bp, "corrodeproof ", l=13) || 1211. !strncmp(bp, "fireproof ", l=10)) { 1212. erodeproof = 1; 1213. } else if (!strncmpi(bp,"lit ", l=4) || 1214. !strncmpi(bp,"burning ", l=8)) { 1215. islit = 1; 1216. } else if (!strncmpi(bp,"unlit ", l=6) || 1217. !strncmpi(bp,"extinguished ", l=13)) { 1218. islit = 0; 1219. /* "unlabeled" and "blank" are synonymous */ 1220. } else if (!strncmpi(bp,"unlabeled ", l=10) || 1221. !strncmpi(bp,"unlabelled ", l=11) || 1222. !strncmpi(bp,"blank ", l=6)) { 1223. unlabeled = 1; 1224. } else if (!strncmpi(bp, "very ", l=5)) { 1225. very = 1; 1226. } else if (!strncmpi(bp, "thoroughly ", l=11)) { 1227. very = 2; 1228. } else if (!strncmp(bp, "rusty ", l=6) || 1229. !strncmp(bp, "rusted ", l=7) || 1230. !strncmp(bp, "eroded ", l=7) || 1231. !strncmp(bp, "corroded ", l=9) || 1232. !strncmp(bp, "burnt ", l=6) || 1233. !strncmp(bp, "burned ", l=7) || 1234. !strncmp(bp, "rotted ", l=7)) { 1235. eroded = 1 + very; very = 0; 1236. } else if (!strncmpi(bp, "partly eaten ", l=13)) { 1237. halfeaten = 1; 1238. } else break; 1239. bp += l; 1240. } 1241. if(!cnt) cnt = 1; /* %% what with "gems" etc. ? */ 1242. #ifdef TUTTI_FRUTTI 1243. Strcpy(fruitbuf, bp); 1244. #endif 1245. if(!strncmpi(bp, "empty ", 6)) { 1246. contents = EMPTY; 1247. bp += 6; 1248. } else if(!strncmpi(bp, "poisoned ",9)) { 1249. ispoisoned=1; 1250. bp += 9; 1251. #ifdef WIZARD 1252. } else if(wizard && !strncmpi(bp, "trapped ",8)) { 1253. ispoisoned=1; 1254. bp += 8; 1255. #endif 1256. } 1257. if (strlen(bp) > 1) { 1258. if (*bp == '+' || *bp == '-') { 1259. spesgn = (*bp++ == '+') ? 1 : -1; 1260. spe = atoi(bp); 1261. while(digit(*bp)) bp++; 1262. while(*bp == ' ') bp++; 1263. } else if ((p = rindex(bp, '(')) != 0) { 1264. if (p > bp && p[-1] == ' ') p[-1] = 0; 1265. else *p = 0; 1266. p++; 1267. if (!strcmpi(p, "lit)")) 1268. islit = 1; 1269. else { 1270. spe = atoi(p); 1271. while(digit(*p)) p++; 1272. if (*p != ')') spe = 0; 1273. else { 1274. spesgn = 1; 1275. p++; 1276. if (*p) Strcat(bp, p); 1277. } 1278. } 1279. } 1280. } 1281. /* 1282. otmp->spe is type schar; so we don't want spe to be any bigger or smaller. 1283. also, spe should always be positive -- some cheaters may try to confuse 1284. atoi() 1285. */ 1286. if (spe < 0) { 1287. spesgn = -1; /* cheaters get what they deserve */ 1288. spe = abs(spe); 1289. } 1290. if (spe > SCHAR_LIM) 1291. spe = SCHAR_LIM; 1292. 1293. /* now we have the actual name, as delivered by xname, say 1294. green potions called whisky 1295. scrolls labeled "QWERTY" 1296. egg 1297. fortune cookies 1298. very heavy iron ball named hoei 1299. wand of wishing 1300. elven cloak 1301. */ 1302. if ((p = strstri(bp, " named ")) != 0) { 1303. *p = 0; 1304. name = p+7; 1305. } 1306. if ((p = strstri(bp, " called ")) != 0) { 1307. *p = 0; 1308. un = p+8; 1309. /* "helmet called telepathy" is not "helmet" (a specific type) 1310. * "shield called reflection" is not "shield" (a general type) 1311. */ 1312. for(i = 0; i < SIZE(o_ranges); i++) 1313. if(!strcmpi(bp, o_ranges[i].name)) { 1314. let = o_ranges[i].osym; 1315. goto srch; 1316. } 1317. } 1318. if ((p = strstri(bp, " labeled ")) != 0) { 1319. *p = 0; 1320. dn = p+9; 1321. } else if ((p = strstri(bp, " labelled ")) != 0) { 1322. *p = 0; 1323. dn = p+10; 1324. } 1325. if ((p = strstri(bp, " of spinach")) != 0) { 1326. *p = 0; 1327. contents = SPINACH; 1328. } 1329. 1330. /* Skip over "pair of ", then jump to the singular since we don't 1331. need to convert "gloves" or "boots". */ 1332. if(cnt == 1 && !strncmpi(bp, "pair of ",8)) { 1333. bp += 8; 1334. cnt = 2; 1335. goto sing; 1336. /* cnt is ignored for armor and other non-stackable objects; 1337. DTRT for stackable objects */ 1338. } else if(cnt > 1 && !strncmpi(bp, "pairs of ",9)) { 1339. bp += 9; 1340. cnt *= 2; 1341. } else if (!strncmpi(bp, "set of ",7)) { 1342. bp += 7; 1343. } else if (!strncmpi(bp, "sets of ",8)) { 1344. bp += 8; 1345. } 1346. 1347. /* 1348. * Find corpse type using "of" (figurine of an orc, tin of orc meat) 1349. * Don't check if it's a wand or spellbook. 1350. * (avoid "wand/finger of death" confusion). 1351. */ 1352. if (!strstri(bp, "wand ") 1353. && !strstri(bp, "spellbook ") 1354. && !strstri(bp, "finger ")) { 1355. if ((p = strstri(bp, " of ")) != 0 1356. && (mntmp = name_to_mon(p+4)) >= 0) 1357. *p = 0; 1358. } 1359. /* Find corpse type w/o "of" (red dragon scale mail, yeti corpse) */ 1360. if (strncmp(bp, "samurai sword", 13)) /* not the "samurai" monster! */ 1361. if (strncmp(bp, "wizard lock", 11)) /* not the "wizard" monster! */ 1362. if (strncmp(bp, "ninja-to", 8)) /* not the "ninja" rank */ 1363. if (mntmp < 0 && strlen(bp) > 2 && (mntmp = name_to_mon(bp)) >= 0) { 1364. int mntmptoo, mntmplen; /* double check for rank title */ 1365. char *obp = bp; 1366. mntmptoo = title_to_mon(bp, (int *)0, &mntmplen); 1367. bp += mntmp != mntmptoo ? strlen(mons[mntmp].mname) : mntmplen; 1368. if (*bp == ' ') bp++; 1369. else if (!strncmpi(bp, "s ", 2)) bp += 2; 1370. else if (!strncmpi(bp, "es ", 3)) bp += 3; 1371. else if (!*bp && !actualn && !dn && !un && !let) { 1372. /* no referent; they don't really mean a monster type */ 1373. bp = obp; 1374. mntmp = -1; 1375. } 1376. } 1377. 1378. /* first change to singular if necessary */ 1379. if (*bp) { 1380. char *sng = makesingular(bp); 1381. if (strcmp(bp, sng)) { 1382. if (cnt == 1) cnt = 2; 1383. Strcpy(bp, sng); 1384. } 1385. } 1386. 1387. sing: 1388. /* Alternate spellings (two-handed sword vs. two handed sword) */ 1389. {struct alt_spellings *as = spellings; 1390. while(as->sp) { 1391. if (!strcmpi(bp, as->sp)) { 1392. typ = as->ob; 1393. goto typfnd; 1394. } 1395. as++; 1396. } 1397. } 1398. 1399. /* dragon scales - assumes order of dragons */ 1400. if(!strcmpi(bp, "scales") && 1401. mntmp >= PM_GRAY_DRAGON && mntmp <= PM_YELLOW_DRAGON) { 1402. typ = GRAY_DRAGON_SCALES + mntmp - PM_GRAY_DRAGON; 1403. mntmp = -1; /* no monster */ 1404. goto typfnd; 1405. } 1406. 1407. if(!strcmpi(bp, "ring mail") || /* Note: ring mail is not a ring ! */ 1408. !strcmpi(bp, "leather armor") || /* Prevent falling to 'armor'. */ 1409. !strcmpi(bp, "studded leather armor")) { 1410. let = ARMOR_CLASS; 1411. actualn = bp; 1412. goto srch; 1413. } 1414. if(!strcmpi(bp, "food ration")){ 1415. let = FOOD_CLASS; 1416. actualn = bp; 1417. goto srch; 1418. } 1419. p = eos(bp); 1420. if(!BSTRCMPI(bp, p-10, "holy water")) { 1421. typ = POT_WATER; 1422. if ((p-bp) >= 12 && *(p-12) == 'u') 1423. iscursed = 1; /* unholy water */ 1424. else blessed = 1; 1425. goto typfnd; 1426. } 1427. if(unlabeled && !BSTRCMPI(bp, p-6, "scroll")) { 1428. typ = SCR_BLANK_PAPER; 1429. goto typfnd; 1430. } 1431. if(unlabeled && !BSTRCMPI(bp, p-9, "spellbook")) { 1432. typ = SPE_BLANK_PAPER; 1433. goto typfnd; 1434. } 1435. #ifdef TOURIST 1436. if (!BSTRCMPI(bp, p-5, "shirt")) { 1437. typ = HAWAIIAN_SHIRT; 1438. goto typfnd; 1439. } 1440. #endif 1441. /* 1442. * NOTE: Gold pieces are handled as objects nowadays, and therefore 1443. * this section should probably be reconsidered as well as the entire 1444. * gold/money concept. Maybe we want to add other monetary units as 1445. * well in the future. (TH) 1446. */ 1447. if(!BSTRCMPI(bp, p-10, "gold piece") || !BSTRCMPI(bp, p-7, "zorkmid") || 1448. !strcmpi(bp, "gold") || !strcmpi(bp, "money") || 1449. !strcmpi(bp, "coin") || *bp == GOLD_SYM) { 1450. if (cnt > 5000 1451. #ifdef WIZARD 1452. && !wizard 1453. #endif 1454. ) cnt=5000; 1455. if (cnt < 1) cnt=1; 1456. pline("%d gold piece%s.", cnt, plur(cnt)); 1457. u.ugold += cnt; 1458. flags.botl=1; 1459. return (&zeroobj); 1460. } 1461. if (strlen(bp) == 1 && 1462. (i = def_char_to_objclass(*bp)) < MAXOCLASSES && i > ILLOBJ_CLASS) { 1463. let = i; 1464. goto any; 1465. } 1466. if(strncmpi(bp, "enchant ", 8) && 1467. strncmpi(bp, "destroy ", 8) && 1468. strncmpi(bp, "food detection", 14)) 1469. /* allow wishes for "enchant weapon" and "food detection" */ 1470. for(i = 0; i < sizeof(wrpsym); i++) { 1471. register int j = strlen(wrp[i]); 1472. if(!strncmpi(bp, wrp[i], j)){ 1473. let = wrpsym[i]; 1474. if(let != AMULET_CLASS) { 1475. bp += j; 1476. if(!strncmpi(bp, " of ", 4)) actualn = bp+4; 1477. /* else if(*bp) ?? */ 1478. } else 1479. actualn = bp; 1480. goto srch; 1481. } 1482. if(!BSTRCMPI(bp, p-j, wrp[i])){ 1483. let = wrpsym[i]; 1484. p -= j; 1485. *p = 0; 1486. if(p > bp && p[-1] == ' ') p[-1] = 0; 1487. actualn = dn = bp; 1488. goto srch; 1489. } 1490. } 1491. if (!BSTRCMPI(bp, p-6, " stone")) { 1492. p[-6] = 0; 1493. let = GEM_CLASS; 1494. dn = actualn = bp; 1495. goto srch; 1496. } else if (!BSTRCMPI(bp, p-6, " glass") || !strcmpi(bp, "glass")) { 1497. register char *g = bp; 1498. if (strstri(g, "broken")) return (struct obj *)0; 1499. if (!strncmpi(g, "worthless ", 10)) g += 10; 1500. if (!strncmpi(g, "piece of ", 9)) g += 9; 1501. if (!strncmpi(g, "colored ", 8)) g += 8; 1502. if (!strcmpi(g, "glass")) { /* choose random color */ 1503. /* white, blue, red, yellowish brown, green, violet */ 1504. typ = LAST_GEM + rnd(6); 1505. if (objects[typ].oc_class == GEM_CLASS) goto typfnd; 1506. else typ = 0; /* somebody changed objects[]? punt */ 1507. } else if (g > bp) { /* try to construct canonical form */ 1508. char tbuf[BUFSZ]; 1509. Strcpy(tbuf, "worthless piece of "); 1510. Strcat(tbuf, g); /* assume it starts with the color */ 1511. Strcpy(bp, tbuf); 1512. } 1513. } 1514. #ifdef WIZARD 1515. /* Let wizards wish for traps --KAA */ 1516. if (wizard) { 1517. int trap; 1518. char *tname; 1519. 1520. for (trap = NO_TRAP+1; trap < TRAPNUM; trap++) { 1521. tname = index(traps[trap], ' '); 1522. if (tname) { 1523. if (!strncmpi(tname+1, bp, strlen(tname+1))) { 1524. /* avoid stupid mistakes */ 1525. if(trap == TRAPDOOR && !Can_fall_thru(&u.uz)) 1526. trap = ROCKTRAP; 1527. 1528. (void) maketrap(u.ux, u.uy, trap); 1529. pline("A%s.", traps[trap]); 1530. return(&zeroobj); 1531. } 1532. } 1533. } 1534. /* or some other dungeon features -dlc */ 1535. p = eos(bp); 1536. if(!BSTRCMP(bp, p-8, "fountain")) { 1537. levl[u.ux][u.uy].typ = FOUNTAIN; 1538. if(!strncmpi(bp, "magic ", 6)) 1539. levl[u.ux][u.uy].blessedftn = 1; 1540. pline("A %sfountain.", 1541. levl[u.ux][u.uy].blessedftn ? "magic " : ""); 1542. newsym(u.ux, u.uy); 1543. return(&zeroobj); 1544. } 1545. if(!BSTRCMP(bp, p-5, "altar")) { 1546. aligntyp al; 1547. 1548. levl[u.ux][u.uy].typ = ALTAR; 1549. if(!strncmpi(bp, "chaotic ", 8)) 1550. al = A_CHAOTIC; 1551. else if(!strncmpi(bp, "neutral ", 8)) 1552. al = A_NEUTRAL; 1553. else if(!strncmpi(bp, "lawful ", 7)) 1554. al = A_LAWFUL; 1555. else if(!strncmpi(bp, "unaligned ", 10)) 1556. al = A_NONE; 1557. else /* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */ 1558. al = (!rn2(6)) ? A_NONE : rn2((int)A_LAWFUL+2) - 1; 1559. levl[u.ux][u.uy].altarmask = Align2amask( al ); 1560. pline("%s altar.", An(align_str(al))); 1561. newsym(u.ux, u.uy); 1562. return(&zeroobj); 1563. } 1564. } 1565. #endif 1566. for (i = 0; i < SIZE(o_ranges); i++) 1567. if(!strcmpi(bp, o_ranges[i].name)) { 1568. typ = rnd_class(o_ranges[i].f_o_range, o_ranges[i].l_o_range); 1569. goto typfnd; 1570. } 1571. 1572. actualn = bp; 1573. if (!dn) dn = actualn; /* ex. "skull cap" */ 1574. srch: 1575. /* check real names of gems first */ 1576. if(!let && actualn) { 1577. for(i = bases[letindex(GEM_CLASS)]; i <= LAST_GEM; i++) { 1578. register const char *zn; 1579. 1580. if((zn = OBJ_NAME(objects[i])) && !strcmpi(actualn, zn)) { 1581. typ = i; 1582. goto typfnd; 1583. } 1584. } 1585. } 1586. i = 1; 1587. if(let) i = bases[letindex(let)]; 1588. while(i <= NROFOBJECTS && (!let || objects[i].oc_class == let)){ 1589. register const char *zn; 1590. 1591. if(actualn && (zn = OBJ_NAME(objects[i])) && !strcmpi(actualn, zn)) { 1592. typ = i; 1593. goto typfnd; 1594. } 1595. if(dn && (zn = OBJ_DESCR(objects[i])) && !strcmpi(dn, zn)) { 1596. /* don't match extra descriptions (w/o real name) */ 1597. if (!OBJ_NAME(objects[i])) return (struct obj *)0; 1598. typ = i; 1599. goto typfnd; 1600. } 1601. if(un && (zn = objects[i].oc_uname) && !strcmpi(un, zn)) { 1602. typ = i; 1603. goto typfnd; 1604. } 1605. i++; 1606. } 1607. if (actualn) { 1608. struct Jitem *j = Japanese_items; 1609. while(j->item) { 1610. if (actualn && !strcmpi(actualn, j->name)) { 1611. typ = j->item; 1612. goto typfnd; 1613. } 1614. j++; 1615. } 1616. } 1617. #ifdef TUTTI_FRUTTI 1618. /* Note: not strncmpi. 2 fruits, one capital, one not, is possible. */ 1619. for(f=ffruit; f; f = f->nextf) { 1620. char *f1 = f->fname, *f2 = makeplural(f->fname); 1621. 1622. if(!strncmp(fruitbuf, f1, strlen(f1)) || 1623. !strncmp(fruitbuf, f2, strlen(f2))) { 1624. typ = SLIME_MOLD; 1625. ftype = f->fid; 1626. goto typfnd; 1627. } 1628. } 1629. #endif 1630. if (!strcmpi(bp, "spinach")) { 1631. contents = SPINACH; 1632. typ = TIN; 1633. goto typfnd; 1634. } 1635. 1636. if(!let && actualn) { 1637. short objtyp; 1638. 1639. /* Perhaps it's an artifact specified by name, not type */ 1640. name = artifact_name(actualn, &objtyp); 1641. if(name) { 1642. typ = objtyp; 1643. goto typfnd; 1644. } 1645. } 1646. if(!let) return((struct obj *)0); 1647. any: 1648. if(!let) let = wrpsym[rn2((int)sizeof(wrpsym))]; 1649. typfnd: 1650. if (typ) let = objects[typ].oc_class; 1651. 1652. /* check for some objects that are not allowed */ 1653. if (typ && objects[typ].oc_unique 1654. #ifdef WIZARD 1655. && !wizard 1656. /* should check flags.made_amulet, but it's not set anywhere */ 1657. #endif 1658. ) 1659. switch (typ) { 1660. case AMULET_OF_YENDOR: 1661. typ = FAKE_AMULET_OF_YENDOR; 1662. break; 1663. case CANDELABRUM_OF_INVOCATION: 1664. typ = rnd_class(TALLOW_CANDLE, WAX_CANDLE); 1665. break; 1666. case BELL_OF_OPENING: 1667. typ = BELL; 1668. break; 1669. case SPE_BOOK_OF_THE_DEAD: 1670. typ = SPE_BLANK_PAPER; 1671. break; 1672. } 1673. 1674. /* venom isn't really an object and can't be wished for; but allow 1675. * wizards to wish for it since it's faster than polymorphing and 1676. * spitting. 1677. */ 1678. if(let == VENOM_CLASS) 1679. #ifdef WIZARD 1680. if (!wizard) 1681. #endif 1682. return((struct obj *)0); 1683. 1684. if(typ) { 1685. otmp = mksobj(typ, TRUE, FALSE); 1686. } else { 1687. otmp = mkobj(let, FALSE); 1688. if (otmp) typ = otmp->otyp; 1689. } 1690. 1691. if(typ == OIL_LAMP || typ == MAGIC_LAMP || typ == BRASS_LANTERN) 1692. otmp->lamplit = islit; 1693. 1694. if(cnt > 0 && objects[typ].oc_merge && let != SPBOOK_CLASS && 1695. (cnt < rnd(6) || 1696. #ifdef WIZARD 1697. wizard || 1698. #endif 1699. (cnt <= 20 && 1700. ((let == WEAPON_CLASS && typ <= SHURIKEN) || (typ == ROCK))))) 1701. otmp->quan = (long) cnt; 1702. 1703. #ifdef WIZARD 1704. if (let == VENOM_CLASS) otmp->spe = 1; 1705. #endif 1706. 1707. if (spesgn == 0) spe = otmp->spe; 1708. #ifdef WIZARD 1709. else if (wizard) /* no alteration to spe */ ; 1710. #endif 1711. else if (let == ARMOR_CLASS || let == WEAPON_CLASS || typ == PICK_AXE || 1712. typ == UNICORN_HORN || 1713. (let==RING_CLASS && objects[typ].oc_charged)) { 1714. if(spe > rnd(5) && spe > otmp->spe) spe = 0; 1715. if(spe > 2 && Luck < 0) spesgn = -1; 1716. } else { 1717. if (let == WAND_CLASS) { 1718. if (spe > 1 && spesgn == -1) spe = 1; 1719. } else { 1720. if (spe > 0 && spesgn == -1) spe = 0; 1721. } 1722. if (spe > otmp->spe) spe = otmp->spe; 1723. } 1724. 1725. if (spesgn == -1) spe = -spe; 1726. 1727. /* set otmp->spe. This may, or may not, use spe... */ 1728. switch (typ) { 1729. case TIN: if (contents==EMPTY) { 1730. otmp->corpsenm = -1; 1731. otmp->spe = 0; 1732. } else if (contents==SPINACH) { 1733. otmp->corpsenm = -1; 1734. otmp->spe = 1; 1735. } 1736. break; 1737. #ifdef TUTTI_FRUTTI 1738. case SLIME_MOLD: otmp->spe = ftype; 1739. /* Fall through */ 1740. #endif 1741. case SKELETON_KEY: case CHEST: case LARGE_BOX: 1742. case HEAVY_IRON_BALL: case IRON_CHAIN: case STATUE: 1743. /* otmp->cobj already done in mksobj() */ 1744. break; 1745. #ifdef MAIL 1746. case SCR_MAIL: otmp->spe = 1; break; 1747. #endif 1748. case WAN_WISHING: 1749. #ifdef WIZARD 1750. if (!wizard) { 1751. #endif 1752. otmp->spe = (rn2(10) ? -1 : 0); 1753. break; 1754. #ifdef WIZARD 1755. } 1756. /* fall through (twice), if wizard */ 1757. #endif 1758. case MAGIC_LAMP: 1759. #ifdef WIZARD 1760. if (!wizard) { 1761. #endif 1762. otmp->spe = 0; 1763. break; 1764. #ifdef WIZARD 1765. } 1766. /* fall through, if wizard */ 1767. #endif 1768. default: otmp->spe = spe; 1769. } 1770. 1771. /* set otmp->corpsenm or dragon scale [mail] */ 1772. if (mntmp > -1) switch(typ) { 1773. case TIN: 1774. otmp->spe = 0; /* No spinach */ 1775. case CORPSE: 1776. if (!(mons[mntmp].geno & (G_UNIQ | G_NOCORPSE))) 1777. otmp->corpsenm = mntmp; 1778. break; 1779. case FIGURINE: 1780. if (!(mons[mntmp].geno & G_UNIQ) 1781. && !is_human(&mons[mntmp])) 1782. otmp->corpsenm = mntmp; 1783. break; 1784. case EGG: if (lays_eggs(&mons[mntmp]) || mntmp==PM_KILLER_BEE) 1785. otmp->corpsenm = mntmp; 1786. break; 1787. case STATUE: otmp->corpsenm = mntmp; 1788. break; 1789. case SCALE_MAIL: 1790. /* Dragon mail - depends on the order of objects */ 1791. /* & dragons. */ 1792. if (mntmp >= PM_GRAY_DRAGON && 1793. mntmp <= PM_YELLOW_DRAGON) 1794. otmp->otyp = GRAY_DRAGON_SCALE_MAIL + 1795. mntmp - PM_GRAY_DRAGON; 1796. break; 1797. } 1798. 1799. /* set blessed/cursed -- setting the fields directly is safe 1800. * since weight() is called below and addinv() will take care 1801. * of luck */ 1802. if (iscursed) { 1803. curse(otmp); 1804. } else if (uncursed) { 1805. otmp->blessed = 0; 1806. otmp->cursed = (Luck < 0 1807. #ifdef WIZARD 1808. && !wizard 1809. #endif 1810. ); 1811. } else if (blessed) { 1812. otmp->blessed = (Luck >= 0 1813. #ifdef WIZARD 1814. || wizard 1815. #endif 1816. ); 1817. otmp->cursed = (Luck < 0 1818. #ifdef WIZARD 1819. && !wizard 1820. #endif 1821. ); 1822. } else if (spesgn < 0) { 1823. curse(otmp); 1824. } 1825. 1826. /* set eroded */ 1827. if (eroded) 1828. otmp->oeroded = eroded; 1829. 1830. /* set erodeproof */ 1831. else if (erodeproof) 1832. otmp->oerodeproof = (Luck >= 0 1833. #ifdef WIZARD 1834. || wizard 1835. #endif 1836. ); 1837. 1838. /* prevent wishing abuse */ 1839. if ( 1840. #ifdef WIZARD 1841. !wizard && 1842. #endif 1843. otmp->otyp == WAN_WISHING) 1844. otmp->recharged = 1; 1845. 1846. /* set poisoned */ 1847. if (ispoisoned) { 1848. if (let == WEAPON_CLASS && typ <= SHURIKEN) 1849. otmp->opoisoned = (Luck >= 0); 1850. else if (Is_box(otmp)) 1851. otmp->otrapped = 1; 1852. else if (let == FOOD_CLASS) 1853. /* try to taint by making it as old as possible */ 1854. otmp->age = 1L; 1855. } 1856. 1857. if (name) { 1858. otmp = oname(otmp, name, 0); 1859. if (otmp->oartifact) otmp->quan = 1L; 1860. } 1861. otmp->owt = weight(otmp); 1862. if (very && otmp->otyp == HEAVY_IRON_BALL) otmp->owt += 160; 1863. if (halfeaten && otmp->oclass == FOOD_CLASS) { 1864. if (otmp->otyp == CORPSE) 1865. otmp->oeaten = mons[otmp->corpsenm].cnutrit; 1866. else otmp->oeaten = objects[otmp->otyp].oc_nutrition; 1867. otmp->owt /= 2; 1868. otmp->oeaten /= 2; 1869. if (!otmp->owt) otmp->owt = 1; 1870. if (!otmp->oeaten) otmp->oeaten = 1; 1871. } 1872. return(otmp); 1873. } 1874. 1875. int 1876. rnd_class(first,last) 1877. int first,last; 1878. { 1879. int i, x, sum=0; 1880. for(i=first; i<=last; i++) 1881. sum += objects[i].oc_prob; 1882. if (!sum) /* all zero */ 1883. return first + rn2(last-first+1); 1884. x = rnd(sum); 1885. for(i=first; i<=last; i++) 1886. if (objects[i].oc_prob && (x -= objects[i].oc_prob) <= 0) 1887. return i; 1888. return 0; 1889. } 1890. 1891. STATIC_OVL const char * 1892. Japanese_item_name(i) 1893. int i; 1894. { 1895. struct Jitem *j = Japanese_items; 1896. 1897. while(j->item) { 1898. if (i == j->item) 1899. return j->name; 1900. j++; 1901. } 1902. return (const char *)0; 1903. } 1904. #endif /* OVLB */ 1905. 1906. /*objnam.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