1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.do_wear.c - version 1.0.3 */
3 /* $FreeBSD: src/games/hack/hack.do_wear.c,v 1.3 1999/11/16 02:57:03 billf Exp $ */
4 /* $DragonFly: src/games/hack/hack.do_wear.c,v 1.6 2008/04/20 13:44:24 swildner Exp $ */
7 extern char quitchars[];
9 static void off_msg(struct obj *);
10 static int dorr(struct obj *);
11 static bool cursed(struct obj *);
14 off_msg(struct obj *otmp)
16 pline("You were wearing %s.", doname(otmp));
24 if (!uarm && !uarmh && !uarms && !uarmg) {
25 pline("Not wearing any armor.");
28 otmp = (!uarmh && !uarms && !uarmg) ? uarm :
29 (!uarms && !uarm && !uarmg) ? uarmh :
30 (!uarmh && !uarm && !uarmg) ? uarms :
31 (!uarmh && !uarm && !uarms) ? uarmg :
32 getobj("[", "take off");
35 if (!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
36 pline("You can't take that off.");
39 if (otmp == uarmg && uwep && uwep->cursed) { /* myers@uwmacc */
40 pline("You seem not able to take off the gloves while holding your weapon.");
50 if (!uleft && !uright) {
51 pline("Not wearing any ring.");
55 return (dorr(uright));
62 pline("What ring, Right or Left? [ rl?]");
63 if (strchr(quitchars, (answer = readchar())))
71 return (dorr(uright));
74 /* might look at morc here %% */
82 dorr(struct obj *otmp)
92 cursed(struct obj *otmp)
95 pline("You can't. It appears to be cursed.");
102 armoroff(struct obj *otmp)
104 int delay = -objects[otmp->otyp].oc_delay;
108 setworn(NULL, otmp->owornmask & W_ARMOR);
111 switch (otmp->otyp) {
113 nomovemsg = "You finished taking off your helmet.";
116 nomovemsg = "You finished taking off your gloves";
119 nomovemsg = "You finished taking off your suit.";
134 otmp = getobj("[", "wear");
137 if (otmp->owornmask & W_ARMOR) {
138 pline("You are already wearing that!");
141 if (otmp->otyp == HELMET) {
143 pline("You are already wearing a helmet.");
147 } else if (otmp->otyp == SHIELD) {
149 pline("You are already wearing a shield."), err++;
150 if (uwep && uwep->otyp == TWO_HANDED_SWORD) {
151 pline("You cannot wear a shield and wield a two-handed sword.");
156 } else if (otmp->otyp == PAIR_OF_GLOVES) {
158 pline("You are already wearing gloves.");
160 } else if (uwep && uwep->cursed) {
161 pline("You cannot wear gloves over your weapon.");
167 if (otmp->otyp != ELVEN_CLOAK || uarm2) {
168 pline("You are already wearing some armor.");
175 if (otmp == uwep && uwep->cursed) {
177 pline("%s is welded to your hand.", Doname(uwep));
184 delay = -objects[otmp->otyp].oc_delay;
187 nomovemsg = "You finished your dressing manoeuvre.";
200 if (uleft && uright) {
201 pline("There are no more ring-fingers to fill.");
204 otmp = getobj("=", "wear");
207 if (otmp->owornmask & W_RING) {
208 pline("You are already wearing that!");
211 if (otmp == uleft || otmp == uright) {
212 pline("You are already wearing that.");
215 if (otmp == uwep && uwep->cursed) {
216 pline("%s is welded to your hand.", Doname(uwep));
227 pline("What ring-finger, Right or Left? ");
228 if (strchr(quitchars, (answer = readchar())))
244 oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
245 u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
246 switch (otmp->otyp) {
251 case RIN_PROTECTION_FROM_SHAPE_CHANGERS:
254 case RIN_GAIN_STRENGTH:
256 u.ustrmax += otmp->spe;
263 case RIN_INCREASE_DAMAGE:
264 u.udaminc += otmp->spe;
272 ringoff(struct obj *obj)
276 mask = obj->owornmask & W_RING;
277 setworn(NULL, obj->owornmask);
278 if (!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
279 impossible("Strange... I didn't know you had that ring.");
280 u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
282 case RIN_FIRE_RESISTANCE:
283 /* Bad luck if the player is in hell... --jgm */
284 if (!Fire_resistance && dlevel >= 30) {
285 pline("The flames of Hell burn you to a crisp.");
286 killer = "stupidity in hell";
291 if (!Levitation) /* no longer floating */
294 case RIN_GAIN_STRENGTH:
296 u.ustrmax -= obj->spe;
303 case RIN_INCREASE_DAMAGE:
304 u.udaminc -= obj->spe;
315 uac -= ARM_BONUS(uarm);
317 uac -= ARM_BONUS(uarm2);
319 uac -= ARM_BONUS(uarmh);
321 uac -= ARM_BONUS(uarms);
323 uac -= ARM_BONUS(uarmg);
324 if (uleft && uleft->otyp == RIN_PROTECTION)
326 if (uright && uright->otyp == RIN_PROTECTION)
341 if (uleft || uright) {
342 /* Note: at present also cursed rings fall off */
343 pline("Your %s off your fingers.",
344 (uleft && uright) ? "rings slip" : "ring slips");
346 if ((otmp = uleft) != NULL) {
350 if ((otmp = uright) != NULL) {
355 if ((otmp = uwep) != NULL) {
356 /* Note: at present also cursed weapons fall */
359 pline("Your weapon %sslips from your hands.",
367 struct obj *otmph = uarm;
369 if (uarmh && (!otmph || !rn2(4)))
371 if (uarmg && (!otmph || !rn2(4)))
373 if (uarms && (!otmph || !rn2(4)))
381 struct obj *otmph = some_armor();
384 if (otmph->rustfree ||
385 otmph->otyp == ELVEN_CLOAK ||
386 otmph->otyp == LEATHER_ARMOR ||
387 otmph->otyp == STUDDED_LEATHER_ARMOR) {
388 pline("Your %s not affected!",
389 aobjnam(otmph, "are"));
392 pline("Your %s!", aobjnam(otmph, "corrode"));