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