Source:NetHack 2.3e/apply.c
Jump to navigation
Jump to search
Below is the full text to apply.c from the source code of NetHack 2.3e.
Warning! This is the source code from an old release. For newer releases, see Source code
Screenshots and source code from Hack are used under the CWI license.
1. /* SCCS Id: @(#)apply.c 2.3 88/01/21 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. 4. #include "hack.h" 5. #include "edog.h" 6. #include "mkroom.h" 7. static struct monst *bchit(); 8. extern struct obj *addinv(); 9. extern struct trap *maketrap(); 10. extern int (*occupation)(); 11. extern char *occtxt; 12. extern char quitchars[]; 13. extern char pl_character[]; 14. 15. #ifdef DGKMOD 16. extern void set_occupation(); 17. #endif 18. #ifdef KAA 19. extern boolean unweapon; 20. #endif 21. static use_camera(), use_ice_box(), use_whistle(); 22. static use_magic_whistle(), use_pick_axe(); 23. #ifdef MARKER 24. extern int dowrite(); 25. #endif 26. #ifdef RPH 27. static use_mirror(); 28. #endif 29. static use_lamp(); 30. 31. doapply() { 32. register struct obj *obj; 33. register int res = 1; 34. 35. obj = getobj("(", "use or apply"); 36. if(!obj) return(0); 37. 38. switch(obj->otyp){ 39. case EXPENSIVE_CAMERA: 40. use_camera(obj); break; 41. case ICE_BOX: 42. use_ice_box(obj); break; 43. case PICK_AXE: 44. res = use_pick_axe(obj); 45. break; 46. 47. case MAGIC_WHISTLE: 48. if(pl_character[0] == 'W' || u.ulevel > 9) { 49. use_magic_whistle(obj); 50. break; 51. } 52. /* fall into next case */ 53. case WHISTLE: 54. use_whistle(obj); 55. break; 56. #ifdef RPH 57. case MIRROR: 58. use_mirror(obj); 59. break; 60. #endif 61. case LAMP: 62. case MAGIC_LAMP: 63. use_lamp(obj); 64. break; 65. #ifdef WALKIES 66. case LEASH: 67. use_leash(obj); 68. break; 69. #endif 70. #ifdef MARKER 71. case MAGIC_MARKER: 72. dowrite(obj); 73. break; 74. #endif 75. case CAN_OPENER: 76. if(!carrying(TIN)) { 77. pline("You have no can to open."); 78. goto xit; 79. } 80. pline("You cannot open a tin without eating its contents."); 81. pline("In order to eat, use the 'e' command."); 82. if(obj != uwep) 83. pline("Opening the tin will be much easier if you wield the can-opener."); 84. goto xit; 85. 86. #ifdef KAA 87. case STETHOSCOPE: 88. res = use_stethoscope(); 89. break; 90. #endif 91. case BLINDFOLD: 92. if (Blindfolded && obj->owornmask) { 93. pline("You remove the blindfold."); 94. Blindfolded = 0; 95. obj->owornmask = 0; 96. if (!Blinded) Blinded = 1; /* see on nexte */ 97. else pline("You still cannot see."); 98. } else if (!Blindfolded) { 99. pline("You put the blindfold on."); 100. Blindfolded = INTRINSIC; 101. obj->owornmask = W_TOOL; 102. seeoff(0); 103. } else pline("You are already wearing a blindfold!"); 104. break; 105. case BADGE: 106. if (Badged && obj->owornmask) { 107. pline("You remove the badge."); 108. Badged = 0; 109. obj->owornmask = 0; 110. } else if (!Badged) { 111. pline("You pin the badge on your chest."); 112. Badged = INTRINSIC; 113. obj->owornmask = W_TOOL; 114. } else pline("You are already wearing a badge!"); 115. break; 116. default: 117. pline("Sorry, I don't know how to use that."); 118. xit: 119. nomul(0); 120. return(0); 121. } 122. nomul(0); 123. return(res); 124. } 125. 126. /* ARGSUSED */ 127. static 128. use_camera(obj) /* register */ struct obj *obj; { 129. register struct monst *mtmp; 130. if(!getdir(1)){ /* ask: in what direction? */ 131. flags.move = multi = 0; 132. return; 133. } 134. if(u.uswallow) { 135. pline("You take a picture of %s's stomach.", monnam(u.ustuck)); 136. return; 137. } 138. if(u.dz) { 139. pline("You take a picture of the %s.", 140. (u.dz > 0) ? "floor" : "ceiling"); 141. return; 142. } 143. #ifdef KAA 144. if(!u.dx && !u.dy && !u.dz) { 145. if(!Blind) { 146. pline("You are blinded by the flash!"); 147. Blinded += rnd(25); 148. seeoff(0); 149. } 150. return; 151. } 152. #endif 153. if(mtmp = bchit(u.dx, u.dy, COLNO, '!')) { 154. if(mtmp->msleep){ 155. mtmp->msleep = 0; 156. pline("The flash awakens %s.", monnam(mtmp)); /* a3 */ 157. } else 158. if(mtmp->data->mlet != 'y') 159. if(mtmp->mcansee || mtmp->mblinded){ 160. register int tmp = dist(mtmp->mx,mtmp->my); 161. register int tmp2; 162. if(cansee(mtmp->mx,mtmp->my)) 163. pline("%s is blinded by the flash!", Monnam(mtmp)); 164. setmangry(mtmp); 165. if(tmp < 9 && !mtmp->isshk && rn2(4)) { 166. mtmp->mflee = 1; 167. if(rn2(4)) mtmp->mfleetim = rnd(100); 168. } 169. if(tmp < 3) mtmp->mcansee = mtmp->mblinded = 0; 170. else { 171. tmp2 = mtmp->mblinded; 172. tmp2 += rnd(1 + 50/tmp); 173. if(tmp2 > 127) tmp2 = 127; 174. mtmp->mblinded = tmp2; 175. mtmp->mcansee = 0; 176. } 177. } 178. } 179. } 180. 181. #ifdef KAA 182. /* Strictly speaking it makes no sense for usage of a stethoscope to 183. not take any time; however, unless it did, the stethoscope would be 184. almost useless. */ 185. static use_stethoscope() { 186. register struct monst *mtmp; 187. register struct rm *lev; 188. register int rx, ry; 189. if(!freehand()) { 190. pline("You have no free hand!"); 191. return(1); 192. } 193. if (!getdir(1)) { 194. flags.move=multi=0; 195. return(0); 196. } 197. if(u.dz < 0 || (u.dz && Levitation)) { 198. pline("You can't reach the %s!", u.dz<0 ? "ceiling" : "floor"); 199. return(1); 200. } 201. if(u.dz) { 202. pline("The floor seems healthy enough."); 203. return(0); 204. } 205. if (Confusion) confdir(); 206. rx = u.ux + u.dx; ry = u.uy + u.dy; 207. if(u.uswallow) { 208. mstatusline(u.ustuck); 209. return(0); 210. } 211. if(mtmp=m_at(rx,ry)) { 212. mstatusline(mtmp); 213. return(0); 214. } 215. if (!isok(rx,ry)) { 216. pline("You hear the sounds at the end of the universe."); 217. return(0); 218. } 219. lev = &levl[rx][ry]; 220. if(lev->typ == SDOOR) { 221. pline("You hear a hollow sound! This must be a secret door!"); 222. lev->typ = DOOR; 223. atl(rx, ry, DOOR_SYM); 224. return(0); 225. } 226. if(lev->typ == SCORR) { 227. pline("You hear a hollow sound! This must be a secret passage!"); 228. lev->typ = CORR; 229. atl(rx, ry, CORR_SYM); 230. return(0); 231. } 232. pline("You hear nothing special."); 233. return(0); 234. } 235. #endif 236. 237. static 238. struct obj *current_ice_box; /* a local variable of use_ice_box, to be 239. used by its local procedures in/ck_ice_box */ 240. static 241. in_ice_box(obj) register struct obj *obj; { 242. if(obj == current_ice_box || 243. (Punished && (obj == uball || obj == uchain))){ 244. pline("You must be kidding."); 245. return(0); 246. } 247. if(obj->owornmask & (W_ARMOR | W_RING)) { 248. pline("You cannot refrigerate something you are wearing."); 249. return(0); 250. } 251. if(obj->owt + current_ice_box->owt > 70) { 252. pline("It won't fit."); 253. return(1); /* be careful! */ 254. } 255. if(obj == uwep) { 256. if(uwep->cursed) { 257. pline("Your weapon is welded to your hand!"); 258. return(0); 259. } 260. setuwep((struct obj *) 0); 261. } 262. current_ice_box->owt += obj->owt; 263. freeinv(obj); 264. obj->o_cnt_id = current_ice_box->o_id; 265. obj->nobj = fcobj; 266. fcobj = obj; 267. obj->age = moves - obj->age; /* actual age */ 268. return(1); 269. } 270. 271. static 272. ck_ice_box(obj) register struct obj *obj; { 273. return(obj->o_cnt_id == current_ice_box->o_id); 274. } 275. 276. static 277. out_ice_box(obj) register struct obj *obj; { 278. register struct obj *otmp; 279. if(obj == fcobj) fcobj = fcobj->nobj; 280. else { 281. for(otmp = fcobj; otmp->nobj != obj; otmp = otmp->nobj) 282. if(!otmp->nobj) panic("out_ice_box"); 283. otmp->nobj = obj->nobj; 284. } 285. current_ice_box->owt -= obj->owt; 286. obj->age = moves - obj->age; /* simulated point of time */ 287. (void) addinv(obj); 288. } 289. 290. static 291. use_ice_box(obj) register struct obj *obj; { 292. register int cnt = 0; 293. register struct obj *otmp; 294. current_ice_box = obj; /* for use by in/out_ice_box */ 295. for(otmp = fcobj; otmp; otmp = otmp->nobj) 296. if(otmp->o_cnt_id == obj->o_id) 297. cnt++; 298. if(!cnt) pline("Your ice-box is empty."); 299. else { 300. pline("Do you want to take something out of the ice-box? [yn] "); 301. if(readchar() == 'y') 302. if(askchain(fcobj, (char *) 0, 0, out_ice_box, ck_ice_box, 0)) 303. return; 304. pline("That was all. Do you wish to put something in? [yn] "); 305. if(readchar() != 'y') return; 306. } 307. /* call getobj: 0: allow cnt; #: allow all types; %: expect food */ 308. otmp = getobj("0#%", "put in"); 309. if(!otmp || !in_ice_box(otmp)) 310. flags.move = multi = 0; 311. } 312. 313. static 314. struct monst * 315. bchit(ddx,ddy,range,sym) register int ddx,ddy,range; char sym; { 316. register struct monst *mtmp = (struct monst *) 0; 317. register int bchx = u.ux, bchy = u.uy; 318. 319. if(sym) Tmp_at(-1, sym); /* open call */ 320. while(range--) { 321. bchx += ddx; 322. bchy += ddy; 323. if(mtmp = m_at(bchx,bchy)) 324. break; 325. if(!ZAP_POS(levl[bchx][bchy].typ)) { 326. bchx -= ddx; 327. bchy -= ddy; 328. break; 329. } 330. if(sym) Tmp_at(bchx, bchy); 331. } 332. if(sym) Tmp_at(-1, -1); 333. return(mtmp); 334. } 335. 336. /* ARGSUSED */ 337. static 338. use_whistle(obj) struct obj *obj; { 339. register struct monst *mtmp = fmon; 340. pline("You produce a high whistling sound."); 341. while(mtmp) { 342. if(dist(mtmp->mx,mtmp->my) < u.ulevel*20) { 343. if(mtmp->msleep) 344. mtmp->msleep = 0; 345. if(mtmp->mtame) 346. EDOG(mtmp)->whistletime = moves; 347. } 348. mtmp = mtmp->nmon; 349. } 350. } 351. 352. /* ARGSUSED */ 353. static 354. use_magic_whistle(obj) struct obj *obj; { 355. register struct monst *mtmp = fmon; 356. pline("You produce a strange whistling sound."); 357. while(mtmp) { 358. if(mtmp->mtame) mnexto(mtmp); 359. mtmp = mtmp->nmon; 360. } 361. } 362. 363. #ifdef WALKIES 364. /* ARGSUSED */ 365. static 366. use_leash(obj) struct obj *obj; { 367. register struct monst *mtmp = fmon; 368. extern char *lmonnam(); 369. 370. while(mtmp && !mtmp->mleashed) mtmp = mtmp->nmon; 371. 372. if(mtmp) { 373. 374. if (next_to(mtmp)) { 375. 376. mtmp->mleashed = 0; 377. pline("You remove the leash from your %s.", 378. #ifdef RPH 379. /* a hack to include the dogs full name. +4 elminates */ 380. /* the 'the' at the start of the name */ 381. lmonnam(mtmp) + 4); 382. #else 383. mtmp->data->mname); 384. #endif 385. } else pline("You must be next to your %s to unleash him.", 386. #ifdef RPH 387. lmonnam(mtmp)+4); 388. #else 389. mtmp->data->mname); 390. #endif 391. } else { 392. 393. for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 394. 395. if(mtmp->mtame && next_to(mtmp)) { 396. 397. pline("You slip the leash around your %s.", mtmp->data->mname); 398. mtmp->mleashed = 1; 399. if(mtmp->msleep) mtmp->msleep = 0; 400. return(0); 401. } 402. } 403. pline("There's nothing here to put a leash on."); 404. } 405. return(0); 406. } 407. 408. next_to(mtmp) register struct monst *mtmp; { 409. 410. return((abs(u.ux - mtmp->mx) <= 1) && (abs(u.uy - mtmp->my) <= 1)); 411. } 412. #endif 413. 414. static int dig_effort; /* effort expended on current pos */ 415. static uchar dig_level; 416. static coord dig_pos; 417. static boolean dig_down; 418. 419. static 420. dig() { 421. register struct rm *lev; 422. register dpx = dig_pos.x, dpy = dig_pos.y; 423. 424. /* perhaps a nymph stole his pick-axe while he was busy digging */ 425. /* or perhaps he teleported away */ 426. if(u.uswallow || !uwep || uwep->otyp != PICK_AXE || 427. dig_level != dlevel || 428. ((dig_down && (dpx != u.ux || dpy != u.uy)) || 429. (!dig_down && dist(dpx,dpy) > 2))) 430. return(0); 431. 432. dig_effort += 10 + abon() + uwep->spe + rn2(5); 433. if(dig_down) { 434. if(!xdnstair) { 435. pline("The floor here seems too hard to dig in."); 436. return(0); 437. } 438. if(dig_effort > 250) { 439. dighole(); 440. return(0); /* done with digging */ 441. } 442. if(dig_effort > 50) { 443. register struct trap *ttmp = t_at(dpx,dpy); 444. 445. if(!ttmp) { 446. ttmp = maketrap(dpx,dpy,PIT); 447. ttmp->tseen = 1; 448. pline("You have dug a pit."); 449. u.utrap = rn1(4,2); 450. u.utraptype = TT_PIT; 451. return(0); 452. } 453. } 454. } else 455. if(dig_effort > 100) { 456. register char *digtxt; 457. register struct obj *obj; 458. 459. lev = &levl[dpx][dpy]; 460. if(obj = sobj_at(ENORMOUS_ROCK, dpx, dpy)) { 461. fracture_rock(obj); 462. digtxt = "The rock falls apart."; 463. } else if(!lev->typ || lev->typ == SCORR) { 464. lev->typ = CORR; 465. digtxt = "You succeeded in cutting away some rock."; 466. } else if(lev->typ == HWALL || lev->typ == VWALL 467. || lev->typ == SDOOR) { 468. lev->typ = xdnstair ? DOOR : ROOM; 469. digtxt = "You just made an opening in the wall."; 470. } else 471. digtxt = "Now what exactly was it that you were digging in?"; 472. mnewsym(dpx, dpy); 473. prl(dpx, dpy); 474. pline(digtxt); /* after mnewsym & prl */ 475. return(0); 476. } else { 477. if(IS_WALL(levl[dpx][dpy].typ)) { 478. register int rno = inroom(dpx,dpy); 479. 480. if(rno >= 0 && rooms[rno].rtype >= SHOPBASE) { 481. pline("This wall seems too hard to dig into."); 482. return(0); 483. } 484. } 485. pline("You hit the rock with all your might."); 486. } 487. return(1); 488. } 489. 490. /* When will hole be finished? Very rough indication used by shopkeeper. */ 491. holetime() { 492. return( (occupation == dig) ? (250 - dig_effort)/20 : -1); 493. } 494. 495. dighole() 496. { 497. register struct trap *ttmp = t_at(u.ux, u.uy); 498. 499. if(!xdnstair) { 500. pline("The floor here seems too hard to dig in."); 501. } else { 502. if(ttmp) 503. ttmp->ttyp = TRAPDOOR; 504. else 505. ttmp = maketrap(u.ux, u.uy, TRAPDOOR); 506. ttmp->tseen = 1; 507. pline("You've made a hole in the floor."); 508. if(!u.ustuck && !Levitation) { /* KAA */ 509. if(inshop()) 510. shopdig(1); 511. pline("You fall through ..."); 512. if(u.utraptype == TT_PIT) { 513. u.utrap = 0; 514. u.utraptype = 0; 515. } 516. goto_level(dlevel+1, FALSE); 517. } 518. } 519. } 520. 521. static 522. use_pick_axe(obj) 523. struct obj *obj; 524. { 525. char dirsyms[12]; 526. extern char sdir[]; 527. register char *dsp = dirsyms, *sdp = sdir; 528. register struct monst *mtmp; 529. register struct rm *lev; 530. register int rx, ry, res = 0; 531. 532. #ifndef FREEHAND 533. /* edited by GAN 10/20/86 so that you can't apply the 534. * pick-axe while wielding a cursed weapon 535. */ 536. if(!freehand()) { 537. pline("You have no free hand to dig with!"); 538. return(0); 539. } 540. # ifdef KAA 541. if(cantwield(u.usym)) { 542. pline("You can't hold it strongly enough."); 543. return(0); 544. } 545. # endif 546. #else 547. if(obj != uwep) { 548. if(uwep && uwep->cursed) { 549. /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */ 550. pline("Since your weapon is welded to your hand,"); 551. pline("you cannot use that pick-axe."); 552. return(0); 553. } 554. # ifdef KAA 555. if(cantwield(u.usym)) { 556. pline("You can't hold it strongly enough."); 557. return(0); 558. } 559. unweapon = TRUE; 560. # endif 561. pline("You now wield %s.", doname(obj)); 562. setuwep(obj); 563. res = 1; 564. } 565. #endif 566. while(*sdp) { 567. (void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */ 568. rx = u.ux + u.dx; 569. ry = u.uy + u.dy; 570. if(u.dz > 0 || (u.dz == 0 && isok(rx, ry) && 571. (IS_ROCK(levl[rx][ry].typ) 572. || sobj_at(ENORMOUS_ROCK, rx, ry)))) 573. *dsp++ = *sdp; 574. sdp++; 575. } 576. *dsp = 0; 577. pline("In what direction do you want to dig? [%s] ", dirsyms); 578. if(!getdir(0)) /* no txt */ 579. return(res); 580. if(u.uswallow && attack(u.ustuck)) /* return(1) */; 581. else 582. if(u.dz < 0) 583. pline("You cannot reach the ceiling."); 584. else 585. #ifdef KAA 586. if(!u.dx && !u.dy && !u.dz) { 587. pline("You hit yourself with your own pick-axe."); 588. losehp(rnd(2)+dbon(), "self-inflicted wound"); 589. flags.botl=1; 590. return(1); 591. } 592. #endif 593. if(u.dz == 0) { 594. if(Confusion) 595. confdir(); 596. rx = u.ux + u.dx; 597. ry = u.uy + u.dy; 598. if((mtmp = m_at(rx, ry)) && attack(mtmp)) 599. return(1); 600. if(!isok(rx, ry)) { 601. pline("Clash!"); 602. return(1); 603. } 604. lev = &levl[rx][ry]; 605. if(lev->typ == DOOR) 606. pline("Your %s against the door.", 607. aobjnam(obj, "clang")); 608. else if(!IS_ROCK(lev->typ) 609. && !sobj_at(ENORMOUS_ROCK, rx, ry)) { 610. /* ACCESSIBLE or POOL */ 611. pline("You swing your %s through thin air.", 612. aobjnam(obj, (char *) 0)); 613. } else { 614. if(dig_pos.x != rx || dig_pos.y != ry 615. || dig_level != dlevel || dig_down) { 616. dig_down = FALSE; 617. dig_pos.x = rx; 618. dig_pos.y = ry; 619. dig_level = dlevel; 620. dig_effort = 0; 621. pline("You start digging."); 622. } else 623. pline("You continue digging."); 624. #ifdef DGKMOD 625. set_occupation(dig, "digging", 0); 626. #else 627. occupation = dig; 628. occtxt = "digging"; 629. #endif 630. } 631. } else if(Levitation) { 632. pline("You cannot reach the floor."); 633. } else { 634. if(dig_pos.x != u.ux || dig_pos.y != u.uy 635. || dig_level != dlevel || !dig_down) { 636. dig_down = TRUE; 637. dig_pos.x = u.ux; 638. dig_pos.y = u.uy; 639. dig_level = dlevel; 640. dig_effort = 0; 641. pline("You start digging in the floor."); 642. if(inshop()) 643. shopdig(0); 644. } else 645. pline("You continue digging in the floor."); 646. #ifdef DGKMOD 647. set_occupation(dig, "digging", 0); 648. #else 649. occupation = dig; 650. occtxt = "digging"; 651. #endif 652. } 653. return(1); 654. } 655. 656. #ifdef RPH 657. static 658. use_mirror(obj) 659. struct obj *obj; 660. { 661. register struct monst *mtmp; 662. register char mlet; 663. extern mpickobj(), freeinv(), rloc(); 664. 665. if(!getdir(1)){ /* ask: in what direction? */ 666. flags.move = multi = 0; 667. return; 668. } 669. if(u.uswallow) { 670. pline("You reflect %s's stomach.", monnam(u.ustuck)); 671. return; 672. } 673. if(u.dz) { 674. pline("You reflect the %s.", 675. (u.dz > 0) ? "floor" : "ceiling"); 676. return; 677. } 678. if(!u.dx && !u.dy && !u.dz) { 679. if(!Blind) 680. pline ("You look as ugly as ever."); 681. else { 682. if (rn2(4-u.uluck/3) || !HTelepat) 683. pline ("You can't see your ugly face."); 684. else { 685. char *tm, *tl; int ll; 686. if (rn2(4)) { 687. tm = "ugly monster"; 688. ll = dlevel - u.medusa_level; 689. } 690. else { 691. tm = "intelligent being"; 692. ll = dlevel - u.wiz_level; 693. } 694. if (ll < -10) tl = "far below you"; 695. else if (ll < -1) tl = "below you"; 696. else if (ll == -1) tl = "under your feet"; 697. else if (ll == 0) tl = "very close to you"; 698. else if (ll == 1) tl = "above your head"; 699. else if (ll > 10) tl = "far above you"; 700. else tl = "above you"; 701. pline ("You get an impression that an %s lives %s.", 702. tm, tl); 703. } 704. } 705. return; 706. } 707. if(mtmp = bchit(u.dx, u.dy, COLNO, 0)) { 708. mlet = mtmp->data->mlet; 709. if(mtmp->msleep){ 710. pline ("%s is tired and doesn't look at your mirror.", 711. Monnam(mtmp)); 712. mtmp->msleep = 0; 713. } else 714. if (!mtmp->mcansee) { 715. pline("%s can't see anything at the moment.", 716. Monnam(mtmp)); 717. } 718. /* some monsters do special things */ 719. else if (!mtmp->mcan && index("EUN8",mlet)) 720. switch (mlet) { 721. case '8': 722. pline("%s is turned to stone!", Monnam(mtmp)); 723. killed(mtmp); 724. break; 725. case 'E': 726. pline("%s is frozen by its reflection.",Monnam(mtmp)); 727. mtmp->mfroz = 1; 728. break; 729. case 'U': 730. pline ("%s has confused itself!", Monnam(mtmp)); 731. mtmp->mconf = 1; 732. break; 733. case 'N': 734. pline ("%s looks beautiful in your mirror.",Monnam(mtmp)); 735. pline ("She decides to take it!"); 736. freeinv(obj); 737. mpickobj(mtmp,obj); 738. rloc(mtmp); 739. break; 740. default: 741. break; 742. } 743. else if (mlet == 'V' || mlet == '&') 744. pline ("%s doesn't seem to reflect anything.", Monnam(mtmp)); 745. else if (!index("agquv1N", mlet) && rn2(5)) { 746. pline ("%s is frightened by its reflection.", 747. Monnam(mtmp)); 748. mtmp->mflee = 1; 749. mtmp->mfleetim += d(2,4); 750. } 751. else 752. pline ("%s doesn't seem to mind %s refection.", 753. Monnam(mtmp), 754. (mlet=='1'?"his":(mlet=='N'?"her":"its"))); 755. }/* if monster hit with mirror */ 756. }/* use_mirror */ 757. 758. #endif 759. 760. static 761. use_lamp(obj) 762. struct obj *obj; 763. { 764. if(obj->spe <= 0 || obj->otyp == MAGIC_LAMP ) { 765. pline("This lamp has no oil."); 766. return; 767. } 768. litroom(TRUE); 769. obj->spe -= 1; 770. } 771. 772. dorub() { 773. 774. if (!(carrying(LAMP) || carrying(MAGIC_LAMP))) { 775. pline("You do not have a lamp!"); 776. return; 777. } 778. if (!(uwep->otyp == LAMP || uwep->otyp == MAGIC_LAMP)) { 779. pline("You must wield the lamp to rub it!"); 780. return; 781. } 782. if (uwep->otyp == MAGIC_LAMP && uwep->spe > 0 && !rn2(3)) { 783. uwep->spe = 0; 784. djinni_from_bottle(); 785. } else if (uwep->otyp == MAGIC_LAMP && rn2(2) && !Blind) 786. pline("You see a puff of smoke."); 787. else pline("Nothing happens."); 788. }