comparison rogue3/init.c @ 0:527e2150eaf0

Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
author edwarj4
date Tue, 13 Oct 2009 13:33:34 +0000
parents
children b4856d4d4c4e
comparison
equal deleted inserted replaced
-1:000000000000 0:527e2150eaf0
1 /*
2 * global variable initializaton
3 *
4 * @(#)init.c 3.33 (Berkeley) 6/15/81
5 *
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
8 * All rights reserved.
9 *
10 * See the file LICENSE.TXT for full copyright and licensing information.
11 */
12
13 #include "curses.h"
14 #include <ctype.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include "machdep.h"
18 #include "rogue.h"
19
20 int playing = TRUE, running = FALSE, wizard = FALSE;
21 int notify = TRUE, fight_flush = FALSE, terse = FALSE, door_stop = FALSE;
22 int jump = FALSE, slow_invent = FALSE, firstmove = FALSE, askme = FALSE;
23 int amulet = FALSE;
24 int in_shell = FALSE;
25 struct linked_list *lvl_obj = NULL, *mlist = NULL;
26 struct object *cur_weapon = NULL;
27 int mpos = 0, no_move = 0, no_command = 0, level = 1, purse = 0, inpack = 0;
28 int total = 0, no_food = 0, count = 0, fung_hit = 0, quiet = 0;
29 int food_left = HUNGERTIME, group = 1, hungry_state = 0;
30 int lastscore = -1;
31
32 struct thing player;
33 struct room rooms[MAXROOMS];
34 struct room *oldrp;
35 struct stats max_stats;
36 struct object *cur_armor;
37 struct object *cur_ring[2];
38 int after;
39 int waswizard;
40 coord oldpos; /* Position before last look() call */
41 coord delta; /* Change indicated to get_dir() */
42
43 int s_know[MAXSCROLLS]; /* Does he know what a scroll does */
44 int p_know[MAXPOTIONS]; /* Does he know what a potion does */
45 int r_know[MAXRINGS]; /* Does he know what a ring does
46 */
47 int ws_know[MAXSTICKS]; /* Does he know what a stick does */
48
49 int take; /* Thing the rogue is taking */
50 int runch; /* Direction player is running */
51 char whoami[80]; /* Name of player */
52 char fruit[80]; /* Favorite fruit */
53 char huh[80]; /* The last message printed */
54 int dnum; /* Dungeon number */
55 char *s_names[MAXSCROLLS]; /* Names of the scrolls */
56 char *p_colors[MAXPOTIONS]; /* Colors of the potions */
57 char *r_stones[MAXRINGS]; /* Stone settings of the rings */
58 char *a_names[MAXARMORS]; /* Names of armor types */
59 char *ws_made[MAXSTICKS]; /* What sticks are made of */
60 char *s_guess[MAXSCROLLS]; /* Players guess at what scroll is */
61 char *p_guess[MAXPOTIONS]; /* Players guess at what potion is */
62 char *r_guess[MAXRINGS]; /* Players guess at what ring is */
63 char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */
64 char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */
65 char file_name[80]; /* Save file name */
66 char home[PATH_MAX]; /* User's home directory */
67 unsigned char prbuf[80]; /* Buffer for sprintfs */
68 int max_hp; /* Player's max hit points */
69 int ntraps; /* Number of traps on this level */
70 int max_level; /* Deepest player has gone */
71 int seed; /* Random number seed */
72
73 struct trap traps[MAXTRAPS];
74
75
76 #define ___ 1
77 #define _x {1,1}
78 struct monster monsters[26] = {
79 /* Name CARRY FLAG str, exp, lvl, amr, hpt, dmg */
80 { "giant ant", 0, ISMEAN, { _x, 10, 2, 3, ___, "1d6" } },
81 { "bat", 0, 0, { _x, 1, 1, 3, ___, "1d2" } },
82 { "centaur", 15, 0, { _x, 15, 4, 4, ___, "1d6/1d6" } },
83 { "dragon", 100, ISGREED,{ _x,9000, 10, -1, ___, "1d8/1d8/3d10" } },
84 { "floating eye",0, 0, { _x, 5, 1, 9, ___, "0d0" } },
85 { "violet fungi",0, ISMEAN, { _x, 85, 8, 3, ___, "000d0" } },
86 { "gnome", 10, 0, { _x, 8, 1, 5, ___, "1d6" } },
87 { "hobgoblin", 0, ISMEAN, { _x, 3, 1, 5, ___, "1d8" } },
88 { "invisible stalker",0,ISINVIS,{ _x,120, 8, 3, ___, "4d4" } },
89 { "jackal", 0, ISMEAN, { _x, 2, 1, 7, ___, "1d2" } },
90 { "kobold", 0, ISMEAN, { _x, 1, 1, 7, ___, "1d4" } },
91 { "leprechaun", 0, 0, { _x, 10, 3, 8, ___, "1d1" } },
92 { "mimic", 30, 0, { _x,140, 7, 7, ___, "3d4" } },
93 { "nymph", 100, 0, { _x, 40, 3, 9, ___, "0d0" } },
94 { "orc", 15, ISBLOCK,{ _x, 5, 1, 6, ___, "1d8" } },
95 { "purple worm", 70, 0, { _x,7000, 15, 6, ___, "2d12/2d4" } },
96 { "quasit", 30, ISMEAN, { _x, 35, 3, 2, ___, "1d2/1d2/1d4" } },
97 { "rust monster",0, ISMEAN, { _x, 25, 5, 2, ___, "0d0/0d0" } },
98 { "snake", 0, ISMEAN, { _x, 3, 1, 5, ___, "1d3" } },
99 { "troll", 50, ISREGEN|ISMEAN,{ _x, 55, 6, 4, ___, "1d8/1d8/2d6" } },
100 { "umber hulk", 40, ISMEAN, { _x,130, 8, 2, ___, "3d4/3d4/2d5" } },
101 { "vampire", 20, ISREGEN|ISMEAN,{ _x,380, 8, 1, ___, "1d10" } },
102 { "wraith", 0, 0, { _x, 55, 5, 4, ___, "1d6" } },
103 { "xorn", 0, ISMEAN, { _x,120, 7, -2, ___, "1d3/1d3/1d3/4d6" } },
104 { "yeti", 30, 0, { _x, 50, 4, 6, ___, "1d6/1d6" } },
105 { "zombie", 0, ISMEAN, { _x, 7, 2, 8, ___, "1d8" } }
106 };
107 #undef ___
108
109 /*
110 * init_player:
111 * roll up the rogue
112 */
113
114 void
115 init_player()
116 {
117 pstats.s_lvl = 1;
118 pstats.s_exp = 0L;
119 max_hp = pstats.s_hpt = 12;
120 if (rnd(100) == 7)
121 {
122 pstats.s_str.st_str = 18;
123 pstats.s_str.st_add = rnd(100) + 1;
124 }
125 else
126 {
127 pstats.s_str.st_str = 16;
128 pstats.s_str.st_add = 0;
129 }
130 strcpy(pstats.s_dmg,"1d4");
131 pstats.s_arm = 10;
132 max_stats = pstats;
133 pack = NULL;
134 }
135
136 /*
137 * Contains defintions and functions for dealing with things like
138 * potions and scrolls
139 */
140
141 char *rainbow[] = {
142 "red",
143 "blue",
144 "green",
145 "yellow",
146 "black",
147 "brown",
148 "orange",
149 "pink",
150 "purple",
151 "grey",
152 "white",
153 "silver",
154 "gold",
155 "violet",
156 "clear",
157 "vermilion",
158 "ecru",
159 "turquoise",
160 "magenta",
161 "amber",
162 "topaz",
163 "plaid",
164 "tan",
165 "tangerine"
166 };
167
168 #define NCOLORS (sizeof rainbow / sizeof (char *))
169 int cNCOLORS = NCOLORS;
170
171 char *sylls[] = {
172 "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", "arze",
173 "ash", "ban", "bar", "bat", "bek", "bie", "bin", "bit", "bjor",
174 "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf",
175 "dan", "den", "do", "e", "eep", "el", "eng", "er", "ere", "erk",
176 "esh", "evs", "fa", "fid", "for", "fri", "fu", "gan", "gar",
177 "glen", "gop", "gre", "ha", "he", "hyd", "i", "ing", "ion", "ip",
178 "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech",
179 "man", "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur",
180 "nej", "nelg", "nep", "ner", "nes", "nes", "nih", "nin", "o", "od",
181 "ood", "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po",
182 "pot", "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol",
183 "sa", "san", "sat", "see", "sef", "seh", "shu", "ski", "sna",
184 "sne", "snik", "sno", "so", "sol", "sri", "sta", "sun", "ta",
185 "tab", "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u",
186 "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", "vom", "wah",
187 "wed", "werg", "wex", "whon", "wun", "xo", "y", "yot", "yu",
188 "zant", "zap", "zeb", "zim", "zok", "zon", "zum",
189 };
190
191 char *stones[] = {
192 "agate",
193 "alexandrite",
194 "amethyst",
195 "carnelian",
196 "diamond",
197 "emerald",
198 "granite",
199 "jade",
200 "kryptonite",
201 "lapus lazuli",
202 "moonstone",
203 "obsidian",
204 "onyx",
205 "opal",
206 "pearl",
207 "ruby",
208 "saphire",
209 "tiger eye",
210 "topaz",
211 "turquoise",
212 };
213
214 #define NSTONES (sizeof stones / sizeof (char *))
215 int cNSTONES = NSTONES;
216
217 char *wood[] = {
218 "avocado wood",
219 "balsa",
220 "banyan",
221 "birch",
222 "cedar",
223 "cherry",
224 "cinnibar",
225 "driftwood",
226 "ebony",
227 "eucalyptus",
228 "hemlock",
229 "ironwood",
230 "mahogany",
231 "manzanita",
232 "maple",
233 "oak",
234 "persimmon wood",
235 "redwood",
236 "rosewood",
237 "teak",
238 "walnut",
239 "zebra wood",
240 };
241
242 #define NWOOD (sizeof wood / sizeof (char *))
243 int cNWOOD = NWOOD;
244
245 char *metal[] = {
246 "aluminium",
247 "bone",
248 "brass",
249 "bronze",
250 "copper",
251 "iron",
252 "lead",
253 "pewter",
254 "steel",
255 "tin",
256 "zinc",
257 };
258
259 #define NMETAL (sizeof metal / sizeof (char *))
260 int cNMETAL = NMETAL;
261
262 struct magic_item things[NUMTHINGS] = {
263 { "", 27 }, /* potion */
264 { "", 27 }, /* scroll */
265 { "", 18 }, /* food */
266 { "", 9 }, /* weapon */
267 { "", 9 }, /* armor */
268 { "", 5 }, /* ring */
269 { "", 5 }, /* stick */
270 };
271
272 struct magic_item s_magic[MAXSCROLLS] = {
273 { "monster confusion", 8, 170 },
274 { "magic mapping", 5, 180 },
275 { "light", 10, 100 },
276 { "hold monster", 2, 200 },
277 { "sleep", 5, 50 },
278 { "enchant armor", 8, 130 },
279 { "identify", 21, 100 },
280 { "scare monster", 4, 180 },
281 { "gold detection", 4, 110 },
282 { "teleportation", 7, 175 },
283 { "enchant weapon", 10, 150 },
284 { "create monster", 5, 75 },
285 { "remove curse", 8, 105 },
286 { "aggravate monsters", 1, 60 },
287 { "blank paper", 1, 50 },
288 { "genocide", 1, 200 },
289 };
290
291 struct magic_item p_magic[MAXPOTIONS] = {
292 { "confusion", 8, 50 },
293 { "paralysis", 10, 50 },
294 { "poison", 8, 50 },
295 { "gain strength", 15, 150 },
296 { "see invisible", 2, 170 },
297 { "healing", 15, 130 },
298 { "monster detection", 6, 120 },
299 { "magic detection", 6, 105 },
300 { "raise level", 2, 220 },
301 { "extra healing", 5, 180 },
302 { "haste self", 4, 200 },
303 { "restore strength", 14, 120 },
304 { "blindness", 4, 50 },
305 { "thirst quenching", 1, 50 },
306 };
307
308 struct magic_item r_magic[MAXRINGS] = {
309 { "protection", 9, 200 },
310 { "add strength", 9, 200 },
311 { "sustain strength", 5, 180 },
312 { "searching", 10, 200 },
313 { "see invisible", 10, 175 },
314 { "adornment", 1, 100 },
315 { "aggravate monster", 11, 100 },
316 { "dexterity", 8, 220 },
317 { "increase damage", 8, 220 },
318 { "regeneration", 4, 260 },
319 { "slow digestion", 9, 240 },
320 { "teleportation", 9, 100 },
321 { "stealth", 7, 100 },
322 };
323
324 struct magic_item ws_magic[MAXSTICKS] = {
325 { "light", 12, 120 },
326 { "striking", 9, 115 },
327 { "lightning", 3, 200 },
328 { "fire", 3, 200 },
329 { "cold", 3, 200 },
330 { "polymorph", 15, 210 },
331 { "magic missile", 10, 170 },
332 { "haste monster", 9, 50 },
333 { "slow monster", 11, 220 },
334 { "drain life", 9, 210 },
335 { "nothing", 1, 70 },
336 { "teleport away", 5, 140 },
337 { "teleport to", 5, 60 },
338 { "cancellation", 5, 130 },
339 };
340
341 int a_class[MAXARMORS] = {
342 8,
343 7,
344 7,