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

Annotation of early-roguelike/arogue7/wear.c, Revision 1.1

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

CVSweb