Source:NetHack 3.6.3/src/mhitu.c
Jump to navigation
Jump to search
Below is the full text to mhitu.c from the source code of NetHack 3.6.3. To link to a particular line, write [[Source:NetHack 3.6.3/src/mhitu.c#line12]], for example.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* NetHack 3.6 mhitu.c $NHDT-Date: 1575245065 2019/12/02 00:04:25 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.168 $ */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /*-Copyright (c) Robert Patrick Rankin, 2012. */ 4. /* NetHack may be freely redistributed. See license for details. */ 5. 6. #include "hack.h" 7. #include "artifact.h" 8. 9. STATIC_VAR NEARDATA struct obj *mon_currwep = (struct obj *) 0; 10. 11. STATIC_DCL boolean FDECL(u_slip_free, (struct monst *, struct attack *)); 12. STATIC_DCL int FDECL(passiveum, (struct permonst *, struct monst *, 13. struct attack *)); 14. STATIC_DCL void FDECL(mayberem, (struct monst *, const char *, 15. struct obj *, const char *)); 16. STATIC_DCL boolean FDECL(diseasemu, (struct permonst *)); 17. STATIC_DCL int FDECL(hitmu, (struct monst *, struct attack *)); 18. STATIC_DCL int FDECL(gulpmu, (struct monst *, struct attack *)); 19. STATIC_DCL int FDECL(explmu, (struct monst *, struct attack *, BOOLEAN_P)); 20. STATIC_DCL void FDECL(missmu, (struct monst *, BOOLEAN_P, struct attack *)); 21. STATIC_DCL void FDECL(mswings, (struct monst *, struct obj *)); 22. STATIC_DCL void FDECL(wildmiss, (struct monst *, struct attack *)); 23. STATIC_DCL void FDECL(hitmsg, (struct monst *, struct attack *)); 24. 25. /* See comment in mhitm.c. If we use this a lot it probably should be */ 26. /* changed to a parameter to mhitu. */ 27. static int dieroll; 28. 29. STATIC_OVL void 30. hitmsg(mtmp, mattk) 31. struct monst *mtmp; 32. struct attack *mattk; 33. { 34. int compat; 35. const char *pfmt = 0; 36. char *Monst_name = Monnam(mtmp); 37. 38. /* Note: if opposite gender, "seductively" */ 39. /* If same gender, "engagingly" for nymph, normal msg for others */ 40. if ((compat = could_seduce(mtmp, &youmonst, mattk)) != 0 41. && !mtmp->mcan && !mtmp->mspec_used) { 42. pline("%s %s you %s.", Monst_name, 43. !Blind ? "smiles at" : !Deaf ? "talks to" : "touches", 44. (compat == 2) ? "engagingly" : "seductively"); 45. } else { 46. switch (mattk->aatyp) { 47. case AT_BITE: 48. pfmt = "%s bites!"; 49. break; 50. case AT_KICK: 51. pline("%s kicks%c", Monst_name, 52. thick_skinned(youmonst.data) ? '.' : '!'); 53. break; 54. case AT_STNG: 55. pfmt = "%s stings!"; 56. break; 57. case AT_BUTT: 58. pfmt = "%s butts!"; 59. break; 60. case AT_TUCH: 61. pfmt = "%s touches you!"; 62. break; 63. case AT_TENT: 64. pfmt = "%s tentacles suck you!"; 65. Monst_name = s_suffix(Monst_name); 66. break; 67. case AT_EXPL: 68. case AT_BOOM: 69. pfmt = "%s explodes!"; 70. break; 71. default: 72. pfmt = "%s hits!"; 73. } 74. if (pfmt) 75. pline(pfmt, Monst_name); 76. } 77. } 78. 79. /* monster missed you */ 80. STATIC_OVL void 81. missmu(mtmp, nearmiss, mattk) 82. struct monst *mtmp; 83. boolean nearmiss; 84. struct attack *mattk; 85. { 86. if (!canspotmon(mtmp)) 87. map_invisible(mtmp->mx, mtmp->my); 88. 89. if (could_seduce(mtmp, &youmonst, mattk) && !mtmp->mcan) 90. pline("%s pretends to be friendly.", Monnam(mtmp)); 91. else 92. pline("%s %smisses!", Monnam(mtmp), 93. (nearmiss && flags.verbose) ? "just " : ""); 94. 95. stop_occupation(); 96. } 97. 98. /* monster swings obj */ 99. STATIC_OVL void 100. mswings(mtmp, otemp) 101. struct monst *mtmp; 102. struct obj *otemp; 103. { 104. if (flags.verbose && !Blind && mon_visible(mtmp)) { 105. pline("%s %s %s%s %s.", Monnam(mtmp), 106. (objects[otemp->otyp].oc_dir & PIERCE) ? "thrusts" : "swings", 107. (otemp->quan > 1L) ? "one of " : "", mhis(mtmp), xname(otemp)); 108. } 109. } 110. 111. /* return how a poison attack was delivered */ 112. const char * 113. mpoisons_subj(mtmp, mattk) 114. struct monst *mtmp; 115. struct attack *mattk; 116. { 117. if (mattk->aatyp == AT_WEAP) { 118. struct obj *mwep = (mtmp == &youmonst) ? uwep : MON_WEP(mtmp); 119. /* "Foo's attack was poisoned." is pretty lame, but at least 120. it's better than "sting" when not a stinging attack... */ 121. return (!mwep || !mwep->opoisoned) ? "attack" : "weapon"; 122. } else { 123. return (mattk->aatyp == AT_TUCH) ? "contact" 124. : (mattk->aatyp == AT_GAZE) ? "gaze" 125. : (mattk->aatyp == AT_BITE) ? "bite" : "sting"; 126. } 127. } 128. 129. /* called when your intrinsic speed is taken away */ 130. void 131. u_slow_down() 132. { 133. HFast = 0L; 134. if (!Fast) 135. You("slow down."); 136. else /* speed boots */ 137. Your("quickness feels less natural."); 138. exercise(A_DEX, FALSE); 139. } 140. 141. /* monster attacked your displaced image */ 142. STATIC_OVL void 143. wildmiss(mtmp, mattk) 144. struct monst *mtmp; 145. struct attack *mattk; 146. { 147. int compat; 148. const char *Monst_name; /* Monnam(mtmp) */ 149. 150. /* no map_invisible() -- no way to tell where _this_ is coming from */ 151. 152. if (!flags.verbose) 153. return; 154. if (!cansee(mtmp->mx, mtmp->my)) 155. return; 156. /* maybe it's attacking an image around the corner? */ 157. 158. compat = ((mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX) 159. ? could_seduce(mtmp, &youmonst, mattk) : 0); 160. Monst_name = Monnam(mtmp); 161. 162. if (!mtmp->mcansee || (Invis && !perceives(mtmp->data))) { 163. const char *swings = (mattk->aatyp == AT_BITE) ? "snaps" 164. : (mattk->aatyp == AT_KICK) ? "kicks" 165. : (mattk->aatyp == AT_STNG 166. || mattk->aatyp == AT_BUTT 167. || nolimbs(mtmp->data)) ? "lunges" 168. : "swings"; 169. 170. if (compat) 171. pline("%s tries to touch you and misses!", Monst_name); 172. else 173. switch (rn2(3)) { 174. case 0: 175. pline("%s %s wildly and misses!", Monst_name, swings); 176. break; 177. case 1: 178. pline("%s attacks a spot beside you.", Monst_name); 179. break; 180. case 2: 181. pline("%s strikes at %s!", Monst_name, 182. (levl[mtmp->mux][mtmp->muy].typ == WATER) 183. ? "empty water" 184. : "thin air"); 185. break; 186. default: 187. pline("%s %s wildly!", Monst_name, swings); 188. break; 189. } 190. 191. } else if (Displaced) { 192. /* give 'displaced' message even if hero is Blind */ 193. if (compat) 194. pline("%s smiles %s at your %sdisplaced image...", Monst_name, 195. (compat == 2) ? "engagingly" : "seductively", 196. Invis ? "invisible " : ""); 197. else 198. pline("%s strikes at your %sdisplaced image and misses you!", 199. /* Note: if you're both invisible and displaced, only 200. * monsters which see invisible will attack your displaced 201. * image, since the displaced image is also invisible. */ 202. Monst_name, Invis ? "invisible " : ""); 203. 204. } else if (Underwater) { 205. /* monsters may miss especially on water level where 206. bubbles shake the player here and there */ 207. if (compat) 208. pline("%s reaches towards your distorted image.", Monst_name); 209. else 210. pline("%s is fooled by water reflections and misses!", 211. Monst_name); 212. 213. } else 214. impossible("%s attacks you without knowing your location?", 215. Monst_name); 216. } 217. 218. void 219. expels(mtmp, mdat, message) 220. struct monst *mtmp; 221. struct permonst *mdat; /* if mtmp is polymorphed, mdat != mtmp->data */ 222. boolean message; 223. { 224. if (message) { 225. if (is_animal(mdat)) { 226. You("get regurgitated!"); 227. } else { 228. char blast[40]; 229. struct attack *attk = attacktype_fordmg(mdat, AT_ENGL, AD_ANY); 230. 231. blast[0] = '\0'; 232. if (!attk) { 233. impossible("Swallower has no engulfing attack?"); 234. } else { 235. if (is_whirly(mdat)) { 236. switch (attk->adtyp) { 237. case AD_ELEC: 238. Strcpy(blast, " in a shower of sparks"); 239. break; 240. case AD_COLD: 241. Strcpy(blast, " in a blast of frost"); 242. break; 243. } 244. } else { 245. Strcpy(blast, " with a squelch"); 246. } 247. You("get expelled from %s%s!", mon_nam(mtmp), blast); 248. } 249. } 250. } 251. unstuck(mtmp); /* ball&chain returned in unstuck() */ 252. mnexto(mtmp); 253. newsym(u.ux, u.uy); 254. spoteffects(TRUE); 255. /* to cover for a case where mtmp is not in a next square */ 256. if (um_dist(mtmp->mx, mtmp->my, 1)) 257. pline("Brrooaa... You land hard at some distance."); 258. } 259. 260. /* select a monster's next attack, possibly substituting for its usual one */ 261. struct attack * 262. getmattk(magr, mdef, indx, prev_result, alt_attk_buf) 263. struct monst *magr, *mdef; 264. int indx, prev_result[]; 265. struct attack *alt_attk_buf; 266. { 267. struct permonst *mptr = magr->data; 268. struct attack *attk = &mptr->mattk[indx]; 269. struct obj *weap = (magr == &youmonst) ? uwep : MON_WEP(magr); 270. 271. /* honor SEDUCE=0 */ 272. if (!SYSOPT_SEDUCE) { 273. extern const struct attack sa_no[NATTK]; 274. 275. /* if the first attack is for SSEX damage, all six attacks will be 276. substituted (expected succubus/incubus handling); if it isn't 277. but another one is, only that other one will be substituted */ 278. if (mptr->mattk[0].adtyp == AD_SSEX) { 279. *alt_attk_buf = sa_no[indx]; 280. attk = alt_attk_buf; 281. } else if (attk->adtyp == AD_SSEX) { 282. *alt_attk_buf = *attk; 283. attk = alt_attk_buf; 284. attk->adtyp = AD_DRLI; 285. } 286. } 287. 288. /* prevent a monster with two consecutive disease or hunger attacks 289. from hitting with both of them on the same turn; if the first has 290. already hit, switch to a stun attack for the second */ 291. if (indx > 0 && prev_result[indx - 1] > 0 292. && (attk->adtyp == AD_DISE || attk->adtyp == AD_PEST 293. || attk->adtyp == AD_FAMN) 294. && attk->adtyp == mptr->mattk[indx - 1].adtyp) { 295. *alt_attk_buf = *attk; 296. attk = alt_attk_buf; 297. attk->adtyp = AD_STUN; 298. 299. /* make drain-energy damage be somewhat in proportion to energy */ 300. } else if (attk->adtyp == AD_DREN && mdef == &youmonst) { 301. int ulev = max(u.ulevel, 6); 302. 303. *alt_attk_buf = *attk; 304. attk = alt_attk_buf; 305. /* 3.6.0 used 4d6 but since energy drain came out of max energy 306. once current energy was gone, that tended to have a severe 307. effect on low energy characters; it's now 2d6 with ajustments */ 308. if (u.uen <= 5 * ulev && attk->damn > 1) { 309. attk->damn -= 1; /* low energy: 2d6 -> 1d6 */ 310. if (u.uenmax <= 2 * ulev && attk->damd > 3) 311. attk->damd -= 3; /* very low energy: 1d6 -> 1d3 */ 312. } else if (u.uen > 12 * ulev) { 313. attk->damn += 1; /* high energy: 2d6 -> 3d6 */ 314. if (u.uenmax > 20 * ulev) 315. attk->damd += 3; /* very high energy: 3d6 -> 3d9 */ 316. /* note: 3d9 is slightly higher than previous 4d6 */ 317. } 318. 319. } else if (attk->aatyp == AT_ENGL && magr->mspec_used) { 320. /* can't re-engulf yet; switch to simpler attack */ 321. *alt_attk_buf = *attk; 322. attk = alt_attk_buf; 323. if (attk->adtyp == AD_ACID || attk->adtyp == AD_ELEC 324. || attk->adtyp == AD_COLD || attk->adtyp == AD_FIRE) { 325. attk->aatyp = AT_TUCH; 326. } else { 327. attk->aatyp = AT_CLAW; /* attack message will be "<foo> hits" */ 328. attk->adtyp = AD_PHYS; 329. } 330. attk->damn = 1; /* relatively weak: 1d6 */ 331. attk->damd = 6; 332. 333. /* barrow wight, Nazgul, erinys have weapon attack for non-physical 334. damage; force physical damage if attacker has been cancelled or 335. if weapon is sufficiently interesting; a few unique creatures 336. have two weapon attacks where one does physical damage and other 337. doesn't--avoid forcing physical damage for those */ 338. } else if (indx == 0 && magr != &youmonst 339. && attk->aatyp == AT_WEAP && attk->adtyp != AD_PHYS 340. && !(mptr->mattk[1].aatyp == AT_WEAP 341. && mptr->mattk[1].adtyp == AD_PHYS) 342. && (magr->mcan 343. || (weap && ((weap->otyp == CORPSE 344. && touch_petrifies(&mons[weap->corpsenm])) 345. || weap->oartifact == ART_STORMBRINGER 346. || weap->oartifact == ART_VORPAL_BLADE)))) { 347. *alt_attk_buf = *attk; 348. attk = alt_attk_buf; 349. attk->adtyp = AD_PHYS; 350. } 351. return attk; 352. } 353. 354. /* 355. * mattacku: monster attacks you 356. * returns 1 if monster dies (e.g. "yellow light"), 0 otherwise 357. * Note: if you're displaced or invisible the monster might attack the 358. * wrong position... 359. * Assumption: it's attacking you or an empty square; if there's another 360. * monster which it attacks by mistake, the caller had better 361. * take care of it... 362. */ 363. int 364. mattacku(mtmp) 365. register struct monst *mtmp; 366. { 367. struct attack *mattk, alt_attk; 368. int i, j = 0, tmp, sum[NATTK]; 369. struct permonst *mdat = mtmp->data; 370. boolean ranged = (distu(mtmp->mx, mtmp->my) > 3); 371. /* Is it near you? Affects your actions */ 372. boolean range2 = !monnear(mtmp, mtmp->mux, mtmp->muy); 373. /* Does it think it's near you? Affects its actions */ 374. boolean foundyou = (mtmp->mux == u.ux && mtmp->muy == u.uy); 375. /* Is it attacking you or your image? */ 376. boolean youseeit = canseemon(mtmp); 377. /* Might be attacking your image around the corner, or 378. * invisible, or you might be blind.... 379. */ 380. boolean skipnonmagc = FALSE; 381. /* Are further physical attack attempts useless? */ 382. 383. if (!ranged) 384. nomul(0); 385. if (DEADMONSTER(mtmp) || (Underwater && !is_swimmer(mtmp->data))) 386. return 0; 387. 388. /* If swallowed, can only be affected by u.ustuck */ 389. if (u.uswallow) { 390. if (mtmp != u.ustuck) 391. return 0; 392. u.ustuck->mux = u.ux; 393. u.ustuck->muy = u.uy; 394. range2 = 0; 395. foundyou = 1; 396. if (u.uinvulnerable) 397. return 0; /* stomachs can't hurt you! */ 398. 399. } else if (u.usteed) { 400. if (mtmp == u.usteed) 401. /* Your steed won't attack you */ 402. return 0; 403. /* Orcs like to steal and eat horses and the like */ 404. if (!rn2(is_orc(mtmp->data) ? 2 : 4) 405. && distu(mtmp->mx, mtmp->my) <= 2) { 406. /* Attack your steed instead */ 407. i = mattackm(mtmp, u.usteed); 408. if ((i & MM_AGR_DIED)) 409. return 1; 410. /* make sure steed is still alive and within range */ 411. if ((i & MM_DEF_DIED) || !u.usteed 412. || distu(mtmp->mx, mtmp->my) > 2) 413. return 0; 414. /* Let your steed retaliate */ 415. return !!(mattackm(u.usteed, mtmp) & MM_DEF_DIED); 416. } 417. } 418. 419. if (u.uundetected && !range2 && foundyou && !u.uswallow) { 420. if (!canspotmon(mtmp)) 421. map_invisible(mtmp->mx, mtmp->my); 422. u.uundetected = 0; 423. if (is_hider(youmonst.data) && u.umonnum != PM_TRAPPER) { 424. /* ceiling hider */ 425. coord cc; /* maybe we need a unexto() function? */ 426. struct obj *obj; 427. 428. You("fall from the %s!", ceiling(u.ux, u.uy)); 429. /* take monster off map now so that its location 430. is eligible for placing hero; we assume that a 431. removed monster remembers its old spot <mx,my> */ 432. remove_monster(mtmp->mx, mtmp->my); 433. if (!enexto(&cc, u.ux, u.uy, youmonst.data) 434. /* a fish won't voluntarily swap positions 435. when it's in water and hero is over land */ 436. || (mtmp->data->mlet == S_EEL 437. && is_pool(mtmp->mx, mtmp->my) 438. && !is_pool(u.ux, u.uy))) { 439. /* couldn't find any spot for hero; this used to 440. kill off attacker, but now we just give a "miss" 441. message and keep both mtmp and hero at their 442. original positions; hero has become unconcealed 443. so mtmp's next move will be a regular attack */ 444. place_monster(mtmp, mtmp->mx, mtmp->my); /* put back */ 445. newsym(u.ux, u.uy); /* u.uundetected was toggled */ 446. pline("%s draws back as you drop!", Monnam(mtmp)); 447. return 0; 448. } 449. 450. /* put mtmp at hero's spot and move hero to <cc.x,.y> */ 451. newsym(mtmp->mx, mtmp->my); /* finish removal */ 452. place_monster(mtmp, u.ux, u.uy); 453. if (mtmp->wormno) { 454. worm_move(mtmp); 455. /* tail hasn't grown, so if it now occupies <cc.x,.y> 456. then one of its original spots must be free */ 457. if (m_at(cc.x, cc.y)) 458. (void) enexto(&cc, u.ux, u.uy, youmonst.data); 459. } 460. teleds(cc.x, cc.y, TRUE); /* move hero */ 461. set_apparxy(mtmp); 462. newsym(u.ux, u.uy); 463. 464. if (youmonst.data->mlet != S_PIERCER) 465. return 0; /* lurkers don't attack */ 466. 467. obj = which_armor(mtmp, WORN_HELMET); 468. if (obj && is_metallic(obj)) { 469. Your("blow glances off %s %s.", s_suffix(mon_nam(mtmp)), 470. helm_simple_name(obj)); 471. } else { 472. if (3 + find_mac(mtmp) <= rnd(20)) { 473. pline("%s is hit by a falling piercer (you)!", 474. Monnam(mtmp)); 475. if ((mtmp->mhp -= d(3, 6)) < 1) 476. killed(mtmp); 477. } else 478. pline("%s is almost hit by a falling piercer (you)!", 479. Monnam(mtmp)); 480. } 481. 482. } else { 483. /* surface hider */ 484. if (!youseeit) { 485. pline("It tries to move where you are hiding."); 486. } else { 487. /* Ugly kludge for eggs. The message is phrased so as 488. * to be directed at the monster, not the player, 489. * which makes "laid by you" wrong. For the 490. * parallelism to work, we can't rephrase it, so we 491. * zap the "laid by you" momentarily instead. 492. */ 493. struct obj *obj = level.objects[u.ux][u.uy]; 494. 495. if (obj || u.umonnum == PM_TRAPPER 496. || (youmonst.data->mlet == S_EEL 497. && is_pool(u.ux, u.uy))) { 498. int save_spe = 0; /* suppress warning */ 499. 500. if (obj) { 501. save_spe = obj->spe; 502. if (obj->otyp == EGG) 503. obj->spe = 0; 504. } 505. /* note that m_monnam() overrides hallucination, which is 506. what we want when message is from mtmp's perspective */ 507. if (youmonst.data->mlet == S_EEL 508. || u.umonnum == PM_TRAPPER) 509. pline( 510. "Wait, %s! There's a hidden %s named %s there!", 511. m_monnam(mtmp), youmonst.data->mname, plname); 512. else 513. pline( 514. "Wait, %s! There's a %s named %s hiding under %s!", 515. m_monnam(mtmp), youmonst.data->mname, plname, 516. doname(level.objects[u.ux][u.uy])); 517. if (obj) 518. obj->spe = save_spe; 519. } else 520. impossible("hiding under nothing?"); 521. } 522. newsym(u.ux, u.uy); 523. } 524. return 0; 525. } 526. 527. /* hero might be a mimic, concealed via #monster */ 528. if (youmonst.data->mlet == S_MIMIC && U_AP_TYPE && !range2 529. && foundyou && !u.uswallow) { 530. boolean sticky = sticks(youmonst.data); 531. 532. if (!canspotmon(mtmp)) 533. map_invisible(mtmp->mx, mtmp->my); 534. if (sticky && !youseeit) 535. pline("It gets stuck on you."); 536. else /* see note about m_monnam() above */ 537. pline("Wait, %s! That's a %s named %s!", m_monnam(mtmp), 538. youmonst.data->mname, plname); 539. if (sticky) 540. u.ustuck = mtmp; 541. youmonst.m_ap_type = M_AP_NOTHING; 542. youmonst.mappearance = 0; 543. newsym(u.ux, u.uy); 544. return 0; 545. } 546. 547. /* non-mimic hero might be mimicking an object after eating m corpse */ 548. if (U_AP_TYPE == M_AP_OBJECT && !range2 && foundyou && !u.uswallow) { 549. if (!canspotmon(mtmp)) 550. map_invisible(mtmp->mx, mtmp->my); 551. if (!youseeit) 552. pline("%s %s!", Something, (likes_gold(mtmp->data) 553. && youmonst.mappearance == GOLD_PIECE) 554. ? "tries to pick you up" 555. : "disturbs you"); 556. else /* see note about m_monnam() above */ 557. pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp), 558. mimic_obj_name(&youmonst), an(mons[u.umonnum].mname), 559. plname); 560. if (multi < 0) { /* this should always be the case */ 561. char buf[BUFSZ]; 562. 563. Sprintf(buf, "You appear to be %s again.", 564. Upolyd ? (const char *) an(youmonst.data->mname) 565. : (const char *) "yourself"); 566. unmul(buf); /* immediately stop mimicking */ 567. } 568. return 0; 569. } 570. 571. /* Work out the armor class differential */ 572. tmp = AC_VALUE(u.uac) + 10; /* tmp ~= 0 - 20 */ 573. tmp += mtmp->m_lev; 574. if (multi < 0) 575. tmp += 4; 576. if ((Invis && !perceives(mdat)) || !mtmp->mcansee) 577. tmp -= 2; 578. if (mtmp->mtrapped) 579. tmp -= 2; 580. if (tmp <= 0) 581. tmp = 1; 582. 583. /* make eels visible the moment they hit/miss us */ 584. if (mdat->mlet == S_EEL && mtmp->minvis && cansee(mtmp->mx, mtmp->my)) { 585. mtmp->minvis = 0; 586. newsym(mtmp->mx, mtmp->my); 587. } 588. 589. /* Special demon handling code */ 590. if ((mtmp->cham == NON_PM) && is_demon(mdat) && !range2 591. && mtmp->data != &mons[PM_BALROG] && mtmp->data != &mons[PM_SUCCUBUS] 592. && mtmp->data != &mons[PM_INCUBUS]) 593. if (!mtmp->mcan && !rn2(13)) 594. (void) msummon(mtmp); 595. 596. /* Special lycanthrope handling code */ 597. if ((mtmp->cham == NON_PM) && is_were(mdat) && !range2) { 598. if (is_human(mdat)) { 599. if (!rn2(5 - (night() * 2)) && !mtmp->mcan) 600. new_were(mtmp); 601. } else if (!rn2(30) && !mtmp->mcan) 602. new_were(mtmp); 603. mdat = mtmp->data; 604. 605. if (!rn2(10) && !mtmp->mcan) { 606. int numseen, numhelp; 607. char buf[BUFSZ], genericwere[BUFSZ]; 608. 609. Strcpy(genericwere, "creature"); 610. numhelp = were_summon(mdat, FALSE, &numseen, genericwere); 611. if (youseeit) { 612. pline("%s summons help!", Monnam(mtmp)); 613. if (numhelp > 0) { 614. if (numseen == 0) 615. You_feel("hemmed in."); 616. } else 617. pline("But none comes."); 618. } else { 619. const char *from_nowhere; 620. 621. if (!Deaf) { 622. pline("%s %s!", Something, makeplural(growl_sound(mtmp))); 623. from_nowhere = ""; 624. } else 625. from_nowhere = " from nowhere"; 626. if (numhelp > 0) { 627. if (numseen < 1) 628. You_feel("hemmed in."); 629. else { 630. if (numseen == 1) 631. Sprintf(buf, "%s appears", an(genericwere)); 632. else 633. Sprintf(buf, "%s appear", 634. makeplural(genericwere)); 635. pline("%s%s!", upstart(buf), from_nowhere); 636. } 637. } /* else no help came; but you didn't know it tried */ 638. } 639. } 640. } 641. 642. if (u.uinvulnerable) { 643. /* monsters won't attack you */ 644. if (mtmp == u.ustuck) { 645. pline("%s loosens its grip slightly.", Monnam(mtmp)); 646. } else if (!range2) { 647. if (youseeit || sensemon(mtmp)) 648. pline("%s starts to attack you, but pulls back.", 649. Monnam(mtmp)); 650. else 651. You_feel("%s move nearby.", something); 652. } 653. return 0; 654. } 655. 656. /* Unlike defensive stuff, don't let them use item _and_ attack. */ 657. if (find_offensive(mtmp)) { 658. int foo = use_offensive(mtmp); 659. 660. if (foo != 0) 661. return (foo == 1); 662. } 663. 664. for (i = 0; i < NATTK; i++) { 665. sum[i] = 0; 666. mon_currwep = (struct obj *)0; 667. mattk = getmattk(mtmp, &youmonst, i, sum, &alt_attk); 668. if ((u.uswallow && mattk->aatyp != AT_ENGL) 669. || (skipnonmagc && mattk->aatyp != AT_MAGC)) 670. continue; 671. 672. switch (mattk->aatyp) { 673. case AT_CLAW: /* "hand to hand" attacks */ 674. case AT_KICK: 675. case AT_BITE: 676. case AT_STNG: 677. case AT_TUCH: 678. case AT_BUTT: 679. case AT_TENT: 680. if (!range2 && (!MON_WEP(mtmp) || mtmp->mconf || Conflict 681. || !touch_petrifies(youmonst.data))) { 682. if (foundyou) { 683. if (tmp > (j = rnd(20 + i))) { 684. if (mattk->aatyp != AT_KICK 685. || !thick_skinned(youmonst.data)) 686. sum[i] = hitmu(mtmp, mattk); 687. } else 688. missmu(mtmp, (tmp == j), mattk); 689. } else { 690. wildmiss(mtmp, mattk); 691. /* skip any remaining non-spell attacks */ 692. skipnonmagc = TRUE; 693. } 694. } 695. break; 696. 697. case AT_HUGS: /* automatic if prev two attacks succeed */ 698. /* Note: if displaced, prev attacks never succeeded */ 699. if ((!range2 && i >= 2 && sum[i - 1] && sum[i - 2]) 700. || mtmp == u.ustuck) 701. sum[i] = hitmu(mtmp, mattk); 702. break; 703. 704. case AT_GAZE: /* can affect you either ranged or not */ 705. /* Medusa gaze already operated through m_respond in 706. dochug(); don't gaze more than once per round. */ 707. if (mdat != &mons[PM_MEDUSA]) 708. sum[i] = gazemu(mtmp, mattk); 709. break; 710. 711. case AT_EXPL: /* automatic hit if next to, and aimed at you */ 712. if (!range2) 713. sum[i] = explmu(mtmp, mattk, foundyou); 714. break; 715. 716. case AT_ENGL: 717. if (!range2) { 718. if (foundyou) { 719. if (u.uswallow 720. || (!mtmp->mspec_used && tmp > (j = rnd(20 + i)))) { 721. /* force swallowing monster to be displayed 722. even when hero is moving away */ 723. flush_screen(1); 724. sum[i] = gulpmu(mtmp, mattk); 725. } else { 726. missmu(mtmp, (tmp == j), mattk); 727. } 728. } else if (is_animal(mtmp->data)) { 729. pline("%s gulps some air!", Monnam(mtmp)); 730. } else { 731. if (youseeit) 732. pline("%s lunges forward and recoils!", Monnam(mtmp)); 733. else 734. You_hear("a %s nearby.", 735. is_whirly(mtmp->data) ? "rushing noise" 736. : "splat"); 737. } 738. } 739. break; 740. case AT_BREA: 741. if (range2) 742. sum[i] = breamu(mtmp, mattk); 743. /* Note: breamu takes care of displacement */ 744. break; 745. case AT_SPIT: 746. if (range2) 747. sum[i] = spitmu(mtmp, mattk); 748. /* Note: spitmu takes care of displacement */ 749. break; 750. case AT_WEAP: 751. if (range2) { 752. if (!Is_rogue_level(&u.uz)) 753. thrwmu(mtmp); 754. } else { 755. int hittmp = 0; 756. 757. /* Rare but not impossible. Normally the monster 758. * wields when 2 spaces away, but it can be 759. * teleported or whatever.... 760. */ 761. if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) { 762. mtmp->weapon_check = NEED_HTH_WEAPON; 763. /* mon_wield_item resets weapon_check as appropriate */ 764. if (mon_wield_item(mtmp) != 0) 765. break; 766. } 767. if (foundyou) { 768. mon_currwep = MON_WEP(mtmp); 769. if (mon_currwep) { 770. hittmp = hitval(mon_currwep, &youmonst); 771. tmp += hittmp; 772. mswings(mtmp, mon_currwep); 773. } 774. if (tmp > (j = dieroll = rnd(20 + i))) 775. sum[i] = hitmu(mtmp, mattk); 776. else 777. missmu(mtmp, (tmp == j), mattk); 778. /* KMH -- Don't accumulate to-hit bonuses */ 779. if (mon_currwep) 780. tmp -= hittmp; 781. } else { 782. wildmiss(mtmp, mattk); 783. /* skip any remaining non-spell attacks */ 784. skipnonmagc = TRUE; 785. } 786. } 787. break; 788. case AT_MAGC: 789. if (range2) 790. sum[i] = buzzmu(mtmp, mattk); 791. else 792. sum[i] = castmu(mtmp, mattk, TRUE, foundyou); 793. break; 794. 795. default: /* no attack */ 796. break; 797. } 798. if (context.botl) 799. bot(); 800. /* give player a chance of waking up before dying -kaa */ 801. if (sum[i] == 1) { /* successful attack */ 802. if (u.usleep && u.usleep < monstermoves && !rn2(10)) { 803. multi = -1; 804. nomovemsg = "The combat suddenly awakens you."; 805. } 806. } 807. if (sum[i] == 2) 808. return 1; /* attacker dead */ 809. if (sum[i] == 3) 810. break; /* attacker teleported, no more attacks */ 811. /* sum[i] == 0: unsuccessful attack */ 812. } 813. return 0; 814. } 815. 816. STATIC_OVL boolean 817. diseasemu(mdat) 818. struct permonst *mdat; 819. { 820. if (Sick_resistance) { 821. You_feel("a slight illness."); 822. return FALSE; 823. } else { 824. make_sick(Sick ? Sick / 3L + 1L : (long) rn1(ACURR(A_CON), 20), 825. mdat->mname, TRUE, SICK_NONVOMITABLE); 826. return TRUE; 827. } 828. } 829. 830. /* check whether slippery clothing protects from hug or wrap attack */ 831. STATIC_OVL boolean 832. u_slip_free(mtmp, mattk) 833. struct monst *mtmp; 834. struct attack *mattk; 835. { 836. struct obj *obj = (uarmc ? uarmc : uarm); 837. 838. if (!obj) 839. obj = uarmu; 840. if (mattk->adtyp == AD_DRIN) 841. obj = uarmh; 842. 843. /* if your cloak/armor is greased, monster slips off; this 844. protection might fail (33% chance) when the armor is cursed */ 845. if (obj && (obj->greased || obj->otyp == OILSKIN_CLOAK) 846. && (!obj->cursed || rn2(3))) { 847. pline("%s %s your %s %s!", Monnam(mtmp), 848. (mattk->adtyp == AD_WRAP) ? "slips off of" 849. : "grabs you, but cannot hold onto", 850. obj->greased ? "greased" : "slippery", 851. /* avoid "slippery slippery cloak" 852. for undiscovered oilskin cloak */ 853. (obj->greased || objects[obj->otyp].oc_name_known) 854. ? xname(obj) 855. : cloak_simple_name(obj)); 856. 857. if (obj->greased && !rn2(2)) { 858. pline_The("grease wears off."); 859. obj->greased = 0; 860. update_inventory(); 861. } 862. return TRUE; 863. } 864. return FALSE; 865. } 866. 867. /* armor that sufficiently covers the body might be able to block magic */ 868. int 869. magic_negation(mon) 870. struct monst *mon; 871. { 872. struct obj *o; 873. long wearmask; 874. int armpro, mc = 0; 875. boolean is_you = (mon == &youmonst), 876. gotprot = is_you ? (EProtection != 0L) 877. /* high priests have innate protection */ 878. : (mon->data == &mons[PM_HIGH_PRIEST]); 879. 880. for (o = is_you ? invent : mon->minvent; o; o = o->nobj) { 881. /* a_can field is only applicable for armor (which must be worn) */ 882. if ((o->owornmask & W_ARMOR) != 0L) { 883. armpro = objects[o->otyp].a_can; 884. if (armpro > mc) 885. mc = armpro; 886. } 887. /* if we've already confirmed Protection, skip additional checks */ 888. if (is_you || gotprot) 889. continue; 890. 891. /* omit W_SWAPWEP+W_QUIVER; W_ART+W_ARTI handled by protects() */ 892. wearmask = W_ARMOR | W_ACCESSORY; 893. if (o->oclass == WEAPON_CLASS || is_weptool(o)) 894. wearmask |= W_WEP; 895. if (protects(o, ((o->owornmask & wearmask) != 0L) ? TRUE : FALSE)) 896. gotprot = TRUE; 897. } 898. 899. if (gotprot) { 900. /* extrinsic Protection increases mc by 1 */ 901. if (mc < 3) 902. mc += 1; 903. } else if (mc < 1) { 904. /* intrinsic Protection is weaker (play balance; obtaining divine 905. protection is too easy); it confers minimum mc 1 instead of 0 */ 906. if ((is_you && ((HProtection && u.ublessed > 0) || u.uspellprot)) 907. /* aligned priests and angels have innate intrinsic Protection */ 908. || (mon->data == &mons[PM_ALIGNED_PRIEST] || is_minion(mon->data))) 909. mc = 1; 910. } 911. return mc; 912. } 913. 914. /* 915. * hitmu: monster hits you 916. * returns 2 if monster dies (e.g. "yellow light"), 1 otherwise 917. * 3 if the monster lives but teleported/paralyzed, so it can't keep 918. * attacking you 919. */ 920. STATIC_OVL int 921. hitmu(mtmp, mattk) 922. register struct monst *mtmp; 923. register struct attack *mattk; 924. { 925. struct permonst *mdat = mtmp->data; 926. int uncancelled, ptmp; 927. int dmg, armpro, permdmg, tmphp; 928. char buf[BUFSZ]; 929. struct permonst *olduasmon = youmonst.data; 930. int res; 931. 932. if (!canspotmon(mtmp)) 933. map_invisible(mtmp->mx, mtmp->my); 934. 935. /* If the monster is undetected & hits you, you should know where 936. * the attack came from. 937. */ 938. if (mtmp->mundetected && (hides_under(mdat) || mdat->mlet == S_EEL)) { 939. mtmp->mundetected = 0; 940. if (!(Blind ? Blind_telepat : Unblind_telepat)) { 941. struct obj *obj; 942. const char *what; 943. 944. if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0) { 945. if (Blind && !obj->dknown) 946. what = something; 947. else if (is_pool(mtmp->mx, mtmp->my) && !Underwater) 948. what = "the water"; 949. else 950. what = doname(obj); 951. 952. pline("%s was hidden under %s!", Amonnam(mtmp), what); 953. } 954. newsym(mtmp->mx, mtmp->my); 955. } 956. } 957. 958. /* First determine the base damage done */ 959. dmg = d((int) mattk->damn, (int) mattk->damd); 960. if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight()) 961. dmg += d((int) mattk->damn, (int) mattk->damd); /* extra damage */ 962. 963. /* Next a cancellation factor. 964. * Use uncancelled when cancellation factor takes into account certain 965. * armor's special magic protection. Otherwise just use !mtmp->mcan. 966. */ 967. armpro = magic_negation(&youmonst); 968. uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro); 969. 970. permdmg = 0; 971. /* Now, adjust damages via resistances or specific attacks */ 972. switch (mattk->adtyp) { 973. case AD_PHYS: 974. if (mattk->aatyp == AT_HUGS && !sticks(youmonst.data)) { 975. if (!u.ustuck && rn2(2)) { 976. if (u_slip_free(mtmp, mattk)) { 977. dmg = 0; 978. } else { 979. u.ustuck = mtmp; 980. pline("%s grabs you!", Monnam(mtmp)); 981. } 982. } else if (u.ustuck == mtmp) { 983. exercise(A_STR, FALSE); 984. You("are being %s.", (mtmp->data == &mons[PM_ROPE_GOLEM]) 985. ? "choked" 986. : "crushed"); 987. } 988. } else { /* hand to hand weapon */ 989. struct obj *otmp = mon_currwep; 990. 991. if (mattk->aatyp == AT_WEAP && otmp) { 992. struct obj *marmg; 993. int tmp; 994. 995. if (otmp->otyp == CORPSE 996. && touch_petrifies(&mons[otmp->corpsenm])) { 997. dmg = 1; 998. pline("%s hits you with the %s corpse.", Monnam(mtmp), 999. mons[otmp->corpsenm].mname); 1000. if (!Stoned) 1001. goto do_stone; 1002. } 1003. dmg += dmgval(otmp, &youmonst); 1004. if ((marmg = which_armor(mtmp, W_ARMG)) != 0 1005. && marmg->otyp == GAUNTLETS_OF_POWER) 1006. dmg += rn1(4, 3); /* 3..6 */ 1007. if (dmg <= 0) 1008. dmg = 1; 1009. if (!(otmp->oartifact 1010. && artifact_hit(mtmp, &youmonst, otmp, &dmg, dieroll))) 1011. hitmsg(mtmp, mattk); 1012. if (!dmg) 1013. break; 1014. if (objects[otmp->otyp].oc_material == SILVER 1015. && Hate_silver) { 1016. pline_The("silver sears your flesh!"); 1017. exercise(A_CON, FALSE); 1018. } 1019. /* this redundancy necessary because you have 1020. to take the damage _before_ being cloned; 1021. need to have at least 2 hp left to split */ 1022. tmp = dmg; 1023. if (u.uac < 0) 1024. tmp -= rnd(-u.uac); 1025. if (tmp < 1) 1026. tmp = 1; 1027. if (u.mh - tmp > 1 1028. && (objects[otmp->otyp].oc_material == IRON 1029. /* relevant 'metal' objects are scalpel and tsurugi */ 1030. || objects[otmp->otyp].oc_material == METAL) 1031. && (u.umonnum == PM_BLACK_PUDDING 1032. || u.umonnum == PM_BROWN_PUDDING)) { 1033. if (tmp > 1) 1034. exercise(A_STR, FALSE); 1035. /* inflict damage now; we know it can't be fatal */ 1036. u.mh -= tmp; 1037. context.botl = 1; 1038. dmg = 0; /* don't inflict more damage below */ 1039. if (cloneu()) 1040. You("divide as %s hits you!", mon_nam(mtmp)); 1041. } 1042. rustm(&youmonst, otmp); 1043. } else if (mattk->aatyp != AT_TUCH || dmg != 0 1044. || mtmp != u.ustuck) 1045. hitmsg(mtmp, mattk); 1046. } 1047. break; 1048. case AD_DISE: 1049. hitmsg(mtmp, mattk); 1050. if (!diseasemu(mdat)) 1051. dmg = 0; 1052. break; 1053. case AD_FIRE: 1054. hitmsg(mtmp, mattk); 1055. if (uncancelled) { 1056. pline("You're %s!", on_fire(youmonst.data, mattk)); 1057. if (completelyburns(youmonst.data)) { /* paper or straw golem */ 1058. You("go up in flames!"); 1059. /* KMH -- this is okay with unchanging */ 1060. rehumanize(); 1061. break; 1062. } else if (Fire_resistance) { 1063. pline_The("fire doesn't feel hot!"); 1064. dmg = 0; 1065. } 1066. if ((int) mtmp->m_lev > rn2(20)) 1067. destroy_item(SCROLL_CLASS, AD_FIRE); 1068. if ((int) mtmp->m_lev > rn2(20)) 1069. destroy_item(POTION_CLASS, AD_FIRE); 1070. if ((int) mtmp->m_lev > rn2(25)) 1071. destroy_item(SPBOOK_CLASS, AD_FIRE); 1072. burn_away_slime(); 1073. } else 1074. dmg = 0; 1075. break; 1076. case AD_COLD: 1077. hitmsg(mtmp, mattk); 1078. if (uncancelled) { 1079. pline("You're covered in frost!"); 1080. if (Cold_resistance) { 1081. pline_The("frost doesn't seem cold!"); 1082. dmg = 0; 1083. } 1084. if ((int) mtmp->m_lev > rn2(20)) 1085. destroy_item(POTION_CLASS, AD_COLD); 1086. } else 1087. dmg = 0; 1088. break; 1089. case AD_ELEC: 1090. hitmsg(mtmp, mattk); 1091. if (uncancelled) { 1092. You("get zapped!"); 1093. if (Shock_resistance) { 1094. pline_The("zap doesn't shock you!"); 1095. dmg = 0; 1096. } 1097. if ((int) mtmp->m_lev > rn2(20)) 1098. destroy_item(WAND_CLASS, AD_ELEC); 1099. if ((int) mtmp->m_lev > rn2(20)) 1100. destroy_item(RING_CLASS, AD_ELEC); 1101. } else 1102. dmg = 0; 1103. break; 1104. case AD_SLEE: 1105. hitmsg(mtmp, mattk); 1106. if (uncancelled && multi >= 0 && !rn2(5)) { 1107. if (Sleep_resistance) 1108. break; 1109. fall_asleep(-rnd(10), TRUE); 1110. if (Blind) 1111. You("are put to sleep!"); 1112. else 1113. You("are put to sleep by %s!", mon_nam(mtmp)); 1114. } 1115. break; 1116. case AD_BLND: 1117. if (can_blnd(mtmp, &youmonst, mattk->aatyp, (struct obj *) 0)) { 1118. if (!Blind) 1119. pline("%s blinds you!", Monnam(mtmp)); 1120. make_blinded(Blinded + (long) dmg, FALSE); 1121. if (!Blind) 1122. Your1(vision_clears); 1123. } 1124. dmg = 0; 1125. break; 1126. case AD_DRST: 1127. ptmp = A_STR; 1128. goto dopois; 1129. case AD_DRDX: 1130. ptmp = A_DEX; 1131. goto dopois; 1132. case AD_DRCO: 1133. ptmp = A_CON; 1134. dopois: 1135. hitmsg(mtmp, mattk); 1136. if (uncancelled && !rn2(8)) { 1137. Sprintf(buf, "%s %s", s_suffix(Monnam(mtmp)), 1138. mpoisons_subj(mtmp, mattk)); 1139. poisoned(buf, ptmp, mdat->mname, 30, FALSE); 1140. } 1141. break; 1142. case AD_DRIN: 1143. hitmsg(mtmp, mattk); 1144. if (defends(AD_DRIN, uwep) || !has_head(youmonst.data)) { 1145. You("don't seem harmed."); 1146. /* Not clear what to do for green slimes */ 1147. break; 1148. } 1149. if (u_slip_free(mtmp, mattk)) 1150. break; 1151. 1152. if (uarmh && rn2(8)) { 1153. /* not body_part(HEAD) */ 1154. Your("%s blocks the attack to your head.", 1155. helm_simple_name(uarmh)); 1156. break; 1157. } 1158. /* negative armor class doesn't reduce this damage */ 1159. if (Half_physical_damage) 1160. dmg = (dmg + 1) / 2; 1161. mdamageu(mtmp, dmg); 1162. dmg = 0; /* don't inflict a second dose below */ 1163. 1164. if (!uarmh || uarmh->otyp != DUNCE_CAP) { 1165. /* eat_brains() will miss if target is mindless (won't 1166. happen here; hero is considered to retain his mind 1167. regardless of current shape) or is noncorporeal 1168. (can't happen here; no one can poly into a ghost 1169. or shade) so this check for missing is academic */ 1170. if (eat_brains(mtmp, &youmonst, TRUE, (int *) 0) == MM_MISS) 1171. break; 1172. } 1173. /* adjattrib gives dunce cap message when appropriate */ 1174. (void) adjattrib(A_INT, -rnd(2), FALSE); 1175. forget_levels(25); /* lose memory of 25% of levels */ 1176. forget_objects(25); /* lose memory of 25% of objects */ 1177. break; 1178. case AD_PLYS: 1179. hitmsg(mtmp, mattk); 1180. if (uncancelled && multi >= 0 && !rn2(3)) { 1181. if (Free_action) { 1182. You("momentarily stiffen."); 1183. } else { 1184. if (Blind) 1185. You("are frozen!"); 1186. else 1187. You("are frozen by %s!", mon_nam(mtmp)); 1188. nomovemsg = You_can_move_again; 1189. nomul(-rnd(10)); 1190. multi_reason = "paralyzed by a monster"; 1191. exercise(A_DEX, FALSE); 1192. } 1193. } 1194. break; 1195. case AD_DRLI: 1196. hitmsg(mtmp, mattk); 1197. if (uncancelled && !rn2(3) && !Drain_resistance) { 1198. losexp("life drainage"); 1199. } 1200. break; 1201. case AD_LEGS: { 1202. long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE; 1203. const char *sidestr = (side == RIGHT_SIDE) ? "right" : "left", 1204. *Monst_name = Monnam(mtmp), *leg = body_part(LEG); 1205. 1206. /* This case is too obvious to ignore, but Nethack is not in 1207. * general very good at considering height--most short monsters 1208. * still _can_ attack you when you're flying or mounted. 1209. */ 1210. if ((u.usteed || Levitation || Flying) && !is_flyer(mtmp->data)) { 1211. pline("%s tries to reach your %s %s!", Monst_name, sidestr, leg); 1212. dmg = 0; 1213. } else if (mtmp->mcan) { 1214. pline("%s nuzzles against your %s %s!", Monnam(mtmp), 1215. sidestr, leg); 1216. dmg = 0; 1217. } else { 1218. if (uarmf) { 1219. if (rn2(2) && (uarmf->otyp == LOW_BOOTS 1220. || uarmf->otyp == IRON_SHOES)) { 1221. pline("%s pricks the exposed part of your %s %s!", 1222. Monst_name, sidestr, leg); 1223. } else if (!rn2(5)) { 1224. pline("%s pricks through your %s boot!", Monst_name, 1225. sidestr); 1226. } else { 1227. pline("%s scratches your %s boot!", Monst_name, 1228. sidestr); 1229. dmg = 0; 1230. break; 1231. } 1232. } else 1233. pline("%s pricks your %s %s!", Monst_name, sidestr, leg); 1234. 1235. set_wounded_legs(side, rnd(60 - ACURR(A_DEX))); 1236. exercise(A_STR, FALSE); 1237. exercise(A_DEX, FALSE); 1238. } 1239. break; 1240. } 1241. case AD_STON: /* cockatrice */ 1242. hitmsg(mtmp, mattk); 1243. if (!rn2(3)) { 1244. if (mtmp->mcan) { 1245. if (!Deaf) 1246. You_hear("a cough from %s!", mon_nam(mtmp)); 1247. } else { 1248. if (!Deaf) 1249. You_hear("%s hissing!", s_suffix(mon_nam(mtmp))); 1250. if (!rn2(10) 1251. || (flags.moonphase == NEW_MOON && !have_lizard())) { 1252. do_stone: 1253. if (!Stoned && !Stone_resistance 1254. && !(poly_when_stoned(youmonst.data) 1255. && polymon(PM_STONE_GOLEM))) { 1256. int kformat = KILLED_BY_AN; 1257. const char *kname = mtmp->data->mname; 1258. 1259. if (mtmp->data->geno & G_UNIQ) { 1260. if (!type_is_pname(mtmp->data)) 1261. kname = the(kname); 1262. kformat = KILLED_BY; 1263. } 1264. make_stoned(5L, (char *) 0, kformat, kname); 1265. return 1; 1266. /* done_in_by(mtmp, STONING); */ 1267. } 1268. } 1269. } 1270. } 1271. break; 1272. case AD_STCK: 1273. hitmsg(mtmp, mattk); 1274. if (uncancelled && !u.ustuck && !sticks(youmonst.data)) 1275. u.ustuck = mtmp; 1276. break; 1277. case AD_WRAP: 1278. if ((!mtmp->mcan || u.ustuck == mtmp) && !sticks(youmonst.data)) { 1279. if (!u.ustuck && !rn2(10)) { 1280. if (u_slip_free(mtmp, mattk)) { 1281. dmg = 0; 1282. } else { 1283. pline("%s swings itself around you!", Monnam(mtmp)); 1284. u.ustuck = mtmp; 1285. } 1286. } else if (u.ustuck == mtmp) { 1287. if (is_pool(mtmp->mx, mtmp->my) && !Swimming && !Amphibious) { 1288. boolean moat = (levl[mtmp->mx][mtmp->my].typ != POOL) 1289. && (levl[mtmp->mx][mtmp->my].typ != WATER) 1290. && !Is_medusa_level(&u.uz) 1291. && !Is_waterlevel(&u.uz); 1292. 1293. pline("%s drowns you...", Monnam(mtmp)); 1294. killer.format = KILLED_BY_AN; 1295. Sprintf(killer.name, "%s by %s", 1296. moat ? "moat" : "pool of water", 1297. an(mtmp->data->mname)); 1298. done(DROWNING); 1299. } else if (mattk->aatyp == AT_HUGS) 1300. You("are being crushed."); 1301. } else { 1302. dmg = 0; 1303. if (flags.verbose) 1304. pline("%s brushes against your %s.", Monnam(mtmp), 1305. body_part(LEG)); 1306. } 1307. } else 1308. dmg = 0; 1309. break; 1310. case AD_WERE: 1311. hitmsg(mtmp, mattk); 1312. if (uncancelled && !rn2(4) && u.ulycn == NON_PM 1313. && !Protection_from_shape_changers && !defends(AD_WERE, uwep)) { 1314. You_feel("feverish."); 1315. exercise(A_CON, FALSE); 1316. set_ulycn(monsndx(mdat)); 1317. retouch_equipment(2); 1318. } 1319. break; 1320. case AD_SGLD: 1321. hitmsg(mtmp, mattk); 1322. if (youmonst.data->mlet == mdat->mlet) 1323. break; 1324. if (!mtmp->mcan) 1325. stealgold(mtmp); 1326. break; 1327. 1328. case AD_SSEX: 1329. if (SYSOPT_SEDUCE) { 1330. if (could_seduce(mtmp, &youmonst, mattk) == 1 && !mtmp->mcan) 1331. if (doseduce(mtmp)) 1332. return 3; 1333. break; 1334. } 1335. /*FALLTHRU*/ 1336. case AD_SITM: /* for now these are the same */ 1337. case AD_SEDU: 1338. if (is_animal(mtmp->data)) { 1339. hitmsg(mtmp, mattk); 1340. if (mtmp->mcan) 1341. break; 1342. /* Continue below */ 1343. } else if (dmgtype(youmonst.data, AD_SEDU) 1344. /* !SYSOPT_SEDUCE: when hero is attacking and AD_SSEX 1345. is disabled, it would be changed to another damage 1346. type, but when defending, it remains as-is */ 1347. || dmgtype(youmonst.data, AD_SSEX)) { 1348. pline("%s %s.", Monnam(mtmp), 1349. Deaf ? "says something but you can't hear it" 1350. : mtmp->minvent 1351. ? "brags about the goods some dungeon explorer provided" 1352. : "makes some remarks about how difficult theft is lately"); 1353. if (!tele_restrict(mtmp)) 1354. (void) rloc(mtmp, TRUE); 1355. return 3; 1356. } else if (mtmp->mcan) { 1357. if (!Blind) 1358. pline("%s tries to %s you, but you seem %s.", 1359. Adjmonnam(mtmp, "plain"), 1360. flags.female ? "charm" : "seduce", 1361. flags.female ? "unaffected" : "uninterested"); 1362. if (rn2(3)) { 1363. if (!tele_restrict(mtmp)) 1364. (void) rloc(mtmp, TRUE); 1365. return 3; 1366. } 1367. break; 1368. } 1369. buf[0] = '\0'; 1370. switch (steal(mtmp, buf)) { 1371. case -1: 1372. return 2; 1373. case 0: 1374. break; 1375. default: 1376. if (!is_animal(mtmp->data) && !tele_restrict(mtmp)) 1377. (void) rloc(mtmp, TRUE); 1378. if (is_animal(mtmp->data) && *buf) { 1379. if (canseemon(mtmp)) 1380. pline("%s tries to %s away with %s.", Monnam(mtmp), 1381. locomotion(mtmp->data, "run"), buf); 1382. } 1383. monflee(mtmp, 0, FALSE, FALSE); 1384. return 3; 1385. } 1386. break; 1387. 1388. case AD_SAMU: 1389. hitmsg(mtmp, mattk); 1390. /* when the Wizard or quest nemesis hits, there's a 1/20 chance 1391. to steal a quest artifact (any, not just the one for the hero's 1392. own role) or the Amulet or one of the invocation tools */ 1393. if (!rn2(20)) 1394. stealamulet(mtmp); 1395. break; 1396. 1397. case AD_TLPT: 1398. hitmsg(mtmp, mattk); 1399. if (uncancelled) { 1400. if (flags.verbose) 1401. Your("position suddenly seems %suncertain!", 1402. (Teleport_control && !Stunned && !unconscious()) ? "" 1403. : "very "); 1404. tele(); 1405. /* As of 3.6.2: make sure damage isn't fatal; previously, it 1406. was possible to be teleported and then drop dead at 1407. the destination when QM's 1d4 damage gets applied below; 1408. even though that wasn't "wrong", it seemed strange, 1409. particularly if the teleportation had been controlled 1410. [applying the damage first and not teleporting if fatal 1411. is another alternative but it has its own complications] */ 1412. if ((Half_physical_damage ? (dmg - 1) / 2 : dmg) 1413. >= (tmphp = (Upolyd ? u.mh : u.uhp))) { 1414. dmg = tmphp - 1; 1415. if (Half_physical_damage) 1416. dmg *= 2; /* doesn't actually increase damage; we only 1417. * get here if half the original damage would 1418. * would have been fatal, so double reduced 1419. * damage will be less than original damage */ 1420. if (dmg < 1) { /* implies (tmphp <= 1) */ 1421. dmg = 1; 1422. /* this might increase current HP beyond maximum HP but 1423. it will be immediately reduced below, so that should 1424. be indistinguishable from zero damage; we don't drop 1425. damage all the way to zero because that inhibits any 1426. passive counterattack if poly'd hero has one */ 1427. if (Upolyd && u.mh == 1) 1428. ++u.mh; 1429. else if (!Upolyd && u.uhp == 1) 1430. ++u.uhp; 1431. /* [don't set context.botl here] */ 1432. } 1433. } 1434. } 1435. break; 1436. case AD_RUST: 1437. hitmsg(mtmp, mattk); 1438. if (mtmp->mcan) 1439. break; 1440. if (u.umonnum == PM_IRON_GOLEM) { 1441. You("rust!"); 1442. /* KMH -- this is okay with unchanging */ 1443. rehumanize(); 1444. break; 1445. } 1446. erode_armor(&youmonst, ERODE_RUST); 1447. break; 1448. case AD_CORR: 1449. hitmsg(mtmp, mattk); 1450. if (mtmp->mcan) 1451. break; 1452. erode_armor(&youmonst, ERODE_CORRODE); 1453. break; 1454. case AD_DCAY: 1455. hitmsg(mtmp, mattk); 1456. if (mtmp->mcan) 1457. break; 1458. if (u.umonnum == PM_WOOD_GOLEM || u.umonnum == PM_LEATHER_GOLEM) { 1459. You("rot!"); 1460. /* KMH -- this is okay with unchanging */ 1461. rehumanize(); 1462. break; 1463. } 1464. erode_armor(&youmonst, ERODE_ROT); 1465. break; 1466. case AD_HEAL: 1467. /* a cancelled nurse is just an ordinary monster, 1468. * nurses don't heal those that cause petrification */ 1469. if (mtmp->mcan || (Upolyd && touch_petrifies(youmonst.data))) { 1470. hitmsg(mtmp, mattk); 1471. break; 1472. } 1473. if (!uwep && !uarmu && !uarm && !uarmc 1474. && !uarms && !uarmg && !uarmf && !uarmh) { 1475. boolean goaway = FALSE; 1476. 1477. pline("%s hits! (I hope you don't mind.)", Monnam(mtmp)); 1478. if (Upolyd) { 1479. u.mh += rnd(7); 1480. if (!rn2(7)) { 1481. /* no upper limit necessary; effect is temporary */ 1482. u.mhmax++; 1483. if (!rn2(13)) 1484. goaway = TRUE; 1485. } 1486. if (u.mh > u.mhmax) 1487. u.mh = u.mhmax; 1488. } else { 1489. u.uhp += rnd(7); 1490. if (!rn2(7)) { 1491. /* hard upper limit via nurse care: 25 * ulevel */ 1492. if (u.uhpmax < 5 * u.ulevel + d(2 * u.ulevel, 10)) 1493. u.uhpmax++; 1494. if (!rn2(13)) 1495. goaway = TRUE; 1496. } 1497. if (u.uhp > u.uhpmax) 1498. u.uhp = u.uhpmax; 1499. } 1500. if (!rn2(3)) 1501. exercise(A_STR, TRUE); 1502. if (!rn2(3)) 1503. exercise(A_CON, TRUE); 1504. if (Sick) 1505. make_sick(0L, (char *) 0, FALSE, SICK_ALL); 1506. context.botl = 1; 1507. if (goaway) { 1508. mongone(mtmp); 1509. return 2; 1510. } else if (!rn2(33)) { 1511. if (!tele_restrict(mtmp)) 1512. (void) rloc(mtmp, TRUE); 1513. monflee(mtmp, d(3, 6), TRUE, FALSE); 1514. return 3; 1515. } 1516. dmg = 0; 1517. } else { 1518. if (Role_if(PM_HEALER)) { 1519. if (!Deaf && !(moves % 5)) 1520. verbalize("Doc, I can't help you unless you cooperate."); 1521. dmg = 0; 1522. } else 1523. hitmsg(mtmp, mattk); 1524. } 1525. break; 1526. case AD_CURS: 1527. hitmsg(mtmp, mattk); 1528. if (!night() && mdat == &mons[PM_GREMLIN]) 1529. break; 1530. if (!mtmp->mcan && !rn2(10)) { 1531. if (!Deaf) { 1532. if (Blind) 1533. You_hear("laughter."); 1534. else 1535. pline("%s chuckles.", Monnam(mtmp)); 1536. } 1537. if (u.umonnum == PM_CLAY_GOLEM) { 1538. pline("Some writing vanishes from your head!"); 1539. /* KMH -- this is okay with unchanging */ 1540. rehumanize(); 1541. break; 1542. } 1543. attrcurse(); 1544. } 1545. break; 1546. case AD_STUN: 1547. hitmsg(mtmp, mattk); 1548. if (!mtmp->mcan && !rn2(4)) { 1549. make_stunned((HStun & TIMEOUT) + (long) dmg, TRUE); 1550. dmg /= 2; 1551. } 1552. break; 1553. case AD_ACID: 1554. hitmsg(mtmp, mattk); 1555. if (!mtmp->mcan && !rn2(3)) 1556. if (Acid_resistance) { 1557. pline("You're covered in %s, but it seems harmless.", 1558. hliquid("acid")); 1559. dmg = 0; 1560. } else { 1561. pline("You're covered in %s! It burns!", hliquid("acid")); 1562. exercise(A_STR, FALSE); 1563. } 1564. else 1565. dmg = 0; 1566. break; 1567. case AD_SLOW: 1568. hitmsg(mtmp, mattk); 1569. if (uncancelled && HFast && !defends(AD_SLOW, uwep) && !rn2(4)) 1570. u_slow_down(); 1571. break; 1572. case AD_DREN: 1573. hitmsg(mtmp, mattk); 1574. if (uncancelled && !rn2(4)) /* 25% chance */ 1575. drain_en(dmg); 1576. dmg = 0; 1577. break; 1578. case AD_CONF: 1579. hitmsg(mtmp, mattk); 1580. if (!mtmp->mcan && !rn2(4) && !mtmp->mspec_used) { 1581. mtmp->mspec_used = mtmp->mspec_used + (dmg + rn2(6)); 1582. if (Confusion) 1583. You("are getting even more confused."); 1584. else 1585. You("are getting confused."); 1586. make_confused(HConfusion + dmg, FALSE); 1587. } 1588. dmg = 0; 1589. break; 1590. case AD_DETH: 1591. pline("%s reaches out with its deadly touch.", Monnam(mtmp)); 1592. if (is_undead(youmonst.data)) { 1593. /* Still does normal damage */ 1594. pline("Was that the touch of death?"); 1595. break; 1596. } 1597. switch (rn2(20)) { 1598. case 19: 1599. case 18: 1600. case 17: 1601. if (!Antimagic) { 1602. killer.format = KILLED_BY_AN; 1603. Strcpy(killer.name, "touch of death"); 1604. done(DIED); 1605. dmg = 0; 1606. break; 1607. } 1608. /*FALLTHRU*/ 1609. default: /* case 16: ... case 5: */ 1610. You_feel("your life force draining away..."); 1611. permdmg = 1; /* actual damage done below */ 1612. break; 1613. case 4: 1614. case 3: 1615. case 2: 1616. case 1: 1617. case 0: 1618. if (Antimagic) 1619. shieldeff(u.ux, u.uy); 1620. pline("Lucky for you, it didn't work!"); 1621. dmg = 0; 1622. break; 1623. } 1624. break; 1625. case AD_PEST: 1626. pline("%s reaches out, and you feel fever and chills.", Monnam(mtmp)); 1627. (void) diseasemu(mdat); /* plus the normal damage */ 1628. break; 1629. case AD_FAMN: 1630. pline("%s reaches out, and your body shrivels.", Monnam(mtmp)); 1631. exercise(A_CON, FALSE); 1632. if (!is_fainted()) 1633. morehungry(rn1(40, 40)); 1634. /* plus the normal damage */ 1635. break; 1636. case AD_SLIM: 1637. hitmsg(mtmp, mattk); 1638. if (!uncancelled) 1639. break; 1640. if (flaming(youmonst.data)) { 1641. pline_The("slime burns away!"); 1642. dmg = 0; 1643. } else if (Unchanging || noncorporeal(youmonst.data) 1644. || youmonst.data == &mons[PM_GREEN_SLIME]) { 1645. You("are unaffected."); 1646. dmg = 0; 1647. } else if (!Slimed) { 1648. You("don't feel very well."); 1649. make_slimed(10L, (char *) 0); 1650. delayed_killer(SLIMED, KILLED_BY_AN, mtmp->data->mname); 1651. } else 1652. pline("Yuck!"); 1653. break; 1654. case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */ 1655. hitmsg(mtmp, mattk); 1656. /* uncancelled is sufficient enough; please 1657. don't make this attack less frequent */ 1658. if (uncancelled) { 1659. struct obj *obj = some_armor(&youmonst); 1660. 1661. if (!obj) { 1662. /* some rings are susceptible; 1663. amulets and blindfolds aren't (at present) */ 1664. switch (rn2(5)) { 1665. case 0: 1666. break; 1667. case 1: 1668. obj = uright; 1669. break; 1670. case 2: 1671. obj = uleft; 1672. break; 1673. case 3: 1674. obj = uamul; 1675. break; 1676. case 4: 1677. obj = ublindf; 1678. break; 1679. } 1680. } 1681. if (drain_item(obj, FALSE)) { 1682. pline("%s less effective.", Yobjnam2(obj, "seem")); 1683. } 1684. } 1685. break; 1686. default: 1687. dmg = 0; 1688. break; 1689. } 1690. if ((Upolyd ? u.mh : u.uhp) < 1) { 1691. /* already dead? call rehumanize() or done_in_by() as appropriate */ 1692. mdamageu(mtmp, 1); 1693. dmg = 0; 1694. } 1695. 1696. /* Negative armor class reduces damage done instead of fully protecting 1697. * against hits. 1698. */ 1699. if (dmg && u.uac < 0) { 1700. dmg -= rnd(-u.uac); 1701. if (dmg < 1) 1702. dmg = 1; 1703. } 1704. 1705. if (dmg) { 1706. if (Half_physical_damage 1707. /* Mitre of Holiness */ 1708. || (Role_if(PM_PRIEST) && uarmh && is_quest_artifact(uarmh) 1709. && (is_undead(mtmp->data) || is_demon(mtmp->data) 1710. || is_vampshifter(mtmp)))) 1711. dmg = (dmg + 1) / 2; 1712. 1713. if (permdmg) { /* Death's life force drain */ 1714. int lowerlimit, *hpmax_p; 1715. /* 1716. * Apply some of the damage to permanent hit points: 1717. * polymorphed 100% against poly'd hpmax 1718. * hpmax > 25*lvl 100% against normal hpmax 1719. * hpmax > 10*lvl 50..100% 1720. * hpmax > 5*lvl 25..75% 1721. * otherwise 0..50% 1722. * Never reduces hpmax below 1 hit point per level. 1723. */ 1724. permdmg = rn2(dmg / 2 + 1); 1725. if (Upolyd || u.uhpmax > 25 * u.ulevel) 1726. permdmg = dmg; 1727. else if (u.uhpmax > 10 * u.ulevel) 1728. permdmg += dmg / 2; 1729. else if (u.uhpmax > 5 * u.ulevel) 1730. permdmg += dmg / 4; 1731. 1732. if (Upolyd) { 1733. hpmax_p = &u.mhmax; 1734. /* [can't use youmonst.m_lev] */ 1735. lowerlimit = min((int) youmonst.data->mlevel, u.ulevel); 1736. } else { 1737. hpmax_p = &u.uhpmax; 1738. lowerlimit = u.ulevel; 1739. } 1740. if (*hpmax_p - permdmg > lowerlimit) 1741. *hpmax_p -= permdmg; 1742. else if (*hpmax_p > lowerlimit) 1743. *hpmax_p = lowerlimit; 1744. /* else unlikely... 1745. * already at or below minimum threshold; do nothing */ 1746. context.botl = 1; 1747. } 1748. 1749. mdamageu(mtmp, dmg); 1750. } 1751. 1752. if (dmg) 1753. res = passiveum(olduasmon, mtmp, mattk); 1754. else 1755. res = 1; 1756. stop_occupation(); 1757. return res; 1758. } 1759. 1760. /* An interface for use when taking a blindfold off, for example, 1761. * to see if an engulfing attack should immediately take affect, like 1762. * a passive attack. TRUE if engulfing blindness occurred */ 1763. boolean 1764. gulp_blnd_check() 1765. { 1766. struct attack *mattk; 1767. 1768. if (!Blinded && u.uswallow 1769. && (mattk = attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND)) 1770. && can_blnd(u.ustuck, &youmonst, mattk->aatyp, (struct obj *) 0)) { 1771. ++u.uswldtim; /* compensate for gulpmu change */ 1772. (void) gulpmu(u.ustuck, mattk); 1773. return TRUE; 1774. } 1775. return FALSE; 1776. } 1777. 1778. /* monster swallows you, or damage if u.uswallow */ 1779. STATIC_OVL int 1780. gulpmu(mtmp, mattk) 1781. struct monst *mtmp; 1782. struct attack *mattk; 1783. { 1784. struct trap *t = t_at(u.ux, u.uy); 1785. int tmp = d((int) mattk->damn, (int) mattk->damd); 1786. int tim_tmp; 1787. struct obj *otmp2; 1788. int i; 1789. boolean physical_damage = FALSE; 1790. 1791. if (!u.uswallow) { /* swallows you */ 1792. int omx = mtmp->mx, omy = mtmp->my; 1793. 1794. if (!engulf_target(mtmp, &youmonst)) 1795. return 0; 1796. if ((t && is_pit(t->ttyp)) && sobj_at(BOULDER, u.ux, u.uy)) 1797. return 0; 1798. 1799. if (Punished) 1800. unplacebc(); /* ball&chain go away */ 1801. remove_monster(omx, omy); 1802. mtmp->mtrapped = 0; /* no longer on old trap */ 1803. place_monster(mtmp, u.ux, u.uy); 1804. u.ustuck = mtmp; 1805. newsym(mtmp->mx, mtmp->my); 1806. if (is_animal(mtmp->data) && u.usteed) { 1807. char buf[BUFSZ]; 1808. 1809. /* Too many quirks presently if hero and steed 1810. * are swallowed. Pretend purple worms don't 1811. * like horses for now :-) 1812. */ 1813. Strcpy(buf, mon_nam(u.usteed)); 1814. pline("%s lunges forward and plucks you off %s!", Monnam(mtmp), 1815. buf); 1816. dismount_steed(DISMOUNT_ENGULFED); 1817. } else 1818. pline("%s engulfs you!", Monnam(mtmp)); 1819. stop_occupation(); 1820. reset_occupations(); /* behave as if you had moved */ 1821. 1822. if (u.utrap) { 1823. You("are released from the %s!", 1824. u.utraptype == TT_WEB ? "web" : "trap"); 1825. reset_utrap(FALSE); 1826. } 1827. 1828. i = number_leashed(); 1829. if (i > 0) { 1830. const char *s = (i > 1) ? "leashes" : "leash"; 1831. 1832. pline_The("%s %s loose.", s, vtense(s, "snap")); 1833. unleash_all(); 1834. } 1835. 1836. if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) { 1837. /* put the attacker back where it started; 1838. the resulting statue will end up there */ 1839. remove_monster(mtmp->mx, mtmp->my); /* u.ux,u.uy */ 1840. place_monster(mtmp, omx, omy); 1841. minstapetrify(mtmp, TRUE); 1842. /* normally unstuck() would do this, but we're not 1843. fully swallowed yet so that won't work here */ 1844. if (Punished) 1845. placebc(); 1846. u.ustuck = 0; 1847. return (!DEADMONSTER(mtmp)) ? 0 : 2; 1848. } 1849. 1850. display_nhwindow(WIN_MESSAGE, FALSE); 1851. vision_recalc(2); /* hero can't see anything */ 1852. u.uswallow = 1; 1853. /* for digestion, shorter time is more dangerous; 1854. for other swallowings, longer time means more 1855. chances for the swallower to attack */ 1856. if (mattk->adtyp == AD_DGST) { 1857. tim_tmp = 25 - (int) mtmp->m_lev; 1858. if (tim_tmp > 0) 1859. tim_tmp = rnd(tim_tmp) / 2; 1860. else if (tim_tmp < 0) 1861. tim_tmp = -(rnd(-tim_tmp) / 2); 1862. /* having good armor & high constitution makes 1863. it take longer for you to be digested, but 1864. you'll end up trapped inside for longer too */ 1865. tim_tmp += -u.uac + 10 + (ACURR(A_CON) / 3 - 1); 1866. } else { 1867. /* higher level attacker takes longer to eject hero */ 1868. tim_tmp = rnd((int) mtmp->m_lev + 10 / 2); 1869. } 1870. /* u.uswldtim always set > 1 */ 1871. u.uswldtim = (unsigned) ((tim_tmp < 2) ? 2 : tim_tmp); 1872. swallowed(1); 1873. for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj) 1874. (void) snuff_lit(otmp2); 1875. } 1876. 1877. if (mtmp != u.ustuck) 1878. return 0; 1879. if (Punished) { 1880. /* ball&chain are in limbo while swallowed; update their internal 1881. location to be at swallower's spot */ 1882. if (uchain->where == OBJ_FREE) 1883. uchain->ox = mtmp->mx, uchain->oy = mtmp->my; 1884. if (uball->where == OBJ_FREE) 1885. uball->ox = mtmp->mx, uball->oy = mtmp->my; 1886. } 1887. if (u.uswldtim > 0) 1888. u.uswldtim -= 1; 1889. 1890. switch (mattk->adtyp) { 1891. case AD_DGST: 1892. physical_damage = TRUE; 1893. if (Slow_digestion) { 1894. /* Messages are handled below */ 1895. u.uswldtim = 0; 1896. tmp = 0; 1897. } else if (u.uswldtim == 0) { 1898. pline("%s totally digests you!", Monnam(mtmp)); 1899. tmp = u.uhp; 1900. if (Half_physical_damage) 1901. tmp *= 2; /* sorry */ 1902. } else { 1903. pline("%s%s digests you!", Monnam(mtmp), 1904. (u.uswldtim == 2) ? " thoroughly" 1905. : (u.uswldtim == 1) ? " utterly" : ""); 1906. exercise(A_STR, FALSE); 1907. } 1908. break; 1909. case AD_PHYS: 1910. physical_damage = TRUE; 1911. if (mtmp->data == &mons[PM_FOG_CLOUD]) { 1912. You("are laden with moisture and %s", 1913. flaming(youmonst.data) 1914. ? "are smoldering out!" 1915. : Breathless ? "find it mildly uncomfortable." 1916. : amphibious(youmonst.data) 1917. ? "feel comforted." 1918. : "can barely breathe!"); 1919. /* NB: Amphibious includes Breathless */ 1920. if (Amphibious && !flaming(youmonst.data)) 1921. tmp = 0; 1922. } else { 1923. You("are pummeled with debris!"); 1924. exercise(A_STR, FALSE); 1925. } 1926. break; 1927. case AD_ACID: 1928. if (Acid_resistance) { 1929. You("are covered with a seemingly harmless goo."); 1930. tmp = 0; 1931. } else { 1932. if (Hallucination) 1933. pline("Ouch! You've been slimed!"); 1934. else 1935. You("are covered in slime! It burns!"); 1936. exercise(A_STR, FALSE); 1937. } 1938. break; 1939. case AD_BLND: 1940. if (can_blnd(mtmp, &youmonst, mattk->aatyp, (struct obj *) 0)) { 1941. if (!Blind) { 1942. long was_blinded = Blinded; 1943. 1944. if (!Blinded) 1945. You_cant("see in here!"); 1946. make_blinded((long) tmp, FALSE); 1947. if (!was_blinded && !Blind) 1948. Your1(vision_clears); 1949. } else 1950. /* keep him blind until disgorged */ 1951. make_blinded(Blinded + 1, FALSE); 1952. } 1953. tmp = 0; 1954. break; 1955. case AD_ELEC: 1956. if (!mtmp->mcan && rn2(2)) { 1957. pline_The("air around you crackles with electricity."); 1958. if (Shock_resistance) { 1959. shieldeff(u.ux, u.uy); 1960. You("seem unhurt."); 1961. ugolemeffects(AD_ELEC, tmp); 1962. tmp = 0; 1963. } 1964. } else 1965. tmp = 0; 1966. break; 1967. case AD_COLD: 1968. if (!mtmp->mcan && rn2(2)) { 1969. if (Cold_resistance) { 1970. shieldeff(u.ux, u.uy); 1971. You_feel("mildly chilly."); 1972. ugolemeffects(AD_COLD, tmp); 1973. tmp = 0; 1974. } else 1975. You("are freezing to death!"); 1976. } else 1977. tmp = 0; 1978. break; 1979. case AD_FIRE: 1980. if (!mtmp->mcan && rn2(2)) { 1981. if (Fire_resistance) { 1982. shieldeff(u.ux, u.uy); 1983. You_feel("mildly hot."); 1984. ugolemeffects(AD_FIRE, tmp); 1985. tmp = 0; 1986. } else 1987. You("are burning to a crisp!"); 1988. burn_away_slime(); 1989. } else 1990. tmp = 0; 1991. break; 1992. case AD_DISE: 1993. if (!diseasemu(mtmp->data)) 1994. tmp = 0; 1995. break; 1996. case AD_DREN: 1997. /* AC magic cancellation doesn't help when engulfed */ 1998. if (!mtmp->mcan && rn2(4)) /* 75% chance */ 1999. drain_en(tmp); 2000. tmp = 0; 2001. break; 2002. default: 2003. physical_damage = TRUE; 2004. tmp = 0; 2005. break; 2006. } 2007. 2008. if (physical_damage) 2009. tmp = Maybe_Half_Phys(tmp); 2010. 2011. mdamageu(mtmp, tmp); 2012. if (tmp) 2013. stop_occupation(); 2014. 2015. if (!u.uswallow) { 2016. ; /* life-saving has already expelled swallowed hero */ 2017. } else if (touch_petrifies(youmonst.data) && !resists_ston(mtmp)) { 2018. pline("%s very hurriedly %s you!", Monnam(mtmp), 2019. is_animal(mtmp->data) ? "regurgitates" : "expels"); 2020. expels(mtmp, mtmp->data, FALSE); 2021. } else if (!u.uswldtim || youmonst.data->msize >= MZ_HUGE) { 2022. /* As of 3.6.2: u.uswldtim used to be set to 0 by life-saving but it 2023. expels now so the !u.uswldtim case is no longer possible; 2024. however, polymorphing into a huge form while already 2025. swallowed is still possible */ 2026. You("get %s!", is_animal(mtmp->data) ? "regurgitated" : "expelled"); 2027. if (flags.verbose 2028. && (is_animal(mtmp->data) 2029. || (dmgtype(mtmp->data, AD_DGST) && Slow_digestion))) 2030. pline("Obviously %s doesn't like your taste.", mon_nam(mtmp)); 2031. expels(mtmp, mtmp->data, FALSE); 2032. } 2033. return 1; 2034. } 2035. 2036. /* monster explodes in your face */ 2037. STATIC_OVL int 2038. explmu(mtmp, mattk, ufound) 2039. struct monst *mtmp; 2040. struct attack *mattk; 2041. boolean ufound; 2042. { 2043. boolean physical_damage = TRUE, kill_agr = TRUE; 2044. 2045. if (mtmp->mcan) 2046. return 0; 2047. 2048. if (!ufound) { 2049. pline("%s explodes at a spot in %s!", 2050. canseemon(mtmp) ? Monnam(mtmp) : "It", 2051. levl[mtmp->mux][mtmp->muy].typ == WATER ? "empty water" 2052. : "thin air"); 2053. } else { 2054. int tmp = d((int) mattk->damn, (int) mattk->damd); 2055. boolean not_affected = defends((int) mattk->adtyp, uwep); 2056. 2057. hitmsg(mtmp, mattk); 2058. 2059. switch (mattk->adtyp) { 2060. case AD_COLD: 2061. physical_damage = FALSE; 2062. not_affected |= Cold_resistance; 2063. goto common; 2064. case AD_FIRE: 2065. physical_damage = FALSE; 2066. not_affected |= Fire_resistance; 2067. goto common; 2068. case AD_ELEC: 2069. physical_damage = FALSE; 2070. not_affected |= Shock_resistance; 2071. goto common; 2072. case AD_PHYS: 2073. /* there aren't any exploding creatures with AT_EXPL attack 2074. for AD_PHYS damage but there might be someday; without this, 2075. static analysis complains that 'physical_damage' is always 2076. False when tested below; it's right, but having that in 2077. place means one less thing to update if AD_PHYS gets added */ 2078. common: 2079. 2080. if (!not_affected) { 2081. if (ACURR(A_DEX) > rnd(20)) { 2082. You("duck some of the blast."); 2083. tmp = (tmp + 1) / 2; 2084. } else { 2085. if (flags.verbose) 2086. You("get blasted!"); 2087. } 2088. if (mattk->adtyp == AD_FIRE) 2089. burn_away_slime(); 2090. if (physical_damage) 2091. tmp = Maybe_Half_Phys(tmp); 2092. mdamageu(mtmp, tmp); 2093. } 2094. break; 2095. 2096. case AD_BLND: 2097. not_affected = resists_blnd(&youmonst); 2098. if (!not_affected) { 2099. /* sometimes you're affected even if it's invisible */ 2100. if (mon_visible(mtmp) || (rnd(tmp /= 2) > u.ulevel)) { 2101. You("are blinded by a blast of light!"); 2102. make_blinded((long) tmp, FALSE); 2103. if (!Blind) 2104. Your1(vision_clears); 2105. } else if (flags.verbose) 2106. You("get the impression it was not terribly bright."); 2107. } 2108. break; 2109. 2110. case AD_HALU: 2111. not_affected |= Blind || (u.umonnum == PM_BLACK_LIGHT 2112. || u.umonnum == PM_VIOLET_FUNGUS 2113. || dmgtype(youmonst.data, AD_STUN)); 2114. if (!not_affected) { 2115. boolean chg; 2116. if (!Hallucination) 2117. You("are caught in a blast of kaleidoscopic light!"); 2118. /* avoid hallucinating the black light as it dies */ 2119. mondead(mtmp); /* remove it from map now */ 2120. kill_agr = FALSE; /* already killed (maybe lifesaved) */ 2121. chg = 2122. make_hallucinated(HHallucination + (long) tmp, FALSE, 0L); 2123. You("%s.", chg ? "are freaked out" : "seem unaffected"); 2124. } 2125. break; 2126. 2127. default: 2128. break; 2129. } 2130. if (not_affected) { 2131. You("seem unaffected by it."); 2132. ugolemeffects((int) mattk->adtyp, tmp); 2133. } 2134. } 2135. if (kill_agr) 2136. mondead(mtmp); 2137. wake_nearto(mtmp->mx, mtmp->my, 7 * 7); 2138. return (!DEADMONSTER(mtmp)) ? 0 : 2; 2139. } 2140. 2141. /* monster gazes at you */ 2142. int 2143. gazemu(mtmp, mattk) 2144. struct monst *mtmp; 2145. struct attack *mattk; 2146. { 2147. static const char *const reactions[] = { 2148. "confused", /* [0] */ 2149. "stunned", /* [1] */ 2150. "puzzled", "dazzled", /* [2,3] */ 2151. "irritated", "inflamed", /* [4,5] */ 2152. "tired", /* [6] */ 2153. "dulled", /* [7] */ 2154. }; 2155. int react = -1; 2156. boolean cancelled = (mtmp->mcan != 0), already = FALSE; 2157. 2158. /* assumes that hero has to see monster's gaze in order to be 2159. affected, rather than monster just having to look at hero; 2160. when hallucinating, hero's brain doesn't register what 2161. it's seeing correctly so the gaze is usually ineffective 2162. [this could be taken a lot farther and select a gaze effect 2163. appropriate to what's currently being displayed, giving 2164. ordinary monsters a gaze attack when hero thinks he or she 2165. is facing a gazing creature, but let's not go that far...] */ 2166. if (Hallucination && rn2(4)) 2167. cancelled = TRUE; 2168. 2169. switch (mattk->adtyp) { 2170. case AD_STON: 2171. if (cancelled || !mtmp->mcansee) { 2172. if (!canseemon(mtmp)) 2173. break; /* silently */ 2174. pline("%s %s.", Monnam(mtmp), 2175. (mtmp->data == &mons[PM_MEDUSA] && mtmp->mcan) 2176. ? "doesn't look all that ugly" 2177. : "gazes ineffectually"); 2178. break; 2179. } 2180. if (Reflecting && couldsee(mtmp->mx, mtmp->my) 2181. && mtmp->data == &mons[PM_MEDUSA]) { 2182. /* hero has line of sight to Medusa and she's not blind */ 2183. boolean useeit = canseemon(mtmp); 2184. 2185. if (useeit) 2186. (void) ureflects("%s gaze is reflected by your %s.", 2187. s_suffix(Monnam(mtmp))); 2188. if (mon_reflects( 2189. mtmp, !useeit ? (char *) 0 2190. : "The gaze is reflected away by %s %s!")) 2191. break; 2192. if (!m_canseeu(mtmp)) { /* probably you're invisible */ 2193. if (useeit) 2194. pline( 2195. "%s doesn't seem to notice that %s gaze was reflected.", 2196. Monnam(mtmp), mhis(mtmp)); 2197. break; 2198. } 2199. if (useeit) 2200. pline("%s is turned to stone!", Monnam(mtmp)); 2201. stoned = TRUE; 2202. killed(mtmp); 2203. 2204. if (!DEADMONSTER(mtmp)) 2205. break; 2206. return 2; 2207. } 2208. if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) 2209. && !Stone_resistance) { 2210. You("meet %s gaze.", s_suffix(mon_nam(mtmp))); 2211. stop_occupation(); 2212. if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) 2213. break; 2214. You("turn to stone..."); 2215. killer.format = KILLED_BY; 2216. Strcpy(killer.name, mtmp->data->mname); 2217. done(STONING); 2218. } 2219. break; 2220. case AD_CONF: 2221. if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee 2222. && !mtmp->mspec_used && rn2(5)) { 2223. if (cancelled) { 2224. react = 0; /* "confused" */ 2225. already = (mtmp->mconf != 0); 2226. } else { 2227. int conf = d(3, 4); 2228. 2229. mtmp->mspec_used = mtmp->mspec_used + (conf + rn2(6)); 2230. if (!Confusion) 2231. pline("%s gaze confuses you!", s_suffix(Monnam(mtmp))); 2232. else 2233. You("are getting more and more confused."); 2234. make_confused(HConfusion + conf, FALSE); 2235. stop_occupation(); 2236. } 2237. } 2238. break; 2239. case AD_STUN: 2240. if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee 2241. && !mtmp->mspec_used && rn2(5)) { 2242. if (cancelled) { 2243. react = 1; /* "stunned" */ 2244. already = (mtmp->mstun != 0); 2245. } else { 2246. int stun = d(2, 6); 2247. 2248. mtmp->mspec_used = mtmp->mspec_used + (stun + rn2(6)); 2249. pline("%s stares piercingly at you!", Monnam(mtmp)); 2250. make_stunned((HStun & TIMEOUT) + (long) stun, TRUE); 2251. stop_occupation(); 2252. } 2253. } 2254. break; 2255. case AD_BLND: 2256. if (canseemon(mtmp) && !resists_blnd(&youmonst) 2257. && distu(mtmp->mx, mtmp->my) <= BOLT_LIM * BOLT_LIM) { 2258. if (cancelled) { 2259. react = rn1(2, 2); /* "puzzled" || "dazzled" */ 2260. already = (mtmp->mcansee == 0); 2261. /* Archons gaze every round; we don't want cancelled ones 2262. giving the "seems puzzled/dazzled" message that often */ 2263. if (mtmp->mcan && mtmp->data == &mons[PM_ARCHON] && rn2(5)) 2264. react = -1; 2265. } else { 2266. int blnd = d((int) mattk->damn, (int) mattk->damd); 2267. 2268. You("are blinded by %s radiance!", s_suffix(mon_nam(mtmp))); 2269. make_blinded((long) blnd, FALSE); 2270. stop_occupation(); 2271. /* not blind at this point implies you're wearing 2272. the Eyes of the Overworld; make them block this 2273. particular stun attack too */ 2274. if (!Blind) { 2275. Your1(vision_clears); 2276. } else { 2277. long oldstun = (HStun & TIMEOUT), newstun = (long) rnd(3); 2278. 2279. /* we don't want to increment stun duration every time 2280. or sighted hero will become incapacitated */ 2281. make_stunned(max(oldstun, newstun), TRUE); 2282. } 2283. } 2284. } 2285. break; 2286. case AD_FIRE: 2287. if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee 2288. && !mtmp->mspec_used && rn2(5)) { 2289. if (cancelled) { 2290. react = rn1(2, 4); /* "irritated" || "inflamed" */ 2291. } else { 2292. int dmg = d(2, 6), lev = (int) mtmp->m_lev; 2293. 2294. pline("%s attacks you with a fiery gaze!", Monnam(mtmp)); 2295. stop_occupation(); 2296. if (Fire_resistance) { 2297. pline_The("fire doesn't feel hot!"); 2298. dmg = 0; 2299. } 2300. burn_away_slime(); 2301. if (lev > rn2(20)) 2302. destroy_item(SCROLL_CLASS, AD_FIRE); 2303. if (lev > rn2(20)) 2304. destroy_item(POTION_CLASS, AD_FIRE); 2305. if (lev > rn2(25)) 2306. destroy_item(SPBOOK_CLASS, AD_FIRE); 2307. if (dmg) 2308. mdamageu(mtmp, dmg); 2309. } 2310. } 2311. break; 2312. #ifdef PM_BEHOLDER /* work in progress */ 2313. case AD_SLEE: 2314. if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee 2315. && multi >= 0 && !rn2(5) && !Sleep_resistance) { 2316. if (cancelled) { 2317. react = 6; /* "tired" */ 2318. already = (mtmp->mfrozen != 0); /* can't happen... */ 2319. } else { 2320. fall_asleep(-rnd(10), TRUE); 2321. pline("%s gaze makes you very sleepy...", 2322. s_suffix(Monnam(mtmp))); 2323. } 2324. } 2325. break; 2326. case AD_SLOW: 2327. if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee 2328. && (HFast & (INTRINSIC | TIMEOUT)) && !defends(AD_SLOW, uwep) 2329. && !rn2(4)) { 2330. if (cancelled) { 2331. react = 7; /* "dulled" */ 2332. already = (mtmp->mspeed == MSLOW); 2333. } else { 2334. u_slow_down(); 2335. stop_occupation(); 2336. } 2337. } 2338. break; 2339. #endif /* BEHOLDER */ 2340. default: 2341. impossible("Gaze attack %d?", mattk->adtyp); 2342. break; 2343. } 2344. if (react >= 0) { 2345. if (Hallucination && rn2(3)) 2346. react = rn2(SIZE(reactions)); 2347. /* cancelled/hallucinatory feedback; monster might look "confused", 2348. "stunned",&c but we don't actually set corresponding attribute */ 2349. pline("%s looks %s%s.", Monnam(mtmp), 2350. !rn2(3) ? "" : already ? "quite " 2351. : (!rn2(2) ? "a bit " : "somewhat "), 2352. reactions[react]); 2353. } 2354. return 0; 2355. } 2356. 2357. /* mtmp hits you for n points damage */ 2358. void 2359. mdamageu(mtmp, n) 2360. struct monst *mtmp; 2361. int n; 2362. { 2363. context.botl = 1; 2364. if (Upolyd) { 2365. u.mh -= n; 2366. if (u.mh < 1) 2367. rehumanize(); 2368. } else { 2369. u.uhp -= n; 2370. if (u.uhp < 1) 2371. done_in_by(mtmp, DIED); 2372. } 2373. } 2374. 2375. /* returns 0 if seduction impossible, 2376. * 1 if fine, 2377. * 2 if wrong gender for nymph 2378. */ 2379. int 2380. could_seduce(magr, mdef, mattk) 2381. struct monst *magr, *mdef; 2382. struct attack *mattk; /* non-Null: current attack; Null: general capability */ 2383. { 2384. struct permonst *pagr; 2385. boolean agrinvis, defperc; 2386. xchar genagr, gendef; 2387. int adtyp; 2388. 2389. if (is_animal(magr->data)) 2390. return 0; 2391. if (magr == &youmonst) { 2392. pagr = youmonst.data; 2393. agrinvis = (Invis != 0); 2394. genagr = poly_gender(); 2395. } else { 2396. pagr = magr->data; 2397. agrinvis = magr->minvis; 2398. genagr = gender(magr); 2399. } 2400. if (mdef == &youmonst) { 2401. defperc = (See_invisible != 0); 2402. gendef = poly_gender(); 2403. } else { 2404. defperc = perceives(mdef->data); 2405. gendef = gender(mdef); 2406. } 2407. 2408. adtyp = mattk ? mattk->adtyp 2409. : dmgtype(pagr, AD_SSEX) ? AD_SSEX 2410. : dmgtype(pagr, AD_SEDU) ? AD_SEDU 2411. : AD_PHYS; 2412. if (adtyp == AD_SSEX && !SYSOPT_SEDUCE) 2413. adtyp = AD_SEDU; 2414. 2415. if (agrinvis && !defperc && adtyp == AD_SEDU) 2416. return 0; 2417. 2418. /* nymphs have two attacks, one for steal-item damage and the other 2419. for seduction, both pass the could_seduce() test; 2420. incubi/succubi have three attacks, their claw attacks for damage 2421. don't pass the test */ 2422. if ((pagr->mlet != S_NYMPH 2423. && pagr != &mons[PM_INCUBUS] && pagr != &mons[PM_SUCCUBUS]) 2424. || (adtyp != AD_SEDU && adtyp != AD_SSEX && adtyp != AD_SITM)) 2425. return 0; 2426. 2427. return (genagr == 1 - gendef) ? 1 : (pagr->mlet == S_NYMPH) ? 2 : 0; 2428. } 2429. 2430. /* returns 1 if monster teleported (or hero leaves monster's vicinity) */ 2431. int 2432. doseduce(mon) 2433. struct monst *mon; 2434. { 2435. struct obj *ring, *nring; 2436. boolean fem = (mon->data == &mons[PM_SUCCUBUS]); /* otherwise incubus */ 2437. boolean seewho, naked; /* True iff no armor */ 2438. int attr_tot, tried_gloves = 0; 2439. char qbuf[QBUFSZ], Who[QBUFSZ]; 2440. 2441. if (mon->mcan || mon->mspec_used) { 2442. pline("%s acts as though %s has got a %sheadache.", Monnam(mon), 2443. mhe(mon), mon->mcan ? "severe " : ""); 2444. return 0; 2445. } 2446. if (unconscious()) { 2447. pline("%s seems dismayed at your lack of response.", Monnam(mon)); 2448. return 0; 2449. } 2450. seewho = canseemon(mon); 2451. if (!seewho) 2452. pline("Someone caresses you..."); 2453. else 2454. You_feel("very attracted to %s.", mon_nam(mon)); 2455. /* cache the seducer's name in a local buffer */ 2456. Strcpy(Who, (!seewho ? (fem ? "She" : "He") : Monnam(mon))); 2457. 2458. /* if in the process of putting armor on or taking armor off, 2459. interrupt that activity now */ 2460. (void) stop_donning((struct obj *) 0); 2461. /* don't try to take off gloves if cursed weapon blocks them */ 2462. if (welded(uwep)) 2463. tried_gloves = 1; 2464. 2465. for (ring = invent; ring; ring = nring) { 2466. nring = ring->nobj; 2467. if (ring->otyp != RIN_ADORNMENT) 2468. continue; 2469. if (fem) { 2470. if (ring->owornmask && uarmg) { 2471. /* don't take off worn ring if gloves are in the way */ 2472. if (!tried_gloves++) 2473. mayberem(mon, Who, uarmg, "gloves"); 2474. if (uarmg) 2475. continue; /* next ring might not be worn */ 2476. } 2477. /* confirmation prompt when charisma is high bypassed if deaf */ 2478. if (!Deaf && rn2(20) < ACURR(A_CHA)) { 2479. (void) safe_qbuf(qbuf, "\"That ", 2480. " looks pretty. May I have it?\"", ring, 2481. xname, simpleonames, "ring"); 2482. makeknown(RIN_ADORNMENT); 2483. if (yn(qbuf) == 'n') 2484. continue; 2485. } else 2486. pline("%s decides she'd like %s, and takes it.", 2487. Who, yname(ring)); 2488. makeknown(RIN_ADORNMENT); 2489. /* might be in left or right ring slot or weapon/alt-wep/quiver */ 2490. if (ring->owornmask) 2491. remove_worn_item(ring, FALSE); 2492. freeinv(ring); 2493. (void) mpickobj(mon, ring); 2494. } else { 2495. if (uleft && uright && uleft->otyp == RIN_ADORNMENT 2496. && uright->otyp == RIN_ADORNMENT) 2497. break; 2498. if (ring == uleft || ring == uright) 2499. continue; 2500. if (uarmg) { 2501. /* don't put on ring if gloves are in the way */ 2502. if (!tried_gloves++) 2503. mayberem(mon, Who, uarmg, "gloves"); 2504. if (uarmg) 2505. break; /* no point trying further rings */ 2506. } 2507. /* confirmation prompt when charisma is high bypassed if deaf */ 2508. if (!Deaf && rn2(20) < ACURR(A_CHA)) { 2509. (void) safe_qbuf(qbuf, "\"That ", 2510. " looks pretty. Would you wear it for me?\"", 2511. ring, xname, simpleonames, "ring"); 2512. makeknown(RIN_ADORNMENT); 2513. if (yn(qbuf) == 'n') 2514. continue; 2515. } else { 2516. pline("%s decides you'd look prettier wearing %s,", 2517. Who, yname(ring)); 2518. pline("and puts it on your finger."); 2519. } 2520. makeknown(RIN_ADORNMENT); 2521. if (!uright) { 2522. pline("%s puts %s on your right %s.", 2523. Who, the(xname(ring)), body_part(HAND)); 2524. setworn(ring, RIGHT_RING); 2525. } else if (!uleft) { 2526. pline("%s puts %s on your left %s.", 2527. Who, the(xname(ring)), body_part(HAND)); 2528. setworn(ring, LEFT_RING); 2529. } else if (uright && uright->otyp != RIN_ADORNMENT) { 2530. /* note: the "replaces" message might be inaccurate if 2531. hero's location changes and the process gets interrupted, 2532. but trying to figure that out in advance in order to use 2533. alternate wording is not worth the effort */ 2534. pline("%s replaces %s with %s.", 2535. Who, yname(uright), yname(ring)); 2536. Ring_gone(uright); 2537. /* ring removal might cause loss of levitation which could 2538. drop hero onto trap that transports hero somewhere else */ 2539. if (u.utotype || distu(mon->mx, mon->my) > 2) 2540. return 1; 2541. setworn(ring, RIGHT_RING); 2542. } else if (uleft && uleft->otyp != RIN_ADORNMENT) { 2543. /* see "replaces" note above */ 2544. pline("%s replaces %s with %s.", 2545. Who, yname(uleft), yname(ring)); 2546. Ring_gone(uleft); 2547. if (u.utotype || distu(mon->mx, mon->my) > 2) 2548. return 1; 2549. setworn(ring, LEFT_RING); 2550. } else 2551. impossible("ring replacement"); 2552. Ring_on(ring); 2553. prinv((char *) 0, ring, 0L); 2554. } 2555. } 2556. 2557. naked = (!uarmc && !uarmf && !uarmg && !uarms && !uarmh && !uarmu); 2558. pline("%s %s%s.", Who, 2559. Deaf ? "seems to murmur into your ear" 2560. : naked ? "murmurs sweet nothings into your ear" 2561. : "murmurs in your ear", 2562. naked ? "" : ", while helping you undress"); 2563. mayberem(mon, Who, uarmc, cloak_simple_name(uarmc)); 2564. if (!uarmc) 2565. mayberem(mon, Who, uarm, suit_simple_name(uarm)); 2566. mayberem(mon, Who, uarmf, "boots"); 2567. if (!tried_gloves) 2568. mayberem(mon, Who, uarmg, "gloves"); 2569. mayberem(mon, Who, uarms, "shield"); 2570. mayberem(mon, Who, uarmh, helm_simple_name(uarmh)); 2571. if (!uarmc && !uarm) 2572. mayberem(mon, Who, uarmu, "shirt"); 2573. 2574. /* removing armor (levitation boots, or levitation ring to make 2575. room for adornment ring with incubus case) might result in the 2576. hero falling through a trap door or landing on a teleport trap 2577. and changing location, so hero might not be adjacent to seducer 2578. any more (mayberem() has its own adjacency test so we don't need 2579. to check after each potential removal) */ 2580. if (u.utotype || distu(mon->mx, mon->my) > 2) 2581. return 1; 2582. 2583. if (uarm || uarmc) { 2584. if (!Deaf) 2585. verbalize("You're such a %s; I wish...", 2586. flags.female ? "sweet lady" : "nice guy"); 2587. else if (seewho) 2588. pline("%s appears to sigh.", Monnam(mon)); 2589. /* else no regret message if can't see or hear seducer */ 2590. 2591. if (!tele_restrict(mon)) 2592. (void) rloc(mon, TRUE); 2593. return 1; 2594. } 2595. if (u.ualign.type == A_CHAOTIC) 2596. adjalign(1); 2597. 2598. /* by this point you have discovered mon's identity, blind or not... */ 2599. pline("Time stands still while you and %s lie in each other's arms...", 2600. noit_mon_nam(mon)); 2601. /* 3.6.1: a combined total for charisma plus intelligence of 35-1 2602. used to guarantee successful outcome; now total maxes out at 32 2603. as far as deciding what will happen; chance for bad outcome when 2604. Cha+Int is 32 or more is 2/35, a bit over 5.7% */ 2605. attr_tot = ACURR(A_CHA) + ACURR(A_INT); 2606. if (rn2(35) > min(attr_tot, 32)) { 2607. /* Don't bother with mspec_used here... it didn't get tired! */ 2608. pline("%s seems to have enjoyed it more than you...", 2609. noit_Monnam(mon)); 2610. switch (rn2(5)) { 2611. case 0: 2612. You_feel("drained of energy."); 2613. u.uen = 0; 2614. u.uenmax -= rnd(Half_physical_damage ? 5 : 10); 2615. exercise(A_CON, FALSE); 2616. if (u.uenmax < 0) 2617. u.uenmax = 0; 2618. break; 2619. case 1: 2620. You("are down in the dumps."); 2621. (void) adjattrib(A_CON, -1, TRUE); 2622. exercise(A_CON, FALSE); 2623. context.botl = 1; 2624. break; 2625. case 2: 2626. Your("senses are dulled."); 2627. (void) adjattrib(A_WIS, -1, TRUE); 2628. exercise(A_WIS, FALSE); 2629. context.botl = 1; 2630. break; 2631. case 3: 2632. if (!resists_drli(&youmonst)) { 2633. You_feel("out of shape."); 2634. losexp("overexertion"); 2635. } else { 2636. You("have a curious feeling..."); 2637. } 2638. exercise(A_CON, FALSE); 2639. exercise(A_DEX, FALSE); 2640. exercise(A_WIS, FALSE); 2641. break; 2642. case 4: { 2643. int tmp; 2644. 2645. You_feel("exhausted."); 2646. exercise(A_STR, FALSE); 2647. tmp = rn1(10, 6); 2648. losehp(Maybe_Half_Phys(tmp), "exhaustion", KILLED_BY); 2649. break; 2650. } /* case 4 */ 2651. } /* switch */ 2652. } else { 2653. mon->mspec_used = rnd(100); /* monster is worn out */ 2654. You("seem to have enjoyed it more than %s...", noit_mon_nam(mon)); 2655. switch (rn2(5)) { 2656. case 0: 2657. You_feel("raised to your full potential."); 2658. exercise(A_CON, TRUE); 2659. u.uen = (u.uenmax += rnd(5)); 2660. break; 2661. case 1: 2662. You_feel("good enough to do it again."); 2663. (void) adjattrib(A_CON, 1, TRUE); 2664. exercise(A_CON, TRUE); 2665. context.botl = 1; 2666. break; 2667. case 2: 2668. You("will always remember %s...", noit_mon_nam(mon)); 2669. (void) adjattrib(A_WIS, 1, TRUE); 2670. exercise(A_WIS, TRUE); 2671. context.botl = 1; 2672. break; 2673. case 3: 2674. pline("That was a very educational experience."); 2675. pluslvl(FALSE); 2676. exercise(A_WIS, TRUE); 2677. break; 2678. case 4: 2679. You_feel("restored to health!"); 2680. u.uhp = u.uhpmax; 2681. if (Upolyd) 2682. u.mh = u.mhmax; 2683. exercise(A_STR, TRUE); 2684. context.botl = 1; 2685. break; 2686. } 2687. } 2688. 2689. if (mon->mtame) { /* don't charge */ 2690. ; 2691. } else if (rn2(20) < ACURR(A_CHA)) { 2692. pline("%s demands that you pay %s, but you refuse...", 2693. noit_Monnam(mon), noit_mhim(mon)); 2694. } else if (u.umonnum == PM_LEPRECHAUN) { 2695. pline("%s tries to take your money, but fails...", noit_Monnam(mon)); 2696. } else { 2697. long cost; 2698. long umoney = money_cnt(invent); 2699. 2700. if (umoney > (long) LARGEST_INT - 10L) 2701. cost = (long) rnd(LARGEST_INT) + 500L; 2702. else 2703. cost = (long) rnd((int) umoney + 10) + 500L; 2704. if (mon->mpeaceful) { 2705. cost /= 5L; 2706. if (!cost) 2707. cost = 1L; 2708. } 2709. if (cost > umoney) 2710. cost = umoney; 2711. if (!cost) { 2712. verbalize("It's on the house!"); 2713. } else { 2714. pline("%s takes %ld %s for services rendered!", noit_Monnam(mon), 2715. cost, currency(cost)); 2716. money2mon(mon, cost); 2717. context.botl = 1; 2718. } 2719. } 2720. if (!rn2(25)) 2721. mon->mcan = 1; /* monster is worn out */ 2722. if (!tele_restrict(mon)) 2723. (void) rloc(mon, TRUE); 2724. return 1; 2725. } 2726. 2727. STATIC_OVL void 2728. mayberem(mon, seducer, obj, str) 2729. struct monst *mon; 2730. const char *seducer; /* only used for alternate message */ 2731. struct obj *obj; 2732. const char *str; 2733. { 2734. char qbuf[QBUFSZ]; 2735. 2736. if (!obj || !obj->owornmask) 2737. return; 2738. /* removal of a previous item might have sent the hero elsewhere 2739. (loss of levitation that leads to landing on a transport trap) */ 2740. if (u.utotype || distu(mon->mx, mon->my) > 2) 2741. return; 2742. 2743. /* being deaf overrides confirmation prompt for high charisma */ 2744. if (Deaf) { 2745. pline("%s takes off your %s.", seducer, str); 2746. } else if (rn2(20) < ACURR(A_CHA)) { 2747. Sprintf(qbuf, "\"Shall I remove your %s, %s?\"", str, 2748. (!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart")); 2749. if (yn(qbuf) == 'n') 2750. return; 2751. } else { 2752. char hairbuf[BUFSZ]; 2753. 2754. Sprintf(hairbuf, "let me run my fingers through your %s", 2755. body_part(HAIR)); 2756. verbalize("Take off your %s; %s.", str, 2757. (obj == uarm) 2758. ? "let's get a little closer" 2759. : (obj == uarmc || obj == uarms) 2760. ? "it's in the way" 2761. : (obj == uarmf) 2762. ? "let me rub your feet" 2763. : (obj == uarmg) 2764. ? "they're too clumsy" 2765. : (obj == uarmu) 2766. ? "let me massage you" 2767. /* obj == uarmh */ 2768. : hairbuf); 2769. } 2770. remove_worn_item(obj, TRUE); 2771. } 2772. 2773. /* FIXME: 2774. * sequencing issue: a monster's attack might cause poly'd hero 2775. * to revert to normal form. The messages for passive counterattack 2776. * would look better if they came before reverting form, but we need 2777. * to know whether hero reverted in order to decide whether passive 2778. * damage applies. 2779. */ 2780. STATIC_OVL int 2781. passiveum(olduasmon, mtmp, mattk) 2782. struct permonst *olduasmon; 2783. struct monst *mtmp; 2784. struct attack *mattk; 2785. { 2786. int i, tmp; 2787. struct attack *oldu_mattk = 0; 2788. 2789. /* 2790. * mattk == mtmp's attack that hit you; 2791. * oldu_mattk == your passive counterattack (even if mtmp's attack 2792. * has already caused you to revert to normal form). 2793. */ 2794. for (i = 0; !oldu_mattk; i++) { 2795. if (i >= NATTK) 2796. return 1; 2797. if (olduasmon->mattk[i].aatyp == AT_NONE 2798. || olduasmon->mattk[i].aatyp == AT_BOOM) 2799. oldu_mattk = &olduasmon->mattk[i]; 2800. } 2801. if (oldu_mattk->damn) 2802. tmp = d((int) oldu_mattk->damn, (int) oldu_mattk->damd); 2803. else if (oldu_mattk->damd) 2804. tmp = d((int) olduasmon->mlevel + 1, (int) oldu_mattk->damd); 2805. else 2806. tmp = 0; 2807. 2808. /* These affect the enemy even if you were "killed" (rehumanized) */ 2809. switch (oldu_mattk->adtyp) { 2810. case AD_ACID: 2811. if (!rn2(2)) { 2812. pline("%s is splashed by %s%s!", Monnam(mtmp), 2813. /* temporary? hack for sequencing issue: "your acid" 2814. looks strange coming immediately after player has 2815. been told that hero has reverted to normal form */ 2816. !Upolyd ? "" : "your ", hliquid("acid")); 2817. if (resists_acid(mtmp)) { 2818. pline("%s is not affected.", Monnam(mtmp)); 2819. tmp = 0; 2820. } 2821. } else 2822. tmp = 0; 2823. if (!rn2(30)) 2824. erode_armor(mtmp, ERODE_CORRODE); 2825. if (!rn2(6)) 2826. acid_damage(MON_WEP(mtmp)); 2827. goto assess_dmg; 2828. case AD_STON: /* cockatrice */ 2829. { 2830. long protector = attk_protection((int) mattk->aatyp), 2831. wornitems = mtmp->misc_worn_check; 2832. 2833. /* wielded weapon gives same protection as gloves here */ 2834. if (MON_WEP(mtmp) != 0) 2835. wornitems |= W_ARMG; 2836. 2837. if (!resists_ston(mtmp) 2838. && (protector == 0L 2839. || (protector != ~0L 2840. && (wornitems & protector) != protector))) { 2841. if (poly_when_stoned(mtmp->data)) { 2842. mon_to_stone(mtmp); 2843. return 1; 2844. } 2845. pline("%s turns to stone!", Monnam(mtmp)); 2846. stoned = 1; 2847. xkilled(mtmp, XKILL_NOMSG); 2848. if (!DEADMONSTER(mtmp)) 2849. return 1; 2850. return 2; 2851. } 2852. return 1; 2853. } 2854. case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */ 2855. if (mon_currwep) { 2856. /* by_you==True: passive counterattack to hero's action 2857. is hero's fault */ 2858. (void) drain_item(mon_currwep, TRUE); 2859. /* No message */ 2860. } 2861. return 1; 2862. default: 2863. break; 2864. } 2865. if (!Upolyd) 2866. return 1; 2867. 2868. /* These affect the enemy only if you are still a monster */ 2869. if (rn2(3)) 2870. switch (oldu_mattk->adtyp) { 2871. case AD_PHYS: 2872. if (oldu_mattk->aatyp == AT_BOOM) { 2873. You("explode!"); 2874. /* KMH, balance patch -- this is okay with unchanging */ 2875. rehumanize(); 2876. goto assess_dmg; 2877. } 2878. break; 2879. case AD_PLYS: /* Floating eye */ 2880. if (tmp > 127) 2881. tmp = 127; 2882. if (u.umonnum == PM_FLOATING_EYE) { 2883. if (!rn2(4)) 2884. tmp = 127; 2885. if (mtmp->mcansee && haseyes(mtmp->data) && rn2(3) 2886. && (perceives(mtmp->data) || !Invis)) { 2887. if (Blind) 2888. pline("As a blind %s, you cannot defend yourself.", 2889. youmonst.data->mname); 2890. else { 2891. if (mon_reflects(mtmp, 2892. "Your gaze is reflected by %s %s.")) 2893. return 1; 2894. pline("%s is frozen by your gaze!", Monnam(mtmp)); 2895. paralyze_monst(mtmp, tmp); 2896. return 3; 2897. } 2898. } 2899. } else { /* gelatinous cube */ 2900. pline("%s is frozen by you.", Monnam(mtmp)); 2901. paralyze_monst(mtmp, tmp); 2902. return 3; 2903. } 2904. return 1; 2905. case AD_COLD: /* Brown mold or blue jelly */ 2906. if (resists_cold(mtmp)) { 2907. shieldeff(mtmp->mx, mtmp->my); 2908. pline("%s is mildly chilly.", Monnam(mtmp)); 2909. golemeffects(mtmp, AD_COLD, tmp); 2910. tmp = 0; 2911. break; 2912. } 2913. pline("%s is suddenly very cold!", Monnam(mtmp)); 2914. u.mh += tmp / 2; 2915. if (u.mhmax < u.mh) 2916. u.mhmax = u.mh; 2917. if (u.mhmax > ((youmonst.data->mlevel + 1) * 8)) 2918. (void) split_mon(&youmonst, mtmp); 2919. break; 2920. case AD_STUN: /* Yellow mold */ 2921. if (!mtmp->mstun) { 2922. mtmp->mstun = 1; 2923. pline("%s %s.", Monnam(mtmp), 2924. makeplural(stagger(mtmp->data, "stagger"))); 2925. } 2926. tmp = 0; 2927. break; 2928. case AD_FIRE: /* Red mold */ 2929. if (resists_fire(mtmp)) { 2930. shieldeff(mtmp->mx, mtmp->my); 2931. pline("%s is mildly warm.", Monnam(mtmp)); 2932. golemeffects(mtmp, AD_FIRE, tmp); 2933. tmp = 0; 2934. break; 2935. } 2936. pline("%s is suddenly very hot!", Monnam(mtmp)); 2937. break; 2938. case AD_ELEC: 2939. if (resists_elec(mtmp)) { 2940. shieldeff(mtmp->mx, mtmp->my); 2941. pline("%s is slightly tingled.", Monnam(mtmp)); 2942. golemeffects(mtmp, AD_ELEC, tmp); 2943. tmp = 0; 2944. break; 2945. } 2946. pline("%s is jolted with your electricity!", Monnam(mtmp)); 2947. break; 2948. default: 2949. tmp = 0; 2950. break; 2951. } 2952. else 2953. tmp = 0; 2954. 2955. assess_dmg: 2956. if ((mtmp->mhp -= tmp) <= 0) { 2957. pline("%s dies!", Monnam(mtmp)); 2958. xkilled(mtmp, XKILL_NOMSG); 2959. if (!DEADMONSTER(mtmp)) 2960. return 1; 2961. return 2; 2962. } 2963. return 1; 2964. } 2965. 2966. struct monst * 2967. cloneu() 2968. { 2969. struct monst *mon; 2970. int mndx = monsndx(youmonst.data); 2971. 2972. if (u.mh <= 1) 2973. return (struct monst *) 0; 2974. if (mvitals[mndx].mvflags & G_EXTINCT) 2975. return (struct monst *) 0; 2976. mon = makemon(youmonst.data, u.ux, u.uy, NO_MINVENT | MM_EDOG); 2977. if (!mon) 2978. return NULL; 2979. mon->mcloned = 1; 2980. mon = christen_monst(mon, plname); 2981. initedog(mon); 2982. mon->m_lev = youmonst.data->mlevel; 2983. mon->mhpmax = u.mhmax; 2984. mon->mhp = u.mh / 2; 2985. u.mh -= mon->mhp; 2986. context.botl = 1; 2987. return mon; 2988. } 2989. 2990. /*mhitu.c*/