comparison xrogue/init.c @ 133:e6179860cb76

Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
author John "Elwin" Edwards
date Tue, 21 Apr 2015 08:55:20 -0400
parents
children ce0cf824c192
comparison
equal deleted inserted replaced
124:d10fc4a065ac 133:e6179860cb76
1 /*
2 init.c - global variable initializaton
3
4 XRogue: Expeditions into the Dungeons of Doom
5 Copyright (C) 1991 Robert Pietkivitch
6 All rights reserved.
7
8 Based on "Advanced Rogue"
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
10 All rights reserved.
11
12 Based on "Rogue: Exploring the Dungeons of Doom"
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
14 All rights reserved.
15
16 See the file LICENSE.TXT for full copyright and licensing information.
17 */
18
19 #include <curses.h>
20 #include <ctype.h>
21 #include "rogue.h"
22 #include "mach_dep.h"
23
24 /*
25 * If there is any news, put it in a character string and assign it to
26 * rogue_news. Otherwise, assign NULL to rogue_news.
27 */
28
29 static char *rogue_news = "Enter a number within the minimum and maximum \
30 range. When satisfied with your choices, enter a 'y'. For help at any \
31 other time enter a '?' or a '='.";
32
33 /* replace the above line with this when descriptions are done */
34 /* other time enter a '?' or a '='. For character and item descriptions \
35 enter a '\\' on any other screen.";
36 */
37
38 struct words rainbow[NCOLORS] = {
39 "Amber", "Aquamarine", "Beige",
40 "Black", "Blue", "Brown",
41 "Clear", "Crimson", "Ecru",
42 "Gold", "Green", "Grey",
43 "Indigo", "Khaki", "Lavender",
44 "Magenta", "Orange", "Pink",
45 "Plaid", "Purple", "Red",
46 "Silver", "Saffron", "Scarlet",
47 "Tan", "Tangerine", "Topaz",
48 "Turquoise", "Vermilion", "Violet",
49 "White", "Yellow",
50 };
51
52 struct words sylls[NSYLLS] = {
53 "a", "ae", "ak", "an", "ax", "ach", "ano", "ars", "bha", "bar", "bre",
54 "cha", "cre", "cum", "cow", "duh", "dha", "e", "ea", "em", "et", "ey",
55 "eck", "etk", "egg", "exl", "fu", "fen", "fid", "gan", "gle", "h", "ha",
56 "hr", "ht", "how", "hex", "hip", "hoc", "i", "ia", "ig", "it", "iz",
57 "ion", "ink", "ivi", "iss", "je", "jin", "jha", "jyr", "ka", "kho", "kal",
58 "kli", "lu", "lre", "lta", "lri", "m", "ma", "mh", "mi", "mr", "mar",
59 "myr", "moh", "mul", "nep", "nes", "o", "oc", "om", "oq", "ox", "orn",
60 "oxy", "olm", "ode", "po", "pie", "pod", "pot", "qar", "que", "ran", "rah",
61 "rok", "sa", "sat", "sha", "sol", "sri", "ti", "tem", "tar", "tki", "tch",
62 "tox", "u", "ub", "uh", "ur", "uv", "unk", "uwh", "ugh", "uyr", "va",
63 "vil", "vit", "vom", "vux", "wah", "wex", "xu", "xed", "xen", "ya", "yep",
64 "yih", "zef", "zen", "zil", "zym", "-"
65 };
66
67 struct words stones[NSTONES] = {
68 "Agate", "Alexandrite", "Amethyst",
69 "Azurite", "Bloodstone", "Cairngorm",
70 "Carnelian", "Chalcedony", "Chrysoberyl",
71 "Chrysolite", "Chrysoprase", "Citrine",
72 "Coral", "Diamond", "Emerald",
73 "Garnet", "Heliotrope", "Hematite",
74 "Hyacinth", "Jacinth", "Jade",
75 "Jargoon", "Jasper", "Kryptonite",
76 "Lapis lazuli", "Malachite", "Mocca stone",
77 "Moonstone", "Obsidian", "Olivine",
78 "Onyx", "Opal", "Pearl",
79 "Peridot", "Quartz", "Rhodochrosite",
80 "Rhodolite", "Ruby", "Sapphire",
81 "Sardonyx", "Serpentine", "Spinel",
82 "Tiger eye", "Topaz", "Tourmaline",
83 "Turquoise", "Zircon",
84 };
85
86 struct words wood[NWOOD] = {
87 "Avocado wood", "Balsa", "Banyan", "Birch",
88 "Cedar", "Cherry", "Cinnabar", "Dogwood",
89 "Driftwood", "Ebony", "Eucalyptus", "Hemlock",
90 "Ironwood", "Mahogany", "Manzanita", "Maple",
91 "Oak", "Pine", "Redwood", "Rosewood",
92 "Teak", "Walnut", "Aloe", "Sandalwood",
93 };
94
95 struct words metal[NMETAL] = {
96 "Aluminium", "Bone", "Brass", "Bronze",
97 "Copper", "Chromium", "Iron", "Lead",
98 "Magnesium", "Pewter", "Platinum", "Silver",
99 "Steel", "Tin", "Titanium", "Zinc",
100 };
101
102 /*
103 * make sure all the percentages specified in the tables add up to the
104 * right amounts
105 */
106
107 badcheck(name, magic, bound)
108 char *name;
109 register struct magic_item *magic;
110 register int bound;
111 {
112 register struct magic_item *end;
113
114 if (magic[bound - 1].mi_prob == 1000)
115 return;
116 printf("\nBad percentages for %s:\n", name);
117 for (end = &magic[bound] ; magic < end ; magic++)
118 printf("%4d%% %s\n", magic->mi_prob, magic->mi_name);
119 printf(retstr);
120 fflush(stdout);
121 while (getchar() != '\n')
122 continue;
123 }
124
125 /*
126 * init_colors:
127 * Initialize the potion color scheme for this time
128 */
129
130 init_colors()
131 {
132 register int i;
133 register char *str;
134
135 for (i = 0 ; i < MAXPOTIONS ; i++)
136 {
137 do
138 str = rainbow[rnd(NCOLORS)].w_string;
139 until (isupper(*str));
140 *str = tolower(*str);
141 p_colors[i] = str;
142 p_know[i] = FALSE;
143 p_guess[i] = NULL;
144 if (i > 0)
145 p_magic[i].mi_prob += p_magic[i-1].mi_prob;
146 }
147 badcheck("potions", p_magic, MAXPOTIONS);
148 }
149
150 /*
151 * do any initialization for food
152 */
153
154 init_foods()
155 {
156 register int i;
157
158 for (i=0; i < MAXFOODS; i++) {
159 if (i > 0)
160 foods[i].mi_prob += foods[i-1].mi_prob;
161 }
162 badcheck("foods", foods, MAXFOODS);
163 }
164
165 /*
166 * init_materials:
167 * Initialize the construction materials for wands and staffs
168 */
169
170 init_materials()
171 {
172 register int i;
173 register char *str;
174
175 for (i = 0 ; i < MAXSTICKS ; i++)
176 {
177 do
178 if (rnd(100) > 50)
179 {
180 str = metal[rnd(NMETAL)].w_string;
181 if (isupper(*str))
182 ws_type[i] = "wand";
183 }
184 else
185 {
186 str = wood[rnd(NWOOD)].w_string;
187 if (isupper(*str))
188 ws_type[i] = "staff";
189 }
190 until (isupper(*str));
191 *str = tolower(*str);
192 ws_made[i] = str;
193 ws_know[i] = FALSE;
194 ws_guess[i] = NULL;
195 if (i > 0)
196 ws_magic[i].mi_prob += ws_magic[i-1].mi_prob;
197 }
198 badcheck("sticks", ws_magic, MAXSTICKS);
199 }
200
201 /*
202 * do any initialization for miscellaneous magic
203 */
204
205 init_misc()
206 {
207 register int i;
208
209 for (i=0; i < MAXMM; i++) {
210 m_know[i] = FALSE;
211 m_guess[i] = NULL;
212 if (i > 0)
213 m_magic[i].mi_prob += m_magic[i-1].mi_prob;
214 }
215 badcheck("miscellaneous magic", m_magic, MAXMM);
216 }
217
218 /*
219 * init_names:
220 * Generate the names of the various scrolls
221 */
222
223 init_names()
224 {
225 register int nsyl;
226 register char *cp, *sp;
227 register int i, nwords;
228
229 for (i = 0 ; i < MAXSCROLLS ; i++)
230 {
231 cp = prbuf;
232 nwords = rnd(cols/20) + 1 + (cols > 40 ? 1 : 0);
233 while(nwords--)
234 {
235 nsyl = rnd(5)+1;
236 while(nsyl--)
237 {
238 sp = sylls[rnd(NSYLLS)].w_string;
239 while(*sp)
240 *cp++ = *sp++;
241 }
242 *cp++ = ' ';
243 }
244 *--cp = '\0';
245 s_names[i] = (char *) new(strlen(prbuf)+1);
246 s_know[i] = FALSE;
247 s_guess[i] = NULL;
248 strcpy(s_names[i], prbuf);
249 if (i > 0)
250 s_magic[i].mi_prob += s_magic[i-1].mi_prob;
251 }
252 badcheck("scrolls", s_magic, MAXSCROLLS);
253 }
254
255 /*
256 * init_player:
257 * roll up the rogue
258 */
259
260 init_player()
261 {
262 int stat_total, round = 0, minimum, maximum, ch, i, j = 0;
263 short do_escape, *our_stats[NUMABILITIES-1];
264 struct linked_list *weap_item, *armor_item, *food_item;
265 struct object *obj;
266
267 weap_item = armor_item = food_item = NULL;
268
269 if (char_type == -1) { /* not set via options */
270 /* See what type character will be */
271 wclear(hw);
272 touchwin(hw);
273 wmove(hw,2,0);
274 for(i=1; i<=NUM_CHARTYPES-1; i++) {
275 wprintw(hw,"[%d] %s\n",i,char_class[i-1].name);
276 }
277 mvwaddstr(hw, 0, 0, "What character class do you desire? ");
278 draw(hw);
279 char_type = (wgetch(hw) - '0');
280 while (char_type < 1 || char_type > NUM_CHARTYPES-1) {
281 wmove(hw,0,0);
282 wprintw(hw,"Please enter a character type between 1 and %d: ",
283 NUM_CHARTYPES-1);
284 draw(hw);
285 char_type = (wgetch(hw) - '0');
286 }
287 char_type--;
288 }
289 player.t_ctype = char_type;
290 player.t_quiet = 0;
291 pack = NULL;
292
293 /* Select the gold */
294 purse = 3000;
295 switch (player.t_ctype) {
296 case C_FIGHTER:
297 purse += 200;
298 when C_MAGICIAN:
299 case C_CLERIC:
300 case C_DRUID:
301 purse += 100;
302 when C_THIEF:
303 case C_ASSASSIN:
304 purse += 0;
305 when C_RANGER:
306 case C_PALADIN:
307 purse -= 100;
308 when C_MONK:
309 purse -= 200;
310 }
311 /*
312 * allow me to describe a super character
313 */
314 /* let's lessen the restrictions on this okay? */
315 if (wizard && strcmp(getenv("SUPER"),"YES") == 0) {
316 pstats.s_str = MAXATT;
317 pstats.s_intel = MAXATT;
318 pstats.s_wisdom = MAXATT;
319 pstats.s_dext = MAXATT;
320 pstats.s_const = MAXATT;
321 pstats.s_charisma = MAXATT;
322 pstats.s_exp = 10000000L;
323 pstats.s_lvl = 1;
324 pstats.s_lvladj = 0;
325 pstats.s_hpt = 500;
326 pstats.s_carry = totalenc(&player);
327 strcpy(pstats.s_dmg,"4d8");
328 check_level();
329 wmove(hw,0,0);
330 wclrtoeol(hw);
331 draw(hw);
332 mpos = 0;
333
334 /* set quest item */
335 if(player.t_ctype == C_FIGHTER) quest_item = AXE_AKLAD;
336 if(player.t_ctype == C_RANGER) quest_item = BRIAN_MANDOLIN;
337 if(player.t_ctype == C_PALADIN) quest_item = HEIL_ANKH;
338 if(player.t_ctype == C_MAGICIAN) quest_item = STONEBONES_AMULET;
339 if(player.t_ctype == C_CLERIC) quest_item = GERYON_HORN;
340 if(player.t_ctype == C_THIEF) quest_item = MUSTY_DAGGER;
341 if(player.t_ctype == C_ASSASSIN) quest_item = EYE_VECNA;
342 if(player.t_ctype == C_DRUID) quest_item = QUILL_NAGROM;
343 if(player.t_ctype == C_MONK) quest_item = EMORI_CLOAK;
344
345 /* armor */
346 if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN)
347 j = STUDDED_LEATHER;
348 else if (player.t_ctype == C_MONK) {