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
|
/* $OpenBSD: hack.do_wear.c,v 1.4 2001/08/06 22:59:13 pjanzen Exp $ */
/*
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
*/
#ifndef lint
static char rcsid[] = "$OpenBSD: hack.do_wear.c,v 1.4 2001/08/06 22:59:13 pjanzen Exp $";
#endif /* not lint */
#include "hack.h"
#include <stdio.h>
extern char *nomovemsg;
extern char quitchars[];
extern char *Doname();
off_msg(otmp) register struct obj *otmp; {
pline("You were wearing %s.", doname(otmp));
}
doremarm() {
register struct obj *otmp;
if(!uarm && !uarmh && !uarms && !uarmg) {
pline("Not wearing any armor.");
return(0);
}
otmp = (!uarmh && !uarms && !uarmg) ? uarm :
(!uarms && !uarm && !uarmg) ? uarmh :
(!uarmh && !uarm && !uarmg) ? uarms :
(!uarmh && !uarm && !uarms) ? uarmg :
getobj("[", "take off");
if(!otmp) return(0);
if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
pline("You can't take that off.");
return(0);
}
if( otmp == uarmg && uwep && uwep->cursed ) { /* myers@uwmacc */
pline("You seem not able to take off the gloves while holding your weapon.");
return(0);
}
(void) armoroff(otmp);
return(1);
}
doremring() {
if(!uleft && !uright){
pline("Not wearing any ring.");
return(0);
}
if(!uleft)
return(dorr(uright));
if(!uright)
return(dorr(uleft));
if(uleft && uright) while(1) {
char answer;
pline("What ring, Right or Left? [ rl?]");
if(strchr(quitchars, (answer = readchar())))
return(0);
switch(answer) {
case 'l':
case 'L':
return(dorr(uleft));
case 'r':
case 'R':
return(dorr(uright));
case '?':
(void) doprring();
/* might look at morc here %% */
}
}
/* NOTREACHED */
#ifdef lint
return(0);
#endif /* lint */
}
dorr(otmp) register struct obj *otmp; {
if(cursed(otmp)) return(0);
ringoff(otmp);
off_msg(otmp);
return(1);
}
cursed(otmp) register struct obj *otmp; {
if(otmp->cursed){
pline("You can't. It appears to be cursed.");
return(1);
}
return(0);
}
armoroff(otmp) register struct obj *otmp; {
register int delay = -objects[otmp->otyp].oc_delay;
if(cursed(otmp)) return(0);
setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
if(delay) {
nomul(delay);
switch(otmp->otyp) {
case HELMET:
nomovemsg = "You finished taking off your helmet.";
break;
case PAIR_OF_GLOVES:
nomovemsg = "You finished taking off your gloves";
break;
default:
nomovemsg = "You finished taking off your suit.";
}
} else {
off_msg(otmp);
}
return(1);
}
doweararm() {
register struct obj *otmp;
register int delay;
register int err = 0;
long mask = 0;
otmp = getobj("[", "wear");
if(!otmp) return(0);
if(otmp->owornmask & W_ARMOR) {
pline("You are already wearing that!");
return(0);
}
if(otmp->otyp == HELMET){
if(uarmh) {
pline("You are already wearing a helmet.");
err++;
} else
mask = W_ARMH;
} else if(otmp->otyp == SHIELD){
if(uarms) pline("You are already wearing a shield."), err++;
if(uwep && uwep->otyp == TWO_HANDED_SWORD)
pline("You cannot wear a shield and wield a two-handed sword."), err++;
if(!err) mask = W_ARMS;
} else if(otmp->otyp == PAIR_OF_GLOVES) {
if(uarmg) {
pline("You are already wearing gloves.");
err++;
} else
if(uwep && uwep->cursed) {
pline("You cannot wear gloves over your weapon.");
err++;
} else
mask = W_ARMG;
} else {
if(uarm) {
if(otmp->otyp != ELVEN_CLOAK || uarm2) {
pline("You are already wearing some armor.");
err++;
}
}
if(!err) mask = W_ARM;
}
if(otmp == uwep && uwep->cursed) {
if(!err++)
pline("%s is welded to your hand.", Doname(uwep));
}
if(err) return(0);
setworn(otmp, mask);
if(otmp == uwep)
setuwep((struct obj *) 0);
delay = -objects[otmp->otyp].oc_delay;
if(delay){
nomul(delay);
nomovemsg = "You finished your dressing manoeuvre.";
}
otmp->known = 1;
return(1);
}
dowearring() {
register struct obj *otmp;
long mask = 0;
long oldprop;
if(uleft && uright){
pline("There are no more ring-fingers to fill.");
return(0);
}
otmp = getobj("=", "wear");
if(!otmp) return(0);
if(otmp->owornmask & W_RING) {
pline("You are already wearing that!");
return(0);
}
if(otmp == uleft || otmp == uright) {
pline("You are already wearing that.");
return(0);
}
if(otmp == uwep && uwep->cursed) {
pline("%s is welded to your hand.", Doname(uwep));
return(0);
}
if(uleft) mask = RIGHT_RING;
else if(uright) mask = LEFT_RING;
else do {
char answer;
pline("What ring-finger, Right or Left? ");
if(strchr(quitchars, (answer = readchar())))
return(0);
switch(answer){
case 'l':
case 'L':
mask = LEFT_RING;
break;
case 'r':
case 'R':
mask = RIGHT_RING;
break;
}
} while(!mask);
setworn(otmp, mask);
if(otmp == uwep)
setuwep((struct obj *) 0);
oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
switch(otmp->otyp){
case RIN_LEVITATION:
if(!oldprop) float_up();
break;
case RIN_PROTECTION_FROM_SHAPE_CHANGERS:
rescham();
break;
case RIN_GAIN_STRENGTH:
u.ustr += otmp->spe;
u.ustrmax += otmp->spe;
if(u.ustr > 118) u.ustr = 118;
if(u.ustrmax > 118) u.ustrmax = 118;
flags.botl = 1;
break;
case RIN_INCREASE_DAMAGE:
u.udaminc += otmp->spe;
break;
}
prinv(otmp);
return(1);
}
ringoff(obj)
register struct obj *obj;
{
register long mask;
mask = obj->owornmask & W_RING;
setworn((struct obj *) 0, obj->owornmask);
if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
impossible("Strange... I didnt know you had that ring.");
u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
switch(obj->otyp) {
case RIN_FIRE_RESISTANCE:
/* Bad luck if the player is in hell... --jgm */
if (!Fire_resistance && dlevel >= 30) {
pline("The flames of Hell burn you to a crisp.");
killer = "stupidity in hell";
done("burned");
}
break;
case RIN_LEVITATION:
if(!Levitation) { /* no longer floating */
float_down();
}
break;
case RIN_GAIN_STRENGTH:
u.ustr -= obj->spe;
u.ustrmax -= obj->spe;
if(u.ustr > 118) u.ustr = 118;
if(u.ustrmax > 118) u.ustrmax = 118;
flags.botl = 1;
break;
case RIN_INCREASE_DAMAGE:
u.udaminc -= obj->spe;
break;
}
}
find_ac(){
register int uac = 10;
if(uarm) uac -= ARM_BONUS(uarm);
if(uarm2) uac -= ARM_BONUS(uarm2);
if(uarmh) uac -= ARM_BONUS(uarmh);
if(uarms) uac -= ARM_BONUS(uarms);
if(uarmg) uac -= ARM_BONUS(uarmg);
if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
if(uac != u.uac){
u.uac = uac;
flags.botl = 1;
}
}
glibr(){
register struct obj *otmp;
int xfl = 0;
if(!uarmg) if(uleft || uright) {
/* Note: at present also cursed rings fall off */
pline("Your %s off your fingers.",
(uleft && uright) ? "rings slip" : "ring slips");
xfl++;
if((otmp = uleft) != Null(obj)){
ringoff(uleft);
dropx(otmp);
}
if((otmp = uright) != Null(obj)){
ringoff(uright);
dropx(otmp);
}
}
if((otmp = uwep) != Null(obj)){
/* Note: at present also cursed weapons fall */
setuwep((struct obj *) 0);
dropx(otmp);
pline("Your weapon %sslips from your hands.",
xfl ? "also " : "");
}
}
struct obj *
some_armor(){
register struct obj *otmph = uarm;
if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
if(uarms && (!otmph || !rn2(4))) otmph = uarms;
return(otmph);
}
corrode_armor(){
register struct obj *otmph = some_armor();
if(otmph){
if(otmph->rustfree ||
otmph->otyp == ELVEN_CLOAK ||
otmph->otyp == LEATHER_ARMOR ||
otmph->otyp == STUDDED_LEATHER_ARMOR) {
pline("Your %s not affected!",
aobjnam(otmph, "are"));
return;
}
pline("Your %s!", aobjnam(otmph, "corrode"));
otmph->spe--;
}
}
|