]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com1.c
1 /* $NetBSD: com1.c,v 1.9 1999/09/18 19:38:46 jsm Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/cdefs.h>
39 static char sccsid
[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95";
41 __RCSID("$NetBSD: com1.c,v 1.9 1999/09/18 19:38:46 jsm Exp $");
52 if ((!notes
[CANTMOVE
] && !notes
[LAUNCHED
]) ||
53 testbit(location
[position
].objects
, LAND
) ||
54 (fuel
> 0 && notes
[LAUNCHED
]))
60 puts("You can't go this way.");
62 whichway(location
[position
]);
66 if (notes
[CANTMOVE
] && !notes
[LAUNCHED
])
67 puts("You aren't able to move; you better drop something.");
69 puts("You are out of fuel; now you will rot in space forever!");
74 convert(tothis
) /* Converts day to night and vice versa. */
75 int tothis
; /* Day objects are permanent. Night objects
77 { /* at dusk, and subtracted at dawn. */
81 if (tothis
== TONIGHT
) {
82 for (i
= 1; i
<= NUMOFROOMS
; i
++)
83 for (j
= 0; j
< NUMOFWORDS
; j
++)
84 nightfile
[i
].objects
[j
] = dayfile
[i
].objects
[j
];
85 for (p
= nightobjs
; p
->room
!= 0; p
++)
86 setbit(nightfile
[p
->room
].objects
, p
->obj
);
89 for (i
= 1; i
<= NUMOFROOMS
; i
++)
90 for (j
= 0; j
< NUMOFWORDS
; j
++)
91 dayfile
[i
].objects
[j
] = nightfile
[i
].objects
[j
];
92 for (p
= nightobjs
; p
->room
!= 0; p
++)
93 clearbit(dayfile
[p
->room
].objects
, p
->obj
);
104 if (ourtime
> 30 && position
< 32) {
105 puts("An explosion of shuddering magnitude splinters bulkheads and");
106 puts("ruptures the battlestar's hull. You are sucked out into the");
107 puts("frozen void of space and killed.");
110 if (ourtime
> 20 && position
< 32)
111 puts("Explosions rock the battlestar.");
112 if (ourtime
> snooze
) {
113 puts("You drop from exhaustion...");
116 if (ourtime
> snooze
- 5)
117 puts("You're getting tired.");
118 if (ourtime
> (rythmn
+ CYCLE
)) {
119 if (location
== nightfile
) {
121 if (OUTSIDE
&& ourtime
- rythmn
- CYCLE
< 10) {
122 puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
123 puts("You awake from a misty dream-world into stark reality.");
128 clearbit(location
[POOLS
].objects
, BATHGOD
);
129 if (OUTSIDE
&& ourtime
- rythmn
- CYCLE
< 10) {
130 puts("The dying sun sinks into the ocean, leaving a blood stained sunset.");
131 puts("The sky slowly fades from orange to violet to black. A few stars");
132 puts("flicker on, and it is night.");
133 puts("The world seems completly different at night.");
136 rythmn
= ourtime
- ourtime
% CYCLE
;
138 if (!wiz
&& !tempwiz
)
139 if ((testbit(inven
, TALISMAN
) || testbit(wear
, TALISMAN
)) && (testbit(inven
, MEDALION
) || testbit(wear
, MEDALION
)) && (testbit(inven
, AMULET
) || testbit(wear
, AMULET
))) {
141 puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard.");
143 if (testbit(location
[position
].objects
, ELF
)) {
144 printf("%s\n", objdes
[ELF
]);
147 if (testbit(location
[position
].objects
, DARK
)) {
148 printf("%s\n", objdes
[DARK
]);
151 if (testbit(location
[position
].objects
, WOODSMAN
)) {
152 printf("%s\n", objdes
[WOODSMAN
]);
158 case 257: /* entering a cave */
164 case 216: /* leaving a cave */
171 if (testbit(location
[position
].objects
, GIRL
))
173 if (meetgirl
&& CYCLE
* 1.5 - ourtime
< 10) {
174 setbit(location
[GARDEN
].objects
, GIRLTALK
);
175 setbit(location
[GARDEN
].objects
, LAMPON
);
176 setbit(location
[GARDEN
].objects
, ROPE
);
178 if (position
== DOCK
&& (beenthere
[position
] || ourtime
> CYCLE
)) {
179 clearbit(location
[DOCK
].objects
, GIRL
);
180 clearbit(location
[DOCK
].objects
, MAN
);
182 if (meetgirl
&& ourtime
- CYCLE
* 1.5 > 10) {
183 clearbit(location
[GARDEN
].objects
, GIRLTALK
);
184 clearbit(location
[GARDEN
].objects
, LAMPON
);
185 clearbit(location
[GARDEN
].objects
, ROPE
);
188 if (testbit(location
[position
].objects
, CYLON
)) {
189 puts("Oh my God, you're being shot at by an alien spacecraft!");
190 printf("The targeting computer says we have %d seconds to attack!\n",
195 hurt
= rnd(NUMOFINJURIES
);
197 puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
198 puts("The viper shudders under a terrible explosion.");
199 printf("I'm afraid you have suffered %s.\n", ouch
[hurt
]);
201 clearbit(location
[position
].objects
, CYLON
);
203 if (injuries
[SKULL
] && injuries
[INCISE
] && injuries
[NECK
]) {
204 puts("I'm afraid you have suffered fatal injuries.");
207 for (n
= 0; n
< NUMOFINJURIES
; n
++)
208 if (injuries
[n
] == 1) {
215 if (injuries
[ARM
] == 2) {
219 if (injuries
[RIBS
] == 2) {
223 if (injuries
[SPINE
] == 2) {
227 if (carrying
> WEIGHT
|| encumber
> CUMBER
)
239 if (!location
[position
].flyhere
||
240 (testbit(location
[position
].objects
, LAND
) && fuel
<= 0)) {
241 if (!location
[position
].flyhere
)
242 puts("You're flying too low. We're going to crash!");
244 puts("You're out of fuel. We'll have to crash land!");
245 if (!location
[position
].down
) {
246 puts("Your viper strikes the ground and explodes into fiery fragments.");
247 puts("Thick black smoke billows up from the wreckage.");
250 position
= location
[position
].down
;
253 setbit(location
[position
].objects
, CRASH
);
254 ourtime
+= rnd(CYCLE
/ 4);
255 puts("The viper explodes into the ground and you lose consciousness...");
257 hurt1
= rnd(NUMOFINJURIES
- 2) + 2;
258 hurt2
= rnd(NUMOFINJURIES
- 2) + 2;
261 injuries
[0] = 1;/* abrasions */
262 injuries
[1] = 1;/* lacerations */
263 printf("I'm afraid you have suffered %s and %s.\n",
264 ouch
[hurt1
], ouch
[hurt2
]);