]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com1.c
Add RCS identifiers.
[bsdgames-darwin.git] / battlestar / com1.c
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, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #ifndef lint
35 /*static char sccsid[] = "from: @(#)com1.c 5.3 (Berkeley) 6/1/90";*/
36 static char rcsid[] = "$Id: com1.c,v 1.2 1993/08/01 18:56:13 mycroft Exp $";
37 #endif /* not lint */
38
39 #include "externs.h"
40
41 move(thataway, token)
42 int thataway, token;
43 {
44 wordnumber++;
45 if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || fuel > 0 && notes[LAUNCHED])
46 if (thataway) {
47 position = thataway;
48 newway(token);
49 time++;
50 }
51 else {
52 puts("You can't go this way.");
53 newway(token);
54 whichway(location[position]);
55 return(0);
56 }
57 else if (notes[CANTMOVE] && !notes[LAUNCHED])
58 puts("You aren't able to move; you better drop something.");
59 else
60 puts("You are out of fuel; now you will rot in space forever!");
61 return(1);
62 }
63
64 convert(tothis) /* Converts day to night and vice versa. */
65 int tothis; /* Day objects are permanent. Night objects are added*/
66 { /* at dusk, and subtracted at dawn. */
67 register struct objs *p;
68 register i, j;
69
70 if (tothis == TONIGHT) {
71 for (i = 1; i <= NUMOFROOMS; i++)
72 for (j = 0; j < NUMOFWORDS; j++)
73 nightfile[i].objects[j] = dayfile[i].objects[j];
74 for (p = nightobjs; p->room != 0; p++)
75 setbit(nightfile[p->room].objects, p->obj);
76 location = nightfile;
77 } else {
78 for (i = 1; i <= NUMOFROOMS; i++)
79 for (j = 0; j < NUMOFWORDS; j++)
80 dayfile[i].objects[j] = nightfile[i].objects[j];
81 for (p = nightobjs; p->room != 0; p++)
82 clearbit(dayfile[p->room].objects, p->obj);
83 location = dayfile;
84 }
85 }
86
87 news()
88 {
89 register int n;
90 int hurt;
91
92 if (time > 30 && position < 32){
93 puts("An explosion of shuddering magnitude splinters bulkheads and");
94 puts("ruptures the battlestar's hull. You are sucked out into the");
95 puts("frozen void of space and killed.");
96 die();
97 }
98 if (time > 20 && position < 32)
99 puts("Explosions rock the battlestar.");
100 if (time > snooze){
101 puts("You drop from exhaustion...");
102 zzz();
103 }
104 if (time > snooze - 5)
105 puts("You're getting tired.");
106 if (time > (rythmn + CYCLE)) {
107 if (location == nightfile) {
108 convert(TODAY);
109 if (OUTSIDE && time - rythmn - CYCLE < 10) {
110 puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
111 puts("You awake from a misty dream-world into stark reality.");
112 puts("It is day.");
113 }
114 } else {
115 convert(TONIGHT);
116 clearbit(location[POOLS].objects, BATHGOD);
117 if (OUTSIDE && time - rythmn - CYCLE < 10) {
118 puts("The dying sun sinks into the ocean, leaving a blood stained sunset.");
119 puts("The sky slowly fades from orange to violet to black. A few stars");
120 puts("flicker on, and it is night.");
121 puts("The world seems completly different at night.");
122 }
123 }
124 rythmn = time - time % CYCLE;
125 }
126 if (!wiz && !tempwiz)
127 if ((testbit(inven,TALISMAN) || testbit(wear,TALISMAN)) && (testbit(inven,MEDALION) || testbit(wear,MEDALION)) && (testbit(inven,AMULET) || testbit(wear,AMULET))){
128 tempwiz = 1;
129 puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard.");
130 }
131 if (testbit(location[position].objects,ELF)){
132 printf("%s\n",objdes[ELF]);
133 fight(ELF,rnd(30));
134 }
135 if (testbit(location[position].objects,DARK)){
136 printf("%s\n",objdes[DARK]);
137 fight(DARK,100);
138 }
139 if (testbit(location[position].objects,WOODSMAN)){
140 printf("%s\n",objdes[WOODSMAN]);
141 fight(WOODSMAN,50);
142 }
143 switch(position){
144
145 case 267:
146 case 257: /* entering a cave */
147 case 274:
148 case 246:
149 notes[CANTSEE] = 1;
150 break;
151 case 160:
152 case 216: /* leaving a cave */
153 case 230:
154 case 231:
155 case 232:
156 notes[CANTSEE] = 0;
157 break;
158 }
159 if (testbit(location[position].objects, GIRL))
160 meetgirl = 1;
161 if (meetgirl && CYCLE * 1.5 - time < 10){
162 setbit(location[GARDEN].objects,GIRLTALK);
163 setbit(location[GARDEN].objects,LAMPON);
164 setbit(location[GARDEN].objects,ROPE);
165 }
166 if (position == DOCK && (beenthere[position] || time > CYCLE)){
167 clearbit(location[DOCK].objects, GIRL);
168 clearbit(location[DOCK].objects,MAN);
169 }
170 if (meetgirl && time - CYCLE * 1.5 > 10){
171 clearbit(location[GARDEN].objects,GIRLTALK);
172 clearbit(location[GARDEN].objects,LAMPON);
173 clearbit(location[GARDEN].objects,ROPE);
174 meetgirl = 0;
175 }
176 if (testbit(location[position].objects,CYLON)){
177 puts("Oh my God, you're being shot at by an alien spacecraft!");
178 printf("The targeting computer says we have %d seconds to attack!\n",clock);
179 fflush(stdout);
180 sleep(1);
181 if (!visual()){
182 hurt = rnd(NUMOFINJURIES);
183 injuries[hurt] = 1;
184 puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
185 puts("The viper shudders under a terrible explosion.");
186 printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
187 }
188 else
189 clearbit(location[position].objects,CYLON);
190 }
191 if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
192 puts("I'm afraid you have suffered fatal injuries.");
193 die();
194 }
195 for (n=0; n < NUMOFINJURIES; n++)
196 if (injuries[n] == 1){
197 injuries[n] = 2;
198 if (WEIGHT > 5)
199 WEIGHT -= 5;
200 else
201 WEIGHT = 0;
202 }
203 if (injuries[ARM] == 2){
204 CUMBER -= 5;
205 injuries[ARM]++;
206 }
207 if (injuries[RIBS] == 2){
208 CUMBER -= 2;
209 injuries[RIBS]++;
210 }
211 if (injuries[SPINE] == 2){
212 WEIGHT = 0;
213 injuries[SPINE]++;
214 }
215 if (carrying > WEIGHT || encumber > CUMBER)
216 notes[CANTMOVE] = 1;
217 else
218 notes[CANTMOVE] = 0;
219 }
220
221 crash()
222 {
223 int hurt1,hurt2;
224
225 fuel--;
226 if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
227 if (!location[position].flyhere)
228 puts("You're flying too low. We're going to crash!");
229 else{
230 puts("You're out of fuel. We'll have to crash land!");
231 if (!location[position].down){
232 puts("Your viper strikes the ground and explodes into firey fragments.");
233 puts("Thick black smoke billows up from the wreckage.");
234 die();
235 }
236 position = location[position].down;
237 }
238 notes[LAUNCHED] = 0;
239 setbit(location[position].objects,CRASH);
240 time += rnd(CYCLE/4);
241 puts("The viper explodes into the ground and you lose consciousness...");
242 zzz();
243 hurt1 = rnd(NUMOFINJURIES - 2) + 2;
244 hurt2 = rnd(NUMOFINJURIES - 2) + 2;
245 injuries[hurt1] = 1;
246 injuries[hurt2] = 1;
247 injuries[0] = 1; /* abrasions */
248 injuries[1] = 1; /* lacerations */
249 printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]);
250 }
251 }