]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.potion.c
1 /* $NetBSD: hack.potion.c,v 1.5 2001/03/25 20:44:02 jsm Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.potion.c,v 1.5 2001/03/25 20:44:02 jsm Exp $");
18 struct obj
*otmp
, *objs
;
20 int unkn
= 0, nothing
= 0;
22 otmp
= getobj("!", "drink");
25 if (!strcmp(objects
[otmp
->otyp
].oc_descr
, "smoky") && !rn2(13)) {
30 case POT_RESTORE_STRENGTH
:
32 pline("Wow! This makes you feel great!");
33 if (u
.ustr
< u
.ustrmax
) {
40 pline("Ooph! This tastes like liquid fire!");
42 /* the whiskey makes us feel better */
44 losehp(-1, "bottle of whiskey");
46 pline("You pass out.");
48 nomovemsg
= "You awake with a headache.";
51 case POT_INVISIBILITY
:
52 if (Invis
|| See_invisible
)
56 pline("Gee! All of a sudden, you can't see yourself.");
58 pline("You feel rather airy."), unkn
++;
64 pline("This tastes like fruit juice.");
68 pline("You begin to feel better.");
74 Blind
= 1; /* see on next move */
80 pline("You are motionlessly suspended.");
82 pline("Your feet are frozen to the floor!");
83 nomul(-(rn1(10, 25)));
85 case POT_MONSTER_DETECTION
:
87 strange_feeling(otmp
, "You feel threatened.");
91 for (mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
)
93 at(mtmp
->mx
, mtmp
->my
, mtmp
->data
->mlet
);
95 pline("You sense the presence of monsters.");
100 case POT_OBJECT_DETECTION
:
102 strange_feeling(otmp
, "You feel a pull downward.");
105 for (objs
= fobj
; objs
; objs
= objs
->nobj
)
106 if (objs
->ox
!= u
.ux
|| objs
->oy
!= u
.uy
)
108 pline("You sense the presence of objects close nearby.");
112 for (objs
= fobj
; objs
; objs
= objs
->nobj
)
113 at(objs
->ox
, objs
->oy
, objs
->olet
);
115 pline("You sense the presence of objects.");
121 pline("Yech! This stuff tastes like poison.");
122 if (Poison_resistance
)
123 pline("(But in fact it was biologically contaminated orange juice.)");
125 losehp(rnd(10), "contaminated potion");
129 pline("Huh, What? Where am I?");
132 Confusion
+= rn1(7, 16);
134 case POT_GAIN_STRENGTH
:
135 pline("Wow do you feel strong!");
137 break; /* > 118 is impossible */
139 u
.ustr
+= rnd(118 - u
.ustr
);
142 if (u
.ustr
> u
.ustrmax
)
152 if (!(Fast
& ~INTRINSIC
))
153 pline("You are suddenly moving much faster.");
155 pline("Your legs get new energy."), unkn
++;
156 Fast
+= rn1(10, 100);
160 pline("A cloud of darkness falls upon you.");
163 Blind
+= rn1(100, 250);
169 case POT_EXTRA_HEALING
:
170 pline("You feel much better.");
172 u
.uhp
+= d(2, 20) + 1;
173 if (u
.uhp
> u
.uhpmax
)
174 u
.uhp
= (u
.uhpmax
+= 2);
185 Levitation
+= rnd(100);
186 u
.uprops
[PROP(RIN_LEVITATION
)].p_tofn
= float_down
;
189 impossible("What a funny potion! (%u)", otmp
->otyp
);
194 pline("You have a peculiar feeling for a moment, then it passes.");
196 if (otmp
->dknown
&& !objects
[otmp
->otyp
].oc_name_known
) {
198 objects
[otmp
->otyp
].oc_name_known
= 1;
199 more_experienced(0, 10);
200 } else if (!objects
[otmp
->otyp
].oc_uname
)
213 pline("You feel more experienced.");
218 u
.uexp
= newuexp() + 1;
219 pline("Welcome to experience level %u.", ++u
.ulevel
);
225 strange_feeling(obj
, txt
)
230 pline("You have a strange feeling for a moment, then it passes.");
233 if (!objects
[obj
->otyp
].oc_name_known
&& !objects
[obj
->otyp
].oc_uname
)
238 const char *const bottlenames
[] = {
239 "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial"
247 const char *botlnam
= bottlenames
[rn2(SIZE(bottlenames
))];
248 boolean uclose
, isyou
= (mon
== &youmonst
);
252 pline("The %s crashes on your head and breaks into shivers.",
254 losehp(rnd(2), "thrown potion");
256 uclose
= (dist(mon
->mx
, mon
->my
) < 3);
257 /* perhaps 'E' and 'a' have no head? */
258 pline("The %s crashes on %s's head and breaks into shivers.",
259 botlnam
, monnam(mon
));
260 if (rn2(5) && mon
->mhp
> 1)
263 pline("The %s evaporates.", xname(obj
));
265 if (!isyou
&& !rn2(3))
268 case POT_RESTORE_STRENGTH
:
269 case POT_GAIN_STRENGTH
:
271 case POT_EXTRA_HEALING
:
272 if (mon
->mhp
< mon
->mhpmax
) {
273 mon
->mhp
= mon
->mhpmax
;
274 pline("%s looks sound and hale again!", Monnam(mon
));
287 case POT_INVISIBILITY
:
299 mon
->mblinded
|= 64 + rn2(64);
302 * case POT_GAIN_LEVEL: case POT_LEVITATION: case
303 * POT_FRUIT_JUICE: case POT_MONSTER_DETECTION: case
304 * POT_OBJECT_DETECTION: break;
307 if (uclose
&& rn2(5))
309 obfree(obj
, Null(obj
));
317 case POT_RESTORE_STRENGTH
:
318 case POT_GAIN_STRENGTH
:
319 if (u
.ustr
< u
.ustrmax
)
320 u
.ustr
++, flags
.botl
= 1;
323 case POT_EXTRA_HEALING
:
324 if (u
.uhp
< u
.uhpmax
)
325 u
.uhp
++, flags
.botl
= 1;
337 pline("You feel somewhat dizzy.");
340 case POT_INVISIBILITY
:
341 pline("For an instant you couldn't see your right hand.");
344 pline("Something seems to be holding you.");
349 pline("Your knees seem more flexible now.");
353 pline("It suddenly gets dark.");
358 * case POT_GAIN_LEVEL: case POT_LEVITATION: case
359 * POT_FRUIT_JUICE: case POT_MONSTER_DETECTION: case
360 * POT_OBJECT_DETECTION: break;
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
) {
401 if (!(mtmp
= makemon(PM_GHOST
, u
.ux
, u
.uy
))) {
402 pline("This bottle turns out to be empty.");
406 pline("As you open the bottle, an enormous ghost emerges!");
407 pline("You are frightened to death, and unable to move.");