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 $");
73 off_msg(struct obj
*otmp
)
75 pline("You were wearing %s.", doname(otmp
));
82 if (!uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
83 pline("Not wearing any armor.");
86 otmp
= (!uarmh
&& !uarms
&& !uarmg
) ? uarm
:
87 (!uarms
&& !uarm
&& !uarmg
) ? uarmh
:
88 (!uarmh
&& !uarm
&& !uarmg
) ? uarms
:
89 (!uarmh
&& !uarm
&& !uarms
) ? uarmg
:
90 getobj("[", "take off");
93 if (!(otmp
->owornmask
& (W_ARMOR
- W_ARM2
))) {
94 pline("You can't take that off.");
97 if (otmp
== uarmg
&& uwep
&& uwep
->cursed
) { /* myers@uwmacc */
98 pline("You seem not able to take off the gloves while holding your weapon.");
101 (void) armoroff(otmp
);
108 if (!uleft
&& !uright
) {
109 pline("Not wearing any ring.");
113 return (dorr(uright
));
115 return (dorr(uleft
));
120 pline("What ring, Right or Left? [ rl?]");
121 if (strchr(quitchars
, (answer
= readchar())))
126 return (dorr(uleft
));
129 return (dorr(uright
));
132 /* might look at morc here %% */
140 dorr(struct obj
*otmp
)
150 cursed(struct obj
*otmp
)
153 pline("You can't. It appears to be cursed.");
160 armoroff(struct obj
*otmp
)
162 int delay
= -objects
[otmp
->otyp
].oc_delay
;
165 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
168 switch (otmp
->otyp
) {
170 nomovemsg
= "You finished taking off your helmet.";
173 nomovemsg
= "You finished taking off your gloves";
176 nomovemsg
= "You finished taking off your suit.";
192 otmp
= getobj("[", "wear");
195 if (otmp
->owornmask
& W_ARMOR
) {
196 pline("You are already wearing that!");
199 if (otmp
->otyp
== HELMET
) {
201 pline("You are already wearing a helmet.");
205 } else if (otmp
->otyp
== SHIELD
) {
207 pline("You are already wearing a shield."), err
++;
208 if (uwep
&& uwep
->otyp
== TWO_HANDED_SWORD
)
209 pline("You cannot wear a shield and wield a two-handed sword."), err
++;
212 } else if (otmp
->otyp
== PAIR_OF_GLOVES
) {
214 pline("You are already wearing gloves.");
216 } else if (uwep
&& uwep
->cursed
) {
217 pline("You cannot wear gloves over your weapon.");
223 if (otmp
->otyp
!= ELVEN_CLOAK
|| uarm2
) {
224 pline("You are already wearing some armor.");
231 if (otmp
== uwep
&& uwep
->cursed
) {
233 pline("%s is welded to your hand.", Doname(uwep
));
239 setuwep((struct obj
*) 0);
240 delay
= -objects
[otmp
->otyp
].oc_delay
;
243 nomovemsg
= "You finished your dressing manoeuvre.";
256 if (uleft
&& uright
) {
257 pline("There are no more ring-fingers to fill.");
260 otmp
= getobj("=", "wear");
263 if (otmp
->owornmask
& W_RING
) {
264 pline("You are already wearing that!");
267 if (otmp
== uleft
|| otmp
== uright
) {
268 pline("You are already wearing that.");
271 if (otmp
== uwep
&& uwep
->cursed
) {
272 pline("%s is welded to your hand.", Doname(uwep
));
283 pline("What ring-finger, Right or Left? ");
284 if (strchr(quitchars
, (answer
= readchar())))
299 setuwep((struct obj
*) 0);
300 oldprop
= u
.uprops
[PROP(otmp
->otyp
)].p_flgs
;
301 u
.uprops
[PROP(otmp
->otyp
)].p_flgs
|= mask
;
302 switch (otmp
->otyp
) {
307 case RIN_PROTECTION_FROM_SHAPE_CHANGERS
:
310 case RIN_GAIN_STRENGTH
:
312 u
.ustrmax
+= otmp
->spe
;
319 case RIN_INCREASE_DAMAGE
:
320 u
.udaminc
+= otmp
->spe
;
328 ringoff(struct obj
*obj
)
331 mask
= obj
->owornmask
& W_RING
;
332 setworn((struct obj
*) 0, obj
->owornmask
);
333 if (!(u
.uprops
[PROP(obj
->otyp
)].p_flgs
& mask
))
334 impossible("Strange... I didnt know you had that ring.");
335 u
.uprops
[PROP(obj
->otyp
)].p_flgs
&= ~mask
;
337 case RIN_FIRE_RESISTANCE
:
338 /* Bad luck if the player is in hell... --jgm */
339 if (!Fire_resistance
&& dlevel
>= 30) {
340 pline("The flames of Hell burn you to a crisp.");
341 killer
= "stupidity in hell";
346 if (!Levitation
) { /* no longer floating */
350 case RIN_GAIN_STRENGTH
:
352 u
.ustrmax
-= obj
->spe
;
359 case RIN_INCREASE_DAMAGE
:
360 u
.udaminc
-= obj
->spe
;
370 uac
-= ARM_BONUS(uarm
);
372 uac
-= ARM_BONUS(uarm2
);
374 uac
-= ARM_BONUS(uarmh
);
376 uac
-= ARM_BONUS(uarms
);
378 uac
-= ARM_BONUS(uarmg
);
379 if (uleft
&& uleft
->otyp
== RIN_PROTECTION
)
381 if (uright
&& uright
->otyp
== RIN_PROTECTION
)
395 if (uleft
|| uright
) {
396 /* Note: at present also cursed rings fall off */
397 pline("Your %s off your fingers.",
398 (uleft
&& uright
) ? "rings slip" : "ring slips");
400 if ((otmp
= uleft
) != Null(obj
)) {
404 if ((otmp
= uright
) != Null(obj
)) {
409 if ((otmp
= uwep
) != Null(obj
)) {
410 /* Note: at present also cursed weapons fall */
411 setuwep((struct obj
*) 0);
413 pline("Your weapon %sslips from your hands.",
421 struct obj
*otmph
= uarm
;
422 if (uarmh
&& (!otmph
|| !rn2(4)))
424 if (uarmg
&& (!otmph
|| !rn2(4)))
426 if (uarms
&& (!otmph
|| !rn2(4)))
434 struct obj
*otmph
= some_armor();
436 if (otmph
->rustfree
||
437 otmph
->otyp
== ELVEN_CLOAK
||
438 otmph
->otyp
== LEATHER_ARMOR
||
439 otmph
->otyp
== STUDDED_LEATHER_ARMOR
) {
440 pline("Your %s not affected!",
441 aobjnam(otmph
, "are"));
444 pline("Your %s!", aobjnam(otmph
, "corrode"));