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.4 2006/08/21 19:45:32 pavalos Exp $ */
7 extern struct monst youmonst
;
9 static void ghost_from_bottle(void);
14 struct obj
*otmp
, *objs
;
16 int unkn
= 0, nothing
= 0;
18 otmp
= getobj("!", "drink");
21 if (!strcmp(objects
[otmp
->otyp
].oc_descr
, "smoky") && !rn2(13)) {
26 case POT_RESTORE_STRENGTH
:
28 pline("Wow! This makes you feel great!");
29 if (u
.ustr
< u
.ustrmax
) {
36 pline("Ooph! This tastes like liquid fire!");
38 /* the whiskey makes us feel better */
40 losehp(-1, "bottle of whiskey");
42 pline("You pass out.");
44 nomovemsg
= "You awake with a headache.";
47 case POT_INVISIBILITY
:
48 if (Invis
|| See_invisible
)
52 pline("Gee! All of a sudden, you can't see yourself.");
54 pline("You feel rather airy."), unkn
++;
60 pline("This tastes like fruit juice.");
64 pline("You begin to feel better.");
69 if (Blind
) /* see on next move */
76 pline("You are motionlessly suspended.");
78 pline("Your feet are frozen to the floor!");
79 nomul(-(rn1(10, 25)));
81 case POT_MONSTER_DETECTION
:
83 strange_feeling(otmp
, "You feel threatened.");
87 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
89 at(mtmp
->mx
, mtmp
->my
, mtmp
->data
->mlet
);
91 pline("You sense the presence of monsters.");
96 case POT_OBJECT_DETECTION
:
98 strange_feeling(otmp
, "You feel a pull downward.");
101 for (objs
= fobj
; objs
; objs
= objs
->nobj
)
102 if (objs
->ox
!= u
.ux
|| objs
->oy
!= u
.uy
)
104 pline("You sense the presence of objects close nearby.");
108 for (objs
= fobj
; objs
; objs
= objs
->nobj
)
109 at(objs
->ox
, objs
->oy
, objs
->olet
);
111 pline("You sense the presence of objects.");
117 pline("Yech! This stuff tastes like poison.");
118 if (Poison_resistance
)
119 pline("(But in fact it was biologically contaminated orange juice.)");
121 losehp(rnd(10), "contaminated potion");
125 pline("Huh, What? Where am I?");
128 Confusion
+= rn1(7, 16);
130 case POT_GAIN_STRENGTH
:
131 pline("Wow do you feel strong!");
132 if (u
.ustr
>= 118) /* > 118 is impossible */
135 u
.ustr
+= rnd(118 - u
.ustr
);
138 if (u
.ustr
> u
.ustrmax
)
148 if (!(Fast
& ~INTRINSIC
))
149 pline("You are suddenly moving much faster.");
151 pline("Your legs get new energy."), unkn
++;
152 Fast
+= rn1(10, 100);
156 pline("A cloud of darkness falls upon you.");
159 Blind
+= rn1(100, 250);
165 case POT_EXTRA_HEALING
:
166 pline("You feel much better.");
168 u
.uhp
+= d(2, 20) + 1;
169 if (u
.uhp
> u
.uhpmax
)
170 u
.uhp
= (u
.uhpmax
+= 2);
181 Levitation
+= rnd(100);
182 u
.uprops
[PROP(RIN_LEVITATION
)].p_tofn
= float_down
;
185 impossible("What a funny potion! (%u)", otmp
->otyp
);
190 pline("You have a peculiar feeling for a moment, then it passes.");
192 if (otmp
->dknown
&& !objects
[otmp
->otyp
].oc_name_known
) {
194 objects
[otmp
->otyp
].oc_name_known
= 1;
195 more_experienced(0, 10);
196 } else if (!objects
[otmp
->otyp
].oc_uname
)
209 pline("You feel more experienced.");
214 u
.uexp
= newuexp() + 1;
215 pline("Welcome to experience level %u.", ++u
.ulevel
);
221 strange_feeling(struct obj
*obj
, const char *txt
)
224 pline("You have a strange feeling for a moment, then it passes.");
227 if (!objects
[obj
->otyp
].oc_name_known
&& !objects
[obj
->otyp
].oc_uname
)
232 static const char *bottlenames
[] = {
233 "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial"
237 potionhit(struct monst
*mon
, struct obj
*obj
)
239 const char *botlnam
= bottlenames
[rn2(SIZE(bottlenames
))];
240 boolean uclose
, isyou
= (mon
== &youmonst
);
244 pline("The %s crashes on your head and breaks into shivers.",
246 losehp(rnd(2), "thrown potion");
248 uclose
= (dist(mon
->mx
, mon
->my
) < 3);
249 /* perhaps 'E' and 'a' have no head? */
250 pline("The %s crashes on %s's head and breaks into shivers.",
251 botlnam
, monnam(mon
));
252 if (rn2(5) && mon
->mhp
> 1)
255 pline("The %s evaporates.", xname(obj
));
257 if (!isyou
&& !rn2(3))
259 case POT_RESTORE_STRENGTH
:
260 case POT_GAIN_STRENGTH
:
262 case POT_EXTRA_HEALING
:
263 if (mon
->mhp
< mon
->mhpmax
) {
264 mon
->mhp
= mon
->mhpmax
;
265 pline("%s looks sound and hale again!", Monnam(mon
));
278 case POT_INVISIBILITY
:
290 mon
->mblinded
|= 64 + rn2(64);
293 * case POT_GAIN_LEVEL:
294 * case POT_LEVITATION:
295 * case POT_FRUIT_JUICE:
296 * case POT_MONSTER_DETECTION:
297 * case POT_OBJECT_DETECTION:
301 if (uclose
&& rn2(5))
307 potionbreathe(struct obj
*obj
)
310 case POT_RESTORE_STRENGTH
:
311 case POT_GAIN_STRENGTH
:
312 if (u
.ustr
< u
.ustrmax
) {
318 case POT_EXTRA_HEALING
:
319 if (u
.uhp
< u
.uhpmax
) {
334 pline("You feel somewhat dizzy.");
337 case POT_INVISIBILITY
:
338 pline("For an instant you couldn't see your right hand.");
341 pline("Something seems to be holding you.");
346 pline("Your knees seem more flexible now.");
350 pline("It suddenly gets dark.");
355 * case POT_GAIN_LEVEL:
356 * case POT_LEVITATION:
357 * case POT_FRUIT_JUICE:
358 * case POT_MONSTER_DETECTION:
359 * case POT_OBJECT_DETECTION:
363 /* note: no obfree() */
367 * -- rudimentary -- to do this correctly requires much more work
368 * -- all sharp weapons get one or more qualities derived from the potions
369 * -- texts on scrolls may be (partially) wiped out; do they become blank?
370 * -- or does their effect change, like under Confusion?
371 * -- all objects may be made invisible by POT_INVISIBILITY
372 * -- If the flask is small, can one dip a large object? Does it magically
373 * -- become a jug? Etc.
378 struct obj
*potion
, *obj
;
380 if (!(obj
= getobj("#", "dip")))
382 if (!(potion
= getobj("!", "dip into")))
384 pline("Interesting...");
385 if (obj
->otyp
== ARROW
|| obj
->otyp
== DART
||
386 obj
->otyp
== CROSSBOW_BOLT
)
387 if (potion
->otyp
== POT_SICKNESS
) {
389 if (obj
->spe
< 7) /* %% */
396 ghost_from_bottle(void)
400 if (!(mtmp
= makemon(PM_GHOST
, u
.ux
, u
.uy
))) {
401 pline("This bottle turns out to be empty.");
405 pline("As you open the bottle, an enormous ghost emerges!");
406 pline("You are frightened to death, and unable to move.");