]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/command1.c
1 /* $NetBSD: command1.c,v 1.2 2003/08/07 09:37:00 agc 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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95";
37 __RCSID("$NetBSD: command1.c,v 1.2 2003/08/07 09:37:00 agc Exp $");
44 moveplayer(thataway
, token
)
48 if ((!notes
[CANTMOVE
] && !notes
[LAUNCHED
]) ||
49 testbit(location
[position
].objects
, LAND
) ||
50 (fuel
> 0 && notes
[LAUNCHED
])) {
56 puts("You can't go this way.");
58 whichway(location
[position
]);
62 if (notes
[CANTMOVE
] && !notes
[LAUNCHED
])
63 puts("You aren't able to move; you better drop something.");
65 puts("You are out of fuel; now you will rot in space forever!");
71 convert(tothis
) /* Converts day to night and vice versa. */
72 int tothis
; /* Day objects are permanent. Night objects
74 { /* at dusk, and subtracted at dawn. */
78 if (tothis
== TONIGHT
) {
79 for (i
= 1; i
<= NUMOFROOMS
; i
++)
80 for (j
= 0; j
< NUMOFWORDS
; j
++)
81 nightfile
[i
].objects
[j
] = dayfile
[i
].objects
[j
];
82 for (p
= nightobjs
; p
->room
!= 0; p
++)
83 setbit(nightfile
[p
->room
].objects
, p
->obj
);
86 for (i
= 1; i
<= NUMOFROOMS
; i
++)
87 for (j
= 0; j
< NUMOFWORDS
; j
++)
88 dayfile
[i
].objects
[j
] = nightfile
[i
].objects
[j
];
89 for (p
= nightobjs
; p
->room
!= 0; p
++)
90 clearbit(dayfile
[p
->room
].objects
, p
->obj
);
101 if (ourtime
> 30 && position
< 32) {
102 puts("An explosion of shuddering magnitude splinters bulkheads and");
103 puts("ruptures the battlestar's hull. You are sucked out into the");
104 puts("frozen void of space and killed.");
107 if (ourtime
> 20 && position
< 32)
108 puts("Explosions rock the battlestar.");
109 if (ourtime
> snooze
) {
110 puts("You drop from exhaustion...");
113 if (ourtime
> snooze
- 5)
114 puts("You're getting tired.");
115 if (ourtime
> (rythmn
+ CYCLE
)) {
116 if (location
== nightfile
) {
118 if (OUTSIDE
&& ourtime
- rythmn
- CYCLE
< 10) {
119 puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
120 puts("You awake from a misty dream-world into stark reality.");
125 clearbit(location
[POOLS
].objects
, BATHGOD
);
126 if (OUTSIDE
&& ourtime
- rythmn
- CYCLE
< 10) {
127 puts("The dying sun sinks into the ocean, leaving a blood-stained sunset.");
128 puts("The sky slowly fades from orange to violet to black. A few stars");
129 puts("flicker on, and it is night.");
130 puts("The world seems completely different at night.");
133 rythmn
= ourtime
- ourtime
% CYCLE
;
135 if (!wiz
&& !tempwiz
)
136 if ((testbit(inven
, TALISMAN
) || testbit(wear
, TALISMAN
)) && (testbit(inven
, MEDALION
) || testbit(wear
, MEDALION
)) && (testbit(inven
, AMULET
) || testbit(wear
, AMULET
))) {
138 puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard.");
140 if (testbit(location
[position
].objects
, ELF
)) {
141 printf("%s\n", objdes
[ELF
]);
144 if (testbit(location
[position
].objects
, DARK
)) {
145 printf("%s\n", objdes
[DARK
]);
148 if (testbit(location
[position
].objects
, WOODSMAN
)) {
149 printf("%s\n", objdes
[WOODSMAN
]);
155 case 257: /* entering a cave */
161 case 216: /* leaving a cave */
168 if (testbit(location
[position
].objects
, GIRL
))
170 if (meetgirl
&& CYCLE
* 1.5 - ourtime
< 10) {
171 setbit(location
[GARDEN
].objects
, GIRLTALK
);
172 setbit(location
[GARDEN
].objects
, LAMPON
);
173 setbit(location
[GARDEN
].objects
, ROPE
);
175 if (position
== DOCK
&& (beenthere
[position
] || ourtime
> CYCLE
)) {
176 clearbit(location
[DOCK
].objects
, GIRL
);
177 clearbit(location
[DOCK
].objects
, MAN
);
179 if (meetgirl
&& ourtime
- CYCLE
* 1.5 > 10) {
180 clearbit(location
[GARDEN
].objects
, GIRLTALK
);
181 clearbit(location
[GARDEN
].objects
, LAMPON
);
182 clearbit(location
[GARDEN
].objects
, ROPE
);
185 if (testbit(location
[position
].objects
, CYLON
)) {
186 puts("Oh my God, you're being shot at by an alien spacecraft!");
187 printf("The targeting computer says we have %d seconds to attack!\n",
192 hurt
= rnd(NUMOFINJURIES
);
194 puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
195 puts("The viper shudders under a terrible explosion.");
196 printf("I'm afraid you have suffered %s.\n", ouch
[hurt
]);
198 clearbit(location
[position
].objects
, CYLON
);
200 if (injuries
[SKULL
] && injuries
[INCISE
] && injuries
[NECK
]) {
201 puts("I'm afraid you have suffered fatal injuries.");
204 for (n
= 0; n
< NUMOFINJURIES
; n
++)
205 if (injuries
[n
] == 1) {
212 if (injuries
[ARM
] == 2) {
219 if (injuries
[RIBS
] == 2) {
226 if (injuries
[SPINE
] == 2) {
230 if (carrying
> WEIGHT
|| encumber
> CUMBER
)
242 if (!location
[position
].flyhere
||
243 (testbit(location
[position
].objects
, LAND
) && fuel
<= 0)) {
244 if (!location
[position
].flyhere
)
245 puts("You're flying too low. We're going to crash!");
247 puts("You're out of fuel. We'll have to crash land!");
248 if (!location
[position
].down
) {
249 puts("Your viper strikes the ground and explodes into fiery fragments.");
250 puts("Thick black smoke billows up from the wreckage.");
253 position
= location
[position
].down
;
256 setbit(location
[position
].objects
, CRASH
);
257 ourtime
+= rnd(CYCLE
/ 4);
258 puts("The viper explodes into the ground and you lose consciousness...");
260 hurt1
= rnd(NUMOFINJURIES
- 2) + 2;
261 hurt2
= rnd(NUMOFINJURIES
- 2) + 2;
264 injuries
[0] = 1;/* abrasions */
265 injuries
[1] = 1;/* lacerations */
266 printf("I'm afraid you have suffered %s and %s.\n",
267 ouch
[hurt1
], ouch
[hurt2
]);