Annotation of 43BSDReno/games/battlestar/com4.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)com4.c     5.4 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: #include "externs.h"
        !            25: 
        !            26: take(from)
        !            27: unsigned int from[];
        !            28: {
        !            29:        int firstnumber, heavy, bulky, value;
        !            30:        register int n;
        !            31: 
        !            32:        firstnumber = wordnumber;
        !            33:        if (wordnumber < wordcount && wordvalue[wordnumber+1] == OFF){
        !            34:                wordnumber++;
        !            35:                wordvalue[wordnumber] = TAKEOFF;
        !            36:                return(cypher());
        !            37:        }
        !            38:        else {
        !            39:                while(wordtype[++wordnumber] == ADJS);
        !            40:                while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
        !            41:                        value = wordvalue[wordnumber];
        !            42:                        printf("%s:\n", objsht[value]);
        !            43:                        for (n=0; objsht[value][n]; n++);
        !            44:                        heavy = (carrying + objwt[value]) <= WEIGHT;
        !            45:                        bulky = (encumber + objcumber[value]) <= CUMBER;
        !            46:                        if ((testbit(from,value) || wiz || tempwiz) && heavy && bulky && !testbit(inven,value)){
        !            47:                                setbit(inven,value);
        !            48:                                carrying += objwt[value];
        !            49:                                encumber += objcumber[value];
        !            50:                                time++;
        !            51:                                if (testbit(from,value))
        !            52:                                        printf("Taken.\n");
        !            53:                                else
        !            54:                                        printf("Zap! Taken from thin air.\n");
        !            55:                                clearbit(from,value);
        !            56:                                if (value == MEDALION)
        !            57:                                        win--;
        !            58:                        }
        !            59:                        else if (testbit(inven,value))
        !            60:                                printf("You're already holding%s%s.\n", (objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
        !            61:                        else if (!heavy)
        !            62:                                printf("The %s %s too heavy.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
        !            63:                        else if (!bulky)
        !            64:                                printf("The %s %s too cumbersome to hold.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
        !            65:                        else
        !            66:                                printf("I dont see any %s around here.\n", objsht[value]);
        !            67:                        if (wordnumber < wordcount -1 && wordvalue[++wordnumber] == AND)
        !            68:                                wordnumber++;
        !            69:                        else
        !            70:                                return(firstnumber);
        !            71:                }
        !            72:        }
        !            73:                            /* special cases with their own return()'s */
        !            74: 
        !            75:        if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS)
        !            76:                switch(wordvalue[wordnumber]){
        !            77:                        
        !            78:                        case SWORD:
        !            79:                                if (testbit(from, SWORD)){
        !            80:                                        wordtype[wordnumber--] = OBJECT;
        !            81:                                        return(take(from));
        !            82:                                }
        !            83:                                if (testbit(from, TWO_HANDED)){
        !            84:                                        wordvalue[wordnumber] = TWO_HANDED;
        !            85:                                        wordtype[wordnumber--] = OBJECT;
        !            86:                                        return(take(from));
        !            87:                                }
        !            88:                                wordvalue[wordnumber] = BROAD;
        !            89:                                wordtype[wordnumber--] = OBJECT;
        !            90:                                return(take(from));
        !            91: 
        !            92:                        case BODY:
        !            93:                                if (testbit(from,MAID)){
        !            94:                                        wordvalue[wordnumber] = MAID;
        !            95:                                        wordtype[wordnumber--] = OBJECT;
        !            96:                                        return(take(from));
        !            97:                                }
        !            98:                                else if (testbit(from,DEADWOOD)){
        !            99:                                        wordvalue[wordnumber] = DEADWOOD;
        !           100:                                        wordtype[wordnumber--] = OBJECT;
        !           101:                                        return(take(from));
        !           102:                                }
        !           103:                                else if (testbit(from,DEADNATIVE)){
        !           104:                                        wordvalue[wordnumber] = DEADNATIVE;
        !           105:                                        wordtype[wordnumber--] = OBJECT;
        !           106:                                        return(take(from));
        !           107:                                }
        !           108:                                else if (testbit(from,DEADGOD)){
        !           109:                                        wordvalue[wordnumber] = DEADGOD;
        !           110:                                        wordtype[wordnumber--] = OBJECT;
        !           111:                                        return(take(from));
        !           112:                                }
        !           113:                                else {
        !           114:                                        wordvalue[wordnumber] = DEADTIME;
        !           115:                                        wordtype[wordnumber--] = OBJECT;
        !           116:                                        return(take(from));
        !           117:                                }
        !           118:                                break;
        !           119: 
        !           120:                        case AMULET:
        !           121:                                if (testbit(location[position].objects,AMULET)){
        !           122:                                        puts("The amulet is warm to the touch, and its beauty catches your breath.");
        !           123:                                        puts("A mist falls over your eyes, but then it is gone.  Sounds seem clearer");
        !           124:                                        puts("and sharper but far away as if in a dream.  The sound of purling water reaches");
        !           125:                                        puts("you from afar.  The mist falls again, and your heart leaps in horror.  The gold");
        !           126:                                        puts("freezes your hands and fathomless darkness engulfs your soul.");
        !           127:                                }
        !           128:                                wordtype[wordnumber--] = OBJECT;
        !           129:                                return(take(from));
        !           130: 
        !           131:                        case MEDALION:
        !           132:                                if (testbit(location[position].objects, MEDALION)){
        !           133:                                        puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
        !           134:                                        puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
        !           135:                                }
        !           136:                                wordtype[wordnumber--] = OBJECT;
        !           137:                                return(take(from));
        !           138: 
        !           139:                        case TALISMAN:
        !           140:                                if (testbit(location[position].objects,TALISMAN)){
        !           141:                                        puts("The talisman is cold to the touch, and it sends a chill down your spine.");
        !           142:                                }
        !           143:                                wordtype[wordnumber--] = OBJECT;
        !           144:                                return(take(from));
        !           145: 
        !           146:                        case NORMGOD:
        !           147:                                if (testbit(location[position].objects,BATHGOD) && (testbit(wear,AMULET) || testbit(inven,AMULET))){
        !           148:                                        puts("She offers a delicate hand, and you help her out of the sparkling springs.");
        !           149:                                        puts("Water droplets like liquid silver bedew her golden skin, but when they part");
        !           150:                                        puts("from her, they fall as teardrops.  She wraps a single cloth around her and");
        !           151:                                        puts("ties it at the waist.  Around her neck hangs a golden amulet.");
        !           152:                                        puts("She bids you to follow her.");
        !           153:                                        pleasure++;
        !           154:                                        followgod = time;
        !           155:                                        clearbit(location[position].objects,BATHGOD);
        !           156:                                } else if (!testbit(location[position].objects,BATHGOD))
        !           157:                                        puts("You're in no position to take her.");
        !           158:                                else 
        !           159:                                        puts("She moves away from you.");
        !           160:                                break;
        !           161: 
        !           162:                        default:
        !           163:                                puts("It doesn't seem to work.");
        !           164:                }
        !           165:        else
        !           166:                puts("You've got to be kidding.");
        !           167:        return(firstnumber);
        !           168: }
        !           169: 
        !           170: throw(name)
        !           171:        char *name;
        !           172: {
        !           173:        int n;
        !           174:        int deposit = 0;
        !           175:        int first, value;
        !           176: 
        !           177:        first = wordnumber;
        !           178:        if (drop(name) != -1){
        !           179:                switch(wordvalue[wordnumber]){
        !           180:                        
        !           181:                        case AHEAD:
        !           182:                                deposit = ahead;
        !           183:                                break;
        !           184: 
        !           185:                        case BACK:
        !           186:                                deposit = back;
        !           187:                                break;
        !           188: 
        !           189:                        case LEFT:
        !           190:                                deposit = left;
        !           191:                                break;
        !           192: 
        !           193:                        case RIGHT:
        !           194:                                deposit = right;
        !           195:                                break;
        !           196: 
        !           197:                        case UP:
        !           198:                                deposit = location[position].up * (location[position].access || position == FINAL);
        !           199:                                break;
        !           200: 
        !           201:                        case DOWN:
        !           202:                                deposit = location[position].down;
        !           203:                                break;
        !           204:                }
        !           205:                wordnumber = first;
        !           206:                while (wordtype[++wordnumber] == ADJS);
        !           207:                while (wordnumber <= wordcount){
        !           208:                        value = wordvalue[wordnumber];
        !           209:                        if (deposit && testbit(location[position].objects,value)){
        !           210:                                clearbit(location[position].objects,value);
        !           211:                                if (value != GRENADE)
        !           212:                                        setbit(location[deposit].objects,value);
        !           213:                                else{
        !           214:                                        puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
        !           215:                                        for (n = 0; n < NUMOFWORDS; n ++)
        !           216:                                                location[deposit].objects[n] = 0;
        !           217:                                        setbit(location[deposit].objects,CHAR);
        !           218:                                }
        !           219:                                if (value == ROPE && position == FINAL)
        !           220:                                        location[position].access = 1;
        !           221:                                switch(deposit){
        !           222:                                        case 189:
        !           223:                                        case 231:
        !           224:                                                puts("The stone door is unhinged.");
        !           225:                                                location[189].north = 231;
        !           226:                                                location[231].south = 189;
        !           227:                                                break;
        !           228:                                        case 30:
        !           229:                                                puts("The wooden door is blown open.");
        !           230:                                                location[30].west = 25;
        !           231:                                                break;
        !           232:                                        case 31:
        !           233:                                                puts("The door is not damaged.");
        !           234:                                }
        !           235:                        }
        !           236:                        else if (value == GRENADE && testbit(location[position].objects,value)){
        !           237:                                puts("You are blown into shreds when your grenade explodes.");
        !           238:                                die();
        !           239:                        }
        !           240:                        if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
        !           241:                                wordnumber++;
        !           242:                        else 
        !           243:                                return(first);
        !           244:                }
        !           245:                return(first);
        !           246:        }
        !           247:        return(first);
        !           248: }
        !           249: 
        !           250: drop(name)
        !           251: char *name;
        !           252: {
        !           253:        
        !           254:        int firstnumber, value;
        !           255: 
        !           256:        firstnumber = wordnumber;
        !           257:        while (wordtype[++wordnumber] == ADJS)
        !           258:                ;
        !           259:        while (wordnumber<=wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) {
        !           260:                value = wordvalue[wordnumber];
        !           261:                printf("%s:\n", objsht[value]);
        !           262:                if (testbit(inven,value)){
        !           263:                        clearbit(inven,value);
        !           264:                        carrying -= objwt[value];
        !           265:                        encumber -= objcumber[value];
        !           266:                        if (value == BOMB){
        !           267:                                puts("The bomb explodes.  A blinding white light and immense concussion obliterate us.");
        !           268:                                die();
        !           269:                        }
        !           270:                        if (value != AMULET && value != MEDALION && value != TALISMAN)
        !           271:                                setbit(location[position].objects,value);
        !           272:                        else
        !           273:                                tempwiz = 0;
        !           274:                        time++;
        !           275:                        if (*name == 'K')
        !           276:                                puts("Drop kicked.");
        !           277:                        else
        !           278:                                printf("%s.\n", name);
        !           279:                }
        !           280:                else {
        !           281:                        if (*name != 'K') {
        !           282:                                printf("You aren't holding the %s.\n", objsht[value]);
        !           283:                                if (testbit(location[position].objects,value)) {
        !           284:                                        if (*name == 'T')
        !           285:                                                puts("Kicked instead.");
        !           286:                                        else if (*name == 'G')
        !           287:                                                puts("Given anyway.");
        !           288:                                }
        !           289:                        } else
        !           290:                                puts("Kicked.");
        !           291:                }
        !           292:                if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
        !           293:                        wordnumber++;
        !           294:                else
        !           295:                        return(firstnumber);
        !           296:        }
        !           297:        puts("Do what?");
        !           298:        return(-1);
        !           299: }
        !           300: 
        !           301: takeoff()
        !           302: {
        !           303:        wordnumber = take(wear);
        !           304:        return(drop("Dropped"));
        !           305: }
        !           306: 
        !           307: puton()
        !           308: {
        !           309:        wordnumber = take(location[position].objects);
        !           310:        return(wearit());
        !           311: }
        !           312: 
        !           313: eat()
        !           314: {
        !           315:        int firstnumber, value;
        !           316: 
        !           317:        firstnumber = wordnumber;
        !           318:        while(wordtype[++wordnumber] == ADJS);
        !           319:        while(wordnumber <= wordcount){
        !           320:                value = wordvalue[wordnumber];
        !           321:                switch(value){
        !           322:                        
        !           323:                        case -1:
        !           324:                                puts("Eat what?");
        !           325:                                return(firstnumber);
        !           326: 
        !           327:                        default:
        !           328:                                printf("You can't eat%s%s!\n",
        !           329:                                        wordtype[wordnumber] == OBJECT &&
        !           330:                                        objsht[value]
        !           331:                                        [strlen(objsht[value]) - 1] == 's' ?
        !           332:                                        " " : " a ",
        !           333:                                        words[wordnumber]);
        !           334:                                return(firstnumber);
        !           335: 
        !           336:                        case PAPAYAS:
        !           337:                        case PINEAPPLE:
        !           338:                        case KIWI:
        !           339:                        case COCONUTS:  /* eatable things */
        !           340:                        case MANGO:
        !           341: 
        !           342:                                printf("%s:\n",objsht[value]);
        !           343:                                if (testbit(inven,value) && time > ate - CYCLE && testbit(inven,KNIFE)){
        !           344:                                        clearbit(inven,value);
        !           345:                                        carrying -= objwt[value];
        !           346:                                        encumber -= objcumber[value];
        !           347:                                        ate = max(time,ate) + CYCLE/3;
        !           348:                                        snooze += CYCLE/10;
        !           349:                                        time++;
        !           350:                                        puts("Eaten.  You can explore a little longer now.");
        !           351:                                }
        !           352:                                else if (time < ate - CYCLE)
        !           353:                                        puts("You're stuffed.");
        !           354:                                else if (!testbit(inven,KNIFE))
        !           355:                                        puts("You need a knife.");
        !           356:                                else
        !           357:                                        printf("You aren't holding the %s.\n", objsht[value]);
        !           358:                                if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
        !           359:                                        wordnumber++;
        !           360:                                else 
        !           361:                                        return(firstnumber);
        !           362:                } /* end switch */
        !           363:        } /* end while */
        !           364:        return(firstnumber);
        !           365: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.