Source:NetHack 3.1.0/were.c
Jump to navigation
Jump to search
Below is the full text to were.c from the source code of NetHack 3.1.0.
Warning! This is the source code from an old release. For newer releases, see Source code
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. /* SCCS Id: @(#)were.c 3.1 93/01/17 */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #include "hack.h" 6. 7. #ifdef OVL0 8. 9. void 10. were_change(mon) 11. register struct monst *mon; 12. { 13. register int pm = monsndx(mon->data); 14. 15. if(is_were(mon->data)) 16. if(is_human(mon->data)) { 17. if(Protection_from_shape_changers) return; 18. if(!rn2(50-(night()*20)) || flags.moonphase == FULL_MOON) { 19. new_were(mon); 20. if(mons[pm].msound == MS_BARK && flags.soundok) 21. You("hear a %s howling at the moon.", 22. pm == PM_HUMAN_WEREJACKAL ? "jackal" : "wolf"); 23. } 24. } else if(!rn2(30) || Protection_from_shape_changers) new_were(mon); 25. } 26. 27. #endif /* OVL0 */ 28. #ifdef OVLB 29. 30. static int FDECL(counter_were,(int)); 31. 32. static int 33. counter_were(pm) 34. int pm; 35. { 36. switch(pm) { 37. case PM_WEREWOLF: return(PM_HUMAN_WEREWOLF); 38. case PM_HUMAN_WEREWOLF: return(PM_WEREWOLF); 39. case PM_WEREJACKAL: return(PM_HUMAN_WEREJACKAL); 40. case PM_HUMAN_WEREJACKAL: return(PM_WEREJACKAL); 41. case PM_WERERAT: return(PM_HUMAN_WERERAT); 42. case PM_HUMAN_WERERAT: return(PM_WERERAT); 43. default: return(0); 44. } 45. } 46. 47. void 48. new_were(mon) 49. register struct monst *mon; 50. { 51. register int pm; 52. 53. pm = counter_were(monsndx(mon->data)); 54. if(!pm) { 55. impossible("unknown lycanthrope %s.", mon->data->mname); 56. return; 57. } 58. 59. if(canseemon(mon)) 60. pline("%s changes into a %s.", Monnam(mon), 61. Hallucination ? rndmonnam() : 62. is_human(&mons[pm]) ? "human" : 63. mons[pm].mname+4); 64. 65. mon->data = &mons[pm]; 66. if (mon->msleep || !mon->mcanmove) { 67. /* transformation wakens and/or revitalizes */ 68. mon->msleep = 0; 69. mon->mfrozen = 0; /* not asleep or paralyzed */ 70. mon->mcanmove = 1; 71. } 72. /* regenerate by 1/4 of the lost hit points */ 73. mon->mhp += (mon->mhpmax - mon->mhp) / 4; 74. newsym(mon->mx,mon->my); 75. #ifdef MUSE 76. mon_break_armor(mon); 77. possibly_unwield(mon); 78. #endif 79. } 80. 81. boolean 82. were_summon(ptr,yours) /* were-creature (even you) summons a horde */ 83. register struct permonst *ptr; 84. register boolean yours; 85. { 86. register int i, typ, pm = monsndx(ptr); 87. register struct monst *mtmp; 88. boolean success = FALSE; 89. 90. if(Protection_from_shape_changers && !yours) 91. return FALSE; 92. for(i = rnd(5); i > 0; i--) { 93. switch(pm) { 94. 95. case PM_WERERAT: 96. case PM_HUMAN_WERERAT: 97. typ = rn2(3) ? PM_SEWER_RAT : rn2(3) ? PM_GIANT_RAT : PM_RABID_RAT ; 98. break; 99. case PM_WEREJACKAL: 100. case PM_HUMAN_WEREJACKAL: 101. typ = PM_JACKAL; 102. break; 103. case PM_WEREWOLF: 104. case PM_HUMAN_WEREWOLF: 105. typ = rn2(5) ? PM_WOLF : PM_WINTER_WOLF ; 106. break; 107. default: 108. continue; 109. } 110. mtmp = makemon(&mons[typ], u.ux, u.uy); 111. if (mtmp) success = TRUE; 112. if (yours && mtmp) 113. (void) tamedog(mtmp, (struct obj *) 0); 114. } 115. return success; 116. } 117. 118. #ifdef POLYSELF 119. void 120. you_were() { 121. char qbuf[80]; 122. if(u.umonnum == u.ulycn) return; 123. if(Polymorph_control) { 124. Sprintf(qbuf,"Do you want to change into a %s? ", mons[u.ulycn].mname+4); 125. if(yn(qbuf) == 'n') return; 126. } 127. (void) polymon(u.ulycn); 128. } 129. #endif 130. 131. #endif /* OVLB */ 132. 133. /*were.c*/