abstract
| - Below is the full text to sit.c from the source code of NetHack 2.2a. To link to a particular line, write [[NetHack 2.2a/sit.c#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)sit.c 2.1 87/11/09 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. 4. #include "hack.h" 5. 6. #ifdef NEWCLASS 7. int identify(); 8. extern struct monst *makemon(); 9. extern struct permonst *courtmon(); 10. 11. dosit() { 12. extern struct obj *readobjnam(), *addinv(); 13. struct obj *sobj_at(); 14. register int cnt; 15. 16. if(Levitation) { 17. 18. pline("You are floating in the air, you can't sit!"); 19. } else if(IS_THRONE(levl[u.ux][u.uy].typ)) { 20. 21. pline("As you sit in the opulent throne"); 22. if (rnd(6) > 4) { 23. 24. switch (rnd(13)) { 25. 26. case 1: 27. pline("you feel suddenly weaker."); 28. if(Poison_resistance) { 29. 30. losestr(rn1(1,2)); 31. losehp(rnd(6), "cursed throne"); 32. } else { 33. 34. losestr(rn1(4,3)); 35. losehp(rnd(10), "cursed throne"); 36. } 37. break; 38. case 2: 39. pline("you feel suddenly stronger."); 40. gainstr(0); 41. break; 42. case 3: 43. pline("A massive charge of electricity shoots through your body!"); 44. losehp(rnd(30), "electric chair"); 45. break; 46. case 4: 47. pline("you feel much, much better!"); 48. if(u.uhp >= (u.uhpmax - 5)) u.uhpmax += 4; 49. u.uhp = u.uhpmax; 50. if (Blinded) Blinded = 1; 51. if (Sick) Sick = 0; 52. heal_legs(); 53. flags.botl = 1; 54. break; 55. case 5: 56. if (u.ugold <= 0) { 57. 58. pline("you feel a strange sensation."); 59. } else { 60. pline("you notice you have no gold!"); 61. u.ugold = 0; 62. flags.botl = 1; 63. } 64. break; 65. case 6: 66. if(u.uluck + rn2(5) < 0) { 67. 68. pline("you feel your luck is changing."); 69. u.uluck++; 70. } else makewish(); 71. break; 72. case 7: 73. cnt = rnd(10); 74. pline("you hear a voice echo:"); 75. pline("Your audience has been summoned, Sire!"); 76. while(cnt--) 77. (void) makemon(courtmon(), u.ux, u.uy); 78. break; 79. case 8: 80. if (Confusion != 0) { 81. 82. pline("you hear a voice echo:"); 83. pline("By your Imperious order Sire..."); 84. } 85. do_genocide(); 86. break; 87. case 9: 88. pline("you hear a voice echo:"); 89. pline("A curse upon you for sitting upon this most holy throne!"); 90. if (u.uluck > 0) { 91. 92. if(!Blind) pline("a cloud of darkness falls upon you."); 93. Blinded += rn1(100,250); 94. seeoff(0); 95. } else rndcurse(); 96. break; 97. case 10: 98. if (u.uluck < 0) { 99. 100. pline("an image forms in your mind."); 101. do_mapping(); 102. } else { 103. 104. pline("your vision clarifies."); 105. HSee_invisible |= INTRINSIC; 106. } 107. break; 108. case 11: 109. if (u.uluck < 0) { 110. 111. pline("you feel threatened."); 112. aggravate(); 113. } else { 114. 115. pline("you feel a wrenching sensation."); 116. tele(); /* teleport him */ 117. } 118. break; 119. case 12: 120. pline("you are granted a gift of insight!"); 121. while (!ggetobj("identify", identify, rn2(5)) 122. && invent); 123. break; 124. case 13: 125. pline("your mind turns into a pretzel!"); 126. HConfusion += rn1(7,16); 127. break; 128. default: impossible("throne effect"); 129. break; 130. } 131. } else pline("you feel somehow out of place..."); 132. 133. if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) { 134. 135. pline("The throne vanishes in a puff of logic."); 136. /* levl[u.ux][u.uy].scrsym = ROOM_SYM; */ 137. levl[u.ux][u.uy].typ = ROOM; 138. } 139. 140. } else pline("Having fun sitting on the floor???"); 141. return(1); 142. } 143. #endif /* NEWCLASS /**/ 144. 145. #if defined(NEWCLASS) || defined(PRAYERS) || defined(HARD) 146. rndcurse() { /* curse a few inventory items at random! */ 147. 148. int nobj = 0; 149. int cnt, onum; 150. struct obj *otmp; 151. 152. for (otmp = invent; otmp; otmp = otmp->nobj) nobj++; 153. for (cnt = rnd(6); cnt > 0; cnt--) { 154. 155. onum = rn2(nobj); 156. for(otmp = invent; onum != 0; onum--) 157. otmp = otmp->nobj; 158. 159. otmp->cursed++; 160. } 161. } 162. #endif
|