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

Annotation of early-roguelike/xrogue/wear.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:     wear.c  -  functions for dealing with armor
                      3:
                      4:     XRogue: Expeditions into the Dungeons of Doom
                      5:     Copyright (C) 1991 Robert Pietkivitch
                      6:     All rights reserved.
                      7:
                      8:     Based on "Advanced Rogue"
                      9:     Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
                     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 <stdlib.h>
                     20: #include <curses.h>
                     21: #include "rogue.h"
                     22:
                     23: int dress_units(struct linked_list *item);
                     24:
                     25: /*
                     26:  * take_off:
                     27:  *      Get the armor off of the players back
                     28:  */
                     29:
                     30: void
                     31: take_off(void)
                     32: {
                     33:     register struct object *obj;
                     34:     register struct linked_list *item;
                     35:
                     36:     /* It takes time to take things off */
                     37:     if (player.t_action != C_TAKEOFF) {
                     38:         /* What does player want to take off? */
                     39:         if ((item = get_item(pack, "take off", REMOVABLE, FALSE, FALSE))==NULL)
                     40:             return;
                     41:
                     42:         obj = OBJPTR(item);
                     43:         if (!is_current(obj)) {
                     44:             msg("Not wearing %c) %s", pack_char(pack, obj),inv_name(obj, TRUE));
                     45:             return;
                     46:         }
                     47:
                     48:         player.t_using = item;        /* Remember what it is */
                     49:         player.t_action = C_TAKEOFF;  /* We are taking something off */
                     50:
                     51:         /* Cursed items take almost no time */
                     52:         if (obj->o_flags & ISCURSED) player.t_no_move = movement(&player);
                     53:         else player.t_no_move = dress_units(item) * movement(&player);
                     54:         return;
                     55:     }
                     56:
                     57:     /* We have waited our time, let's take off our item */
                     58:     item = player.t_using;
                     59:     player.t_using = NULL;
                     60:     player.t_action = A_NIL;
                     61:
                     62:     obj = OBJPTR(item);
                     63:     if (!is_current(obj)) {     /* Just to be on the safe side */
                     64:         msg("Not wearing %c) %s", pack_char(pack, obj),inv_name(obj, TRUE));
                     65:         return;
                     66:     }
                     67:
                     68:     /* Can the player remove the item? */
                     69:     if (!dropcheck(obj)) return;
                     70:     updpack(TRUE, &player);
                     71:
                     72:     msg("Was wearing %c) %s", pack_char(pack, obj),inv_name(obj,TRUE));
                     73: }
                     74:
                     75: /*
                     76:  * wear:
                     77:  *      The player wants to wear something, so let him/her put it on.
                     78:  */
                     79:
                     80: void
                     81: wear(void)
                     82: {
                     83:     register struct linked_list *item;
                     84:     register struct object *obj;
                     85:     register int i;
                     86:
                     87:     /* It takes time to put things on */
                     88:     if (player.t_action != C_WEAR) {
                     89:         /* What does player want to wear? */
                     90:         if ((item = get_item(pack, "wear", WEARABLE, FALSE, FALSE)) == NULL)
                     91:             return;
                     92:
                     93:         obj = OBJPTR(item);
                     94:
                     95:         switch (obj->o_type) {
                     96:             case ARMOR:
                     97:                 if (cur_armor != NULL) {
                     98:                     addmsg("You are already wearing armor");
                     99:                     if (!terse) addmsg(".  You'll have to take it off first.");
                    100:                     endmsg();
                    101:                     after = FALSE;
                    102:                     return;
                    103:                 }
                    104:                 if (player.t_ctype == C_MONK) {
                    105:                     msg("Monks can't wear armor!");
                    106:                     return;
                    107:                 }
                    108:                 if (cur_misc[WEAR_BRACERS] != NULL) {
                    109:                     msg("You can't wear armor with bracers of defense.");
                    110:                     return;
                    111:                 }
                    112:                 if (cur_misc[WEAR_CLOAK] != NULL || cur_relic[EMORI_CLOAK]) {
                    113:                     msg("You can't wear armor with a cloak.");
                    114:                     return;
                    115:                 }
                    116:                 if (player.t_ctype == C_THIEF   &&
                    117:                     (obj->o_which != LEATHER    &&
                    118:                      obj->o_which != STUDDED_LEATHER)) {
                    119:                     if (terse) msg("Thieves can't wear that type of armor.");
                    120:                     else
                    121:                  msg("Thieves can wear leather and studded leather armor.");
                    122:                     return;
                    123:                 }
                    124:                 if (player.t_ctype == C_ASSASSIN &&
                    125:                     (obj->o_which != LEATHER    &&
                    126:                      obj->o_which != STUDDED_LEATHER)) {
                    127:                     if (terse) msg("Assassins can't wear that type of armor.");
                    128:                     else
                    129:                  msg("Assassins can wear leather and studded leather armor.");
                    130:                     return;
                    131:                 }
                    132:
                    133:             when MM:
                    134:                 switch (obj->o_which) {
                    135:                 /*
                    136:                  * when wearing the boots of elvenkind the player will not
                    137:                  * set off any traps
                    138:                  */
                    139:                 case MM_ELF_BOOTS:
                    140:                     if (cur_misc[WEAR_BOOTS] != NULL) {
                    141:                         msg("Already wearing a pair of boots. ");
                    142:                         return;
                    143:                     }
                    144:                 /*
                    145:                  * when wearing the boots of dancing the player will dance
                    146:                  * uncontrollably
                    147:                  */
                    148:                 when MM_DANCE:
                    149:                     if (cur_misc[WEAR_BOOTS] != NULL) {
                    150:                         msg("Already wearing a pair of boots.");
                    151:                         return;
                    152:                     }
                    153:                 /*
                    154:                  * bracers give the hero protection in he same way armor does.
                    155:                  * they cannot be used with armor but can be used with cloaks
                    156:                  */
                    157:                 when MM_BRACERS:
                    158:                     if (cur_misc[WEAR_BRACERS] != NULL) {
                    159:                         msg("Already wearing bracers.");
                    160:                         return;
                    161:                     }
                    162:                     else {
                    163:                         if (cur_armor != NULL) {
                    164:                            msg("You can't wear bracers of defense with armor.");
                    165:                            return;
                    166:                         }
                    167:                     }
                    168:
                    169:                 /*
                    170:                  * The robe (cloak) of powerlessness disallows any spell casting
                    171:                  */
                    172:                 when MM_R_POWERLESS:
                    173:                 /*
                    174:                  * the cloak of displacement gives the hero an extra +2 on AC
                    175:                  * and saving throws. Cloaks cannot be used with armor.
                    176:                  */
                    177:                 case MM_DISP:
                    178:                 /*
                    179:                  * the cloak of protection gives the hero +n on AC and saving
                    180:                  * throws with a max of +3 on saves
                    181:                  */
                    182:                 case MM_PROTECT:
                    183:                     if (cur_misc[WEAR_CLOAK] != NULL ||
                    184:                         cur_relic[EMORI_CLOAK]) {
                    185:                         msg("%slready wearing a cloak.", terse ? "A"
                    186:                                                                : "You are a");
                    187:                         return;
                    188:                     }
                    189:                     else {
                    190:                         if (cur_armor != NULL) {
                    191:                             msg("You can't wear a cloak with armor.");
                    192:                             return;
                    193:                         }
                    194:                     }
                    195:                 /*
                    196:                  * the gauntlets of dexterity and ogre power give the hero
                    197:                  * a dexterity of 21, the gauntlets of fumbling cause the
                    198:                  * hero to drop his weapon.
                    199:                  */
                    200:                 when MM_G_DEXTERITY:
                    201:                 case MM_G_OGRE:
                    202:                 case MM_FUMBLE:
                    203:                     if (cur_misc[WEAR_GAUNTLET] != NULL) {
                    204:                         msg("Already wearing a pair of gauntlets.");
                    205:                         return;
                    206:                     }
                    207:                 /*
                    208:                  * the jewel of attacks does an aggavate monster
                    209:                  */
                    210:                 when MM_JEWEL:
                    211:                     if (cur_misc[WEAR_JEWEL] != NULL    ||
                    212:                         cur_relic[YENDOR_AMULET]        ||
                    213:                         cur_relic[STONEBONES_AMULET]) {
                    214:                         msg("Already wearing an amulet.");
                    215:                         return;
                    216:                     }
                    217:                 /*
                    218:                  * the necklace of adaption makes the hero immune to
                    219:                  * chlorine gas and acid breath.
                    220:                  */
                    221:                 when MM_ADAPTION:
                    222:                     if (cur_misc[WEAR_NECKLACE] != NULL) {
                    223:                         msg("Already wearing a necklace.");
                    224:                         return;
                    225:                     }
                    226:                 /*
                    227:                  * the necklace of stragulation will try to strangle the
                    228:                  * hero to death
                    229:                  */
                    230:                 when MM_STRANGLE:
                    231:                     if (cur_misc[WEAR_NECKLACE] != NULL) {
                    232:                         msg("Already wearing a necklace.");
                    233:                         return;
                    234:                     }
                    235:                 otherwise:
                    236:                     msg("What a strange item you have!");
                    237:                     return;
                    238:                 }
                    239:
                    240:             when RING:
                    241:                 if (cur_misc[WEAR_GAUNTLET] != NULL) {
                    242:                     msg ("You have to remove your gauntlets first!");
                    243:                     return;
                    244:                 }
                    245:
                    246:                 /* Is there room to put the ring on */
                    247:                 for (i=0; i<NUM_FINGERS; i++)
                    248:                     if (cur_ring[i] == NULL) {
                    249:                         break;
                    250:                     }
                    251:                 if (i == NUM_FINGERS) { /* Not enough fingers */
                    252:                     if (terse) msg("Wearing enough rings.");
                    253:                     else msg("You are already wearing eight rings.");
                    254:                     return;
                    255:                 }
                    256:         }
                    257:
                    258:         player.t_using = item;      /* Remember what it is */
                    259:         player.t_action = C_WEAR;   /* We are taking something off */
                    260:         player.t_no_move = dress_units(item) * movement(&player);
                    261:         return;
                    262:     }
                    263:
                    264:     /* We have waited our time, let's put on our item */
                    265:     item = player.t_using;
                    266:     player.t_using = NULL;
                    267:     player.t_action = A_NIL;
                    268:
                    269:     obj = OBJPTR(item);
                    270:
                    271:     switch (obj->o_type) {
                    272:         case ARMOR:
                    273:             obj->o_flags |= ISKNOW;
                    274:             cur_armor = obj;
                    275:             addmsg(terse ? "W" : "You are now w");
                    276:             msg("earing %s.", armors[obj->o_which].a_name);
                    277:
                    278:         when MM:
                    279:             switch (obj->o_which) {
                    280:             /*
                    281:              * when wearing the boots of elvenkind the player will not
                    282:              * set off any traps
                    283:              */
                    284:             case MM_ELF_BOOTS:
                    285:                 msg("Wearing %s",inv_name(obj,TRUE));
                    286:                 cur_misc[WEAR_BOOTS] = obj;
                    287:             /*
                    288:              * when wearing the boots of dancing the player will dance
                    289:              * uncontrollably
                    290:              */
                    291:             when MM_DANCE:
                    292:                 msg("Wearing %s",inv_name(obj,TRUE));
                    293:                 cur_misc[WEAR_BOOTS] = obj;
                    294:                 msg("You begin to dance uncontrollably!");
                    295:                 turn_on(player, ISDANCE);
                    296:             /*
                    297:              * bracers give the hero protection in he same way armor does.
                    298:              * they cannot be used with armor but can be used with cloaks
                    299:              */
                    300:             when MM_BRACERS:
                    301:                 msg("wearing %s",inv_name(obj,TRUE));
                    302:                 cur_misc[WEAR_BRACERS] = obj;
                    303:
                    304:             /*
                    305:              * The robe (cloak) of powerlessness disallows any spell casting
                    306:              */
                    307:             when MM_R_POWERLESS:
                    308:             /*
                    309:              * the cloak of displacement gives the hero an extra +2 on AC
                    310:              * and saving throws. Cloaks cannot be used with armor.
                    311:              */
                    312:             case MM_DISP:
                    313:             /*
                    314:              * the cloak of protection gives the hero +n on AC and saving
                    315:              * throws with a max of +3 on saves
                    316:              */
                    317:             case MM_PROTECT:
                    318:                 msg("wearing %s",inv_name(obj,TRUE));
                    319:                 cur_misc[WEAR_CLOAK] = obj;
                    320:             /*
                    321:              * the gauntlets of dexterity and ogre power give the hero
                    322:              * a dexterity of 21, the gauntlets of fumbling cause the
                    323:              * hero to drop his weapon.
                    324:              */
                    325:             when MM_G_DEXTERITY:
                    326:             case MM_G_OGRE:
                    327:             case MM_FUMBLE:
                    328:                 msg("Wearing %s", inv_name(obj,TRUE));
                    329:                 cur_misc[WEAR_GAUNTLET] = obj;
                    330:                 if (obj->o_which == MM_FUMBLE)
                    331:                     start_daemon(fumble, NULL, AFTER);
                    332:             /*
                    333:              * the jewel of attacks does an aggavate monster
                    334:              */
                    335:             when MM_JEWEL:
                    336:                 msg("Wearing %s",inv_name(obj,TRUE));
                    337:                 cur_misc[WEAR_JEWEL] = obj;
                    338:                 aggravate(TRUE, TRUE); /* affect all charactors */
                    339:                 if (player.t_ctype == C_PALADIN ||
                    340:                     player.t_ctype == C_RANGER  || player.t_ctype == C_MONK)
                    341:                         msg("A chill runs down your spine! ");
                    342:
                    343:             /*
                    344:              * the necklace of adaption makes the hero immune to
                    345:              * chlorine gas and acid
                    346:              */
                    347:             when MM_ADAPTION:
                    348:                 msg("Wearing %s",inv_name(obj,TRUE));
                    349:                 cur_misc[WEAR_NECKLACE] = obj;
                    350:                 turn_on(player, NOGAS);
                    351:                 turn_on(player, NOACID);
                    352:
                    353:             /*
                    354:              * the necklace of stragulation will try to strangle the
                    355:              * hero to death
                    356:              */
                    357:             when MM_STRANGLE:
                    358:                 msg("Wearing %s",inv_name(obj,TRUE));
                    359:                 cur_misc[WEAR_NECKLACE] = obj;
                    360:                 msg("The necklace is beginning to strangle you!");
                    361:                 start_daemon(strangle, NULL, AFTER);
                    362:             otherwise:
                    363:                 msg("What a strange item you have!");
                    364:             }
                    365:             status(FALSE);
                    366:             if (m_know[obj->o_which] && m_guess[obj->o_which]) {
                    367:                 free(m_guess[obj->o_which]);
                    368:                 m_guess[obj->o_which] = NULL;
                    369:             }
                    370:             else if (!m_know[obj->o_which] &&
                    371:                      askme &&
                    372:                      (obj->o_flags & ISKNOW) == 0  &&
                    373:                      m_guess[obj->o_which] == NULL) {
                    374:                 nameitem(item, FALSE);
                    375:             }
                    376:
                    377:         when RING:
                    378:             /* If there is room, put on the ring */
                    379:             for (i=0; i<NUM_FINGERS; i++)
                    380:                 if (cur_ring[i] == NULL) {
                    381:                     cur_ring[i] = obj;
                    382:                     break;
                    383:                 }
                    384:             if (i == NUM_FINGERS) {     /* Not enough fingers */
                    385:                 if (terse) msg("Wearing enough rings.");
                    386:                 else msg("You are already wearing eight rings.");
                    387:                 return;
                    388:             }
                    389:
                    390:             /* Calculate the effect of the ring */
                    391:             ring_on(item);
                    392:     }
                    393:     updpack(TRUE, &player);
                    394: }
                    395:
                    396: /*
                    397:  * dress_units:
                    398:  *      How many movements periods does it take to put on or remove the
                    399:  *      given item of "clothing"?
                    400:  */
                    401:
                    402: int
                    403: dress_units(struct linked_list *item)
                    404: {
                    405:     register struct object *obj;
                    406:
                    407:     obj = OBJPTR(item);
                    408:
                    409:     switch (obj->o_type) {
                    410:         case ARMOR:
                    411:             return(10-armors[obj->o_which].a_class);
                    412:         when RING:
                    413:             return(2);
                    414:         when MM:
                    415:             switch (obj->o_which) {
                    416:                 case MM_ELF_BOOTS:
                    417:                 case MM_DANCE:
                    418:                     /* Boots */
                    419:                     return(5);
                    420:                 when MM_R_POWERLESS:
                    421:                 case MM_DISP:
                    422:                 case MM_PROTECT:
                    423:                     /* Robes */
                    424:                     return(4);
                    425:                 when MM_BRACERS:
                    426:                 case MM_G_DEXTERITY:
                    427:                 case MM_G_OGRE:
                    428:                 case MM_FUMBLE:
                    429:                     /* Hand garments */
                    430:                     return(3);
                    431:                 when MM_JEWEL:
                    432:                 case MM_ADAPTION:
                    433:                 case MM_STRANGLE:
                    434:                     /* Jewelry */
                    435:                     return(2);
                    436:                 otherwise:
                    437:                     return(1);  /* What is it? */
                    438:         }
                    439:         otherwise:
                    440:             return(1);  /* What is it? */
                    441:     }
                    442: }
                    443:

CVSweb