118720Sedward /*
260750Sbostic * Copyright (c) 1983, 1993
360750Sbostic * The Regents of the University of California. All rights reserved.
434234Sbostic *
542567Sbostic * %sccs.include.redist.c%
618720Sedward */
718720Sedward
817375Sedward #ifndef lint
9*69064Sbostic static char sccsid[] = "@(#)com1.c 8.2 (Berkeley) 04/28/95";
1034234Sbostic #endif /* not lint */
1117375Sedward
12*69064Sbostic #include "extern.h"
1317375Sedward
move(thataway,token)1417375Sedward move(thataway, token)
1517375Sedward int thataway, token;
1617375Sedward {
1717375Sedward wordnumber++;
1817375Sedward if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || fuel > 0 && notes[LAUNCHED])
1917375Sedward if (thataway) {
2017375Sedward position = thataway;
2117375Sedward newway(token);
2217375Sedward time++;
2317375Sedward }
2417375Sedward else {
2517375Sedward puts("You can't go this way.");
2617375Sedward newway(token);
2717375Sedward whichway(location[position]);
2817375Sedward return(0);
2917375Sedward }
3017375Sedward else if (notes[CANTMOVE] && !notes[LAUNCHED])
3117439Sedward puts("You aren't able to move; you better drop something.");
3217375Sedward else
3317439Sedward puts("You are out of fuel; now you will rot in space forever!");
3417375Sedward return(1);
3517375Sedward }
3617375Sedward
convert(tothis)3717375Sedward convert(tothis) /* Converts day to night and vice versa. */
3817375Sedward int tothis; /* Day objects are permanent. Night objects are added*/
3917375Sedward { /* at dusk, and subtracted at dawn. */
4017375Sedward register struct objs *p;
4117439Sedward register i, j;
4217375Sedward
4317439Sedward if (tothis == TONIGHT) {
4417439Sedward for (i = 1; i <= NUMOFROOMS; i++)
4517439Sedward for (j = 0; j < NUMOFWORDS; j++)
4617439Sedward nightfile[i].objects[j] = dayfile[i].objects[j];
4717439Sedward for (p = nightobjs; p->room != 0; p++)
4817439Sedward setbit(nightfile[p->room].objects, p->obj);
4917375Sedward location = nightfile;
5017439Sedward } else {
5117439Sedward for (i = 1; i <= NUMOFROOMS; i++)
5217439Sedward for (j = 0; j < NUMOFWORDS; j++)
5317439Sedward dayfile[i].objects[j] = nightfile[i].objects[j];
5417375Sedward for (p = nightobjs; p->room != 0; p++)
5517439Sedward clearbit(dayfile[p->room].objects, p->obj);
5617375Sedward location = dayfile;
5717375Sedward }
5817375Sedward }
5917375Sedward
news()6017375Sedward news()
6117375Sedward {
6217375Sedward register int n;
6317375Sedward int hurt;
6417375Sedward
6517375Sedward if (time > 30 && position < 32){
6617375Sedward puts("An explosion of shuddering magnitude splinters bulkheads and");
6717375Sedward puts("ruptures the battlestar's hull. You are sucked out into the");
6817439Sedward puts("frozen void of space and killed.");
6917375Sedward die();
7017375Sedward }
7117375Sedward if (time > 20 && position < 32)
7217375Sedward puts("Explosions rock the battlestar.");
7317375Sedward if (time > snooze){
7417375Sedward puts("You drop from exhaustion...");
7517375Sedward zzz();
7617375Sedward }
7717375Sedward if (time > snooze - 5)
7817439Sedward puts("You're getting tired.");
7917439Sedward if (time > (rythmn + CYCLE)) {
8017439Sedward if (location == nightfile) {
8117439Sedward convert(TODAY);
8217439Sedward if (OUTSIDE && time - rythmn - CYCLE < 10) {
8317439Sedward puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
8417439Sedward puts("You awake from a misty dream-world into stark reality.");
8517439Sedward puts("It is day.");
8617439Sedward }
8717439Sedward } else {
8817439Sedward convert(TONIGHT);
8917439Sedward clearbit(location[POOLS].objects, BATHGOD);
9017439Sedward if (OUTSIDE && time - rythmn - CYCLE < 10) {
9117439Sedward puts("The dying sun sinks into the ocean, leaving a blood stained sunset.");
9217439Sedward puts("The sky slowly fades from orange to violet to black. A few stars");
9317439Sedward puts("flicker on, and it is night.");
9417439Sedward puts("The world seems completly different at night.");
9517439Sedward }
9617375Sedward }
9717439Sedward rythmn = time - time % CYCLE;
9817375Sedward }
9917375Sedward if (!wiz && !tempwiz)
10017375Sedward if ((testbit(inven,TALISMAN) || testbit(wear,TALISMAN)) && (testbit(inven,MEDALION) || testbit(wear,MEDALION)) && (testbit(inven,AMULET) || testbit(wear,AMULET))){
10117375Sedward tempwiz = 1;
10217439Sedward puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard.");
10317375Sedward }
10417375Sedward if (testbit(location[position].objects,ELF)){
10517375Sedward printf("%s\n",objdes[ELF]);
10617375Sedward fight(ELF,rnd(30));
10717375Sedward }
10817375Sedward if (testbit(location[position].objects,DARK)){
10917375Sedward printf("%s\n",objdes[DARK]);
11017375Sedward fight(DARK,100);
11117375Sedward }
11217375Sedward if (testbit(location[position].objects,WOODSMAN)){
11317375Sedward printf("%s\n",objdes[WOODSMAN]);
11417375Sedward fight(WOODSMAN,50);
11517375Sedward }
11617375Sedward switch(position){
11717375Sedward
11817375Sedward case 267:
11917375Sedward case 257: /* entering a cave */
12017375Sedward case 274:
12117375Sedward case 246:
12217375Sedward notes[CANTSEE] = 1;
12317375Sedward break;
12417375Sedward case 160:
12517375Sedward case 216: /* leaving a cave */
12617375Sedward case 230:
12717375Sedward case 231:
12817375Sedward case 232:
12917375Sedward notes[CANTSEE] = 0;
13017375Sedward break;
13117375Sedward }
13217375Sedward if (testbit(location[position].objects, GIRL))
13317375Sedward meetgirl = 1;
13417375Sedward if (meetgirl && CYCLE * 1.5 - time < 10){
13517375Sedward setbit(location[GARDEN].objects,GIRLTALK);
13617375Sedward setbit(location[GARDEN].objects,LAMPON);
13717375Sedward setbit(location[GARDEN].objects,ROPE);
13817375Sedward }
13917375Sedward if (position == DOCK && (beenthere[position] || time > CYCLE)){
14017375Sedward clearbit(location[DOCK].objects, GIRL);
14117375Sedward clearbit(location[DOCK].objects,MAN);
14217375Sedward }
14317375Sedward if (meetgirl && time - CYCLE * 1.5 > 10){
14417375Sedward clearbit(location[GARDEN].objects,GIRLTALK);
14517375Sedward clearbit(location[GARDEN].objects,LAMPON);
14617375Sedward clearbit(location[GARDEN].objects,ROPE);
14717375Sedward meetgirl = 0;
14817375Sedward }
14917375Sedward if (testbit(location[position].objects,CYLON)){
15017375Sedward puts("Oh my God, you're being shot at by an alien spacecraft!");
15117375Sedward printf("The targeting computer says we have %d seconds to attack!\n",clock);
15217375Sedward fflush(stdout);
15317439Sedward sleep(1);
15417375Sedward if (!visual()){
15517375Sedward hurt = rnd(NUMOFINJURIES);
15617375Sedward injuries[hurt] = 1;
15717439Sedward puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
15817375Sedward puts("The viper shudders under a terrible explosion.");
15917375Sedward printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
16017375Sedward }
16117375Sedward else
16217375Sedward clearbit(location[position].objects,CYLON);
16317375Sedward }
16417375Sedward if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
16517375Sedward puts("I'm afraid you have suffered fatal injuries.");
16617375Sedward die();
16717375Sedward }
16817375Sedward for (n=0; n < NUMOFINJURIES; n++)
16917375Sedward if (injuries[n] == 1){
17017375Sedward injuries[n] = 2;
17117375Sedward if (WEIGHT > 5)
17217375Sedward WEIGHT -= 5;
17317375Sedward else
17417375Sedward WEIGHT = 0;
17517375Sedward }
17617375Sedward if (injuries[ARM] == 2){
17717375Sedward CUMBER -= 5;
17817375Sedward injuries[ARM]++;
17917375Sedward }
18017375Sedward if (injuries[RIBS] == 2){
18117375Sedward CUMBER -= 2;
18217375Sedward injuries[RIBS]++;
18317375Sedward }
18417375Sedward if (injuries[SPINE] == 2){
18517375Sedward WEIGHT = 0;
18617375Sedward injuries[SPINE]++;
18717375Sedward }
18817375Sedward if (carrying > WEIGHT || encumber > CUMBER)
18917375Sedward notes[CANTMOVE] = 1;
19017375Sedward else
19117375Sedward notes[CANTMOVE] = 0;
19217375Sedward }
19317375Sedward
crash()19417375Sedward crash()
19517375Sedward {
19617375Sedward int hurt1,hurt2;
19717375Sedward
19817375Sedward fuel--;
19917375Sedward if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
20017375Sedward if (!location[position].flyhere)
20117375Sedward puts("You're flying too low. We're going to crash!");
20217375Sedward else{
20317375Sedward puts("You're out of fuel. We'll have to crash land!");
20417375Sedward if (!location[position].down){
20517439Sedward puts("Your viper strikes the ground and explodes into firey fragments.");
20617375Sedward puts("Thick black smoke billows up from the wreckage.");
20717375Sedward die();
20817375Sedward }
20917375Sedward position = location[position].down;
21017375Sedward }
21117375Sedward notes[LAUNCHED] = 0;
21217375Sedward setbit(location[position].objects,CRASH);
21317375Sedward time += rnd(CYCLE/4);
21417375Sedward puts("The viper explodes into the ground and you lose consciousness...");
21517375Sedward zzz();
21617375Sedward hurt1 = rnd(NUMOFINJURIES - 2) + 2;
21717375Sedward hurt2 = rnd(NUMOFINJURIES - 2) + 2;
21817375Sedward injuries[hurt1] = 1;
21917375Sedward injuries[hurt2] = 1;
22017375Sedward injuries[0] = 1; /* abrasions */
22117375Sedward injuries[1] = 1; /* lacerations */
22217375Sedward printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]);
22317375Sedward }
22417375Sedward }
225