* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)com4.c 5.4 (Berkeley) 6/1/90";
int firstnumber
, heavy
, bulky
, value
;
firstnumber
= wordnumber
;
if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == OFF
){
wordvalue
[wordnumber
] = TAKEOFF
;
while(wordtype
[++wordnumber
] == ADJS
);
while(wordnumber
<=wordcount
&& wordtype
[wordnumber
] == OBJECT
){
value
= wordvalue
[wordnumber
];
printf("%s:\n", objsht
[value
]);
for (n
=0; objsht
[value
][n
]; n
++);
heavy
= (carrying
+ objwt
[value
]) <= WEIGHT
;
bulky
= (encumber
+ objcumber
[value
]) <= CUMBER
;
if ((testbit(from
,value
) || wiz
|| tempwiz
) && heavy
&& bulky
&& !testbit(inven
,value
)){
carrying
+= objwt
[value
];
encumber
+= objcumber
[value
];
printf("Zap! Taken from thin air.\n");
else if (testbit(inven
,value
))
printf("You're already holding%s%s.\n", (objsht
[value
][n
-1] == 's' ? " " : " a "),objsht
[value
]);
printf("The %s %s too heavy.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
printf("The %s %s too cumbersome to hold.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
printf("I dont see any %s around here.\n", objsht
[value
]);
if (wordnumber
< wordcount
-1 && wordvalue
[++wordnumber
] == AND
)
/* special cases with their own return()'s */
if (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == NOUNS
)
switch(wordvalue
[wordnumber
]){
if (testbit(from
, SWORD
)){
wordtype
[wordnumber
--] = OBJECT
;
if (testbit(from
, TWO_HANDED
)){
wordvalue
[wordnumber
] = TWO_HANDED
;
wordtype
[wordnumber
--] = OBJECT
;
wordvalue
[wordnumber
] = BROAD
;
wordtype
[wordnumber
--] = OBJECT
;
wordvalue
[wordnumber
] = MAID
;
wordtype
[wordnumber
--] = OBJECT
;
else if (testbit(from
,DEADWOOD
)){
wordvalue
[wordnumber
] = DEADWOOD
;
wordtype
[wordnumber
--] = OBJECT
;
else if (testbit(from
,DEADNATIVE
)){
wordvalue
[wordnumber
] = DEADNATIVE
;
wordtype
[wordnumber
--] = OBJECT
;
else if (testbit(from
,DEADGOD
)){
wordvalue
[wordnumber
] = DEADGOD
;
wordtype
[wordnumber
--] = OBJECT
;
wordvalue
[wordnumber
] = DEADTIME
;
wordtype
[wordnumber
--] = OBJECT
;
if (testbit(location
[position
].objects
,AMULET
)){
puts("The amulet is warm to the touch, and its beauty catches your breath.");
puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer");
puts("and sharper but far away as if in a dream. The sound of purling water reaches");
puts("you from afar. The mist falls again, and your heart leaps in horror. The gold");
puts("freezes your hands and fathomless darkness engulfs your soul.");
wordtype
[wordnumber
--] = OBJECT
;
if (testbit(location
[position
].objects
, MEDALION
)){
puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
wordtype
[wordnumber
--] = OBJECT
;
if (testbit(location
[position
].objects
,TALISMAN
)){
puts("The talisman is cold to the touch, and it sends a chill down your spine.");
wordtype
[wordnumber
--] = OBJECT
;
if (testbit(location
[position
].objects
,BATHGOD
) && (testbit(wear
,AMULET
) || testbit(inven
,AMULET
))){
puts("She offers a delicate hand, and you help her out of the sparkling springs.");
puts("Water droplets like liquid silver bedew her golden skin, but when they part");
puts("from her, they fall as teardrops. She wraps a single cloth around her and");
puts("ties it at the waist. Around her neck hangs a golden amulet.");
puts("She bids you to follow her.");
clearbit(location
[position
].objects
,BATHGOD
);
} else if (!testbit(location
[position
].objects
,BATHGOD
))
puts("You're in no position to take her.");
puts("She moves away from you.");
puts("It doesn't seem to work.");
puts("You've got to be kidding.");
switch(wordvalue
[wordnumber
]){
deposit
= location
[position
].up
* (location
[position
].access
|| position
== FINAL
);
deposit
= location
[position
].down
;
while (wordtype
[++wordnumber
] == ADJS
);
while (wordnumber
<= wordcount
){
value
= wordvalue
[wordnumber
];
if (deposit
&& testbit(location
[position
].objects
,value
)){
clearbit(location
[position
].objects
,value
);
setbit(location
[deposit
].objects
,value
);
puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
for (n
= 0; n
< NUMOFWORDS
; n
++)
location
[deposit
].objects
[n
] = 0;
setbit(location
[deposit
].objects
,CHAR
);
if (value
== ROPE
&& position
== FINAL
)
location
[position
].access
= 1;
puts("The stone door is unhinged.");
location
[189].north
= 231;
location
[231].south
= 189;
puts("The wooden door is blown open.");
puts("The door is not damaged.");
else if (value
== GRENADE
&& testbit(location
[position
].objects
,value
)){
puts("You are blown into shreds when your grenade explodes.");
if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
firstnumber
= wordnumber
;
while (wordtype
[++wordnumber
] == ADJS
)
while (wordnumber
<=wordcount
&& (wordtype
[wordnumber
] == OBJECT
|| wordtype
[wordnumber
] == NOUNS
)) {
value
= wordvalue
[wordnumber
];
printf("%s:\n", objsht
[value
]);
if (testbit(inven
,value
)){
carrying
-= objwt
[value
];
encumber
-= objcumber
[value
];
puts("The bomb explodes. A blinding white light and immense concussion obliterate us.");
if (value
!= AMULET
&& value
!= MEDALION
&& value
!= TALISMAN
)
setbit(location
[position
].objects
,value
);
printf("You aren't holding the %s.\n", objsht
[value
]);
if (testbit(location
[position
].objects
,value
)) {
if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
wordnumber
= take(location
[position
].objects
);
firstnumber
= wordnumber
;
while(wordtype
[++wordnumber
] == ADJS
);
while(wordnumber
<= wordcount
){
value
= wordvalue
[wordnumber
];
printf("You can't eat%s%s!\n",
wordtype
[wordnumber
] == OBJECT
&&
[strlen(objsht
[value
]) - 1] == 's' ?
case COCONUTS
: /* eatable things */
printf("%s:\n",objsht
[value
]);
if (testbit(inven
,value
) && time
> ate
- CYCLE
&& testbit(inven
,KNIFE
)){
carrying
-= objwt
[value
];
encumber
-= objcumber
[value
];
ate
= max(time
,ate
) + CYCLE
/3;
puts("Eaten. You can explore a little longer now.");
else if (time
< ate
- CYCLE
)
else if (!testbit(inven
,KNIFE
))
puts("You need a knife.");
printf("You aren't holding the %s.\n", objsht
[value
]);
if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)