Mercurial > hg > early-roguelike
comparison arogue7/potions.c @ 125:adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
author | John "Elwin" Edwards |
---|---|
date | Fri, 08 May 2015 15:24:40 -0400 |
parents | |
children | b786053d2f37 |
comparison
equal
deleted
inserted
replaced
124:d10fc4a065ac | 125:adfa37e67084 |
---|---|
1 /* | |
2 * potions.c - Function(s) for dealing with potions | |
3 * | |
4 * Advanced Rogue | |
5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T | |
6 * All rights reserved. | |
7 * | |
8 * Based on "Rogue: Exploring the Dungeons of Doom" | |
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
10 * All rights reserved. | |
11 * | |
12 * See the file LICENSE.TXT for full copyright and licensing information. | |
13 */ | |
14 | |
15 /* | |
16 * Function(s) for dealing with potions | |
17 */ | |
18 | |
19 #include "curses.h" | |
20 #include "rogue.h" | |
21 | |
22 | |
23 /* | |
24 * add_abil is an array of functions used to change attributes. It must be | |
25 * ordered according to the attribute definitions in rogue.h. | |
26 */ | |
27 | |
28 void (*add_abil[NUMABILITIES])() = { | |
29 add_intelligence, add_strength, add_wisdom, add_dexterity, | |
30 add_constitution, add_charisma | |
31 }; | |
32 | |
33 /* | |
34 * res_abil is an array of functions used to change attributes. It must be | |
35 * ordered according to the attribute definitions in rogue.h. | |
36 */ | |
37 | |
38 void (*res_abil[NUMABILITIES])() = { | |
39 res_intelligence, res_strength, res_wisdom, res_dexterity, | |
40 res_constitution, res_charisma | |
41 }; | |
42 | |
43 /* | |
44 * Increase player's constitution | |
45 */ | |
46 | |
47 void | |
48 add_constitution(change) | |
49 int change; | |
50 { | |
51 /* Do the potion */ | |
52 if (change < 0) { | |
53 msg("You feel less healthy now."); | |
54 pstats.s_const += change; | |
55 if (pstats.s_const <= 0) | |
56 death(D_CONSTITUTION); | |
57 } | |
58 else { | |
59 msg("You feel healthier now."); | |
60 pstats.s_const = min(pstats.s_const + change, 25); | |
61 } | |
62 | |
63 /* Adjust the maximum */ | |
64 if (max_stats.s_const < pstats.s_const) | |
65 max_stats.s_const = pstats.s_const; | |
66 } | |
67 | |
68 /* | |
69 * Increase player's charisma | |
70 */ | |
71 | |
72 void | |
73 add_charisma(change) | |
74 int change; | |
75 { | |
76 /* Do the potion */ | |
77 if (change < 0) msg("You feel less attractive now."); | |
78 else msg("You feel more attractive now."); | |
79 | |
80 pstats.s_charisma += change; | |
81 if (pstats.s_charisma > 25) pstats.s_charisma = 25; | |
82 else if (pstats.s_charisma < 3) pstats.s_charisma = 3; | |
83 | |
84 /* Adjust the maximum */ | |
85 if (max_stats.s_charisma < pstats.s_charisma) | |
86 max_stats.s_charisma = pstats.s_charisma; | |
87 } | |
88 | |
89 /* | |
90 * Increase player's dexterity | |
91 */ | |
92 | |
93 void | |
94 add_dexterity(change) | |
95 int change; | |
96 { | |
97 int ring_str; /* Value of ring strengths */ | |
98 | |
99 /* Undo any ring changes */ | |
100 ring_str = ring_value(R_ADDHIT); | |
101 pstats.s_dext -= ring_str; | |
102 | |
103 /* Now do the potion */ | |
104 if (change < 0) msg("You feel less dextrous now."); | |
105 else msg("You feel more dextrous now. Watch those hands!"); | |
106 | |
107 pstats.s_dext += change; | |
108 if (pstats.s_dext > 25) pstats.s_dext = 25; | |
109 else if (pstats.s_dext < 3) pstats.s_dext = 3; | |
110 | |
111 /* Adjust the maximum */ | |
112 if (max_stats.s_dext < pstats.s_dext) | |
113 max_stats.s_dext = pstats.s_dext; | |
114 | |
115 /* Now put back the ring changes */ | |
116 if (ring_str) | |
117 pstats.s_dext += ring_str; | |
118 } | |
119 | |
120 /* | |
121 * add_haste: | |
122 * add a haste to the player | |
123 */ | |
124 | |
125 add_haste(blessed) | |
126 bool blessed; | |
127 { | |
128 int hasttime; | |
129 | |
130 if (player.t_ctype == C_MONK) { /* monks cannot be slowed or hasted */ | |
131 msg(nothing); | |
132 return; | |
133 } | |
134 | |
135 if (blessed) hasttime = HASTETIME*2; | |
136 else hasttime = HASTETIME; | |
137 | |
138 if (on(player, ISSLOW)) { /* Is person slow? */ | |
139 extinguish(noslow); | |
140 noslow(); | |
141 | |
142 if (blessed) hasttime = HASTETIME/2; | |
143 else return; | |
144 } | |
145 | |
146 if (on(player, ISHASTE)) { | |
147 msg("You faint from exhaustion."); | |
148 player.t_no_move += movement(&player) * rnd(hasttime); | |
149 player.t_action = A_FREEZE; | |
150 lengthen(nohaste, roll(hasttime,hasttime)); | |
151 } | |
152 else { | |
153 msg("You feel yourself moving %sfaster.", blessed ? "much " : ""); | |
154 turn_on(player, ISHASTE); | |
155 fuse(nohaste, 0, roll(hasttime, hasttime), AFTER); | |
156 } | |
157 } | |
158 | |
159 /* | |
160 * Increase player's intelligence | |
161 */ | |
162 void | |
163 add_intelligence(change) | |
164 int change; | |
165 { | |
166 int ring_str; /* Value of ring strengths */ | |
167 | |
168 /* Undo any ring changes */ | |
169 ring_str = ring_value(R_ADDINTEL); | |
170 pstats.s_intel -= ring_str; | |
171 | |
172 /* Now do the potion */ | |
173 if (change < 0) msg("You feel slightly less intelligent now."); | |
174 else msg("You feel more intelligent now. What a mind!"); | |
175 | |
176 pstats.s_intel += change; | |
177 if (pstats.s_intel > 25) pstats.s_intel = 25; | |
178 else if (pstats.s_intel < 3) pstats.s_intel = 3; | |
179 | |
180 /* Adjust the maximum */ | |
181 if (max_stats.s_intel < pstats.s_intel) | |
182 max_stats.s_intel = pstats.s_intel; | |
183 | |
184 /* Now put back the ring changes */ | |
185 if (ring_str) | |
186 pstats.s_intel += ring_str; | |
187 } | |
188 | |
189 /* | |
190 * this routine makes the hero move slower | |
191 */ | |
192 add_slow() | |
193 { | |
194 /* monks cannot be slowed or hasted */ | |
195 if (player.t_ctype == C_MONK || ISWEARING(R_FREEDOM)) { | |
196 msg(nothing); | |
197 return; | |
198 } | |
199 | |
200 if (on(player, ISHASTE)) { /* Already sped up */ | |
201 extinguish(nohaste); | |
202 nohaste(); | |
203 } | |
204 else { | |
205 msg("You feel yourself moving %sslower.", | |
206 on(player, ISSLOW) ? "even " : ""); | |
207 if (on(player, ISSLOW)) | |
208 lengthen(noslow, roll(HASTETIME,HASTETIME)); | |
209 else { | |
210 turn_on(player, ISSLOW); | |
211 fuse(noslow, 0, roll(HASTETIME,HASTETIME), AFTER); | |
212 } | |
213 } | |
214 } | |
215 | |
216 /* | |
217 * Increase player's strength | |
218 */ | |
219 | |
220 void | |
221 add_strength(change) | |
222 int change; | |
223 { | |
224 | |
225 if (change < 0) { | |
226 msg("You feel slightly weaker now."); | |
227 chg_str(change); | |
228 } | |
229 else { | |
230 msg("You feel stronger now. What bulging muscles!"); | |
231 chg_str(change); | |
232 } | |
233 } | |
234 | |
235 /* | |
236 * Increase player's wisdom | |
237 */ | |
238 | |
239 void | |
240 add_wisdom(change) | |
241 int change; | |
242 { | |
243 int ring_str; /* Value of ring strengths */ | |
244 | |
245 /* Undo any ring changes */ | |
246 ring_str = ring_value(R_ADDWISDOM); | |
247 pstats.s_wisdom -= ring_str; | |
248 | |
249 /* Now do the potion */ | |
250 if (change < 0) msg("You feel slightly less wise now."); | |
251 else msg("You feel wiser now. What a sage!"); | |
252 | |
253 pstats.s_wisdom += change; | |
254 if (pstats.s_wisdom > 25) pstats.s_wisdom = 25; | |
255 else if (pstats.s_wisdom < 3) pstats.s_wisdom = 3; | |
256 | |
257 /* Adjust the maximum */ | |
258 if (max_stats.s_wisdom < pstats.s_wisdom) | |
259 max_stats.s_wisdom = pstats.s_wisdom; | |
260 | |
261 /* Now put back the ring changes */ | |
262 if (ring_str) | |
263 pstats.s_wisdom += ring_str; | |
264 } | |
265 | |
266 quaff(which, kind, flags, is_potion) | |
267 int which; | |
268 int kind; | |
269 int flags; | |
270 bool is_potion; | |
271 { | |
272 register struct object *obj; | |
273 register struct linked_list *item, *titem; | |
274 register struct thing *th; | |
275 bool cursed, blessed; | |
276 | |
277 blessed = FALSE; | |
278 cursed = FALSE; | |
279 item = NULL; | |
280 | |
281 if (which < 0) { /* figure out which ourselves */ | |
282 /* This is a potion. */ | |
283 if (player.t_action != C_QUAFF) { | |
284 int units; | |
285 | |
286 item = get_item(pack, "quaff", QUAFFABLE, FALSE, FALSE); | |
287 | |
288 /* | |
289 * Make certain that it is somethings that we want to drink | |
290 */ | |
291 if (item == NULL) | |
292 return; | |
293 | |
294 /* How long does it take to quaff? */ | |
295 units = usage_time(item); | |
296 if (units < 0) return; | |
297 | |
298 player.t_using = item; /* Remember what it is */ | |
299 player.t_no_move = units * movement(&player); | |
300 if ((OBJPTR(item))->o_type == POTION) player.t_action = C_QUAFF; | |
301 else player.t_action = C_USE; | |
302 return; | |
303 } | |
304 | |
305 /* We have waited our time, let's quaff the potion */ | |
306 item = player.t_using; | |
307 player.t_using = NULL; | |
308 player.t_action = A_NIL; | |
309 | |
310 obj = OBJPTR(item); | |
311 /* remove it from the pack */ | |
312 inpack--; | |
313 detach(pack, item); | |
314 | |
315 flags = obj->o_flags; | |
316 which = obj->o_which; | |
317 kind = obj->o_kind; | |
318 } | |
319 cursed = flags & ISCURSED; | |
320 blessed = flags & ISBLESSED; | |
321 | |
322 switch(which) { | |
323 case P_CLEAR: | |
324 if (cursed) { | |
325 confus_player(); | |
326 } | |
327 else { | |
328 if (blessed) { /* Make player immune for the whole game */ | |
329 extinguish(unclrhead); /* If we have a fuse, put it out */ | |
330 msg("A strong blue aura surrounds your head."); | |
331 } | |
332 else { /* Just light a fuse for how long player is safe */ | |
333 if (off(player, ISCLEAR)) { | |
334 fuse(unclrhead, 0, CLRDURATION, AFTER); | |
335 msg("A faint blue aura surrounds your head."); | |
336 } | |
337 else { /* If we have a fuse lengthen it, else we | |
338 * are permanently clear. | |
339 */ | |
340 if (find_slot(unclrhead) == 0) | |
341 msg("Your blue aura continues to glow strongly."); | |
342 else { | |
343 lengthen(unclrhead, CLRDURATION); | |
344 msg("Your blue aura brightens for a moment."); | |
345 } | |
346 } | |
347 } | |
348 turn_on(player, ISCLEAR); | |
349 /* If player is confused, unconfuse him */ | |
350 if (on(player, ISHUH)) { | |
351 extinguish(unconfuse); | |
352 unconfuse(); | |
353 } | |
354 } | |
355 when P_HEALING: | |
356 if (cursed) { | |
357 msg("You feel worse now."); | |
358 pstats.s_hpt -= roll(pstats.s_lvl, char_class[player.t_ctype].hit_pts); | |
359 if (pstats.s_hpt <= 0) | |
360 death(D_POISON); | |
361 } | |
362 else { | |
363 if (blessed) { | |
364 pstats.s_hpt += roll(pstats.s_lvl+1, char_class[player.t_ctype].hit_pts); | |
365 if (pstats.s_hpt > max_stats.s_hpt) | |
366 pstats.s_hpt = ++max_stats.s_hpt; | |
367 if (on(player, ISHUH)) { | |
368 extinguish(unconfuse); | |
369 unconfuse(); | |
370 } | |
371 } | |
372 else { | |
373 pstats.s_hpt += roll(pstats.s_lvl+1, char_class[player.t_ctype].hit_pts/2); | |
374 if (pstats.s_hpt > max_stats.s_hpt) | |
375 pstats.s_hpt = ++max_stats.s_hpt; | |
376 } | |
377 msg("You begin to feel %sbetter.", | |
378 blessed ? "much " : ""); | |
379 sight(); | |
380 if (is_potion) p_know[P_HEALING] = TRUE; | |