Source:NetHack 3.0.0/sit.c

Below is the full text to sit.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/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	3.0	89/06/12 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.   #if defined(THRONES) || defined(SPELLS) 8.   void 9.   take_gold 10.  {  11.   	if (u.ugold <= 0)  { 12.  		You("feel a strange sensation."); 13.  	} else { 14.  		You("notice you have no gold!"); 15.  		u.ugold = 0; 16.  		flags.botl = 1; 17.  	}  18.   }  19.   #endif 20.   21.   int 22.  dosit { 23.  #ifdef THRONES 24.  	register int cnt; 25.  #endif 26.   27.   	if(Levitation)  { 28.  	    pline("There's nothing to sit on up here."); 29.  #ifdef THRONES 30.  	} else  if(IS_THRONE(levl[u.ux][u.uy].typ)) { 31.   32.   	    if (rnd(6) > 4)  { 33.  		switch (rnd(13))  { 34.  		    case 1: 35.  			adjattrib(rn2(A_MAX), -rn1(4,3), FALSE); 36.  			losehp(rnd(10), "cursed throne"); 37.  			break; 38.  		    case 2: 39.  			adjattrib(rn2(A_MAX), 1, FALSE); 40.  			break; 41.  		    case 3: 42.  		pline("A%s charge of electricity shoots through your body!",  43.   			      (Shock_resistance) ? "" : " massive"); 44.  			if(Shock_resistance) 45.  				losehp(rnd(6), "electric chair"); 46.  			else	losehp(rnd(30), "electric chair"); 47.  			break; 48.  		    case 4: 49.  			You("feel much, much better!"); 50.  			if(u.uhp >= (u.uhpmax - 5))  u.uhpmax += 4; 51.  			u.uhp = u.uhpmax; 52.  			make_blinded(0L,TRUE); 53.  			make_sick(0L,FALSE); 54.  			heal_legs; 55.  			flags.botl = 1; 56.  			break; 57.  		    case 5: 58.  			take_gold; 59.  			break; 60.  		    case 6: 61.  			if(u.uluck + rn2(5) < 0) { 62.  			    You("feel your luck is changing."); 63.  			    change_luck(1); 64.  			} else	    makewish; 65.  			break; 66.  		    case 7: 67.  			cnt = rnd(10); 68.  			You("hear a voice echo:"); 69.  			pline("\"Thy audience hath been summoned, Sire!\""); 70.  			while(cnt--) 71.  			    (void) makemon(courtmon, u.ux, u.uy); 72.  			break; 73.  		    case 8: 74.  			You("hear a voice echo:"); 75.  			pline("\"By thy Imperious order, Sire...\""); 76.  			do_genocide(1); 77.  			break; 78.  		    case 9: 79.  			You("hear a voice echo:"); 80.  	pline("\"A curse upon thee for sitting upon this most holy throne!\""); 81.  			if (u.uluck > 0)  { 82.  			    make_blinded(Blinded + rn1(100,250),TRUE); 83.  			} else	    rndcurse; 84.  			break; 85.  		    case 10: 86.  			if (u.uluck < 0 || (HSee_invisible & INTRINSIC))  { 87.  				pline("An image forms in your mind."); 88.  				do_mapping; 89.  			} else  { 90.  				Your("vision clarifies."); 91.  				HSee_invisible |= INTRINSIC; 92.  			}  93.   			break; 94.  		    case 11: 95.  			if (u.uluck < 0)  { 96.  			    You("feel threatened."); 97.  			    aggravate; 98.  			} else  { 99.   100.  			    You("feel a wrenching sensation."); 101. 			    tele;		/* teleport him */ 102. 			}  103.  			break; 104. 		    case 12: 105. 			You("are granted a gift of insight!"); 106. 			while (!ggetobj("identify", identify, rn2(5))  107.  				&& invent); 108. 			break; 109. 		    case 13: 110. 			Your("mind turns into a pretzel!"); 111. 			make_confused(HConfusion + rn1(7,16),FALSE); 112. 			break; 113. 		    default:	impossible("throne effect"); 114. 				break; 115. 		}  116.  	    } else	You("feel somehow out of place..."); 117.  118.  	    if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ))	{ 119. 		pline("The throne vanishes in a puff of logic."); 120. /*		levl[u.ux][u.uy].scrsym = ROOM_SYM; */ 121. 		levl[u.ux][u.uy].typ = ROOM; 122. 		if(Invisible) newsym(u.ux,u.uy); 123. 	    }  124.  #endif 125. #ifdef POLYSELF 126. 	} else if (lays_eggs(uasmon) || u.umonnum == PM_QUEEN_BEE) { 127. 		struct obj *uegg; 128.  129.  		if (u.uhunger < objects[EGG].nutrition) { 130. 			You("are too weak to lay an egg."); 131. 			return 0; 132. 		}  133.   134.  		uegg = mksobj(EGG, 0); 135. 		uegg->spe = 1; 136. 		uegg->quan = 1; 137. 		uegg->owt = weight(uegg); 138. 		uegg->corpsenm = 139. 		    (u.umonnum==PM_QUEEN_BEE ? PM_KILLER_BEE : monsndx(uasmon)); 140. 		uegg->known = uegg->dknown = 1; 141. 		You("lay an egg."); 142. 		dropy(uegg); 143. 		stackobj(uegg); 144. 		morehungry(objects[EGG].nutrition); 145. #endif 146. 	} else 147. 		pline("Having fun sitting on the floor?"); 148. 	return(1); 149. }  150.   151.  void 152. rndcurse {			/* curse a few inventory items at random! */ 153.   154.  	int	nobj = 0; 155. 	int	cnt, onum; 156. 	struct	obj	*otmp; 157.  158.  	if(Antimagic) { 159. 	    shieldeff(u.ux, u.uy); 160. 	    You("feel a malignant aura surround you."); 161. 	}  162.   163.  	for (otmp = invent; otmp; otmp = otmp->nobj)  nobj++; 164. 	    if (nobj) for (cnt = rnd(6/((!!Antimagic) + 1)); cnt > 0; cnt--)  { 165.  166.  		onum = rn2(nobj); 167. 		for(otmp = invent; onum != 0; onum--) 168. 		    otmp = otmp->nobj; 169. 		if(otmp->blessed) 170. 			otmp->blessed = 0; 171. 		else 172. 			otmp->cursed++; 173. 	    }  174.  }  175.   176.  void 177. attrcurse {			/* remove a random INTRINSIC ability */ 178. 	switch(rnd(10)) { 179. 	case 1 : if (HFire_resistance & INTRINSIC) { 180. 			HFire_resistance &= ~INTRINSIC; 181. 			if (Inhell && !Fire_resistance) { 182. 			    You("burn to a crisp."); 183. 			    killer = "gremlin curse"; 184. 			    done("died"); 185. 			} else You("feel warmer."); 186. 			break; 187. 		}  188.  	case 2 : if (HTeleportation & INTRINSIC) { 189. 			HTeleportation &= ~INTRINSIC; 190. 			You("feel less jumpy."); 191. 			break; 192. 		}  193.  	case 3 : if (HPoison_resistance & INTRINSIC) { 194. 			HPoison_resistance &= ~INTRINSIC; 195. 			You("feel a little sick!"); 196. 			break; 197. 		}  198.  	case 4 : if (HTelepat & INTRINSIC) { 199. 			HTelepat &= ~INTRINSIC; 200. 			Your("senses fail!"); 201. 			break; 202. 		}  203.  	case 5 : if (HCold_resistance & INTRINSIC) { 204. 			HCold_resistance &= ~INTRINSIC; 205. 			You("feel cooler."); 206. 			break; 207. 		}  208.  	case 6 : if (HInvis & INTRINSIC) { 209. 			HInvis &= ~INTRINSIC; 210. 			You("feel paranoid."); 211. 			break; 212. 		}  213.  	case 7 : if (HSee_invisible & INTRINSIC) { 214. 			HSee_invisible &= ~INTRINSIC; 215. 			You("thought you saw something!"); 216. 			break; 217. 		}  218.  	case 8 : if (Fast & INTRINSIC) { 219. 			Fast &= ~INTRINSIC; 220. 			You("feel slower."); 221. 			break; 222. 		}  223.  	case 9 : if (Stealth & INTRINSIC) { 224. 			Stealth &= ~INTRINSIC; 225. 			You("feel clumsy."); 226. 			break; 227. 		}  228.  	case 10: if (Protection & INTRINSIC) { 229. 			Protection &= ~INTRINSIC; 230. 			You("feel vulnerable."); 231. 			break; 232. 		}  233.  	default: break; 234. 	}  235.  }