-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPOTIONS.C
291 lines (277 loc) · 6.8 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
/*
* Function(s) for dealing with potions
*
* potions.c 1.4 (AI Design) 2/12/84
*/
#include "rogue.h"
#include "curses.h"
/*
* quaff:
* Quaff a potion from the pack
*/
quaff()
{
register THING *obj, *th;
register bool discardit = FALSE;
if ((obj = get_item("quaff", POTION)) == NULL)
return;
/*
* Make certain that it is somethings that we want to drink
*/
if (obj->o_type != POTION)
{
msg("yuk! Why would you want to drink that?");
return;
}
if (obj == cur_weapon)
cur_weapon = NULL;
/*
* Calculate the effect it has on the poor guy.
*/
switch (obj->o_which)
{
when P_CONFUSE:
p_know[P_CONFUSE] = TRUE;
if (!on(player, ISHUH))
{
if (on(player, ISHUH))
lengthen(unconfuse, rnd(8)+HUHDURATION);
else
fuse(unconfuse, 0, rnd(8)+HUHDURATION);
player.t_flags |= ISHUH;
msg("wait, what's going on? Huh? What? Who?");
}
when P_POISON:
{
char *sick = "you feel %s sick.";
p_know[P_POISON] = TRUE;
if (!ISWEARING(R_SUSTSTR))
{
chg_str(-(rnd(3)+1));
msg(sick, "very");
}
else
msg(sick, "momentarily");
}
when P_HEALING:
p_know[P_HEALING] = TRUE;
if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
pstats.s_hpt = ++max_hp;
sight();
msg("you begin to feel better");
when P_STRENGTH:
p_know[P_STRENGTH] = TRUE;
chg_str(1);
msg("you feel stronger. What bulging muscles!");
when P_MFIND:
#ifndef DEMO
fuse(turn_see, TRUE, HUHDURATION);
if (mlist == NULL)
msg("you have a strange feeling%s.",
noterse(" for a moment"));
else
{
p_know[P_MFIND] |= turn_see(FALSE);
msg("");
}
#else
msg("you can't move");
msg(" and are forced to watch this advertisement");
msg("rogue: The ULTIMATE Adventure Game");
msg("the most popular game on UNIX ever!");
msg("now runs on YOUR IBM PC");
msg("UNIX is a trademark of Bell Labs");
p_know[P_MFIND] = TRUE;
#endif
when P_TFIND:
/*
* Potion of magic detection. Find everything interesting on
* the level and show him where they are. Also give hints as
* to whether he would want to use the object.
*/
if (lvl_obj != NULL)
{
register THING *tp;
register bool show;
show = FALSE;
for (tp = lvl_obj; tp != NULL; tp = next(tp))
{
if (is_magic(tp))
{
show = TRUE;
mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, goodch(tp));
p_know[P_TFIND] = TRUE;
}
}
for (th = mlist; th != NULL; th = next(th))
{
for (tp = th->t_pack; tp != NULL; tp = next(tp))
{
if (is_magic(tp))
{
show = TRUE;
mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
p_know[P_TFIND] = TRUE;
}
}
}
if (show)
{
msg("You sense the presence of magic.");
break;
}
}
msg("you have a strange feeling for a moment%s.",
noterse(", then it passes"));
when P_PARALYZE:
p_know[P_PARALYZE] = TRUE;
no_command = HOLDTIME;
player.t_flags &= ~ISRUN;
msg("you can't move");
when P_SEEINVIS:
if (!on(player, CANSEE)) {
fuse(unsee, 0, SEEDURATION);
look(FALSE);
invis_on();
}
sight();
msg("this potion tastes like %s juice", fruit);
when P_RAISE:
p_know[P_RAISE] = TRUE;
msg("you suddenly feel much more skillful");
raise_level();
when P_XHEAL:
p_know[P_XHEAL] = TRUE;
if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
{
if (pstats.s_hpt > max_hp + pstats.s_lvl + 1)
++max_hp;
pstats.s_hpt = ++max_hp;
}
sight();
msg("you begin to feel much better");
when P_HASTE:
p_know[P_HASTE] = TRUE;
if (add_haste(TRUE))
msg("you feel yourself moving much faster");
when P_RESTORE:
if (ISRING(LEFT, R_ADDSTR))
add_str(&pstats.s_str, -cur_ring[LEFT]->o_ac);
if (ISRING(RIGHT, R_ADDSTR))
add_str(&pstats.s_str, -cur_ring[RIGHT]->o_ac);
if (pstats.s_str < max_stats.s_str)
pstats.s_str = max_stats.s_str;
if (ISRING(LEFT, R_ADDSTR))
add_str(&pstats.s_str, cur_ring[LEFT]->o_ac);
if (ISRING(RIGHT, R_ADDSTR))
add_str(&pstats.s_str, cur_ring[RIGHT]->o_ac);
msg("%syou feel warm all over",
noterse("hey, this tastes great. It makes "));
when P_BLIND:
p_know[P_BLIND] = TRUE;
if (!on(player, ISBLIND))
{
player.t_flags |= ISBLIND;
fuse(sight, 0, SEEDURATION);
look(FALSE);
}
msg("a cloak of darkness falls around you");
when P_NOP:
msg("this potion tastes extremely dull");
otherwise:
msg("what an odd tasting potion!");
return;
}
status();
/*
* Throw the item away
*/
inpack--;
if (obj->o_count > 1)
obj->o_count--;
else
{
detach(pack, obj);
discardit = TRUE;
}
call_it(p_know[obj->o_which], &p_guess[obj->o_which]);
if (discardit)
discard(obj);
}
/*
* invis_on:
* Turn on the ability to see invisible
*/
invis_on()
{
register THING *th;
player.t_flags |= CANSEE;
for (th = mlist; th != NULL; th = next(th))
if (on(*th, ISINVIS) && see_monst(th))
{
mvaddch(th->t_pos.y, th->t_pos.x,th->t_disguise);
}
}
/*
* turn_see:
* Put on or off seeing monsters on this level
*/
turn_see(turn_off)
register bool turn_off;
{
register THING *mp;
register bool can_see, add_new;
byte was_there;
add_new = FALSE;
for (mp = mlist; mp != NULL; mp = next(mp)) {
move(mp->t_pos.y, mp->t_pos.x);
can_see = (see_monst(mp) || (was_there = inch()) == mp->t_type);
if (turn_off) {
if (!see_monst(mp) && mp->t_oldch != '@')
addch(mp->t_oldch);
} else {
if (!can_see) {
standout();
mp->t_oldch = was_there;
}
addch(mp->t_type);
if (!can_see) {
standend();
add_new++;
}
}
}
player.t_flags |= SEEMONST;
if (turn_off)
player.t_flags &= ~SEEMONST;
return add_new;
}
/*
* th_effect:
* Compute the effect of this potion hitting a monster.
*/
th_effect(obj, tp)
register THING *obj, *tp;
{
switch (obj->o_which)
{
when P_CONFUSE:
case P_BLIND:
tp->t_flags |= ISHUH;
msg("the %s appears confused", monsters[tp->t_type-'A'].m_name);
when P_PARALYZE:
tp->t_flags &= ~ISRUN;
tp->t_flags |= ISHELD;
when P_HEALING:
case P_XHEAL:
if ((tp->t_stats.s_hpt += rnd(8)) > tp->t_stats.s_maxhp)
tp->t_stats.s_hpt = ++tp->t_stats.s_maxhp;
when P_RAISE:
tp->t_stats.s_hpt += 8;
tp->t_stats.s_maxhp += 8;
tp->t_stats.s_lvl++;
when P_HASTE:
tp->t_flags |= ISHASTE;
}
msg("the flask shatters.");
}