comparison srogue/potions.c @ 36:2128c7dc8a40

Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
author elwin
date Thu, 25 Nov 2010 12:21:41 +0000
parents
children 3aa87373c908
comparison
equal deleted inserted replaced
35:05018c63a721 36:2128c7dc8a40
1 /*
2 * Functions for dealing with potions
3 *
4 * @(#)potions.c 9.0 (rdk) 7/17/84
5 *
6 * Super-Rogue
7 * Copyright (C) 1984 Robert D. Kindelberger
8 * All rights reserved.
9 *
10 * Based on "Rogue: Exploring the Dungeons of Doom"
11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
12 * All rights reserved.
13 *
14 * See the file LICENSE.TXT for full copyright and licensing information.
15 */
16
17 #include "rogue.h"
18 #include "rogue.ext"
19
20 /*
21 * quaff:
22 * Let the hero drink a potion
23 */
24 quaff()
25 {
26 reg struct object *obj;
27 reg struct linked_list *item, *titem;
28 reg struct thing *th;
29 reg int wh;
30 char buf[LINLEN];
31 bool bless, curse;
32
33 /*
34 * Make certain that it is somethings that we want to drink
35 */
36 if ((item = get_item("quaff", POTION)) == NULL)
37 return;
38 obj = OBJPTR(item);
39 if (obj->o_type != POTION) {
40 msg("That's undrinkable!");
41 after = FALSE;
42 return;
43 }
44 wh = obj->o_which;
45 bless = o_on(obj, ISBLESS);
46 curse = o_on(obj, ISCURSED);
47 del_pack(item); /* get rid of it */
48
49 /*
50 * Calculate the effect it has on the poor guy.
51 */
52 switch(wh) {
53 case P_CONFUSE:
54 if (!bless) {
55 if (pl_on(ISINVINC))
56 msg("You remain level-headed.");
57 else {
58 chg_abil(WIS,-1,TRUE); /* confuse his mind */
59 if (pl_off(ISHUH)) {
60 msg("Wait, what's going on here. Huh? What? Who?");
61 if (pl_on(ISHUH))
62 lengthen(unconfuse,rnd(8)+HUHDURATION);
63 else
64 fuse(unconfuse,TRUE,rnd(8)+HUHDURATION);
65 player.t_flags |= ISHUH;
66 }
67 }
68 p_know[P_CONFUSE] = TRUE;
69 }
70 when P_POISON:
71 if (!bless) {
72 if (pl_off(ISINVINC) && !iswearing(R_SUSTSTR) &&
73 !iswearing(R_SUSAB)) {
74 chg_abil(CON,-1,TRUE);
75 chg_abil(STR,-(rnd(3)+1),TRUE);
76 msg("You feel very sick now.");
77 }
78 else
79 msg("You feel momentarily sick.");
80 p_know[P_POISON] = TRUE;
81 }
82 when P_HEALING:
83 if (!curse) {
84 heal_self(4, TRUE);
85 msg("You begin to feel better.");
86 if (!iswearing(R_SLOW))
87 notslow(FALSE);
88 sight(FALSE);
89 p_know[P_HEALING] = TRUE;
90 }
91 when P_STRENGTH:
92 if (!curse) {
93 msg("You feel stronger, now. What bulging muscles!");
94 chg_abil(STR,1,TRUE);
95 p_know[P_STRENGTH] = TRUE;
96 }
97 when P_MFIND:
98 /*
99 * Potion of monster detection - find all monsters
100 */
101 if (mlist != NULL && !curse) {
102 dispmons();
103 mpos = 0;
104 msg("You begin to sense the presence of monsters--More--");
105 p_know[P_MFIND] = TRUE;
106 wait_for(cw,' ');
107 msg(""); /* clear line */
108 }
109 else
110 msg("You have a strange feeling for a moment, then it passes.");
111 when P_TFIND:
112 /*
113 * Potion of magic detection. Show the potions and scrolls
114 */
115 if (lvl_obj != NULL && !curse) {
116 struct linked_list *mobj;
117 struct object *tp;
118 bool show;
119
120 show = FALSE;
121 wclear(hw);
122 for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj)) {
123 tp = OBJPTR(mobj);
124 if (is_magic(tp)) {
125 show = TRUE;
126 mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
127 }
128 }
129 for(titem = mlist; titem != NULL; titem = next(titem)) {
130 reg struct linked_list *pitem;
131
132 th = THINGPTR(titem);
133 for(pitem=th->t_pack;pitem!=NULL;pitem=next(pitem)) {
134 if (is_magic(ldata(pitem))) {
135 show = TRUE;
136 mvwaddch(hw,th->t_pos.y, th->t_pos.x, MAGIC);
137 }
138 }
139 }
140 if (show) {
141 msg("You begin to sense the presence of magic.");
142 overlay(hw,cw);
143 p_know[P_TFIND] = TRUE;
144 break;
145 }
146 }
147 msg("You have a strange feeling for a moment, then it passes.");
148 when P_PARALYZE:
149 if (!bless) {
150 if (pl_on(ISINVINC))
151 msg("You feel numb for a moment.");
152 else {
153 msg("You can't move.");
154 player.t_nocmd = HOLDTIME;
155 }
156 p_know[P_PARALYZE] = TRUE;
157 }
158 when P_SEEINVIS:
159 if (!curse) {
160 int invlen = roll(40,20);
161
162 msg("This potion tastes like %s juice.", fruit);
163 if (pl_off(CANSEE)) {
164 player.t_flags |= CANSEE;
165 fuse(unsee, TRUE, invlen);
166 light(&hero);
167 }
168 else
169 lengthen(unsee, invlen);
170 sight(FALSE);
171 }
172 when P_RAISE:
173 if (!curse) {
174 msg("You suddenly feel much more skillful.");
175 p_know[P_RAISE] = TRUE;
176 chg_abil(DEX,1,TRUE);
177 chg_abil(WIS,1,TRUE);
178 chg_abil(CON,1,TRUE);
179 raise_level();
180 }
181 when P_XHEAL:
182 if (!curse) {
183 heal_self(8, TRUE);
184 if (rnd(100) < 50)
185 chg_abil(CON,1,TRUE);
186 msg("You begin to feel much better.");
187 p_know[P_XHEAL] = TRUE;
188 if (!iswearing(R_SLOW))
189 notslow(FALSE);
190 unconfuse();
191 extinguish(unconfuse);
192 sight(FALSE);
193 }
194 when P_HASTE:
195 if (!curse) {
196 add_haste(TRUE);
197 msg("You feel yourself moving much faster.");
198 p_know[P_HASTE] = TRUE;
199 }
200 when P_INVINC:
201 if (!curse) {
202 int time = rnd(400) + 350;
203
204 msg("You feel invincible.");
205 if (player.t_flags & ISINVINC)
206 lengthen(notinvinc,time);
207 else
208 fuse(notinvinc,TRUE,time);
209 player.t_flags |= ISINVINC;
210 p_know[P_INVINC] = TRUE;
211 }
212 when P_SMART:
213 if (!curse) {
214 msg("You feel more perceptive.");
215 p_know[P_SMART] = TRUE;
216 chg_abil(WIS,1,TRUE);
217 }
218 when P_RESTORE:
219 if (!curse) {
220 msg("Hey, this tastes great. You feel warm all over.");
221 him->s_re = max_stats.s_re;
222 him->s_ef = max_stats.s_re;
223 ringabil(); /* add in rings */
224 updpack(); /* update weight */
225 p_know[P_RESTORE] = TRUE;
226 extinguish(rchg_str); /* kill restore in from ulodyte */
227 }
228 when P_BLIND:
229 if (!bless) {
230 if (pl_on(ISINVINC))
231 msg("The light dims for a moment.");
232 else {
233 chg_abil(WIS,-1,TRUE);
234 msg("A cloak of darkness falls around you.");
235 if (pl_off(ISBLIND)) {
236 player.t_flags |= ISBLIND;
237 fuse(sight, TRUE, rnd(400) + 450);
238 light(&hero);
239 }
240 }
241 p_know[P_BLIND] = TRUE;
242 }
243 when P_ETH:
244 if (!curse) {
245 int ethlen = roll(40,20);
246
247 msg("You feel more vaporous.");
248 if (pl_on(ISETHER))
249 lengthen(noteth,ethlen);
250 else
251 fuse(noteth,TRUE,ethlen);
252 player.t_flags |= ISETHER;
253 p_know[P_ETH] = TRUE;
254 }
255 when P_NOP:
256 msg("This potion tastes extremely dull.");
257 when P_DEX:
258 if (!curse) {
259 chg_abil(DEX,1,TRUE); /* increase dexterity */
260 p_know[P_DEX] = TRUE;
261 msg("You feel much more agile.");
262 }
263 when P_REGEN:
264 if (!curse) {
265 int reglen = rnd(450) + 450;
266
267 if (pl_on(ISREGEN))
268 lengthen(notregen, reglen);
269 else
270 fuse(notregen, TRUE, reglen);
271 player.t_flags |= ISREGEN;
272 msg("You feel yourself improved.");
273 p_know[P_REGEN] = TRUE;
274 }
275 when P_DECREP:
276 case P_SUPHERO: {
277 int howmuch = rnd(3) + 1;
278
279 if (wh == P_DECREP) {
280 if (!bless) {
281 if (iswearing(R_SUSAB) || pl_on(ISINVINC)) {
282 msg("You feel momentarily woozy.");
283 howmuch = 0;
284 }
285 else {
286 msg("You feel crippled.");
287 howmuch = -howmuch;
288 if (!iswearing(R_SUSTSTR))
289 chg_abil(STR,howmuch,TRUE);
290 }
291 }
292 else
293 howmuch = 0;
294 }
295 else { /* potion of superhero */
296 if (curse)
297 howmuch = 0;
298 msg("You feel invigorated.");
299 chg_abil(STR,howmuch,TRUE);
300 }
301 chg_abil(CON,howmuch,TRUE);
302 chg_abil(DEX,howmuch,TRUE);
303 chg_abil(WIS,howmuch,TRUE); /* change abilities */
304 p_know[wh] = TRUE;
305 }
306 otherwise:
307 msg("What an odd tasting potion!");
308 return;
309 }
310 nochange = FALSE;
311 if (p_know[wh] && p_guess[wh]) {
312 free(p_guess[wh]);
313 p_guess[wh] = NULL;
314 }
315 else if(!p_know[wh] && p_guess[wh] == NULL) {
316 strcpy(buf, p_colors[wh]);
317 msg(callit);
318 if (get_str(buf, cw) == NORM) {
319 p_guess[wh] = new(strlen(buf) + 1);
320 strcpy(p_guess[wh], buf);
321 }
322 }
323 }