xref: /openbsd/games/battlestar/globals.c (revision 84f04a3e)
1 /*	$OpenBSD: globals.c,v 1.16 2019/05/09 20:19:23 tedu Exp $	*/
2 /*	$NetBSD: globals.c,v 1.3 1995/03/21 15:07:32 cgd Exp $	*/
3 
4 /*
5  * Copyright (c) 1983, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 #include <stdio.h>		/* NULL */
34 #include "extern.h"
35 
36 int     WEIGHT = MAXWEIGHT;
37 int     CUMBER = MAXCUMBER;
38 
39 const char   *const objdes[NUMOFOBJECTS] = {
40 	"There is a knife here.",
41 	"There are an exquisitely crafted sword and scabbard here.",
42 	NULL,			/* can land from here */
43 	"There is a fierce woodsman here brandishing a heavy mallet.",
44 	"There is an unwieldy two-handed sword here.",
45 	"There is a bloody meat cleaver here.",
46 	"A rusty broadsword is lying here.",
47 	"There is an ancient coat of finely woven mail here.",
48 	"There is a old dented helmet with an ostrich plume here.",
49 	"There is a shield of some native tribe here.",
50 	"The maid's body is lying here. She was murdered!",
51 	"There is a Viper ready for launch here.",
52 	"A kerosene lantern is burning luridly here.",
53 	"An old pair of shoes has been discarded here.",
54 	NULL,			/* cylon */
55 	"There is a pair of pajamas here.",
56 	"A kingly robe of royal purple and spun gold is draped here.",
57 	"There is a strange golden amulet on the floor here.",
58 	"A medallion of solid gold shimmers on the ground nearby.",
59 	"A talisman of gold is lying here.",
60 	"A dead woodsman has fallen here. He was savagely murdered.",
61 	"A heavy wooden mallet lies nearby.",
62 	"There is a laser pistol here.",
63 	"A flower-like young goddess is bathing in the hot mineral pools. She is \nwatching you, but continues to steep and sing softly.",
64 	"The goddess is reclining on a bed of ferns and studying you intently.",
65 	"There is a grenade here.",
66 	"There is a length of heavy chain here.",
67 	"There is a stout rope here.",
68 	"There is a pair of Levi's here.",
69 	"A bloody mace is lying on the ground here.",
70 	"There is a shovel here.",
71 	"A long, sharp halberd is propped up here.",
72 	"There is a compass here.",
73 	"Wreckage and smoldering debris from a crash litter the ground here.",
74 	"A woodland Elf armed with a shield and deadly halberd lunges toward you!",
75 	"I think I hear footsteps behind us.",
76 	"There are a few coins here.",
77 	"There are some matches here.",
78 	"An unctuous man in a white suit and a dwarf are standing here.",
79 	"There are some ripe papayas here.",
80 	"There is a ripe pineapple here.",
81 	"There are some kiwi fruit here.",
82 	"There are some coconuts here.",
83 	"There is a ripe mango here.",
84 	"There is a sparkling diamond ring here.",
85 	"There is a colorful pink potion in a small crystal vial here.",
86 	"A gold bracelet is on the ground here.",
87 	"A swarthy woman with stern features pulls you aside from the crowd,\n'I must talk to you -- but not here.  Meet me at midnight in the gardens.'",
88 	"The swarthy woman has been awaiting you anxiously. 'I must warn you that the\nIsland has anticipated your Quest.  You will not be welcomed. The Darkness is\nstrong where you must search.  Seek not the shadows save only at night, for\nthen are they the weakest.  In the mountains far from here a canyon winds\nwith ferns and streams and forgotten vines.  There you must go. Take this\nrope.'",
89 	"Out from the shadows a figure leaps!  His black cape swirls around, and he\nholds a laser sword at your chest.  'So, you have come to fulfill the Quest.\nHa! Your weapons are no match for me!'",
90 	"An old-timer with one eye missing and no money for a drink sits at the bar.",
91 	"You are flying through an asteroid field!",
92 	"A planet is nearby.",
93 	"The ground is charred here.",
94 	"There is a thermonuclear warhead here.",
95 	"The fragile, beautiful young goddess lies here.  You murdered her horribly.",
96 	"The old-timer is lying here.  He is dead.",
97 	"The native girl's body is lying here.",
98 	"A native girl is sitting here.",
99 	"A gorgeous white stallion is standing here.",
100 	"The keys are in the ignition.",
101 	"A pot of pearls and jewels is sitting here.",
102 	"A bar of solid gold is here.",
103 	"There is a 10 kilogram diamond block here."
104 
105 };
106 
107 const char   *const objsht[NUMOFOBJECTS] = {
108 	"knife",
109 	"fine sword",
110 	NULL,			/* can land from here */
111 	"Woodsman",
112 	"two-handed sword",
113 	"meat cleaver",
114 	"broadsword",
115 	"coat of mail",
116 	"plumed helmet",
117 	"shield",
118 	"maid's body",
119 	"viper",
120 	"lantern",
121 	"shoes",
122 	NULL,			/* cylon */
123 	"pajamas",
124 	"robe",
125 	"amulet",
126 	"medallion",
127 	"talisman",
128 	"woodsman's body",
129 	"wooden mallet",
130 	"laser",
131 	NULL,			/* bathing goddess */
132 	NULL,			/* goddess */
133 	"grenade",
134 	"chain",
135 	"rope",
136 	"levis",
137 	"mace",
138 	"shovel",
139 	"halberd",
140 	"compass",
141 	NULL,			/* crash debris */
142 	"Elf",
143 	NULL,			/* footsteps */
144 	"coins",
145 	"match book",
146 	NULL,			/* man and dwarf */
147 	"papayas",
148 	"pineapple",
149 	"kiwi",
150 	"coconuts",
151 	"mango",
152 	"ring",
153 	"potion",
154 	"bracelet",
155 	NULL,			/* swarthy woman */
156 	NULL,			/* swarthy woman (with message) */
157 	"Dark Lord",
158 	NULL,			/* old-timer */
159 	NULL,			/* asteroid field */
160 	NULL,			/* nearby planet */
161 	NULL,			/* charred ground */
162 	"warhead",
163 	"goddess's body",
164 	"old-timer's body",
165 	"girl's body",
166 	NULL,			/* native girl */
167 	"stallion",
168 	"car",
169 	"pot of jewels",
170 	"bar of gold",
171 	"diamond block"
172 };
173 
174 const char    *const ouch[NUMOFINJURIES] = {
175 	"some minor abrasions",
176 	"some minor lacerations",
177 	"a minor puncture wound",
178 	"a minor amputation",
179 	"a sprained wrist",
180 	"a fractured ankle and shattered kneecap",
181 	"a broken arm and dislocated shoulder",
182 	"a few broken ribs",
183 	"a broken leg and torn ligaments",
184 	"a broken back and ruptured spleen",
185 	"some deep incisions and a loss of blood",
186 	"a fractured skull and mashed face",
187 	"a broken neck"
188 };
189 
190 const int     objwt[NUMOFOBJECTS] = {
191 	1, 	5,	0,	10,	15,	2,	10,	10,
192 	3,	5,	50,	2500,	2,	1,	100,	1,
193 	2,	1,	1,	1,	60,	10,	5,	0,
194 	50,	5,	15,	5,	1,	20,	10,	10,
195 	0,	0,	0,	0,	1,	0,	0,	1,
196 	1,	1,	2,	1,	0,	0,	0,	0,
197 	0,	0,	100,	0,	0,	0,	55,	47,
198 	50,	45,	45,	100,	2000,	30,	20,	10
199 };
200 
201 const int     objcumber[NUMOFOBJECTS] = {
202 	1, 	5,	0,	150,	10,	1,	5,	2,
203 	2,	1,	5,	10,	1,	1,	10,	1,
204 	1,	1,	1,	1,	7,	5,	4,	0,
205 	0,	1,	1,	1,	1,	5,	4,	4,
206 	1,	0,	0,	0,	1,	0,	0,	1,
207 	1,	1,	3,	1,	0,	0,	1,	0,
208 	0,	0,	10,	0,	0,	0,	7,	8,
209 	10,	8,	8,	10,	10,	3,	1,	2
210 };
211 
212 const int objflags[NUMOFOBJECTS] = {
213 	0,		0,	    OBJ_NONOBJ,	    OBJ_PERSON,
214 	0,		0,		0,		0,
215 	0,		0,		0,		0,
216 	0,	    OBJ_PLURAL,	    OBJ_NONOBJ,	    OBJ_PLURAL,
217 	0,	      OBJ_AN,		0,		0,
218 	0,		0,		0,	    OBJ_PERSON,
219     OBJ_PERSON,		0,		0,		0,
220     OBJ_PLURAL,		0,		0,		0,
221 	0,	OBJ_NONOBJ,	OBJ_AN | OBJ_PERSON, OBJ_NONOBJ,
222     OBJ_PLURAL,		0,	    OBJ_PERSON,	    OBJ_PLURAL,
223 	0,		0,	    OBJ_PLURAL,		0,
224 	0,		0,		0,	    OBJ_PERSON,
225     OBJ_PERSON,	    OBJ_PERSON,	    OBJ_PERSON,	    OBJ_NONOBJ,
226     OBJ_NONOBJ,	    OBJ_NONOBJ,		0,		0,
227       OBJ_AN,		0,	    OBJ_PERSON,		0,
228 	0,		0,		0,		0
229 };
230 
231 int     win = 1;
232 int     matchcount = 20;
233 int     followgod = -1;
234 int     followfight = -1;
235 
236 struct room *location;
237 
238  /* current input line */
239 char    words[NWORD][WORDLEN];
240 int     wordvalue[NWORD];
241 int     wordtype[NWORD];
242 int     wordcount, wordnumber;
243 int     stop_cypher;	/* continue parsing the current line? */
244 
245  /* state of the game */
246 int     ourtime;
247 int     position;
248 int     direction;
249 int     left, right, ahead, back;
250 int     fuel, torps;
251 int     carrying, encumber;
252 int     rythmn;
253 int     ate;
254 int     snooze;
255 int     meetgirl;
256 int     godready;
257 int     wintime;
258 int     tempwiz;
259 int     matchlight;
260 int     loved;
261 int     pleasure, power, ego;
262 int     notes[NUMOFNOTES];
263 unsigned int inven[NUMOFWORDS];
264 unsigned int wear[NUMOFWORDS];
265 char    beenthere[NUMOFROOMS + 1];
266 char    injuries[NUMOFINJURIES];
267 int     verbose = 0;
268 
269 const char *username;
270