1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.potion.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.potion.c,v 1.5 1999/11/16 10:26:37 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.potion.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */
7 extern int float_down();
8 extern char *nomovemsg;
9 extern struct monst youmonst;
10 extern struct monst *makemon();
13 struct obj *otmp,*objs;
15 int unkn = 0, nothing = 0;
17 otmp = getobj("!", "drink");
19 if(!strcmp(objects[otmp->otyp].oc_descr, "smoky") && !rn2(13)) {
24 case POT_RESTORE_STRENGTH:
26 pline("Wow! This makes you feel great!");
27 if(u.ustr < u.ustrmax) {
34 pline("Ooph! This tastes like liquid fire!");
36 /* the whiskey makes us feel better */
37 if(u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey");
39 pline("You pass out.");
41 nomovemsg = "You awake with a headache.";
44 case POT_INVISIBILITY:
45 if(Invis || See_invisible)
49 pline("Gee! All of a sudden, you can't see yourself.");
51 pline("You feel rather airy."), unkn++;
57 pline("This tastes like fruit juice.");
61 pline("You begin to feel better.");
66 if(Blind) Blind = 1; /* see on next move */
71 pline("You are motionlessly suspended.");
73 pline("Your feet are frozen to the floor!");
76 case POT_MONSTER_DETECTION:
78 strange_feeling(otmp, "You feel threatened.");
82 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
84 at(mtmp->mx,mtmp->my,mtmp->data->mlet);
86 pline("You sense the presence of monsters.");
91 case POT_OBJECT_DETECTION:
93 strange_feeling(otmp, "You feel a pull downward.");
96 for(objs = fobj; objs; objs = objs->nobj)
97 if(objs->ox != u.ux || objs->oy != u.uy)
99 pline("You sense the presence of objects close nearby.");
103 for(objs = fobj; objs; objs = objs->nobj)
104 at(objs->ox,objs->oy,objs->olet);
106 pline("You sense the presence of objects.");
112 pline("Yech! This stuff tastes like poison.");
113 if(Poison_resistance)
114 pline("(But in fact it was biologically contaminated orange juice.)");
116 losehp(rnd(10), "contaminated potion");
120 pline("Huh, What? Where am I?");
123 Confusion += rn1(7,16);
125 case POT_GAIN_STRENGTH:
126 pline("Wow do you feel strong!");
127 if(u.ustr >= 118) break; /* > 118 is impossible */
128 if(u.ustr > 17) u.ustr += rnd(118-u.ustr);
130 if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
139 if(!(Fast & ~INTRINSIC))
140 pline("You are suddenly moving much faster.");
142 pline("Your legs get new energy."), unkn++;
147 pline("A cloud of darkness falls upon you.");
150 Blind += rn1(100,250);
156 case POT_EXTRA_HEALING:
157 pline("You feel much better.");
161 u.uhp = (u.uhpmax += 2);
170 Levitation += rnd(100);
171 u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down;
174 impossible("What a funny potion! (%u)", otmp->otyp);
179 pline("You have a peculiar feeling for a moment, then it passes.");
181 if(otmp->dknown && !objects[otmp->otyp].oc_name_known) {
183 objects[otmp->otyp].oc_name_known = 1;
184 more_experienced(0,10);
185 } else if(!objects[otmp->otyp].oc_uname)
197 pline("You feel more experienced.");
202 extern long newuexp();
204 u.uexp = newuexp()+1;
205 pline("Welcome to experience level %u.", ++u.ulevel);
210 strange_feeling(obj,txt)
215 pline("You have a strange feeling for a moment, then it passes.");
218 if(!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)
223 char *bottlenames[] = {
224 "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial"
231 extern char *xname();
232 char *botlnam = bottlenames[rn2(SIZE(bottlenames))];
233 boolean uclose, isyou = (mon == &youmonst);
237 pline("The %s crashes on your head and breaks into shivers.",
239 losehp(rnd(2), "thrown potion");
241 uclose = (dist(mon->mx,mon->my) < 3);
242 /* perhaps 'E' and 'a' have no head? */
243 pline("The %s crashes on %s's head and breaks into shivers.",
244 botlnam, monnam(mon));
245 if(rn2(5) && mon->mhp > 1)
248 pline("The %s evaporates.", xname(obj));
250 if(!isyou && !rn2(3)) switch(obj->otyp) {
252 case POT_RESTORE_STRENGTH:
253 case POT_GAIN_STRENGTH:
255 case POT_EXTRA_HEALING:
256 if(mon->mhp < mon->mhpmax) {
257 mon->mhp = mon->mhpmax;
258 pline("%s looks sound and hale again!", Monnam(mon));
271 case POT_INVISIBILITY:
283 mon->mblinded |= 64 + rn2(64);
288 case POT_FRUIT_JUICE:
289 case POT_MONSTER_DETECTION:
290 case POT_OBJECT_DETECTION:
296 obfree(obj, Null(obj));
303 case POT_RESTORE_STRENGTH:
304 case POT_GAIN_STRENGTH:
305 if(u.ustr < u.ustrmax) u.ustr++, flags.botl = 1;
308 case POT_EXTRA_HEALING:
309 if(u.uhp < u.uhpmax) u.uhp++, flags.botl = 1;
312 if(u.uhp <= 5) u.uhp = 1; else u.uhp -= 5;
318 pline("You feel somewhat dizzy.");
321 case POT_INVISIBILITY:
322 pline("For an instant you couldn't see your right hand.");
325 pline("Something seems to be holding you.");
330 pline("Your knees seem more flexible now.");
333 if(!Blind) pline("It suddenly gets dark.");
340 case POT_FRUIT_JUICE:
341 case POT_MONSTER_DETECTION:
342 case POT_OBJECT_DETECTION:
346 /* note: no obfree() */
350 * -- rudimentary -- to do this correctly requires much more work
351 * -- all sharp weapons get one or more qualities derived from the potions
352 * -- texts on scrolls may be (partially) wiped out; do they become blank?
353 * -- or does their effect change, like under Confusion?
354 * -- all objects may be made invisible by POT_INVISIBILITY
355 * -- If the flask is small, can one dip a large object? Does it magically
356 * -- become a jug? Etc.
359 struct obj *potion, *obj;
361 if(!(obj = getobj("#", "dip")))
363 if(!(potion = getobj("!", "dip into")))
365 pline("Interesting...");
366 if(obj->otyp == ARROW || obj->otyp == DART ||
367 obj->otyp == CROSSBOW_BOLT) {
368 if(potion->otyp == POT_SICKNESS) {
370 if(obj->spe < 7) obj->spe++; /* %% */
377 extern struct permonst pm_ghost;
380 if(!(mtmp = makemon(PM_GHOST,u.ux,u.uy))){
381 pline("This bottle turns out to be empty.");
385 pline("As you open the bottle, an enormous ghost emerges!");
386 pline("You are frightened to death, and unable to move.");