-
Notifications
You must be signed in to change notification settings - Fork 4
/
rings.c
288 lines (267 loc) · 6.66 KB
/
rings.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
/*
rings.c - routines dealing specifically with rings
Last Modified: Dec 29, 1990
UltraRogue
Copyright (C) 1984, 1985, 1986, 1987, 1990 Herb Chong
All rights reserved.
Based on "Advanced Rogue"
Copyright (C) 1983, 1984 Michael Morgan, Ken Dalka and AT&T
All rights reserved.
Based on "Super-Rogue"
Copyright (C) 1982, 1983 Robert D. Kindelberger
All rights reserved.
Based on "Rogue: Exploring the Dungeons of Doom"
Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
All rights reserved.
See the file LICENSE.TXT for full copyright and licensing information.
*/
#include "rogue.h"
ring_on()
{
struct object *obj;
struct linked_list *item;
int ring;
char buf[2 * LINELEN];
if ((item = get_item("put on", RING)) == NULL)
return;
obj = OBJPTR(item);
if (obj->o_type != RING) {
msg("You can't put that on!");
return;
}
/*
* find out which hand to put it on
*/
if (is_current(obj)) {
msg("Already wearing that!");
return;
}
if (cur_ring[LEFT_1] == NULL)
ring = LEFT_1;
else if (cur_ring[LEFT_2] == NULL)
ring = LEFT_2;
else if (cur_ring[LEFT_3] == NULL)
ring = LEFT_3;
else if (cur_ring[LEFT_4] == NULL)
ring = LEFT_4;
else if (cur_ring[LEFT_5] == NULL)
ring = LEFT_5;
else if (cur_ring[RIGHT_1] == NULL)
ring = RIGHT_1;
else if (cur_ring[RIGHT_2] == NULL)
ring = RIGHT_2;
else if (cur_ring[RIGHT_3] == NULL)
ring = RIGHT_3;
else if (cur_ring[RIGHT_4] == NULL)
ring = RIGHT_4;
else if (cur_ring[RIGHT_5] == NULL)
ring = RIGHT_5;
else {
if (terse)
msg("Wearing enough rings.");
else
msg("You already have on eight rings.");
return;
}
cur_ring[ring] = obj;
/*
* Calculate the effect it has on the poor guy.
*/
switch (obj->o_which) {
when R_ADDSTR:
pstats.s_str += obj->o_ac;
when R_ADDHIT:
pstats.s_dext += obj->o_ac;
when R_ADDINTEL:
pstats.s_intel += obj->o_ac;
when R_ADDWISDOM:
pstats.s_wisdom += obj->o_ac;
when R_FREEDOM:
turn_off(player, ISHELD);
hold_count = 0;
when R_TRUESEE:
if (off(player, PERMBLIND)) {
turn_on(player, CANTRUESEE);
msg("You become more aware of your surroundings.");
sight();
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER);
}
when R_SEEINVIS:
if (off(player, PERMBLIND)) {
turn_on(player, CANTRUESEE);
msg("Your eyes begin to tingle.");
sight();
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER);
}
when R_AGGR:
aggravate();
when R_CARRYING:
updpack();
when R_LEVITATION:
msg("You begin to float in the air!");
when R_LIGHT:
if (roomin(&hero) != NULL) {
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER);
}
}
status(FALSE);
if (know_items[TYP_RING][obj->o_which] &&
guess_items[TYP_RING][obj->o_which]) {
free(guess_items[TYP_RING][obj->o_which]);
guess_items[TYP_RING][obj->o_which] = NULL;
}
else if (!know_items[TYP_RING][obj->o_which] &&
askme &&
(obj->o_flags & ISKNOW) == 0 &&
guess_items[TYP_RING][obj->o_which] == NULL) {
mpos = 0;
msg(terse ? "Call it: " : "What do you want to call it? ");
if (get_str(buf, cw) == NORM) {
guess_items[TYP_RING][obj->o_which] =
new((unsigned int) strlen(buf) + 1);
strcpy(guess_items[TYP_RING][obj->o_which], buf);
}
msg("");
}
}
ring_off()
{
struct object *obj;
struct linked_list *item;
if (cur_ring[LEFT_1] == NULL && cur_ring[LEFT_2] == NULL &&
cur_ring[LEFT_3] == NULL && cur_ring[LEFT_4] == NULL &&
cur_ring[LEFT_5] == NULL &&
cur_ring[RIGHT_1] == NULL && cur_ring[RIGHT_2] == NULL &&
cur_ring[RIGHT_3] == NULL && cur_ring[RIGHT_4] == NULL &&
cur_ring[RIGHT_5] == NULL) {
if (terse)
msg("No rings.");
else
msg("You aren't wearing any rings.");
return;
}
else if ((item = get_item("remove", RING)) == NULL)
return;
mpos = 0;
obj = OBJPTR(item);
if ((obj = OBJPTR(item)) == NULL)
msg("%s wearing that!", terse ? "Not" : "You are not");
if (dropcheck(obj)) {
switch (obj->o_which) {
when R_SEEINVIS:
msg("Your eyes stop tingling.");
when R_CARRYING:
updpack();
when R_LEVITATION:
msg("You float gently to the ground.");
when R_LIGHT:
if (roomin(&hero) != NULL) {
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER);
}
when R_TRUESEE:
msg("Your sensory perceptions return to normal.");
}
msg("Was wearing %s.", inv_name(obj, LOWERCASE));
}
}
/*
* how much food does this ring use up?
*/
ring_eat(hand)
int hand;
{
int ret_val = 0;
int ac;
if (cur_ring[hand] != NULL) {
switch (cur_ring[hand]->o_which) {
case R_REGEN:
case R_VREGEN:
ret_val = rnd(pstats.s_lvl > 10 ? 10
: pstats.s_lvl);
case R_ALERT:
case R_SUSABILITY:
return 1;
case R_DIGEST:
ac = cur_ring[hand]->o_ac;
if (ac < 0 && rnd(1 - (ac / 3)) == 0)
ret_val = -ac + 1;
else if (rnd((ac / 2) + 2) == 0)
ret_val = -1 - ac;
case R_SEARCH:
ret_val = rnd(100) < 33;
}
}
ret_val += rnd(luck);
return (ret_val);
}
/*
* print ring bonuses
*/
char *
ring_num(obj)
struct object *obj;
{
static char buf[10];
buf[0] = '\0';
if (obj->o_flags & ISKNOW) {
switch (obj->o_which) {
when R_PROTECT:
case R_ADDSTR:
case R_ADDDAM:
case R_ADDHIT:
case R_ADDINTEL:
case R_ADDWISDOM:
case R_CARRYING:
case R_VREGEN:
case R_RESURRECT:
case R_TELCONTROL:
case R_REGEN:
case R_PIETY:
case R_WIZARD:
buf[0] = ' ';
strcpy(&buf[1], num(obj->o_ac, 0));
when R_DIGEST:
buf[0] = ' ';
strcpy(&buf[1], num(obj->o_ac < 0 ?
obj->o_ac : obj->o_ac - 1, 0));
otherwise:
if (obj->o_flags & ISCURSED)
strcpy(buf, " cursed");
}
}
return (buf);
}
/*
* ring_value - Return the effect of the specified ring
*/
#define ISRING(h, r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r)
ring_value(type)
int type;
{
int result = 0;
if (ISRING(LEFT_1, type))
result += cur_ring[LEFT_1]->o_ac;
if (ISRING(LEFT_2, type))
result += cur_ring[LEFT_2]->o_ac;
if (ISRING(LEFT_3, type))
result += cur_ring[LEFT_3]->o_ac;
if (ISRING(LEFT_4, type))
result += cur_ring[LEFT_4]->o_ac;
if (ISRING(LEFT_5, type))
result += cur_ring[LEFT_5]->o_ac;
if (ISRING(RIGHT_1, type))
result += cur_ring[RIGHT_1]->o_ac;
if (ISRING(RIGHT_2, type))
result += cur_ring[RIGHT_2]->o_ac;
if (ISRING(RIGHT_3, type))
result += cur_ring[RIGHT_3]->o_ac;
if (ISRING(RIGHT_4, type))
result += cur_ring[RIGHT_4]->o_ac;
if (ISRING(RIGHT_5, type))
result += cur_ring[RIGHT_5]->o_ac;
return (result);
}