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));
23 if(!uarm && !uarmh && !uarms && !uarmg) {
24 pline("Not wearing any armor.");
27 otmp = (!uarmh && !uarms && !uarmg) ? uarm :
28 (!uarms && !uarm && !uarmg) ? uarmh :
29 (!uarmh && !uarm && !uarmg) ? uarms :
30 (!uarmh && !uarm && !uarms) ? uarmg :
31 getobj("[", "take off");
33 if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
34 pline("You can't take that off.");
37 if( otmp == uarmg && uwep && uwep->cursed ) { /* myers@uwmacc */
38 pline("You seem not able to take off the gloves while holding your weapon.");
48 if(!uleft && !uright){
49 pline("Not wearing any ring.");
56 if(uleft && uright) while(1) {
59 pline("What ring, Right or Left? [ rl?]");
60 if(index(quitchars, (answer = readchar())))
71 /* might look at morc here %% */
79 dorr(struct obj *otmp)
81 if(cursed(otmp)) return(0);
88 cursed(struct obj *otmp)
91 pline("You can't. It appears to be cursed.");
99 armoroff(struct obj *otmp)
101 int delay = -objects[otmp->otyp].oc_delay;
102 if(cursed(otmp)) return(0);
103 setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
108 nomovemsg = "You finished taking off your helmet.";
111 nomovemsg = "You finished taking off your gloves";
114 nomovemsg = "You finished taking off your suit.";
130 otmp = getobj("[", "wear");
132 if(otmp->owornmask & W_ARMOR) {
133 pline("You are already wearing that!");
136 if(otmp->otyp == HELMET){
138 pline("You are already wearing a helmet.");
142 } else if(otmp->otyp == SHIELD){
143 if(uarms) pline("You are already wearing a shield."), err++;
144 if(uwep && uwep->otyp == TWO_HANDED_SWORD)
145 pline("You cannot wear a shield and wield a two-handed sword."), err++;
146 if(!err) mask = W_ARMS;
147 } else if(otmp->otyp == PAIR_OF_GLOVES) {
149 pline("You are already wearing gloves.");
152 if(uwep && uwep->cursed) {
153 pline("You cannot wear gloves over your weapon.");
159 if(otmp->otyp != ELVEN_CLOAK || uarm2) {
160 pline("You are already wearing some armor.");
164 if(!err) mask = W_ARM;
166 if(otmp == uwep && uwep->cursed) {
168 pline("%s is welded to your hand.", Doname(uwep));
173 setuwep((struct obj *) 0);
174 delay = -objects[otmp->otyp].oc_delay;
177 nomovemsg = "You finished your dressing manoeuvre.";
191 pline("There are no more ring-fingers to fill.");
194 otmp = getobj("=", "wear");
196 if(otmp->owornmask & W_RING) {
197 pline("You are already wearing that!");
200 if(otmp == uleft || otmp == uright) {
201 pline("You are already wearing that.");
204 if(otmp == uwep && uwep->cursed) {
205 pline("%s is welded to your hand.", Doname(uwep));
208 if(uleft) mask = RIGHT_RING;
209 else if(uright) mask = LEFT_RING;
213 pline("What ring-finger, Right or Left? ");
214 if(index(quitchars, (answer = readchar())))
229 setuwep((struct obj *) 0);
230 oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
231 u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
234 if(!oldprop) float_up();
236 case RIN_PROTECTION_FROM_SHAPE_CHANGERS:
239 case RIN_GAIN_STRENGTH:
241 u.ustrmax += otmp->spe;
242 if(u.ustr > 118) u.ustr = 118;
243 if(u.ustrmax > 118) u.ustrmax = 118;
246 case RIN_INCREASE_DAMAGE:
247 u.udaminc += otmp->spe;
255 ringoff(struct obj *obj)
258 mask = obj->owornmask & W_RING;
259 setworn((struct obj *) 0, obj->owornmask);
260 if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
261 impossible("Strange... I didn't know you had that ring.");
262 u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
264 case RIN_FIRE_RESISTANCE:
265 /* Bad luck if the player is in hell... --jgm */
266 if (!Fire_resistance && dlevel >= 30) {
267 pline("The flames of Hell burn you to a crisp.");
268 killer = "stupidity in hell";
273 if(!Levitation) { /* no longer floating */
277 case RIN_GAIN_STRENGTH:
279 u.ustrmax -= obj->spe;
280 if(u.ustr > 118) u.ustr = 118;
281 if(u.ustrmax > 118) u.ustrmax = 118;
284 case RIN_INCREASE_DAMAGE:
285 u.udaminc -= obj->spe;
294 if(uarm) uac -= ARM_BONUS(uarm);
295 if(uarm2) uac -= ARM_BONUS(uarm2);
296 if(uarmh) uac -= ARM_BONUS(uarmh);
297 if(uarms) uac -= ARM_BONUS(uarms);
298 if(uarmg) uac -= ARM_BONUS(uarmg);
299 if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
300 if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
312 if(!uarmg) if(uleft || uright) {
313 /* Note: at present also cursed rings fall off */
314 pline("Your %s off your fingers.",
315 (uleft && uright) ? "rings slip" : "ring slips");
317 if((otmp = uleft) != Null(obj)){
321 if((otmp = uright) != Null(obj)){
326 if((otmp = uwep) != Null(obj)){
327 /* Note: at present also cursed weapons fall */
328 setuwep((struct obj *) 0);
330 pline("Your weapon %sslips from your hands.",
338 struct obj *otmph = uarm;
339 if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
340 if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
341 if(uarms && (!otmph || !rn2(4))) otmph = uarms;
348 struct obj *otmph = some_armor();
350 if(otmph->rustfree ||
351 otmph->otyp == ELVEN_CLOAK ||
352 otmph->otyp == LEATHER_ARMOR ||
353 otmph->otyp == STUDDED_LEATHER_ARMOR) {
354 pline("Your %s not affected!",
355 aobjnam(otmph, "are"));
358 pline("Your %s!", aobjnam(otmph, "corrode"));