-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpotions.c
202 lines (196 loc) · 4.81 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
/*
* @(#)potions.c 3.1 3.1 5/7/81
* Function(s) for dealing with potions
*/
#include <curses.h>
#include "rogue.h"
quaff()
{
register struct object *obj;
register struct linked_list *item, *titem;
register struct monster *th;
char buf[80];
item = get_item("quaff", POTION);
/*
* Make certain that it is somethings that we want to drink
*/
if (item == NULL)
return;
obj = (struct object *) ldata(item);
if (obj->o_type != POTION)
{
if (!terse)
msg("Yuk! Why would you want to drink that?");
else
msg("That's undrinkable");
return;
}
if (obj == cur_weapon)
cur_weapon = NULL;
/*
* Calculate the effect it has on the poor guy.
*/
switch(obj->o_which)
{
when P_CONFUSE:
if (off(player, ISHUH))
{
msg("Wait, what's going on here. Huh? What? Who?");
if (on(player, ISHUH))
lengthen(unconfuse, rnd(8)+HUHDURATION);
else
fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
player.t_flags |= ISHUH;
}
p_know[P_CONFUSE] = TRUE;
when P_POISON:
if (!ISWEARING(R_SUSTSTR))
{
chg_str(-(rnd(3)+1));
msg("You feel very sick now.");
}
else
msg("You feel momentarily sick");
p_know[P_POISON] = TRUE;
when P_HEALING:
if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
pstats.s_hpt = ++max_hp;
msg("You begin to feel better.");
sight();
p_know[P_HEALING] = TRUE;
when P_STRENGTH:
msg("You feel stronger, now. What bulging muscles!");
chg_str(1);
p_know[P_STRENGTH] = TRUE;
when P_MFIND:
/*
* Potion of monster detection, if there are monters, detect them
*/
if (mlist != NULL)
{
wclear(hw);
overwrite(mw, hw);
show_win(hw,
"You begin to sense the presence of monsters.--More--");
p_know[P_MFIND] = TRUE;
}
else
msg("You have a strange feeling for a moment, then it passes.");
when P_TFIND:
/*
* Potion of magic detection. Show the potions and scrolls
*/
if (lvl_obj != NULL)
{
struct linked_list *mobj;
struct object *tp;
bool show;
show = FALSE;
wclear(hw);
for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj))
{
tp = (struct object *) ldata(mobj);
if (is_magic(tp))
{
show = TRUE;
mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
}
p_know[P_TFIND] = TRUE;
}
for (titem = mlist; titem != NULL; titem = next(titem))
{
register struct linked_list *pitem;
th = (struct monster *) ldata(titem);
for (pitem = th->t_pack; pitem != NULL; pitem = next(pitem))
{
if (is_magic(ldata(pitem)))
{
show = TRUE;
mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
}
p_know[P_TFIND] = TRUE;
}
}
if (show)
{
show_win(hw,
"You sense the presence of magic on this level.--More--");
break;
}
}
msg("You have a strange feeling for a moment, then it passes.");
when P_PARALYZE:
msg("You can't move.");
no_command = HOLDTIME;
p_know[P_PARALYZE] = TRUE;
when P_SEEINVIS:
msg("This potion tastes like %s juice.", fruit);
if (off(player, CANSEE))
{
player.t_flags |= CANSEE;
fuse(unsee, 0, SEEDURATION, AFTER);
light(&hero);
}
sight();
when P_RAISE:
msg("You suddenly feel much more skillful");
p_know[P_RAISE] = TRUE;
raise_level();
when P_XHEAL:
if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
pstats.s_hpt = ++max_hp;
msg("You begin to feel much better.");
p_know[P_XHEAL] = TRUE;
sight();
when P_HASTE:
add_haste(TRUE);
msg("You feel yourself moving much faster.");
p_know[P_HASTE] = TRUE;
when P_RESTORE:
msg("Hey, this tastes great. It make you feel warm all over.");
if (pstats.s_str.st_str < max_stats.s_str.st_str ||
(pstats.s_str.st_str == 18 &&
pstats.s_str.st_add < max_stats.s_str.st_add))
pstats.s_str = max_stats.s_str;
when P_BLIND:
msg("A cloak of darkness falls around you.");
if (off(player, ISBLIND))
{
player.t_flags |= ISBLIND;
fuse(sight, 0, SEEDURATION, AFTER);
look(FALSE);
}
p_know[P_BLIND] = TRUE;
when P_NOP:
msg("This potion tastes extremely dull.");
otherwise:
msg("What an odd tasting potion!");
return;
}
status();
if (p_know[obj->o_which] && p_guess[obj->o_which])
{
cfree(p_guess[obj->o_which]);
p_guess[obj->o_which] = NULL;
}
else if (!p_know[obj->o_which] && askme && p_guess[obj->o_which] == NULL)
{
msg(terse ? "Call it: " : "What do you want to call it? ");
if (get_str(buf, cw) == NORM)
{
p_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1);
strcpy(p_guess[obj->o_which], buf);
}
}
/*
* Throw the item away
*/
inpack--;
if (obj->o_count > 1)
obj->o_count--;
else
{
detach(pack, item);
discard(item);
}
}