Mercurial > hg > early-roguelike
diff urogue/init.c @ 256:c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
author | John "Elwin" Edwards |
---|---|
date | Tue, 31 Jan 2017 19:56:04 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/urogue/init.c Tue Jan 31 19:56:04 2017 -0500 @@ -0,0 +1,1075 @@ +/* + init.c - global variable initializaton + + UltraRogue: The Ultimate Adventure in the Dungeons of Doom + Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong + All rights reserved. + + Based on "Advanced Rogue" + Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka + 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. +*/ + +/* + Notes + + Need to add ring of maintain armor (same as ring of prot, armor only) + Resplit file into one just for data, one just for functions +*/ + +#define _ALL_SOURCE /* Need to remove need for this AIXism */ + +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include "rogue.h" + +static char *rainbow[] = +{ + "Red", "Blue", "Green", "Yellow", + "Black", "Brown", "Orange", "Pink", + "Purple", "Grey", "White", "Silver", + "Gold", "Violet", "Clear", "Vermilion", + "Ecru", "Turquoise", "Magenta", "Amber", + "Topaz", "Plaid", "Tan", "Tangerine", + "Aquamarine", "Scarlet", "Khaki", "Crimson", + "Indigo", "Beige", "Lavender", "Saffron" +}; + +#define NCOLORS (sizeof rainbow / sizeof (char *)) + +static char *sylls[] = +{ + "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", "arze", + "ash", "ban", "bar", "bat", "bek", "bie", "bin", "bit", "bjor", + "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf", + "dan", "den", "do", "e", "eep", "el", "eng", "er", "ere", "erk", + "esh", "evs", "fa", "fid", "for", "fri", "fu", "gan", "gar", + "glen", "gop", "gre", "ha", "he", "hyd", "i", "ing", "ion", "ip", + "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech", + "man", "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur", + "nej", "nelg", "nep", "ner", "nes", "nes", "nih", "nin", "o", "od", + "ood", "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po", + "pot", "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol", + "sa", "san", "sat", "see", "sef", "seh", "shu", "ski", "sna", + "sne", "snik", "sno", "so", "sol", "sri", "sta", "sun", "ta", + "tab", "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u", + "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", "vom", "wah", + "wed", "werg", "wex", "whon", "wun", "xo", "y", "yot", "yu", + "zant", "zap", "zeb", "zim", "zok", "zon", "zum" +}; + +static char *stones[] = +{ + "Agate", "Alexandrite", "Amethyst", + "Azurite", "Carnelian", "Chrysoberyl", + "Chrysoprase", "Citrine", "Diamond", + "Emerald", "Garnet", "Hematite", + "Jacinth", "Jade", "Kryptonite", + "Lapus lazuli", "Malachite", "Moonstone", + "Obsidian", "Olivine", "Onyx", + "Opal", "Pearl", "Peridot", + "Quartz", "Rhodochrosite", "Ruby", + "Sapphire", "Sardonyx", "Serpentine", + "Spinel", "Tiger eye", "Topaz", + "Tourmaline", "Turquoise" +}; + +#define NSTONES (sizeof stones / sizeof (char *)) + +static char *wood[] = +{ + "Avocado wood", "Balsa", "Banyan", "Birch", + "Cedar", "Cherry", "Cinnibar", "Dogwood", + "Driftwood", "Ebony", "Eucalyptus", "Hemlock", + "Ironwood", "Mahogany", "Manzanita", "Maple", + "Oak", "Pine", "Redwood", "Rosewood", + "Teak", "Walnut", "Zebra wood", "Persimmon wood" +}; + +#define NWOOD (sizeof wood / sizeof (char *)) + +static char *metal[] = +{ + "Aluminium", "Bone", "Brass", "Bronze", + "Copper", "Chromium", "Iron", "Lead", + "Magnesium", "Pewter", "Platinum", "Steel", + "Tin", "Titanium", "Zinc", "Carbon", + "Plastic", "Glass", "Ice", "Chocolate", + "Gold", "Silver", "Invisible" +}; + +#define NMETAL (sizeof metal / sizeof (char *)) + +const char *monstern = "monster"; +char *spacemsg = "--Press SPACE to continue--"; +char *morestr = "--More--"; +char *retstr = "[Press RETURN to continue]"; + +/* 15 named levels */ + +const char *cnames[C_NOTSET][15] = +{ + { "Veteran", "Warrior", + "Swordsman", "Hero", /* Fighter */ + "Swashbuckler", "Myrmidon", + "Champion", "Superhero", + "Lord", "Lord", + "Lord", "Lord", + "Lord", "Lord", + "Lord" + }, + + { "Gallant", "Keeper", + "Protector", "Defender", /* Paladin */ + "Warder", "Guardian", + "Chevalier", "Justiciar", + "Paladin", "Paladin", + "Paladin", "Paladin", + "Paladin", "Paladin", + "Paladin" + }, + + { "Runner", "Strider", + "Scout", "Courser", /* Ranger */ + "Tracker", "Guide", + "Pathfinder", "Ranger", + "Ranger Knight", "Ranger Lord", + "Ranger Lord", "Ranger Lord", + "Ranger Lord", "Ranger Lord", + "Ranger Lord" + }, + + { "Acolyte", "Adept", + "Priest", "Curate", /* Cleric */ + "Prefect", "Canon", + "Lama", "Patriarch", + "High Priest", "High Priest", + "High Priest", "High Priest", + "High Priest", "High Priest", + "High Priest" + }, + + { "Aspirant", "Ovate", /* Druid */ + "Initiate of the 1st Circle", "Initiate of the 2nd Circle", + "Initiate of the 3rd Circle", "Initiate of the 4th Circle", + "Initiate of the 5th Circle", "Initiate of the 6th Circle", + "Initiate of the 7th Circle", "Initiate of the 8th Circle", + "Initiate of the 9th Circle", "Druid", + "Archdruid", "The Great Druid", + "The Grand Druid" + }, + + { "Prestidigitator", "Evoker", + "Conjurer", "Theurgist", /* Magic User */ + "Thaumaturgist", "Magician", + "Enchanter", "Warlock", + "Sorcerer", "Necromancer", + "Wizard", "Wizard", + "Wizard", "Wizard", + "Wizard" + }, + + { "Prestidigitator", "Minor Trickster", + "Trickster", "Master Trickster", /* Illusionist */ + "Cabalist", "Visionist", + "Phantasmist", "Apparitionist", + "Spellbinder", "Illusionist", + "Illusionist", "Illusionist", + "Illusionist", "Illusionist", + "Illusionist" + }, + + { "Rogue", "Footpad", + "Cutpurse", "Robber", /* Thief */ + "Burglar", "Filcher", + "Sharper", "Magsman", + "Thief", "Master Thief", + "Master Thief", "Master Thief", + "Master Thief", "Master Thief", + "Master Thief" + }, + + { "Bravo", "Rutterkin", + "Waghalter", "Murderer", /* Assasin */ + "Thug", "Killer", + "Cutthroat", "Executioner", + "Assassin", "Expert Assassin", + "Senior Assassin", "Chief Assassin", + "Prime Assassin", "Guildmaster Assassin", + "Grandfather of Assassins" + }, + + { "Ninja", "Ninja", + "Ninja", "Ninja", /* Ninja */ + "Ninja", "Ninja", + "Ninja", "Ninja", + "Ninja", "Ninja", + "Ninja", "Ninja", + "Ninja", "Ninja", + "Ninja" + } +}; + +const struct h_list helpstr[] = +{ + { '?', " prints help" }, + { '/', " identify object" }, + { 'h', " left" }, + { 'j', " down" }, + { 'k', " up" }, + { 'l', " right" }, + { 'y', " up & left" }, + { 'u', " up & right" }, + { 'b', " down & left" }, + { 'n', " down & right" }, + { '<', "SHIFT><dir> run that way" }, + { 'm', "<dir> move onto without picking up" }, + { 't', "<dir> throw something" }, + { 'z', "<dir> zap a wand or staff" }, + { '>', " go down a staircase" }, + { 's', " search for trap/secret door" }, + { '.', " rest for a while" }, + { ',', " pick up an object" }, + { 'i', " inventory all items" }, + { 'I', " inventory type of item" }, + { 'q', " quaff potion" }, + { 'r', " read paper" }, + { 'e', " eat food" }, + { 'w', " wield a weapon" }, + { 'W', " wear armor" }, + { 'T', " take armor off" }, + { 'P', " put on ring" }, + { 'R', " remove ring" }, + { 'A', " activate/apply an artifact" }, + { 'd', " drop object" }, + { 'C', " call object (generic)" }, + { 'M', " mark object (specific)" }, + { 'o', " examine/set options" }, + { 'c', " cast a spell/say a prayer" }, + { 'p', " pray for help (risky)" }, + { 'a', " affect the undead" }, + { '^', " set a trap" }, + { 'D', " dip something (into a pool)" }, + { 20, "<dir> take (steal) from (direction)" }, /* ctrl-t */ + { 18, " redraw screen" }, /* ctrl-r */ + { 16, " back up to 10 previous messages" }, /* ctrl-p */ + { ESCAPE, " cancel command" }, + { 'v', " print program version number" }, + { 'S', " save game" }, + { 'Q', " quit" }, + { '=', " listen for monsters" }, + { 'f', "<dir> fight monster" }, + { 'F', "<dir> fight monster to the death" }, + + /* Wizard commands. Identified by (h_ch != 0 && h_desc == 0). */ + + {'-', 0 }, + { 23, " enter wizard mode" }, /* ctrl-w */ + { 23, "v toggle wizard verbose mode" }, + { 23, "e exit wizard mode" }, + { 23, "r random number check" }, + { 23, "s system statistics" }, + { 23, "F food statistics" }, + { 23, "f floor map" }, + { 23, "m see monster" }, + { 23, "M create monster" }, + { 23, "c create item" }, + { 23, "i inventory level" }, + { 23, "I identify item" }, + { 23, "t random teleport" }, + { 23, "g goto level" }, + { 23, "C charge item" }, + { 23, "w print worth of object" }, + { 23, "o improve stats and pack" }, + { 0, 0 } +}; + +struct magic_item things[] = +{ + {"potion", "POTION", 250, 5}, /* potion */ + {"scroll", "SCROLL", 260, 30},/* scroll */ + {"ring", "RING", 70, 5}, /* ring */ + {"stick", "STICK", 60, 0}, /* stick */ + {"food", "FOOD", 210, 7}, /* food */ + {"weapon", "WEAPON", 60, 0}, /* weapon */ + {"armor", "ARMOR", 90, 0}, /* armor */ + {"artifact","ARTIFACT", 0, 0} /* special artifacts*/ +}; + +int numthings = NUMTHINGS; + +struct magic_item s_magic[] = +{ + {"monster confusion", "CON", 50, 125, 0, 0 }, + {"magic mapping", "MAP", 45, 150, 20, 10 }, + {"light", "WATT", 0, 0, 0, 0 }, + {"hold monster", "HOLD", 25, 200, 33, 10 }, + {"sleep", "SNOOZE", 23, 50, 20, 10 }, + {"enchantment", "ENCHANT", 110,400, 15, 10 }, + {"identify", "ID", 150,50, 0, 15 }, + {"scare monster", "SCARE", 35, 250, 27, 21 }, + {"detect gold", "GOLD", 0, 0, 0, 0 }, + {"teleportation", "TELEP", 50, 165, 10, 20 }, + {"create monster", "CREATE", 25, 75, 30, 0 }, + {"remove curse", "REM", 75, 220, 10, 15 }, + {"petrification", "PET", 25, 285, 0, 0 }, + {"genocide", "GEN", 10, 1200, 0, 0 }, + {"cure disease", "CURE", 70, 80, 0, 0 }, + {"acquirement", "MAKE", 5, 2500, 50, 15 }, + {"protection", "PROT", 50, 1150, 0, 0 }, + {"nothing", "NOTHING", 75, 50, 50, 50 }, + {"magic hitting", "SILVER", 25, 1875, 45, 10 }, + {"ownership", "OWN", 15, 1550, 45, 10 }, + {"detect food", "FOOD", 0, 0, 0, 0 }, + {"electrification", "ELECTRIFY",20, 1450, 0, 0 }, + {"charm monster", "CHARM", 26, 1500, 25, 15 }, + {"summon monster", "SUMMON", 26, 1500, 25, 15 }, + {"gaze reflection", "REFLECT", 25, 400, 25, 15 }, + {"summon familiar", "SUMFAM", 0, 0, 0, 0 }, + {"fear", "FEAR", 20, 200, 20, 10 }, + {"missile protection", "MSHIELD", 20, 300, 20, 10 } +}; + +int maxscrolls = MAXSCROLLS; + +struct magic_item p_magic[] = +{ + {"clear thought", "CLEAR", 90, 380, 27, 15 }, + {"gain ability", "GAINABIL", 40, 1250, 15, 15 }, + {"see invisible", "SEE", 0, 0, 0, 0 }, + {"healing", "HEAL", 120,330, 27, 27 }, + {"detect monster", "MON", 0, 0, 0, 0 }, + {"detect magic", "MAG", 0, 0, 0, 0 }, + {"raise level", "RAISE", 1, 1900, 11, 10 }, + {"haste self", "HASTE", 140,300, 30, 5 }, + {"restore abilities", "RESTORE", 130,120, 0, 0 }, + {"phasing", "PHASE", 45, 340, 21, 20 }, + {"invisibility", "INVIS", 30, 300, 0, 15 }, + {"acute scent", "SMELL", 30, 100, 20, 15 }, + {"acute hearing", "HEAR", 30, 100, 20, 15 }, + {"super heroism", "SUPER", 10, 800, 20, 15 }, + {"disguise", "DISGUISE", 30, 500, 0, 15 }, + {"fire resistance", "NOFIRE", 40, 350, 20, 15 }, + {"cold resistance", "NOCOLD", 40, 300, 20, 15 }, + {"continuous breathing","BREATHE", 10, 200, 20, 15 }, + {"flying", "FLY", 30, 300, 20, 15 }, + {"regeneration", "REGEN", 20, 500, 20, 15 }, + {"shield", "SHIELD", 100,200, 20, 10 }, + {"true sight", "TRUESEE", 64, 570, 25, 15 } +}; + +int maxpotions = MAXPOTIONS; + +struct magic_item r_magic[] = +{ + {"protection", "", 70, 500, 33, 25 }, + {"add strength", "", 65, 300, 33, 25 }, + {"sustain ability", "", 40, 380, 10, 0 }, + {"searching", "", 65, 250, 10, 0 }, + {"see invisible", "", 30, 175, 10, 0 }, + {"alertness", "", 40, 190, 10, 0 }, + {"aggravate monster", "", 35, 100, 100,0 }, + {"dexterity", "", 65, 220, 33, 25 }, + {"increase damage", "", 65, 320, 33, 25 }, + {"regeneration", "", 35, 860, 10, 0 }, + {"slow digestion", "", 40, 340, 15, 10 }, + {"teleportation", "", 35, 100, 100,0 }, + {"stealth", "", 50, 700, 10, 0 }, + {"add intelligence", "", 60, 540, 33, 25 }, + {"increase wisdom", "", 60, 540, 33, 25 }, + {"sustain health", "", 60, 250, 10, 0 }, + {"vampiric regeneration", "", 20, 900, 25, 10 }, + {"illumination", "", 20, 300, 10, 0 }, + {"delusion", "", 20, 100, 75, 0 }, + {"carrying", "", 20, 400, 30, 30 }, + {"adornment", "", 15, 10000, 10, 0 }, + {"levitation", "", 20, 450, 30, 0 }, + {"fire resistance", "", 10, 750, 10, 0 }, + {"cold resistance", "", 10, 650, 10, 0 }, + {"lightning resistance", "", 10, 750, 10, 0 }, + {"resurrection", "", 1, 8000, 10, 0 }, + {"breathing", "", 10, 250, 10, 0 }, + {"free action", "", 10, 225, 10, 0 }, + {"wizardry", "", 2, 1950, 10, 0 }, + {"piety", "", 2, 1950, 10, 0 }, + {"teleport control", "", 5, 450, 10, 0 }, + {"true sight", "", 10, 775, 10, 0 } +}; + +int maxrings = MAXRINGS; + +struct magic_item ws_magic[] = +{ + {"light", "LIGHT", 90, 150, 20, 20 }, + {"striking", "HIT", 58, 400, 0, 0 }, + {"lightning", "BOLT", 25, 800, 0, 0 }, + {"fire", "FIRE", 25, 600, 0, 0 }, + {"cold", "COLD", 30, 600, 0, 0 }, + {"polymorph", "POLY", 90, 210, 0, 0 }, + {"magic missile", "MLE", 90, 500, 0, 0 }, + {"slow monster", "SLOW", 76, 320, 25, 20 }, + {"drain life", "DRAIN", 90, 310, 20, 0 }, + {"charging", "CHARGE", 70, 1100, 0, 0 }, + {"teleport monster","RANDOM", 90, 240, 25, 20 }, + {"cancellation", "CANCEL", 38, 230, 0, 0 }, + {"confuse monster", "CONFMON", 50, 200, 0, 0 }, + {"disintegration", "KILL-O-ZAP", 10, 1550, 33, 0 }, + {"anti-matter", "BLACKHOLE", 30, 980, 0, 0 }, + {"paralyze monster","PARAL", 38, 200, 0, 0 }, + {"heal monster", "XENOHEAL", 30, 200, 40, 10 }, + {"nothing", "NOTHING", 30, 100, 0, 0 }, + {"invisibility", "WS_INVIS", 30, 150, 30, 5 }, + {"blasting", "BLAST", 10, 220, 0, 0 }, + {"webbing", "WEB", 0, 0, 0, 0 }, + {"door opening", "KNOCK", 0, 0, 0, 0 }, + {"hold portal", "CLOSE", 0, 0, 0, 0 } +}; + +int maxsticks = MAXSTICKS; + +struct magic_item fd_data[] = +{ + {"food ration", "RATION", 400, 20, 20, 20 }, + {"random fruit","FRUIT", 300, 10, 0, 0}, + {"cram", "CRAM", 120, 30, 0, 0 }, + {"honey cake", "CAKES", 80, 10, 0, 0 }, + {"lemba", "LEMBA", 50, 80, 0, 0 }, + {"miruvor", "MIRUVOR", 50, 200, 0, 0 } +}; + +int maxfoods = MAXFOODS; + +/* + * weapons and their attributes + * Average Damage = (min_damage + max_damage) / 2) + * AD of 2D5+3 = (5 + 13) / 2 = 9 + * AD of 3D6 = (3 + 18) / 2 = 10.5 + */ + +#define ISSHARPMETAL (ISSHARP | ISMETAL) +#define ISCRYSKNIFE (ISSHARP | ISPOISON | ISMANY | ISLITTLE) + +struct init_weps weaps[] = +{ + /* Missile weapons */ + {"sling", "0d0", "0d0", NONE, 5, 1, + ISLAUNCHER | ISLITTLE, }, + {"rock", "1d2", "1d4", SLING, 5, 1, + ISMANY | ISMISL | ISLITTLE }, + {"sling bullet", "1d1", "1d8", SLING, 3, 1, + ISSHARP | ISMANY | ISMISL | ISMETAL | ISLITTLE }, + {"short bow", "1d1", "1d1", NONE, 40, 75, + ISLAUNCHER }, + {"arrow", "1d1", "2d3", BOW, 5, 1, + ISSHARP | ISMANY | ISMISL | ISLITTLE }, + {"arrow", "1d2", "2d8", BOW, 10, 5, + ISSHARP | ISSILVER | ISMANY | ISMISL | ISLITTLE }, + {"fire arrow", "1d2", "2d8", BOW, 10, 3, + ISSHARP | CANBURN | ISMANY | ISMISL | ISLITTLE }, + {"footbow", "1d1", "1d1", NONE, 90, 125, + ISLAUNCHER }, + {"footbow bolt", "1d2", "1d10", FOOTBOW, 5, 1, + ISSHARP | ISMANY | ISMISL | ISLITTLE }, + {"crossbow", "1d1", "1d1", NONE, 100,175, + ISLAUNCHER }, + {"crossbow bolt", "1d2", "2d5", CROSSBOW, 7, 3, + ISSHARP | ISMANY | ISMISL | ISLITTLE }, + + /* Useful throwing weapons */ + {"dart", "1d1", "1d3", NONE, 5, 1, + ISSHARP | ISMANY | ISMISL | ISLITTLE }, + {"dagger", "1d6", "1d4", NONE, 10, 2, + ISSHARP | ISMETAL | ISMANY | ISMISL | ISLITTLE }, + {"hammer", "1d3", "1d5", NONE, 50, 3, + ISMETAL | ISMISL }, + {"leuku", "1d6", "1d5", NONE, 40, 4, + ISSHARP | ISMETAL | ISTWOH }, + {"javelin", "1d4", "1d6", NONE, 10, 5, + ISSHARP | ISMISL | ISTWOH }, + {"tomahawk", "1d6", "1d6", NONE, 45, 7, + ISSHARP | ISMISL }, + {"machete", "1d7", "1d6", NONE, 45, 4,