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