[BACK]Return to armor.c CVS log [TXT][DIR] Up to [contributed] / early-roguelike / urogue

Annotation of early-roguelike/urogue/armor.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:     armor.c  -  functions for dealing with armor
                      3:
                      4:     UltraRogue: The Ultimate Adventure in the Dungeons of Doom
                      5:     Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong
                      6:     All rights reserved.
                      7:
                      8:     Based on "Advanced Rogue"
                      9:     Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka
                     10:     All rights reserved.
                     11:
                     12:     Based on "Rogue: Exploring the Dungeons of Doom"
                     13:     Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
                     14:     All rights reserved.
                     15:
                     16:     See the file LICENSE.TXT for full copyright and licensing information.
                     17: */
                     18:
                     19: #include "rogue.h"
                     20:
                     21: /*
                     22:     wear()
                     23:         The player wants to wear something, so let him/her put it on.
                     24: */
                     25:
                     26: void
                     27: wear(void)
                     28: {
                     29:     struct object *obj;
                     30:
                     31:     if (cur_armor != NULL)
                     32:     {
                     33:         msg("You are already wearing some.");
                     34:
                     35:         after = FALSE;
                     36:
                     37:         return;
                     38:     }
                     39:
                     40:     /* What does player want to wear? */
                     41:
                     42:     if ((obj = get_object(pack, "wear", ARMOR, NULL)) == NULL)
                     43:         return;
                     44:
                     45:     wear_ok(&player, obj, MESSAGE);
                     46:     waste_time();
                     47:
                     48:     cur_armor = obj;
                     49:     obj->o_flags |= ISKNOW;
                     50:
                     51:     msg("You are now wearing %s.", inv_name(obj, TRUE));
                     52:
                     53:     return;
                     54: }
                     55:
                     56: /*
                     57:     take_off()
                     58:         Get the armor off of the players back
                     59: */
                     60:
                     61: void
                     62: take_off(void)
                     63: {
                     64:     struct object   *obj;
                     65:
                     66:     if ((obj = cur_armor) == NULL)
                     67:     {
                     68:         msg("You aren't wearing armor!");
                     69:         return;
                     70:     }
                     71:
                     72:     if (!dropcheck(cur_armor))
                     73:         return;
                     74:
                     75:     msg("You were wearing %c%c) %s.", ARMOR, print_letters[get_ident(obj)],
                     76:         inv_name(obj, LOWERCASE));
                     77:
                     78:     cur_armor = NULL;
                     79:
                     80:     if (on(player, STUMBLER))
                     81:     {
                     82:         msg("Your foot feels a lot better now.");
                     83:         turn_off(player, STUMBLER);
                     84:     }
                     85: }
                     86:
                     87: /*
                     88:     wear_ok()
                     89:         enforce player class armor restrictions
                     90: */
                     91:
                     92: int
                     93: wear_ok(struct thing *wearee, struct object *obj, int print_message)
                     94: {
                     95:     int which      = obj->o_which;
                     96:     int ret_val    = TRUE;
                     97:     int class_type = wearee->t_ctype;
                     98:
                     99:     if (obj->o_type != ARMOR)
                    100:         return(FALSE);
                    101:     else
                    102:         switch (class_type)
                    103:         {
                    104:             case C_MAGICIAN: /* cannot wear metal */
                    105:             case C_ILLUSION:
                    106:                 switch (which)
                    107:                 {
                    108:                     case RING_MAIL:
                    109:                     case SCALE_MAIL:
                    110:                     case PADDED_ARMOR:
                    111:                     case CHAIN_MAIL:
                    112:                     case BRIGANDINE:
                    113:                     case SPLINT_MAIL:
                    114:                     case GOOD_CHAIN:
                    115:                     case PLATE_MAIL:
                    116:                     case PLATE_ARMOR:
                    117:                         ret_val = FALSE;
                    118:                         break;
                    119:                     default:
                    120:                         break;
                    121:                 }
                    122:
                    123:             case C_THIEF:    /* cannot clank around */
                    124:             case C_ASSASIN:
                    125:             case C_NINJA:
                    126:                 switch (which)
                    127:                 {
                    128:                     case CHAIN_MAIL:
                    129:                     case BRIGANDINE:
                    130:                     case SPLINT_MAIL:
                    131:                     case GOOD_CHAIN:
                    132:                     case PLATE_MAIL:
                    133:                     case PLATE_ARMOR:
                    134:                         ret_val = FALSE;
                    135:                         break;
                    136:                     default:
                    137:                         break;
                    138:                 }
                    139:
                    140:             case C_CLERIC:   /* cannot wear plate */
                    141:             case C_DRUID:
                    142:                 switch (which)
                    143:                 {
                    144:                     case PLATE_MAIL:
                    145:                     case PLATE_ARMOR:
                    146:                     case MITHRIL:
                    147:                         ret_val = FALSE;
                    148:                         break;
                    149:                     default:
                    150:                         break;
                    151:                 }
                    152:
                    153:             case C_FIGHTER: /* wear anything */
                    154:             case C_RANGER:
                    155:                 break;
                    156:
                    157:             case    C_PALADIN:  /* cannot wear common stuff */
                    158:                 switch (which)
                    159:                 {
                    160:                     case SOFT_LEATHER:
                    161:                     case CUIRBOLILLI:
                    162:                     case HEAVY_LEATHER:
                    163:                     case STUDDED_LEATHER:
                    164:                     case PADDED_ARMOR:
                    165:                     case BRIGANDINE:
                    166:                         ret_val = FALSE;
                    167:                         break;
                    168:                     default:
                    169:                         break;
                    170:                 }
                    171:
                    172:             case C_MONSTER:
                    173:                 break;
                    174:
                    175:             default:      /* Unknown class */
                    176:                 debug("Unknown class %d.", class_type);
                    177:                 break;
                    178:         }
                    179:
                    180:     if (ret_val == FALSE && print_message == MESSAGE)
                    181:         switch (class_type)
                    182:         {
                    183:             case C_MAGICIAN:
                    184:             case C_ILLUSION:
                    185:                 msg("You cannot regenerate spell points while wearing that!");
                    186:                 break;
                    187:
                    188:             case C_THIEF:
                    189:             case C_ASSASIN:
                    190:             case C_NINJA:
                    191:                 msg("Don't expect to be stealthy while wearing that!");
                    192:                 break;
                    193:
                    194:             case C_CLERIC:
                    195:             case C_DRUID:
                    196:             case C_PALADIN:
                    197:                 msg("Your god strongly disapproves of your wearing that!");
                    198:                 break;
                    199:
                    200:             case C_FIGHTER:
                    201:             case C_RANGER:
                    202:             case C_MONSTER:
                    203:                 break;
                    204:         }
                    205:
                    206:     return(ret_val);
                    207: }

CVSweb