date and time created 84/11/18 18:58:43 by edward
[unix-history] / usr / src / games / battlestar / com1.c
CommitLineData
6bd0a3e3
EW
1#ifndef lint
2static char sccsid[] = "@(#)com1.c 1.1 %G%";
3#endif
4
5#include "externs.h"
6
7move(thataway, token)
8int thataway, token;
9{
10 wordnumber++;
11 if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || fuel > 0 && notes[LAUNCHED])
12 if (thataway) {
13 position = thataway;
14 newway(token);
15 time++;
16 }
17 else {
18 puts("You can't go this way.");
19 newway(token);
20 whichway(location[position]);
21 return(0);
22 }
23 else if (notes[CANTMOVE] && !notes[LAUNCHED])
24 puts("You aren't able to move, you better drop something.");
25 else
26 puts("You are out of fuel, now we will rot in space forever!");
27 return(1);
28}
29
30convert(tothis) /* Converts day to night and vice versa. */
31int tothis; /* Day objects are permanent. Night objects are added*/
32{ /* at dusk, and subtracted at dawn. */
33 register struct objs *p;
34
35 if (tothis == TONIGHT){
36 location = nightfile;
37 for (p = nightobjs; p->room != 0; p++)
38 setbit(location[p->room].objects, p->obj);
39 } else {
40 location = dayfile;
41 for (p = nightobjs; p->room != 0; p++)
42 clearbit(location[p->room].objects, p->obj);
43 }
44}
45
46news()
47{
48 register int n;
49 int hurt;
50
51 if (time > 30 && position < 32){
52 puts("An explosion of shuddering magnitude splinters bulkheads and");
53 puts("ruptures the battlestar's hull. You are sucked out into the");
54 puts("frozen void of space and killed...");
55 die();
56 }
57 if (time > 20 && position < 32)
58 puts("Explosions rock the battlestar.");
59 if (time > snooze){
60 puts("You drop from exhaustion...");
61 zzz();
62 }
63 if (time > snooze - 5)
64 puts("I'm getting tired.");
65 if (time > (rythmn + CYCLE) && location == nightfile){
66 convert(TODAY);
67 if (OUTSIDE && time - rythmn - CYCLE < 10){
68 puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
69 puts("You awake from a misty dream-world into stark reality");
70 puts("It is day.");
71 }
72 rythmn = time;
73 }
74 else if (time > (rythmn + CYCLE)){
75 convert(TONIGHT);
76 clearbit(location[POOLS].objects,BATHGOD);
77 if (OUTSIDE && time - rythmn - CYCLE < 10){
78 puts("The dying sun sinks into the ocean, leaving a blood stained sunset.");
79 puts("The sky slowly fades from orange to violet to black. A few stars");
80 puts("flicker on, and it is night.");
81 puts("The world seems completly different at night.");
82 }
83 rythmn = time;
84 }
85 if (!wiz && !tempwiz)
86 if ((testbit(inven,TALISMAN) || testbit(wear,TALISMAN)) && (testbit(inven,MEDALION) || testbit(wear,MEDALION)) && (testbit(inven,AMULET) || testbit(wear,AMULET))){
87 tempwiz = 1;
88 puts("The three amulets glow and reenforce each other in power. You are now a wizard.");
89 }
90 if (testbit(location[position].objects,ELF)){
91 printf("%s\n",objdes[ELF]);
92 fight(ELF,rnd(30));
93 }
94 if (testbit(location[position].objects,DARK)){
95 printf("%s\n",objdes[DARK]);
96 fight(DARK,100);
97 }
98 if (testbit(location[position].objects,WOODSMAN)){
99 printf("%s\n",objdes[WOODSMAN]);
100 fight(WOODSMAN,50);
101 }
102 switch(position){
103
104 case 267:
105 case 257: /* entering a cave */
106 case 274:
107 case 246:
108 notes[CANTSEE] = 1;
109 break;
110 case 160:
111 case 216: /* leaving a cave */
112 case 230:
113 case 231:
114 case 232:
115 notes[CANTSEE] = 0;
116 break;
117 }
118 if (testbit(location[position].objects, GIRL))
119 meetgirl = 1;
120 if (meetgirl && CYCLE * 1.5 - time < 10){
121 setbit(location[GARDEN].objects,GIRLTALK);
122 setbit(location[GARDEN].objects,LAMPON);
123 setbit(location[GARDEN].objects,ROPE);
124 }
125 if (position == DOCK && (beenthere[position] || time > CYCLE)){
126 clearbit(location[DOCK].objects, GIRL);
127 clearbit(location[DOCK].objects,MAN);
128 }
129 if (meetgirl && time - CYCLE * 1.5 > 10){
130 clearbit(location[GARDEN].objects,GIRLTALK);
131 clearbit(location[GARDEN].objects,LAMPON);
132 clearbit(location[GARDEN].objects,ROPE);
133 meetgirl = 0;
134 }
135 if (testbit(location[position].objects,CYLON)){
136 puts("Oh my God, you're being shot at by an alien spacecraft!");
137 printf("The targeting computer says we have %d seconds to attack!\n",clock);
138 fflush(stdout);
139 if (!visual()){
140 hurt = rnd(NUMOFINJURIES);
141 injuries[hurt] = 1;
142 puts("Laser blasts sear the cockpit, but then he veers off.");
143 puts("The viper shudders under a terrible explosion.");
144 printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
145 }
146 else
147 clearbit(location[position].objects,CYLON);
148 }
149 if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
150 puts("I'm afraid you have suffered fatal injuries.");
151 die();
152 }
153 for (n=0; n < NUMOFINJURIES; n++)
154 if (injuries[n] == 1){
155 injuries[n] = 2;
156 if (WEIGHT > 5)
157 WEIGHT -= 5;
158 else
159 WEIGHT = 0;
160 }
161 if (injuries[ARM] == 2){
162 CUMBER -= 5;
163 injuries[ARM]++;
164 }
165 if (injuries[RIBS] == 2){
166 CUMBER -= 2;
167 injuries[RIBS]++;
168 }
169 if (injuries[SPINE] == 2){
170 WEIGHT = 0;
171 injuries[SPINE]++;
172 }
173 if (carrying > WEIGHT || encumber > CUMBER)
174 notes[CANTMOVE] = 1;
175 else
176 notes[CANTMOVE] = 0;
177}
178
179crash()
180{
181 int hurt1,hurt2;
182
183 fuel--;
184 if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
185 if (!location[position].flyhere)
186 puts("You're flying too low. We're going to crash!");
187 else{
188 puts("You're out of fuel. We'll have to crash land!");
189 if (!location[position].down){
190 puts("You're viper strikes the ground and explodes into firey fragments.");
191 puts("Thick black smoke billows up from the wreckage.");
192 die();
193 }
194 position = location[position].down;
195 }
196 notes[LAUNCHED] = 0;
197 setbit(location[position].objects,CRASH);
198 time += rnd(CYCLE/4);
199 puts("The viper explodes into the ground and you lose consciousness...");
200 zzz();
201 hurt1 = rnd(NUMOFINJURIES - 2) + 2;
202 hurt2 = rnd(NUMOFINJURIES - 2) + 2;
203 injuries[hurt1] = 1;
204 injuries[hurt2] = 1;
205 injuries[0] = 1; /* abrasions */
206 injuries[1] = 1; /* lacerations */
207 printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]);
208 }
209}