forked from dungeons-of-moria/icmoria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
potions.c
384 lines (320 loc) · 8.48 KB
/
potions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/* potions.c */
/**/
#include "imoria.h"
#include "dungeon.h"
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void q__potion_effect(integer effect, boolean *idented)
{
integer i4,i5;
boolean redraw = false;
boolean ident = false;
/*{ Potions }*/
switch (effect) {
case 1 : /*{ Gain Str }*/
ident = gain_stat(STR,"X");
break;
case 2 : /*{ Lose Str }*/
ident = lose_stat(STR,"X","X");
break;
case 3 : /*{ Restore Str }*/
ident = restore_stat(STR,"X");
break;
case 4 : /*{ Gain Int }*/
ident = gain_stat(INT,"X");
break;
case 5 : /*{ Lose Int }*/
msg_print("This potion tastes very dull.");
ident = lose_stat(INT,"X","X");
break;
case 6 : /*{ Restore Int }*/
ident = restore_stat(INT,"X");
break;
case 7 : /*{ Gain Wis }*/
ident = gain_stat(WIS,"X");
break;
case 8 : /*{ Lose Wis }*/
ident = lose_stat(WIS,"X","X");
break;
case 9 : /*{ Restore Wis }*/
ident = restore_stat(WIS,"X");
break;
case 10 : /*{ Gain Chr }*/
ident = gain_stat(CHR,"X");
break;
case 11 : /*{ Lose Chr }*/
ident = lose_stat(CHR,"X","X");
break;
case 12 : /*{ Restore Chr }*/
ident = restore_stat(CHR,"X");
break;
/*{ Cures and healing }*/
case 13 :
ident = hp_player(damroll("2d7"),"a potion.");
break;
case 14 :
ident = hp_player(damroll("4d7"),"a potion.");
break;
case 15 :
ident = hp_player(damroll("6d7"),"a potion.");
break;
case 16 :
ident = hp_player(1000,"a potion.");
break;
case 17 : /*{ Gain Con }*/
py.misc.mhp++;
py.misc.chp += py.misc.mhp;
ident = gain_stat(CON,"X");
prt_hp();
break;
case 18 : /*{ Gain Experience }*/
//with py.misc do;
i5 = (PM.exp div 2) + 10;
if (i5 > 100000) {
i5 = 100000;
}
PM.exp += i5;
msg_print("You feel more experienced.");
prt_experience();
ident = true;
break;
case 19 : /*{ Sleep }*/
if (! (py.flags.free_act)) {
msg_print("You fall asleep.");
py.flags.paralysis += randint(4) + 4;
ident = true;
}
break;
case 20 : /*{ Darkness }*/
msg_print("You are covered by a veil of darkness.");
PF.blind += randint(100) + 100;
ident = true;
break;
case 21 : /*{ Confusion }*/
msg_print("Hey! This is good stuff! * Hick! *");
PF.confused += randint(20) + 12;
ident = true;
break;
case 22 : /*{ Poison }*/
msg_print("You feel very sick.");
PF.poisoned += randint(15) + 10;
ident = true;
break;
case 23 : /*{ Haste Self }*/
py.flags.fast += randint(25) + 15;
ident = true;
break;
case 24 : /*{ Slowness }*/
py.flags.slow += randint(25) + 15;
ident = true;
break;
case 25 :
ident = detect_creatures(c_monster);
break;
case 26 : /*{ Increase Dex }*/
ident = gain_stat(DEX,"X");
break;
case 27 : /*{ Restore Dex }*/
ident = restore_stat(DEX,"X");
break;
case 28 : /*{ Restore Con }*/
ident = restore_stat(CON,"X");
break;
case 29 : /*{ Cure Blindness }*/
cure_me(&py.flags.blind);
break;
case 30 : /*{ Cure Confusion }*/
cure_me(&py.flags.confused);
break;
case 31 : /*{ Cure Poison }*/
cure_me(&py.flags.poisoned);
break;
case 32 : /*{ Learning }*/ /* 32 is the Cursed_worn_bit value */
case 48 : /*{ Learning }*/
//with py.misc do;
//with class[pclass] do;
if (class[PM.pclass].mspell) {
ident = learn_spell(&redraw);
if (redraw) {
draw_cave();
}
} else if (class[PM.pclass].bspell) {
ident = learn_song(&redraw);
if (redraw) {
draw_cave();
}
} else if (class[PM.pclass].pspell) {
ident = learn_prayer();
} else if (class[PM.pclass].dspell) {
ident = learn_druid();
}
break;
case 33 : /*{ Lose Memories }*/
msg_print("You feel your memories fade...");
msg_print("");
i4 = trunc(py.misc.exp/5.0);
lose_exp(randint(i4)+i4);
ident = true;
break;
case 34 : /*{ Salt Water }*/
//with py.flags do;
PF.poisoned = 0;
py.flags.status &= ~IS_POISONED;
prt_poisoned();
if (PF.foodc > 150) {
PF.foodc = 150;
}
PF.paralysis = 4;
msg_print("The potion makes you vomit!");
ident = true;
break;
case 35 : /*{ Invulnerability }*/
py.flags.invuln += randint(10) + 10;
ident = true;
break;
case 36 : /*{ Heroism }*/
py.flags.hero += randint(25) + 25;
ident = true;
break;
case 37 : /*{ Super-Heroism }*/
py.flags.shero += randint(25) + 25;
ident = true;
break;
case 38 : /*{ Remove Fear }*/
ident = cure_me(&py.flags.afraid);
break;
case 39 : /*{ Restore Level }*/
ident = restore_level();
add_food(5000);
py.flags.status &= ~(IS_WEAK | IS_HUNGERY);
prt_hunger();
break;
case 40 : /*{ Resist Heat }*/
PF.resist_heat += randint(10) + 10;
break;
case 41 : /*{ Resist Cold }*/
PF.resist_cold += randint(10) + 10;
break;
case 42 :
detect_inv2(randint(12)+12);
break;
case 43 : /*{ Slow Poison }*/
ident = slow_poison();
break;
case 44 : /*{ Cure Poison }*/
ident = cure_me(&py.flags.poisoned);
break;
case 45 : /*{ Restore Mana }*/
//with py.misc do;
if (PM.cmana < PM.mana) {
PM.cmana = PM.mana;
}
ident = true;
msg_print("Your feel your head clear...");
break;
case 46 : /*{ Infra-Vision }*/
PF.tim_infra += 100 + randint(100);
ident = true;
msg_print("Your eyes begin to tingle.");
break;
case 47 : /* cure hallucination */
msg_print("Pretty colors!");
PF.confused += randint(5) + 5;
ident = cure_me(&py.flags.image);
break;
/* case 48 moved up to 32 */
case 49 : /* reduce petrification */
if ( PF.petrification > 0 ) {
ident = true;
PF.petrification -= 100;
if ( PF.petrification < 0 ) {
PF.petrification = 0;
}
}
break;
case 50 : ;
case 51 : ;
case 52 : ;
case 53 : ;
case 54 : ;
case 55 : ;
case 56 : ;
case 57 : ;
case 58 : ;
case 59 : ;
case 60 : ;
case 61 : ;
case 62 : ;
default:
break;
} /* end switch */
/*{ End of Potions... }*/
*idented = ident;
};
//////////////////////////////////////////////////////////////////////
void quaff()
{
/*{ Potions for the quaffing -RAK- }*/
unsigned long q1,q2;
integer i3,i6;
treas_ptr i2,item_ptr;
char trash_char;
boolean redraw,ident;
obj_set stuff_to_drink = {potion1, potion2, 0};
reset_flag = true;
if (inven_ctr > 0) {
if (find_range(stuff_to_drink,false,&i2,&i3)) {
redraw = false;
if (get_item(&item_ptr,"Quaff which potion?",
&redraw,i3,&trash_char,false,false)) {
//with item_ptr->data. do;
if (redraw) {
draw_cave();
}
reset_flag = false;
q1 = item_ptr->data.flags;
q2 = item_ptr->data.flags2;
ident = false;
for (;q1 > 0 || q2 > 0;) {
i6 = bit_pos64(&q2,&q1)+1;
/*
* It looks like potion2 was created before flags2 was
* added to the treasure type, now we can fit all the
* potion effects into the pair of flags.
*
* The += 31 should be 64 now, I am leaving it at 31 so
* that old characters do not get confused.
*/
if (item_ptr->data.tval == potion2) {
i6 += 31;
}
q__potion_effect(i6, &ident);
} /* end for */
if (ident) {
identify(&(item_ptr->data));
}
if (item_ptr->data.flags != 0) {
PM.exp += (item_ptr->data.level / (real)PM.lev) + .5;
prt_experience();
}
add_food(item_ptr->data.p1);
desc_remain(item_ptr);
inven_destroy(item_ptr);
prt_weight();
} else {
if (redraw) {
draw_cave();
}
}
} else {
msg_print("You are not carrying any potions.");
}
} else {
msg_print("But you are not carrying anything.");
}
};
/* END FILE potions.c */
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////