comparison rogue5/init.c @ 33:f502bf60e6e4

Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
author elwin
date Mon, 24 May 2010 20:10:59 +0000
parents
children
comparison
equal deleted inserted replaced
32:2dcd75e6a736 33:f502bf60e6e4
1 /*
2 * global variable initializaton
3 *
4 * @(#)init.c 4.31 (Berkeley) 02/05/99
5 *
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980-1983, 1985, 1999 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 <stdlib.h>
14 #include <curses.h>
15 #include <ctype.h>
16 #include <string.h>
17 #include "rogue.h"
18
19 /*
20 * init_player:
21 * Roll her up
22 */
23 void
24 init_player(void)
25 {
26 THING *obj;
27
28 pstats = max_stats;
29 food_left = HUNGERTIME;
30 /*
31 * Give him some food
32 */
33 obj = new_item();
34 obj->o_type = FOOD;
35 obj->o_count = 1;
36 add_pack(obj, TRUE);
37 /*
38 * And his suit of armor
39 */
40 obj = new_item();
41 obj->o_type = ARMOR;
42 obj->o_which = RING_MAIL;
43 obj->o_arm = a_class[RING_MAIL] - 1;
44 obj->o_flags |= ISKNOW;
45 obj->o_count = 1;
46 cur_armor = obj;
47 add_pack(obj, TRUE);
48 /*
49 * Give him his weaponry. First a mace.
50 */
51 obj = new_item();
52 init_weapon(obj, MACE);
53 obj->o_hplus = 1;
54 obj->o_dplus = 1;
55 obj->o_flags |= ISKNOW;
56 add_pack(obj, TRUE);
57 cur_weapon = obj;
58 /*
59 * Now a +1 bow
60 */
61 obj = new_item();
62 init_weapon(obj, BOW);
63 obj->o_hplus = 1;
64 obj->o_flags |= ISKNOW;
65 add_pack(obj, TRUE);
66 /*
67 * Now some arrows
68 */
69 obj = new_item();
70 init_weapon(obj, ARROW);
71 obj->o_count = rnd(15) + 25;
72 obj->o_flags |= ISKNOW;
73 add_pack(obj, TRUE);
74 }
75
76 /*
77 * Contains defintions and functions for dealing with things like
78 * potions and scrolls
79 */
80
81 const char *rainbow[] = {
82 "amber",
83 "aquamarine",
84 "black",
85 "blue",
86 "brown",
87 "clear",
88 "crimson",
89 "cyan",
90 "ecru",
91 "gold",
92 "green",
93 "grey",
94 "magenta",
95 "orange",
96 "pink",
97 "plaid",
98 "purple",
99 "red",
100 "silver",
101 "tan",
102 "tangerine",
103 "topaz",
104 "turquoise",
105 "vermilion",
106 "violet",
107 "white",
108 "yellow",
109 };
110
111 #define NCOLORS (sizeof rainbow / sizeof (char *))
112
113 static const char *sylls[] = {
114 "a", "ab", "ag", "aks", "ala", "an", "app", "arg", "arze", "ash",
115 "bek", "bie", "bit", "bjor", "blu", "bot", "bu", "byt", "comp",
116 "con", "cos", "cre", "dalf", "dan", "den", "do", "e", "eep", "el",
117 "eng", "er", "ere", "erk", "esh", "evs", "fa", "fid", "fri", "fu",
118 "gan", "gar", "glen", "gop", "gre", "ha", "hyd", "i", "ing", "ip",
119 "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech",
120 "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur", "nej",
121 "nelg", "nep", "ner", "nes", "nes", "nih", "nin", "o", "od", "ood",
122 "org", "orn", "ox", "oxy", "pay", "ple", "plu", "po", "pot",
123 "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol", "sa",
124 "san", "sat", "sef", "seh", "shu", "ski", "sna", "sne", "snik",
125 "sno", "so", "sol", "sri", "sta", "sun", "ta", "tab", "tem",
126 "ther", "ti", "tox", "trol", "tue", "turs", "u", "ulk", "um", "un",
127 "uni", "ur", "val", "viv", "vly", "vom", "wah", "wed", "werg",
128 "wex", "whon", "wun", "xo", "y", "yot", "yu", "zant", "zeb", "zim",
129 "zok", "zon", "zum",
130 };
131
132 const STONE stones[] = {
133 { "agate", 25},
134 { "alexandrite", 40},
135 { "amethyst", 50},
136 { "carnelian", 40},
137 { "diamond", 300},
138 { "emerald", 300},
139 { "germanium", 225},
140 { "granite", 5},
141 { "garnet", 50},
142 { "jade", 150},
143 { "kryptonite", 300},
144 { "lapis lazuli", 50},
145 { "moonstone", 50},
146 { "obsidian", 15},
147 { "onyx", 60},
148 { "opal", 200},
149 { "pearl", 220},
150 { "peridot", 63},
151 { "ruby", 350},
152 { "sapphire", 285},
153 { "stibotantalite", 200},
154 { "tiger eye", 50},
155 { "topaz", 60},
156 { "turquoise", 70},
157 { "taaffeite", 300},
158 { "zircon", 80},
159 };
160
161 #define NSTONES (sizeof stones / sizeof (STONE))
162
163 const char *wood[] = {
164 "avocado wood",
165 "balsa",
166 "bamboo",
167 "banyan",
168 "birch",
169 "cedar",
170 "cherry",
171 "cinnibar",
172 "cypress",
173 "dogwood",
174 "driftwood",
175 "ebony",
176 "elm",
177 "eucalyptus",
178 "fall",
179 "hemlock",
180 "holly",
181 "ironwood",
182 "kukui wood",
183 "mahogany",
184 "manzanita",
185 "maple",
186 "oaken",
187 "persimmon wood",
188 "pecan",
189 "pine",
190 "poplar",
191 "redwood",
192 "rosewood",
193 "spruce",
194 "teak",
195 "walnut",
196 "zebrawood",
197 };
198
199 #define NWOOD (sizeof wood / sizeof (char *))
200
201 const char *metal[] = {
202 "aluminum",
203 "beryllium",
204 "bone",
205 "brass",
206 "bronze",
207 "copper",
208 "electrum",
209 "gold",
210 "iron",
211 "lead",
212 "magnesium",
213 "mercury",
214 "nickel",
215 "pewter",
216 "platinum",
217 "steel",
218 "silver",
219 "silicon",
220 "tin",
221 "titanium",
222 "tungsten",
223 "zinc",
224 };
225
226 #define NMETAL (sizeof metal / sizeof (char *))
227
228 int cNWOOD = NWOOD;
229 int cNMETAL = NMETAL;
230 int cNSTONES = NSTONES;
231 int cNCOLORS = NCOLORS;
232
233 /*
234 * init_colors:
235 * Initialize the potion color scheme for this time
236 */
237 void
238 init_colors(void)
239 {
240 int i, j;
241 int used[NCOLORS];
242
243 for (i = 0; i < NCOLORS; i++)
244 used[i] = FALSE;
245 for (i = 0; i < MAXPOTIONS; i++)
246 {
247 do
248 j = rnd(NCOLORS);
249 until (!used[j]);
250 used[j] = TRUE;
251 p_colors[i] = rainbow[j];
252 }
253 }
254
255 /*
256 * init_names:
257 * Generate the names of the various scrolls
258 */
259 #define MAXNAME 40 /* Max number of characters in a name */
260
261 void
262 init_names(void)
263 {
264 int nsyl;
265 const char *sp;
266 char *cp;
267 int i, nwords;
268
269 for (i = 0; i < MAXSCROLLS; i++)
270 {
271 cp = prbuf;
272 nwords = rnd(3) + 2;
273 while (nwords--)
274 {
275 nsyl = rnd(3) + 1;
276 while (nsyl--)
277 {
278 sp = sylls[rnd((sizeof sylls) / (sizeof (char *)))];
279 if (&cp[strlen(sp)] > &prbuf[MAXNAME])
280 break;
281 while (*sp)
282 *cp++ = *sp++;
283 }
284 *cp++ = ' ';
285 }
286 *--cp = '\0';
287 s_names[i] = malloc(strlen(prbuf)+1);
288 if (s_names[i] != NULL)
289 strcpy(s_names[i], prbuf);
290 }
291 }
292
293 /*
294 * init_stones:
295 * Initialize the ring stone setting scheme for this time