xref: /netbsd-src/games/battlestar/globals.c (revision 475cad676332cba515027c3ccc68aa4dfc6d14f3)
1 /*	$NetBSD: globals.c,v 1.20 2020/12/06 11:35:27 dholland Exp $	*/
2 
3 /*
4  * Copyright (c) 1983, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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.
18  *
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
29  * SUCH DAMAGE.
30  */
31 
32 #include <sys/cdefs.h>
33 #ifndef lint
34 #if 0
35 static char sccsid[] = "@(#)globals.c	8.2 (Berkeley) 4/28/95";
36 #else
37 __RCSID("$NetBSD: globals.c,v 1.20 2020/12/06 11:35:27 dholland Exp $");
38 #endif
39 #endif				/* not lint */
40 
41 #include "extern.h"
42 
43 int     WEIGHT = MAXWEIGHT;
44 int     CUMBER = MAXCUMBER;
45 
46 const char   *const objdes[NUMOFOBJECTS] = {
47 	"There is a knife here.",
48 	"There are an exquisitely crafted sword and scabbard here.",
49 	NULL,			/* Can land from here. */
50 	"There is a fierce woodsman here brandishing a heavy mallet.",
51 	"There is an unwieldy two-handed sword here.",
52 	"There is a bloody meat cleaver here.",
53 	"A rusty broadsword is lying here.",
54 	"There is an ancient coat of finely woven mail here.",
55 	"There is a old dented helmet with an ostrich plume here.",
56 	"There is a shield of some native tribe here.",
57 	"The maid's body is lying here. She was murdered!",
58 	"There is a Viper ready for launch here.",
59 	"A kerosene lantern is burning luridly here.",
60 	"An old pair of shoes has been discarded here.",
61 	NULL,			/* Cylon. */
62 	"There is a pair of pajamas here.",
63 	"A kingly robe of royal purple and spun gold is draped here.",
64 	"There is a strange golden amulet on the floor here.",
65 	"A medallion of solid gold shimmers on the ground nearby.",
66 	"A talisman of gold is lying here.",
67 	"A dead woodsman has fallen here. He was savagely murdered.",
68 	"A heavy wooden mallet lies nearby.",
69 	"There is a laser pistol here.",
70 	"A flower-like young goddess is bathing in the hot mineral pools. She "
71 		"is \nwatching you, but continues to steep and sing softly.",
72 	"The goddess is reclining on a bed of ferns and studying you intently.",
73 	"There is a grenade here.",
74 	"There is a length of heavy chain here.",
75 	"There is a stout rope here.",
76 	"There is a pair of Levi's here.",
77 	"A bloody mace is lying on the ground here.",
78 	"There is a shovel here.",
79 	"A long, sharp halberd is propped up here.",
80 	"There is a compass here.",
81 	"Wreckage and smoldering debris from a crash litter the ground here.",
82 	"A woodland Elf armed with a shield and deadly halberd lunges toward "
83 		"you!",
84 	"I think I hear footsteps behind us.",
85 	"There are a few coins here.",
86 	"There are some matches here.",
87 	"An unctuous man in a white suit and a dwarf are standing here.",
88 	"There are some ripe papayas here.",
89 	"There is a ripe pineapple here.",
90 	"There are some kiwi fruit here.",
91 	"There are some coconuts here.",
92 	"There is a ripe mango here.",
93 	"There is a sparkling diamond ring here.",
94 	"There is a colorful pink potion in a small crystal vial here.",
95 	"A gold bracelet is on the ground here.",
96 	"A swarthy woman with stern features pulls you aside from the crowd,\n"
97 		"'I must talk to you -- but not here.  "
98 		"Meet me at midnight in the gardens.'",
99 	"The swarthy woman has been awaiting you anxiously. 'I must warn you "
100 		"that the\nIsland has anticipated your Quest.  You will not be "
101 		"welcomed. The Darkness is\nstrong where you must search.  Seek"
102 		" not the shadows save only at night, for\nthen are they the "
103 		"weakest.  In the mountains far from here a canyon winds\nwith "
104 		"ferns and streams and forgotten vines.  There you must go. "
105 		"Take this\nrope.'",
106 	"Out from the shadows a figure leaps!  His black cape swirls around,"
107 		" and he\nholds a laser sword at your chest.  'So, you have"
108 		" come to fulfill the Quest.\nHa! Your weapons are no match for"
109 		" me!'",
110 	"An old-timer with one eye missing and no money for a drink sits at the"
111 		" bar.",
112 	"You are flying through an asteroid field!",
113 	"A planet is nearby.",
114 	"The ground is charred here.",
115 	"There is a thermonuclear warhead here.",
116 	"The fragile, beautiful young goddess lies here.  You murdered her "
117 		"horribly.",
118 	"The old-timer is lying here.  He is dead.",
119 	"The native girl's body is lying here.",
120 	"A native girl is sitting here.",
121 	"A gorgeous white stallion is standing here.",
122 	"The keys are in the ignition.",
123 	"A pot of pearls and jewels is sitting here.",
124 	"A bar of solid gold is here.",
125 	"There is a 10 kilogram diamond block here."
126 
127 };
128 
129 const char   *const objsht[NUMOFOBJECTS] = {
130 	"knife",
131 	"fine sword",
132 	NULL,			/* Can land from here. */
133 	"Woodsman",
134 	"two-handed sword",
135 	"meat cleaver",
136 	"broadsword",
137 	"coat of mail",
138 	"plumed helmet",
139 	"shield",
140 	"maid's body",
141 	"viper",
142 	"lantern",
143 	"shoes",
144 	NULL,			/* Cylon. */
145 	"pajamas",
146 	"robe",
147 	"amulet",
148 	"medallion",
149 	"talisman",
150 	"woodsman's body",
151 	"wooden mallet",
152 	"laser",
153 	NULL,			/* Bathing goddess. */
154 	NULL,			/* Goddess. */
155 	"grenade",
156 	"chain",
157 	"rope",
158 	"levis",
159 	"mace",
160 	"shovel",
161 	"halberd",
162 	"compass",
163 	NULL,			/* Crash debris. */
164 	"Elf",
165 	NULL,			/* Footsteps. */
166 	"coins",
167 	"match book",
168 	NULL,			/* Man and dwarf. */
169 	"papayas",
170 	"pineapple",
171 	"kiwi",
172 	"coconuts",
173 	"mango",
174 	"ring",
175 	"potion",
176 	"bracelet",
177 	NULL,			/* Swarthy woman. */
178 	NULL,			/* Swarthy woman (with message). */
179 	"Dark Lord",
180 	NULL,			/* Old-timer. */
181 	NULL,			/* Asteroid field. */
182 	NULL,			/* Planet nearby. */
183 	NULL,			/* Charred ground. */
184 	"warhead",
185 	"goddess's body",
186 	"old-timer's body",
187 	"girl's body",
188 	NULL,			/* Native girl. */
189 	"stallion",
190 	"car",
191 	"pot of jewels",
192 	"bar of gold",
193 	"diamond block"
194 };
195 
196 const char   *const ouch[NUMOFINJURIES] = {
197 	"some minor abrasions",
198 	"some minor lacerations",
199 	"a minor puncture wound",
200 	"a minor amputation",
201 	"a sprained wrist",
202 	"a fractured ankle and shattered kneecap",
203 	"a broken arm and dislocated shoulder",
204 	"a few broken ribs",
205 	"a broken leg and torn ligaments",
206 	"a broken back and ruptured spleen",
207 	"some deep incisions and a loss of blood",
208 	"a fractured skull and mashed face",
209 	"a broken neck"
210 };
211 
212 const int     objwt[NUMOFOBJECTS] = {
213 	1, 5, 0, 10, 15, 2, 10, 10,
214 	3, 5, 50, 2500, 2, 1, 100, 1,
215 	2, 1, 1, 1, 60, 10, 5, 0,
216 	50, 5, 15, 5, 1, 20, 10, 10,
217 	0, 0, 0, 0, 1, 0, 0, 1,
218 	1, 1, 2, 1, 0, 0, 0, 0,
219 	0, 0, 100, 0, 0, 0, 55, 47,
220 	50, 45, 45, 100, 2000, 30, 20, 10
221 };
222 
223 const int     objcumber[NUMOFOBJECTS] = {
224 	1, 5, 0, 150, 10, 1, 5, 2,
225 	2, 1, 5, 10, 1, 1, 10, 1,
226 	1, 1, 1, 1, 7, 5, 4, 0,
227 	0, 1, 1, 1, 1, 5, 4, 4,
228 	1, 0, 0, 0, 1, 0, 0, 1,
229 	1, 1, 3, 1, 0, 0, 1, 0,
230 	0, 0, 10, 0, 0, 0, 7, 8,
231 	10, 8, 8, 10, 10, 3, 1, 2
232 };
233 
234 const int objflags[NUMOFOBJECTS] = {
235 	0,		0,	    OBJ_NONOBJ,	    OBJ_PERSON,
236 	0,		0,		0,		0,
237 	0,		0,		0,		0,
238 	0,	    OBJ_PLURAL,	    OBJ_NONOBJ,	    OBJ_PLURAL,
239 	0,	      OBJ_AN,		0,		0,
240 	0,		0,		0,	    OBJ_PERSON,
241     OBJ_PERSON,		0,		0,		0,
242     OBJ_PLURAL,		0,		0,		0,
243 	0,		0,	OBJ_AN|OBJ_PERSON,  OBJ_NONOBJ,
244     OBJ_PLURAL,		0,	    OBJ_PERSON,	    OBJ_PLURAL,
245 	0,		0,	    OBJ_PLURAL,		0,
246 	0,		0,		0,	    OBJ_PERSON,
247     OBJ_PERSON,	    OBJ_PERSON,	    OBJ_PERSON,	    OBJ_NONOBJ,
248     OBJ_NONOBJ,	    OBJ_NONOBJ,		0,		0,
249       OBJ_AN,		0,	    OBJ_PERSON,		0,
250 	0,		0,		0,		0
251 };
252 
253 int     win = 1;
254 int     matchcount = 20;
255 int     followgod = -1;
256 int     followfight = -1;
257 
258 struct room *location;
259 
260  /* current input line */
261 char    words[NWORD][WORDLEN];
262 int     wordvalue[NWORD];
263 int     wordtype[NWORD];
264 int     wordcount, wordnumber;
265 
266  /* state of the game */
267 int     ourtime;
268 int     position;
269 int     direction;
270 int     left, right, ahead, back;
271 int     fuel, torps;
272 int     carrying, encumber;
273 int     rythmn;
274 int     ate;
275 int     snooze;
276 int     meetgirl;
277 int     godready;
278 int     wintime;
279 int     wiz;
280 int     tempwiz;
281 int     matchlight;
282 int     loved;
283 int     pleasure, power, ego;
284 int     notes[NUMOFNOTES];
285 unsigned int inven[NUMOFWORDS];
286 unsigned int wear[NUMOFWORDS];
287 char    beenthere[NUMOFROOMS + 1];
288 char    injuries[NUMOFINJURIES];
289 int     verbose = 0;
290 
291 const char *username;
292