Tweak liking thresholds. Required interest rate is higher to discourage flirt grinding.
[rogue-pphs.git] / potions.c
1 /*
2 * @(#)potions.c 3.1 3.1 5/7/81
3 * Function(s) for dealing with potions
4 *
5 * Rogue: Exploring the Cavern of Cuties
6 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
7 * All rights reserved.
8 *
9 * See the file LICENSE.TXT for full copyright and licensing information.
10 */
11
12 #include "curses.h"
13 #include <stdlib.h>
14 #include <string.h>
15 #include "rogue.h"
16
17 quaff()
18 {
19 register struct object *obj;
20 register struct linked_list *item, *titem;
21 register struct thing *th;
22 char buf[80];
23
24 item = get_item("quaff", POTION);
25 /*
26 * Make certain that it is somethings that we want to drink
27 */
28 if (item == NULL)
29 return;
30 obj = (struct object *) ldata(item);
31 if (obj->o_type != POTION)
32 {
33 if (!terse)
34 msg("Yuk! Why would you want to drink that?");
35 else
36 msg("That's undrinkable");
37 return;
38 }
39 if (obj == cur_weapon)
40 cur_weapon = NULL;
41
42 /*
43 * Calculate the effect it has on the poor guy.
44 */
45 switch(obj->o_which)
46 {
47 case P_CONFUSE:
48 if (off(player, ISHUH))
49 msg("Wait, what's going on here. Huh? What? Who?");
50
51 if (on(player, ISHUH))
52 lengthen(unconfuse, rnd(8)+HUHDURATION);
53 else
54 fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
55
56 player.t_flags |= ISHUH;
57 p_know[P_CONFUSE] = TRUE;
58 when P_POISON:
59 if (!ISWEARING(R_SUSTSTR))
60 {
61 chg_str(-(rnd(3)+1));
62 msg("You feel very sick now.");
63 }
64 else
65 msg("You feel momentarily sick");
66 p_know[P_POISON] = TRUE;
67 when P_HEALING:
68 if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
69 pstats.s_hpt = ++max_hp;
70 msg("You begin to feel better.");
71 sight();
72 p_know[P_HEALING] = TRUE;
73 when P_STRENGTH:
74 msg("You feel stronger, now. What bulging muscles!");
75 chg_str(1);
76 p_know[P_STRENGTH] = TRUE;
77 when P_MFIND:
78 /*
79 * Potion of monster detection, if there are monters, detect them
80 */
81 if (mlist != NULL)
82 {
83 wclear(hw);
84 overwrite(mw, hw);
85 show_win(hw,
86 "You begin to sense the presence of monsters.--More--");
87 p_know[P_MFIND] = TRUE;
88 }
89 else
90 msg("You have a strange feeling for a moment, then it passes.");
91 when P_TFIND:
92 /*
93 * Potion of magic detection. Show the potions and scrolls
94 */
95 if (lvl_obj != NULL)
96 {
97 struct linked_list *mobj;
98 struct object *tp;
99 bool show;
100
101 show = FALSE;
102 wclear(hw);
103 for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj))
104 {
105 tp = (struct object *) ldata(mobj);
106 if (is_magic(tp))
107 {
108 show = TRUE;
109 mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
110 }
111 p_know[P_TFIND] = TRUE;
112 }
113 for (titem = mlist; titem != NULL; titem = next(titem))
114 {
115 register struct linked_list *pitem;
116
117 th = (struct thing *) ldata(titem);
118 for (pitem = th->t_pack; pitem != NULL; pitem = next(pitem))
119 {
120 if (is_magic(ldata(pitem)))
121 {
122 show = TRUE;
123 mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
124 }
125 p_know[P_TFIND] = TRUE;
126 }
127 }
128 if (show)
129 {
130 show_win(hw,
131 "You sense the presence of magic on this level.--More--");
132 break;
133 }
134 }
135 msg("You have a strange feeling for a moment, then it passes.");
136 when P_PARALYZE:
137 msg("You can't move.");
138 no_command = HOLDTIME;
139 p_know[P_PARALYZE] = TRUE;
140 when P_SEEINVIS:
141 msg("This potion tastes like %s juice.", fruit);
142 if (off(player, CANSEE))
143 {
144 player.t_flags |= CANSEE;
145 fuse(unsee, 0, SEEDURATION, AFTER);
146 light(&hero);
147 }
148 sight();
149 when P_RAISE:
150 msg("You suddenly feel much more skillful");
151 p_know[P_RAISE] = TRUE;
152 raise_level();
153 when P_XHEAL:
154 if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
155 pstats.s_hpt = ++max_hp;
156 msg("You begin to feel much better.");
157 p_know[P_XHEAL] = TRUE;
158 sight();
159 when P_HASTE:
160 add_haste(TRUE);
161 msg("You feel yourself moving much faster.");
162 p_know[P_HASTE] = TRUE;
163 when P_RESTORE:
164 msg("Hey, this tastes great. It make you feel warm all over.");
165 if (pstats.s_str.st_str < max_stats.s_str.st_str ||
166 (pstats.s_str.st_str == 18 &&
167 pstats.s_str.st_add < max_stats.s_str.st_add))
168 pstats.s_str = max_stats.s_str;
169 when P_BLIND:
170 msg("A cloak of darkness falls around you.");
171 if (off(player, ISBLIND))
172 {
173 player.t_flags |= ISBLIND;
174 fuse(sight, 0, SEEDURATION, AFTER);
175 look(FALSE);
176 }
177 p_know[P_BLIND] = TRUE;
178 when P_NOP:
179 msg("This potion tastes extremely dull.");
180 otherwise:
181 msg("What an odd tasting potion!");
182 return;
183 }
184 status();
185 if (p_know[obj->o_which] && p_guess[obj->o_which])
186 {
187 free(p_guess[obj->o_which]);
188 p_guess[obj->o_which] = NULL;
189 }
190 else if (!p_know[obj->o_which] && askme && p_guess[obj->o_which] == NULL)
191 {
192 msg(terse ? "Call it: " : "What do you want to call it? ");
193 if (get_str(buf, cw) == NORM)
194 {
195 p_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1);
196 if (p_guess[obj->o_which] != NULL)
197 strcpy(p_guess[obj->o_which], buf);
198 }
199 }
200 /*
201 * Throw the item away
202 */
203 inpack--;
204 if (obj->o_count > 1)
205 obj->o_count--;
206 else
207 {
208 detach(pack, item);
209 discard(item);
210 }
211 }