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