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) {
349 armor_item = spec_item(MM, MM_BRACERS, 20, 0);
350 obj = OBJPTR(armor_item);
351 obj->o_weight = things[TYP_MM].mi_wght;
352 whatis (armor_item); /* identify it */
353 obj->o_flags |= (ISKNOW | ISPROT);
354 add_pack(armor_item, TRUE);
355 cur_misc[WEAR_BRACERS] = obj;
356 goto w_armorjmp;
357 }
358 else j = PLATE_ARMOR;
359
360 armor_item = spec_item(ARMOR, j, 20, 0);
361 obj = OBJPTR(armor_item);
362 obj->o_weight = armors[j].a_wght;
363 obj->o_flags |= (ISKNOW | ISPROT);
364 add_pack(armor_item, TRUE);
365 cur_armor = obj;
366
367 w_armorjmp: /* monk doesn't wear armor */
368
369 /* weapons */
370 if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN ||
371 player.t_ctype == C_MONK)
372 j = BASWORD;
373 else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
374 player.t_ctype == C_PALADIN)
375 j = TWOSWORD;
376 else j = TRIDENT;
377
378 weap_item = spec_item(WEAPON, j, 20, 20);
379 obj = OBJPTR(weap_item);
380 obj->o_flags |= (ISKNOW | ISPROT);
381 obj->o_weight = weaps[j].w_wght;
382 add_pack(weap_item, TRUE);
383 cur_weapon = obj;
384
385 /* food */
386 food_item = spec_item(FOOD, E_RATION, 0, 0);
387 obj = OBJPTR(food_item);
388 obj->o_flags |= ISKNOW;
389 obj->o_weight = foods[TYP_FOOD].mi_wght;
390 add_pack(food_item, TRUE); /* just one */
391
392 /* give wizard plenty gold */
393 purse = 50000;
394 }
395 else
396 /* default attributes checked */
397 {
398 if (def_attr == TRUE) { /* "default" option used in ROGUEOPTS */
399 switch(player.t_ctype) {
400 /* set "default attributes" option and quest items here */
401 case C_FIGHTER:
402 case C_MONK:
403 pstats.s_intel = 7;
404 pstats.s_dext = 16;
405 pstats.s_charisma = 11;
406 if (player.t_ctype == C_FIGHTER) {
407 pstats.s_str = 16;
408 pstats.s_wisdom = 7;
409 pstats.s_const = 17;
410 quest_item = AXE_AKLAD;
411 }
412 else {
413 pstats.s_str = 11;
414 pstats.s_wisdom = 11;
415 pstats.s_const = 18;
416 quest_item = EMORI_CLOAK;
417 }
418 when C_RANGER:
419 case C_PALADIN:
420 pstats.s_str = 11;
421 pstats.s_dext = 16;
422 pstats.s_const = 16;
423 pstats.s_charisma = 13;
424 /* intelligence or wisdom */
425 if (player.t_ctype == C_RANGER) {
426 pstats.s_intel = 11;
427 pstats.s_wisdom = 7;
428 quest_item = BRIAN_MANDOLIN;
429 }
430 else {
431 pstats.s_intel = 7;
432 pstats.s_wisdom = 11;
433 quest_item = HEIL_ANKH;
434 }
435 when C_THIEF:
436 case C_ASSASSIN:
437 pstats.s_intel = 7;
438 pstats.s_str = 14;
439 pstats.s_wisdom = 7;
440 pstats.s_dext = 18;
441 pstats.s_const = 17;
442 pstats.s_charisma = 11;
443 if (player.t_ctype == C_THIEF)
444 quest_item = MUSTY_DAGGER;
445 else
446 quest_item = EYE_VECNA;
447 when C_MAGICIAN:
448 case C_CLERIC:
449 case C_DRUID:
450 pstats.s_str = 10;
451 pstats.s_dext = 16;
452 pstats.s_const = 15;
453 pstats.s_charisma = 12;
454 /* intelligence & wisdom */
455 if (player.t_ctype == C_MAGICIAN) {
456 pstats.s_intel = 14;
457 pstats.s_wisdom = 7;
458 }
459 else {
460 pstats.s_intel = 7;
461 pstats.s_wisdom = 14;
462 }
463 if (player.t_ctype == C_MAGICIAN)
464 quest_item = STONEBONES_AMULET;
465 else if (player.t_ctype == C_CLERIC)
466 quest_item = GERYON_HORN;
467 else
468 quest_item = QUILL_NAGROM;
469 }
470 /* Intialize */
471 pstats.s_exp = 0L;
472 pstats.s_lvl = 1;
473 pstats.s_lvladj = 0;
474 pstats.s_exp = 0L;
475 strcpy(pstats.s_dmg,"2d4");
476 pstats.s_carry = totalenc(&player);
477 check_level();
478 wmove(hw,0,0);
479 wclrtoeol(hw);
480 draw(hw);
481 mpos = 0;
482
483 /* Get the hit points. */
484 pstats.s_hpt = 12 + const_bonus(); /* Base plus bonus */
485
486 /* Add in the component that varies according to class */
487 pstats.s_hpt += char_class[player.t_ctype].hit_pts;
488
489 /* dole out some armor */
490 if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN)
491 j = STUDDED_LEATHER;
492 else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
493 player.t_ctype == C_PALADIN) {
494 switch (rnd(4)) {
495 case 0: j = PLATE_ARMOR;
496 when 1: j = PLATE_MAIL;
497 when 2: case 3: j = BANDED_MAIL;
498 }
499 }
500 else if (player.t_ctype == C_MONK) {
501 if (rnd(3) == 0) j = MM_PROTECT;
502 else j = MM_BRACERS;
503 armor_item = spec_item(MM, j, rnd(125)/60+3, 0);
504 obj = OBJPTR(armor_item);
505 obj->o_weight = things[TYP_MM].mi_wght;
506 whatis (armor_item); /* identify it */
507 obj->o_flags |= ISKNOW;
508 add_pack(armor_item, TRUE);
509 goto p_armorjmp;
510 }
511 else { /* other characters */
512 switch (rnd(7)) {
513 case 0: j = PLATE_MAIL;
514 when 1: case 2: j = BANDED_MAIL;
515 when 3: case 4: j = SPLINT_MAIL;
516 when 5: case 6: j = PADDED_ARMOR;
517 }
518 }
519 armor_item = spec_item(ARMOR, j, rnd(100)/85, 0);
520 obj = OBJPTR(armor_item);
521 obj->o_weight = armors[j].a_wght;
522 obj->o_flags |= ISKNOW;
523 add_pack(armor_item, TRUE);
524
525 p_armorjmp: /* monk doesn't wear armor */
526
527 /* give him a weapon */
528 if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASSIN ||
529 player.t_ctype == C_MONK) {
530 switch (rnd(5)) {
531 case 0: j = BASWORD;
532 when 1: case 2: j = TRIDENT;
533 when 3: case 4: j = BARDICHE;
534 }
535 }
536 else if (player.t_ctype == C_FIGHTER || player.t_ctype == C_RANGER ||
537 player.t_ctype == C_PALADIN) {
538 switch (rnd(5)) {
539 case 0: j= TWOSWORD;
540 when 1: case 2: j= TRIDENT;
541 when 3: case 4: j= SWORD;
542 }
543 }
544 else {
545 switch (rnd(7)) {
546 case 0: j = TRIDENT;
547 when 1: case 2: j = SWORD;
548 when 3: case 4: j = BARDICHE;
549 when 5: j = MACE;
550 when 6: j = SPETUM;
551 }
552 }
553 weap_item = spec_item(WEAPON, j, rnd(155)/75, rnd(165)/80);
554 obj = OBJPTR(weap_item);
555 obj->o_weight = weaps[j].w_wght;
556 obj->o_flags |= ISKNOW;
557 add_pack(weap_item, TRUE);
558
559 /* food rations */
560 food_item = spec_item(FOOD, E_RATION, 0, 0);
561 obj = OBJPTR(food_item);
562 obj->o_weight = foods[TYP_FOOD].mi_wght;
563 obj->o_flags |= ISKNOW;
564 add_pack(food_item, TRUE);
565
566 /* give him some fruit - coose from those w/o special effects */
567 switch (rnd(6)) {
568 case 0: j = E_BANANA;
569 when 1: j = E_BLUEBERRY;
570 when 2: j = E_ELDERBERRY;
571 when 3: j = E_GUANABANA;
572 when 4: j = E_CAPRIFIG;
573 when 5: j = E_GOOSEBERRY;
574 }
575 food_item = spec_item(FOOD, j, 0, 0);
576 obj = OBJPTR(food_item);
577 obj->o_weight = foods[TYP_FOOD].mi_wght;
578 obj->o_flags |= ISKNOW;
579 add_pack(food_item, TRUE);
580
581 /* adjust purse */
582 purse = 2000;
583 }
584 else { /* select attibutes */
585 switch(player.t_ctype) {
586 case C_FIGHTER: round = A_STRENGTH;
587 when C_RANGER: round = A_CHARISMA;
588 when C_PALADIN: round = A_CHARISMA;
589 when C_MAGICIAN: round = A_INTELLIGENCE;
590 when C_CLERIC: round = A_WISDOM;
591 when C_THIEF: round = A_DEXTERITY;
592 when C_ASSASSIN: round = A_DEXTERITY;
593 when C_DRUID: round = A_WISDOM;
594 when C_MONK: round = A_CONSTITUTION;
595 }
596
597 do {
598 wclear(hw);
599
600 /* If there is any news, display it */
601 if (rogue_news) {
602 register int i;
603
604 /* Print a separator line */
605 wmove(hw, 12, 0);
606 for (i=0; i<cols; i++) waddch(hw, '-');
607
608 /* Print the news */
609 mvwaddstr(hw, 14, 0, rogue_news);
610 }
611
612 stat_total = MAXSTATS;
613 do_escape = FALSE; /* No escape seen yet */
614
615 /* Initialize abilities */
616 pstats.s_intel = 0;
617 pstats.s_str = 0;
618 pstats.s_wisdom = 0;
619 pstats.s_dext = 0;
620 pstats.s_const = 0;
621 pstats.s_charisma = 0;
622
623 /* Initialize pointer into abilities */
624 our_stats[A_INTELLIGENCE] = &pstats.s_intel;
625 our_stats[A_STRENGTH] = &pstats.s_str;
626 our_stats[A_WISDOM] = &pstats.s_wisdom;
627 our_stats[A_DEXTERITY] = &pstats.s_dext;
628 our_stats[A_CONSTITUTION] = &pstats.s_const;
629
630 /* Let player distribute attributes */
631 for (i=0; i<NUMABILITIES-1; i++) {
632 wmove(hw, 2, 0);
633 wprintw(hw, "You are creating a %s with %2d attribute points.",
634 char_class[player.t_ctype].name, stat_total);
635
636 /*
637 * Player must have a minimum of 7 in any attribute and 11 in
638 * the player's primary attribute.
639 */
640 minimum = (round == i ? 11 : 7);
641
642 /* Subtract out remaining minimums */
643 maximum = stat_total - (7 * (NUMABILITIES-1 - i));
644
645 /* Subtract out remainder of profession minimum (11 - 7) */
646 if (round > i) maximum -= 4;
647
648 /* Maximum can't be greater than 18 */
649 if (maximum > 18) maximum = 18;
650
651 wmove(hw, 4, 0);
652 wprintw(hw,
653 "Minimum: %2d; Maximum: %2d (%s corrects previous entry)",
654 minimum, maximum, unctrl('\b'));
655
656 wmove(hw, 6, 0);
657 wprintw(hw, " Int: %-2d", pstats.s_intel);
658 wprintw(hw, " Str: %-2d", pstats.s_str);
659 wprintw(hw, " Wis: %-2d", pstats.s_wisdom);
660 wprintw(hw, " Dex: %-2d", pstats.s_dext);
661 wprintw(hw, " Con: %-2d", pstats.s_const);
662 wprintw(hw, " Cha: %-2d", pstats.s_charisma);
663 wclrtoeol(hw);
664 wmove(hw, 6, 11*i + 9);
665 if (do_escape == FALSE) draw(hw);
666
667 /* Get player's input */
668 if (do_escape || maximum == minimum) {
669 *our_stats[i] = maximum;
670 stat_total -= maximum;
671 }
672 else for (;;) {
673 ch = wgetch(hw);
674 if (ch == '\b') { /* Backspace */
675 if (i == 0) continue; /* Can't move back */
676 else {
677 stat_total += *our_stats[i-1];
678 *our_stats[i] = 0;
679 *our_stats[i-1] = 0;
680 i -= 2; /* Back out */
681 break;
682 }
683 }
684 if (ch == '\033') { /* Escape */
685 /*
686 * Escape will result in using all maximums for
687 * remaining abilities.
688 */
689 do_escape = TRUE;
690 *our_stats[i] = maximum;
691 stat_total -= maximum;
692 break;
693 }
694
695 /* Do we have a legal digit? */
696 if (ch >= '0' && ch <= '9') {
697 ch -= '0'; /* Convert it to a number */
698 *our_stats[i] = 10 * *our_stats[i] + ch;
699
700 /* Is the number in range? */
701 if (*our_stats[i] >= minimum &&
702 *our_stats[i] <= maximum) {
703 stat_total -= *our_stats[i];
704 break;
705 }
706
707 /*
708 * If it's too small, get more - 1x is the only
709 * allowable case.
710 */
711 if (*our_stats[i] < minimum && *our_stats[i] == 1) {
712 /* Print the player's one */
713 waddch(hw, '1');
714 draw(hw);
715 continue;
716 }
717 }
718
719 /* Error condition */
720 putchar('\007');
721 *our_stats[i] = 0;
722 i--; /* Rewind */
723 break;
724 }
725 }
726
727 /* Discard extra points over 18 */
728 if (stat_total > 18) stat_total = 18;
729
730 /* Charisma gets what's left */
731 pstats.s_charisma = stat_total;
732
733 /* Intialize constants */
734 pstats.s_lvl = 1;
735 pstats.s_lvladj = 0;
736 pstats.s_exp = 0L;
737 strcpy(pstats.s_dmg,"2d4");
738 pstats.s_carry = totalenc(&player);
739
740 /* Get the hit points. */
741 pstats.s_hpt = 12 + const_bonus(); /* Base plus bonus */
742
743 /* Add in the component that varies according to class */
744 pstats.s_hpt += char_class[player.t_ctype].hit_pts;
745
746 /* Display the character */
747 wmove(hw, 2, 0);
748 wprintw(hw,"You are creating a %s.",
749 char_class[player.t_ctype].name);
750 wclrtoeol(hw);
751
752 /* Get rid of max/min line */
753 wmove(hw, 4, 0);
754 wclrtoeol(hw);
755
756 wmove(hw, 6, 0);
757 wprintw(hw, " Int: %2d", pstats.s_intel);
758 wprintw(hw, " Str: %2d", pstats.s_str);
759 wprintw(hw, " Wis: %2d", pstats.s_wisdom);
760 wprintw(hw, " Dex: %2d", pstats.s_dext);
761 wprintw(hw, " Con: %2d", pstats.s_const);
762 wprintw(hw, " Cha: %2d", pstats.s_charisma);
763 wclrtoeol(hw);
764
765 wmove(hw, 8, 0);
766 wprintw(hw, " Hp: %2d", pstats.s_hpt);
767 wclrtoeol(hw);
768
769 wmove(hw, 10, 0);
770 wprintw(hw, " Gold: %ld", purse);
771
772 mvwaddstr(hw, 0, 0, "Is this character okay? ");
773 draw(hw);
774 } while(wgetch(hw) != 'y');
775 }
776 }
777 pstats.s_arm = 10;
778 max_stats = pstats;
779 /* Set up initial movement rate */
780 player.t_action = A_NIL;
781 player.t_movement = 6;
782 player.t_no_move = 0;
783 player.t_using = NULL;
784 wclear(hw);
785 }
786
787 /*
788 * init_stones:
789 * Initialize the ring stone setting scheme for this time
790 */
791
792 init_stones()
793 {
794 register int i;
795 register char *str;
796
797 for (i = 0 ; i < MAXRINGS ; i++)
798 {
799 do
800 str = stones[rnd(NSTONES)].w_string;
801 until (isupper(*str));
802 *str = tolower(*str);
803 r_stones[i] = str;
804 r_know[i] = FALSE;
805 r_guess[i] = NULL;
806 if (i > 0)
807 r_magic[i].mi_prob += r_magic[i-1].mi_prob;
808 }
809 badcheck("rings", r_magic, MAXRINGS);
810 }
811
812 /*
813 * init_things
814 * Initialize the probabilities for types of things
815 */
816
817 init_things()
818 {
819 register struct magic_item *mp;
820
821 for (mp = &things[1] ; mp < &things[NUMTHINGS] ; mp++)
822 mp->mi_prob += (mp-1)->mi_prob;
823 badcheck("things", things, NUMTHINGS);
824 }
825