2 * global variable initializaton
4 * @(#)init.c 3.33 (Berkeley) 6/15/81
6 * Rogue: Exploring the Cavern of Cuties
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * See the file LICENSE.TXT for full copyright and licensing information.
18 bool playing
= TRUE
, running
= FALSE
, wizard
= FALSE
;
19 bool notify
= TRUE
, fight_flush
= FALSE
, terse
= FALSE
, door_stop
= FALSE
;
20 bool jump
= FALSE
, slow_invent
= FALSE
, firstmove
= FALSE
, askme
= FALSE
;
21 bool amulet
= FALSE
, in_shell
= FALSE
;
22 struct linked_list
*lvl_obj
= NULL
, *mlist
= NULL
;
23 struct object
*cur_weapon
= NULL
;
24 int mpos
= 0, no_move
= 0, no_command
= 0, level
= 1, purse
= 0, inpack
= 0;
25 int total
= 0, no_food
= 0, count
= 0, fung_hit
= 0, quiet
= 0;
26 int food_left
= HUNGERTIME
, group
= 1, hungry_state
= 0;
30 struct room rooms
[MAXROOMS
];
32 struct stats max_stats
;
33 struct object
*cur_armor
;
34 struct object
*cur_ring
[2];
37 coord oldpos
; /* Position before last look() call */
38 coord delta
; /* Change indicated to get_dir() */
40 bool s_know
[MAXSCROLLS
]; /* Does he know what a scroll does */
41 bool p_know
[MAXPOTIONS
]; /* Does he know what a potion does */
42 bool r_know
[MAXRINGS
]; /* Does he know what a ring does
44 bool ws_know
[MAXSTICKS
]; /* Does he know what a stick does */
46 char take
; /* Thing the rogue is taking */
47 char runch
; /* Direction player is running */
48 char whoami
[80]; /* Name of player */
49 char fruit
[80]; /* Favorite fruit */
50 char huh
[80]; /* The last message printed */
51 int dnum
; /* Cavern number */
52 char *s_names
[MAXSCROLLS
]; /* Names of the scrolls */
53 char *p_colors
[MAXPOTIONS
]; /* Colors of the potions */
54 char *r_stones
[MAXRINGS
]; /* Stone settings of the rings */
55 char *a_names
[MAXARMORS
]; /* Names of armor types */
56 char *ws_made
[MAXSTICKS
]; /* What sticks are made of */
57 char *s_guess
[MAXSCROLLS
]; /* Players guess at what scroll is */
58 char *p_guess
[MAXPOTIONS
]; /* Players guess at what potion is */
59 char *r_guess
[MAXRINGS
]; /* Players guess at what ring is */
60 char *ws_guess
[MAXSTICKS
]; /* Players guess at what wand is */
61 char *ws_type
[MAXSTICKS
]; /* Is it a wand or a staff */
62 char file_name
[80]; /* Save file name */
63 char home
[80]; /* User's home directory */
64 char prbuf
[80]; /* Buffer for sprintfs */
65 int max_hp
; /* Player's max hit points */
66 int ntraps
; /* Number of traps on this level */
67 int max_level
; /* Deepest player has gone */
68 int seed
; /* Random number seed */
70 struct trap traps
[MAXTRAPS
];
75 struct monster monsters
[26] = {
76 /* Name CARRY FLAG str, exp, lvl, amr, hpt, dmg */
77 { "giant ant", 0, ISMEAN
, { _x
, 10, 2, 3, ___
, "1d6" } },
78 { "bat", 0, 0, { _x
, 1, 1, 3, ___
, "1d2" } },
79 { "centaur", 15, 0, { _x
, 15, 4, 4, ___
, "1d6/1d6" } },
80 { "dragon", 100, ISGREED
,{ _x
,9000, 10, -1, ___
, "1d8/1d8/3d10" } },
81 { "floating eye",0, 0, { _x
, 5, 1, 9, ___
, "0d0" } },
82 { "violet fungi",0, ISMEAN
, { _x
, 85, 8, 3, ___
, "000d0" } },
83 { "gnome", 10, 0, { _x
, 8, 1, 5, ___
, "1d6" } },
84 { "hobgoblin", 0, ISMEAN
, { _x
, 3, 1, 5, ___
, "1d8" } },
85 { "invisible stalker",0,ISINVIS
,{ _x
,120, 8, 3, ___
, "4d4" } },
86 { "jackal", 0, ISMEAN
, { _x
, 2, 1, 7, ___
, "1d2" } },
87 { "kobold", 0, ISMEAN
, { _x
, 1, 1, 7, ___
, "1d4" } },
88 { "leprechaun", 0, 0, { _x
, 10, 3, 8, ___
, "1d1" } },
89 { "mimic", 30, 0, { _x
,140, 7, 7, ___
, "3d4" } },
90 { "nymph", 100, 0, { _x
, 40, 3, 9, ___
, "0d0" } },
91 { "orc", 15, ISBLOCK
,{ _x
, 5, 1, 6, ___
, "1d8" } },
92 { "purple worm", 70, 0, { _x
,7000, 15, 6, ___
, "2d12/2d4" } },
93 { "quasit", 30, ISMEAN
, { _x
, 35, 3, 2, ___
, "1d2/1d2/1d4" } },
94 { "rust monster",0, ISMEAN
, { _x
, 25, 5, 2, ___
, "0d0/0d0" } },
95 { "snake", 0, ISMEAN
, { _x
, 3, 1, 5, ___
, "1d3" } },
96 { "troll", 50, ISREGEN
|ISMEAN
,{ _x
, 55, 6, 4, ___
, "1d8/1d8/2d6" } },
97 { "umber hulk", 40, ISMEAN
, { _x
,130, 8, 2, ___
, "3d4/3d4/2d5" } },
98 { "vampire", 20, ISREGEN
|ISMEAN
,{ _x
,380, 8, 1, ___
, "1d10" } },
99 { "wraith", 0, 0, { _x
, 55, 5, 4, ___
, "1d6" } },
100 { "xorn", 0, ISMEAN
, { _x
,120, 7, -2, ___
, "1d3/1d3/1d3/4d6" } },
101 { "yeti", 30, 0, { _x
, 50, 4, 6, ___
, "1d6/1d6" } },
102 { "zombie", 0, ISMEAN
, { _x
, 7, 2, 8, ___
, "1d8" } }
115 pstats
.s_ont
= rnd(1 << NUM_FEATURES
);
116 max_hp
= pstats
.s_hpt
= 12;
119 pstats
.s_str
.st_str
= 18;
120 pstats
.s_str
.st_add
= rnd(100) + 1;
124 pstats
.s_str
.st_str
= 16;
125 pstats
.s_str
.st_add
= 0;
127 strcpy(pstats
.s_dmg
,"1d4");
134 * Contains defintions and functions for dealing with things like
135 * potions and scrolls
165 #define NCOLORS (sizeof rainbow / sizeof (char *))
166 const int cNCOLORS
= NCOLORS
;
169 "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", "arze",
170 "ash", "ban", "bar", "bat", "bek", "bie", "bin", "bit", "bjor",
171 "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf",
172 "dan", "den", "do", "e", "eep", "el", "eng", "er", "ere", "erk",
173 "esh", "evs", "fa", "fid", "for", "fri", "fu", "gan", "gar",
174 "glen", "gop", "gre", "ha", "he", "hyd", "i", "ing", "ion", "ip",
175 "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech",
176 "man", "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur",
177 "nej", "nelg", "nep", "ner", "nes", "nes", "nih", "nin", "o", "od",
178 "ood", "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po",
179 "pot", "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol",
180 "sa", "san", "sat", "see", "sef", "seh", "shu", "ski", "sna",
181 "sne", "snik", "sno", "so", "sol", "sri", "sta", "sun", "ta",
182 "tab", "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u",
183 "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", "vom", "wah",
184 "wed", "werg", "wex", "whon", "wun", "xo", "y", "yot", "yu",
185 "zant", "zap", "zeb", "zim", "zok", "zon", "zum",
211 #define NSTONES (sizeof stones / sizeof (char *))
212 const int cNSTONES
= NSTONES
;
239 #define NWOOD (sizeof wood / sizeof (char *))
240 const int cNWOOD
= NWOOD
;
256 #define NMETAL (sizeof metal / sizeof (char *))
257 const int cNMETAL
= NMETAL
;
259 struct magic_item things
[NUMTHINGS
] = {
260 { "", 27 }, /* potion */
261 { "", 27 }, /* scroll */
262 { "", 18 }, /* food */
263 { "", 9 }, /* weapon */
264 { "", 9 }, /* armor */
265 { "", 5 }, /* ring */
266 { "", 5 }, /* stick */
269 struct magic_item s_magic
[MAXSCROLLS
] = {
270 { "monster confusion", 8, 170 },
271 { "magic mapping", 5, 180 },
272 { "light", 10, 100 },
273 { "hold monster", 2, 200 },
275 { "enchant armor", 8, 130 },
276 { "identify", 21, 100 },
277 { "scare monster", 4, 180 },
278 { "gold detection", 4, 110 },
279 { "teleportation", 7, 175 },
280 { "enchant weapon", 10, 150 },
281 { "create monster", 5, 75 },
282 { "remove curse", 8, 105 },
283 { "aggravate monsters", 1, 60 },
284 { "blank paper", 1, 50 },
285 { "genocide", 1, 200 },
288 struct magic_item p_magic
[MAXPOTIONS
] = {
289 { "confusion", 8, 50 },
290 { "paralysis", 10, 50 },
292 { "gain strength", 15, 150 },
293 { "see invisible", 2, 170 },
294 { "healing", 15, 130 },
295 { "monster detection", 6, 120 },
296 { "magic detection", 6, 105 },
297 { "raise level", 2, 220 },
298 { "extra healing", 5, 180 },
299 { "haste self", 4, 200 },
300 { "restore strength", 14, 120 },
301 { "blindness", 4, 50 },
302 { "thirst quenching", 1, 50 },
305 struct magic_item r_magic
[MAXRINGS
] = {
306 { "protection", 9, 200 },
307 { "add strength", 9, 200 },
308 { "sustain strength", 5, 180 },
309 { "searching", 10, 200 },
310 { "see invisible", 10, 175 },
311 { "adornment", 1, 100 },
312 { "aggravate monster", 11, 100 },
313 { "dexterity", 8, 220 },
314 { "increase damage", 8, 220 },
315 { "regeneration", 4, 260 },
316 { "slow digestion", 9, 240 },
317 { "teleportation", 9, 100 },
318 { "stealth", 7, 100 },
321 struct magic_item ws_magic
[MAXSTICKS
] = {
322 { "light", 12, 120 },
323 { "striking", 9, 115 },
324 { "lightning", 3, 200 },
327 { "polymorph", 15, 210 },
328 { "magic missile", 10, 170 },
329 { "haste monster", 9, 50 },
330 { "slow monster", 11, 220 },
331 { "drain life", 9, 210 },
332 { "nothing", 1, 70 },
333 { "teleport away", 5, 140 },
334 { "teleport to", 5, 60 },
335 { "cancellation", 5, 130 },
338 int a_class
[MAXARMORS
] = {
349 char *a_names
[MAXARMORS
] = {
352 "studded leather armor",
360 int a_chances
[MAXARMORS
] = {
371 #define MAX3(a,b,c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
372 static bool used
[MAX3(NCOLORS
, NSTONES
, NWOOD
)];
376 * Initialize the probabilities for types of things
380 register struct magic_item
*mp
;
382 for (mp
= &things
[1]; mp
<= &things
[NUMTHINGS
-1]; mp
++)
383 mp
->mi_prob
+= (mp
-1)->mi_prob
;
384 badcheck("things", things
, NUMTHINGS
);
389 * Initialize the potion color scheme for this time
396 for (i
= 0; i
< NCOLORS
; i
++)
398 for (i
= 0; i
< MAXPOTIONS
; i
++)
404 p_colors
[i
] = rainbow
[j
];
408 p_magic
[i
].mi_prob
+= p_magic
[i
-1].mi_prob
;
410 badcheck("potions", p_magic
, MAXPOTIONS
);
415 * Generate the names of the various scrolls
421 register char *cp
, *sp
;
422 register int i
, nwords
;
424 for (i
= 0; i
< MAXSCROLLS
; i
++)
433 sp
= sylls
[rnd((sizeof sylls
) / (sizeof (char *)))];
440 s_names
[i
] = (char *) new(strlen(prbuf
)+1);
443 strcpy(s_names
[i
], prbuf
);
445 s_magic
[i
].mi_prob
+= s_magic
[i
-1].mi_prob
;
447 badcheck("scrolls", s_magic
, MAXSCROLLS
);
452 * Initialize the ring stone setting scheme for this time
459 for (i
= 0; i
< NSTONES
; i
++)
461 for (i
= 0; i
< MAXRINGS
; i
++)
467 r_stones
[i
] = stones
[j
];
471 r_magic
[i
].mi_prob
+= r_magic
[i
-1].mi_prob
;
473 badcheck("rings", r_magic
, MAXRINGS
);
478 * Initialize the construction materials for wands and staffs
484 static bool metused
[NMETAL
];
486 for (i
= 0; i
< NWOOD
; i
++)
488 for (i
= 0; i
< NMETAL
; i
++)
491 for (i
= 0; i
< MAXSTICKS
; i
++)
500 ws_made
[i
] = metal
[j
];
511 ws_made
[i
] = wood
[j
];
512 ws_type
[i
] = "staff";
520 ws_magic
[i
].mi_prob
+= ws_magic
[i
-1].mi_prob
;
522 badcheck("sticks", ws_magic
, MAXSTICKS
);
525 badcheck(name
, magic
, bound
)
527 register struct magic_item
*magic
;
530 register struct magic_item
*end
;
532 if (magic
[bound
- 1].mi_prob
== 100)
534 printf("\nBad percentages for %s:\n", name
);
535 for (end
= &magic
[bound
]; magic
< end
; magic
++)
536 printf("%3d%% %s\n", magic
->mi_prob
, magic
->mi_name
);
537 printf("[hit RETURN to continue]");
539 while (getchar() != '\n')
543 struct h_list helpstr
[] = {
545 '/', " identify object",
553 'n', " down & right",
558 'Y', " run up & left",
559 'U', " run up & right",
560 'B', " run down & left",
561 'N', " run down & right",
562 't', "<dir> throw something",
563 'p', "<dir> zap a wand in a direction",
564 'z', " zap a wand or staff",
565 '>', " go down a staircase",
566 's', " search for trap/secret door",
567 ' ', " (space) rest for a while",
569 'I', " inventory single item",
570 'q', " quaff potion",
573 'w', " wield a weapon",
575 'T', " take armor off",
580 'f', "<dir> flirt with someone",
581 'g', "<dir> give an item as a gift",
583 'o', " examine/set options",
584 CTRL('L'), " redraw screen",
585 CTRL('R'), " repeat last message",
586 ESCAPE
, " cancel command",
587 'v', " print program version number",