1 /* $NetBSD: hack.do_wear.c,v 1.5 2003/04/02 18:36:36 jsm Exp $ */
4 * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * - Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * - Neither the name of the Stichting Centrum voor Wiskunde en
20 * Informatica, nor the names of its contributors may be used to endorse or
21 * promote products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
39 * All rights reserved.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. The name of the author may not be used to endorse or promote products
50 * derived from this software without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
53 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
54 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
55 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
58 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
59 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
60 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
61 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 #include <sys/cdefs.h>
66 __RCSID("$NetBSD: hack.do_wear.c,v 1.5 2003/04/02 18:36:36 jsm Exp $");
76 pline("You were wearing %s.", doname(otmp
));
83 if (!uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
84 pline("Not wearing any armor.");
87 otmp
= (!uarmh
&& !uarms
&& !uarmg
) ? uarm
:
88 (!uarms
&& !uarm
&& !uarmg
) ? uarmh
:
89 (!uarmh
&& !uarm
&& !uarmg
) ? uarms
:
90 (!uarmh
&& !uarm
&& !uarms
) ? uarmg
:
91 getobj("[", "take off");
94 if (!(otmp
->owornmask
& (W_ARMOR
- W_ARM2
))) {
95 pline("You can't take that off.");
98 if (otmp
== uarmg
&& uwep
&& uwep
->cursed
) { /* myers@uwmacc */
99 pline("You seem not able to take off the gloves while holding your weapon.");
102 (void) armoroff(otmp
);
109 if (!uleft
&& !uright
) {
110 pline("Not wearing any ring.");
114 return (dorr(uright
));
116 return (dorr(uleft
));
121 pline("What ring, Right or Left? [ rl?]");
122 if (strchr(quitchars
, (answer
= readchar())))
127 return (dorr(uleft
));
130 return (dorr(uright
));
133 /* might look at morc here %% */
156 pline("You can't. It appears to be cursed.");
166 int delay
= -objects
[otmp
->otyp
].oc_delay
;
169 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
172 switch (otmp
->otyp
) {
174 nomovemsg
= "You finished taking off your helmet.";
177 nomovemsg
= "You finished taking off your gloves";
180 nomovemsg
= "You finished taking off your suit.";
196 otmp
= getobj("[", "wear");
199 if (otmp
->owornmask
& W_ARMOR
) {
200 pline("You are already wearing that!");
203 if (otmp
->otyp
== HELMET
) {
205 pline("You are already wearing a helmet.");
209 } else if (otmp
->otyp
== SHIELD
) {
211 pline("You are already wearing a shield."), err
++;
212 if (uwep
&& uwep
->otyp
== TWO_HANDED_SWORD
)
213 pline("You cannot wear a shield and wield a two-handed sword."), err
++;
216 } else if (otmp
->otyp
== PAIR_OF_GLOVES
) {
218 pline("You are already wearing gloves.");
220 } else if (uwep
&& uwep
->cursed
) {
221 pline("You cannot wear gloves over your weapon.");
227 if (otmp
->otyp
!= ELVEN_CLOAK
|| uarm2
) {
228 pline("You are already wearing some armor.");
235 if (otmp
== uwep
&& uwep
->cursed
) {
237 pline("%s is welded to your hand.", Doname(uwep
));
243 setuwep((struct obj
*) 0);
244 delay
= -objects
[otmp
->otyp
].oc_delay
;
247 nomovemsg
= "You finished your dressing manoeuvre.";
260 if (uleft
&& uright
) {
261 pline("There are no more ring-fingers to fill.");
264 otmp
= getobj("=", "wear");
267 if (otmp
->owornmask
& W_RING
) {
268 pline("You are already wearing that!");
271 if (otmp
== uleft
|| otmp
== uright
) {
272 pline("You are already wearing that.");
275 if (otmp
== uwep
&& uwep
->cursed
) {
276 pline("%s is welded to your hand.", Doname(uwep
));
287 pline("What ring-finger, Right or Left? ");
288 if (strchr(quitchars
, (answer
= readchar())))
303 setuwep((struct obj
*) 0);
304 oldprop
= u
.uprops
[PROP(otmp
->otyp
)].p_flgs
;
305 u
.uprops
[PROP(otmp
->otyp
)].p_flgs
|= mask
;
306 switch (otmp
->otyp
) {
311 case RIN_PROTECTION_FROM_SHAPE_CHANGERS
:
314 case RIN_GAIN_STRENGTH
:
316 u
.ustrmax
+= otmp
->spe
;
323 case RIN_INCREASE_DAMAGE
:
324 u
.udaminc
+= otmp
->spe
;
336 mask
= obj
->owornmask
& W_RING
;
337 setworn((struct obj
*) 0, obj
->owornmask
);
338 if (!(u
.uprops
[PROP(obj
->otyp
)].p_flgs
& mask
))
339 impossible("Strange... I didnt know you had that ring.");
340 u
.uprops
[PROP(obj
->otyp
)].p_flgs
&= ~mask
;
342 case RIN_FIRE_RESISTANCE
:
343 /* Bad luck if the player is in hell... --jgm */
344 if (!Fire_resistance
&& dlevel
>= 30) {
345 pline("The flames of Hell burn you to a crisp.");
346 killer
= "stupidity in hell";
351 if (!Levitation
) { /* no longer floating */
355 case RIN_GAIN_STRENGTH
:
357 u
.ustrmax
-= obj
->spe
;
364 case RIN_INCREASE_DAMAGE
:
365 u
.udaminc
-= obj
->spe
;
375 uac
-= ARM_BONUS(uarm
);
377 uac
-= ARM_BONUS(uarm2
);
379 uac
-= ARM_BONUS(uarmh
);
381 uac
-= ARM_BONUS(uarms
);
383 uac
-= ARM_BONUS(uarmg
);
384 if (uleft
&& uleft
->otyp
== RIN_PROTECTION
)
386 if (uright
&& uright
->otyp
== RIN_PROTECTION
)
400 if (uleft
|| uright
) {
401 /* Note: at present also cursed rings fall off */
402 pline("Your %s off your fingers.",
403 (uleft
&& uright
) ? "rings slip" : "ring slips");
405 if ((otmp
= uleft
) != Null(obj
)) {
409 if ((otmp
= uright
) != Null(obj
)) {
414 if ((otmp
= uwep
) != Null(obj
)) {
415 /* Note: at present also cursed weapons fall */
416 setuwep((struct obj
*) 0);
418 pline("Your weapon %sslips from your hands.",
426 struct obj
*otmph
= uarm
;
427 if (uarmh
&& (!otmph
|| !rn2(4)))
429 if (uarmg
&& (!otmph
|| !rn2(4)))
431 if (uarms
&& (!otmph
|| !rn2(4)))
439 struct obj
*otmph
= some_armor();
441 if (otmph
->rustfree
||
442 otmph
->otyp
== ELVEN_CLOAK
||
443 otmph
->otyp
== LEATHER_ARMOR
||
444 otmph
->otyp
== STUDDED_LEATHER_ARMOR
) {
445 pline("Your %s not affected!",
446 aobjnam(otmph
, "are"));
449 pline("Your %s!", aobjnam(otmph
, "corrode"));