Source:NetHack 3.4.3/src/potion.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to src/potion.c from NetHack 3.4.3. To link to a particular line, write [[potion.c#line123]], for example.

Top of file[edit]

  1. /*	SCCS Id: @(#)potion.c	3.4	2002/10/02	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */

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. #include "hack.h"
  2.  
  3. #ifdef OVLB
  4. boolean notonhead = FALSE;
  5.  
  6. static NEARDATA int nothing, unkn;
  7. static NEARDATA const char beverages[] = { POTION_CLASS, 0 };
  8.  
  9. STATIC_DCL long FDECL(itimeout, (long));
  10. STATIC_DCL long FDECL(itimeout_incr, (long,int));
  11. STATIC_DCL void NDECL(ghost_from_bottle);
  12. STATIC_DCL short FDECL(mixtype, (struct obj *,struct obj *));

itimeout[edit]

  1. /* force `val' to be within valid range for intrinsic timeout value */
  2. STATIC_OVL long
  3. itimeout(val)
  4. long val;
  5. {
  6. if (val >= TIMEOUT) val = TIMEOUT;
  7. else if (val < 1) val = 0;
  8.  
  9. return val;
  10. }

itimeout_incr[edit]

  1. /* increment `old' by `incr' and force result to be valid intrinsic timeout */
  2. STATIC_OVL long
  3. itimeout_incr(old, incr)
  4. long old;
  5. int incr;
  6. {
  7. return itimeout((old & TIMEOUT) + (long)incr);
  8. }

set_itimeout[edit]

  1. /* set the timeout field of intrinsic `which' */
  2. void
  3. set_itimeout(which, val)
  4. long *which, val;
  5. {
  6. *which &= ~TIMEOUT;
  7. *which |= itimeout(val);
  8. }

incr_itimeout[edit]

  1. /* increment the timeout field of intrinsic `which' */
  2. void
  3. incr_itimeout(which, incr)
  4. long *which;
  5. int incr;
  6. {
  7. set_itimeout(which, itimeout_incr(*which, incr));
  8. }

make_confused[edit]

  1. void
  2. make_confused(xtime,talk)
  3. long xtime;
  4. boolean talk;
  5. {
  6. 	long old = HConfusion;
  7.  
  8. 	if (!xtime && old) {
  9. 		if (talk)
  10. 		    You_feel("less %s now.",
  11. 			Hallucination ? "trippy" : "confused");
  12. 	}
  13. 	if ((xtime && !old) || (!xtime && old)) flags.botl = TRUE;
  14.  
  15. 	set_itimeout(&HConfusion, xtime);
  16. }

make_stunned[edit]

  1. void
  2. make_stunned(xtime,talk)
  3. long xtime;
  4. boolean talk;
  5. {
  6. 	long old = HStun;
  7.  
  8. 	if (!xtime && old) {
  9. 		if (talk)
  10. 		    You_feel("%s now.",
  11. 			Hallucination ? "less wobbly" : "a bit steadier");
  12. 	}
  13. 	if (xtime && !old) {
  14. 		if (talk) {
  15. #ifdef STEED
  16. 			if (u.usteed)
  17. 				You("wobble in the saddle.");
  18. 			else
  19. #endif
  20. 			You("%s...", stagger(youmonst.data, "stagger"));
  21. 		}
  22. 	}
  23. 	if ((!xtime && old) || (xtime && !old)) flags.botl = TRUE;
  24.  
  25. 	set_itimeout(&HStun, xtime);
  26. }

make_sick[edit]

  1. void
  2. make_sick(xtime, cause, talk, type)
  3. long xtime;
  4. const char *cause;	/* sickness cause */
  5. boolean talk;
  6. int type;
  7. {
  8. 	long old = Sick;
  9.  
  10. 	if (xtime > 0L) {
  11. 	    if (Sick_resistance) return;
  12. 	    if (!old) {
  13. 		/* newly sick */
  14. 		You_feel("deathly sick.");
  15. 	    } else {
  16. 		/* already sick */
  17. 		if (talk) You_feel("%s worse.",
  18. 			      xtime <= Sick/2L ? "much" : "even");
  19. 	    }
  20. 	    set_itimeout(&Sick, xtime);
  21. 	    u.usick_type |= type;
  22. 	    flags.botl = TRUE;
  23. 	} else if (old && (type & u.usick_type)) {
  24. 	    /* was sick, now not */
  25. 	    u.usick_type &= ~type;
  26. 	    if (u.usick_type) { /* only partly cured */
  27. 		if (talk) You_feel("somewhat better.");
  28. 		set_itimeout(&Sick, Sick * 2); /* approximation */
  29. 	    } else {
  30. 		if (talk) pline("What a relief!");
  31. 		Sick = 0L;		/* set_itimeout(&Sick, 0L) */
  32. 	    }
  33. 	    flags.botl = TRUE;
  34. 	}
  35.  
  36. 	if (Sick) {
  37. 	    exercise(A_CON, FALSE);
  38. 	    if (cause) {
  39. 		(void) strncpy(u.usick_cause, cause, sizeof(u.usick_cause));
  40. 		u.usick_cause[sizeof(u.usick_cause)-1] = 0;
  41. 		}
  42. 	    else
  43. 		u.usick_cause[0] = 0;
  44. 	} else
  45. 	    u.usick_cause[0] = 0;
  46. }

make_vomiting[edit]

  1. void
  2. make_vomiting(xtime, talk)
  3. long xtime;
  4. boolean talk;
  5. {
  6. 	long old = Vomiting;
  7.  
  8. 	if(!xtime && old)
  9. 	    if(talk) You_feel("much less nauseated now.");
  10.  
  11. 	set_itimeout(&Vomiting, xtime);
  12. }
  13.  
  14. static const char vismsg[] = "vision seems to %s for a moment but is %s now.";
  15. static const char eyemsg[] = "%s momentarily %s.";
  16.  
  17. void

make_blinded[edit]

  1. make_blinded(xtime, talk)
  2. long xtime;
  3. boolean talk;
  4. {
  5. 	long old = Blinded;
  6. 	boolean u_could_see, can_see_now;
  7. 	int eyecnt;
  8. 	char buf[BUFSZ];
  9.  
  10. 	/* we need to probe ahead in case the Eyes of the Overworld
  11. 	   are or will be overriding blindness */
  12. 	u_could_see = !Blind;
  13. 	Blinded = xtime ? 1L : 0L;
  14. 	can_see_now = !Blind;
  15. 	Blinded = old;		/* restore */
  16.  
  17. 	if (u.usleep) talk = FALSE;
  18.  
  19. 	if (can_see_now && !u_could_see) {	/* regaining sight */
  20. 	    if (talk) {
  21. 		if (Hallucination)
  22. 		    pline("Far out!  Everything is all cosmic again!");
  23. 		else
  24. 		    You("can see again.");
  25. 	    }
  26. 	} else if (old && !xtime) {
  27. 	    /* clearing temporary blindness without toggling blindness */
  28. 	    if (talk) {
  29. 		if (!haseyes(youmonst.data)) {
  30. 		    strange_feeling((struct obj *)0, (char *)0);
  31. 		} else if (Blindfolded) {
  32. 		    Strcpy(buf, body_part(EYE));
  33. 		    eyecnt = eyecount(youmonst.data);
  34. 		    Your(eyemsg, (eyecnt == 1) ? buf : makeplural(buf),
  35. 			 (eyecnt == 1) ? "itches" : "itch");
  36. 		} else {	/* Eyes of the Overworld */
  37. 		    Your(vismsg, "brighten",
  38. 			 Hallucination ? "sadder" : "normal");
  39. 		}
  40. 	    }
  41. 	}
  42.  
  43. 	if (u_could_see && !can_see_now) {	/* losing sight */
  44. 	    if (talk) {
  45. 		if (Hallucination)
  46. 		    pline("Oh, bummer!  Everything is dark!  Help!");
  47. 		else
  48. 		    pline("A cloud of darkness falls upon you.");
  49. 	    }
  50. 	    /* Before the hero goes blind, set the ball&chain variables. */
  51. 	    if (Punished) set_bc(0);
  52. 	} else if (!old && xtime) {
  53. 	    /* setting temporary blindness without toggling blindness */
  54. 	    if (talk) {
  55. 		if (!haseyes(youmonst.data)) {
  56. 		    strange_feeling((struct obj *)0, (char *)0);
  57. 		} else if (Blindfolded) {
  58. 		    Strcpy(buf, body_part(EYE));
  59. 		    eyecnt = eyecount(youmonst.data);
  60. 		    Your(eyemsg, (eyecnt == 1) ? buf : makeplural(buf),
  61. 			 (eyecnt == 1) ? "twitches" : "twitch");
  62. 		} else {	/* Eyes of the Overworld */
  63. 		    Your(vismsg, "dim",
  64. 			 Hallucination ? "happier" : "normal");
  65. 		}
  66. 	    }
  67. 	}
  68.  
  69. 	set_itimeout(&Blinded, xtime);
  70.  
  71. 	if (u_could_see ^ can_see_now) {  /* one or the other but not both */
  72. 	    flags.botl = 1;
  73. 	    vision_full_recalc = 1;	/* blindness just got toggled */
  74. 	    if (Blind_telepat || Infravision) see_monsters();
  75. 	}
  76. }

make_hallucinated[edit]

  1. boolean
  2. make_hallucinated(xtime, talk, mask)
  3. long xtime;	/* nonzero if this is an attempt to turn on hallucination */
  4. boolean talk;
  5. long mask;	/* nonzero if resistance status should change by mask */
  6. {
  7. 	long old = HHallucination;
  8. 	boolean changed = 0;
  9. 	const char *message, *verb;
  10.  
  11. 	message = (!xtime) ? "Everything %s SO boring now." :
  12. 			     "Oh wow!  Everything %s so cosmic!";
  13. 	verb = (!Blind) ? "looks" : "feels";
  14.  
  15. 	if (mask) {
  16. 	    if (HHallucination) changed = TRUE;
  17.  
  18. 	    if (!xtime) EHalluc_resistance |= mask;
  19. 	    else EHalluc_resistance &= ~mask;
  20. 	} else {
  21. 	    if (!EHalluc_resistance && (!!HHallucination != !!xtime))
  22. 		changed = TRUE;
  23. 	    set_itimeout(&HHallucination, xtime);
  24.  
  25. 	    /* clearing temporary hallucination without toggling vision */
  26. 	    if (!changed && !HHallucination && old && talk) {
  27. 		if (!haseyes(youmonst.data)) {
  28. 		    strange_feeling((struct obj *)0, (char *)0);
  29. 		} else if (Blind) {
  30. 		    char buf[BUFSZ];
  31. 		    int eyecnt = eyecount(youmonst.data);
  32.  
  33. 		    Strcpy(buf, body_part(EYE));
  34. 		    Your(eyemsg, (eyecnt == 1) ? buf : makeplural(buf),
  35. 			 (eyecnt == 1) ? "itches" : "itch");
  36. 		} else {	/* Grayswandir */
  37. 		    Your(vismsg, "flatten", "normal");
  38. 		}
  39. 	    }
  40. 	}
  41.  
  42. 	if (changed) {
  43. 	    if (u.uswallow) {
  44. 		swallowed(0);	/* redraw swallow display */
  45. 	    } else {
  46. 		/* The see_* routines should be called *before* the pline. */
  47. 		see_monsters();
  48. 		see_objects();
  49. 		see_traps();
  50. 	    }
  51.  
  52. 	    /* for perm_inv and anything similar
  53. 	    (eg. Qt windowport's equipped items display) */
  54. 	    update_inventory();
  55.  
  56. 	    flags.botl = 1;
  57. 	    if (talk) pline(message, verb);
  58. 	}
  59. 	return changed;
  60. }

ghost_from_bottle[edit]

  1. STATIC_OVL void
  2. ghost_from_bottle()
  3. {
  4. 	struct monst *mtmp = makemon(&mons[PM_GHOST], u.ux, u.uy, NO_MM_FLAGS);
  5.  
  6. 	if (!mtmp) {
  7. 		pline("This bottle turns out to be empty.");
  8. 		return;
  9. 	}
  10. 	if (Blind) {
  11. 		pline("As you open the bottle, %s emerges.", something);
  12. 		return;
  13. 	}
  14. 	pline("As you open the bottle, an enormous %s emerges!",
  15. 		Hallucination ? rndmonnam() : (const char *)"ghost");
  16. 	if(flags.verbose)
  17. 	    You("are frightened to death, and unable to move.");
  18. 	nomul(-3);
  19. 	nomovemsg = "You regain your composure.";
  20. }

dodrink[edit]

  1. /* "Quaffing is like drinking, except you spill more."  -- Terry Pratchett
  2. */
  3. int
  4. dodrink()
  5. {
  6. 	register struct obj *otmp;
  7. 	const char *potion_descr;
  8.  
  9. 	if (Strangled) {
  10. 		pline("If you can't breathe air, how can you drink liquid?");
  11. 		return 0;
  12. 	}
  13. 	/* Is there a fountain to drink from here? */
  14. 	if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) && !Levitation) {
  15. 		if(yn("Drink from the fountain?") == 'y') {
  16. 			drinkfountain();
  17. 			return 1;
  18. 		}
  19. 	}
  20. #ifdef SINKS
  21. 	/* Or a kitchen sink? */
  22. 	if (IS_SINK(levl[u.ux][u.uy].typ)) {
  23. 		if (yn("Drink from the sink?") == 'y') {
  24. 			drinksink();
  25. 			return 1;
  26. 		}
  27. 	}
  28. #endif
  29.  
  30. 	/* Or are you surrounded by water? */
  31. 	if (Underwater) {
  32. 		if (yn("Drink the water around you?") == 'y') {
  33. 		    pline("Do you know what lives in this water!");
  34. 			return 1;
  35. 		}
  36. 	}
  37.  
  38. 	otmp = getobj(beverages, "drink");
  39. 	if(!otmp) return(0);
  40. 	otmp->in_use = TRUE;		/* you've opened the stopper */
  41.  
  42. #define POTION_OCCUPANT_CHANCE(n) (13 + 2*(n))	/* also in muse.c */
  43.  
  44. 	potion_descr = OBJ_DESCR(objects[otmp->otyp]);
  45. 	if (potion_descr) {
  46. 	    if (!strcmp(potion_descr, "milky") &&
  47. 		    flags.ghost_count < MAXMONNO &&
  48. 		    !rn2(POTION_OCCUPANT_CHANCE(flags.ghost_count))) {
  49. 		ghost_from_bottle();
  50. 		useup(otmp);
  51. 		return(1);
  52. 	    } else if (!strcmp(potion_descr, "smoky") &&
  53. 		    flags.djinni_count < MAXMONNO &&
  54. 		    !rn2(POTION_OCCUPANT_CHANCE(flags.djinni_count))) {
  55. 		djinni_from_bottle(otmp);
  56. 		useup(otmp);
  57. 		return(1);
  58. 	    }
  59. 	}
  60. 	return dopotion(otmp);
  61. }

dopotion[edit]

  1. int
  2. dopotion(otmp)
  3. register struct obj *otmp;
  4. {
  5. 	int retval;
  6.  
  7. 	otmp->in_use = TRUE;
  8. 	nothing = unkn = 0;
  9. 	if((retval = peffects(otmp)) >= 0) return(retval);
  10.  
  11. 	if(nothing) {
  12. 	    unkn++;
  13. 	    You("have a %s feeling for a moment, then it passes.",
  14. 		  Hallucination ? "normal" : "peculiar");
  15. 	}
  16. 	if(otmp->dknown && !objects[otmp->otyp].oc_name_known) {
  17. 		if(!unkn) {
  18. 			makeknown(otmp->otyp);
  19. 			more_experienced(0,10);
  20. 		} else if(!objects[otmp->otyp].oc_uname)
  21. 			docall(otmp);
  22. 	}
  23. 	useup(otmp);
  24. 	return(1);
  25. }

peffects[edit]

  1. int
  2. peffects(otmp)
  3. 	register struct obj	*otmp;
  4. {
  5. 	register int i, ii, lim;
  6.  
  7. 	switch(otmp->otyp){
  8. 	case POT_RESTORE_ABILITY:
  9. 	case SPE_RESTORE_ABILITY:
  10. 		unkn++;
  11. 		if(otmp->cursed) {
  12. 		    pline("Ulch!  This makes you feel mediocre!");
  13. 		    break;
  14. 		} else {
  15. 		    pline("Wow!  This makes you feel %s!",
  16. 			  (otmp->blessed) ?
  17. 				(unfixable_trouble_count(FALSE) ? "better" : "great")
  18. 			  : "good");
  19. 		    i = rn2(A_MAX);		/* start at a random point */
  20. 		    for (ii = 0; ii < A_MAX; ii++) {
  21. 			lim = AMAX(i);
  22. 			if (i == A_STR && u.uhs >= 3) --lim;	/* WEAK */
  23. 			if (ABASE(i) < lim) {
  24. 			    ABASE(i) = lim;
  25. 			    flags.botl = 1;
  26. 			    /* only first found if not blessed */
  27. 			    if (!otmp->blessed) break;
  28. 			}
  29. 			if(++i >= A_MAX) i = 0;
  30. 		    }
  31. 		}
  32. 		break;
  33. 	case POT_HALLUCINATION:
  34. 		if (Hallucination || Halluc_resistance) nothing++;
  35. 		(void) make_hallucinated(itimeout_incr(HHallucination,
  36. 					   rn1(200, 600 - 300 * bcsign(otmp))),
  37. 				  TRUE, 0L);
  38. 		break;
  39. 	case POT_WATER:
  40. 		if(!otmp->blessed && !otmp->cursed) {
  41. 		    pline("This tastes like water.");
  42. 		    u.uhunger += rnd(10);
  43. 		    newuhs(FALSE);
  44. 		    break;
  45. 		}
  46. 		unkn++;
  47. 		if(is_undead(youmonst.data) || is_demon(youmonst.data) ||
  48. 				u.ualign.type == A_CHAOTIC) {
  49. 		    if(otmp->blessed) {
  50. 			pline("This burns like acid!");
  51. 			exercise(A_CON, FALSE);
  52. 			if (u.ulycn >= LOW_PM) {
  53. 			    Your("affinity to %s disappears!",
  54. 				 makeplural(mons[u.ulycn].mname));
  55. 			    if (youmonst.data == &mons[u.ulycn])
  56. 				you_unwere(FALSE);
  57. 			    u.ulycn = NON_PM;	/* cure lycanthropy */
  58. 			}
  59. 			losehp(d(2,6), "potion of holy water", KILLED_BY_AN);
  60. 		    } else if(otmp->cursed) {
  61. 			You_feel("quite proud of yourself.");
  62. 			healup(d(2,6),0,0,0);
  63. 			if (u.ulycn >= LOW_PM && !Upolyd) you_were();
  64. 			exercise(A_CON, TRUE);
  65. 		    }
  66. 		} else {
  67. 		    if(otmp->blessed) {
  68. 			You_feel("full of awe.");
  69. 			make_sick(0L, (char *) 0, TRUE, SICK_ALL);
  70. 			exercise(A_WIS, TRUE);
  71. 			exercise(A_CON, TRUE);
  72. 			if (u.ulycn >= LOW_PM)
  73. 			    you_unwere(TRUE);	/* "Purified" */
  74. 			/* make_confused(0L,TRUE); */
  75. 		    } else {
  76. 			if(u.ualign.type == A_LAWFUL) {
  77. 			    pline("This burns like acid!");
  78. 			    losehp(d(2,6), "potion of unholy water",
  79. 				KILLED_BY_AN);
  80. 			} else
  81. 			    You_feel("full of dread.");
  82. 			if (u.ulycn >= LOW_PM && !Upolyd) you_were();
  83. 			exercise(A_CON, FALSE);
  84. 		    }
  85. 		}
  86. 		break;
  87. 	case POT_BOOZE:
  88. 		unkn++;
  89. 		pline("Ooph!  This tastes like %s%s!",
  90. 		      otmp->odiluted ? "watered down " : "",
  91. 		      Hallucination ? "dandelion wine" : "liquid fire");
  92. 		if (!otmp->blessed)
  93. 		    make_confused(itimeout_incr(HConfusion, d(3,8)), FALSE);
  94. 		/* the whiskey makes us feel better */
  95. 		if (!otmp->odiluted) healup(1, 0, FALSE, FALSE);
  96. 		u.uhunger += 10 * (2 + bcsign(otmp));
  97. 		newuhs(FALSE);
  98. 		exercise(A_WIS, FALSE);
  99. 		if(otmp->cursed) {
  100. 			You("pass out.");
  101. 			multi = -rnd(15);
  102. 			nomovemsg = "You awake with a headache.";
  103. 		}
  104. 		break;
  105. 	case POT_ENLIGHTENMENT:
  106. 		if(otmp->cursed) {
  107. 			unkn++;
  108. 			You("have an uneasy feeling...");
  109. 			exercise(A_WIS, FALSE);
  110. 		} else {
  111. 			if (otmp->blessed) {
  112. 				(void) adjattrib(A_INT, 1, FALSE);
  113. 				(void) adjattrib(A_WIS, 1, FALSE);
  114. 			}
  115. 			You_feel("self-knowledgeable...");
  116. 			display_nhwindow(WIN_MESSAGE, FALSE);
  117. 			enlightenment(0);
  118. 			pline_The("feeling subsides.");
  119. 			exercise(A_WIS, TRUE);
  120. 		}
  121. 		break;
  122. 	case SPE_INVISIBILITY:
  123. 		/* spell cannot penetrate mummy wrapping */
  124. 		if (BInvis && uarmc->otyp == MUMMY_WRAPPING) {
  125. 			You_feel("rather itchy under your %s.", xname(uarmc));
  126. 			break;
  127. 		}
  128. 		/* FALLTHRU */
  129. 	case POT_INVISIBILITY:
  130. 		if (Invis || Blind || BInvis) {
  131. 		    nothing++;
  132. 		} else {
  133. 		    self_invis_message();
  134. 		}
  135. 		if (otmp->blessed) HInvis |= FROMOUTSIDE;
  136. 		else incr_itimeout(&HInvis, rn1(15,31));
  137. 		newsym(u.ux,u.uy);	/* update position */
  138. 		if(otmp->cursed) {
  139. 		    pline("For some reason, you feel your presence is known.");
  140. 		    aggravate();
  141. 		}
  142. 		break;
  143. 	case POT_SEE_INVISIBLE:
  144. 		/* tastes like fruit juice in Rogue */
  145. 	case POT_FRUIT_JUICE:
  146. 	    {
  147. 		int msg = Invisible && !Blind;
  148.  
  149. 		unkn++;
  150. 		if (otmp->cursed)
  151. 		    pline("Yecch!  This tastes %s.",
  152. 			  Hallucination ? "overripe" : "rotten");
  153. 		else
  154. 		    pline(Hallucination ?
  155. 		      "This tastes like 10%% real %s%s all-natural beverage." :
  156. 				"This tastes like %s%s.",
  157. 			  otmp->odiluted ? "reconstituted " : "",
  158. 			  fruitname(TRUE));
  159. 		if (otmp->otyp == POT_FRUIT_JUICE) {
  160. 		    u.uhunger += (otmp->odiluted ? 5 : 10) * (2 + bcsign(otmp));
  161. 		    newuhs(FALSE);
  162. 		    break;
  163. 		}
  164. 		if (!otmp->cursed) {
  165. 			/* Tell them they can see again immediately, which
  166. 			 * will help them identify the potion...
  167. 			 */
  168. 			make_blinded(0L,TRUE);
  169. 		}
  170. 		if (otmp->blessed)
  171. 			HSee_invisible |= FROMOUTSIDE;
  172. 		else
  173. 			incr_itimeout(&HSee_invisible, rn1(100,750));
  174. 		set_mimic_blocking(); /* do special mimic handling */
  175. 		see_monsters();	/* see invisible monsters */
  176. 		newsym(u.ux,u.uy); /* see yourself! */
  177. 		if (msg && !Blind) { /* Blind possible if polymorphed */
  178. 		    You("can see through yourself, but you are visible!");
  179. 		    unkn--;
  180. 		}
  181. 		break;
  182. 	    }
  183. 	case POT_PARALYSIS:
  184. 		if (Free_action)
  185. 		    You("stiffen momentarily.");
  186. 		else {
  187. 		    if (Levitation || Is_airlevel(&u.uz)||Is_waterlevel(&u.uz))
  188. 			You("are motionlessly suspended.");
  189. #ifdef STEED
  190. 		    else if (u.usteed)
  191. 			You("are frozen in place!");
  192. #endif
  193. 		    else
  194. 			Your("%s are frozen to the %s!",
  195. 			     makeplural(body_part(FOOT)), surface(u.ux, u.uy));
  196. 		    nomul(-(rn1(10, 25 - 12*bcsign(otmp))));
  197. 		    nomovemsg = You_can_move_again;
  198. 		    exercise(A_DEX, FALSE);
  199. 		}
  200. 		break;
  201. 	case POT_SLEEPING:
  202. 		if(Sleep_resistance || Free_action)
  203. 		    You("yawn.");
  204. 		else {
  205. 		    You("suddenly fall asleep!");
  206. 		    fall_asleep(-rn1(10, 25 - 12*bcsign(otmp)), TRUE);
  207. 		}
  208. 		break;
  209. 	case POT_MONSTER_DETECTION:
  210. 	case SPE_DETECT_MONSTERS:
  211. 		if (otmp->blessed) {
  212. 		    int x, y;
  213.  
  214. 		    if (Detect_monsters) nothing++;
  215. 		    unkn++;
  216. 		    /* after a while, repeated uses become less effective */
  217. 		    if (HDetect_monsters >= 300L)
  218. 			i = 1;
  219. 		    else
  220. 			i = rn1(40,21);
  221. 		    incr_itimeout(&HDetect_monsters, i);
  222. 		    for (x = 1; x < COLNO; x++) {
  223. 			for (y = 0; y < ROWNO; y++) {
  224. 			    if (levl[x][y].glyph == GLYPH_INVISIBLE) {
  225. 				unmap_object(x, y);
  226. 				newsym(x,y);
  227. 			    }
  228. 			    if (MON_AT(x,y)) unkn = 0;
  229. 			}
  230. 		    }
  231. 		    see_monsters();
  232. 		    if (unkn) You_feel("lonely.");
  233. 		    break;
  234. 		}
  235. 		if (monster_detect(otmp, 0))
  236. 			return(1);		/* nothing detected */
  237. 		exercise(A_WIS, TRUE);
  238. 		break;
  239. 	case POT_OBJECT_DETECTION:
  240. 	case SPE_DETECT_TREASURE:
  241. 		if (object_detect(otmp, 0))
  242. 			return(1);		/* nothing detected */
  243. 		exercise(A_WIS, TRUE);
  244. 		break;
  245. 	case POT_SICKNESS:
  246. 		pline("Yecch!  This stuff tastes like poison.");
  247. 		if (otmp->blessed) {
  248. 		    pline("(But in fact it was mildly stale %s.)",
  249. 			  fruitname(TRUE));
  250. 		    if (!Role_if(PM_HEALER)) {
  251. 			/* NB: blessed otmp->fromsink is not possible */
  252. 			losehp(1, "mildly contaminated potion", KILLED_BY_AN);
  253. 		    }
  254. 		} else {
  255. 		    if(Poison_resistance)
  256. 			pline(
  257. 			  "(But in fact it was biologically contaminated %s.)",
  258. 			      fruitname(TRUE));
  259. 		    if (Role_if(PM_HEALER))
  260. 			pline("Fortunately, you have been immunized.");
  261. 		    else {
  262. 			int typ = rn2(A_MAX);
  263.  
  264. 			if (!Fixed_abil) {
  265. 			    poisontell(typ);
  266. 			    (void) adjattrib(typ,
  267. 			    		Poison_resistance ? -1 : -rn1(4,3),
  268. 			    		TRUE);
  269. 			}
  270. 			if(!Poison_resistance) {
  271. 			    if (otmp->fromsink)
  272. 				losehp(rnd(10)+5*!!(otmp->cursed),
  273. 				       "contaminated tap water", KILLED_BY);
  274. 			    else
  275. 				losehp(rnd(10)+5*!!(otmp->cursed),
  276. 				       "contaminated potion", KILLED_BY_AN);
  277. 			}
  278. 			exercise(A_CON, FALSE);
  279. 		    }
  280. 		}
  281. 		if(Hallucination) {
  282. 			You("are shocked back to your senses!");
  283. 			(void) make_hallucinated(0L,FALSE,0L);
  284. 		}
  285. 		break;
  286. 	case POT_CONFUSION:
  287. 		if(!Confusion)
  288. 		    if (Hallucination) {
  289. 			pline("What a trippy feeling!");
  290. 			unkn++;
  291. 		    } else
  292. 			pline("Huh, What?  Where am I?");
  293. 		else	nothing++;
  294. 		make_confused(itimeout_incr(HConfusion,
  295. 					    rn1(7, 16 - 8 * bcsign(otmp))),
  296. 			      FALSE);
  297. 		break;
  298. 	case POT_GAIN_ABILITY:
  299. 		if(otmp->cursed) {
  300. 		    pline("Ulch!  That potion tasted foul!");
  301. 		    unkn++;
  302. 		} else if (Fixed_abil) {
  303. 		    nothing++;
  304. 		} else {      /* If blessed, increase all; if not, try up to */
  305. 		    int itmp; /* 6 times to find one which can be increased. */
  306. 		    i = -1;		/* increment to 0 */
  307. 		    for (ii = A_MAX; ii > 0; ii--) {
  308. 			i = (otmp->blessed ? i + 1 : rn2(A_MAX));
  309. 			/* only give "your X is already as high as it can get"
  310. 			   message on last attempt (except blessed potions) */
  311. 			itmp = (otmp->blessed || ii == 1) ? 0 : -1;
  312. 			if (adjattrib(i, 1, itmp) && !otmp->blessed)
  313. 			    break;
  314. 		    }
  315. 		}
  316. 		break;
  317. 	case POT_SPEED:
  318. 		if(Wounded_legs && !otmp->cursed
  319. #ifdef STEED
  320. 		   && !u.usteed	/* heal_legs() would heal steeds legs */
  321. #endif
  322. 						) {
  323. 			heal_legs();
  324. 			unkn++;
  325. 			break;
  326. 		} /* and fall through */
  327. 	case SPE_HASTE_SELF:
  328. 		if(!Very_fast) /* wwf@doe.carleton.ca */
  329. 			You("are suddenly moving %sfaster.",
  330. 				Fast ? "" : "much ");
  331. 		else {
  332. 			Your("%s get new energy.",
  333. 				makeplural(body_part(LEG)));
  334. 			unkn++;
  335. 		}
  336. 		exercise(A_DEX, TRUE);
  337. 		incr_itimeout(&HFast, rn1(10, 100 + 60 * bcsign(otmp)));
  338. 		break;
  339. 	case POT_BLINDNESS:
  340. 		if(Blind) nothing++;
  341. 		make_blinded(itimeout_incr(Blinded,
  342. 					   rn1(200, 250 - 125 * bcsign(otmp))),
  343. 			     (boolean)!Blind);
  344. 		break;
  345. 	case POT_GAIN_LEVEL:
  346. 		if (otmp->cursed) {
  347. 			unkn++;
  348. 			/* they went up a level */
  349. 			if((ledger_no(&u.uz) == 1 && u.uhave.amulet) ||
  350. 				Can_rise_up(u.ux, u.uy, &u.uz)) {
  351. 			    const char *riseup ="rise up, through the %s!";
  352. 			    if(ledger_no(&u.uz) == 1) {
  353. 			        You(riseup, ceiling(u.ux,u.uy));
  354. 				goto_level(&earth_level, FALSE, FALSE, FALSE);
  355. 			    } else {
  356. 			        register int newlev = depth(&u.uz)-1;
  357. 				d_level newlevel;
  358.  
  359. 				get_level(&newlevel, newlev);
  360. 				if(on_level(&newlevel, &u.uz)) {
  361. 				    pline("It tasted bad.");
  362. 				    break;
  363. 				} else You(riseup, ceiling(u.ux,u.uy));
  364. 				goto_level(&newlevel, FALSE, FALSE, FALSE);
  365. 			    }
  366. 			}
  367. 			else You("have an uneasy feeling.");
  368. 			break;
  369. 		}
  370. 		pluslvl(FALSE);
  371. 		if (otmp->blessed)
  372. 			/* blessed potions place you at a random spot in the
  373. 			 * middle of the new level instead of the low point
  374. 			 */
  375. 			u.uexp = rndexp(TRUE);
  376. 		break;
  377. 	case POT_HEALING:
  378. 		You_feel("better.");
  379. 		healup(d(6 + 2 * bcsign(otmp), 4),
  380. 		       !otmp->cursed ? 1 : 0, !!otmp->blessed, !otmp->cursed);
  381. 		exercise(A_CON, TRUE);
  382. 		break;
  383. 	case POT_EXTRA_HEALING:
  384. 		You_feel("much better.");
  385. 		healup(d(6 + 2 * bcsign(otmp), 8),
  386. 		       otmp->blessed ? 5 : !otmp->cursed ? 2 : 0,
  387. 		       !otmp->cursed, TRUE);
  388. 		(void) make_hallucinated(0L,TRUE,0L);
  389. 		exercise(A_CON, TRUE);
  390. 		exercise(A_STR, TRUE);
  391. 		break;
  392. 	case POT_FULL_HEALING:
  393. 		You_feel("completely healed.");
  394. 		healup(400, 4+4*bcsign(otmp), !otmp->cursed, TRUE);
  395. 		/* Restore one lost level if blessed */
  396. 		if (otmp->blessed && u.ulevel < u.ulevelmax) {
  397. 		    /* when multiple levels have been lost, drinking
  398. 		       multiple potions will only get half of them back */
  399. 		    u.ulevelmax -= 1;
  400. 		    pluslvl(FALSE);
  401. 		}
  402. 		(void) make_hallucinated(0L,TRUE,0L);
  403. 		exercise(A_STR, TRUE);
  404. 		exercise(A_CON, TRUE);
  405. 		break;
  406. 	case POT_LEVITATION:
  407. 	case SPE_LEVITATION:
  408. 		if (otmp->cursed) HLevitation &= ~I_SPECIAL;
  409. 		if(!Levitation) {
  410. 			/* kludge to ensure proper operation of float_up() */
  411. 			HLevitation = 1;
  412. 			float_up();
  413. 			/* reverse kludge */
  414. 			HLevitation = 0;
  415. 			if (otmp->cursed && !Is_waterlevel(&u.uz)) {
  416. 	if((u.ux != xupstair || u.uy != yupstair)
  417. 	   && (u.ux != sstairs.sx || u.uy != sstairs.sy || !sstairs.up)
  418. 	   && (!xupladder || u.ux != xupladder || u.uy != yupladder)
  419. 	) {
  420. 					You("hit your %s on the %s.",
  421. 						body_part(HEAD),
  422. 						ceiling(u.ux,u.uy));
  423. 					losehp(uarmh ? 1 : rnd(10),
  424. 						"colliding with the ceiling",
  425. 						KILLED_BY);
  426. 				} else (void) doup();
  427. 			}
  428. 		} else
  429. 			nothing++;
  430. 		if (otmp->blessed) {
  431. 		    incr_itimeout(&HLevitation, rn1(50,250));
  432. 		    HLevitation |= I_SPECIAL;
  433. 		} else incr_itimeout(&HLevitation, rn1(140,10));
  434. 		spoteffects(FALSE);	/* for sinks */
  435. 		break;
  436. 	case POT_GAIN_ENERGY:			/* M. Stephenson */
  437. 		{	register int num;
  438. 			if(otmp->cursed)
  439. 			    You_feel("lackluster.");
  440. 			else
  441. 			    pline("Magical energies course through your body.");
  442. 			num = rnd(5) + 5 * otmp->blessed + 1;
  443. 			u.uenmax += (otmp->cursed) ? -num : num;
  444. 			u.uen += (otmp->cursed) ? -num : num;
  445. 			if(u.uenmax <= 0) u.uenmax = 0;
  446. 			if(u.uen <= 0) u.uen = 0;
  447. 			flags.botl = 1;
  448. 			exercise(A_WIS, TRUE);
  449. 		}
  450. 		break;
  451. 	case POT_OIL:				/* P. Winner */
  452. 		{
  453. 			boolean good_for_you = FALSE;
  454.  
  455. 			if (otmp->lamplit) {
  456. 			    if (likes_fire(youmonst.data)) {
  457. 				pline("Ahh, a refreshing drink.");
  458. 				good_for_you = TRUE;
  459. 			    } else {
  460. 				You("burn your %s.", body_part(FACE));
  461. 				losehp(d(Fire_resistance ? 1 : 3, 4),
  462. 				       "burning potion of oil", KILLED_BY_AN);
  463. 			    }
  464. 			} else if(otmp->cursed)
  465. 			    pline("This tastes like castor oil.");
  466. 			else
  467. 			    pline("That was smooth!");
  468. 			exercise(A_WIS, good_for_you);
  469. 		}
  470. 		break;
  471. 	case POT_ACID:
  472. 		if (Acid_resistance)
  473. 			/* Not necessarily a creature who _likes_ acid */
  474. 			pline("This tastes %s.", Hallucination ? "tangy" : "sour");
  475. 		else {
  476. 			pline("This burns%s!", otmp->blessed ? " a little" :
  477. 					otmp->cursed ? " a lot" : " like acid");
  478. 			losehp(d(otmp->cursed ? 2 : 1, otmp->blessed ? 4 : 8),
  479. 					"potion of acid", KILLED_BY_AN);
  480. 			exercise(A_CON, FALSE);
  481. 		}
  482. 		if (Stoned) fix_petrification();
  483. 		unkn++; /* holy/unholy water can burn like acid too */
  484. 		break;
  485. 	case POT_POLYMORPH:
  486. 		You_feel("a little %s.", Hallucination ? "normal" : "strange");
  487. 		if (!Unchanging) polyself(FALSE);
  488. 		break;
  489. 	default:
  490. 		impossible("What a funny potion! (%u)", otmp->otyp);
  491. 		return(0);
  492. 	}
  493. 	return(-1);
  494. }

healup[edit]

  1. void
  2. healup(nhp, nxtra, curesick, cureblind)
  3. 	int nhp, nxtra;
  4. 	register boolean curesick, cureblind;
  5. {
  6. 	if (nhp) {
  7. 		if (Upolyd) {
  8. 			u.mh += nhp;
  9. 			if (u.mh > u.mhmax) u.mh = (u.mhmax += nxtra);
  10. 		} else {
  11. 			u.uhp += nhp;
  12. 			if(u.uhp > u.uhpmax) u.uhp = (u.uhpmax += nxtra);
  13. 		}
  14. 	}
  15. 	if(cureblind)	make_blinded(0L,TRUE);
  16. 	if(curesick)	make_sick(0L, (char *) 0, TRUE, SICK_ALL);
  17. 	flags.botl = 1;
  18. 	return;
  19. }

strange_feeling[edit]

  1. void
  2. strange_feeling(obj,txt)
  3. register struct obj *obj;
  4. register const char *txt;
  5. {
  6. 	if (flags.beginner || !txt)
  7. 		You("have a %s feeling for a moment, then it passes.",
  8. 		Hallucination ? "normal" : "strange");
  9. 	else
  10. 		pline(txt);
  11.  
  12. 	if(!obj)	/* e.g., crystal ball finds no traps */
  13. 		return;
  14.  
  15. 	if(obj->dknown && !objects[obj->otyp].oc_name_known &&
  16. 						!objects[obj->otyp].oc_uname)
  17. 		docall(obj);
  18. 	useup(obj);
  19. }

bottlename[edit]

  1. const char *bottlenames[] = {
  2. 	"bottle", "phial", "flagon", "carafe", "flask", "jar", "vial"
  3. };
  4.  
  5.  
  6. const char *
  7. bottlename()
  8. {
  9. 	return bottlenames[rn2(SIZE(bottlenames))];
  10. }

potionhit[edit]

  1. void
  2. potionhit(mon, obj, your_fault)
  3. register struct monst *mon;
  4. register struct obj *obj;
  5. boolean your_fault;
  6. {
  7. 	register const char *botlnam = bottlename();
  8. 	boolean isyou = (mon == &youmonst);
  9. 	int distance;
  10.  
  11. 	if(isyou) {
  12. 		distance = 0;
  13. 		pline_The("%s crashes on your %s and breaks into shards.",
  14. 			botlnam, body_part(HEAD));
  15. 		losehp(rnd(2), "thrown potion", KILLED_BY_AN);
  16. 	} else {
  17. 		distance = distu(mon->mx,mon->my);
  18. 		if (!cansee(mon->mx,mon->my)) pline("Crash!");
  19. 		else {
  20. 		    char *mnam = mon_nam(mon);
  21. 		    char buf[BUFSZ];
  22.  
  23. 		    if(has_head(mon->data)) {
  24. 			Sprintf(buf, "%s %s",
  25. 				s_suffix(mnam),
  26. 				(notonhead ? "body" : "head"));
  27. 		    } else {
  28. 			Strcpy(buf, mnam);
  29. 		    }
  30. 		    pline_The("%s crashes on %s and breaks into shards.",
  31. 			   botlnam, buf);
  32. 		}
  33. 		if(rn2(5) && mon->mhp > 1)
  34. 			mon->mhp--;
  35. 	}
  36.  
  37. 	/* oil doesn't instantly evaporate */
  38. 	if (obj->otyp != POT_OIL && cansee(mon->mx,mon->my))
  39. 		pline("%s.", Tobjnam(obj, "evaporate"));
  40.  
  41. if (isyou) {
  42. 	switch (obj->otyp) {
  43. 	case POT_OIL:
  44. 		if (obj->lamplit)
  45. 		    splatter_burning_oil(u.ux, u.uy);
  46. 		break;
  47. 	case POT_POLYMORPH:
  48. 		You_feel("a little %s.", Hallucination ? "normal" : "strange");
  49. 		if (!Unchanging && !Antimagic) polyself(FALSE);
  50. 		break;
  51. 	case POT_ACID:
  52. 		if (!Acid_resistance) {
  53. 		    pline("This burns%s!", obj->blessed ? " a little" :
  54. 				    obj->cursed ? " a lot" : "");
  55. 		    losehp(d(obj->cursed ? 2 : 1, obj->blessed ? 4 : 8),
  56. 				    "potion of acid", KILLED_BY_AN);
  57. 		}
  58. 		break;
  59. 	}
  60. } else {
  61. 	boolean angermon = TRUE;
  62.  
  63. 	if (!your_fault) angermon = FALSE;
  64. 	switch (obj->otyp) {
  65. 	case POT_HEALING:
  66. 	case POT_EXTRA_HEALING:
  67. 	case POT_FULL_HEALING:
  68. 		if (mon->data == &mons[PM_PESTILENCE]) goto do_illness;
  69. 		/*FALLTHRU*/
  70. 	case POT_RESTORE_ABILITY:
  71. 	case POT_GAIN_ABILITY:
  72. do_healing:
  73. 		angermon = FALSE;
  74. 		if(mon->mhp < mon->mhpmax) {
  75. 		    mon->mhp = mon->mhpmax;
  76. 		    if (canseemon(mon))
  77. 			pline("%s looks sound and hale again.", Monnam(mon));
  78. 		}
  79. 		break;
  80. 	case POT_SICKNESS:
  81. 		if (mon->data == &mons[PM_PESTILENCE]) goto do_healing;
  82. 		if (dmgtype(mon->data, AD_DISE) ||
  83. 			   dmgtype(mon->data, AD_PEST) || /* won't happen, see prior goto */
  84. 			   resists_poison(mon)) {
  85. 		    if (canseemon(mon))
  86. 			pline("%s looks unharmed.", Monnam(mon));
  87. 		    break;
  88. 		}
  89. do_illness:
  90. 		if((mon->mhpmax > 3) && !resist(mon, POTION_CLASS, 0, NOTELL))
  91. 			mon->mhpmax /= 2;
  92. 		if((mon->mhp > 2) && !resist(mon, POTION_CLASS, 0, NOTELL))
  93. 			mon->mhp /= 2;
  94. 		if (mon->mhp > mon->mhpmax) mon->mhp = mon->mhpmax;
  95. 		if (canseemon(mon))
  96. 		    pline("%s looks rather ill.", Monnam(mon));
  97. 		break;
  98. 	case POT_CONFUSION:
  99. 	case POT_BOOZE:
  100. 		if(!resist(mon, POTION_CLASS, 0, NOTELL))  mon->mconf = TRUE;
  101. 		break;
  102. 	case POT_INVISIBILITY:
  103. 		angermon = FALSE;
  104. 		mon_set_minvis(mon);
  105. 		break;
  106. 	case POT_SLEEPING:
  107. 		/* wakeup() doesn't rouse victims of temporary sleep */
  108. 		if (sleep_monst(mon, rnd(12), POTION_CLASS)) {
  109. 		    pline("%s falls asleep.", Monnam(mon));
  110. 		    slept_monst(mon);
  111. 		}
  112. 		break;
  113. 	case POT_PARALYSIS:
  114. 		if (mon->mcanmove) {
  115. 			mon->mcanmove = 0;
  116. 			/* really should be rnd(5) for consistency with players
  117. 			 * breathing potions, but...
  118. 			 */
  119. 			mon->mfrozen = rnd(25);
  120. 		}
  121. 		break;
  122. 	case POT_SPEED:
  123. 		angermon = FALSE;
  124. 		mon_adjust_speed(mon, 1, obj);
  125. 		break;
  126. 	case POT_BLINDNESS:
  127. 		if(haseyes(mon->data)) {
  128. 		    register int btmp = 64 + rn2(32) +
  129. 			rn2(32) * !resist(mon, POTION_CLASS, 0, NOTELL);
  130. 		    btmp += mon->mblinded;
  131. 		    mon->mblinded = min(btmp,127);
  132. 		    mon->mcansee = 0;
  133. 		}
  134. 		break;
  135. 	case POT_WATER:
  136. 		if (is_undead(mon->data) || is_demon(mon->data) ||
  137. 			is_were(mon->data)) {
  138. 		    if (obj->blessed) {
  139. 			pline("%s %s in pain!", Monnam(mon),
  140. 			      is_silent(mon->data) ? "writhes" : "shrieks");
  141. 			mon->mhp -= d(2,6);
  142. 			/* should only be by you */
  143. 			if (mon->mhp < 1) killed(mon);
  144. 			else if (is_were(mon->data) && !is_human(mon->data))
  145. 			    new_were(mon);	/* revert to human */
  146. 		    } else if (obj->cursed) {
  147. 			angermon = FALSE;
  148. 			if (canseemon(mon))
  149. 			    pline("%s looks healthier.", Monnam(mon));
  150. 			mon->mhp += d(2,6);
  151. 			if (mon->mhp > mon->mhpmax) mon->mhp = mon->mhpmax;
  152. 			if (is_were(mon->data) && is_human(mon->data) &&
  153. 				!Protection_from_shape_changers)
  154. 			    new_were(mon);	/* transform into beast */
  155. 		    }
  156. 		} else if(mon->data == &mons[PM_GREMLIN]) {
  157. 		    angermon = FALSE;
  158. 		    (void)split_mon(mon, (struct monst *)0);
  159. 		} else if(mon->data == &mons[PM_IRON_GOLEM]) {
  160. 		    if (canseemon(mon))
  161. 			pline("%s rusts.", Monnam(mon));
  162. 		    mon->mhp -= d(1,6);
  163. 		    /* should only be by you */
  164. 		    if (mon->mhp < 1) killed(mon);
  165. 		}
  166. 		break;
  167. 	case POT_OIL:
  168. 		if (obj->lamplit)
  169. 			splatter_burning_oil(mon->mx, mon->my);
  170. 		break;
  171. 	case POT_ACID:
  172. 		if (!resists_acid(mon) && !resist(mon, POTION_CLASS, 0, NOTELL)) {
  173. 		    pline("%s %s in pain!", Monnam(mon),
  174. 			  is_silent(mon->data) ? "writhes" : "shrieks");
  175. 		    mon->mhp -= d(obj->cursed ? 2 : 1, obj->blessed ? 4 : 8);
  176. 		    if (mon->mhp < 1) {
  177. 			if (your_fault)
  178. 			    killed(mon);
  179. 			else
  180. 			    monkilled(mon, "", AD_ACID);
  181. 		    }
  182. 		}
  183. 		break;
  184. 	case POT_POLYMORPH:
  185. 		(void) bhitm(mon, obj);
  186. 		break;
  187. /*
  188. 	case POT_GAIN_LEVEL:
  189. 	case POT_LEVITATION:
  190. 	case POT_FRUIT_JUICE:
  191. 	case POT_MONSTER_DETECTION:
  192. 	case POT_OBJECT_DETECTION:
  193. 		break;
  194. */
  195. 	}
  196. 	if (angermon)
  197. 	    wakeup(mon);
  198. 	else
  199. 	    mon->msleeping = 0;
  200. }
  201.  
  202. 	/* Note: potionbreathe() does its own docall() */
  203. 	if ((distance==0 || ((distance < 3) && rn2(5))) &&
  204. 	    (!breathless(youmonst.data) || haseyes(youmonst.data)))
  205. 		potionbreathe(obj);
  206. 	else if (obj->dknown && !objects[obj->otyp].oc_name_known &&
  207. 		   !objects[obj->otyp].oc_uname && cansee(mon->mx,mon->my))
  208. 		docall(obj);
  209. 	if(*u.ushops && obj->unpaid) {
  210. 	        register struct monst *shkp =
  211. 			shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE));
  212.  
  213. 		if(!shkp)
  214. 		    obj->unpaid = 0;
  215. 		else {
  216. 		    (void)stolen_value(obj, u.ux, u.uy,
  217. 				 (boolean)shkp->mpeaceful, FALSE);
  218. 		    subfrombill(obj, shkp);
  219. 		}
  220. 	}
  221. 	obfree(obj, (struct obj *)0);
  222. }

potionbreathe[edit]

  1. /* vapors are inhaled or get in your eyes */
  2. void
  3. potionbreathe(obj)
  4. register struct obj *obj;
  5. {
  6. 	register int i, ii, isdone, kn = 0;
  7.  
  8. 	switch(obj->otyp) {
  9. 	case POT_RESTORE_ABILITY:
  10. 	case POT_GAIN_ABILITY:
  11. 		if(obj->cursed) {
  12. 		    if (!breathless(youmonst.data))
  13. 			pline("Ulch!  That potion smells terrible!");
  14. 		    else if (haseyes(youmonst.data)) {
  15. 			int numeyes = eyecount(youmonst.data);
  16. 			Your("%s sting%s!",
  17. 			     (numeyes == 1) ? body_part(EYE) : makeplural(body_part(EYE)),
  18. 			     (numeyes == 1) ? "s" : "");
  19. 		    }
  20. 		    break;
  21. 		} else {
  22. 		    i = rn2(A_MAX);		/* start at a random point */
  23. 		    for(isdone = ii = 0; !isdone && ii < A_MAX; ii++) {
  24. 			if(ABASE(i) < AMAX(i)) {
  25. 			    ABASE(i)++;
  26. 			    /* only first found if not blessed */
  27. 			    isdone = !(obj->blessed);
  28. 			    flags.botl = 1;
  29. 			}
  30. 			if(++i >= A_MAX) i = 0;
  31. 		    }
  32. 		}
  33. 		break;
  34. 	case POT_FULL_HEALING:
  35. 		if (Upolyd && u.mh < u.mhmax) u.mh++, flags.botl = 1;
  36. 		if (u.uhp < u.uhpmax) u.uhp++, flags.botl = 1;
  37. 		/*FALL THROUGH*/
  38. 	case POT_EXTRA_HEALING:
  39. 		if (Upolyd && u.mh < u.mhmax) u.mh++, flags.botl = 1;
  40. 		if (u.uhp < u.uhpmax) u.uhp++, flags.botl = 1;
  41. 		/*FALL THROUGH*/
  42. 	case POT_HEALING:
  43. 		if (Upolyd && u.mh < u.mhmax) u.mh++, flags.botl = 1;
  44. 		if (u.uhp < u.uhpmax) u.uhp++, flags.botl = 1;
  45. 		exercise(A_CON, TRUE);
  46. 		break;
  47. 	case POT_SICKNESS:
  48. 		if (!Role_if(PM_HEALER)) {
  49. 			if (Upolyd) {
  50. 			    if (u.mh <= 5) u.mh = 1; else u.mh -= 5;
  51. 			} else {
  52. 			    if (u.uhp <= 5) u.uhp = 1; else u.uhp -= 5;
  53. 			}
  54. 			flags.botl = 1;
  55. 			exercise(A_CON, FALSE);
  56. 		}
  57. 		break;
  58. 	case POT_HALLUCINATION:
  59. 		You("have a momentary vision.");
  60. 		break;
  61. 	case POT_CONFUSION:
  62. 	case POT_BOOZE:
  63. 		if(!Confusion)
  64. 			You_feel("somewhat dizzy.");
  65. 		make_confused(itimeout_incr(HConfusion, rnd(5)), FALSE);
  66. 		break;
  67. 	case POT_INVISIBILITY:
  68. 		if (!Blind && !Invis) {
  69. 		    kn++;
  70. 		    pline("For an instant you %s!",
  71. 			See_invisible ? "could see right through yourself"
  72. 			: "couldn't see yourself");
  73. 		}
  74. 		break;
  75. 	case POT_PARALYSIS:
  76. 		kn++;
  77. 		if (!Free_action) {
  78. 		    pline("%s seems to be holding you.", Something);
  79. 		    nomul(-rnd(5));
  80. 		    nomovemsg = You_can_move_again;
  81. 		    exercise(A_DEX, FALSE);
  82. 		} else You("stiffen momentarily.");
  83. 		break;
  84. 	case POT_SLEEPING:
  85. 		kn++;
  86. 		if (!Free_action && !Sleep_resistance) {
  87. 		    You_feel("rather tired.");
  88. 		    nomul(-rnd(5));
  89. 		    nomovemsg = You_can_move_again;
  90. 		    exercise(A_DEX, FALSE);
  91. 		} else You("yawn.");
  92. 		break;
  93. 	case POT_SPEED:
  94. 		if (!Fast) Your("knees seem more flexible now.");
  95. 		incr_itimeout(&HFast, rnd(5));
  96. 		exercise(A_DEX, TRUE);
  97. 		break;
  98. 	case POT_BLINDNESS:
  99. 		if (!Blind && !u.usleep) {
  100. 		    kn++;
  101. 		    pline("It suddenly gets dark.");
  102. 		}
  103. 		make_blinded(itimeout_incr(Blinded, rnd(5)), FALSE);
  104. 		if (!Blind && !u.usleep) Your(vision_clears);
  105. 		break;
  106. 	case POT_WATER:
  107. 		if(u.umonnum == PM_GREMLIN) {
  108. 		    (void)split_mon(&youmonst, (struct monst *)0);
  109. 		} else if (u.ulycn >= LOW_PM) {
  110. 		    /* vapor from [un]holy water will trigger
  111. 		       transformation but won't cure lycanthropy */
  112. 		    if (obj->blessed && youmonst.data == &mons[u.ulycn])
  113. 			you_unwere(FALSE);
  114. 		    else if (obj->cursed && !Upolyd)
  115. 			you_were();
  116. 		}
  117. 		break;
  118. 	case POT_ACID:
  119. 	case POT_POLYMORPH:
  120. 		exercise(A_CON, FALSE);
  121. 		break;
  122. /*
  123. 	case POT_GAIN_LEVEL:
  124. 	case POT_LEVITATION:
  125. 	case POT_FRUIT_JUICE:
  126. 	case POT_MONSTER_DETECTION:
  127. 	case POT_OBJECT_DETECTION:
  128. 	case POT_OIL:
  129. 		break;
  130. */
  131. 	}
  132. 	/* note: no obfree() */
  133. 	if (obj->dknown) {
  134. 	    if (kn)
  135. 		makeknown(obj->otyp);
  136. 	    else if (!objects[obj->otyp].oc_name_known &&
  137. 						!objects[obj->otyp].oc_uname)
  138. 		docall(obj);
  139. 	}
  140. }

mixtype[edit]

  1. STATIC_OVL short
  2. mixtype(o1, o2)
  3. register struct obj *o1, *o2;
  4. /* returns the potion type when o1 is dipped in o2 */
  5. {
  6. 	/* cut down on the number of cases below */
  7. 	if (o1->oclass == POTION_CLASS &&
  8. 	    (o2->otyp == POT_GAIN_LEVEL ||
  9. 	     o2->otyp == POT_GAIN_ENERGY ||
  10. 	     o2->otyp == POT_HEALING ||
  11. 	     o2->otyp == POT_EXTRA_HEALING ||
  12. 	     o2->otyp == POT_FULL_HEALING ||
  13. 	     o2->otyp == POT_ENLIGHTENMENT ||
  14. 	     o2->otyp == POT_FRUIT_JUICE)) {
  15. 		struct obj *swp;
  16.  
  17. 		swp = o1; o1 = o2; o2 = swp;
  18. 	}
  19.  
  20. 	switch (o1->otyp) {
  21. 		case POT_HEALING:
  22. 			switch (o2->otyp) {
  23. 			    case POT_SPEED:
  24. 			    case POT_GAIN_LEVEL:
  25. 			    case POT_GAIN_ENERGY:
  26. 				return POT_EXTRA_HEALING;
  27. 			}
  28. 		case POT_EXTRA_HEALING:
  29. 			switch (o2->otyp) {
  30. 			    case POT_GAIN_LEVEL:
  31. 			    case POT_GAIN_ENERGY:
  32. 				return POT_FULL_HEALING;
  33. 			}
  34. 		case POT_FULL_HEALING:
  35. 			switch (o2->otyp) {
  36. 			    case POT_GAIN_LEVEL:
  37. 			    case POT_GAIN_ENERGY:
  38. 				return POT_GAIN_ABILITY;
  39. 			}
  40. 		case UNICORN_HORN:
  41. 			switch (o2->otyp) {
  42. 			    case POT_SICKNESS:
  43. 				return POT_FRUIT_JUICE;
  44. 			    case POT_HALLUCINATION:
  45. 			    case POT_BLINDNESS:
  46. 			    case POT_CONFUSION:
  47. 				return POT_WATER;
  48. 			}
  49. 			break;
  50. 		case AMETHYST:		/* "a-methyst" == "not intoxicated" */
  51. 			if (o2->otyp == POT_BOOZE)
  52. 			    return POT_FRUIT_JUICE;
  53. 			break;
  54. 		case POT_GAIN_LEVEL:
  55. 		case POT_GAIN_ENERGY:
  56. 			switch (o2->otyp) {
  57. 			    case POT_CONFUSION:
  58. 				return (rn2(3) ? POT_BOOZE : POT_ENLIGHTENMENT);
  59. 			    case POT_HEALING:
  60. 				return POT_EXTRA_HEALING;
  61. 			    case POT_EXTRA_HEALING:
  62. 				return POT_FULL_HEALING;
  63. 			    case POT_FULL_HEALING:
  64. 				return POT_GAIN_ABILITY;
  65. 			    case POT_FRUIT_JUICE:
  66. 				return POT_SEE_INVISIBLE;
  67. 			    case POT_BOOZE:
  68. 				return POT_HALLUCINATION;
  69. 			}
  70. 			break;
  71. 		case POT_FRUIT_JUICE:
  72. 			switch (o2->otyp) {
  73. 			    case POT_SICKNESS:
  74. 				return POT_SICKNESS;
  75. 			    case POT_SPEED:
  76. 				return POT_BOOZE;
  77. 			    case POT_GAIN_LEVEL:
  78. 			    case POT_GAIN_ENERGY:
  79. 				return POT_SEE_INVISIBLE;
  80. 			}
  81. 			break;
  82. 		case POT_ENLIGHTENMENT:
  83. 			switch (o2->otyp) {
  84. 			    case POT_LEVITATION:
  85. 				if (rn2(3)) return POT_GAIN_LEVEL;
  86. 				break;
  87. 			    case POT_FRUIT_JUICE:
  88. 				return POT_BOOZE;
  89. 			    case POT_BOOZE:
  90. 				return POT_CONFUSION;
  91. 			}
  92. 			break;
  93. 	}
  94.  
  95. 	return 0;
  96. }

get_wet[edit]

  1. boolean
  2. get_wet(obj)
  3. register struct obj *obj;
  4. /* returns TRUE if something happened (potion should be used up) */
  5. {
  6. 	char Your_buf[BUFSZ];
  7.  
  8. 	if (snuff_lit(obj)) return(TRUE);
  9.  
  10. 	if (obj->greased) {
  11. 		grease_protect(obj,(char *)0,&youmonst);
  12. 		return(FALSE);
  13. 	}
  14. 	(void) Shk_Your(Your_buf, obj);
  15. 	/* (Rusting shop goods ought to be charged for.) */
  16. 	switch (obj->oclass) {
  17. 	    case POTION_CLASS:
  18. 		if (obj->otyp == POT_WATER) return FALSE;
  19. 		/* KMH -- Water into acid causes an explosion */
  20. 		if (obj->otyp == POT_ACID) {
  21. 			pline("It boils vigorously!");
  22. 			You("are caught in the explosion!");
  23. 			losehp(rnd(10), "elementary chemistry", KILLED_BY);
  24. 			makeknown(obj->otyp);
  25. 			update_inventory();
  26. 			return (TRUE);
  27. 		}
  28. 		pline("%s %s%s.", Your_buf, aobjnam(obj,"dilute"),
  29. 		      obj->odiluted ? " further" : "");
  30. 		if(obj->unpaid && costly_spot(u.ux, u.uy)) {
  31. 		    You("dilute it, you pay for it.");
  32. 		    bill_dummy_object(obj);
  33. 		}
  34. 		if (obj->odiluted) {
  35. 			obj->odiluted = 0;
  36. #ifdef UNIXPC
  37. 			obj->blessed = FALSE;
  38. 			obj->cursed = FALSE;
  39. #else
  40. 			obj->blessed = obj->cursed = FALSE;
  41. #endif
  42. 			obj->otyp = POT_WATER;
  43. 		} else obj->odiluted++;
  44. 		update_inventory();
  45. 		return TRUE;
  46. 	    case SCROLL_CLASS:
  47. 		if (obj->otyp != SCR_BLANK_PAPER
  48. #ifdef MAIL
  49. 		    && obj->otyp != SCR_MAIL
  50. #endif
  51. 		    ) {
  52. 			if (!Blind) {
  53. 				boolean oq1 = obj->quan == 1L;
  54. 				pline_The("scroll%s %s.",
  55. 					  oq1 ? "" : "s", otense(obj, "fade"));
  56. 			}
  57. 			if(obj->unpaid && costly_spot(u.ux, u.uy)) {
  58. 			    You("erase it, you pay for it.");
  59. 			    bill_dummy_object(obj);
  60. 			}
  61. 			obj->otyp = SCR_BLANK_PAPER;
  62. 			obj->spe = 0;
  63. 			update_inventory();
  64. 			return TRUE;
  65. 		} else break;
  66. 	    case SPBOOK_CLASS:
  67. 		if (obj->otyp != SPE_BLANK_PAPER) {
  68.  
  69. 			if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
  70. 	pline("%s suddenly heats up; steam rises and it remains dry.",
  71. 				The(xname(obj)));
  72. 			} else {
  73. 			    if (!Blind) {
  74. 				    boolean oq1 = obj->quan == 1L;
  75. 				    pline_The("spellbook%s %s.",
  76. 					oq1 ? "" : "s", otense(obj, "fade"));
  77. 			    }
  78. 			    if(obj->unpaid && costly_spot(u.ux, u.uy)) {
  79. 			        You("erase it, you pay for it.");
  80. 			        bill_dummy_object(obj);
  81. 			    }
  82. 			    obj->otyp = SPE_BLANK_PAPER;
  83. 			    update_inventory();
  84. 			}
  85. 			return TRUE;
  86. 		}
  87. 		break;
  88. 	    case WEAPON_CLASS:
  89. 	    /* Just "fall through" to generic rustprone check for now. */
  90. 	    /* fall through */
  91. 	    default:
  92. 		if (!obj->oerodeproof && is_rustprone(obj) &&
  93. 		    (obj->oeroded < MAX_ERODE) && !rn2(2)) {
  94. 			pline("%s %s some%s.",
  95. 			      Your_buf, aobjnam(obj, "rust"),
  96. 			      obj->oeroded ? " more" : "what");
  97. 			obj->oeroded++;
  98. 			update_inventory();
  99. 			return TRUE;
  100. 		} else break;
  101. 	}
  102. 	pline("%s %s wet.", Your_buf, aobjnam(obj,"get"));
  103. 	return FALSE;
  104. }

dodip[edit]

  1. int
  2. dodip()
  3. {
  4. 	register struct obj *potion, *obj;
  5. 	struct obj *singlepotion;
  6. 	const char *tmp;
  7. 	uchar here;
  8. 	char allowall[2];
  9. 	short mixture;
  10. 	char qbuf[QBUFSZ], Your_buf[BUFSZ];
  11.  
  12. 	allowall[0] = ALL_CLASSES; allowall[1] = '\0';
  13. 	if(!(obj = getobj(allowall, "dip")))
  14. 		return(0);
  15.  
  16. 	here = levl[u.ux][u.uy].typ;
  17. 	/* Is there a fountain to dip into here? */
  18. 	if (IS_FOUNTAIN(here)) {
  19. 		if(yn("Dip it into the fountain?") == 'y') {
  20. 			dipfountain(obj);
  21. 			return(1);
  22. 		}
  23. 	} else if (is_pool(u.ux,u.uy)) {
  24. 		tmp = waterbody_name(u.ux,u.uy);
  25. 		Sprintf(qbuf, "Dip it into the %s?", tmp);
  26. 		if (yn(qbuf) == 'y') {
  27. 		    if (Levitation) {
  28. 			floating_above(tmp);
  29. #ifdef STEED
  30. 		    } else if (u.usteed && !is_swimmer(u.usteed->data) &&
  31. 			    P_SKILL(P_RIDING) < P_BASIC) {
  32. 			rider_cant_reach(); /* not skilled enough to reach */
  33. #endif
  34. 		    } else {
  35. 			(void) get_wet(obj);
  36. 			if (obj->otyp == POT_ACID) useup(obj);
  37. 		    }
  38. 		    return 1;
  39. 		}
  40. 	}
  41.  
  42. 	if(!(potion = getobj(beverages, "dip into")))
  43. 		return(0);
  44. 	if (potion == obj && potion->quan == 1L) {
  45. 		pline("That is a potion bottle, not a Klein bottle!");
  46. 		return 0;
  47. 	}
  48. 	potion->in_use = TRUE;		/* assume it will be used up */
  49. 	if(potion->otyp == POT_WATER) {
  50. 		boolean useeit = !Blind;
  51. 		if (useeit) (void) Shk_Your(Your_buf, obj);
  52. 		if (potion->blessed) {
  53. 			if (obj->cursed) {
  54. 				if (useeit)
  55. 				    pline("%s %s %s.",
  56. 					  Your_buf,
  57. 					  aobjnam(obj, "softly glow"),
  58. 					  hcolor(NH_AMBER));
  59. 				uncurse(obj);
  60. 				obj->bknown=1;
  61. 	poof:
  62. 				if(!(objects[potion->otyp].oc_name_known) &&
  63. 				   !(objects[potion->otyp].oc_uname))
  64. 					docall(potion);
  65. 				useup(potion);
  66. 				return(1);
  67. 			} else if(!obj->blessed) {
  68. 				if (useeit) {
  69. 				    tmp = hcolor(NH_LIGHT_BLUE);
  70. 				    pline("%s %s with a%s %s aura.",
  71. 					  Your_buf,
  72. 					  aobjnam(obj, "softly glow"),
  73. 					  index(vowels, *tmp) ? "n" : "", tmp);
  74. 				}
  75. 				bless(obj);
  76. 				obj->bknown=1;
  77. 				goto poof;
  78. 			}
  79. 		} else if (potion->cursed) {
  80. 			if (obj->blessed) {
  81. 				if (useeit)
  82. 				    pline("%s %s %s.",
  83. 					  Your_buf,
  84. 					  aobjnam(obj, "glow"),
  85. 					  hcolor((const char *)"brown"));
  86. 				unbless(obj);
  87. 				obj->bknown=1;
  88. 				goto poof;
  89. 			} else if(!obj->cursed) {
  90. 				if (useeit) {
  91. 				    tmp = hcolor(NH_BLACK);
  92. 				    pline("%s %s with a%s %s aura.",
  93. 					  Your_buf,
  94. 					  aobjnam(obj, "glow"),
  95. 					  index(vowels, *tmp) ? "n" : "", tmp);
  96. 				}
  97. 				curse(obj);
  98. 				obj->bknown=1;
  99. 				goto poof;
  100. 			}
  101. 		} else
  102. 			if (get_wet(obj))
  103. 			    goto poof;
  104. 	} else if (obj->otyp == POT_POLYMORPH ||
  105. 		potion->otyp == POT_POLYMORPH) {
  106. 	    /* some objects can't be polymorphed */
  107. 	    if (obj->otyp == potion->otyp ||	/* both POT_POLY */
  108. 		    obj->otyp == WAN_POLYMORPH ||
  109. 		    obj->otyp == SPE_POLYMORPH ||
  110. 		    obj == uball || obj == uskin ||
  111. 		    obj_resists(obj->otyp == POT_POLYMORPH ?
  112. 				potion : obj, 5, 95)) {
  113. 		pline(nothing_happens);
  114. 	    } else {
  115. 	    	boolean was_wep = FALSE, was_swapwep = FALSE, was_quiver = FALSE;
  116. 		short save_otyp = obj->otyp;
  117. 		/* KMH, conduct */
  118. 		u.uconduct.polypiles++;
  119.  
  120. 		if (obj == uwep) was_wep = TRUE;
  121. 		else if (obj == uswapwep) was_swapwep = TRUE;
  122. 		else if (obj == uquiver) was_quiver = TRUE;
  123.  
  124. 		obj = poly_obj(obj, STRANGE_OBJECT);
  125.  
  126. 		if (was_wep) setuwep(obj);
  127. 		else if (was_swapwep) setuswapwep(obj);
  128. 		else if (was_quiver) setuqwep(obj);
  129.  
  130. 		if (obj->otyp != save_otyp) {
  131. 			makeknown(POT_POLYMORPH);
  132. 			useup(potion);
  133. 			prinv((char *)0, obj, 0L);
  134. 			return 1;
  135. 		} else {
  136. 			pline("Nothing seems to happen.");
  137. 			goto poof;
  138. 		}
  139. 	    }
  140. 	    potion->in_use = FALSE;	/* didn't go poof */
  141. 	    return(1);
  142. 	} else if(obj->oclass == POTION_CLASS && obj->otyp != potion->otyp) {
  143. 		/* Mixing potions is dangerous... */
  144. 		pline_The("potions mix...");
  145. 		/* KMH, balance patch -- acid is particularly unstable */
  146. 		if (obj->cursed || obj->otyp == POT_ACID || !rn2(10)) {
  147. 			pline("BOOM!  They explode!");
  148. 			exercise(A_STR, FALSE);
  149. 			if (!breathless(youmonst.data) || haseyes(youmonst.data))
  150. 				potionbreathe(obj);
  151. 			useup(obj);
  152. 			useup(potion);
  153. 			losehp(rnd(10), "alchemic blast", KILLED_BY_AN);
  154. 			return(1);
  155. 		}
  156.  
  157. 		obj->blessed = obj->cursed = obj->bknown = 0;
  158. 		if (Blind || Hallucination) obj->dknown = 0;
  159.  
  160. 		if ((mixture = mixtype(obj, potion)) != 0) {
  161. 			obj->otyp = mixture;
  162. 		} else {
  163. 		    switch (obj->odiluted ? 1 : rnd(8)) {
  164. 			case 1:
  165. 				obj->otyp = POT_WATER;
  166. 				break;
  167. 			case 2:
  168. 			case 3:
  169. 				obj->otyp = POT_SICKNESS;
  170. 				break;
  171. 			case 4:
  172. 				{
  173. 				  struct obj *otmp;
  174. 				  otmp = mkobj(POTION_CLASS,FALSE);
  175. 				  obj->otyp = otmp->otyp;
  176. 				  obfree(otmp, (struct obj *)0);
  177. 				}
  178. 				break;
  179. 			default:
  180. 				if (!Blind)
  181. 			  pline_The("mixture glows brightly and evaporates.");
  182. 				useup(obj);
  183. 				useup(potion);
  184. 				return(1);
  185. 		    }
  186. 		}
  187.  
  188. 		obj->odiluted = (obj->otyp != POT_WATER);
  189.  
  190. 		if (obj->otyp == POT_WATER && !Hallucination) {
  191. 			pline_The("mixture bubbles%s.",
  192. 				Blind ? "" : ", then clears");
  193. 		} else if (!Blind) {
  194. 			pline_The("mixture looks %s.",
  195. 				hcolor(OBJ_DESCR(objects[obj->otyp])));
  196. 		}
  197.  
  198. 		useup(potion);
  199. 		return(1);
  200. 	}
  201.  
  202. #ifdef INVISIBLE_OBJECTS
  203. 	if (potion->otyp == POT_INVISIBILITY && !obj->oinvis) {
  204. 		obj->oinvis = TRUE;
  205. 		if (!Blind) {
  206. 		    if (!See_invisible) pline("Where did %s go?",
  207. 		    		the(xname(obj)));
  208. 		    else You("notice a little haziness around %s.",
  209. 		    		the(xname(obj)));
  210. 		}
  211. 		goto poof;
  212. 	} else if (potion->otyp == POT_SEE_INVISIBLE && obj->oinvis) {
  213. 		obj->oinvis = FALSE;
  214. 		if (!Blind) {
  215. 		    if (!See_invisible) pline("So that's where %s went!",
  216. 		    		the(xname(obj)));
  217. 		    else pline_The("haziness around %s disappears.",
  218. 		    		the(xname(obj)));
  219. 		}
  220. 		goto poof;
  221. 	}
  222. #endif
  223.  
  224. 	if(is_poisonable(obj)) {
  225. 	    if(potion->otyp == POT_SICKNESS && !obj->opoisoned) {
  226. 		char buf[BUFSZ];
  227. 		if (potion->quan > 1L)
  228. 		    Sprintf(buf, "One of %s", the(xname(potion)));
  229. 		else
  230. 		    Strcpy(buf, The(xname(potion)));
  231. 		pline("%s forms a coating on %s.",
  232. 		      buf, the(xname(obj)));
  233. 		obj->opoisoned = TRUE;
  234. 		goto poof;
  235. 	    } else if(obj->opoisoned &&
  236. 		      (potion->otyp == POT_HEALING ||
  237. 		       potion->otyp == POT_EXTRA_HEALING ||
  238. 		       potion->otyp == POT_FULL_HEALING)) {
  239. 		pline("A coating wears off %s.", the(xname(obj)));
  240. 		obj->opoisoned = 0;
  241. 		goto poof;
  242. 	    }
  243. 	}
  244.  
  245. 	if (potion->otyp == POT_OIL) {
  246. 	    boolean wisx = FALSE;
  247. 	    if (potion->lamplit) {	/* burning */
  248. 		int omat = objects[obj->otyp].oc_material;
  249. 		/* the code here should be merged with fire_damage */
  250. 		if (catch_lit(obj)) {
  251. 		    /* catch_lit does all the work if true */
  252. 		} else if (obj->oerodeproof || obj_resists(obj, 5, 95) ||
  253. 			   !is_flammable(obj) || obj->oclass == FOOD_CLASS) {
  254. 		    pline("%s %s to burn for a moment.",
  255. 			  Yname2(obj), otense(obj, "seem"));
  256. 		} else {
  257. 		    if ((omat == PLASTIC || omat == PAPER) && !obj->oartifact)
  258. 			obj->oeroded = MAX_ERODE;
  259. 		    pline_The("burning oil %s %s.",
  260. 			    obj->oeroded == MAX_ERODE ? "destroys" : "damages",
  261. 			    yname(obj));
  262. 		    if (obj->oeroded == MAX_ERODE) {
  263. 			obj_extract_self(obj);
  264. 			obfree(obj, (struct obj *)0);
  265. 			obj = (struct obj *) 0;
  266. 		    } else {
  267. 			/* we know it's carried */
  268. 			if (obj->unpaid) {
  269. 			    /* create a dummy duplicate to put on bill */
  270. 			    verbalize("You burnt it, you bought it!");
  271. 			    bill_dummy_object(obj);
  272. 			}
  273. 			obj->oeroded++;
  274. 		    }
  275. 		}
  276. 	    } else if (potion->cursed) {
  277. 		pline_The("potion spills and covers your %s with oil.",
  278. 			  makeplural(body_part(FINGER)));
  279. 		incr_itimeout(&Glib, d(2,10));
  280. 	    } else if (obj->oclass != WEAPON_CLASS && !is_weptool(obj)) {
  281. 		/* the following cases apply only to weapons */
  282. 		goto more_dips;
  283. 	    /* Oil removes rust and corrosion, but doesn't unburn.
  284. 	     * Arrows, etc are classed as metallic due to arrowhead
  285. 	     * material, but dipping in oil shouldn't repair them.
  286. 	     */
  287. 	    } else if ((!is_rustprone(obj) && !is_corrodeable(obj)) ||
  288. 			is_ammo(obj) || (!obj->oeroded && !obj->oeroded2)) {
  289. 		/* uses up potion, doesn't set obj->greased */
  290. 		pline("%s %s with an oily sheen.",
  291. 		      Yname2(obj), otense(obj, "gleam"));
  292. 	    } else {
  293. 		pline("%s %s less %s.",
  294. 		      Yname2(obj), otense(obj, "are"),
  295. 		      (obj->oeroded && obj->oeroded2) ? "corroded and rusty" :
  296. 			obj->oeroded ? "rusty" : "corroded");
  297. 		if (obj->oeroded > 0) obj->oeroded--;
  298. 		if (obj->oeroded2 > 0) obj->oeroded2--;
  299. 		wisx = TRUE;
  300. 	    }
  301. 	    exercise(A_WIS, wisx);
  302. 	    makeknown(potion->otyp);
  303. 	    useup(potion);
  304. 	    return 1;
  305. 	}
  306. more_dips:
  307.  
  308. 	/* Allow filling of MAGIC_LAMPs to prevent identification by player */
  309. 	if ((obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP) &&
  310. 	   (potion->otyp == POT_OIL)) {
  311. 	    /* Turn off engine before fueling, turn off fuel too :-)  */
  312. 	    if (obj->lamplit || potion->lamplit) {
  313. 		useup(potion);
  314. 		explode(u.ux, u.uy, 11, d(6,6), 0, EXPL_FIERY);
  315. 		exercise(A_WIS, FALSE);
  316. 		return 1;
  317. 	    }
  318. 	    /* Adding oil to an empty magic lamp renders it into an oil lamp */
  319. 	    if ((obj->otyp == MAGIC_LAMP) && obj->spe == 0) {
  320. 		obj->otyp = OIL_LAMP;
  321. 		obj->age = 0;
  322. 	    }
  323. 	    if (obj->age > 1000L) {
  324. 		pline("%s %s full.", Yname2(obj), otense(obj, "are"));
  325. 		potion->in_use = FALSE;	/* didn't go poof */
  326. 	    } else {
  327. 		You("fill %s with oil.", yname(obj));
  328. 		check_unpaid(potion);	/* Yendorian Fuel Tax */
  329. 		obj->age += 2*potion->age;	/* burns more efficiently */
  330. 		if (obj->age > 1500L) obj->age = 1500L;
  331. 		useup(potion);
  332. 		exercise(A_WIS, TRUE);
  333. 	    }
  334. 	    makeknown(POT_OIL);
  335. 	    obj->spe = 1;
  336. 	    update_inventory();
  337. 	    return 1;
  338. 	}
  339.  
  340. 	potion->in_use = FALSE;		/* didn't go poof */
  341. 	if ((obj->otyp == UNICORN_HORN || obj->otyp == AMETHYST) &&
  342. 	    (mixture = mixtype(obj, potion)) != 0) {
  343. 		char oldbuf[BUFSZ], newbuf[BUFSZ];
  344. 		short old_otyp = potion->otyp;
  345. 		boolean old_dknown = FALSE;
  346. 		boolean more_than_one = potion->quan > 1;
  347.  
  348. 		oldbuf[0] = '\0';
  349. 		if (potion->dknown) {
  350. 		    old_dknown = TRUE;
  351. 		    Sprintf(oldbuf, "%s ",
  352. 			    hcolor(OBJ_DESCR(objects[potion->otyp])));
  353. 		}
  354. 		/* with multiple merged potions, split off one and
  355. 		   just clear it */
  356. 		if (potion->quan > 1L) {
  357. 		    singlepotion = splitobj(potion, 1L);
  358. 		} else singlepotion = potion;
  359.  
  360. 		if(singlepotion->unpaid && costly_spot(u.ux, u.uy)) {
  361. 		    You("use it, you pay for it.");
  362. 		    bill_dummy_object(singlepotion);
  363. 		}
  364. 		singlepotion->otyp = mixture;
  365. 		singlepotion->blessed = 0;
  366. 		if (mixture == POT_WATER)
  367. 		    singlepotion->cursed = singlepotion->odiluted = 0;
  368. 		else
  369. 		    singlepotion->cursed = obj->cursed;  /* odiluted left as-is */
  370. 		singlepotion->bknown = FALSE;
  371. 		if (Blind) {
  372. 		    singlepotion->dknown = FALSE;
  373. 		} else {
  374. 		    singlepotion->dknown = !Hallucination;
  375. 		    if (mixture == POT_WATER && singlepotion->dknown)
  376. 			Sprintf(newbuf, "clears");
  377. 		    else
  378. 			Sprintf(newbuf, "turns %s",
  379. 				hcolor(OBJ_DESCR(objects[mixture])));
  380. 		    pline_The("%spotion%s %s.", oldbuf,
  381. 			      more_than_one ? " that you dipped into" : "",
  382. 			      newbuf);
  383. 		    if(!objects[old_otyp].oc_uname &&
  384. 			!objects[old_otyp].oc_name_known && old_dknown) {
  385. 			struct obj fakeobj;
  386. 			fakeobj = zeroobj;
  387. 			fakeobj.dknown = 1;
  388. 			fakeobj.otyp = old_otyp;
  389. 			fakeobj.oclass = POTION_CLASS;
  390. 			docall(&fakeobj);
  391. 		    }
  392. 		}
  393. 		obj_extract_self(singlepotion);
  394. 		singlepotion = hold_another_object(singlepotion,
  395. 					"You juggle and drop %s!",
  396. 					doname(singlepotion), (const char *)0);
  397. 		update_inventory();
  398. 		return(1);
  399. 	}
  400.  
  401. 	pline("Interesting...");
  402. 	return(1);
  403. }

djinni_from_bottle[edit]

  1. void
  2. djinni_from_bottle(obj)
  3. register struct obj *obj;
  4. {
  5. 	struct monst *mtmp;
  6. 	int chance;
  7.  
  8. 	if(!(mtmp = makemon(&mons[PM_DJINNI], u.ux, u.uy, NO_MM_FLAGS))){
  9. 		pline("It turns out to be empty.");
  10. 		return;
  11. 	}
  12.  
  13. 	if (!Blind) {
  14. 		pline("In a cloud of smoke, %s emerges!", a_monnam(mtmp));
  15. 		pline("%s speaks.", Monnam(mtmp));
  16. 	} else {
  17. 		You("smell acrid fumes.");
  18. 		pline("%s speaks.", Something);
  19. 	}
  20.  
  21. 	chance = rn2(5);
  22. 	if (obj->blessed) chance = (chance == 4) ? rnd(4) : 0;
  23. 	else if (obj->cursed) chance = (chance == 0) ? rn2(4) : 4;
  24. 	/* 0,1,2,3,4:  b=80%,5,5,5,5; nc=20%,20,20,20,20; c=5%,5,5,5,80 */
  25.  
  26. 	switch (chance) {
  27. 	case 0 : verbalize("I am in your debt.  I will grant one wish!");
  28. 		makewish();
  29. 		mongone(mtmp);
  30. 		break;
  31. 	case 1 : verbalize("Thank you for freeing me!");
  32. 		(void) tamedog(mtmp, (struct obj *)0);
  33. 		break;
  34. 	case 2 : verbalize("You freed me!");
  35. 		mtmp->mpeaceful = TRUE;
  36. 		set_malign(mtmp);
  37. 		break;
  38. 	case 3 : verbalize("It is about time!");
  39. 		pline("%s vanishes.", Monnam(mtmp));
  40. 		mongone(mtmp);
  41. 		break;
  42. 	default: verbalize("You disturbed me, fool!");
  43. 		break;
  44. 	}
  45. }

split_mon[edit]

  1. /* clone a gremlin or mold (2nd arg non-null implies heat as the trigger);
  2. hit points are cut in half (odd HP stays with original) */
  3. struct monst *
  4. split_mon(mon, mtmp)
  5. struct monst *mon,	/* monster being split */
  6. 	     *mtmp;	/* optional attacker whose heat triggered it */
  7. {
  8. 	struct monst *mtmp2;
  9. 	char reason[BUFSZ];
  10.  
  11. 	reason[0] = '\0';
  12. 	if (mtmp) Sprintf(reason, " from %s heat",
  13. 			  (mtmp == &youmonst) ? (const char *)"your" :
  14. 			      (const char *)s_suffix(mon_nam(mtmp)));
  15.  
  16. 	if (mon == &youmonst) {
  17. 	    mtmp2 = cloneu();
  18. 	    if (mtmp2) {
  19. 		mtmp2->mhpmax = u.mhmax / 2;
  20. 		u.mhmax -= mtmp2->mhpmax;
  21. 		flags.botl = 1;
  22. 		You("multiply%s!", reason);
  23. 	    }
  24. 	} else {
  25. 	    mtmp2 = clone_mon(mon, 0, 0);
  26. 	    if (mtmp2) {
  27. 		mtmp2->mhpmax = mon->mhpmax / 2;
  28. 		mon->mhpmax -= mtmp2->mhpmax;
  29. 		if (canspotmon(mon))
  30. 		    pline("%s multiplies%s!", Monnam(mon), reason);
  31. 	    }
  32. 	}
  33. 	return mtmp2;
  34. }
  35.  
  36. #endif /* OVLB */
  37.  
  38. /*potion.c*/