About: Source:NetHack 3.0.0/zap.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 zap.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/zap.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.0.0/zap.c
rdfs:comment
  • Below is the full text to zap.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/zap.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 zap.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/zap.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)zap.c 3.0 88/10/25 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. #if defined(ALTARS) && defined(THEOLOGY) 8. static boolean priesthit = FALSE; 9. #endif 10. 11. const char *fl[]= { 12. "magic missile", /* Wands must be 0-9 */ 13. "bolt of fire", 14. "sleep ray", 15. "bolt of cold", 16. "death ray", 17. "bolt of lightning", 18. "", 19. "", 20. "", 21. "", 22. 23. "magic missile", /* Spell equivalents must be 10-19 */ 24. "fireball", 25. "sleep ray", 26. "cone of cold", 27. "finger of death", 28. "bolt of lightning", 29. "", 30. "", 31. "", 32. "", 33. 34. "blast of missiles", /* Dragon breath equivalents 20-29*/ 35. "blast of fire", 36. "blast of sleeping gas", 37. "blast of frost", 38. "blast of disintegration", 39. "blast of lightning", 40. "blast of poison gas", 41. "blast of acid", 42. "", 43. "" 44. }; 45. 46. /* Routines for IMMEDIATE wands and spells. */ 47. /* bhitm: monster mtmp was hit by the effect of wand or spell otmp */ 48. static int 49. bhitm(mtmp, otmp) 50. register struct monst *mtmp; 51. register struct obj *otmp; 52. { 53. wakeup(mtmp); 54. switch(otmp->otyp) { 55. case WAN_STRIKING: 56. #ifdef SPELLS 57. case SPE_FORCE_BOLT: 58. #endif 59. if(u.uswallow || rnd(20) < 10+mtmp->data->ac) { 60. register int tmp = d(2,12); 61. hit((otmp->otyp == WAN_STRIKING) ? "wand" : "spell", mtmp, exclam(tmp)); 62. (void) resist(mtmp, otmp->olet, tmp, TELL); 63. } else miss((otmp->otyp == WAN_STRIKING) ? "wand" : "spell", mtmp); 64. break; 65. case WAN_SLOW_MONSTER: 66. #ifdef SPELLS 67. case SPE_SLOW_MONSTER: 68. #endif 69. if(! resist(mtmp, otmp->olet, 0, NOTELL)) 70. if (mtmp->mspeed == MFAST) mtmp->mspeed = 0; 71. else mtmp->mspeed = MSLOW; 72. break; 73. case WAN_SPEED_MONSTER: 74. if (!resist(mtmp, otmp->olet, 0, NOTELL)) 75. if (mtmp->mspeed == MSLOW) mtmp->mspeed = 0; 76. else mtmp->mspeed = MFAST; 77. break; 78. case WAN_UNDEAD_TURNING: 79. #ifdef SPELLS 80. case SPE_TURN_UNDEAD: 81. #endif 82. if(is_undead(mtmp->data)) { 83. 84. if(!resist(mtmp, otmp->olet, rnd(8), NOTELL)) 85. mtmp->mflee = 1; 86. } 87. break; 88. case WAN_POLYMORPH: 89. #ifdef SPELLS 90. case SPE_POLYMORPH: 91. #endif 92. if(!resist(mtmp, otmp->olet, 0, NOTELL)) 93. if( newcham(mtmp, (struct permonst *)0) ) 94. if (!Hallucination) 95. makeknown(otmp->otyp); 96. break; 97. case WAN_CANCELLATION: 98. #ifdef SPELLS 99. case SPE_CANCELLATION: 100. #endif 101. if(!resist(mtmp, otmp->olet, 0, NOTELL)) { 102. if (is_were(mtmp->data) && mtmp->data->mlet != S_HUMAN) 103. were_change(mtmp); 104. #ifdef GOLEMS 105. if (mtmp->data == &mons[PM_CLAY_GOLEM]) { 106. if (!Blind) 107. pline("Some writing vanishes from %s's head!", 108. mon_nam(mtmp)); 109. killed(mtmp); 110. } 111. else 112. #endif /* GOLEMS */ 113. mtmp->mcan = 1; 114. } 115. break; 116. case WAN_TELEPORTATION: 117. #ifdef SPELLS 118. case SPE_TELEPORT_AWAY: 119. #endif 120. #if defined(ALTARS) && defined(THEOLOGY) 121. if(mtmp->ispriest && in_temple(mtmp->mx, mtmp->my)) { 122. kludge("%s resists your magic!", Monnam(mtmp)); 123. wakeup(mtmp); 124. break; 125. } 126. #endif 127. rloc(mtmp); 128. break; 129. case WAN_MAKE_INVISIBLE: 130. mtmp->minvis = 1; 131. break; 132. case WAN_NOTHING: 133. break; 134. #ifdef PROBING 135. case WAN_PROBING: 136. makeknown(otmp->otyp); 137. mstatusline(mtmp); 138. break; 139. #endif 140. case WAN_OPENING: 141. case WAN_LOCKING: 142. #ifdef SPELLS 143. case SPE_KNOCK: 144. case SPE_WIZARD_LOCK: 145. #endif 146. break; 147. default: 148. impossible("What an interesting effect (%u)", otmp->otyp); 149. } 150. return 0; 151. } 152. 153. struct monst * 154. revive(obj,ininv) 155. register struct obj *obj; 156. boolean ininv; 157. { 158. register struct monst *mtmp; 159. 160. if(obj->otyp == CORPSE) { 161. int montype,x,y,nl; 162. char buf[BUFSZ]; 163. 164. if (nl = obj->onamelth) Strcpy(buf, ONAME(obj)); 165. montype = obj->corpsenm; 166. if (ininv) { 167. x = u.ux; y = u.uy; 168. useup(obj); 169. } else { 170. x = obj->ox; y = obj->oy; 171. useupf(obj); 172. } 173. if (cant_create(&montype)) { /* will make zombie instead */ 174. mtmp = makemon(&mons[PM_HUMAN_ZOMBIE], x, y); 175. if (mtmp) { 176. mtmp->mhp = mtmp->mhpmax = 100; 177. mtmp->mspeed = MFAST; 178. } 179. } else { 180. #ifdef ARMY 181. if (is_mercenary(&mons[montype])) 182. montype = PM_UNARMORED_SOLDIER; 183. #endif 184. mons[montype].pxlth += nl; 185. mtmp = mkmon_at(mons[montype].mname, x, y); 186. mons[montype].pxlth -= nl; 187. if (mtmp) { 188. /* Monster retains its name */ 189. mtmp->mnamelth = nl; 190. if (nl) Strcpy(NAME(mtmp), buf); 191. /* No inventory for newly revived monsters */ 192. while(obj = (mtmp->minvent)) { 193. mtmp->minvent = obj->nobj; 194. free((genericptr_t)obj); 195. } 196. } 197. } 198. } 199. return mtmp; 200. } 201. 202. static const char charged_objs[] = { WAND_SYM, WEAPON_SYM, ARMOR_SYM, 0 }; 203. 204. static void 205. cancel_item(obj) 206. register struct obj *obj; 207. { 208. if(obj->spe && 209. !(obj->otyp == AMULET_OF_YENDOR || 210. obj->otyp == WAN_CANCELLATION || /* can't cancel cancellation */ 211. obj->otyp == TIN || obj->otyp == EGG || 212. obj->otyp == STATUE || 213. #ifdef MAIL 214. obj->otyp == SCR_MAIL || 215. #endif 216. obj->otyp == KEY || obj->otyp == SKELETON_KEY || 217. obj->otyp == LARGE_BOX || obj->otyp == CHEST)) 218. obj->spe = (obj->olet == WAND_SYM) ? -1 : 0; 219. if (obj->olet == SCROLL_SYM 220. #ifdef MAIL 221. && obj->otyp != SCR_MAIL 222. #endif 223. ) 224. obj->otyp = SCR_BLANK_PAPER; 225. if (obj->olet == POTION_SYM && obj->otyp > POT_BOOZE) 226. obj->otyp = (obj->otyp==POT_SICKNESS) ? POT_FRUIT_JUICE : POT_WATER; 227. /* sickness is "biologically contaminated" fruit juice; cancel it 228. * and it just becomes fruit juice... 229. */ 230. obj->blessed = obj->cursed = FALSE; 231. } 232. 233. static int 234. bhito(obj, otmp) /* object obj was hit by the effect of wand otmp */ 235. register struct obj *obj, *otmp; /* returns TRUE if sth was done */ 236. { 237. register int res = 1; 238. struct obj *otmp2; 239. 240. if(obj == uball || obj == uchain) 241. res = 0; 242. else 243. switch(otmp->otyp) { 244. case WAN_POLYMORPH: 245. #ifdef SPELLS 246. case SPE_POLYMORPH: 247. #endif 248. #ifdef MAIL 249. /* You can't send yourself 100 mail messages and then 250. * polymorph them into useful scrolls 251. */ 252. if (obj->otyp == SCR_MAIL) obj->spe = 1; 253. #endif 254. /* preserve symbol and quantity */ 255. otmp2 = mkobj_at(obj->olet, obj->ox, obj->oy); 256. otmp2->quan = obj->quan; 257. 258. /* keep special fields (including charges on wands) */ 259. if (index(charged_objs, otmp2->olet)) otmp2->spe = obj->spe; 260. 261. /* Amulet gets cheap stewr 870807 */ 262. if (obj->otyp == AMULET_OF_YENDOR) otmp2->spe = -1; 263. 264. /* Wands of wishing max 3 stewr 870808 */ 265. if ((otmp2->otyp == WAN_WISHING) 266. && (obj->spe > 3)) otmp2->spe = 3; 267. 268. otmp2->cursed = obj->cursed; 269. otmp2->blessed = obj->blessed; 270. otmp2->rustfree = obj->rustfree; 271. 272. /* Keep chest/box traps and poisoned ammo if we may */ 273. if (obj->otrapped && Is_box(otmp2)) 274. otmp2->otrapped = 1; 275. if (obj->opoisoned && 276. (otmp2->olet == WEAPON_SYM && otmp2->otyp <= SHURIKEN)) 277. otmp2->opoisoned = 1; 278. 279. /* Turn dragon corpses into dragon armors */ 280. if (obj->otyp == CORPSE && obj->corpsenm >= PM_GREY_DRAGON 281. && obj->corpsenm <= PM_YELLOW_DRAGON) { 282. if (!rn2(10)) { /* Random failure */ 283. otmp2->otyp = TIN; 284. otmp2->known = otmp2->dknown = 1; 285. } else { 286. otmp2->otyp = DRAGON_SCALE_MAIL; 287. otmp2->olet = ARMOR_SYM; 288. otmp2->spe = 0; 289. otmp2->rustfree = 1; 290. otmp2->quan = 1; 291. otmp2->cursed = 0; 292. } 293. otmp2->corpsenm = obj->corpsenm; 294. } 295. 296. /* update the weight */ 297. otmp2->owt = weight(otmp2); 298. delobj(obj); 299. break; 300. case WAN_STRIKING: 301. #ifdef SPELLS 302. case SPE_FORCE_BOLT: 303. #endif 304. if(obj->otyp == BOULDER) 305. fracture_rock(obj); 306. else if(obj->otyp == STATUE) 307. (void) break_statue(obj); 308. else 309. res = 0; 310. break; 311. case WAN_CANCELLATION: 312. #ifdef SPELLS 313. case SPE_CANCELLATION: 314. #endif 315. cancel_item(obj); 316. break; 317. case WAN_TELEPORTATION: 318. #ifdef SPELLS 319. case SPE_TELEPORT_AWAY: 320. #endif 321. rloco(obj); 322. break; 323. case WAN_MAKE_INVISIBLE: 324. obj->oinvis = 1; 325. break; 326. case WAN_UNDEAD_TURNING: 327. #ifdef SPELLS 328. case SPE_TURN_UNDEAD: 329. #endif 330. res = !!revive(obj,FALSE); 331. break; 332. case WAN_OPENING: 333. case WAN_LOCKING: 334. #ifdef SPELLS 335. case SPE_KNOCK: 336. case SPE_WIZARD_LOCK: 337. #endif 338. if(Is_box(obj)) 339. res = boxlock(obj, otmp); 340. else 341. res = 0; 342. if (res /* && obj->olet == WAND_SYM */) 343. makeknown(obj->otyp); 344. break; 345. case WAN_SLOW_MONSTER: /* no effect on objects */ 346. #ifdef SPELLS 347. case SPE_SLOW_MONSTER: 348. #endif 349. case WAN_SPEED_MONSTER: 350. case WAN_NOTHING: 351. #ifdef PROBING 352. case WAN_PROBING: 353. #endif 354. res = 0; 355. break; 356. default: 357. impossible("What an interesting effect (%u)", otmp->otyp); 358. } 359. return(res); 360. } 361. 362. /* 363. * zappable - returns 1 if zap is available, 0 otherwise. 364. * it removes a charge from the wand if zappable. 365. * added by GAN 11/03/86 366. */ 367. int 368. zappable(wand) 369. register struct obj *wand; 370. { 371. if(wand->spe < 0 || (wand->spe == 0 && rn2(121))) 372. return 0; 373. if(wand->spe == 0) 374. You("wrest one more spell from the worn-out wand."); 375. wand->spe--; 376. return 1; 377. } 378. 379. /* 380. * zapnodir - zaps an NODIR wand. 381. * added by GAN 11/03/86 382. */ 383. void 384. zapnodir(wand) 385. register struct obj *wand; 386. { 387. switch(wand->otyp){ 388. case WAN_LIGHT: 389. litroom(TRUE); 390. break; 391. case WAN_SECRET_DOOR_DETECTION: 392. if(!findit()) return; 393. break; 394. case WAN_CREATE_MONSTER: 395. { register int cnt = 1; 396. if(!rn2(23)) cnt += rn2(7) + 1; 397. while(cnt--) 398. (void) makemon((struct permonst *) 0, u.ux, u.uy); 399. } 400. break; 401. case WAN_WISHING: 402. 403. if(u.uluck + rn2(5) < 0) { 404. pline("Unfortunately, nothing happens."); 405. break; 406. } 407. makewish(); 408. break; 409. } 410. if(!objects[wand->otyp].oc_name_known) { 411. makeknown(wand->otyp); 412. more_experienced(0,10); 413. } 414. } 415. 416. static void 417. backfire(otmp) 418. 419. register struct obj * otmp; 420. { 421. pline("The %s suddenly explodes!", xname(otmp)); 422. losehp(d(otmp->spe+2,6), "exploding wand"); 423. useup(otmp); 424. } 425. 426. static const char zap_syms[] = { WAND_SYM, 0 }; 427. 428. int 429. dozap() 430. { 431. register struct obj *obj; 432. int damage; 433. 434. obj = getobj(zap_syms, "zap"); 435. if(!obj) return(0); 436. 437. check_unpaid(obj); 438. 439. /* zappable addition done by GAN 11/03/86 */ 440. if(!zappable(obj)) pline(nothing_happens); 441. else if(obj->cursed && !rn2(100)) { 442. backfire(obj); /* the wand blows up in your face! */ 443. return(1); 444. } else if(!(objects[obj->otyp].bits & NODIR) && !getdir(1)) { 445. if (!Blind) 446. pline("The %s glows and fades.", xname(obj)); 447. /* make him pay for knowing !NODIR */ 448. } else if(!u.dx && !u.dy && !u.dz && !(objects[obj->otyp].bits & NODIR)) { 449. if((damage = zapyourself(obj))) 450. losehp(damage,"self-inflicted injury"); 451. } 452. else { 453. weffects(obj); 454. #if defined(ALTARS) && defined(THEOLOGY) 455. if(priesthit) ghod_hitsu(); 456. priesthit = FALSE; 457. #endif 458. } 459. if (obj->spe < 0) { 460. pline ("The %s %sturns to dust.", 461. xname(obj), Blind ? "" : "glows violently, then "); 462. useup(obj); 463. } 464. return(1); 465. } 466. 467. int 468. zapyourself(obj) 469. register struct obj *obj; 470. { 471. struct obj *otmp; 472. int damage = 0; 473. 474. switch(obj->otyp) { 475. case WAN_STRIKING: 476. #ifdef SPELLS 477. case SPE_FORCE_BOLT: 478. #endif 479. if(Antimagic) { 480. shieldeff(u.ux, u.uy); 481. pline("Boing!"); 482. } else { 483. You("magically bash yourself!"); 484. damage=d(8,6); 485. } 486. break; 487. case WAN_LIGHTNING: 488. makeknown(WAN_LIGHTNING); 489. if (!Shock_resistance) { 490. pline("Idiot! You've shocked yourself!"); 491. damage = d(12,6); 492. } else { 493. shieldeff(u.ux, u.uy); 494. You("zap yourself, but seem unharmed."); 495. #ifdef POLYSELF 496. #ifdef GOLEMS 497. ugolemeffects(AD_ELEC, d(12,6)); 498. #endif /* GOLEMS */ 499. #endif 500. } 501. if(!Blind) { 502. You("are blinded by the flash!"); 503. make_blinded((long)rnd(100),FALSE); 504. } 505. break; 506. case WAN_FIRE: 507. makeknown(WAN_FIRE); 508. #ifdef SPELLS 509. case SPE_FIREBALL: 510. #endif 511. #ifdef MUSIC 512. case FIRE_HORN: 513. #endif 514. pline("You've set light to yourself!"); 515. if (Fire_resistance) { 516. shieldeff(u.ux, u.uy); 517. You("feel mildly hot."); 518. #ifdef POLYSELF 519. #ifdef GOLEMS 520. ugolemeffects(AD_FIRE, d(12,6)); 521. #endif /* GOLEMS */ 522. #endif 523. } else 524. damage = d(12,6); 525. destroy_item(SCROLL_SYM, AD_FIRE); 526. destroy_item(POTION_SYM, AD_FIRE); 527. #ifdef SPELLS 528. destroy_item(SPBOOK_SYM, AD_FIRE); 529. #endif 530. break; 531. case WAN_COLD: 532. makeknown(WAN_COLD); 533. #ifdef SPELLS 534. case SPE_CONE_OF_COLD: 535. #endif 536. #ifdef MUSIC 537. case FROST_HORN: 538. #endif 539. if (Cold_resistance) { 540. shieldeff(u.ux, u.uy); 541. You("feel mildly chilly."); 542. #ifdef POLYSELF 543. #ifdef GOLEMS 544. ugolemeffects(AD_COLD, d(12,6)); 545. #endif /* GOLEMS */ 546. #endif 547. } else { 548. You("imitate a popsicle!"); 549. damage = d(12,6); 550. } 551. destroy_item(POTION_SYM, AD_COLD); 552. break; 553. case WAN_MAGIC_MISSILE: 554. makeknown(WAN_MAGIC_MISSILE); 555. #ifdef SPELLS 556. case SPE_MAGIC_MISSILE: 557. #endif 558. if(Antimagic) { 559. shieldeff(u.ux, u.uy); 560. pline("The missiles bounce!"); 561. } else { 562. damage = d(4,6); 563. pline("Idiot! You've shot yourself!"); 564. } 565. break; 566. case WAN_POLYMORPH: 567. #ifdef POLYSELF 568. makeknown(WAN_POLYMORPH); 569. #endif 570. #ifdef SPELLS 571. case SPE_POLYMORPH: 572. #endif 573. #ifdef POLYSELF 574. polyself(); 575. #else 576. You("shudder for a moment."); 577. #endif 578. break; 579. case WAN_CANCELLATION: 580. #ifdef SPELLS 581. case SPE_CANCELLATION: 582. #endif 583. #ifdef POLYSELF 584. #ifdef GOLEMS 585. if (u.umonnum == PM_CLAY_GOLEM) { 586. if (!Blind) 587. pline("Some writing vanishes from your head!"); 588. rehumanize(); 589. break; 590. } 591. #endif /* GOLEMS */ 592. #endif 593. for(otmp = invent; otmp; otmp = otmp->nobj) 594. cancel_item(otmp); 595. #ifdef POLYSELF 596. if(u.mtimedone) rehumanize(); 597. #endif 598. flags.botl = 1; /* because of potential AC change */ 599. find_ac(); 600. break; 601. case WAN_MAKE_INVISIBLE: 602. if (!Invisible) makeknown(WAN_MAKE_INVISIBLE); 603. HInvis |= INTRINSIC; 604. if (!See_invisible) newsym(u.ux, u.uy); 605. break; 606. case WAN_SPEED_MONSTER: 607. if (!(Fast & INTRINSIC)) { 608. Fast |= INTRINSIC; 609. You("seem to be moving faster."); 610. makeknown(WAN_SPEED_MONSTER); 611. } 612. break; 613. case WAN_SLEEP: 614. makeknown(WAN_SLEEP); 615. #ifdef SPELLS 616. case SPE_SLEEP: 617. #endif 618. if(Sleep_resistance) { 619. shieldeff(u.ux, u.uy); 620. You("don't feel sleepy!"); 621. } else { 622. pline("The sleep ray hits you!"); 623. nomul(-rn2(50)); 624. } 625. break; 626. case WAN_SLOW_MONSTER: 627. #ifdef SPELLS 628. case SPE_SLOW_MONSTER: 629. #endif 630. if(Fast & (TIMEOUT | INTRINSIC)) { 631. Fast &= ~(TIMEOUT | INTRINSIC); 632. You("seem to be moving slower."); 633. } 634. break; 635. case WAN_TELEPORTATION: 636. #ifdef SPELLS 637. case SPE_TELEPORT_AWAY: 638. #endif 639. tele(); 640. break; 641. case WAN_DEATH: 642. #ifdef SPELLS 643. case SPE_FINGER_OF_DEATH: 644. #endif 645. #ifdef POLYSELF 646. if (is_undead(uasmon)) { 647. pline((obj->otyp == WAN_DEATH) ? 648. "The wand shoots an apparently harmless beam at you." 649. : "You seem no deader than before."); 650. break; 651. } 652. #endif 653. killer = "death ray"; 654. You("irradiate yourself with pure energy!"); 655. You("die."); 656. makeknown(WAN_DEATH); 657. /* They might survive with an amulet of life saving */ 658. done("died"); 659. break; 660. #ifdef SPELLS 661. case SPE_TURN_UNDEAD: 662. #endif 663. case WAN_UNDEAD_TURNING: 664. #ifdef POLYSELF 665. if (is_undead(uasmon)) { 666. Printf("You feel frightened and %sstunned.", 667. Stunned ? "even more " : ""); 668. make_stunned(HStun + rnd(30), FALSE); 669. } 670. #endif 671. break; 672. #ifdef SPELLS 673. case SPE_DIG: 674. case SPE_DETECT_UNSEEN: 675. #endif 676. case WAN_DIGGING: 677. case WAN_NOTHING: 678. case WAN_OPENING: 679. case WAN_LOCKING: 680. #ifdef SPELLS 681. case SPE_KNOCK: 682. case SPE_WIZARD_LOCK: 683. #endif 684. break; 685. #ifdef PROBING 686. case WAN_PROBING: 687. makeknown(WAN_PROBING); 688. ustatusline(); 689. break; 690. #endif 691. default: impossible("object %d used?",obj->otyp); 692. } 693. return(damage); 694. } 695. 696. /* called for various wand and spell effects - M. Stephenson */ 697. void 698. weffects(obj) 699. register struct obj *obj; 700. { 701. xchar zx,zy; 702. 703. if(objects[obj->otyp].bits & IMMEDIATE) { 704. if(u.uswallow) (void)bhitm(u.ustuck, obj); 705. else if(u.dz) { 706. if(u.dz > 0 && levl[u.ux][u.uy].omask) { 707. register struct obj *otmp,*otmp2; 708. 709. /* changed by GAN to hit all objects there */ 710. for(otmp = fobj; otmp ; otmp = otmp2) { 711. otmp2 = otmp->nobj; 712. /* save pointer as bhito may destroy otmp */ 713. if(otmp->ox == u.ux && otmp->oy == u.uy) 714. (void) bhito(otmp, obj); 715. } 716. } 717. } else if((obj->otyp == WAN_OPENING) || 718. #ifdef SPELLS 719. (obj->otyp == SPE_KNOCK) || 720. (obj->otyp == SPE_WIZARD_LOCK) || 721. #endif 722. (obj->otyp == WAN_LOCKING)) { 723. (void)bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj); 724. #ifdef STRONGHOLD 725. } else if(obj->otyp == WAN_STRIKING 726. #ifdef SPELLS 727. || obj->otyp == SPE_FORCE_BOLT 728. #endif /* SPELLS /**/ 729. ) { 730. int x,y; 731. x = u.ux + u.dx; 732. y = u.uy + u.dy; 733. if (find_drawbridge(&x,&y)) 734. destroy_drawbridge(x,y); 735. 736. else (void) bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj); 737. #endif /* STRONGHOLD /**/ 738. } else (void) bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj); 739. } else { 740. switch(obj->otyp){ 741. case WAN_LIGHT: 742. #ifdef SPELLS 743. case SPE_LIGHT: 744. #endif 745. litroom(TRUE); 746. break; 747. case WAN_SECRET_DOOR_DETECTION: 748. #ifdef SPELLS 749. case SPE_DETECT_UNSEEN: 750. #endif 751. if(!findit()) return; 752. break; 753. case WAN_CREATE_MONSTER: 754. { register int cnt = 1; 755. if(!rn2(23)) cnt += rn2(7) + 1; 756. while(cnt--) 757. (void) makemon((struct permonst *) 0, u.ux, u.uy); 758. } 759. break; 760. case WAN_WISHING: 761. if(u.uluck + rn2(5) < 0) { 762. pline("Unfortunately, nothing happens."); 763. break; 764. } 765. makewish(); 766. break; 767. case WAN_DIGGING: 768. #ifdef SPELLS 769. case SPE_DIG: 770. #endif 771. /* Original effect (approximately): 772. * from CORR: dig until we pierce a wall 773. * from ROOM: piece wall and dig until we reach 774. * an ACCESSIBLE place. 775. * Currently: dig for digdepth positions; 776. * also down on request of Lennart Augustsson. 777. */ 778. { register struct rm *room; 779. register int digdepth,dlx,dly; 780. register boolean shopdoor = FALSE; 781. if(u.uswallow) { 782. register struct monst *mtmp = u.ustuck; 783. 784. You("pierce %s's stomach wall!", 785. mon_nam(mtmp)); 786. mtmp->mhp = 1; /* almost dead */ 787. unstuck(mtmp); 788. mnexto(mtmp); 789. break; 790. } 791. if(u.dz) { 792. if(u.dz < 0) { 793. You("loosen a rock from the ceiling."); 794. pline("It falls on your %s!", 795. body_part(HEAD)); 796. losehp(1, "falling rock"); 797. (void) mksobj_at((int)ROCK, u.ux, u.uy); 798. fobj->quan = 1; 799. stackobj(fobj); 800. if(Invisible) newsym(u.ux, u.uy); 801. } else { 802. dighole(); 803. } 804. break; 805. } 806. zx = u.ux+u.dx; 807. zy = u.uy+u.dy; 808. digdepth = 8 + rn2(18); 809. Tmp_at2(-1, '*'); /* open call */ 810. while(--digdepth >= 0) { 811. if(!isok(zx,zy)) break; 812. room = &levl[zx][zy]; 813. Tmp_at2(zx,zy); 814. if(is_maze_lev) { 815. if(IS_WALL(room->typ)) { 816. if(room->diggable == W_DIGGABLE) 817. room->typ = ROOM; 818. else if(!Blind) 819. pline("The wall glows then fades."); 820. break; 821. } 822. if(room->typ == STONE) { 823. if(room->diggable == W_DIGGABLE) 824. room->typ = CORR; 825. else if (!Blind) 826. pline("The rock glows then fades."); 827. break; 828. } 829. } else 830. if(IS_ROCK(room->typ)) 831. if(may_dig(zx,zy)) 832. if(IS_WALL(room->typ) || 833. room->typ == SDOOR) { 834. room->typ = DOOR; 835. room->doormask = D_NODOOR; 836. if(in_shop(zx,zy)) { 837. shopdoor = TRUE; 838. dlx = zx; 839. dly = zy; 840. } 841. digdepth -= 2; 842. } else { 843. room->typ = CORR; 844. digdepth--; 845. } 846. else 847. break; 848. else if(room->typ == DOOR && 849. (room->doormask & (D_LOCKED | D_CLOSED))) { 850. room->doormask = D_NODOOR; 851. if(in_shop(zx,zy)) { 852. shopdoor = TRUE; 853. dlx = zx; 854. dly = zy; 855. } 856. digdepth -= 2; 857. } 858. mnewsym(zx,zy); 859. zx += u.dx; 860. zy += u.dy; 861. } 862. mnewsym(zx,zy); /* not always necessary */ 863. Tmp_at2(-1,-1); /* closing call */ 864. if(shopdoor && !in_shop(u.ux, u.uy)) 865. pay_for_door(dlx, dly, "destroy"); 866. break; 867. } 868. default: 869. #ifdef SPELLS 870. if((int) obj->otyp >= SPE_MAGIC_MISSILE) { 871. 872. buzz((int) obj->otyp - SPE_MAGIC_MISSILE + 10, 873. (int)u.ulevel / 2 + 1, u.ux, u.uy, u.dx, u.dy); 874. } else 875. #endif 876. 877. buzz((int) obj->otyp - WAN_MAGIC_MISSILE, 6, 878. u.ux, u.uy, u.dx, u.dy); 879. break; 880. } 881. if(!objects[obj->otyp].oc_name_known) { 882. makeknown(obj->otyp); 883. more_experienced(0,10); 884. } 885. } 886. return; 887. } 888. 889. char * 890. exclam(force) 891. register int force; 892. { 893. /* force == 0 occurs e.g. with sleep ray */ 894. /* note that large force is usual with wands so that !! would 895. require information about hand/weapon/wand */ 896. return( (force < 0) ? "?" : (force <= 4) ? "." : "!" ); 897. } 898. 899. void 900. hit(str,mtmp,force) 901. register char *str; 902. register struct monst *mtmp; 903. register char *force; /* usually either "." or "!" */ 904. { 905. if(!cansee(mtmp->mx,mtmp->my) || !flags.verbose) pline("The %s hits it.", str); 906. else pline("The %s hits %s%s", str, mon_nam(mtmp), force); 907. } 908. 909. void 910. miss(str,mtmp) 911. register char *str; 912. register struct monst *mtmp; 913. { 914. pline("The %s misses %s.", str, 915. (cansee(mtmp->mx,mtmp->my) && flags.verbose) ? mon_nam(mtmp) : "it"); 916. } 917. 918. /* bhit: called when a weapon is thrown (sym = obj->olet) or when an 919. IMMEDIATE wand is zapped (sym = 0); the weapon falls down at end of 920. range or when a monster is hit; the monster is returned, and bhitpos 921. is set to the final position of the weapon thrown; the ray of a wand 922. may affect several objects and monsters on its path - for each of 923. these an argument function is called. */ 924. /* check !u.uswallow before calling bhit() */ 925. 926. struct monst * 927. bhit(ddx,ddy,range,sym,fhitm,fhito,obj) 928. register int ddx,ddy,range; /* direction and range */ 929. char sym; /* symbol displayed on path */ 930. int (*fhitm)(), (*fhito)(); /* fns called when mon/obj hit */ 931. struct obj *obj; /* 2nd arg to fhitm/fhito */ 932. { 933. register struct monst *mtmp; 934. register struct obj *otmp; 935. register int typ; 936. 937. bhitpos.x = u.ux; 938. bhitpos.y = u.uy; 939. 940. if(sym) { 941. tmp_at(-1, sym); /* open call */ 942. tmp_at(-3, (int)AT_OBJ); 943. } 944. while(range-- > 0) { 945. bhitpos.x += ddx; 946. bhitpos.y += ddy; 947. typ = levl[bhitpos.x][bhitpos.y].typ; 948. #ifdef STRONGHOLD 949. if(IS_DRAWBRIDGE(typ)) 950. switch (obj->otyp) { 951. case WAN_OPENING: 952. # ifdef SPELLS 953. case SPE_KNOCK: 954. # endif 955. (void) open_drawbridge(bhitpos.x,bhitpos.y); 956. break; 957. case WAN_LOCKING: 958. # ifdef SPELLS 959. case SPE_WIZARD_LOCK: 960. # endif 961. (void) close_drawbridge(bhitpos.x,bhitpos.y); 962. } 963. #endif /* STRONGHOLD /**/ 964. if(levl[bhitpos.x][bhitpos.y].mmask){ 965. mtmp = m_at(bhitpos.x,bhitpos.y); 966. if(sym) { 967. tmp_at(-1, -1); /* close call */ 968. return(mtmp); 969. } 970. (*fhitm)(mtmp, obj); 971. range -= 3; 972. } 973. /* modified by GAN to hit all objects */ 974. if(fhito && levl[bhitpos.x][bhitpos.y].omask){ 975. int hitanything = 0; 976. otmp = fobj; 977. /* Fix for polymorph bug, Tim Wright */ 978. while(otmp) { /* was a "for" loop. */ 979. register struct obj *next_obj; 980. 981. next_obj = otmp->nobj; 982. if(otmp->ox == bhitpos.x && otmp->oy == bhitpos.y) 983. hitanything += (*fhito)(otmp, obj); 984. otmp = next_obj; 985. } 986. if(hitanything) range--; 987. } 988. if(IS_DOOR(typ) || typ == SDOOR) { 989. switch (obj->otyp) { 990. case WAN_OPENING: 991. case WAN_LOCKING: 992. #ifdef SPELLS 993. case SPE_KNOCK: 994. case SPE_WIZARD_LOCK: 995. #endif 996. if (doorlock(obj,bhitpos.x,bhitpos.y)) 997. makeknown(obj->otyp); 998. break; 999. } 1000. } 1001. if(!ZAP_POS(typ) || (IS_DOOR(typ) && 1002. (levl[bhitpos.x][bhitpos.y].doormask & (D_LOCKED | D_CLOSED))) 1003. ) { 1004. bhitpos.x -= ddx; 1005. bhitpos.y -= ddy; 1006. break; 1007. } 1008. if(sym) tmp_at(bhitpos.x, bhitpos.y); 1009. #ifdef SINKS 1010. if(sym && IS_SINK(typ)) 1011. break; /* physical objects fall onto sink */ 1012. #endif 1013. } 1014. 1015. /* leave last symbol unless in a pool */ 1016. if(sym) 1017. tmp_at(-1, is_pool(bhitpos.x,bhitpos.y) ? -1 : 0); 1018. return (struct monst *)0; 1019. } 1020. 1021. struct monst * 1022. boomhit(dx, dy) 1023. int dx, dy; 1024. { 1025. register int i, ct; 1026. char sym = ')'; 1027. 1028. bhitpos.x = u.ux; 1029. bhitpos.y = u.uy; 1030. 1031. for(i=0; i<8; i++) if(xdir[i] == dx && ydir[i] == dy) break; 1032. tmp_at(-1, sym); /* open call */ 1033. tmp_at(-3, (int)AT_OBJ); 1034. for(ct=0; ct<10; ct++) { 1035. if(i == 8) i = 0; 1036. sym = ')' + '(' - sym; 1037. tmp_at(-2, sym); /* change let call */ 1038. dx = xdir[i]; 1039. dy = ydir[i]; 1040. bhitpos.x += dx; 1041. bhitpos.y += dy; 1042. if(levl[bhitpos.x][bhitpos.y].mmask){ 1043. tmp_at(-1,-1); 1044. return(m_at(bhitpos.x,bhitpos.y)); 1045. } 1046. if(!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)) { 1047. bhitpos.x -= dx; 1048. bhitpos.y -= dy; 1049. break; 1050. } 1051. if(bhitpos.x == u.ux && bhitpos.y == u.uy) { /* ct == 9 */ 1052. if(rn2(20) >= ACURR(A_DEX)){ /* we hit ourselves */ 1053. (void) thitu(10, rnd(10), "boomerang"); 1054. break; 1055. } else { /* we catch it */ 1056. tmp_at(-1,-1); 1057. pline("Skillfully, you catch the boomerang."); 1058. return(&youmonst); 1059. } 1060. } 1061. tmp_at(bhitpos.x, bhitpos.y); 1062. if(ct % 5 != 0) i++; 1063. #ifdef SINKS 1064. if(IS_SINK(levl[bhitpos.x][bhitpos.y].typ)) 1065. break; /* boomerang falls on sink */ 1066. #endif 1067. } 1068. tmp_at(-1, -1); /* do not leave last symbol */ 1069. return (struct monst *)0; 1070. } 1071. 1072. static uchar 1073. dirlet(dx, dy) 1074. register int dx, dy; 1075. { 1076. return 1077. (dx == dy) ? LSLANT_SYM : 1078. (dx && dy) ? RSLANT_SYM : 1079. dx ? HBEAM_SYM : VBEAM_SYM; 1080. } 1081. 1082. static int 1083. zhit(mon, type, nd) /* returns damage to mon */ 1084. register struct monst *mon; 1085. register int type, nd; 1086. { 1087. register int tmp = 0; 1088. register int abstype = abs(type) % 10; 1089. 1090. switch(abstype) { 1091. case 0: /* magic missile */ 1092. tmp = d(nd,6); 1093. break; 1094. case 1: /* fire */ 1095. if(resists_fire(mon->data)) { 1096. shieldeff(mon->mx, mon->my); 1097. break; 1098. } 1099. tmp = d(nd,6); 1100. if(resists_cold(mon->data)) tmp += 7; 1101. break; 1102. case 2: /* sleep */ 1103. tmp = 0; 1104. if(resists_sleep(mon->data) || 1105. resist(mon, (type == 2) ? WAND_SYM : '\0', 0, NOTELL)) 1106. shieldeff(mon->mx, mon->my); 1107. else mon->mfroz = 1; 1108. break; 1109. case 3: /* cold */ 1110. if(resists_cold(mon->data)) { 1111. shieldeff(mon->mx, mon->my); 1112. break; 1113. } 1114. tmp = d(nd,6); 1115. if(resists_fire(mon->data)) tmp += d(nd, 3); 1116. break; 1117. case 4: /* death/disintegration */ 1118. if(abs(type) != 24) { /* death */ 1119. if(is_undead(mon->data)) { 1120. shieldeff(mon->mx, mon->my); 1121. break; 1122. } 1123. type = 0; /* so they don't get saving throws */ 1124. } 1125. tmp = mon->mhp+1; 1126. break; 1127. case 5: /* lightning */ 1128. if(resists_elec(mon->data)) { 1129. shieldeff(mon->mx, mon->my); 1130. break; 1131. } 1132. tmp = d(nd,6); 1133. { 1134. register unsigned rnd_tmp = rnd(50); 1135. mon->mcansee = 0; 1136. if((mon->mblinded + rnd_tmp) > 127) 1137. mon->mblinded = 127; 1138. else mon->mblinded += rnd_tmp; 1139. } 1140. break; 1141. case 6: /* poison */ 1142. if(resists_poison(mon->data)) { 1143. shieldeff(mon->mx, mon->my); 1144. break; 1145. } 1146. tmp = d(nd,6); 1147. break; 1148. case 7: /* acid */ 1149. if(resists_acid(mon->data)) { 1150. shieldeff(mon->mx, mon->my); 1151. break; 1152. } 1153. tmp = d(nd,6); 1154. break; 1155. } 1156. if (type >= 0) 1157. if (resist(mon, (type < 10) ? WAND_SYM : '\0', 0, NOTELL)) tmp /= 2; 1158. mon->mhp -= tmp; 1159. return(tmp); 1160. } 1161. 1162. /* 1163. * burn scrolls on floor at position x,y 1164. * return the number of scrolls burned 1165. */ 1166. static int 1167. burn_floor_scrolls(x, y) 1168. int x, y; 1169. { 1170. register struct obj *obj, *obj2; 1171. register int scrquan, i, cnt = 0; 1172. 1173. if(levl[x][y].omask) 1174. for(obj = fobj; obj; obj = obj2) { 1175. obj2 = obj->nobj; 1176. /* Bug fix - KAA */ 1177. if(obj->ox == x && obj->oy == y && obj->olet == SCROLL_SYM) { 1178. scrquan = obj->quan; 1179. for(i = 1; i <= scrquan ; i++) 1180. if(!rn2(3)) { 1181. cnt++; 1182. if(in_shop(u.ux, u.uy)) 1183. addtobill(obj, FALSE); 1184. useupf(obj); 1185. } 1186. } 1187. } 1188. return(cnt); 1189. } 1190. 1191. /* type == 0 to 9 : you shooting a wand */ 1192. /* type == 10 to 19 : you casting a spell */ 1193. /* type == 20 to 29 : you breathing as a monster */ 1194. /* type == -10 to -19 : monster casting spell */ 1195. /* type == -20 to -29 : monster breathing at you */ 1196. /* called with dx = dy = 0 with vertical bolts */ 1197. void 1198. buzz(type,nd,sx,sy,dx,dy) 1199. register int type, nd; 1200. register xchar sx,sy; 1201. register int dx,dy; 1202. { 1203. int abstype = abs(type) % 10; 1204. register char *fltxt = fl[abs(type)]; 1205. struct rm *lev; 1206. xchar range, olx, oly; 1207. struct monst *mon; 1208. register boolean bodyhit = FALSE; 1209. register boolean shopdoor = FALSE; 1210. 1211. if(u.uswallow) { 1212. register int tmp; 1213. 1214. if(type < 0) return; 1215. tmp = zhit(u.ustuck, type, nd); 1216. if(!u.ustuck) u.uswallow = 0; 1217. else pline("The %s rips into %s%s", 1218. fltxt, mon_nam(u.ustuck), exclam(tmp)); 1219. if (u.ustuck->mhp < 1) 1220. killed(u.ustuck); 1221. return; 1222. } 1223. if(type < 0) pru(); 1224. range = rn1(7,7); 1225. Tmp_at2(-1, (int) dirlet(dx,dy)); /* open call */ 1226. #ifdef MSDOSCOLOR 1227. Tmp_at2(-3, (int)(abstype == 1 ? AT_RED : /* fire */ 1228. abstype == 3 || abstype == 5 ? AT_WHITE : /* cold/elec */ 1229. AT_ZAP); 1230. #endif 1231. while(range-- > 0) { 1232. sx += dx; 1233. sy += dy; 1234. if((lev = &levl[sx][sy])->typ) Tmp_at2(sx,sy); 1235. else { 1236. int bounce = 0; 1237. if(cansee(sx-dx,sy-dy)) 1238. pline("The %s bounces!", fltxt); 1239. if(ZAP_POS(levl[sx][sy-dy].typ)) 1240. bounce = 1; 1241. if(ZAP_POS(levl[sx-dx][sy].typ)) { 1242. if(!bounce || rn2(2)) bounce = 2; 1243. } 1244. switch(bounce){ 1245. case 0: 1246. dx = -dx; 1247. dy = -dy; 1248. continue; 1249. case 1: 1250. dy = -dy; 1251. sx -= dx; 1252. break; 1253. case 2: 1254. dx = -dx; 1255. sy -= dy; 1256. break; 1257. } 1258. Tmp_at2(-2,(int) dirlet(dx,dy)); 1259. continue; 1260. } 1261. if(is_pool(sx,sy) && abstype == 1 /* fire */) { 1262. #ifdef STRONGHOLD 1263. if(lev->typ != POOL) { /* MOAT or DRAWBRIDGE_UP */ 1264. if(cansee(sx,sy)) 1265. pline("Some water evaporates."); 1266. else if(flags.soundok) 1267. You("hear a hissing sound."); 1268. } else { 1269. #endif 1270. register struct trap *ttmp; 1271. 1272. range -= 3; 1273. lev->typ = ROOM; 1274. mnewsym(sx,sy); 1275. if(cansee(sx,sy)) pline("The water evaporates."); 1276. else if(flags.soundok) 1277. You("hear a hissing sound."); 1278. ttmp = maketrap(sx, sy, PIT); 1279. ttmp->tseen = 1; 1280. #ifdef STRONGHOLD 1281. } 1282. #endif 1283. } 1284. if(is_pool(sx,sy) && abstype == 3 /* cold */) { 1285. boolean moat = (lev->typ != POOL); 1286. 1287. range -= 3; 1288. #ifdef STRONGHOLD 1289. if(lev->typ == DRAWBRIDGE_UP) 1290. lev->drawbridgemask |= DB_FLOOR; 1291. else 1292. #endif 1293. lev->typ = ROOM; 1294. mnewsym(sx,sy); 1295. if(cansee(sx,sy)) { 1296. if(moat) 1297. pline("The moat is bridged with ice!"); 1298. else pline("The water freezes."); 1299. } else if(flags.soundok) 1300. You("hear a crackling sound."); 1301. } 1302. if(IS_DOOR(lev->typ) && (lev->doormask & (D_LOCKED | D_CLOSED))) { 1303. range = 0; 1304. switch(abstype) { 1305. case 1: 1306. lev->doormask = D_NODOOR; 1307. if(cansee(sx,sy)) 1308. pline("The door is consumed in flames!"); 1309. else You("smell smoke."); 1310. if(type >= 0 && in_shop(sx, sy)) { 1311. shopdoor = TRUE; 1312. olx = sx; 1313. oly = sy; 1314. } 1315. break; 1316. case 3: 1317. lev->doormask = D_NODOOR; 1318. if(cansee(sx,sy)) 1319. pline("The door freezes and shatters!"); 1320. else You("feel cold."); 1321. if(type >= 0 && in_shop(sx, sy)) { 1322. shopdoor = TRUE; 1323. olx = sx; 1324. oly = sy; 1325. } 1326. break; 1327. case 4: 1328. lev->doormask = D_NODOOR; 1329. if(cansee(sx,sy)) 1330. pline("The door disintegrates!"); 1331. else if(flags.soundok) 1332. You("hear a crashing sound."); 1333. if(type >= 0 && in_shop(sx, sy)) { 1334. shopdoor = TRUE; 1335. olx = sx; 1336. oly = sy; 1337. } 1338. break; 1339. case 5: 1340. lev->doormask = D_BROKEN; 1341. if(cansee(sx,sy)) 1342. pline("The door splinters!"); 1343. else if(flags.soundok) 1344. You("hear a crackling sound."); 1345. if(type >= 0 && in_shop(sx, sy)) { 1346. shopdoor = TRUE; 1347. olx = sx; 1348. oly = sy; 1349. } 1350. break; 1351. default: 1352. if(cansee(sx,sy)) { 1353. if (type >= 0 && type <= 9) 1354. pline("The door absorbs your bolt!"); 1355. else if (type >= 10 && type <= 19) 1356. pline("The door absorbs your spell!"); 1357. #ifdef POLYSELF 1358. else if (type >= 20 && type <= 29) 1359. pline("The door absorbs your blast!"); 1360. #endif 1361. else if (type >= -19 && type <= -10) 1362. pline("The door absorbs the spell!"); 1363. else 1364. pline("The door absorbs the blast!"); 1365. } else You("feel vibrations."); 1366. break; 1367. } 1368. } 1369. if(levl[sx][sy].omask && abstype == 1) 1370. if(burn_floor_scrolls(sx,sy) && cansee(sx,sy)) { 1371. mnewsym(sx,sy); 1372. if(!Blind) 1373. You("see a puff of smoke."); 1374. } 1375. if(levl[sx][sy].mmask){ 1376. mon = m_at(sx,sy); 1377. /* Cannot use wakeup() which also angers the monster */ 1378. mon->msleep = 0; 1379. if(mon->mimic) seemimic(mon); 1380. if(type >= 0) { 1381. setmangry(mon); 1382. #if defined(ALTARS) && defined(THEOLOGY) 1383. if(mon->ispriest && in_temple(mon->mx, mon->my)) 1384. priesthit = TRUE; 1385. #endif 1386. } 1387. if(rnd(20) < 18 + mon->data->ac) { 1388. register int tmp = zhit(mon, type, nd); 1389. if(mon->mhp < 1) { 1390. if(type < 0) { 1391. if(cansee(mon->mx,mon->my)) 1392. pline("%s is killed by the %s!", 1393. Monnam(mon), fltxt); 1394. mondied(mon); 1395. } else 1396. killed(mon); 1397. } else 1398. hit(fltxt, mon, exclam(tmp)); 1399. range -= 2; 1400. } else 1401. miss(fltxt,mon); 1402. } else if(sx == u.ux && sy == u.uy) { 1403. nomul(0); 1404. if(rnd(20) < 18+u.uac) { 1405. register int dam = 0; 1406. range -= 2; 1407. pline("The %s hits you!",fltxt); 1408. if (Reflecting) { 1409. if (!Blind) { 1410. if(Reflecting & WORN_AMUL) 1411. makeknown(AMULET_OF_REFLECTION); 1412. else 1413. makeknown(SHIELD_OF_REFLECTION); 1414. pline("But it reflects from your %s!", 1415. (Reflecting & W_AMUL) ? "amulet" : "shield"); 1416. } else 1417. pline("For some reason you are not affected!"); 1418. if (dx) dx = -dx; 1419. if (dy) dy = -dy; 1420. shieldeff(sx, sy); 1421. } 1422. else switch(abstype) { 1423. case 0: /* magic missile */ 1424. if(Antimagic) { 1425. shieldeff(sx, sy); 1426. pline("The missiles bounce off!"); 1427. } else dam = d(nd,6); 1428. break; 1429. case 1: /* fire */ 1430. if(Fire_resistance) { 1431. shieldeff(sx, sy); 1432. You("don't feel hot!"); 1433. #ifdef POLYSELF 1434. #ifdef GOLEMS 1435. ugolemeffects(AD_FIRE, d(nd, 6)); 1436. #endif /* GOLEMS */ 1437. #endif 1438. } else dam = d(nd, 6); 1439. while (1) { 1440. switch(rn2(5)) { 1441. case 0: 1442. if (!rust_dmg(uarmh, "leather helmet", 0, FALSE)) continue; 1443. break; 1444. case 1: 1445. bodyhit = TRUE; 1446. if (uarmc) break; 1447. (void)(rust_dmg(uarm, "leather armor", 0, FALSE)); 1448. break; 1449. case 2: 1450. if (!rust_dmg(uarms, "wooden shield", 0, FALSE)) continue; 1451. break; 1452. case 3: 1453. if (!rust_dmg(uarmg, "gloves", 0, FALSE)) continue; 1454. break; 1455. case 4: 1456. if (!rust_dmg(uarmf, "boots", 0, FALSE)) continue; 1457. break; 1458. } 1459. break; /* Out of while loop */ 1460. } 1461. if(!rn2(3) && bodyhit) 1462. destroy_item(POTION_SYM, AD_FIRE); 1463. if(!rn2(3) && bodyhit) 1464. destroy_item(SCROLL_SYM, AD_FIRE); 1465. #ifdef SPELLS 1466. if(!rn2(5) && bodyhit) 1467. destroy_item(SPBOOK_SYM, AD_FIRE); 1468. #endif 1469. break; 1470. case 2: /* sleep */ 1471. if(Sleep_resistance) { 1472. shieldeff(u.ux, u.uy); 1473. You("don't feel sleepy."); 1474. } else nomul(-d(nd,25)); /* sleep ray */ 1475. break; 1476. case 3: /* cold */ 1477. if(Cold_resistance) { 1478. shieldeff(sx, sy); 1479. You("don't feel cold."); 1480. #ifdef POLYSELF 1481. #ifdef GOLEMS 1482. ugolemeffects(AD_COLD, d(nd, 6)); 1483. #endif /* GOLEMS */ 1484. #endif 1485. } else 1486. dam = d(nd, 6); 1487. if(!rn2(3)) 1488. destroy_item(POTION_SYM, AD_COLD); 1489. break; 1490. case 4: /* death */ 1491. if(type == -24) { /* disintegration */ 1492. if(uarms) { 1493. (void) destroy_arm(uarms); 1494. } else if (uarm) { 1495. if (Disint_resistance & WORN_ARMOR) 1496. Your("armor absorbs the blast!"); 1497. else (void) destroy_arm(uarm); 1498. } 1499. break; 1500. } 1501. #ifdef POLYSELF 1502. else if(is_undead(uasmon)) { 1503. shieldeff(sx, sy); 1504. You("seem unaffected."); 1505. break; 1506. } 1507. #endif 1508. u.uhp = -1; 1509. break; 1510. case 5: /* lightning */ 1511. if (Shock_resistance) { 1512. shieldeff(sx, sy); 1513. You("aren't affected."); 1514. #ifdef POLYSELF 1515. #ifdef GOLEMS 1516. ugolemeffects(AD_ELEC, d(nd, 6)); 1517. #endif /* GOLEMS */ 1518. #endif 1519. } else 1520. dam = d(nd, 6); 1521. break; 1522. case 6: /* poison */ 1523. poisoned("blast", A_DEX, "poisoned blast"); 1524. break; 1525. case 7: /* acid */ 1526. pline("The acid burns!"); 1527. dam = d(nd,6); 1528. if(!rn2(6)) corrode_weapon(); 1529. if(!rn2(6)) corrode_armor(); 1530. break; 1531. } 1532. losehp(dam,fltxt); 1533. } else pline("The %s whizzes by you!",fltxt); 1534. if (abstype == 5 && !Blind) { /* LIGHTNING */ 1535. You("are blinded by the flash!"); 1536. make_blinded((long)d(nd,50),FALSE); 1537. seeoff(0); 1538. } 1539. stop_occupation(); 1540. } 1541. if(!ZAP_POS(lev->typ)) { 1542. int bounce = 0, rmn; 1543. if(cansee(sx,sy)) pline("The %s bounces!", fltxt); 1544. range--; 1545. if(!dx || !dy || !rn2(20)){ 1546. dx = -dx; 1547. dy = -dy; 1548. } else { 1549. if(ZAP_POS(rmn = levl[sx][sy-dy].typ) && 1550. (IS_ROOM(rmn) || ZAP_POS(levl[sx+dx][sy-dy].typ))) 1551. bounce = 1; 1552. if(ZAP_POS(rmn = levl[sx-dx][sy].typ) && 1553. (IS_ROOM(rmn) || ZAP_POS(levl[sx-dx][sy+dy].typ))) 1554. if(!bounce || rn2(2)) 1555. bounce = 2; 1556. 1557. switch(bounce){ 1558. case 0: 1559. dy = -dy; 1560. dx = -dx; 1561. break; 1562. case 1: 1563. dy = -dy; 1564. break; 1565. case 2: 1566. dx = -dx; 1567. break; 1568. } 1569. Tmp_at2(-2, (int) dirlet(dx,dy)); 1570. } 1571. } 1572. } 1573. Tmp_at2(-1,-1); 1574. if(shopdoor && !in_shop(u.ux, u.uy)) 1575. pay_for_door(olx, oly, abstype == 1 ? "burn away" : 1576. abstype == 3 ? "shatter" : 1577. abstype == 4 ? "disintegrate" : 1578. "destroy"); 1579. } 1580. 1581. void 1582. rloco(obj) 1583. register struct obj *obj; 1584. { 1585. register int tx, ty, otx, oty; 1586. 1587. otx = obj->ox; 1588. oty = obj->oy; 1589. do { 1590. tx = rn1(COLNO-3,2); 1591. ty = rn2(ROWNO); 1592. } while(!goodpos(tx,ty)); 1593. obj->ox = tx; 1594. obj->oy = ty; 1595. set_omask(otx,oty); 1596. if(cansee(otx,oty)) 1597. newsym(otx,oty); 1598. levl[tx][ty].omask = 1; 1599. if(cansee(tx,ty)) 1600. newsym(tx,ty); 1601. } 1602. 1603. void 1604. fracture_rock(obj) /* fractured by pick-axe or wand of striking */ 1605. register struct obj *obj; /* no texts here! */ 1606. { 1607. /* unpobj(obj); */ 1608. obj->otyp = ROCK; 1609. obj->blessed = FALSE; 1610. obj->quan = 7 + rn2(60); 1611. obj->owt = weight(obj); 1612. obj->olet = GEM_SYM; 1613. obj->known = FALSE; 1614. if(cansee(obj->ox,obj->oy)) 1615. prl(obj->ox,obj->oy); 1616. } 1617. 1618. boolean 1619. break_statue(obj) 1620. register struct obj *obj; 1621. { 1622. struct trap *trap; 1623. 1624. if(trap = t_at(obj->ox,obj->oy)) 1625. if(obj->corpsenm == trap->pm) 1626. if(makemon(&mons[trap->pm], obj->ox, obj->oy)) { 1627. pline("Instead of shattering, the statue suddenly comes alive!"); 1628. delobj(obj); 1629. deltrap(trap); 1630. return FALSE; 1631. } 1632. if (obj->spe) { 1633. struct obj *magazine; 1634. #ifdef SPELLS 1635. magazine = mkobj_at(SPBOOK_SYM, obj->ox, obj->oy); 1636. #else 1637. magazine = mkobj_at(SCROLL_SYM, obj->ox, obj->oy); 1638. #endif 1639. magazine->blessed = obj->blessed; 1640. magazine->cursed = obj->cursed; 1641. } 1642. fracture_rock(obj); 1643. return TRUE; 1644. } 1645. 1646. const char *destroy_strings[] = { 1647. "freezes and shatters", "freeze and shatter", "shattered potion", 1648. "boils and explodes", "boil and explode", "boiling potion", 1649. "catches fire and burns", "catch fire and burn", "burning scroll", 1650. "catches fire and burns", "catch fire and burn", "burning book", 1651. "turns to dust and vanishes", "turn to dust and vanish", "", 1652. "breaks apart and explodes", "break apart and explode", "exploding wand" 1653. }; 1654. 1655. void 1656. destroy_item(osym, dmgtyp) 1657. register int osym, dmgtyp; 1658. { 1659. register struct obj *obj, *obj2; 1660. register int quan, i, cnt, dmg, xresist, skip; 1661. register int dindx; 1662. char *mult; 1663. 1664. for(obj = invent; obj; obj = obj2) { 1665. 1666. obj2 = obj->nobj; 1667. if(obj->olet != osym) continue; /* test only objs of type osym */ 1668. xresist = skip = 0; 1669. 1670. switch(dmgtyp) { 1671. case AD_COLD: 1672. if(osym == POTION_SYM) { 1673. quan = obj->quan; 1674. dindx = 0; 1675. dmg = rnd(4); 1676. } else skip++; 1677. break; 1678. case AD_FIRE: 1679. xresist = (Fire_resistance && obj->olet != POTION_SYM); 1680. 1681. /* Let's say scrolls of fire are fire resistant */ 1682. 1683. if (obj->otyp == SCR_FIRE) 1684. skip++; 1685. quan = obj->quan; 1686. switch(osym) { 1687. case POTION_SYM: 1688. dindx = 1; 1689. dmg = rnd(6); 1690. break; 1691. case SCROLL_SYM: 1692. dindx = 2; 1693. dmg = 1; 1694. break; 1695. #ifdef SPELLS 1696. case SPBOOK_SYM: 1697. dindx = 3; 1698. dmg = 1; 1699. break; 1700. #endif 1701. default: 1702. skip++; 1703. break; 1704. } 1705. break; 1706. case AD_ELEC: 1707. xresist = (Shock_resistance && obj->olet != RING_SYM); 1708. quan = obj->quan; 1709. switch(osym) { 1710. case RING_SYM: 1711. if(obj->otyp == RIN_SHOCK_RESISTANCE) 1712. { skip++; break; } 1713. dindx = 4; 1714. dmg = 0; 1715. break; 1716. case WAND_SYM: 1717. if(obj->otyp == WAN_LIGHTNING) { skip++; break; } 1718. dindx = 5; 1719. dmg = rnd(10); 1720. break; 1721. default: 1722. skip++; 1723. break; 1724. } 1725. break; 1726. default: 1727. skip++; 1728. break; 1729. } 1730. if(!skip) { 1731. for(i = cnt = 0; i < quan; i++) 1732. if(!rn2(3)) cnt++; 1733. 1734. if(!cnt) continue; 1735. if(cnt == quan) mult = "Your"; 1736. else mult = (cnt == 1) ? "One of your" : "Some of your"; 1737. pline("%s %s %s!", mult, xname(obj), 1738. (cnt > 1) ? destroy_strings[dindx*3 + 1] 1739. : destroy_strings[dindx*3]); 1740. if(osym == POTION_SYM && dmgtyp != AD_COLD) 1741. potionbreathe(obj); 1742. for(i = 0; i < cnt; i++) useup(obj); 1743. if(dmg) { 1744. if(xresist) You("aren't hurt!"); 1745. else losehp(dmg, destroy_strings[dindx*3 + 2]); 1746. } 1747. } 1748. } 1749. return; 1750. } 1751. 1752. int 1753. destroy_mitem(mtmp, osym, dmgtyp) 1754. register struct monst *mtmp; 1755. register int osym, dmgtyp; 1756. { 1757. register struct obj *obj, *obj2; 1758. register int quan, i, cnt, skip, tmp = 0; 1759. register int dindx; 1760. 1761. for(obj = mtmp->minvent; obj; obj = obj2) { 1762. 1763. obj2 = obj->nobj; 1764. if(obj->olet != osym) continue; /* test only objs of type osym */ 1765. skip = 0; 1766. 1767. switch(dmgtyp) { 1768. case AD_COLD: 1769. if(osym == POTION_SYM) { 1770. quan = obj->quan; 1771. dindx = 0; 1772. tmp++; 1773. } else skip++; 1774. break; 1775. case AD_FIRE: 1776. /* Let's say scrolls of fire are fire resistant */ 1777. 1778. if (obj->otyp == SCR_FIRE) 1779. skip++; 1780. quan = obj->quan; 1781. switch(osym) { 1782. case POTION_SYM: 1783. dindx = 1; 1784. tmp++; 1785. break; 1786. case SCROLL_SYM: 1787. dindx = 2; 1788. tmp++; 1789. break; 1790. #ifdef SPELLS 1791. case SPBOOK_SYM: 1792. dindx = 3; 1793. tmp++; 1794. break; 1795. #endif 1796. default: 1797. skip++; 1798. break; 1799. } 1800. break; 1801. case AD_ELEC: 1802. quan = obj->quan; 1803. switch(osym) { 1804. case RING_SYM: 1805. if(obj->otyp == RIN_SHOCK_RESISTANCE) 1806. { skip++; break; } 1807. dindx = 4; 1808. break; 1809. case WAND_SYM: 1810. if(obj->otyp == WAN_LIGHTNING) { skip++; break; } 1811. dindx = 5; 1812. tmp++; 1813. break; 1814. default: 1815. skip++; 1816. break; 1817. } 1818. break; 1819. default: 1820. skip++; 1821. break; 1822. } 1823. if(!skip) { 1824. for(i = cnt = 0; i < quan; i++) 1825. if(!rn2(3)) cnt++; 1826. 1827. if(!cnt) continue; 1828. pline("%s's %s %s!", Monnam(mtmp), xname(obj), 1829. (cnt > 1) ? destroy_strings[dindx*3 + 1] 1830. : destroy_strings[dindx*3]); 1831. for(i = 0; i < cnt; i++) m_useup(mtmp, obj); 1832. } 1833. } 1834. return(tmp); 1835. } 1836. 1837. /*ARGSUSED*/ 1838. int 1839. resist(mtmp, olet, damage, tell) 1840. register struct monst *mtmp; 1841. register char olet; 1842. register int damage, tell; 1843. { 1844. register int resisted = 0; 1845. #ifdef HARD 1846. register int level; 1847. 1848. switch(olet) { 1849. 1850. case WAND_SYM: 1851. level = 8; 1852. break; 1853. 1854. case SCROLL_SYM: 1855. level = 6; 1856. break; 1857. 1858. case POTION_SYM: 1859. level = 5; 1860. break; 1861. 1862. default: level = u.ulevel; 1863. break; 1864. } 1865. 1866. resisted = (rn2(100) - mtmp->m_lev + level) < mtmp->data->mr; 1867. if(resisted) { 1868. 1869. if(tell) { 1870. shieldeff(mtmp->mx, mtmp->my); 1871. pline("%s resists!", canseemon(mtmp) ? Monnam(mtmp) : "It"); 1872. } 1873. mtmp->mhp -= damage/2; 1874. } else 1875. #endif 1876. mtmp->mhp -= damage; 1877. 1878. if(mtmp->mhp < 1) killed(mtmp); 1879. return(resisted); 1880. } 1881. 1882. void 1883. makewish() 1884. { 1885. char buf[BUFSZ]; 1886. register struct obj *otmp; 1887. int wishquan, mergquan; 1888. register boolean dropit = (inv_cnt() >= 52); 1889. int tries = 0; 1890. 1891. retry: 1892. You("may wish for an object. What do you want? "); 1893. getlin(buf); 1894. if(buf[0] == '\033') buf[0] = 0; 1895. /* Note: if they wished for and got a non-object successfully, such as gold, 1896. * otmp = &zeroobj 1897. */ 1898. otmp = readobjnam(buf); 1899. if (!otmp) { 1900. pline("Nothing fitting that description exists in the game."); 1901. if (++tries < 5) goto retry; 1902. pline(thats_enough_tries); 1903. if (!(otmp = readobjnam((char *)0))) 1904. return; /* for safety; should never happen */ 1905. } 1906. if (otmp != &zeroobj) { 1907. if(dropit) { 1908. pline("Oops! The %s drop%s to the floor!", xname(otmp), 1909. otmp->quan > 1 ? "" : "s"); 1910. dropy(otmp); 1911. } else { 1912. wishquan = otmp->quan; 1913. otmp = addinv(otmp); 1914. mergquan = otmp->quan; 1915. otmp->quan = wishquan; /* to fool prinv() */ 1916. prinv(otmp); 1917. otmp->quan = mergquan; 1918. } 1919. #ifdef WIZARD 1920. if (!wizard) 1921. #endif 1922. if(otmp->otyp == WAN_WISHING) otmp->recharged = 1; 1923. 1924. #ifdef THEOLOGY 1925. u.ublesscnt += rn1(100,50); /* the gods take notice */ 1926. #endif 1927. } 1928. }
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