comparison rogue4/potions.c @ 12:9535a08ddc39

Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
author edwarj4
date Sat, 24 Oct 2009 16:52:52 +0000
parents
children 1b73a8641b37
comparison
equal deleted inserted replaced
11:949d558c2162 12:9535a08ddc39
1 /*
2 * Function(s) for dealing with potions
3 *
4 * @(#)potions.c 4.24 (Berkeley) 4/6/82
5 *
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
8 * All rights reserved.
9 *
10 * See the file LICENSE.TXT for full copyright and licensing information.
11 */
12
13 #include <curses.h>
14 #include "rogue.h"
15
16 /*
17 * quaff:
18 * Quaff a potion from the pack
19 */
20 quaff()
21 {
22 register THING *obj, *th;
23 register bool discardit = FALSE;
24
25 obj = get_item("quaff", POTION);
26 /*
27 * Make certain that it is somethings that we want to drink
28 */
29 if (obj == NULL)
30 return;
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 p_know[P_CONFUSE] = TRUE;
49 if (!on(player, ISHUH))
50 {
51 if (on(player, ISHUH))
52 lengthen(unconfuse, rnd(8)+HUHDURATION);
53 else
54 fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
55 player.t_flags |= ISHUH;
56 msg("wait, what's going on here. Huh? What? Who?");
57 }
58 when P_POISON:
59 p_know[P_POISON] = TRUE;
60 if (!ISWEARING(R_SUSTSTR))
61 {
62 chg_str(-(rnd(3)+1));
63 msg("you feel very sick now");
64 }
65 else
66 msg("you feel momentarily sick");
67 when P_HEALING:
68 p_know[P_HEALING] = TRUE;
69 if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
70 pstats.s_hpt = ++max_hp;
71 sight();
72 msg("you begin to feel better");
73 when P_STRENGTH:
74 p_know[P_STRENGTH] = TRUE;
75 chg_str(1);
76 msg("you feel stronger, now. What bulging muscles!");
77 when P_MFIND:
78 player.t_flags |= SEEMONST;
79 fuse(turn_see, TRUE, HUHDURATION, AFTER);
80 if (mlist == NULL)
81 msg("you have a strange feeling for a moment");
82 else
83 p_know[P_MFIND] |= turn_see(FALSE);
84 when P_TFIND:
85 /*
86 * Potion of magic detection. Show the potions and scrolls
87 */
88 if (lvl_obj != NULL)
89 {
90 register THING *tp;
91 register bool show;
92
93 show = FALSE;
94 wclear(hw);
95 for (tp = lvl_obj; tp != NULL; tp = next(tp))
96 {
97 if (is_magic(tp))
98 {
99 show = TRUE;
100 mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
101 p_know[P_TFIND] = TRUE;
102 }
103 }
104 for (th = mlist; th != NULL; th = next(th))
105 {
106 for (tp = th->t_pack; tp != NULL; tp = next(tp))
107 {
108 if (is_magic(tp))
109 {
110 show = TRUE;
111 mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
112 p_know[P_TFIND] = TRUE;
113 }
114 }
115 }
116 if (show)
117 {
118 show_win(hw,
119 "You sense the presence of magic on this level.--More--");
120 break;
121 }
122 }
123 msg("you have a strange feeling for a moment, then it passes");
124 when P_PARALYZE:
125 p_know[P_PARALYZE] = TRUE;
126 no_command = HOLDTIME;
127 player.t_flags &= ~ISRUN;
128 msg("you can't move");
129 when P_SEEINVIS:
130 if (!on(player, CANSEE))
131 {
132 fuse(unsee, 0, SEEDURATION, AFTER);
133 look(FALSE);
134 invis_on();
135 }
136 sight();
137 msg("this potion tastes like %s juice", fruit);
138 when P_RAISE:
139 p_know[P_RAISE] = TRUE;
140 msg("you suddenly feel much more skillful");
141 raise_level();
142 when P_XHEAL:
143 p_know[P_XHEAL] = TRUE;
144 if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
145 {
146 if (pstats.s_hpt > max_hp + pstats.s_lvl + 1)
147 ++max_hp;
148 pstats.s_hpt = ++max_hp;
149 }
150 sight();
151 msg("you begin to feel much better");
152 when P_HASTE:
153 p_know[P_HASTE] = TRUE;
154 if (add_haste(TRUE))
155 msg("you feel yourself moving much faster");
156 when P_RESTORE:
157 if (ISRING(LEFT, R_ADDSTR))
158 add_str(&pstats.s_str, -cur_ring[LEFT]->o_ac);
159 if (ISRING(RIGHT, R_ADDSTR))
160 add_str(&pstats.s_str, -cur_ring[RIGHT]->o_ac);
161 if (pstats.s_str < max_stats.s_str)
162 pstats.s_str = max_stats.s_str;
163 if (ISRING(LEFT, R_ADDSTR))
164 add_str(&pstats.s_str, cur_ring[LEFT]->o_ac);
165 if (ISRING(RIGHT, R_ADDSTR))
166 add_str(&pstats.s_str, cur_ring[RIGHT]->o_ac);
167 msg("hey, this tastes great. It make you feel warm all over");
168 when P_BLIND:
169 p_know[P_BLIND] = TRUE;
170 if (!on(player, ISBLIND))
171 {
172 player.t_flags |= ISBLIND;
173 fuse(sight, 0, SEEDURATION, AFTER);
174 look(FALSE);
175 }
176 msg("a cloak of darkness falls around you");
177 when P_NOP:
178 msg("this potion tastes extremely dull");
179 otherwise:
180 msg("what an odd tasting potion!");
181 return;
182 }
183 status();
184 /*
185 * Throw the item away
186 */
187 inpack--;
188 if (obj->o_count > 1)
189 obj->o_count--;
190 else
191 {
192 detach(pack, obj);
193 discardit = TRUE;
194 }
195
196 call_it(p_know[obj->o_which], &p_guess[obj->o_which]);
197
198 if (discardit)
199 discard(obj);
200 }
201
202 /*
203 * invis_on:
204 * Turn on the ability to see invisible
205 */
206 invis_on()
207 {
208 register THING *th;
209
210 player.t_flags |= CANSEE;
211 for (th = mlist; th != NULL; th = next(th))
212 if (on(*th, ISINVIS) && see_monst(th))
213 {
214 move(th->t_pos.y, th->t_pos.x);
215 addch(th->t_disguise);
216 }
217 }
218
219 /*
220 * see_monst:
221 * Put on or off seeing monsters on this level
222 */
223 turn_see(turn_off)
224 register bool turn_off;
225 {
226 register THING *mp;
227 register bool can_see, add_new;
228
229 add_new = FALSE;
230 for (mp = mlist; mp != NULL; mp = next(mp))
231 {
232 move(mp->t_pos.y, mp->t_pos.x);
233 can_see = (see_monst(mp) || inch() == (unsigned char)mp->t_type);
234 if (turn_off)
235 {
236 if (!can_see)
237 addch(mp->t_oldch);
238 }
239 else
240 {
241 if (!can_see)
242 standout();
243 addch(mp->t_type);
244 if (!can_see)
245 {
246 standend();
247 add_new++;
248 }
249 }
250 }
251 if (turn_off)
252 player.t_flags &= ~SEEMONST;
253 else
254 player.t_flags |= SEEMONST;
255 return add_new;
256 }