-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRINGS.C
183 lines (167 loc) · 3.17 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
/*
* Routines dealing specifically with rings
*
* rings.c 1.4 (AI Design) 12/13/84
*/
#include "rogue.h"
#include "curses.h"
/*
* ring_on:
* Put a ring on a hand
*/
ring_on()
{
register THING *obj;
register int ring = -1;
if ((obj = get_item("put on", RING)) == NULL)
goto no_ring;
/*
* Make certain that it is somethings that we want to wear
*/
if (obj->o_type != RING) {
msg("you can't put that on your finger");
goto no_ring;
}
/*
* find out which hand to put it on
*/
if (is_current(obj))
goto no_ring;
if (cur_ring[LEFT] == NULL)
ring = LEFT;
if (cur_ring[RIGHT] == NULL)
ring = RIGHT;
if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
if ((ring = gethand()) < 0)
goto no_ring;
if (ring < 0) {
msg("you already have a ring on each hand");
goto no_ring;
}
cur_ring[ring] = obj;
/*
* Calculate the effect it has on the poor guy.
*/
switch (obj->o_which) {
case R_ADDSTR:
chg_str(obj->o_ac);
break;
case R_SEEINVIS:
invis_on();
break;
case R_AGGR:
aggravate();
break;
}
msg("%swearing %s (%c)", noterse("you are now "), inv_name(obj, TRUE), pack_char(obj));
return ;
no_ring:
after = FALSE;
return;
}
/*
* ring_off:
* Take off a ring
*/
ring_off()
{
register int ring;
register THING *obj;
register char packchar;
if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) {
msg("you aren't wearing any rings");
after = FALSE;
return;
} else if (cur_ring[LEFT] == NULL)
ring = RIGHT;
else if (cur_ring[RIGHT] == NULL)
ring = LEFT;
else
if ((ring = gethand()) < 0)
return;
mpos = 0;
obj = cur_ring[ring];
if (obj == NULL) {
msg("not wearing such a ring");
after = FALSE;
return;
}
packchar = pack_char(obj);
if (can_drop(obj))
msg("was wearing %s(%c)", inv_name(obj, TRUE), packchar);
}
/*
* gethand:
* Which hand is the hero interested in?
*/
gethand()
{
register int c;
for (;;) {
msg("left hand or right hand? ");
if ((c = readchar()) == ESCAPE) {
after = FALSE;
return -1;
}
mpos = 0;
if (c == 'l' || c == 'L')
return LEFT;
else if (c == 'r' || c == 'R')
return RIGHT;
msg("please type L or R");
}
}
/*
* ring_eat:
* How much food does this ring use up?
*/
ring_eat(hand)
register int hand;
{
if (cur_ring[hand] == NULL)
return 0;
switch (cur_ring[hand]->o_which) {
case R_REGEN:
return 2;
case R_SUSTSTR:
case R_SUSTARM:
case R_PROTECT:
case R_ADDSTR:
case R_STEALTH:
return 1;
case R_SEARCH:
return(rnd(5)==0);
case R_ADDHIT:
case R_ADDDAM:
return (rnd(3) == 0);
case R_DIGEST:
return -rnd(2);
case R_SEEINVIS:
return (rnd(5) == 0);
default:
return 0;
}
}
/*
* ring_num:
* Print ring bonuses
*/
char *
ring_num(obj)
register THING *obj;
{
extern char *ring_buf;
if (!(obj->o_flags & ISKNOW))
return "";
switch (obj->o_which) {
when R_PROTECT:
case R_ADDSTR:
case R_ADDDAM:
case R_ADDHIT:
ring_buf[0] = ' ';
strcpy(&ring_buf[1], num(obj->o_ac, 0, RING));
otherwise:
return "";
}
return ring_buf;
}