About: Source:NetHack 1.4f/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 1.4f. To link to a particular line, write [[NetHack 1.4f/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 1.4f/zap.c
rdfs:comment
  • Below is the full text to zap.c from the source code of NetHack 1.4f. To link to a particular line, write [[NetHack 1.4f/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 1.4f. To link to a particular line, write [[NetHack 1.4f/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 1.4 87/08/08 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* zap.c - version 1.0.3 */ 4. 5. #include "hack.h" 6. 7. extern struct obj *mkobj_at(); 8. extern struct monst *makemon(), *mkmon_at(), youmonst; 9. struct monst *bhit(); 10. char *exclam(); 11. #ifdef KAA 12. extern char *xname(); 13. #endif 14. 15. char *fl[]= { 16. "magic missile", 17. "bolt of fire", 18. "sleep ray", 19. "bolt of cold", 20. "death ray", 21. "magic missle", /* Spell equivalents of above wands */ 22. "fireball", 23. "sleep ray", 24. "cone of cold", 25. "finger of death" 26. }; 27. 28. /* Routines for IMMEDIATE wands and spells. */ 29. /* bhitm: monster mtmp was hit by the effect of wand or spell otmp */ 30. bhitm(mtmp, otmp) 31. register struct monst *mtmp; 32. register struct obj *otmp; 33. { 34. wakeup(mtmp); 35. switch(otmp->otyp) { 36. case WAN_STRIKING: 37. #ifdef SPELLS 38. case SPE_FORCE_BOLT: 39. #endif 40. if(u.uswallow || rnd(20) < 10+mtmp->data->ac) { 41. register int tmp = d(2,12); 42. hit((otmp->otyp == WAN_STRIKING) ? "wand" : "spell", mtmp, exclam(tmp)); 43. resist(mtmp, otmp->olet, tmp, TELL); 44. } else miss((otmp->otyp == WAN_STRIKING) ? "wand" : "spell", mtmp); 45. break; 46. case WAN_SLOW_MONSTER: 47. #ifdef SPELLS 48. case SPE_SLOW_MONSTER: 49. #endif 50. if(! resist(mtmp, otmp->olet, 0, NOTELL)) 51. mtmp->mspeed = MSLOW; 52. break; 53. case WAN_SPEED_MONSTER: 54. if (!resist(mtmp, otmp->olet, 0, NOTELL)) 55. mtmp->mspeed = MFAST; 56. break; 57. case WAN_UNDEAD_TURNING: 58. #ifdef SPELLS 59. case SPE_TURN_UNDEAD: 60. #endif 61. if(index(UNDEAD,mtmp->data->mlet)) { 62. 63. if(!resist(mtmp, otmp->olet, rnd(8), NOTELL)) 64. mtmp->mflee = 1; 65. } 66. break; 67. case WAN_POLYMORPH: 68. #ifdef SPELLS 69. case SPE_POLYMORPH: 70. #endif 71. if(!resist(mtmp, otmp->olet, 0, NOTELL)) 72. if( newcham(mtmp,&mons[rn2(CMNUM)]) ) 73. if (!Hallucination) 74. objects[otmp->otyp].oc_name_known = 1; 75. break; 76. case WAN_CANCELLATION: 77. #ifdef SPELLS 78. case SPE_CANCELLATION: 79. #endif 80. if(!resist(mtmp, otmp->olet, 0, NOTELL)) 81. mtmp->mcan = 1; 82. break; 83. case WAN_TELEPORTATION: 84. #ifdef SPELLS 85. case SPE_TELEPORT_AWAY: 86. #endif 87. rloc(mtmp); 88. break; 89. case WAN_MAKE_INVISIBLE: 90. mtmp->minvis = 1; 91. break; 92. case WAN_NOTHING: 93. break; 94. case WAN_PROBING: 95. #ifdef PROBING 96. mstatusline(mtmp); 97. #else 98. pline("Nothing Happens."); 99. #endif 100. break; 101. default: 102. impossible("What an interesting effect (%u)", otmp->otyp); 103. } 104. } 105. 106. bhito(obj, otmp) /* object obj was hit by the effect of wand otmp */ 107. register struct obj *obj, *otmp; /* returns TRUE if sth was done */ 108. { 109. register int res = TRUE; 110. #ifdef DGKMOD 111. struct obj *otmp2; 112. #endif 113. 114. if(obj == uball || obj == uchain) 115. res = FALSE; 116. else 117. switch(otmp->otyp) { 118. case WAN_POLYMORPH: 119. #ifdef SPELLS 120. case SPE_POLYMORPH: 121. #endif 122. /* preserve symbol and quantity, but turn rocks into gems */ 123. #ifdef DGKMOD 124. otmp2 = mkobj_at((obj->otyp == ROCK 125. || obj->otyp == ENORMOUS_ROCK) ? GEM_SYM : obj->olet, 126. obj->ox, obj->oy); 127. otmp2->quan = obj->quan; 128. /* keep special fields (including charges on wands) */ 129. /* The DGK modification doesn't allow polymorphing a weapon 130. with enchantments into another one, and doesn't allow 131. polymorphed rings to have plusses. KAA*/ 132. if (index("/)[", otmp2->olet)) otmp2->spe = obj->spe; 133. /* Amulets gets cheap stewr 870807 */ 134. if (obj->otyp == AMULET_OF_YENDOR) otmp2->spe = obj->spe; 135. /* Wands of wishing max 3 stewr 870808 */ 136. if ((otmp2->otyp == WAN_WISHING) 137. && (obj->spe > 3)) otmp2->spe = 3; 138. otmp2->cursed = otmp->cursed; 139. /* update the weight */ 140. otmp2->owt = weight(otmp2); 141. #else 142. mkobj_at((obj->otyp == ROCK || obj->otyp == ENORMOUS_ROCK) 143. ? GEM_SYM : obj->olet, 144. obj->ox, obj->oy) -> quan = obj->quan; 145. #endif 146. delobj(obj); 147. break; 148. case WAN_STRIKING: 149. #ifdef SPELLS 150. case SPE_FORCE_BOLT: 151. #endif 152. if(obj->otyp == ENORMOUS_ROCK) 153. fracture_rock(obj); 154. else 155. res = FALSE; 156. break; 157. case WAN_CANCELLATION: 158. #ifdef SPELLS 159. case SPE_CANCELLATION: 160. #endif 161. if(obj->spe && obj->olet != AMULET_SYM) { 162. obj->known = 0; 163. obj->spe = 0; 164. } 165. break; 166. case WAN_TELEPORTATION: 167. #ifdef SPELLS 168. case SPE_TELEPORT_AWAY: 169. #endif 170. rloco(obj); 171. break; 172. case WAN_MAKE_INVISIBLE: 173. obj->oinvis = 1; 174. break; 175. case WAN_UNDEAD_TURNING: 176. #ifdef SPELLS 177. case SPE_TURN_UNDEAD: 178. #endif 179. res = revive(obj); 180. break; 181. case WAN_SLOW_MONSTER: /* no effect on objects */ 182. #ifdef SPELLS 183. case SPE_SLOW_MONSTER: 184. #endif 185. case WAN_SPEED_MONSTER: 186. case WAN_NOTHING: 187. case WAN_PROBING: 188. res = FALSE; 189. break; 190. default: 191. impossible("What an interesting effect (%u)", otmp->otyp); 192. } 193. return(res); 194. } 195. 196. /* 197. * zappable - returns 1 if zap is available, 0 otherwise. 198. * it removes a charge from the wand if zappable. 199. * added by GAN 11/03/86 200. */ 201. int 202. zappable(wand) 203. register struct obj *wand; 204. { 205. if(wand->spe < 0 || (wand->spe ==0 && rn2(121))) 206. return(0); 207. else { 208. if(wand->spe == 0) 209. pline("You wrest one more spell from the worn-out wand."); 210. wand->spe--; 211. return(1); 212. } 213. } 214. 215. /* 216. * zapnodir - zaps an NODIR wand. 217. * added by GAN 11/03/86 218. */ 219. zapnodir(wand) 220. register struct obj *wand; 221. { 222. switch(wand->otyp){ 223. case WAN_LIGHT: 224. litroom(TRUE); 225. break; 226. case WAN_SECRET_DOOR_DETECTION: 227. if(!findit()) return(1); 228. break; 229. case WAN_CREATE_MONSTER: 230. { register int cnt = 1; 231. if(!rn2(23)) cnt += rn2(7) + 1; 232. while(cnt--) 233. (void) makemon((struct permonst *) 0, u.ux, u.uy); 234. } 235. break; 236. case WAN_WISHING: 237. 238. if(u.uluck + rn2(5) < 0) { 239. pline("Unfortunately, nothing happens."); 240. break; 241. } 242. makewish(); 243. break; 244. } 245. if(!objects[wand->otyp].oc_name_known) { 246. objects[wand->otyp].oc_name_known = 1; 247. more_experienced(0,10); 248. } 249. } 250. 251. dozap() 252. { 253. register struct obj *obj; 254. int damage; 255. 256. obj = getobj("/", "zap"); 257. if(!obj) return(0); 258. 259. /* zappable addition done by GAN 11/03/86 */ 260. if(!zappable(obj)) { 261. pline("Nothing Happens."); 262. return(1); 263. } 264. if(!(objects[obj->otyp].bits & NODIR) && !getdir(1)) { 265. pline("The %s glows and fades.",xname(obj)); 266. return(1); /* make him pay for knowing !NODIR */ 267. } 268. #ifdef KAA 269. if(!u.dx && !u.dy && !u.dz && !(objects[obj->otyp].bits & NODIR)) { 270. 271. if((damage = zapyourself(obj))) 272. losehp(damage,"self-inflicted injury"); 273. return(1); 274. } 275. #endif 276. weffects(obj); 277. return(1); 278. } 279. 280. #ifdef KAA 281. #define makeknown(x) objects[x].oc_name_known = 1 282. 283. zapyourself(obj) 284. register struct obj *obj; 285. { 286. struct obj *otmp; 287. int damage = 0; 288. 289. switch(obj->otyp) { 290. case WAN_STRIKING: 291. #ifdef SPELLS 292. case SPE_FORCE_BOLT: 293. #endif 294. pline("You magically bash yourself!"); 295. damage=d(8,6); 296. break; 297. case WAN_FIRE: 298. makeknown(WAN_FIRE); 299. #ifdef SPELLS 300. case SPE_FIREBALL: 301. #endif 302. pline("You've set light to yourself!"); 303. if (!Fire_resistance) damage=d(12,6); 304. burn_scrolls(); 305. boil_potions(); 306. break; 307. case WAN_COLD: 308. makeknown(WAN_COLD); 309. #ifdef SPELLS 310. case SPE_CONE_OF_COLD: 311. #endif 312. pline("You imitate a popsicle!"); 313. if (!Cold_resistance) damage=d(12,6); 314. break; 315. case WAN_MAGIC_MISSILE: 316. makeknown(WAN_MAGIC_MISSILE); 317. #ifdef SPELLS 318. case SPE_MAGIC_MISSILE: 319. #endif 320. damage = d(4,6); 321. pline("Idiot! You've shot yourself!"); 322. break; 323. case WAN_POLYMORPH: 324. makeknown(WAN_POLYMORPH); 325. #ifdef SPELLS 326. case SPE_POLYMORPH: 327. #endif 328. polyself(); 329. break; 330. case WAN_CANCELLATION: 331. #ifdef SPELLS 332. case SPE_CANCELLATION: 333. #endif 334. for(otmp = invent; otmp; otmp = otmp->nobj) 335. if(otmp != uball && otmp->otyp != AMULET_OF_YENDOR) 336. otmp->spe = 0; 337. if(u.mtimedone) rehumanize(); 338. flags.botl = 1; /* because of potential AC change */ 339. find_ac(); 340. break; 341. case WAN_MAKE_INVISIBLE: 342. HInvis |= INTRINSIC; 343. /* Tough luck if you cannot see invisible! */ 344. if (!See_invisible) newsym(u.ux, u.uy); 345. break; 346. case WAN_SPEED_MONSTER: 347. Fast |= INTRINSIC; 348. break; 349. case WAN_SLEEP: 350. makeknown(WAN_SLEEP); 351. #ifdef SPELLS 352. case SPE_SLEEP: 353. #endif 354. pline("The sleep ray hits you!"); 355. nomul(-rn2(50)); 356. break; 357. case WAN_SLOW_MONSTER: 358. #ifdef SPELLS 359. case SPE_SLOW_MONSTER: 360. #endif 361. Fast = 0; 362. break; 363. case WAN_TELEPORTATION: 364. #ifdef SPELLS 365. case SPE_TELEPORT_AWAY: 366. #endif 367. tele(); 368. break; 369. case WAN_DEATH: 370. #ifdef SPELLS 371. case SPE_FINGER_OF_DEATH: 372. #endif 373. killer = "death ray"; 374. pline("You irradiate yourself with pure energy!"); 375. pline("You die."); 376. done("died"); 377. break; 378. #ifdef SPELLS 379. case SPE_LIGHT: 380. pline("You've blinded yourself!"); 381. Blind += rnd(100); 382. break; 383. case SPE_DIG: 384. case SPE_TURN_UNDEAD: 385. case SPE_DETECT_UNSEEN: 386. #endif 387. case WAN_DIGGING: 388. case WAN_UNDEAD_TURNING: 389. case WAN_NOTHING: 390. break; 391. default: impossible("object %d used?",obj->otyp); 392. } 393. return(damage); 394. } 395. #endif /* KAA /**/ 396. 397. /* called for various wand and spell effects - M. Stephenson */ 398. weffects(obj) 399. register struct obj *obj; 400. { 401. xchar zx,zy; 402. 403. if(objects[obj->otyp].bits & IMMEDIATE) { 404. if(u.uswallow) 405. bhitm(u.ustuck, obj); 406. else if(u.dz) { 407. if(u.dz > 0 && o_at(u.ux,u.uy)) { 408. register struct obj *otmp; 409. 410. /* changed by GAN to hit all objects there */ 411. for(otmp = fobj; otmp ; otmp = otmp->nobj) 412. if(otmp->ox == u.ux && 413. otmp->oy == u.uy) 414. (void) bhito(otmp, obj); 415. } 416. } else 417. (void) bhit(u.dx,u.dy,rn1(8,6),0,bhitm,bhito,obj); 418. } else { 419. switch(obj->otyp){ 420. case WAN_LIGHT: 421. #ifdef SPELLS 422. case SPE_LIGHT: 423. #endif 424. litroom(TRUE); 425. break; 426. case WAN_SECRET_DOOR_DETECTION: 427. #ifdef SPELLS 428. case SPE_DETECT_UNSEEN: 429. #endif 430. if(!findit()) return(1); 431. break; 432. case WAN_CREATE_MONSTER: 433. { register int cnt = 1; 434. if(!rn2(23)) cnt += rn2(7) + 1; 435. while(cnt--) 436. (void) makemon((struct permonst *) 0, u.ux, u.uy); 437. } 438. break; 439. case WAN_WISHING: 440. if(u.uluck + rn2(5) < 0) { 441. pline("Unfortunately, nothing happens."); 442. break; 443. } 444. makewish(); 445. break; 446. case WAN_DIGGING: 447. #ifdef SPELLS 448. case SPE_DIG: 449. #endif 450. /* Original effect (approximately): 451. * from CORR: dig until we pierce a wall 452. * from ROOM: piece wall and dig until we reach 453. * an ACCESSIBLE place. 454. * Currently: dig for digdepth positions; 455. * also down on request of Lennart Augustsson. 456. */ 457. { register struct rm *room; 458. register int digdepth; 459. if(u.uswallow) { 460. register struct monst *mtmp = u.ustuck; 461. 462. pline("You pierce %s's stomach wall!", 463. monnam(mtmp)); 464. mtmp->mhp = 1; /* almost dead */ 465. unstuck(mtmp); 466. mnexto(mtmp); 467. break; 468. } 469. if(u.dz) { 470. if(u.dz < 0) { 471. pline("You loosen a rock from the ceiling."); 472. pline("It falls on your head!"); 473. losehp(1, "falling rock"); 474. mksobj_at(ROCK, u.ux, u.uy); 475. fobj->quan = 1; 476. stackobj(fobj); 477. if(Invisible) newsym(u.ux, u.uy); 478. } else { 479. dighole(); 480. } 481. break; 482. } 483. zx = u.ux+u.dx; 484. zy = u.uy+u.dy; 485. digdepth = 8 + rn2(18); 486. Tmp_at(-1, '*'); /* open call */ 487. while(--digdepth >= 0) { 488. if(!isok(zx,zy)) break; 489. room = &levl[zx][zy]; 490. Tmp_at(zx,zy); 491. if(!xdnstair){ 492. if(zx < 3 || zx > COLNO-3 || 493. zy < 3 || zy > ROWNO-3) 494. break; 495. if(room->typ == HWALL || 496. room->typ == VWALL){ 497. room->typ = ROOM; 498. break; 499. } 500. } else 501. if(room->typ == HWALL || room->typ == VWALL || 502. room->typ == SDOOR || room->typ == LDOOR){ 503. room->typ = DOOR; 504. digdepth -= 2; 505. } else 506. if(room->typ == SCORR || !room->typ) { 507. room->typ = CORR; 508. digdepth--; 509. } 510. mnewsym(zx,zy); 511. zx += u.dx; 512. zy += u.dy; 513. } 514. mnewsym(zx,zy); /* not always necessary */ 515. Tmp_at(-1,-1); /* closing call */ 516. break; 517. } 518. default: 519. #ifdef SPELLS 520. if((int) obj->otyp >= SPE_MAGIC_MISSILE) { 521. 522. buzz((int) obj->otyp - SPE_MAGIC_MISSILE + 5, 523. u.ux, u.uy, u.dx, u.dy); 524. } else 525. #endif 526. 527. buzz((int) obj->otyp - WAN_MAGIC_MISSILE, 528. u.ux, u.uy, u.dx, u.dy); 529. break; 530. } 531. if(!objects[obj->otyp].oc_name_known) { 532. objects[obj->otyp].oc_name_known = 1; 533. more_experienced(0,10); 534. } 535. } 536. return; 537. } 538. 539. char * 540. exclam(force) 541. register int force; 542. { 543. /* force == 0 occurs e.g. with sleep ray */ 544. /* note that large force is usual with wands so that !! would 545. require information about hand/weapon/wand */ 546. return( (force < 0) ? "?" : (force <= 4) ? "." : "!" ); 547. } 548. 549. hit(str,mtmp,force) 550. register char *str; 551. register struct monst *mtmp; 552. register char *force; /* usually either "." or "!" */ 553. { 554. if(!cansee(mtmp->mx,mtmp->my)) pline("The %s hits it.", str); 555. else pline("The %s hits %s%s", str, monnam(mtmp), force); 556. } 557. 558. miss(str,mtmp) 559. register char *str; 560. register struct monst *mtmp; 561. { 562. if(!cansee(mtmp->mx,mtmp->my)) pline("The %s misses it.",str); 563. else pline("The %s misses %s.",str,monnam(mtmp)); 564. } 565. 566. /* bhit: called when a weapon is thrown (sym = obj->olet) or when an 567. IMMEDIATE wand is zapped (sym = 0); the weapon falls down at end of 568. range or when a monster is hit; the monster is returned, and bhitpos 569. is set to the final position of the weapon thrown; the ray of a wand 570. may affect several objects and monsters on its path - for each of 571. these an argument function is called. */ 572. /* check !u.uswallow before calling bhit() */ 573. 574. struct monst * 575. bhit(ddx,ddy,range,sym,fhitm,fhito,obj) 576. register int ddx,ddy,range; /* direction and range */ 577. char sym; /* symbol displayed on path */ 578. int (*fhitm)(), (*fhito)(); /* fns called when mon/obj hit */ 579. struct obj *obj; /* 2nd arg to fhitm/fhito */ 580. { 581. register struct monst *mtmp; 582. register struct obj *otmp; 583. register int typ; 584. 585. bhitpos.x = u.ux; 586. bhitpos.y = u.uy; 587. 588. if(sym) tmp_at(-1, sym); /* open call */ 589. while(range-- > 0) { 590. bhitpos.x += ddx; 591. bhitpos.y += ddy; 592. typ = levl[bhitpos.x][bhitpos.y].typ; 593. if(mtmp = m_at(bhitpos.x,bhitpos.y)){ 594. if(sym) { 595. tmp_at(-1, -1); /* close call */ 596. return(mtmp); 597. } 598. (*fhitm)(mtmp, obj); 599. range -= 3; 600. } 601. /* modified by GAN to hit all objects */ 602. if(fhito && o_at(bhitpos.x,bhitpos.y)){ 603. int hitanything = 0; 604. for(otmp = fobj; otmp; otmp = otmp->nobj) 605. if(otmp->ox == bhitpos.x && 606. otmp->oy == bhitpos.y) 607. hitanything += (*fhito)(otmp, obj); 608. if(hitanything) range--; 609. } 610. if(!ZAP_POS(typ)) { 611. bhitpos.x -= ddx; 612. bhitpos.y -= ddy; 613. break; 614. } 615. if(sym) tmp_at(bhitpos.x, bhitpos.y); 616. } 617. 618. /* leave last symbol unless in a pool */ 619. if(sym) 620. tmp_at(-1, (levl[bhitpos.x][bhitpos.y].typ == POOL) ? -1 : 0); 621. return(0); 622. } 623. 624. struct monst * 625. boomhit(dx,dy) { 626. register int i, ct; 627. register struct monst *mtmp; 628. char sym = ')'; 629. extern schar xdir[], ydir[]; 630. 631. bhitpos.x = u.ux; 632. bhitpos.y = u.uy; 633. 634. for(i=0; i<8; i++) if(xdir[i] == dx && ydir[i] == dy) break; 635. tmp_at(-1, sym); /* open call */ 636. for(ct=0; ct<10; ct++) { 637. if(i == 8) i = 0; 638. sym = ')' + '(' - sym; 639. tmp_at(-2, sym); /* change let call */ 640. dx = xdir[i]; 641. dy = ydir[i]; 642. bhitpos.x += dx; 643. bhitpos.y += dy; 644. if(mtmp = m_at(bhitpos.x, bhitpos.y)){ 645. tmp_at(-1,-1); 646. return(mtmp); 647. } 648. if(!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)) { 649. bhitpos.x -= dx; 650. bhitpos.y -= dy; 651. break; 652. } 653. if(bhitpos.x == u.ux && bhitpos.y == u.uy) { /* ct == 9 */ 654. if(rn2(20) >= 10+u.ulevel){ /* we hit ourselves */ 655. (void) thitu(10, rnd(10), "boomerang"); 656. break; 657. } else { /* we catch it */ 658. tmp_at(-1,-1); 659. pline("Skillfully, you catch the boomerang."); 660. return(&youmonst); 661. } 662. } 663. tmp_at(bhitpos.x, bhitpos.y); 664. if(ct % 5 != 0) i++; 665. } 666. tmp_at(-1, -1); /* do not leave last symbol */ 667. return(0); 668. } 669. 670. char 671. dirlet(dx,dy) register dx,dy; { 672. return 673. (dx == dy) ? '\\' : (dx && dy) ? '/' : dx ? HWALL_SYM : VWALL_SYM; 674. } 675. 676. /* type == -1: monster spitting fire at you */ 677. /* type == -1,-2,-3: bolts sent out by wizard */ 678. /* called with dx = dy = 0 with vertical bolts */ 679. buzz(type,sx,sy,dx,dy) 680. register int type; 681. register xchar sx,sy; 682. register int dx,dy; 683. { 684. int abstype = (type == 10) ? 1 : abs(type); 685. register char *fltxt = (type == -1 || type == 10) ? "blaze of fire" : fl[abstype]; 686. struct rm *lev; 687. xchar range; 688. struct monst *mon; 689. 690. if(u.uswallow) { 691. register int tmp; 692. 693. if(type < 0) return; 694. tmp = zhit(u.ustuck, type); 695. pline("The %s rips into %s%s", 696. fltxt, monnam(u.ustuck), exclam(tmp)); 697. return; 698. } 699. if(type < 0) pru(); 700. range = rn1(7,7); 701. Tmp_at(-1, dirlet(dx,dy)); /* open call */ 702. while(range-- > 0) { 703. sx += dx; 704. sy += dy; 705. if((lev = &levl[sx][sy])->typ) Tmp_at(sx,sy); 706. else { 707. int bounce = 0; 708. if(cansee(sx-dx,sy-dy)) 709. pline("The %s bounces!", fltxt); 710. if(ZAP_POS(levl[sx][sy-dy].typ)) 711. bounce = 1; 712. if(ZAP_POS(levl[sx-dx][sy].typ)) { 713. if(!bounce || rn2(2)) bounce = 2; 714. } 715. switch(bounce){ 716. case 0: 717. dx = -dx; 718. dy = -dy; 719. continue; 720. case 1: 721. dy = -dy; 722. sx -= dx; 723. break; 724. case 2: 725. dx = -dx; 726. sy -= dy; 727. break; 728. } 729. Tmp_at(-2,dirlet(dx,dy)); 730. continue; 731. } 732. if(lev->typ == POOL && abstype == 1 /* fire */) { 733. range -= 3; 734. lev->typ = ROOM; 735. if(cansee(sx,sy)) { 736. mnewsym(sx,sy); 737. pline("The water evaporates."); 738. } else 739. pline("You hear a hissing sound."); 740. } 741. if(o_at(sx,sy) && abstype == 1) 742. if(burn_floor_scrolls(sx,sy) && cansee(sx,sy)) { 743. mnewsym(sx,sy); 744. pline("You see a puff of smoke."); 745. } 746. if((mon = m_at(sx,sy)) && 747. (type != -1 || mon->data->mlet != 'D')) { 748. wakeup(mon); 749. if(rnd(20) < 18 + mon->data->ac) { 750. register int tmp = zhit(mon,abstype); 751. if(mon->mhp < 1) { 752. if(type < 0) { 753. if(cansee(mon->mx,mon->my)) 754. pline("%s is killed by the %s!", 755. Monnam(mon), fltxt); 756. mondied(mon); 757. } else 758. killed(mon); 759. } else 760. hit(fltxt, mon, exclam(tmp)); 761. range -= 2; 762. } else 763. miss(fltxt,mon); 764. } else if(sx == u.ux && sy == u.uy) { 765. nomul(0); 766. if(rnd(20) < 18+u.uac) { 767. register int dam = 0; 768. range -= 2; 769. pline("The %s hits you!",fltxt); 770. switch(abstype) { 771. case 0: 772. case 5: dam = d(2,6); 773. break; 774. case 1: 775. case 6: if(Fire_resistance) 776. pline("You don't feel hot!"); 777. else dam = d(6,6); 778. if(!rn2(3)) { 779. boil_potions(); 780. burn_scrolls(); 781. } 782. break; 783. case 2: 784. case 7: nomul(-rnd(25)); /* sleep ray */ 785. break; 786. case 3: 787. case 8: if(Cold_resistance) 788. pline("You don't feel cold!"); 789. else dam = d(6,6); 790. break; 791. case 4: 792. case 9: u.uhp = -1; 793. break; 794. } 795. losehp(dam,fltxt); 796. } else pline("The %s whizzes by you!",fltxt); 797. stop_occupation(); 798. } 799. if(!ZAP_POS(lev->typ)) { 800. int bounce = 0, rmn; 801. if(cansee(sx,sy)) pline("The %s bounces!",fltxt); 802. range--; 803. if(!dx || !dy || !rn2(20)){ 804. dx = -dx; 805. dy = -dy; 806. } else { 807. if(ZAP_POS(rmn = levl[sx][sy-dy].typ) && 808. (IS_ROOM(rmn) || ZAP_POS(levl[sx+dx][sy-dy].typ))) 809. bounce = 1; 810. if(ZAP_POS(rmn = levl[sx-dx][sy].typ) && 811. (IS_ROOM(rmn) || ZAP_POS(levl[sx-dx][sy+dy].typ))) 812. if(!bounce || rn2(2)) 813. bounce = 2; 814. 815. switch(bounce){ 816. case 0: 817. dy = -dy; 818. dx = -dx; 819. break; 820. case 1: 821. dy = -dy; 822. break; 823. case 2: 824. dx = -dx; 825. break; 826. } 827. Tmp_at(-2, dirlet(dx,dy)); 828. } 829. } 830. } 831. Tmp_at(-1,-1); 832. } 833. 834. zhit(mon,type) /* returns damage to mon */ 835. register struct monst *mon; 836. register type; 837. { 838. register int tmp = 0; 839. 840. switch(type) { 841. case 0: /* magic missile */ 842. case 5: tmp = d(2,6); 843. break; 844. case -1: /* Dragon blazing fire */ 845. case 1: /* fire wand*/ 846. case 6: /* fire spell */ 847. case 10: /* Polymorphed human blazing fire */ 848. if(index("Dg", mon->data->mlet)) break; 849. tmp = d(6,6); 850. if(index("YF", mon->data->mlet)) tmp += 7; 851. break; 852. case 2: /* sleep*/ 853. case 7: tmp = 0; 854. if(!resist(mon, (type == 2) ? '/' : '+', 0, NOTELL)) 855. mon->mfroz = 1; 856. break; 857. case 3: /* cold */ 858. case 8: 859. if(index("YFgf", mon->data->mlet)) break; 860. tmp = d(6,6); 861. if(mon->data->mlet == 'D') tmp += 7; 862. break; 863. case 4: /* death*/ 864. case 9: 865. if(index(UNDEAD, mon->data->mlet)) break; 866. tmp = mon->mhp+1; 867. break; 868. } 869. if (resist(mon, (type < 5) ? '/' : '+', 0, NOTELL)) tmp /= 2; 870. mon->mhp -= tmp; 871. return(tmp); 872. } 873. 874. #define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\ 875. ? 'a' + (otyp - DEAD_ACID_BLOB)\ 876. : '@' + (otyp - DEAD_HUMAN)) 877. revive(obj) 878. register struct obj *obj; 879. { 880. register struct monst *mtmp; 881. register int let; 882. 883. if(obj->olet == FOOD_SYM && obj->otyp > CORPSE) { 884. #ifdef KAA 885. switch (obj->otyp) { 886. case DEAD_HUMAN: { let = 'Z'; break; } 887. case DEAD_GIANT: { let = '9'; break; } 888. case DEAD_DEMON: { let = '&'; break; } 889. default: let = CORPSE_I_TO_C(obj->otyp); 890. } 891. delobj(obj); 892. /* Originally there was a bug which caused the object not to be erased 893. from the screen. This happened because first the monster got created, 894. then the corpse removed. Although delobj() called unpobj(), the object 895. didn't get erased from the screen because the monster was sitting on top 896. of it. Solution: place the delobj() call before the mkmon() call. */ 897. mtmp = mkmon_at(let, obj->ox, obj->oy); 898. if (mtmp && obj->otyp == DEAD_HUMAN) { 899. mtmp->mhp = mtmp->mhpmax = 100; 900. mtmp->mspeed = MFAST; 901. } 902. #endif 903. /* do not (yet) revive shopkeepers */ 904. /* Note: this might conceivably produce two monsters 905. at the same position - strange, but harmless */ 906. #ifndef KAA 907. delobj(obj); 908. mtmp = mkmon_at(CORPSE_I_TO_C(obj->otyp),obj->ox,obj->oy); 909. #endif 910. } 911. return(!!mtmp); /* TRUE if some monster created */ 912. } 913. 914. rloco(obj) 915. register struct obj *obj; 916. { 917. register tx,ty,otx,oty; 918. 919. otx = obj->ox; 920. oty = obj->oy; 921. do { 922. tx = rn1(COLNO-3,2); 923. ty = rn2(ROWNO); 924. } while(!goodpos(tx,ty)); 925. obj->ox = tx; 926. obj->oy = ty; 927. if(cansee(otx,oty)) 928. newsym(otx,oty); 929. } 930. 931. fracture_rock(obj) /* fractured by pick-axe or wand of striking */ 932. register struct obj *obj; /* no texts here! */ 933. { 934. /* unpobj(obj); */ 935. obj->otyp = ROCK; 936. obj->quan = 7 + rn2(60); 937. obj->owt = weight(obj); 938. obj->olet = WEAPON_SYM; 939. if(cansee(obj->ox,obj->oy)) 940. prl(obj->ox,obj->oy); 941. } 942. 943. boil_potions() 944. { 945. register struct obj *obj, *obj2; 946. register int scrquan, i; 947. 948. for(obj = invent; obj; obj = obj2) { 949. obj2 = obj->nobj; 950. if(obj->olet == POTION_SYM) { 951. scrquan = obj->quan; 952. for(i = 1; i <= scrquan; i++) 953. if(!rn2(3)) { 954. pline("%s %s boils and explodes!", 955. (obj->quan != 1) ? "One of your" : "Your", 956. xname(obj)); 957. potionbreathe(obj); 958. useup(obj); 959. losehp(rn2(4),"boiling potion"); 960. } 961. } 962. } 963. } 964. 965. burn_scrolls() 966. { 967. register struct obj *obj, *obj2; 968. register int cnt = 0; 969. register int scrquan, i; 970. 971. for(obj = invent; obj; obj = obj2) { 972. obj2 = obj->nobj; 973. if(obj->olet == SCROLL_SYM) { 974. scrquan = obj->quan; 975. for(i = 1; i <= scrquan ; i++) 976. if(!rn2(3)) { 977. cnt++; 978. useup(obj); 979. } 980. } 981. } 982. 983. /* "Killed by a burning scrolls" doesn't make too much sense. KAA*/ 984. if (cnt) { 985. pline("%s of your scrolls catch%s fire!", 986. cnt==1 ? "One" : "Some", cnt==1 ? "es" : ""); 987. if(Fire_resistance) 988. pline("You aren't hurt!"); 989. else 990. losehp(cnt,"burning scroll"); 991. } 992. } 993. 994. resist(mtmp, olet, damage, tell) 995. register struct monst *mtmp; 996. register char olet; 997. register int damage, tell; 998. { 999. register int resisted = 0; 1000. #ifdef HARD 1001. register int level; 1002. 1003. switch(olet) { 1004. 1005. case '/': level = 8; 1006. break; 1007. 1008. case '?': level = 6; 1009. break; 1010. 1011. case '!': level = 5; 1012. break; 1013. 1014. default: level = u.ulevel; 1015. break; 1016. } 1017. 1018. resisted = (rn2(100) - mtmp->data->mlevel + level) < mtmp->data->mr; 1019. if(resisted) { 1020. 1021. if(tell) pline("The %s resists!", mtmp->data->mname); 1022. mtmp->mhp -= damage/2; 1023. } else 1024. #endif 1025. mtmp->mhp -= damage; 1026. 1027. if(mtmp->mhp < 1) killed(mtmp); 1028. return(resisted); 1029. } 1030. 1031. /* 1032. * burn scrolls on floor at position x,y 1033. * return the number of scrolls burned 1034. */ 1035. int 1036. burn_floor_scrolls(x,y) 1037. { 1038. register struct obj *obj, *obj2; 1039. register int scrquan, i; 1040. register int cnt = 0; 1041. 1042. for(obj = fobj; obj; obj = obj2) { 1043. obj2 = obj->nobj; 1044. /* Bug fix - KAA */ 1045. if(obj->ox == x && obj->oy == y && obj->olet == SCROLL_SYM) { 1046. scrquan = obj->quan; 1047. for(i = 1; i <= scrquan ; i++) 1048. if(!rn2(3)) { 1049. cnt++; 1050. useupf(obj); 1051. } 1052. } 1053. } 1054. return(cnt); 1055. } 1056. 1057. makewish() /* Separated as there are now 3 places you can wish at. */ 1058. { 1059. char buf[BUFSZ]; 1060. register struct obj *otmp; 1061. extern struct obj *readobjnam(), *addinv(); 1062. int wishquan, mergquan; 1063. 1064. pline("You may wish for an object. What do you want? "); 1065. getlin(buf); 1066. if(buf[0] == '\033') buf[0] = 0; 1067. otmp = readobjnam(buf); 1068. #ifdef KAA 1069. /* Wishing for gold has been implemented in readobjnam() and returns 0 1070. if successful. */ 1071. if (otmp) { 1072. #endif 1073. wishquan = otmp->quan; 1074. otmp = addinv(otmp); 1075. /* indented lines added below so quantity shows 1076. * right. GAN - 11/13/86 1077. */ 1078. mergquan = otmp->quan; 1079. otmp->quan = wishquan; /* to fool prinv() */ 1080. prinv(otmp); 1081. otmp->quan = mergquan; 1082. #ifdef KAA 1083. } 1084. #endif 1085. }
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