1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
   2: /* hack.do_wear.c - version 1.0.3 */
   3: 
   4: #include "hack.h"
   5: #include <stdio.h>
   6: extern char *nomovemsg;
   7: extern char quitchars[];
   8: extern char *Doname();
   9: 
  10: off_msg(otmp) register struct obj *otmp; {
  11:     pline("You were wearing %s.", doname(otmp));
  12: }
  13: 
  14: doremarm() {
  15:     register struct obj *otmp;
  16:     if(!uarm && !uarmh && !uarms && !uarmg) {
  17:         pline("Not wearing any armor.");
  18:         return(0);
  19:     }
  20:     otmp = (!uarmh && !uarms && !uarmg) ? uarm :
  21:         (!uarms && !uarm && !uarmg) ? uarmh :
  22:         (!uarmh && !uarm && !uarmg) ? uarms :
  23:         (!uarmh && !uarm && !uarms) ? uarmg :
  24:         getobj("[", "take off");
  25:     if(!otmp) return(0);
  26:     if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
  27:         pline("You can't take that off.");
  28:         return(0);
  29:     }
  30:     if( otmp == uarmg && uwep && uwep->cursed ) {   /* myers@uwmacc */
  31:  pline("You seem not able to take off the gloves while holding your weapon.");
  32:         return(0);
  33:     }
  34:     (void) armoroff(otmp);
  35:     return(1);
  36: }
  37: 
  38: doremring() {
  39:     if(!uleft && !uright){
  40:         pline("Not wearing any ring.");
  41:         return(0);
  42:     }
  43:     if(!uleft)
  44:         return(dorr(uright));
  45:     if(!uright)
  46:         return(dorr(uleft));
  47:     if(uleft && uright) while(1) {
  48:         char answer;
  49: 
  50:         pline("What ring, Right or Left? [ rl?]");
  51:         if(index(quitchars, (answer = readchar())))
  52:             return(0);
  53:         switch(answer) {
  54:         case 'l':
  55:         case 'L':
  56:             return(dorr(uleft));
  57:         case 'r':
  58:         case 'R':
  59:             return(dorr(uright));
  60:         case '?':
  61:             (void) doprring();
  62:             /* might look at morc here %% */
  63:         }
  64:     }
  65:     /* NOTREACHED */
  66: #ifdef lint
  67:     return(0);
  68: #endif lint
  69: }
  70: 
  71: dorr(otmp) register struct obj *otmp; {
  72:     if(cursed(otmp)) return(0);
  73:     ringoff(otmp);
  74:     off_msg(otmp);
  75:     return(1);
  76: }
  77: 
  78: cursed(otmp) register struct obj *otmp; {
  79:     if(otmp->cursed){
  80:         pline("You can't. It appears to be cursed.");
  81:         return(1);
  82:     }
  83:     return(0);
  84: }
  85: 
  86: armoroff(otmp) register struct obj *otmp; {
  87: register int delay = -objects[otmp->otyp].oc_delay;
  88:     if(cursed(otmp)) return(0);
  89:     setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
  90:     if(delay) {
  91:         nomul(delay);
  92:         switch(otmp->otyp) {
  93:         case HELMET:
  94:             nomovemsg = "You finished taking off your helmet.";
  95:             break;
  96:         case PAIR_OF_GLOVES:
  97:             nomovemsg = "You finished taking off your gloves";
  98:             break;
  99:         default:
 100:             nomovemsg = "You finished taking off your suit.";
 101:         }
 102:     } else {
 103:         off_msg(otmp);
 104:     }
 105:     return(1);
 106: }
 107: 
 108: doweararm() {
 109:     register struct obj *otmp;
 110:     register int delay;
 111:     register int err = 0;
 112:     long mask = 0;
 113: 
 114:     otmp = getobj("[", "wear");
 115:     if(!otmp) return(0);
 116:     if(otmp->owornmask & W_ARMOR) {
 117:         pline("You are already wearing that!");
 118:         return(0);
 119:     }
 120:     if(otmp->otyp == HELMET){
 121:         if(uarmh) {
 122:             pline("You are already wearing a helmet.");
 123:             err++;
 124:         } else
 125:             mask = W_ARMH;
 126:     } else if(otmp->otyp == SHIELD){
 127:         if(uarms) pline("You are already wearing a shield."), err++;
 128:         if(uwep && uwep->otyp == TWO_HANDED_SWORD)
 129:     pline("You cannot wear a shield and wield a two-handed sword."), err++;
 130:         if(!err) mask = W_ARMS;
 131:     } else if(otmp->otyp == PAIR_OF_GLOVES) {
 132:         if(uarmg) {
 133:             pline("You are already wearing gloves.");
 134:             err++;
 135:         } else
 136:         if(uwep && uwep->cursed) {
 137:             pline("You cannot wear gloves over your weapon.");
 138:             err++;
 139:         } else
 140:             mask = W_ARMG;
 141:     } else {
 142:         if(uarm) {
 143:             if(otmp->otyp != ELVEN_CLOAK || uarm2) {
 144:                 pline("You are already wearing some armor.");
 145:                 err++;
 146:             }
 147:         }
 148:         if(!err) mask = W_ARM;
 149:     }
 150:     if(otmp == uwep && uwep->cursed) {
 151:         if(!err++)
 152:             pline("%s is welded to your hand.", Doname(uwep));
 153:     }
 154:     if(err) return(0);
 155:     setworn(otmp, mask);
 156:     if(otmp == uwep)
 157:         setuwep((struct obj *) 0);
 158:     delay = -objects[otmp->otyp].oc_delay;
 159:     if(delay){
 160:         nomul(delay);
 161:         nomovemsg = "You finished your dressing manoeuvre.";
 162:     }
 163:     otmp->known = 1;
 164:     return(1);
 165: }
 166: 
 167: dowearring() {
 168:     register struct obj *otmp;
 169:     long mask = 0;
 170:     long oldprop;
 171: 
 172:     if(uleft && uright){
 173:         pline("There are no more ring-fingers to fill.");
 174:         return(0);
 175:     }
 176:     otmp = getobj("=", "wear");
 177:     if(!otmp) return(0);
 178:     if(otmp->owornmask & W_RING) {
 179:         pline("You are already wearing that!");
 180:         return(0);
 181:     }
 182:     if(otmp == uleft || otmp == uright) {
 183:         pline("You are already wearing that.");
 184:         return(0);
 185:     }
 186:     if(otmp == uwep && uwep->cursed) {
 187:         pline("%s is welded to your hand.", Doname(uwep));
 188:         return(0);
 189:     }
 190:     if(uleft) mask = RIGHT_RING;
 191:     else if(uright) mask = LEFT_RING;
 192:     else do {
 193:         char answer;
 194: 
 195:         pline("What ring-finger, Right or Left? ");
 196:         if(index(quitchars, (answer = readchar())))
 197:             return(0);
 198:         switch(answer){
 199:         case 'l':
 200:         case 'L':
 201:             mask = LEFT_RING;
 202:             break;
 203:         case 'r':
 204:         case 'R':
 205:             mask = RIGHT_RING;
 206:             break;
 207:         }
 208:     } while(!mask);
 209:     setworn(otmp, mask);
 210:     if(otmp == uwep)
 211:         setuwep((struct obj *) 0);
 212:     oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
 213:     u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
 214:     switch(otmp->otyp){
 215:     case RIN_LEVITATION:
 216:         if(!oldprop) float_up();
 217:         break;
 218:     case RIN_PROTECTION_FROM_SHAPE_CHANGERS:
 219:         rescham();
 220:         break;
 221:     case RIN_GAIN_STRENGTH:
 222:         u.ustr += otmp->spe;
 223:         u.ustrmax += otmp->spe;
 224:         if(u.ustr > 118) u.ustr = 118;
 225:         if(u.ustrmax > 118) u.ustrmax = 118;
 226:         flags.botl = 1;
 227:         break;
 228:     case RIN_INCREASE_DAMAGE:
 229:         u.udaminc += otmp->spe;
 230:         break;
 231:     }
 232:     prinv(otmp);
 233:     return(1);
 234: }
 235: 
 236: ringoff(obj)
 237: register struct obj *obj;
 238: {
 239: register long mask;
 240:     mask = obj->owornmask & W_RING;
 241:     setworn((struct obj *) 0, obj->owornmask);
 242:     if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
 243:         impossible("Strange... I didnt know you had that ring.");
 244:     u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
 245:     switch(obj->otyp) {
 246:     case RIN_FIRE_RESISTANCE:
 247:         /* Bad luck if the player is in hell... --jgm */
 248:         if (!Fire_resistance && dlevel >= 30) {
 249:             pline("The flames of Hell burn you to a crisp.");
 250:             killer = "stupidity in hell";
 251:             done("burned");
 252:         }
 253:         break;
 254:     case RIN_LEVITATION:
 255:         if(!Levitation) {   /* no longer floating */
 256:             float_down();
 257:         }
 258:         break;
 259:     case RIN_GAIN_STRENGTH:
 260:         u.ustr -= obj->spe;
 261:         u.ustrmax -= obj->spe;
 262:         if(u.ustr > 118) u.ustr = 118;
 263:         if(u.ustrmax > 118) u.ustrmax = 118;
 264:         flags.botl = 1;
 265:         break;
 266:     case RIN_INCREASE_DAMAGE:
 267:         u.udaminc -= obj->spe;
 268:         break;
 269:     }
 270: }
 271: 
 272: find_ac(){
 273: register int uac = 10;
 274:     if(uarm) uac -= ARM_BONUS(uarm);
 275:     if(uarm2) uac -= ARM_BONUS(uarm2);
 276:     if(uarmh) uac -= ARM_BONUS(uarmh);
 277:     if(uarms) uac -= ARM_BONUS(uarms);
 278:     if(uarmg) uac -= ARM_BONUS(uarmg);
 279:     if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
 280:     if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
 281:     if(uac != u.uac){
 282:         u.uac = uac;
 283:         flags.botl = 1;
 284:     }
 285: }
 286: 
 287: glibr(){
 288: register struct obj *otmp;
 289: int xfl = 0;
 290:     if(!uarmg) if(uleft || uright) {
 291:         /* Note: at present also cursed rings fall off */
 292:         pline("Your %s off your fingers.",
 293:             (uleft && uright) ? "rings slip" : "ring slips");
 294:         xfl++;
 295:         if((otmp = uleft) != Null(obj)){
 296:             ringoff(uleft);
 297:             dropx(otmp);
 298:         }
 299:         if((otmp = uright) != Null(obj)){
 300:             ringoff(uright);
 301:             dropx(otmp);
 302:         }
 303:     }
 304:     if((otmp = uwep) != Null(obj)){
 305:         /* Note: at present also cursed weapons fall */
 306:         setuwep((struct obj *) 0);
 307:         dropx(otmp);
 308:         pline("Your weapon %sslips from your hands.",
 309:             xfl ? "also " : "");
 310:     }
 311: }
 312: 
 313: struct obj *
 314: some_armor(){
 315: register struct obj *otmph = uarm;
 316:     if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
 317:     if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
 318:     if(uarms && (!otmph || !rn2(4))) otmph = uarms;
 319:     return(otmph);
 320: }
 321: 
 322: corrode_armor(){
 323: register struct obj *otmph = some_armor();
 324:     if(otmph){
 325:         if(otmph->rustfree ||
 326:            otmph->otyp == ELVEN_CLOAK ||
 327:            otmph->otyp == LEATHER_ARMOR ||
 328:            otmph->otyp == STUDDED_LEATHER_ARMOR) {
 329:             pline("Your %s not affected!",
 330:                 aobjnam(otmph, "are"));
 331:             return;
 332:         }
 333:         pline("Your %s!", aobjnam(otmph, "corrode"));
 334:         otmph->spe--;
 335:     }
 336: }

Defined functions

armoroff defined in line 86; used 2 times
corrode_armor defined in line 322; never used
cursed defined in line 78; used 7 times
doremarm defined in line 14; used 2 times
doremring defined in line 38; used 2 times
dorr defined in line 71; used 4 times
doweararm defined in line 108; used 2 times
dowearring defined in line 167; used 2 times
glibr defined in line 287; used 1 times
off_msg defined in line 10; used 2 times
ringoff defined in line 236; used 4 times
some_armor defined in line 313; used 4 times
Last modified: 1985-10-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3102
Valid CSS Valid XHTML 1.0 Strict