About: Source:NetHack 3.3.0/polyself.c   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

Below is the full text to polyself.c from the source code of NetHack 3.3.0. To link to a particular line, write [[NetHack 3.3.0/polyself.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code

AttributesValues
rdfs:label
  • Source:NetHack 3.3.0/polyself.c
rdfs:comment
  • Below is the full text to polyself.c from the source code of NetHack 3.3.0. To link to a particular line, write [[NetHack 3.3.0/polyself.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code
dcterms:subject
dbkwik:nethack/pro...iPageUsesTemplate
abstract
  • Below is the full text to polyself.c from the source code of NetHack 3.3.0. To link to a particular line, write [[NetHack 3.3.0/polyself.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)polyself.c 3.3 1999/08/16 */ 2. /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. /* 6. * Polymorph self routine. 7. * 8. * Note: the light source handling code assumes that both youmonst.m_id 9. * and youmonst.mx will always remain 0 when it handles the case of the 10. * player polymorphed into a light-emitting monster. 11. */ 12. 13. #include "hack.h" 14. 15. #ifdef OVLB 16. STATIC_DCL void FDECL(polyman, (const char *,const char *)); 17. STATIC_DCL void NDECL(break_armor); 18. STATIC_DCL void FDECL(drop_weapon,(int)); 19. STATIC_DCL void NDECL(skinback); 20. STATIC_DCL void NDECL(uunstick); 21. STATIC_DCL int FDECL(armor_to_dragon,(int)); 22. STATIC_DCL void NDECL(newman); 23. 24. /* update the youmonst.data structure pointer */ 25. void 26. set_uasmon() 27. { 28. set_mon_data(&youmonst, &mons[u.umonnum], 0); 29. } 30. 31. /* make a (new) human out of the player */ 32. STATIC_OVL void 33. polyman(fmt, arg) 34. const char *fmt, *arg; 35. { 36. boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow, 37. was_mimicking_gold = (youmonst.m_ap_type == M_AP_OBJECT 38. && youmonst.mappearance == GOLD_PIECE); 39. boolean was_blind = !!Blind; 40. 41. if (Upolyd) { 42. u.acurr = u.macurr; /* restore old attribs */ 43. u.amax = u.mamax; 44. u.umonnum = u.umonster; 45. flags.female = u.mfemale; 46. } 47. set_uasmon(); 48. 49. u.mh = u.mhmax = 0; 50. u.mtimedone = 0; 51. skinback(); 52. u.uundetected = 0; 53. 54. if (sticky) uunstick(); 55. find_ac(); 56. if (was_mimicking_gold) { 57. if (multi < 0) unmul(""); 58. } else { 59. /* 60. * Clear any in-progress imitations -- the case where not a 61. * mimic is handled above. 62. * 63. * Except, this is not complete if the hero ever gets the 64. * chance to imitate anything, then s/he may be mimicing 65. * gold, but not the way its done for eating a mimic. 66. */ 67. youmonst.m_ap_type = M_AP_NOTHING; 68. } 69. newsym(u.ux,u.uy); 70. 71. You(fmt, arg); 72. /* check whether player foolishly genocided self while poly'd */ 73. if ((mvitals[urole.malenum].mvflags & G_GENOD) || 74. (urole.femalenum != NON_PM && 75. (mvitals[urole.femalenum].mvflags & G_GENOD)) || 76. (mvitals[urace.malenum].mvflags & G_GENOD) || 77. (urace.femalenum != NON_PM && 78. (mvitals[urace.femalenum].mvflags & G_GENOD))) { 79. /* intervening activity might have clobbered genocide info */ 80. if (!killer || !strstri(killer, "genocid")) { 81. killer_format = KILLED_BY; 82. killer = "self-genocide"; 83. } 84. done(GENOCIDED); 85. } 86. if (was_blind && !Blind) { /* reverting from eyeless */ 87. Blinded = 1L; 88. make_blinded(0L, TRUE); /* remove blindness */ 89. } 90. 91. if(!Levitation && !u.ustuck && 92. (is_pool(u.ux,u.uy) || is_lava(u.ux,u.uy))) 93. spoteffects(); 94. 95. see_monsters(); 96. } 97. 98. void 99. change_sex() 100. { 101. /* setting u.umonster for caveman/cavewoman or priest/priestess 102. swap unintentionally makes `Upolyd' appear to be true */ 103. boolean already_polyd = (boolean) Upolyd; 104. 105. flags.female = !flags.female; 106. if (already_polyd) /* poly'd: also change saved sex */ 107. u.mfemale = !u.mfemale; 108. max_rank_sz(); /* [this appears to be superfluous] */ 109. if (flags.female && urole.name.f) 110. Strcpy(pl_character, urole.name.f); 111. else 112. Strcpy(pl_character, urole.name.m); 113. u.umonster = (flags.female && urole.femalenum != NON_PM) ? 114. urole.femalenum : urole.malenum; 115. if (!already_polyd) { 116. u.umonnum = u.umonster; 117. } else if (u.umonnum == PM_SUCCUBUS || u.umonnum == PM_INCUBUS) { 118. /* change monster type to match new sex */ 119. u.umonnum = (u.umonnum == PM_SUCCUBUS) ? PM_INCUBUS : PM_SUCCUBUS; 120. set_uasmon(); 121. } 122. } 123. 124. STATIC_OVL void 125. newman() 126. { 127. int tmp, tmp2; 128. 129. if (!rn2(10)) change_sex(); 130. 131. tmp = u.uhpmax; 132. tmp2 = u.ulevel; 133. u.ulevel = u.ulevel + rn1(5, -2); 134. if (u.ulevel > 127 || u.ulevel < 1) u.ulevel = 1; 135. if (u.ulevel > MAXULEV) u.ulevel = MAXULEV; 136. if (u.ulevelmax < u.ulevel) u.ulevelmax = u.ulevel; 137. 138. adjabil(tmp2, (int)u.ulevel); 139. reset_rndmonst(NON_PM); /* new monster generation criteria */ 140. 141. /* random experience points for the new experience level */ 142. u.uexp = rndexp(); 143. 144. /* u.uhpmax * u.ulevel / tmp2: proportionate hit points to new level 145. * -10 and +10: don't apply proportionate HP to 10 of a starting 146. * character's hit points (since a starting character's hit points 147. * are not on the same scale with hit points obtained through level 148. * gain) 149. * 9 - rn2(19): random change of -9 to +9 hit points 150. */ 151. #ifndef LINT 152. u.uhpmax = ((u.uhpmax - 10) * (long)u.ulevel / tmp2 + 10) + 153. (9 - rn2(19)); 154. #endif 155. 156. #ifdef LINT 157. u.uhp = u.uhp + tmp; 158. #else 159. u.uhp = u.uhp * (long)u.uhpmax/tmp; 160. #endif 161. 162. tmp = u.uenmax; 163. #ifndef LINT 164. u.uenmax = u.uenmax * (long)u.ulevel / tmp2 + 9 - rn2(19); 165. #endif 166. if (u.uenmax < 0) u.uenmax = 0; 167. #ifndef LINT 168. u.uen = (tmp ? u.uen * (long)u.uenmax / tmp : u.uenmax); 169. #endif 170. 171. redist_attr(); 172. u.uhunger = rn1(500,500); 173. newuhs(FALSE); 174. if (Sick) make_sick(0L, (char *) 0, FALSE, SICK_ALL); 175. Stoned = 0; 176. if (u.uhp <= 0 || u.uhpmax <= 0) { 177. if (Polymorph_control) { 178. if (u.uhp <= 0) u.uhp = 1; 179. if (u.uhpmax <= 0) u.uhpmax = 1; 180. } else { 181. Your("new form doesn't seem healthy enough to survive."); 182. killer_format = KILLED_BY_AN; 183. killer="unsuccessful polymorph"; 184. done(DIED); 185. } 186. } 187. polyman("feel like a new %s!", 188. (flags.female && urace.individual.f) ? urace.individual.f : 189. (urace.individual.m) ? urace.individual.m : urace.noun); 190. flags.botl = 1; 191. see_monsters(); 192. (void) encumber_msg(); 193. } 194. 195. void 196. polyself() 197. { 198. char buf[BUFSZ]; 199. int old_light, new_light; 200. int mntmp = NON_PM; 201. int tries=0; 202. boolean draconian = (uarm && 203. uarm->otyp >= GRAY_DRAGON_SCALE_MAIL && 204. uarm->otyp <= YELLOW_DRAGON_SCALES); 205. boolean iswere = (u.ulycn >= LOW_PM || is_were(youmonst.data)); 206. boolean isvamp = (youmonst.data->mlet == S_VAMPIRE || u.umonnum == PM_VAMPIRE_BAT); 207. 208. if(!Polymorph_control && !draconian && !iswere && !isvamp) { 209. if (rn2(20) > ACURR(A_CON)) { 210. You(shudder_for_moment); 211. losehp(rnd(30), "system shock", KILLED_BY_AN); 212. exercise(A_CON, FALSE); 213. return; 214. } 215. } 216. old_light = Upolyd ? emits_light(youmonst.data) : 0; 217. 218. if (Polymorph_control) { 219. do { 220. getlin("Become what kind of monster? [type the name]", 221. buf); 222. mntmp = name_to_mon(buf); 223. if (mntmp < LOW_PM) 224. pline("I've never heard of such monsters."); 225. /* Note: humans are illegal as monsters, but an 226. * illegal monster forces newman(), which is what we 227. * want if they specified a human.... */ 228. else if (!polyok(&mons[mntmp]) && !your_race(&mons[mntmp])) 229. You("cannot polymorph into that."); 230. else break; 231. } while(++tries < 5); 232. if (tries==5) pline(thats_enough_tries); 233. /* allow skin merging, even when polymorph is controlled */ 234. if (draconian && 235. (mntmp == armor_to_dragon(uarm->otyp) || tries == 5)) 236. goto do_merge; 237. } else if (draconian || iswere || isvamp) { 238. /* special changes that don't require polyok() */ 239. if (draconian) { 240. do_merge: 241. mntmp = armor_to_dragon(uarm->otyp); 242. if (!(mvitals[mntmp].mvflags & G_GENOD)) { 243. /* allow G_EXTINCT */ 244. You("merge with your scaly armor."); 245. uskin = uarm; 246. uarm = (struct obj *)0; 247. /* save/restore hack */ 248. uskin->owornmask |= I_SPECIAL; 249. } 250. } else if (iswere) { 251. if (is_were(youmonst.data)) 252. mntmp = PM_HUMAN; /* Illegal; force newman() */ 253. else 254. mntmp = u.ulycn; 255. } else { 256. if (youmonst.data->mlet == S_VAMPIRE) 257. mntmp = PM_VAMPIRE_BAT; 258. else 259. mntmp = PM_VAMPIRE; 260. } 261. if (polymon(mntmp)) 262. goto made_change; 263. } 264. 265. if (mntmp < LOW_PM) { 266. tries = 0; 267. do { 268. /* randomly pick an "ordinary" monster */ 269. mntmp = rn1(SPECIAL_PM - LOW_PM, LOW_PM); 270. } while((!polyok(&mons[mntmp]) || is_placeholder(&mons[mntmp])) 271. && tries++ < 200); 272. } 273. 274. /* The below polyok() fails either if everything is genocided, or if 275. * we deliberately chose something illegal to force newman(). 276. */ 277. if (!polyok(&mons[mntmp]) || !rn2(5)) 278. newman(); 279. else if(!polymon(mntmp)) return; 280. 281. if (!uarmg) selftouch("No longer petrify-resistant, you"); 282. 283. made_change: 284. new_light = Upolyd ? emits_light(youmonst.data) : 0; 285. if (old_light != new_light) { 286. if (old_light) 287. del_light_source(LS_MONSTER, (genericptr_t)&youmonst); 288. if (new_light == 1) ++new_light; /* otherwise it's undetectable */ 289. if (new_light) 290. new_light_source(u.ux, u.uy, new_light, 291. LS_MONSTER, (genericptr_t)&youmonst); 292. } 293. } 294. 295. /* (try to) make a mntmp monster out of the player */ 296. int 297. polymon(mntmp) /* returns 1 if polymorph successful */ 298. int mntmp; 299. { 300. boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow, 301. was_blind = !!Blind, dochange = FALSE; 302. int mlvl; 303. 304. if (mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */ 305. You_feel("rather %s-ish.",mons[mntmp].mname); 306. exercise(A_WIS, TRUE); 307. return(0); 308. } 309. 310. /* KMH, conduct */ 311. u.uconduct.polyselfs++; 312. 313. if (!Upolyd) { 314. /* Human to monster; save human stats */ 315. u.macurr = u.acurr; 316. u.mamax = u.amax; 317. u.mfemale = flags.female; 318. } else { 319. /* Monster to monster; restore human stats, to be 320. * immediately changed to provide stats for the new monster 321. */ 322. u.acurr = u.macurr; 323. u.amax = u.mamax; 324. flags.female = u.mfemale; 325. } 326. 327. if (youmonst.m_ap_type == M_AP_OBJECT && 328. youmonst.mappearance == GOLD_PIECE) { 329. /* stop mimicking gold immediately */ 330. if (multi < 0) unmul(""); 331. } 332. if (is_male(&mons[mntmp])) { 333. if(flags.female) dochange = TRUE; 334. } else if (is_female(&mons[mntmp])) { 335. if(!flags.female) dochange = TRUE; 336. } else if (!is_neuter(&mons[mntmp]) && mntmp != u.ulycn) { 337. if(!rn2(10)) dochange = TRUE; 338. } 339. if (dochange) { 340. flags.female = !flags.female; 341. You("%s %s %s!", 342. (u.umonnum != mntmp) ? "turn into a" : "feel like a new", 343. flags.female ? "female" : "male", 344. mons[mntmp].mname); 345. } else { 346. if (u.umonnum != mntmp) 347. You("turn into %s!", an(mons[mntmp].mname)); 348. else 349. You_feel("like a new %s!", mons[mntmp].mname); 350. } 351. if (Stoned && poly_when_stoned(&mons[mntmp])) { 352. /* poly_when_stoned already checked stone golem genocide */ 353. You("turn to stone!"); 354. mntmp = PM_STONE_GOLEM; 355. Stoned = 0; 356. } 357. 358. u.mtimedone = rn1(500, 500); 359. u.umonnum = mntmp; 360. set_uasmon(); 361. 362. /* New stats for monster, to last only as long as polymorphed. 363. * Currently only strength gets changed. 364. */ 365. if(strongmonst(&mons[mntmp])) ABASE(A_STR) = AMAX(A_STR) = STR18(100); 366. 367. if (Stone_resistance && Stoned) { /* parnes@eniac.seas.upenn.edu */ 368. Stoned = 0; 369. You("no longer seem to be petrifying."); 370. } 371. if (Sick_resistance && Sick) { 372. make_sick(0L, (char *) 0, FALSE, SICK_ALL); 373. You("no longer feel sick."); 374. } 375. if (nohands(youmonst.data)) Glib = 0; 376. 377. /* 378. mlvl = adj_lev(&mons[mntmp]); 379. * We can't do the above, since there's no such thing as an 380. * "experience level of you as a monster" for a polymorphed character. 381. */ 382. mlvl = (int)mons[mntmp].mlevel; 383. if (youmonst.data->mlet == S_DRAGON && mntmp >= PM_GRAY_DRAGON) { 384. u.mhmax = In_endgame(&u.uz) ? (8*mlvl) : (4*mlvl + d(mlvl,4)); 385. } else if (is_golem(youmonst.data)) { 386. u.mhmax = golemhp(mntmp); 387. } else { 388. if (!mlvl) u.mhmax = rnd(4); 389. else u.mhmax = d(mlvl, 8); 390. if (is_home_elemental(&mons[mntmp])) u.mhmax *= 3; 391. } 392. u.mh = u.mhmax; 393. 394. if (u.ulevel < mlvl) { 395. /* Low level characters can't become high level monsters for long */ 396. #ifdef DUMB 397. /* DRS/NS 2.2.6 messes up -- Peter Kendell */ 398. int mtd = u.mtimedone, ulv = u.ulevel; 399. 400. u.mtimedone = mtd * ulv / mlvl; 401. #else 402. u.mtimedone = u.mtimedone * u.ulevel / mlvl; 403. #endif 404. } 405. 406. if (uskin && mntmp != armor_to_dragon(uskin->otyp)) 407. skinback(); 408. break_armor(); 409. drop_weapon(1); 410. if (hides_under(youmonst.data)) 411. u.uundetected = OBJ_AT(u.ux, u.uy); 412. else if (youmonst.data->mlet == S_EEL) 413. u.uundetected = is_pool(u.ux, u.uy); 414. else 415. u.uundetected = 0; 416. 417. if (was_blind && !Blind) { /* previous form was eyeless */ 418. Blinded = 1L; 419. make_blinded(0L, TRUE); /* remove blindness */ 420. } 421. newsym(u.ux,u.uy); /* Change symbol */ 422. 423. if (!sticky && !u.uswallow && u.ustuck && sticks(youmonst.data)) u.ustuck = 0; 424. else if (sticky && !sticks(youmonst.data)) uunstick(); 425. #ifdef STEED 426. if (u.usteed) { 427. if (touch_petrifies(u.usteed->data) && 428. !Stone_resistance && rnl(3)) { 429. char buf[BUFSZ]; 430. 431. pline("No longer petrifying-resistant, you touch %s.", 432. mon_nam(u.usteed)); 433. Sprintf(buf, "riding %s", an(u.usteed->data->mname)); 434. instapetrify(buf); 435. } 436. if (!can_ride(u.usteed)) dismount_steed(DISMOUNT_POLY); 437. } 438. #endif 439. 440. if (flags.verbose) { 441. static const char use_thec[] = "Use the command #%s to %s."; 442. static const char monsterc[] = "monster"; 443. if (can_breathe(youmonst.data)) 444. pline(use_thec,monsterc,"use your breath weapon"); 445. if (attacktype(youmonst.data, AT_SPIT)) 446. pline(use_thec,monsterc,"spit venom"); 447. if (youmonst.data->mlet == S_NYMPH) 448. pline(use_thec,monsterc,"remove an iron ball"); 449. if (youmonst.data->mlet == S_UMBER) 450. pline(use_thec,monsterc,"confuse monsters"); 451. if (is_hider(youmonst.data)) 452. pline(use_thec,monsterc,"hide"); 453. if (is_were(youmonst.data)) 454. pline(use_thec,monsterc,"summon help"); 455. if (webmaker(youmonst.data)) 456. pline(use_thec,monsterc,"spin a web"); 457. if (u.umonnum == PM_GREMLIN) 458. pline(use_thec,monsterc,"multiply in a fountain"); 459. if (is_unicorn(youmonst.data)) 460. pline(use_thec,monsterc,"use your horn"); 461. if (is_mind_flayer(youmonst.data)) 462. pline(use_thec,monsterc,"emit a mental blast"); 463. if (youmonst.data->msound == MS_SHRIEK) /* worthless, actually */ 464. pline(use_thec,monsterc,"shriek"); 465. if (lays_eggs(youmonst.data) && flags.female) 466. pline(use_thec,"sit","lay an egg"); 467. } 468. /* you now know what an egg of your type looks like */ 469. if (lays_eggs(youmonst.data)) { 470. learn_egg_type(u.umonnum); 471. /* make queen bees recognize killer bee eggs */ 472. learn_egg_type(egg_type_from_parent(u.umonnum, TRUE)); 473. } 474. find_ac(); 475. if((!Levitation && !u.ustuck && !Flying && 476. (is_pool(u.ux,u.uy) || is_lava(u.ux,u.uy))) || 477. (Underwater && !Swimming)) 478. spoteffects(); 479. if (Passes_walls && u.utrap && u.utraptype == TT_INFLOOR) { 480. u.utrap = 0; 481. pline_The("rock seems to no longer trap you."); 482. } else if (likes_lava(youmonst.data) && u.utrap && u.utraptype == TT_LAVA) { 483. u.utrap = 0; 484. pline_The("lava now feels soothing."); 485. } 486. if (amorphous(youmonst.data) || is_whirly(youmonst.data) || unsolid(youmonst.data)) { 487. if (Punished) { 488. You("slip out of the iron chain."); 489. unpunish(); 490. } 491. } 492. if (u.utrap && (u.utraptype == TT_WEB || u.utraptype == TT_BEARTRAP) && 493. (amorphous(youmonst.data) || is_whirly(youmonst.data) || unsolid(youmonst.data) || 494. (youmonst.data->msize <= MZ_SMALL && u.utraptype == TT_BEARTRAP))) { 495. You("are no longer stuck in the %s.", 496. u.utraptype == TT_WEB ? "web" : "bear trap"); 497. /* probably should burn webs too if PM_FIRE_ELEMENTAL */ 498. u.utrap = 0; 499. } 500. if (youmonst.data->mlet == S_SPIDER && u.utrap && u.utraptype == TT_WEB) { 501. You("orient yourself on the web."); 502. u.utrap = 0; 503. } 504. flags.botl = 1; 505. vision_full_recalc = 1; 506. see_monsters(); 507. exercise(A_CON, FALSE); 508. exercise(A_WIS, TRUE); 509. (void) encumber_msg(); 510. return(1); 511. } 512. 513. STATIC_OVL void 514. break_armor() 515. { 516. register struct obj *otmp; 517. 518. if (breakarm(youmonst.data)) { 519. if ((otmp = uarm) != 0) { 520. if (donning(otmp)) cancel_don(); 521. You("break out of your armor!"); 522. exercise(A_STR, FALSE); 523. (void) Armor_gone(); 524. useup(otmp); 525. } 526. if ((otmp = uarmc) != 0) { 527. if(otmp->oartifact) { 528. Your("cloak falls off!"); 529. (void) Cloak_off(); 530. dropx(otmp); 531. } else { 532. Your("cloak tears apart!"); 533. (void) Cloak_off(); 534. useup(otmp); 535. } 536. } 537. #ifdef TOURIST 538. if (uarmu) { 539. Your("shirt rips to shreds!"); 540. useup(uarmu); 541. } 542. #endif 543. } else if (sliparm(youmonst.data)) { 544. if ((otmp = uarm) != 0) { 545. if (donning(otmp)) cancel_don(); 546. Your("armor falls around you!"); 547. (void) Armor_gone(); 548. dropx(otmp); 549. } 550. if ((otmp = uarmc) != 0) { 551. if (is_whirly(youmonst.data)) 552. Your("cloak falls, unsupported!"); 553. else You("shrink out of your cloak!"); 554. (void) Cloak_off(); 555. dropx(otmp); 556. } 557. #ifdef TOURIST 558. if ((otmp = uarmu) != 0) { 559. if (is_whirly(youmonst.data)) 560. You("seep right through your shirt!"); 561. else You("become much too small for your shirt!"); 562. setworn((struct obj *)0, otmp->owornmask & W_ARMU); 563. dropx(otmp); 564. } 565. #endif 566. } 567. if (nohands(youmonst.data) || verysmall(youmonst.data)) { 568. if ((otmp = uarmg) != 0) { 569. if (donning(otmp)) cancel_don(); 570. /* Drop weapon along with gloves */ 571. You("drop your gloves%s!", uwep ? " and weapon" : ""); 572. drop_weapon(0); 573. (void) Gloves_off(); 574. dropx(otmp); 575. } 576. if ((otmp = uarms) != 0) { 577. You("can no longer hold your shield!"); 578. (void) Shield_off(); 579. dropx(otmp); 580. } 581. if ((otmp = uarmh) != 0) { 582. if (donning(otmp)) cancel_don(); 583. Your("helmet falls to the %s!", surface(u.ux, u.uy)); 584. (void) Helmet_off(); 585. dropx(otmp); 586. } 587. } 588. if (nohands(youmonst.data) || verysmall(youmonst.data) || 589. slithy(youmonst.data) || youmonst.data->mlet == S_CENTAUR) { 590. if ((otmp = uarmf) != 0) { 591. if (donning(otmp)) cancel_don(); 592. if (is_whirly(youmonst.data)) 593. Your("boots fall away!"); 594. else Your("boots %s off your feet!", 595. verysmall(youmonst.data) ? "slide" : "are pushed"); 596. (void) Boots_off(); 597. dropx(otmp); 598. } 599. } 600. } 601. 602. STATIC_OVL void 603. drop_weapon(alone) 604. int alone; 605. { 606. struct obj *otmp; 607. if ((otmp = uwep) != 0) { 608. /* !alone check below is currently superfluous but in the 609. * future it might not be so if there are monsters which cannot 610. * wear gloves but can wield weapons 611. */ 612. if (!alone || cantwield(youmonst.data)) { 613. struct obj *wep = uwep; 614. 615. if (alone) You("find you must drop your weapon%s!", 616. u.twoweap ? "s" : ""); 617. uwepgone(); 618. if (!wep->cursed || wep->otyp != LOADSTONE) 619. dropx(otmp); 620. untwoweapon(); 621. } 622. } 623. } 624. 625. void 626. rehumanize() 627. { 628. /* You can't revert back while unchanging */ 629. if (Unchanging && (u.mh < 1)) { 630. killer_format = NO_KILLER_PREFIX; 631. killer = "killed while stuck in creature form"; 632. done(DIED); 633. } 634. 635. if (emits_light(youmonst.data)) 636. del_light_source(LS_MONSTER, (genericptr_t)&youmonst); 637. polyman("return to %s form!", urace.adj); 638. 639. if (u.uhp < 1) { 640. char kbuf[256]; 641. 642. Sprintf(kbuf, "reverting to unhealthy %s form", urace.adj); 643. killer_format = KILLED_BY; 644. killer = kbuf; 645. done(DIED); 646. } 647. if (!uarmg) selftouch("No longer petrify-resistant, you"); 648. nomul(0); 649. 650. flags.botl = 1; 651. vision_full_recalc = 1; 652. (void) encumber_msg(); 653. } 654. 655. int 656. dobreathe() 657. { 658. if (Strangled) { 659. You_cant("breathe. Sorry."); 660. return(0); 661. } 662. if (u.uen < 15) { 663. You("don't have enough energy to breathe!"); 664. return(0); 665. } 666. u.uen -= 15; 667. flags.botl = 1; 668. 669. if (!getdir((char *)0)) return(0); 670. else { 671. register struct attack *mattk; 672. register int i; 673. 674. for(i = 0; i < NATTK; i++) { 675. mattk = &(youmonst.data->mattk[i]); 676. if(mattk->aatyp == AT_BREA) break; 677. } 678. buzz((int) (20 + mattk->adtyp-1), (int)mattk->damn, 679. u.ux, u.uy, u.dx, u.dy); 680. } 681. return(1); 682. } 683. 684. int 685. dospit() 686. { 687. struct obj *otmp; 688. 689. if (!getdir((char *)0)) return(0); 690. otmp = mksobj(u.umonnum==PM_COBRA ? BLINDING_VENOM : ACID_VENOM, 691. TRUE, FALSE); 692. otmp->spe = 1; /* to indicate it's yours */ 693. throwit(otmp); 694. return(1); 695. } 696. 697. int 698. doremove() 699. { 700. if (!Punished) { 701. You("are not chained to anything!"); 702. return(0); 703. } 704. unpunish(); 705. return(1); 706. } 707. 708. int 709. dospinweb() 710. { 711. register struct trap *ttmp = t_at(u.ux,u.uy); 712. 713. if (Levitation || Is_airlevel(&u.uz) 714. || Underwater || Is_waterlevel(&u.uz)) { 715. You("must be on the ground to spin a web."); 716. return(0); 717. } 718. if (u.uswallow) { 719. You("release web fluid inside %s.", mon_nam(u.ustuck)); 720. if (is_animal(u.ustuck->data)) { 721. expels(u.ustuck, u.ustuck->data, TRUE); 722. return(0); 723. } 724. if (is_whirly(u.ustuck->data)) { 725. int i; 726. 727. for (i = 0; i < NATTK; i++) 728. if (u.ustuck->data->mattk[i].aatyp == AT_ENGL) 729. break; 730. if (i == NATTK) 731. impossible("Swallower has no engulfing attack?"); 732. else { 733. char sweep[30]; 734. 735. sweep[0] = '\0'; 736. switch(u.ustuck->data->mattk[i].adtyp) { 737. case AD_FIRE: 738. Strcpy(sweep, "ignites and "); 739. break; 740. case AD_ELEC: 741. Strcpy(sweep, "fries and "); 742. break; 743. case AD_COLD: 744. Strcpy(sweep, 745. "freezes, shatters and "); 746. break; 747. } 748. pline_The("web %sis swept away!", sweep); 749. } 750. return(0); 751. } /* default: a nasty jelly-like creature */ 752. pline_The("web dissolves into %s.", mon_nam(u.ustuck)); 753. return(0); 754. } 755. if (u.utrap) { 756. You("cannot spin webs while stuck in a trap."); 757. return(0); 758. } 759. exercise(A_DEX, TRUE); 760. if (ttmp) switch (ttmp->ttyp) { 761. case PIT: 762. case SPIKED_PIT: You("spin a web, covering up the pit."); 763. deltrap(ttmp); 764. bury_objs(u.ux, u.uy); 765. if (Invisible) newsym(u.ux, u.uy); 766. return(1); 767. case SQKY_BOARD: pline_The("squeaky board is muffled."); 768. deltrap(ttmp); 769. if (Invisible) newsym(u.ux, u.uy); 770. return(1); 771. case TELEP_TRAP: 772. case LEVEL_TELEP: 773. case MAGIC_PORTAL: 774. Your("webbing vanishes!"); 775. return(0); 776. case WEB: You("make the web thicker."); 777. return(1); 778. case HOLE: 779. case TRAPDOOR: 780. You("web over the %s.", 781. (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole"); 782. deltrap(ttmp); 783. if (Invisible) newsym(u.ux, u.uy); 784. return 1; 785. case ARROW_TRAP: 786. case DART_TRAP: 787. case BEAR_TRAP: 788. case LANDMINE: 789. case SLP_GAS_TRAP: 790. case RUST_TRAP: 791. case MAGIC_TRAP: 792. case ANTI_MAGIC: 793. case POLY_TRAP: 794. You("have triggered a trap!"); 795. dotrap(ttmp); 796. return(1); 797. default: 798. impossible("Webbing over trap type %d?", ttmp->ttyp); 799. return(0); 800. } 801. ttmp = maketrap(u.ux, u.uy, WEB); 802. if (ttmp) { 803. ttmp->tseen = 1; 804. ttmp->madeby_u = 1; 805. } 806. if (Invisible) newsym(u.ux, u.uy); 807. return(1); 808. } 809. 810. int 811. dosummon() 812. { 813. if (u.uen < 10) { 814. You("lack the energy to send forth a call for help!"); 815. return(0); 816. } 817. u.uen -= 10; 818. flags.botl = 1; 819. 820. You("call upon your brethren for help!"); 821. exercise(A_WIS, TRUE); 822. if (!were_summon(youmonst.data,TRUE)) 823. pline("But none arrive."); 824. return(1); 825. } 826. 827. int 828. doconfuse() 829. { 830. register struct monst *mtmp; 831. int looked = 0; 832. char qbuf[QBUFSZ]; 833. 834. if (Blind) { 835. You_cant("see anything to gaze at."); 836. return 0; 837. } 838. if (u.uen < 15) { 839. You("lack the energy to use your special gaze!"); 840. return(0); 841. } 842. u.uen -= 15; 843. flags.botl = 1; 844. 845. for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 846. if (canseemon(mtmp)) { 847. looked++; 848. if (Invis && !perceives(mtmp->data)) 849. pline("%s seems not to notice your gaze.", Monnam(mtmp)); 850. else if (mtmp->minvis && !See_invisible) 851. You_cant("see where to gaze at %s.", Monnam(mtmp)); 852. else if (mtmp->m_ap_type == M_AP_FURNITURE 853. || mtmp->m_ap_type == M_AP_OBJECT) { 854. looked--; 855. continue; 856. } else if (flags.safe_dog && !Confusion && !Hallucination 857. && mtmp->mtame) { 858. You("avoid gazing at %s.", y_monnam(mtmp)); 859. } else { 860. if (flags.confirm && mtmp->mpeaceful && !Confusion 861. && !Hallucination) { 862. Sprintf(qbuf, "Really confuse %s?", mon_nam(mtmp)); 863. if (yn(qbuf) != 'y') continue; 864. setmangry(mtmp); 865. } 866. if (!mtmp->mcanmove || mtmp->mstun || mtmp->msleeping || 867. !mtmp->mcansee || !haseyes(mtmp->data)) { 868. looked--; 869. continue; 870. } 871. if (!mon_reflects(mtmp,"Your gaze is reflected by %s %s.")){ 872. if (!mtmp->mconf) 873. Your("gaze confuses %s!", mon_nam(mtmp)); 874. else 875. pline("%s is getting more and more confused.", 876. Monnam(mtmp)); 877. mtmp->mconf = 1; 878. } 879. if ((mtmp->data==&mons[PM_FLOATING_EYE]) && !mtmp->mcan) { 880. if (!Free_action) { 881. You("are frozen by %s gaze!", 882. s_suffix(mon_nam(mtmp))); 883. nomul((u.ulevel > 6 || rn2(4)) ? 884. -d((int)mtmp->m_lev+1, 885. (int)mtmp->data->mattk[0].damd) 886. : -200); 887. return 1; 888. } else 889. You("stiffen momentarily under %s gaze.", 890. s_suffix(mon_nam(mtmp))); 891. } 892. if ((mtmp->data == &mons[PM_MEDUSA]) && !mtmp->mcan) { 893. pline( 894. "Gazing at the awake %s is not a very good idea.", 895. l_monnam(mtmp)); 896. /* as if gazing at a sleeping anything is fruitful... */ 897. You("turn to stone..."); 898. killer_format = KILLED_BY; 899. killer = 900. "deliberately gazing at Medusa's hideous countenance"; 901. done(STONING); 902. } 903. } 904. } 905. } 906. if (!looked) You("gaze at no place in particular."); 907. return 1; 908. } 909. 910. int 911. dohide() 912. { 913. boolean ismimic = youmonst.data->mlet == S_MIMIC; 914. 915. if (u.uundetected || (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) { 916. You("are already hiding."); 917. return(0); 918. } 919. if (ismimic) { 920. /* should bring up a dialog "what would you like to imitate?" */ 921. youmonst.m_ap_type = M_AP_OBJECT; 922. youmonst.mappearance = STRANGE_OBJECT; 923. } else 924. u.uundetected = 1; 925. newsym(u.ux,u.uy); 926. return(1); 927. } 928. 929. int 930. domindblast() 931. { 932. struct monst *mtmp, *nmon; 933. 934. if (u.uen < 10) { 935. You("concentrate but lack the energy to maintain doing so."); 936. return(0); 937. } 938. u.uen -= 10; 939. flags.botl = 1; 940. 941. You("concentrate."); 942. pline("A wave of psychic energy pours out."); 943. for(mtmp=fmon; mtmp; mtmp = nmon) { 944. int u_sen; 945. 946. nmon = mtmp->nmon; 947. if (distu(mtmp->mx, mtmp->my) > BOLT_LIM * BOLT_LIM) 948. continue; 949. if(mtmp->mpeaceful) 950. continue; 951. u_sen = telepathic(mtmp->data) && !mtmp->mcansee; 952. if (u_sen || (telepathic(mtmp->data) && rn2(2)) || !rn2(10)) { 953. You("lock in on %s %s.", s_suffix(mon_nam(mtmp)), 954. u_sen ? "telepathy" : 955. telepathic(mtmp->data) ? "latent telepathy" : 956. "mind"); 957. mtmp->mhp -= rnd(15); 958. if (mtmp->mhp <= 0) 959. killed(mtmp); 960. } 961. } 962. return 1; 963. } 964. 965. STATIC_OVL void 966. uunstick() 967. { 968. pline("%s is no longer in your clutches.", Monnam(u.ustuck)); 969. u.ustuck = 0; 970. } 971. 972. STATIC_OVL void 973. skinback() 974. { 975. if (uskin) { 976. Your("skin returns to its original form."); 977. uarm = uskin; 978. uskin = (struct obj *)0; 979. /* undo save/restore hack */ 980. uarm->owornmask &= ~I_SPECIAL; 981. } 982. } 983. 984. #endif /* OVLB */ 985. #ifdef OVL1 986. 987. const char * 988. mbodypart(mon, part) 989. struct monst *mon; 990. int part; 991. { 992. static NEARDATA const char 993. *humanoid_parts[] = { "arm", "eye", "face", "finger", 994. "fingertip", "foot", "hand", "handed", "head", "leg", 995. "light headed", "neck", "spine", "toe", "hair" }, 996. *jelly_parts[] = { "pseudopod", "dark spot", "front", 997. "pseudopod extension", "pseudopod extremity", 998. "pseudopod root", "grasp", "grasped", "cerebral area", 999. "lower pseudopod", "viscous", "middle", "surface", 1000. "pseudopod extremity", "ripples" }, 1001. *animal_parts[] = { "forelimb", "eye", "face", "foreclaw", "claw tip", 1002. "rear claw", "foreclaw", "clawed", "head", "rear limb", 1003. "light headed", "neck", "spine", "rear claw tip", "fur" }, 1004. *horse_parts[] = { "foreleg", "eye", "face", "forehoof", "hoof tip", 1005. "rear hoof", "foreclaw", "hooved", "head", "rear leg", 1006. "light headed", "neck", "backbone", "rear hoof tip", "mane" }, 1007. *sphere_parts[] = { "appendage", "optic nerve", "body", "tentacle", 1008. "tentacle tip", "lower appendage", "tentacle", "tentacled", 1009. "body", "lower tentacle", "rotational", "equator", "body", 1010. "lower tentacle tip", "cilia" }, 1011. *fungus_parts[] = { "mycelium", "visual area", "front", "hypha", 1012. "hypha", "root", "strand", "stranded", "cap area", 1013. "rhizome", "sporulated", "stalk", "root", "rhizome tip", 1014. "spores" }, 1015. *vortex_parts[] = { "region", "eye", "front", "minor current", 1016. "minor current", "lower current", "swirl", "swirled", 1017. "central core", "lower current", "addled", "center", 1018. "currents", "edge", "currents" }, 1019. *snake_parts[] = { "vestigial limb", "eye", "face", "large scale", 1020. "large scale tip", "rear region", "scale gap", "scale gapped", 1021. "head", "rear region", "light headed", "neck", "length", 1022. "rear scale", "scales" }; 1023. /* claw attacks are overloaded in mons[]; most humanoids with 1024. such attacks should still reference hands rather than claws */ 1025. static const char not_claws[] = { 1026. S_HUMAN, S_MUMMY, S_ZOMBIE, S_ANGEL, 1027. S_NYMPH, S_LEPRECHAUN, S_QUANTMECH, S_VAMPIRE, 1028. S_ORC, S_GIANT, /* quest nemeses */ 1029. '\0' /* string terminator; assert( S_xxx != 0 ); */ 1030. }; 1031. struct permonst *mptr = mon->data; 1032. 1033. if (part == HAND || part == HANDED) { /* some special cases */ 1034. if (mptr->mlet == S_DOG || mptr->mlet == S_FELINE || 1035. mptr->mlet == S_YETI) 1036. return part == HAND ? "paw" : "pawed"; 1037. if (humanoid(mptr) && attacktype(mptr, AT_CLAW) && 1038. !index(not_claws, mptr->mlet) && 1039. mptr != &mons[PM_STONE_GOLEM] && 1040. mptr != &mons[PM_INCUBUS] && mptr != &mons[PM_SUCCUBUS]) 1041. return part == HAND ? "claw" : "clawed"; 1042. } 1043. if (humanoid(mptr) && 1044. (part == ARM || part == FINGER || part == FINGERTIP || 1045. part == HAND || part == HANDED)) 1046. return humanoid_parts[part]; 1047. if (mptr->mlet == S_CENTAUR || mptr->mlet == S_UNICORN || 1048. (mptr == &mons[PM_ROTHE] && part != HAIR)) 1049. return horse_parts[part]; 1050. if (slithy(mptr)) 1051. return snake_parts[part]; 1052. if (mptr->mlet == S_EYE) 1053. return sphere_parts[part]; 1054. if (mptr->mlet == S_JELLY || mptr->mlet == S_PUDDING || 1055. mptr->mlet == S_BLOB) 1056. return jelly_parts[part]; 1057. if (mptr->mlet == S_VORTEX || mptr->mlet == S_ELEMENTAL) 1058. return vortex_parts[part]; 1059. if (mptr->mlet == S_FUNGUS) 1060. return fungus_parts[part]; 1061. if (humanoid(mptr)) 1062. return humanoid_parts[part]; 1063. return animal_parts[part]; 1064. } 1065. 1066. const char * 1067. body_part(part) 1068. int part; 1069. { 1070. return mbodypart(&youmonst, part); 1071. } 1072. 1073. #endif /* OVL1 */ 1074. #ifdef OVL0 1075. 1076. int 1077. poly_gender() 1078. { 1079. /* Returns gender of polymorphed player; 0/1=same meaning as flags.female, 1080. * 2=none. 1081. * Used in: 1082. * - Seduction by succubus/incubus 1083. * - Talking to nymphs (sounds.c) 1084. * Not used in: 1085. * - Messages given by nymphs stealing armor (they can't steal from 1086. * incubi/succubi/nymphs, and nonhumanoids can't wear armor). 1087. * - Amulet of change (must refer to real gender no matter what 1088. * polymorphed into). 1089. * - Priest/Priestess, Caveman/Cavewoman (ditto) 1090. * - Polymorph self (only happens when human) 1091. * - Shopkeeper messages (since referred to as "creature" and not "sir" 1092. * or "lady" when polymorphed) 1093. */ 1094. if (!humanoid(youmonst.data)) return 2; 1095. return flags.female; 1096. } 1097. 1098. #endif /* OVL0 */ 1099. #ifdef OVLB 1100. 1101. void 1102. ugolemeffects(damtype, dam) 1103. int damtype, dam; 1104. { 1105. int heal = 0; 1106. /* We won't bother with "slow"/"haste" since players do not 1107. * have a monster-specific slow/haste so there is no way to 1108. * restore the old velocity once they are back to human. 1109. */ 1110. if (u.umonnum != PM_FLESH_GOLEM && u.umonnum != PM_IRON_GOLEM) 1111. return; 1112. switch (damtype) { 1113. case AD_ELEC: if (u.umonnum == PM_IRON_GOLEM) 1114. heal = dam / 6; /* Approx 1 per die */ 1115. break; 1116. case AD_FIRE: if (u.umonnum == PM_IRON_GOLEM) 1117. heal = dam; 1118. break; 1119. } 1120. if (heal && (u.mh < u.mhmax)) { 1121. u.mh += heal; 1122. if (u.mh > u.mhmax) u.mh = u.mhmax; 1123. flags.botl = 1; 1124. pline("Strangely, you feel better than before."); 1125. exercise(A_STR, TRUE); 1126. } 1127. } 1128. 1129. STATIC_OVL int 1130. armor_to_dragon(atyp) 1131. int atyp; 1132. { 1133. switch(atyp) { 1134. case GRAY_DRAGON_SCALE_MAIL: 1135. case GRAY_DRAGON_SCALES: 1136. return PM_GRAY_DRAGON; 1137. case SILVER_DRAGON_SCALE_MAIL: 1138. case SILVER_DRAGON_SCALES: 1139. return PM_SILVER_DRAGON; 1140. #if 0 /* DEFERRED */ 1141. case SHIMMERING_DRAGON_SCALE_MAIL: 1142. case SHIMMERING_DRAGON_SCALES: 1143. return PM_SHIMMERING_DRAGON; 1144. #endif 1145. case RED_DRAGON_SCALE_MAIL: 1146. case RED_DRAGON_SCALES: 1147. return PM_RED_DRAGON; 1148. case ORANGE_DRAGON_SCALE_MAIL: 1149. case ORANGE_DRAGON_SCALES: 1150. return PM_ORANGE_DRAGON; 1151. case WHITE_DRAGON_SCALE_MAIL: 1152. case WHITE_DRAGON_SCALES: 1153. return PM_WHITE_DRAGON; 1154. case BLACK_DRAGON_SCALE_MAIL: 1155. case BLACK_DRAGON_SCALES: 1156. return PM_BLACK_DRAGON; 1157. case BLUE_DRAGON_SCALE_MAIL: 1158. case BLUE_DRAGON_SCALES: 1159. return PM_BLUE_DRAGON; 1160. case GREEN_DRAGON_SCALE_MAIL: 1161. case GREEN_DRAGON_SCALES: 1162. return PM_GREEN_DRAGON; 1163. case YELLOW_DRAGON_SCALE_MAIL: 1164. case YELLOW_DRAGON_SCALES: 1165. return PM_YELLOW_DRAGON; 1166. default: 1167. return -1; 1168. } 1169. } 1170. 1171. #endif /* OVLB */ 1172. 1173. /*polyself.c*/
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software