home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / misc / 39 / do_wear1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-07-17  |  2.3 KB  |  106 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  2. /* do_wear.c - version 1.0.3 */
  3.  
  4. #include <stdio.h>
  5. #include "hack.h"
  6. extern char *nomovemsg;
  7. extern char quitchars[];
  8.  
  9. off_msg(otmp) register struct obj *otmp; {
  10.     pline("You were wearing %s.", doname(otmp));
  11. }
  12.  
  13. doremarm() {
  14.     register struct obj *otmp;
  15.     if(!uarm && !uarmh && !uarms && !uarmg) {
  16.         pline("Not wearing any armor.");
  17.         return(0);
  18.     }
  19.     otmp = (!uarmh && !uarms && !uarmg) ? uarm :
  20.         (!uarms && !uarm && !uarmg) ? uarmh :
  21.         (!uarmh && !uarm && !uarmg) ? uarms :
  22.         (!uarmh && !uarm && !uarms) ? uarmg :
  23.         getobj("[", "take off");
  24.     if(!otmp) return(0);
  25.     if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
  26.         pline("You can't take that off.");
  27.         return(0);
  28.     }
  29.     if( otmp == uarmg && uwep && uwep->cursed ) {    /* myers@uwmacc */
  30.  pline("You seem not able to take off the gloves while holding your weapon.");
  31.         return(0);
  32.     }
  33.     (void) armoroff(otmp);
  34.     return(1);
  35. }
  36.  
  37. doremring() {
  38.     if(!uleft && !uright){
  39.         pline("Not wearing any ring.");
  40.         return(0);
  41.     }
  42.     if(!uleft)
  43.         return(dorr(uright));
  44.     if(!uright)
  45.         return(dorr(uleft));
  46.     if(uleft && uright) while(1) {
  47.         char answer;
  48.  
  49.         pline("What ring, Right or Left? [ rl?]");
  50.         if(index(quitchars, (answer = readchar())))
  51.             return(0);
  52.         switch(answer) {
  53.         case 'l':
  54.         case 'L':
  55.             return(dorr(uleft));
  56.         case 'r':
  57.         case 'R':
  58.             return(dorr(uright));
  59.         case '?':
  60.             (void) doprring();
  61.             /* might look at morc here %% */
  62.         }
  63.     }
  64.     /* NOTREACHED */
  65. #ifdef lint
  66.     return(0);
  67. #endif lint
  68. }
  69.  
  70. dorr(otmp) register struct obj *otmp; {
  71.     if(cursed(otmp)) return(0);
  72.     ringoff(otmp);
  73.     off_msg(otmp);
  74.     return(1);
  75. }
  76.  
  77. cursed(otmp) register struct obj *otmp; {
  78.     if(otmp->cursed){
  79.         pline("You can't. It appears to be cursed.");
  80.         return(1);
  81.     }
  82.     return(0);
  83. }
  84.  
  85. armoroff(otmp) register struct obj *otmp; {
  86. register int delay = -objects[otmp->otyp].oc_delay;
  87.     if(cursed(otmp)) return(0);
  88.     setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
  89.     if(delay) {
  90.         nomul(delay);
  91.         switch(otmp->otyp) {
  92.         case HELMET:
  93.             nomovemsg = "You finished taking off your helmet.";
  94.             break;
  95.         case PAIR_OF_GLOVES:
  96.             nomovemsg = "You finished taking off your gloves";
  97.             break;
  98.         default:
  99.             nomovemsg = "You finished taking off your suit.";
  100.         }
  101.     } else {
  102.         off_msg(otmp);
  103.     }
  104.     return(1);
  105. }
  106.