1 /* $NetBSD: hack.do_wear.c,v 1.6 2009/06/07 18:30:39 dholland 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.6 2009/06/07 18:30:39 dholland Exp $");
72 static int dorr(struct obj
*);
73 static int cursed(struct obj
*);
76 off_msg(struct obj
*otmp
)
78 pline("You were wearing %s.", doname(otmp
));
85 if (!uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
86 pline("Not wearing any armor.");
89 otmp
= (!uarmh
&& !uarms
&& !uarmg
) ? uarm
:
90 (!uarms
&& !uarm
&& !uarmg
) ? uarmh
:
91 (!uarmh
&& !uarm
&& !uarmg
) ? uarms
:
92 (!uarmh
&& !uarm
&& !uarms
) ? uarmg
:
93 getobj("[", "take off");
96 if (!(otmp
->owornmask
& (W_ARMOR
- W_ARM2
))) {
97 pline("You can't take that off.");
100 if (otmp
== uarmg
&& uwep
&& uwep
->cursed
) { /* myers@uwmacc */
101 pline("You seem not able to take off the gloves while holding your weapon.");
104 (void) armoroff(otmp
);
111 if (!uleft
&& !uright
) {
112 pline("Not wearing any ring.");
116 return (dorr(uright
));
118 return (dorr(uleft
));
123 pline("What ring, Right or Left? [ rl?]");
124 if (strchr(quitchars
, (answer
= readchar())))
129 return (dorr(uleft
));
132 return (dorr(uright
));
135 /* might look at morc here %% */
143 dorr(struct obj
*otmp
)
153 cursed(struct obj
*otmp
)
156 pline("You can't. It appears to be cursed.");
163 armoroff(struct obj
*otmp
)
165 int delay
= -objects
[otmp
->otyp
].oc_delay
;
168 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
171 switch (otmp
->otyp
) {
173 nomovemsg
= "You finished taking off your helmet.";
176 nomovemsg
= "You finished taking off your gloves";
179 nomovemsg
= "You finished taking off your suit.";
195 otmp
= getobj("[", "wear");
198 if (otmp
->owornmask
& W_ARMOR
) {
199 pline("You are already wearing that!");
202 if (otmp
->otyp
== HELMET
) {
204 pline("You are already wearing a helmet.");
208 } else if (otmp
->otyp
== SHIELD
) {
210 pline("You are already wearing a shield."), err
++;
211 if (uwep
&& uwep
->otyp
== TWO_HANDED_SWORD
)
212 pline("You cannot wear a shield and wield a two-handed sword."), err
++;
215 } else if (otmp
->otyp
== PAIR_OF_GLOVES
) {
217 pline("You are already wearing gloves.");
219 } else if (uwep
&& uwep
->cursed
) {
220 pline("You cannot wear gloves over your weapon.");
226 if (otmp
->otyp
!= ELVEN_CLOAK
|| uarm2
) {
227 pline("You are already wearing some armor.");
234 if (otmp
== uwep
&& uwep
->cursed
) {
236 pline("%s is welded to your hand.", Doname(uwep
));
242 setuwep((struct obj
*) 0);
243 delay
= -objects
[otmp
->otyp
].oc_delay
;
246 nomovemsg
= "You finished your dressing manoeuvre.";
259 if (uleft
&& uright
) {
260 pline("There are no more ring-fingers to fill.");
263 otmp
= getobj("=", "wear");
266 if (otmp
->owornmask
& W_RING
) {
267 pline("You are already wearing that!");
270 if (otmp
== uleft
|| otmp
== uright
) {
271 pline("You are already wearing that.");
274 if (otmp
== uwep
&& uwep
->cursed
) {
275 pline("%s is welded to your hand.", Doname(uwep
));
286 pline("What ring-finger, Right or Left? ");
287 if (strchr(quitchars
, (answer
= readchar())))
302 setuwep((struct obj
*) 0);
303 oldprop
= u
.uprops
[PROP(otmp
->otyp
)].p_flgs
;
304 u
.uprops
[PROP(otmp
->otyp
)].p_flgs
|= mask
;
305 switch (otmp
->otyp
) {
310 case RIN_PROTECTION_FROM_SHAPE_CHANGERS
:
313 case RIN_GAIN_STRENGTH
:
315 u
.ustrmax
+= otmp
->spe
;
322 case RIN_INCREASE_DAMAGE
:
323 u
.udaminc
+= otmp
->spe
;
331 ringoff(struct obj
*obj
)
334 mask
= obj
->owornmask
& W_RING
;
335 setworn((struct obj
*) 0, obj
->owornmask
);
336 if (!(u
.uprops
[PROP(obj
->otyp
)].p_flgs
& mask
))
337 impossible("Strange... I didnt know you had that ring.");
338 u
.uprops
[PROP(obj
->otyp
)].p_flgs
&= ~mask
;
340 case RIN_FIRE_RESISTANCE
:
341 /* Bad luck if the player is in hell... --jgm */
342 if (!Fire_resistance
&& dlevel
>= 30) {
343 pline("The flames of Hell burn you to a crisp.");
344 killer
= "stupidity in hell";
349 if (!Levitation
) { /* no longer floating */
353 case RIN_GAIN_STRENGTH
:
355 u
.ustrmax
-= obj
->spe
;
362 case RIN_INCREASE_DAMAGE
:
363 u
.udaminc
-= obj
->spe
;
373 uac
-= ARM_BONUS(uarm
);
375 uac
-= ARM_BONUS(uarm2
);
377 uac
-= ARM_BONUS(uarmh
);
379 uac
-= ARM_BONUS(uarms
);
381 uac
-= ARM_BONUS(uarmg
);
382 if (uleft
&& uleft
->otyp
== RIN_PROTECTION
)
384 if (uright
&& uright
->otyp
== RIN_PROTECTION
)
398 if (uleft
|| uright
) {
399 /* Note: at present also cursed rings fall off */
400 pline("Your %s off your fingers.",
401 (uleft
&& uright
) ? "rings slip" : "ring slips");
403 if ((otmp
= uleft
) != Null(obj
)) {
407 if ((otmp
= uright
) != Null(obj
)) {
412 if ((otmp
= uwep
) != Null(obj
)) {
413 /* Note: at present also cursed weapons fall */
414 setuwep((struct obj
*) 0);
416 pline("Your weapon %sslips from your hands.",
424 struct obj
*otmph
= uarm
;
425 if (uarmh
&& (!otmph
|| !rn2(4)))
427 if (uarmg
&& (!otmph
|| !rn2(4)))
429 if (uarms
&& (!otmph
|| !rn2(4)))
437 struct obj
*otmph
= some_armor();
439 if (otmph
->rustfree
||
440 otmph
->otyp
== ELVEN_CLOAK
||
441 otmph
->otyp
== LEATHER_ARMOR
||
442 otmph
->otyp
== STUDDED_LEATHER_ARMOR
) {
443 pline("Your %s not affected!",
444 aobjnam(otmph
, "are"));
447 pline("Your %s!", aobjnam(otmph
, "corrode"));