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