Mercurial > hg > early-roguelike
view xrogue/init.c @ 272:1db299e868b8
UltraRogue: add the autosave feature.
UltraRogue now automatically saves the game when SIGHUP or SIGTERM is
received.
| author | John "Elwin" Edwards |
|---|---|
| date | Sun, 03 Sep 2017 19:58:22 -0400 |
| parents | f54901b9c39b |
| children | 0250220d8cdd |
line wrap: on
line source
/* init.c - global variable initializaton XRogue: Expeditions into the Dungeons of Doom Copyright (C) 1991 Robert Pietkivitch All rights reserved. Based on "Advanced Rogue" Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T All rights reserved. Based on "Rogue: Exploring the Dungeons of Doom" Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman All rights reserved. See the file LICENSE.TXT for full copyright and licensing information. */ #include <curses.h> #include <ctype.h> #include <string.h> #include "rogue.h" #include "mach_dep.h" /* * If there is any news, put it in a character string and assign it to * rogue_news. Otherwise, assign NULL to rogue_news. */ static char *rogue_news = "Enter a number within the minimum and maximum \ range. When satisfied with your choices, enter a 'y'. For help at any \ other time enter a '?' or a '='."; /* replace the above line with this when descriptions are done */ /* other time enter a '?' or a '='. For character and item descriptions \ enter a '\\' on any other screen."; */ struct words rainbow[NCOLORS] = { "Amber", "Aquamarine", "Beige", "Black", "Blue", "Brown", "Clear", "Crimson", "Ecru", "Gold", "Green", "Grey", "Indigo", "Khaki", "Lavender", "Magenta", "Orange", "Pink", "Plaid", "Purple", "Red", "Silver", "Saffron", "Scarlet", "Tan", "Tangerine", "Topaz", "Turquoise", "Vermilion", "Violet", "White", "Yellow", }; struct words sylls[NSYLLS] = { "a", "ae", "ak", "an", "ax", "ach", "ano", "ars", "bha", "bar", "bre", "cha", "cre", "cum", "cow", "duh", "dha", "e", "ea", "em", "et", "ey", "eck", "etk", "egg", "exl", "fu", "fen", "fid", "gan", "gle", "h", "ha", "hr", "ht", "how", "hex", "hip", "hoc", "i", "ia", "ig", "it", "iz", "ion", "ink", "ivi", "iss", "je", "jin", "jha", "jyr", "ka", "kho", "kal", "kli", "lu", "lre", "lta", "lri", "m", "ma", "mh", "mi", "mr", "mar", "myr", "moh", "mul", "nep", "nes", "o", "oc", "om", "oq", "ox", "orn", "oxy", "olm", "ode", "po", "pie", "pod", "pot", "qar", "que", "ran", "rah", "rok", "sa", "sat", "sha", "sol", "sri", "ti", "tem", "tar", "tki", "tch", "tox", "u", "ub", "uh", "ur", "uv", "unk", "uwh", "ugh", "uyr", "va", "vil", "vit", "vom", "vux", "wah", "wex", "xu", "xed", "xen", "ya", "yep", "yih", "zef", "zen", "zil", "zym", "-" }; struct words stones[NSTONES] = { "Agate", "Alexandrite", "Amethyst", "Azurite", "Bloodstone", "Cairngorm", "Carnelian", "Chalcedony", "Chrysoberyl", "Chrysolite", "Chrysoprase", "Citrine", "Coral", "Diamond", "Emerald", "Garnet", "Heliotrope", "Hematite", "Hyacinth", "Jacinth", "Jade", "Jargoon", "Jasper", "Kryptonite", "Lapis lazuli", "Malachite", "Mocca stone", "Moonstone", "Obsidian", "Olivine", "Onyx", "Opal", "Pearl", "Peridot", "Quartz", "Rhodochrosite", "Rhodolite", "Ruby", "Sapphire", "Sardonyx", "Serpentine", "Spinel", "Tiger eye", "Topaz", "Tourmaline", "Turquoise", "Zircon", }; struct words wood[NWOOD] = { "Avocado wood", "Balsa", "Banyan", "Birch", "Cedar", "Cherry", "Cinnabar", "Dogwood", "Driftwood", "Ebony", "Eucalyptus", "Hemlock", "Ironwood", "Mahogany", "Manzanita", "Maple", "Oak", "Pine", "Redwood", "Rosewood", "Teak", "Walnut", "Aloe", "Sandalwood", }; struct words metal[NMETAL] = { "Aluminium", "Bone", "Brass", "Bronze", "Copper", "Chromium", "Iron", "Lead", "Magnesium", "Pewter", "Platinum", "Silver", "Steel", "Tin", "Titanium", "Zinc", }; /* * make sure all the percentages specified in the tables add up to the * right amounts */ void badcheck(char *name, struct magic_item *magic, int bound) { register struct magic_item *end; if (magic[bound - 1].mi_prob == 1000) return; printf("\nBad percentages for %s:\n", name); for (end = &magic[bound] ; magic < end ; magic++) printf("%4d%% %s\n", magic->mi_prob, magic->mi_name); printf(retstr); fflush(stdout); while (getchar() != '\n') continue; } /* * init_colors: * Initialize the potion color scheme for this time */ void init_colors(void) { register int i; register char *str; for (i = 0 ; i < MAXPOTIONS ; i++) { do str = rainbow[rnd(NCOLORS)].w_string; until (isupper(*str)); *str = tolower(*str); p_colors[i] = str; p_know[i] = FALSE; p_guess[i] = NULL; if (i > 0) p_magic[i].mi_prob += p_magic[i-1].mi_prob; } badcheck("potions", p_magic, MAXPOTIONS); } /* * do any initialization for food */ void init_foods(void) { register int i; for (i=0; i < MAXFOODS; i++) { if (i > 0) foods[i].mi_prob += foods[i-1].mi_prob; } badcheck("foods", foods, MAXFOODS); } /* * init_materials: * Initialize the construction materials for wands and staffs */ void init_materials(void) { register int i; register char *str; for (i = 0 ; i < MAXSTICKS ; i++) { do if (rnd(100) > 50) { str = metal[rnd(NMETAL)].w_string; if (isupper(*str)) ws_type[i] = "wand"; } else { str = wood[rnd(NWOOD)].w_string; if (isupper(*str)) ws_type[i] = "staff"; } until (isupper(*str)); *str = tolower(*str); ws_made[i] = str; ws_know[i] = FALSE; ws_guess[i] = NULL; if (i > 0) ws_magic[i].mi_prob += ws_magic[i-1].mi_prob; } badcheck("sticks", ws_magic, MAXSTICKS); } /* * do any initialization for miscellaneous magic */ void init_misc(void) { register int i; for (i=0; i < MAXMM; i++) { m_know[i] = FALSE; m_guess[i] = NULL; if (i > 0) m_magic[i].mi_prob += m_magic[i-1].mi_prob; } badcheck("miscellaneous magic", m_magic, MAXMM); } /* * init_names: * Generate the names of the various scrolls */ void init_names(void) { register int nsyl; register char *cp, *sp; register int i, nwords; for (i = 0 ; i < MAXSCROLLS ; i++) { cp = prbuf; nwords = rnd(cols/20) + 1 + (cols > 40 ? 1 : 0); while(nwords--) { nsyl = rnd(5)+1; while(nsyl--) { sp = sylls[rnd(NSYLLS)].w_string; while(*sp) *cp++ = *sp++; } *cp++ = ' '; } *--cp = '\0'; s_names[i] = (char *) new(strlen(prbuf)+1); s_know[i] = FALSE; s_guess[i] = NULL; strcpy(s_names[i], prbuf); if (i > 0) s_magic[i].mi_prob += s_magic[i-1].mi_prob; } badcheck("scrolls", s_magic, MAXSCROLLS); } /* * init_player: * roll up the rogue */ void init_player(void) { int stat_total, round = 0, minimum, maximum, ch, i, j = 0; short do_escape, *our_stats[NUMABILITIES-1]; struct linked_list *weap_item, *armor_item, *food_item; struct object *obj; weap_item = armor_item = food_item = NULL; if (char_type == -1) { /* not set via options */ /* See what type character will be */ wclear(hw); touchwin(hw); wmove(hw,2,0); for(i=1; i<=NUM_CHARTYPES-1; i++) { wprintw(hw,"[%d] %s\n",i,char_class[i-1].name); } mvwaddstr(hw, 0, 0, "What character class do you desire? "); draw(hw); char_type = (wgetch(hw) - '0'); while (char_type < 1 || char_type > NUM_CHARTYPES-1) { wmove(hw,0,0); wprintw(hw,"Please enter a character type between 1 and %d: ", NUM_CHARTYPES-1); draw(hw); char_type = (wgetch(hw) - '0'); } char_type--; } player.t_ctype = char_type; player.t_quiet = 0; pack = NULL; /* Select the gold */ purse = 3000; switch (player.t_ctype) { case C_FIGHTER: purse += 200; when C_MAGICIAN: case C_CLERIC: case C_DRUID: purse += 100; when C_THIEF: case C_ASSASSIN: purse += 0; when C_RANGER: case C_PALADIN: purse -= 100; when C_MONK: purse -= 200; } /* * allow me to describe a super character */ /* let's lessen the restrictions on this okay? */ if (wizard && strcmp(getenv("SUPER"),"YES") == 0) { pstats.s_str = MAXATT; pstats.s_intel = MAXATT; pstats.s_wisdom = MAXATT; pstats.s_dext = MAXATT; pstats.s_const = MAXATT; pstats.s_charisma = MAXATT; pstats.s_exp = 10000000L; pstats.s_lvl = 1; pstats.s_lvladj = 0; pstats.s_hpt = 500; pstats.s_carry = totalenc(&player); strcpy(pstats.s_dmg,"4d8"); check_level(); wmove(hw,0,0); wclrtoeol(hw); draw(hw); mpos = 0; /* set quest item */ if(player.t_ctype == C_FIGHTER) quest_item = AXE_AKLAD; if(player.t_ctype == C_RANGER) quest_item = BRIAN_MANDOLIN; if(player.t_ctype == C_PALADIN) quest_item = HEIL_ANKH; if(player.t_ctype == C_MAGICIAN) quest_item = STONEBONES_AMULET; if(player.t_ctype == C_CLERIC) quest_item = GERYON_HORN; if(player.t_ctype == C_THIEF) quest_item = MUSTY_DAGGER; if(player.t_ctype == C_ASSASSIN) quest_item = EYE_VECNA; if(player.t_ctype == C_DRUID) quest_item = QUILL_NAGROM; if(player.t_ctype == C_MONK) quest_item = EMORI_CLOAK; /* armor */
