1 /* $NetBSD: hack.do_wear.c,v 1.7 2009/08/12 07:28:40 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.
67 static int dorr(struct obj
*);
68 static int cursed(struct obj
*);
71 off_msg(struct obj
*otmp
)
73 pline("You were wearing %s.", doname(otmp
));
80 if (!uarm
&& !uarmh
&& !uarms
&& !uarmg
) {
81 pline("Not wearing any armor.");
84 otmp
= (!uarmh
&& !uarms
&& !uarmg
) ? uarm
:
85 (!uarms
&& !uarm
&& !uarmg
) ? uarmh
:
86 (!uarmh
&& !uarm
&& !uarmg
) ? uarms
:
87 (!uarmh
&& !uarm
&& !uarms
) ? uarmg
:
88 getobj("[", "take off");
91 if (!(otmp
->owornmask
& (W_ARMOR
- W_ARM2
))) {
92 pline("You can't take that off.");
95 if (otmp
== uarmg
&& uwep
&& uwep
->cursed
) { /* myers@uwmacc */
96 pline("You seem not able to take off the gloves while holding your weapon.");
99 (void) armoroff(otmp
);
106 if (!uleft
&& !uright
) {
107 pline("Not wearing any ring.");
111 return (dorr(uright
));
113 return (dorr(uleft
));
118 pline("What ring, Right or Left? [ rl?]");
119 if (strchr(quitchars
, (answer
= readchar())))
124 return (dorr(uleft
));
127 return (dorr(uright
));
130 /* might look at morc here %% */
138 dorr(struct obj
*otmp
)
148 cursed(struct obj
*otmp
)
151 pline("You can't. It appears to be cursed.");
158 armoroff(struct obj
*otmp
)
160 int delay
= -objects
[otmp
->otyp
].oc_delay
;
163 setworn((struct obj
*) 0, otmp
->owornmask
& W_ARMOR
);
166 switch (otmp
->otyp
) {
168 nomovemsg
= "You finished taking off your helmet.";
171 nomovemsg
= "You finished taking off your gloves";
174 nomovemsg
= "You finished taking off your suit.";
190 otmp
= getobj("[", "wear");
193 if (otmp
->owornmask
& W_ARMOR
) {
194 pline("You are already wearing that!");
197 if (otmp
->otyp
== HELMET
) {
199 pline("You are already wearing a helmet.");
203 } else if (otmp
->otyp
== SHIELD
) {
205 pline("You are already wearing a shield."), err
++;
206 if (uwep
&& uwep
->otyp
== TWO_HANDED_SWORD
)
207 pline("You cannot wear a shield and wield a two-handed sword."), err
++;
210 } else if (otmp
->otyp
== PAIR_OF_GLOVES
) {
212 pline("You are already wearing gloves.");
214 } else if (uwep
&& uwep
->cursed
) {
215 pline("You cannot wear gloves over your weapon.");
221 if (otmp
->otyp
!= ELVEN_CLOAK
|| uarm2
) {
222 pline("You are already wearing some armor.");
229 if (otmp
== uwep
&& uwep
->cursed
) {
231 pline("%s is welded to your hand.", Doname(uwep
));
237 setuwep((struct obj
*) 0);
238 delay
= -objects
[otmp
->otyp
].oc_delay
;
241 nomovemsg
= "You finished your dressing manoeuvre.";
254 if (uleft
&& uright
) {
255 pline("There are no more ring-fingers to fill.");
258 otmp
= getobj("=", "wear");
261 if (otmp
->owornmask
& W_RING
) {
262 pline("You are already wearing that!");
265 if (otmp
== uleft
|| otmp
== uright
) {
266 pline("You are already wearing that.");
269 if (otmp
== uwep
&& uwep
->cursed
) {
270 pline("%s is welded to your hand.", Doname(uwep
));
281 pline("What ring-finger, Right or Left? ");
282 if (strchr(quitchars
, (answer
= readchar())))
297 setuwep((struct obj
*) 0);
298 oldprop
= u
.uprops
[PROP(otmp
->otyp
)].p_flgs
;
299 u
.uprops
[PROP(otmp
->otyp
)].p_flgs
|= mask
;
300 switch (otmp
->otyp
) {
305 case RIN_PROTECTION_FROM_SHAPE_CHANGERS
:
308 case RIN_GAIN_STRENGTH
:
310 u
.ustrmax
+= otmp
->spe
;
317 case RIN_INCREASE_DAMAGE
:
318 u
.udaminc
+= otmp
->spe
;
326 ringoff(struct obj
*obj
)
329 mask
= obj
->owornmask
& W_RING
;
330 setworn((struct obj
*) 0, obj
->owornmask
);
331 if (!(u
.uprops
[PROP(obj
->otyp
)].p_flgs
& mask
))
332 impossible("Strange... I didn't know you had that ring.");
333 u
.uprops
[PROP(obj
->otyp
)].p_flgs
&= ~mask
;
335 case RIN_FIRE_RESISTANCE
:
336 /* Bad luck if the player is in hell... --jgm */
337 if (!Fire_resistance
&& dlevel
>= 30) {
338 pline("The flames of Hell burn you to a crisp.");
339 killer
= "stupidity in hell";
344 if (!Levitation
) { /* no longer floating */
348 case RIN_GAIN_STRENGTH
:
350 u
.ustrmax
-= obj
->spe
;
357 case RIN_INCREASE_DAMAGE
:
358 u
.udaminc
-= obj
->spe
;
368 uac
-= ARM_BONUS(uarm
);
370 uac
-= ARM_BONUS(uarm2
);
372 uac
-= ARM_BONUS(uarmh
);
374 uac
-= ARM_BONUS(uarms
);
376 uac
-= ARM_BONUS(uarmg
);
377 if (uleft
&& uleft
->otyp
== RIN_PROTECTION
)
379 if (uright
&& uright
->otyp
== RIN_PROTECTION
)
393 if (uleft
|| uright
) {
394 /* Note: at present also cursed rings fall off */
395 pline("Your %s off your fingers.",
396 (uleft
&& uright
) ? "rings slip" : "ring slips");
398 if ((otmp
= uleft
) != Null(obj
)) {
402 if ((otmp
= uright
) != Null(obj
)) {
407 if ((otmp
= uwep
) != Null(obj
)) {
408 /* Note: at present also cursed weapons fall */
409 setuwep((struct obj
*) 0);
411 pline("Your weapon %sslips from your hands.",
419 struct obj
*otmph
= uarm
;
420 if (uarmh
&& (!otmph
|| !rn2(4)))
422 if (uarmg
&& (!otmph
|| !rn2(4)))
424 if (uarms
&& (!otmph
|| !rn2(4)))
432 struct obj
*otmph
= some_armor();
434 if (otmph
->rustfree
||
435 otmph
->otyp
== ELVEN_CLOAK
||
436 otmph
->otyp
== LEATHER_ARMOR
||
437 otmph
->otyp
== STUDDED_LEATHER_ARMOR
) {
438 pline("Your %s not affected!",
439 aobjnam(otmph
, "are"));
442 pline("Your %s!", aobjnam(otmph
, "corrode"));