1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.potion.c - version 1.0.3 */
5 extern int float_down();
6 extern char *nomovemsg;
7 extern struct monst youmonst;
8 extern struct monst *makemon();
11 register struct obj *otmp,*objs;
12 register struct monst *mtmp;
13 register int unkn = 0, nothing = 0;
15 otmp = getobj("!", "drink");
17 if(!strcmp(objects[otmp->otyp].oc_descr, "smoky") && !rn2(13)) {
22 case POT_RESTORE_STRENGTH:
24 pline("Wow! This makes you feel great!");
25 if(u.ustr < u.ustrmax) {
32 pline("Ooph! This tastes like liquid fire!");
34 /* the whiskey makes us feel better */
35 if(u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey");
37 pline("You pass out.");
39 nomovemsg = "You awake with a headache.";
42 case POT_INVISIBILITY:
43 if(Invis || See_invisible)
47 pline("Gee! All of a sudden, you can't see yourself.");
49 pline("You feel rather airy."), unkn++;
55 pline("This tastes like fruit juice.");
59 pline("You begin to feel better.");
64 if(Blind) Blind = 1; /* see on next move */
69 pline("You are motionlessly suspended.");
71 pline("Your feet are frozen to the floor!");
74 case POT_MONSTER_DETECTION:
76 strange_feeling(otmp, "You feel threatened.");
80 for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
82 at(mtmp->mx,mtmp->my,mtmp->data->mlet);
84 pline("You sense the presence of monsters.");
89 case POT_OBJECT_DETECTION:
91 strange_feeling(otmp, "You feel a pull downward.");
94 for(objs = fobj; objs; objs = objs->nobj)
95 if(objs->ox != u.ux || objs->oy != u.uy)
97 pline("You sense the presence of objects close nearby.");
101 for(objs = fobj; objs; objs = objs->nobj)
102 at(objs->ox,objs->oy,objs->olet);
104 pline("You sense the presence of objects.");
110 pline("Yech! This stuff tastes like poison.");
111 if(Poison_resistance)
112 pline("(But in fact it was biologically contaminated orange juice.)");
114 losehp(rnd(10), "contaminated potion");
118 pline("Huh, What? Where am I?");
121 Confusion += rn1(7,16);
123 case POT_GAIN_STRENGTH:
124 pline("Wow do you feel strong!");
125 if(u.ustr >= 118) break; /* > 118 is impossible */
126 if(u.ustr > 17) u.ustr += rnd(118-u.ustr);
128 if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
137 if(!(Fast & ~INTRINSIC))
138 pline("You are suddenly moving much faster.");
140 pline("Your legs get new energy."), unkn++;
145 pline("A cloud of darkness falls upon you.");
148 Blind += rn1(100,250);
154 case POT_EXTRA_HEALING:
155 pline("You feel much better.");
159 u.uhp = (u.uhpmax += 2);
168 Levitation += rnd(100);
169 u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down;
172 impossible("What a funny potion! (%u)", otmp->otyp);
177 pline("You have a peculiar feeling for a moment, then it passes.");
179 if(otmp->dknown && !objects[otmp->otyp].oc_name_known) {
181 objects[otmp->otyp].oc_name_known = 1;
182 more_experienced(0,10);
183 } else if(!objects[otmp->otyp].oc_uname)
195 pline("You feel more experienced.");
200 extern long newuexp();
202 u.uexp = newuexp()+1;
203 pline("Welcome to experience level %u.", ++u.ulevel);
208 strange_feeling(obj,txt)
209 register struct obj *obj;
213 pline("You have a strange feeling for a moment, then it passes.");
216 if(!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)
221 char *bottlenames[] = {
222 "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial"
226 register struct monst *mon;
227 register struct obj *obj;
229 extern char *xname();
230 register char *botlnam = bottlenames[rn2(SIZE(bottlenames))];
231 boolean uclose, isyou = (mon == &youmonst);
235 pline("The %s crashes on your head and breaks into shivers.",
237 losehp(rnd(2), "thrown potion");
239 uclose = (dist(mon->mx,mon->my) < 3);
240 /* perhaps 'E' and 'a' have no head? */
241 pline("The %s crashes on %s's head and breaks into shivers.",
242 botlnam, monnam(mon));
243 if(rn2(5) && mon->mhp > 1)
246 pline("The %s evaporates.", xname(obj));
248 if(!isyou && !rn2(3)) switch(obj->otyp) {
250 case POT_RESTORE_STRENGTH:
251 case POT_GAIN_STRENGTH:
253 case POT_EXTRA_HEALING:
254 if(mon->mhp < mon->mhpmax) {
255 mon->mhp = mon->mhpmax;
256 pline("%s looks sound and hale again!", Monnam(mon));
269 case POT_INVISIBILITY:
281 mon->mblinded |= 64 + rn2(64);
286 case POT_FRUIT_JUICE:
287 case POT_MONSTER_DETECTION:
288 case POT_OBJECT_DETECTION:
294 obfree(obj, Null(obj));
298 register struct obj *obj;
301 case POT_RESTORE_STRENGTH:
302 case POT_GAIN_STRENGTH:
303 if(u.ustr < u.ustrmax) u.ustr++, flags.botl = 1;
306 case POT_EXTRA_HEALING:
307 if(u.uhp < u.uhpmax) u.uhp++, flags.botl = 1;
310 if(u.uhp <= 5) u.uhp = 1; else u.uhp -= 5;
316 pline("You feel somewhat dizzy.");
319 case POT_INVISIBILITY:
320 pline("For an instant you couldn't see your right hand.");
323 pline("Something seems to be holding you.");
328 pline("Your knees seem more flexible now.");
331 if(!Blind) pline("It suddenly gets dark.");
338 case POT_FRUIT_JUICE:
339 case POT_MONSTER_DETECTION:
340 case POT_OBJECT_DETECTION:
344 /* note: no obfree() */
348 * -- rudimentary -- to do this correctly requires much more work
349 * -- all sharp weapons get one or more qualities derived from the potions
350 * -- texts on scrolls may be (partially) wiped out; do they become blank?
351 * -- or does their effect change, like under Confusion?
352 * -- all objects may be made invisible by POT_INVISIBILITY
353 * -- If the flask is small, can one dip a large object? Does it magically
354 * -- become a jug? Etc.
357 register struct obj *potion, *obj;
359 if(!(obj = getobj("#", "dip")))
361 if(!(potion = getobj("!", "dip into")))
363 pline("Interesting...");
364 if(obj->otyp == ARROW || obj->otyp == DART ||
365 obj->otyp == CROSSBOW_BOLT) {
366 if(potion->otyp == POT_SICKNESS) {
368 if(obj->spe < 7) obj->spe++; /* %% */
375 extern struct permonst pm_ghost;
376 register struct monst *mtmp;
378 if(!(mtmp = makemon(PM_GHOST,u.ux,u.uy))){
379 pline("This bottle turns out to be empty.");
383 pline("As you open the bottle, an enormous ghost emerges!");
384 pline("You are frightened to death, and unable to move.");