comparison arogue7/init.c @ 125:adfa37e67084

Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
author John "Elwin" Edwards
date Fri, 08 May 2015 15:24:40 -0400
parents
children b786053d2f37
comparison
equal deleted inserted replaced
124:d10fc4a065ac 125:adfa37e67084
1 /*
2 * init.c - global variable initializaton
3 *
4 * Advanced Rogue
5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
6 * All rights reserved.
7 *
8 * Based on "Rogue: Exploring the Dungeons of Doom"
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * All rights reserved.
11 *
12 * See the file LICENSE.TXT for full copyright and licensing information.
13 */
14
15 /*
16 * global variable initializaton
17 *
18 */
19
20 #include "curses.h"
21 #include <ctype.h>
22 #include "rogue.h"
23 #include "mach_dep.h"
24
25
26 /*
27 * If there is any news, put it in a character string and assign it to
28 * rogue_news. Otherwise, assign NULL to rogue_news.
29 */
30 static char *rogue_news = "You no longer fall into trading posts. They are \
31 now entered like going down the stairs.";
32
33 char *rainbow[] = {
34
35 "amber", "aquamarine", "beige",
36 "black", "blue", "brown",
37 "clear", "crimson", "ecru",
38 "gold", "green", "grey",
39 "indigo", "khaki", "lavender",
40 "magenta", "orange", "pink",
41 "plaid", "purple", "red",
42 "silver", "saffron", "scarlet",
43 "tan", "tangerine", "topaz",
44 "turquoise", "vermilion", "violet",
45 "white", "yellow",
46 };
47 #define NCOLORS (sizeof rainbow / sizeof(char *))
48 int cNCOLORS = NCOLORS;
49
50 static char *sylls[] = {
51 "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", "arze",
52 "ash", "ban", "bar", "bat", "bek", "bie", "bin", "bit", "bjor",
53 "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf",
54 "dan", "den", "do", "e", "eep", "el", "eng", "er", "ere", "erk",
55 "esh", "evs", "fa", "fid", "for", "fri", "fu", "gan", "gar",
56 "glen", "gop", "gre", "ha", "he", "hyd", "i", "ing", "ion", "ip",
57 "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech",
58 "man", "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur",
59 "nej", "nelg", "nep", "ner", "nes", "net", "nih", "nin", "o", "od",
60 "ood", "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po",
61 "pot", "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol",
62 "sa", "san", "sat", "see", "sef", "seh", "shu", "ski", "sna",
63 "sne", "snik", "sno", "so", "sol", "sri", "sta", "sun", "ta",
64 "tab", "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u",
65 "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", "vom", "wah",
66 "wed", "werg", "wex", "whon", "wun", "xo", "y", "yot", "yu",
67 "zant", "zap", "zeb", "zim", "zok", "zon", "zum",
68 };
69
70 char *stones[] = {
71 "agate", "alexandrite", "amethyst",
72 "azurite", "bloodstone", "cairngorm",
73 "carnelian", "chalcedony", "chrysoberyl",
74 "chrysolite", "chrysoprase", "citrine",
75 "coral", "diamond", "emerald",
76 "garnet", "heliotrope", "hematite",
77 "hyacinth", "jacinth", "jade",
78 "jargoon", "jasper", "kryptonite",
79 "lapus lazuli", "malachite", "mocca stone",
80 "moonstone", "obsidian", "olivine",
81 "onyx", "opal", "pearl",
82 "peridot", "quartz", "rhodochrosite",
83 "rhodolite", "ruby", "sapphire",
84 "sardonyx", "serpintine", "spinel",
85 "tiger eye", "topaz", "tourmaline",
86 "turquoise", "zircon",
87 };
88 #define NSTONES (sizeof stones / sizeof(char *))
89 int cNSTONES = NSTONES;
90
91 char *wood[] = {
92 "avocado wood", "balsa", "banyan", "birch",
93 "cedar", "cherry", "cinnibar", "dogwood",
94 "driftwood", "ebony", "eucalyptus", "hemlock",
95 "ironwood", "mahogany", "manzanita", "maple",
96 "oak", "pine", "redwood", "rosewood",
97 "teak", "walnut", "zebra wood", "persimmon wood",
98 };
99 #define NWOOD (sizeof wood / sizeof(char *))
100 int cNWOOD = NWOOD;
101
102 char *metal[] = {
103 "aluminium", "bone", "brass", "bronze",
104 "copper", "chromium", "iron", "lead",
105 "magnesium", "pewter", "platinum", "silver",
106 "steel", "tin", "titanium", "zinc",
107 };
108 #define NMETAL (sizeof metal / sizeof(char *))
109 int cNMETAL = NMETAL;
110 #define MAX3(a,b,c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
111
112 static bool used[MAX3(NCOLORS, NSTONES, NWOOD)];
113
114
115 /*
116 * make sure all the percentages specified in the tables add up to the
117 * right amounts
118 */
119 badcheck(name, magic, bound)
120 char *name;
121 register struct magic_item *magic;
122 register int bound;
123 {
124 register struct magic_item *end;
125
126 if (magic[bound - 1].mi_prob == 1000)
127 return;
128 printf("\nBad percentages for %s:\n", name);
129 for (end = &magic[bound] ; magic < end ; magic++)
130 printf("%4d%% %s\n", magic->mi_prob, magic->mi_name);
131 printf(retstr);
132 fflush(stdout);
133 while (getchar() != '\n')
134 continue;
135 }
136
137 /*
138 * init_colors:
139 * Initialize the potion color scheme for this time
140 */
141
142 init_colors()
143 {
144 register int i, j;
145
146 for (i = 0; i < NCOLORS; i++)
147 used[i] = FALSE;
148
149 for (i = 0 ; i < MAXPOTIONS ; i++)
150 {
151 do
152 j = rnd(NCOLORS);
153 until (!used[j]);
154 used[j] = TRUE;
155 p_colors[i] = rainbow[j];
156 p_know[i] = FALSE;
157 p_guess[i] = NULL;
158 if (i > 0)
159 p_magic[i].mi_prob += p_magic[i-1].mi_prob;
160 }
161 badcheck("potions", p_magic, MAXPOTIONS);
162 }
163
164 /*
165 * do any initialization for food
166 */
167
168 init_foods()
169 {
170 register int i;
171
172 for (i=0; i < MAXFOODS; i++) {
173 if (i > 0)
174 foods[i].mi_prob += foods[i-1].mi_prob;
175 }
176 badcheck("foods", foods, MAXFOODS);
177 }
178
179 /*
180 * init_materials:
181 * Initialize the construction materials for wands and staffs
182 */
183
184 init_materials()
185 {
186 register int i, j;
187 register char *str;
188 static bool metused[NMETAL];
189
190 for (i = 0; i < NWOOD; i++)
191 used[i] = FALSE;
192 for (i = 0; i < NMETAL; i++)
193 metused[i] = FALSE;
194
195 for (i = 0 ; i < MAXSTICKS ; i++)
196 {
197 for (;;)
198 if (rnd(100) > 50)
199 {
200 j = rnd(NMETAL);
201 if (!metused[j])
202 {
203 ws_type[i] = "wand";
204 str = metal[j];
205 metused[j] = TRUE;
206 break;
207 }
208 }
209 else
210 {
211 j = rnd(NWOOD);
212 if (!used[j])
213 {
214 ws_type[i] = "staff";
215 str = wood[j];
216 used[j] = TRUE;
217 break;
218 }
219 }
220
221 ws_made[i] = str;
222 ws_know[i] = FALSE;
223 ws_guess[i] = NULL;
224 if (i > 0)
225 ws_magic[i].mi_prob += ws_magic[i-1].mi_prob;
226 }
227 badcheck("sticks", ws_magic, MAXSTICKS);
228 }
229
230 /*
231 * do any initialization for miscellaneous magic
232 */
233
234 init_misc()
235 {
236 register int i;
237
238 for (i=0; i < MAXMM; i++) {
239 m_know[i] = FALSE;
240 m_guess[i] = NULL;
241 if (i > 0)
242 m_magic[i].mi_prob += m_magic[i-1].mi_prob;
243 }
244 badcheck("miscellaneous magic", m_magic, MAXMM);
245 }
246
247 /*
248 * init_names:
249 * Generate the names of the various scrolls
250 */
251
252 init_names()
253 {
254 register int nsyl;
255 register char *cp, *sp;
256 register int i, nwords;
257
258 for (i = 0 ; i < MAXSCROLLS ; i++)
259 {
260 cp = prbuf;
261 nwords = rnd(cols/20) + 1 + (cols > 40 ? 1 : 0);
262 while(nwords--)
263 {
264 nsyl = rnd(3)+1;
265 while(nsyl--)
266 {
267 sp = sylls[rnd((sizeof sylls) / (sizeof (char *)))];
268 while(*sp)
269 *cp++ = *sp++;
270 }
271 *cp++ = ' ';
272 }
273 *--cp = '\0';
274 s_names[i] = (char *) new(strlen(prbuf)+1);
275 s_know[i] = FALSE;
276 s_guess[i] = NULL;
277 strcpy(s_names[i], prbuf);
278 if (i > 0)
279 s_magic[i].mi_prob += s_magic[i-1].mi_prob;
280 }
281 badcheck("scrolls", s_magic, MAXSCROLLS);
282 }
283
284 /*
285 * init_player:
286 * roll up the rogue
287 */
288
289 init_player()
290 {
291 int stat_total, round, minimum, maximum, ch, i, j;
292 short do_escape, *our_stats[NUMABILITIES-1];
293 struct linked_list *weap_item, *armor_item;
294 struct object *obj;
295
296 weap_item = armor_item = NULL;
297
298 if (char_type == -1) {
299 /* See what type character will be */
300 wclear(hw);
301 touchwin(hw);
302 wmove(hw,2,0);
303 for(i=1; i<=NUM_CHARTYPES-1; i++) {
304 wprintw(hw,"[%d] %s\n",i,char_class[i-1].name);
305 }
306 mvwaddstr(hw, 0, 0, "What character class do you desire? ");
307 draw(hw);
308 char_type = (wgetch(hw) - '0');
309 while (char_type < 1 || char_type > NUM_CHARTYPES-1) {
310 wmove(hw,0,0);
311 wprintw(hw,"Please enter a character type between 1 and %d: ",
312 NUM_CHARTYPES-1);
313 draw(hw);
314 char_type = (wgetch(hw) - '0');
315 }
316 char_type--;
317 }
318 player.t_ctype = char_type;
319 player.t_quiet = 0;
320 pack = NULL;
321
322 /* Select the gold */
323 purse = 2700;
324 switch (player.t_ctype) {
325 case C_FIGHTER:
326 purse += 1800;
327 when C_THIEF:
328 case C_ASSASIN:
329 purse += 600;
330 }
331 #ifdef WIZARD
332 /*
333 * allow me to describe a super character
334 */
335 if (wizard && strcmp(getenv("SUPER"),"YES") == 0) {
336 pstats.s_str = 25;
337 pstats.s_intel = 25;
338 pstats.s_wisdom = 25;
339 pstats.s_dext = 25;
340 pstats.s_const = 25;
341 pstats.s_charisma = 25;
342 pstats.s_exp = 10000000L;
343 pstats.s_lvladj = 0;
344 pstats.s_lvl = 1;
345 pstats.s_hpt = 500;
346 pstats.s_carry = totalenc(&player);
347 strncpy(pstats.s_dmg, "3d4", sizeof(pstats.s_dmg));
348 check_level();
349 mpos = 0;
350 if (player.t_ctype == C_FIGHTER ||
351 player.t_ctype == C_RANGER ||
352 player.t_ctype == C_PALADIN)
353 weap_item = spec_item(WEAPON, TWOSWORD, 5, 5);
354 else
355 weap_item = spec_item(WEAPON, SWORD, 5, 5);
356 obj = OBJPTR(weap_item);
357 obj->o_flags |= ISKNOW;
358 add_pack(weap_item, TRUE, NULL);
359 cur_weapon = obj;
360 if (player.t_ctype != C_MONK) {