Merge branch 'vendor/BYACC'
[dragonfly.git] / games / battlestar / globals.c
1 /*      @(#)globals.c   8.2 (Berkeley) 4/28/95                  */
2 /*      $NetBSD: globals.c,v 1.19 2003/08/07 09:37:02 agc 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 "extern.h"
34
35 int     WEIGHT = MAXWEIGHT;
36 int     CUMBER = MAXCUMBER;
37
38 const char   *const objdes[NUMOFOBJECTS] = {
39         "There is a knife here.",
40         "There are an exquisitely crafted sword and scabbard here.",
41         NULL,                   /* Can land from here. */
42         "There is a fierce woodsman here brandishing a heavy mallet.",
43         "There is an unwieldy two-handed sword here.",
44         "There is a bloody meat cleaver here.",
45         "A rusty broadsword is lying here.",
46         "There is an ancient coat of finely woven mail here.",
47         "There is an old dented helmet with an ostrich plume here.",
48         "There is a shield of some native tribe here.",
49         "The maid's body is lying here. She was murdered!",
50         "There is a Viper ready for launch here.",
51         "A kerosene lantern is burning luridly here.",
52         "An old pair of shoes has been discarded here.",
53         NULL,                   /* Cylon. */
54         "There is a pair of pajamas here.",
55         "A kingly robe of royal purple and spun gold is draped here.",
56         "There is a strange golden amulet on the floor here.",
57         "A medallion of solid gold shimmers on the ground nearby.",
58         "A talisman of gold is lying here.",
59         "A dead woodsman has fallen here. He was savagely murdered.",
60         "A heavy wooden mallet lies nearby.",
61         "There is a laser pistol here.",
62         "A flower-like young goddess is bathing in the hot mineral pools. She is \nwatching you, but continues to steep and sing softly.",
63         "The goddess is reclining on a bed of ferns and studying you intently.",
64         "There is a grenade here.",
65         "There is a length of heavy chain here.",
66         "There is a stout rope here.",
67         "There is a pair of Levi's here.",
68         "A bloody mace is lying on the ground here.",
69         "There is a shovel here.",
70         "A long, sharp halberd is propped up here.",
71         "There is a compass here.",
72         "Wreckage and smoldering debris from a crash litter the ground here.",
73         "A woodland Elf armed with a shield and deadly halberd lunges toward you!",
74         "I think I hear footsteps behind us.",
75         "There are a few coins here.",
76         "There are some matches here.",
77         "An unctuous man in a white suit and a dwarf are standing here.",
78         "There are some ripe papayas here.",
79         "There is a ripe pineapple here.",
80         "There are some kiwi fruit here.",
81         "There are some coconuts here.",
82         "There is a ripe mango here.",
83         "There is a sparkling diamond ring here.",
84         "There is a colorful pink potion in a small crystal vial here.",
85         "A gold bracelet is on the ground here.",
86         "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.'",
87         "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.'",
88         "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!'",
89         "An old-timer with one eye missing and no money for a drink sits at the bar.",
90         "You are flying through an asteroid field!",
91         "A planet is nearby.",
92         "The ground is charred here.",
93         "There is a thermonuclear warhead here.",
94         "The fragile, beautiful young goddess lies here.  You murdered her horribly.",
95         "The old-timer is lying here.  He is dead.",
96         "The native girl's body is lying here.",
97         "A native girl is sitting here.",
98         "A gorgeous white stallion is standing here.",
99         "The keys are in the ignition.",
100         "A pot of pearls and jewels is sitting here.",
101         "A bar of solid gold is here.",
102         "There is a 10 kilogram diamond block here."
103
104 };
105
106 const char   *const objsht[NUMOFOBJECTS] = {
107         "knife",
108         "fine sword",
109         NULL,                   /* Can land from here. */
110         "Woodsman",
111         "two-handed sword",
112         "meat cleaver",
113         "broadsword",
114         "coat of mail",
115         "plumed helmet",
116         "shield",
117         "maid's body",
118         "viper",
119         "lantern",
120         "shoes",
121         NULL,                   /* Cylon. */
122         "pajamas",
123         "robe",
124         "amulet",
125         "medallion",
126         "talisman",
127         "woodsman's body",
128         "wooden mallet",
129         "laser",
130         NULL,                   /* Bathing goddess. */
131         NULL,                   /* Goddess. */
132         "grenade",
133         "chain",
134         "rope",
135         "levis",
136         "mace",
137         "shovel",
138         "halberd",
139         "compass",
140         NULL,                   /* Crash debris. */
141         "Elf",
142         NULL,                   /* Footsteps. */
143         "coins",
144         "match book",
145         NULL,                   /* Man and dwarf. */
146         "papayas",
147         "pineapple",
148         "kiwi",
149         "coconuts",
150         "mango",
151         "ring",
152         "potion",
153         "bracelet",
154         NULL,                   /* Swarthy woman. */
155         NULL,                   /* Swarthy woman (with message). */
156         "Dark Lord",
157         NULL,                   /* Old-timer. */
158         NULL,                   /* Asteroid field. */
159         NULL,                   /* Planet nearby. */
160         NULL,                   /* Charred ground. */
161         "warhead",
162         "goddess's body",
163         "old-timer's body",
164         "girl's body",
165         NULL,                   /* Native girl. */
166         "stallion",
167         "car",
168         "pot of jewels",
169         "bar of gold",
170         "diamond block"
171 };
172
173 const char   *const ouch[NUMOFINJURIES] = {
174         "some minor abrasions",
175         "some minor lacerations",
176         "a minor puncture wound",
177         "a minor amputation",
178         "a sprained wrist",
179         "a fractured ankle and shattered kneecap",
180         "a broken arm and dislocated shoulder",
181         "a few broken ribs",
182         "a broken leg and torn ligaments",
183         "a broken back and ruptured spleen",
184         "some deep incisions and a loss of blood",
185         "a fractured skull and mashed face",
186         "a broken neck"
187 };
188
189 const int     objwt[NUMOFOBJECTS] = {
190         1, 5, 0, 10, 15, 2, 10, 10,
191         3, 5, 50, 2500, 2, 1, 100, 1,
192         2, 1, 1, 1, 60, 10, 5, 0,
193         50, 5, 15, 5, 1, 20, 10, 10,
194         0, 0, 0, 0, 1, 0, 0, 1,
195         1, 1, 2, 1, 0, 0, 0, 0,
196         0, 0, 100, 0, 0, 0, 55, 47,
197         50, 45, 45, 100, 2000, 30, 20, 10
198 };
199
200 const int     objcumber[NUMOFOBJECTS] = {
201         1, 5, 0, 150, 10, 1, 5, 2,
202         2, 1, 5, 10, 1, 1, 10, 1,
203         1, 1, 1, 1, 7, 5, 4, 0,
204         0, 1, 1, 1, 1, 5, 4, 4,
205         1, 0, 0, 0, 1, 0, 0, 1,
206         1, 1, 3, 1, 0, 0, 1, 0,
207         0, 0, 10, 0, 0, 0, 7, 8,
208         10, 8, 8, 10, 10, 3, 1, 2
209 };
210
211 const int objflags[NUMOFOBJECTS] = {
212         0,              0,          OBJ_NONOBJ,     OBJ_PERSON,
213         0,              0,              0,              0,
214         0,              0,              0,              0,
215         0,          OBJ_PLURAL,     OBJ_NONOBJ,     OBJ_PLURAL,
216         0,            OBJ_AN,           0,              0,
217         0,              0,              0,          OBJ_PERSON,
218     OBJ_PERSON,         0,              0,              0,
219     OBJ_PLURAL,         0,              0,              0,
220         0,              0,      OBJ_AN|OBJ_PERSON,  OBJ_NONOBJ,
221     OBJ_PLURAL,         0,          OBJ_PERSON,     OBJ_PLURAL,
222         0,              0,          OBJ_PLURAL,         0,
223         0,              0,              0,          OBJ_PERSON,
224     OBJ_PERSON,     OBJ_PERSON,     OBJ_PERSON,     OBJ_NONOBJ,
225     OBJ_NONOBJ,     OBJ_NONOBJ,         0,              0,
226       OBJ_AN,           0,          OBJ_PERSON,         0,
227         0,              0,              0,              0
228 };
229
230 int     win = 1;
231 int     matchcount = 20;
232 int     followgod = -1;
233 int     followfight = -1;
234
235 struct room *location;
236
237  /* current input line */
238 char    words[NWORD][WORDLEN];
239 int     wordvalue[NWORD];
240 int     wordtype[NWORD];
241 int     wordcount, wordnumber;
242
243  /* state of the game */
244 int     ourtime;
245 int     position;
246 int     direction;
247 int     left, right, ahead, back;
248 int     fuel, torps;
249 int     carrying, encumber;
250 int     rythmn;
251 int     ate;
252 int     snooze;
253 int     meetgirl;
254 int     godready;
255 int     wintime;
256 int     wiz;
257 int     tempwiz;
258 int     matchlight;
259 int     loved;
260 int     pleasure, power, ego;
261 int     notes[NUMOFNOTES];
262 unsigned int inven[NUMOFWORDS];
263 unsigned int wear[NUMOFWORDS];
264 char    beenthere[NUMOFROOMS + 1];
265 char    injuries[NUMOFINJURIES];
266 int     verbose = 0;
267
268 const char *username;