Mercurial > hg > early-roguelike
comparison xrogue/rogue.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 | 1fbdefa82533 |
comparison
equal
deleted
inserted
replaced
| 124:d10fc4a065ac | 133:e6179860cb76 |
|---|---|
| 1 /* | |
| 2 rogue.c - Global game variables | |
| 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 <ctype.h> | |
| 20 #include <curses.h> | |
| 21 #include "rogue.h" | |
| 22 | |
| 23 /* | |
| 24 * Now all the global variables | |
| 25 */ | |
| 26 | |
| 27 struct trap traps[MAXTRAPS]; | |
| 28 struct room rooms[MAXROOMS]; /* One for each room -- A level */ | |
| 29 struct room *oldrp; /* Roomin(&player.t_oldpos) */ | |
| 30 struct thing player; /* The rogue */ | |
| 31 struct object *cur_armor; /* What a well dresssed rogue wears */ | |
| 32 struct object *cur_ring[NUM_FINGERS]; /* Which rings are being worn */ | |
| 33 struct object *cur_misc[NUM_MM]; /* which MM's are in use */ | |
| 34 int cur_relic[MAXRELIC]; /* Currently used relics */ | |
| 35 struct linked_list *lvl_obj = NULL; | |
| 36 struct linked_list *mlist = NULL; | |
| 37 struct linked_list *rlist = NULL; /* list of dead monsters to be reaped */ | |
| 38 struct linked_list *tlist = NULL; /* list of monsters fallen down traps */ | |
| 39 struct linked_list *monst_dead = NULL; /* monster killed by monster */ | |
| 40 struct object *cur_weapon = NULL; | |
| 41 int char_type = -1; /* what type of character is player */ | |
| 42 int foodlev = 1; /* how fast he eats food */ | |
| 43 int ntraps; /* Number of traps on this level */ | |
| 44 int trader = 0; /* no. of purchases */ | |
| 45 int curprice = -1; /* current price of item */ | |
| 46 int seed; /* Random number seed */ | |
| 47 int max_level; /* Deepest player has gone ever */ | |
| 48 int cur_max; /* Deepest player has gone currently */ | |
| 49 int prev_max; /* A flag indicating worm hole */ | |
| 50 int move_free = 0; /* Movement check (io.c & actions.c) */ | |
| 51 int mpos = 0; | |
| 52 int level = 0; | |
| 53 long purse = 0; | |
| 54 int inpack = 0; | |
| 55 int total = 0; | |
| 56 int no_food = 0; /* how long has he gone with no food */ | |
| 57 int foods_this_level = 0; /* foods made per level */ | |
| 58 int count = 0; | |
| 59 int food_left = STOMACHSIZE-MORETIME-1; | |
| 60 int group = 1; | |
| 61 int hungry_state = F_OKAY; | |
| 62 int infest_dam=0; | |
| 63 int lost_str=0; | |
| 64 int lastscore = -1; | |
| 65 int hold_count = 0; | |
| 66 int trap_tries = 0; | |
| 67 int chant_time = 0; | |
| 68 int pray_time = 0; | |
| 69 int spell_power = 0; | |
| 70 long turns = 0; /* Number of turns player has taken */ | |
| 71 int quest_item = 0; /* Item player is looking for */ | |
| 72 int cols = 0; /* number of columns in terminal */ | |
| 73 int lines = 0; /* number of lines on the terminal */ | |
| 74 int nfloors = -1; /* Number of floors in this dungeon */ | |
| 75 char curpurch[LINELEN]; /* name of item ready to buy */ | |
| 76 char PLAYER = VPLAYER; /* what the player looks like */ | |
| 77 char take; /* Thing the rogue is taking */ | |
| 78 char prbuf[LINELEN*2]; /* Buffer for sprintfs */ | |
| 79 char runch; /* Direction player is running */ | |
| 80 char *s_names[MAXSCROLLS]; /* Names of the scrolls */ | |
| 81 char *p_colors[MAXPOTIONS]; /* Colors of the potions */ | |
| 82 char *r_stones[MAXRINGS]; /* Stone settings of the rings */ | |
| 83 char *ws_made[MAXSTICKS]; /* What sticks are made of */ | |
| 84 char whoami[LINELEN]; /* Name of player */ | |
| 85 char huh[LINELEN]; /* The last message printed */ | |
| 86 char *s_guess[MAXSCROLLS]; /* Players guess at what scroll is */ | |
| 87 char *p_guess[MAXPOTIONS]; /* Players guess at what potion is */ | |
| 88 char *r_guess[MAXRINGS]; /* Players guess at what ring is */ | |
| 89 char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */ | |
| 90 char *m_guess[MAXMM]; /* Players guess at what MM is */ | |
| 91 char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ | |
| 92 char file_name[LINELEN]; /* Save file name */ | |
| 93 char score_file[LINELEN]; /* Score file name */ | |
| 94 char home[LINELEN]; /* User's home directory */ | |
| 95 WINDOW *cw; /* Window that the player sees */ | |
| 96 WINDOW *hw; /* Used for the help command */ | |
| 97 WINDOW *mw; /* Used to store monsters */ | |
| 98 WINDOW *msgw; /* Used to display messages */ | |
| 99 bool pool_teleport = FALSE; /* just teleported from a pool */ | |
| 100 bool inwhgt = FALSE; /* true if from wghtchk() */ | |
| 101 bool after; /* True if we want after daemons */ | |
| 102 bool waswizard; /* Was a wizard sometime */ | |
| 103 bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */ | |
| 104 bool p_know[MAXPOTIONS]; /* Does he know what a potion does */ | |
| 105 bool r_know[MAXRINGS]; /* Does he know what a ring does */ | |
| 106 bool ws_know[MAXSTICKS]; /* Does he know what a stick does */ | |
| 107 bool m_know[MAXMM]; /* Does he know what a MM does */ | |
| 108 | |
| 109 /* options */ | |
| 110 bool playing = TRUE; /* Defaults */ | |
| 111 bool running = FALSE; | |
| 112 bool wizard = FALSE; | |
| 113 bool notify = TRUE; | |
| 114 bool fight_flush = FALSE; | |
| 115 bool terse = FALSE; | |
| 116 bool auto_pickup = FALSE; | |
| 117 bool def_attr = FALSE; /* default attributes */ | |
| 118 bool menu_overlay = TRUE; | |
| 119 bool door_stop = TRUE; | |
| 120 bool jump = TRUE; | |
| 121 bool slow_invent = FALSE; | |
| 122 bool firstmove = FALSE; | |
| 123 bool askme = TRUE; | |
| 124 bool in_shell = FALSE; | |
| 125 bool daytime = TRUE; | |
| 126 bool funfont = FALSE; | |
| 127 | |
| 128 LEVTYPE levtype; /* what type of level am i'm on? */ | |
| 129 | |
| 130 char *nothing = "Nothing seems to happen. "; | |
| 131 char *spacemsg = "--Press space to continue--"; | |
| 132 char *morestr = " --More--"; | |
| 133 char *retstr = "[Press return to continue]"; | |
| 134 | |
| 135 /* | |
| 136 * This lays out all the class specific details | |
| 137 * | |
| 138 * Here are the beginning experience levels for all players. | |
| 139 * All further experience levels are computed by muliplying by 2 | |
| 140 * up through MAXDOUBLE. Then exp pts are calculated by adding | |
| 141 * in the cap figure. You must change MAXDOUBLE if you change the | |
| 142 * cap figure. | |
| 143 */ | |
| 144 | |
| 145 struct character_types char_class[NUM_CHARTYPES] = { | |
| 146 /* name exppts cap hitpts Base Maxlvl, Factor, Offset, Range */ | |
| 147 { "fighter", 90, 1310720, 13, 10, 30, 2, 1, 3 }, | |
| 148 { "ranger", 110, 2293760, 10, 10, 22, 2, 1, 2 }, | |
| 149 { "paladin", 110, 1966080, 10, 10, 23, 2, 1, 2 }, | |
| 150 { "magician", 105, 2129920, 9, 10, 24, 2, 1, 2 }, | |
| 151 { "cleric", 105, 1802240, 9, 10, 24, 2, 1, 2 }, | |
| 152 { "thief", 95, 1228800, 11, 10, 28, 2, 1, 3 }, | |
| 153 { "assassin", 95, 1392640, 11, 10, 26, 2, 1, 3 }, | |
| 154 { "druid", 105, 1638400, 9, 10, 24, 2, 1, 2 }, | |
| 155 { "monk", 100, 1556480, 10, 10, 25, 2, 1, 2 }, | |
| 156 { "monster", 0, 0, 8, 10, 20, 1, 0, 2 }, | |
| 157 }; | |
| 158 | |
| 159 /* | |
| 160 * This array lists the names of the character's abilities. It must be ordered | |
| 161 * according to the ability definitions in rogue.h. | |
| 162 */ | |
| 163 | |
| 164 struct words abilities[NUMABILITIES] = { | |
| 165 "Intelligence", "Strength", "Wisdom", "Dexterity", "Constitution", "Charisma" | |
| 166 }; | |
| 167 | |
| 168 /* | |
| 169 * NOTE: the ordering of the points in this array is critical. They MUST | |
| 170 * be listed in the following sequence: | |
| 171 * | |
| 172 * 7 4 6 | |
| 173 * 1 0 2 | |
| 174 * 5 3 8 | |
| 175 */ | |
| 176 | |
| 177 coord grid[9] = {{0,0}, | |
| 178 { 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, | |
| 179 {-1,-1}, { 1, 1}, { 1,-1}, {-1, 1} | |
| 180 }; | |
| 181 | |
| 182 struct death_type deaths[DEATHNUM] = { | |
| 183 { D_ARROW, "an arrow"}, | |
| 184 { D_DART, "a dart"}, | |
| 185 { D_BOLT, "a bolt"}, | |
| 186 { D_POISON, "poison"}, | |
| 187 { D_POTION, "a cursed potion"}, | |
| 188 { D_PETRIFY, "petrification"}, | |
| 189 { D_SUFFOCATION, "suffocation"}, | |
| 190 { D_INFESTATION, "a parasite"}, | |
| 191 { D_DROWN, "drowning"}, | |
| 192 { D_ROT, "body rot"}, | |
| 193 { D_CONSTITUTION, "poor health"}, | |
| 194 { D_STRENGTH, "being too weak"}, | |
| 195 { D_SIGNAL, "a bug"}, | |
| 196 { D_CHOKE, "dust of choking"}, | |
| 197 { D_STRANGLE, "strangulation"}, | |
| 198 { D_FALL, "a fall"}, | |
| 199 { D_RELIC, "an artifact's wrath"}, | |
| 200 { D_STARVATION, "starvation"}, | |
| 201 { D_FOOD_CHOKE, "choking on food"}, | |
| 202 { D_SCROLL, "reading a scroll"}, | |
| 203 { D_FRIGHT, "being too frightened"}, | |
| 204 { D_CRYSTAL, "being absorbed"}, | |
| 205 { D_CARD, "the face of death"}, | |
| 206 }; | |
| 207 | |
| 208 /* | |
| 209 * weapons and their attributes | |
| 210 */ | |
| 211 | |
| 212 struct init_weps weaps[MAXWEAPONS] = { | |
| 213 { "mace", "2d10","2d10", NONE, ISMETAL, 6, 150, 15 }, | |
| 214 { "long sword", "3d4", "2d8", NONE, ISMETAL, 5, 200, 25 }, | |
| 215 { "short bow", "1d1", "1d1", NONE, 0, 8, 50, 4 }, | |
| 216 { "arrow", "2d4", "1d6", BOW, ISMANY|ISMISL, 1, 5, 4 }, | |
| 217 { "dagger", "2d8", "1d6", NONE, ISMETAL|ISMISL|ISMANY, 2,10,7}, | |
| 218 { "rock", "2d4", "1d6", SLING, ISMANY|ISMISL, 1, 20, 3 }, | |
| 219 { "two-handed sword","3d10","3d8", NONE, ISMETAL, 4, 250, 40 }, | |
| 220 { "sling", "1d1", "1d1", NONE, 0, 8, 25, 3 }, | |
| 221 { "dart", "2d4", "2d6", NONE, ISMANY|ISMISL, 2, 15, 7 }, | |
| 222 { "crossbow", "1d1", "1d1", NONE, 0, 8, 75, 5 }, | |
| 223 { "crossbow bolt", "2d4", "2d4", CROSSBOW, ISMANY|ISMISL, 1, 10, 5 }, | |
| 224 { "spear", "2d6", "3d10", NONE, ISMISL, 7, 100, 15 }, | |
| 225 { "trident", "3d6", "3d4", NONE, ISMETAL, 4, 200, 30 }, | |
| 226 { "spetum", "2d6", "2d8", NONE, ISMETAL, 6, 150, 20 }, | |
| 227 { "bardiche", "3d4", "2d10", NONE, ISMETAL, 5, 150, 25 }, | |
| 228 { "pike", "2d8", "2d8", NONE, ISMETAL, 7, 100, 15 }, | |
| 229 { "bastard sword", "3d8", "3d6", NONE, ISMETAL, 4, 175, 30 }, | |
| 230 { "halberd", "2d8", "2d4", NONE, ISMETAL, 6, 100, 10 }, | |
| 231 { "battle axe", "2d8", "3d8", NONE, ISMETAL, 5, 150, 15 }, | |
| 232 } ; | |
| 233 | |
| 234 struct init_armor armors[MAXARMORS] = { | |
| 235 { "leather armor", 10, 8, 200, 100 }, | |
| 236 { "ring mail", 20, 7, 250, 200 }, | |
| 237 { "studded leather armor", 30, 5, 320, 250 }, | |
| 238 { "scale mail", 40, 7, 280, 250 }, | |
| 239 { "padded armor", 50, 6, 350, 300 }, | |
| 240 { "chain mail", 60, 6, 350, 600 }, | |
| 241 { "splint mail", 70, 5, 370, 400 }, | |
| 242 { "banded mail", 80, 5, 370, 350 }, | |
| 243 { "plate mail", 90, 4, 400, 400 }, | |
| 244 { "plate armor", 100, 3, 500, 450 }, | |
| 245 }; | |
| 246 | |
| 247 struct magic_item things[NUMTHINGS] = { | |
| 248 { "potion", 220, 10 }, /* potion */ | |
| 249 { "scroll", 220, 30 }, /* scroll */ | |
| 250 { "food", 190, 20 }, /* food */ | |
| 251 { "weapon", 90, 0 }, /* weapon */ | |
| 252 { "armor", 90, 0 }, /* armor */ | |
| 253 { "ring", 70, 5 }, /* ring */ | |
| 254 { "stick", 70, 0 }, /* stick */ | |
| 255 { "miscellaneous magic", 50, 50 }, /* miscellaneous magic */ | |
| 256 { "artifact", 0, 10 }, /* artifact */ | |
| 257 }; | |
| 258 | |
| 259 struct magic_item s_magic[MAXSCROLLS] = { | |
| 260 { "monster confusion", 40, 125, 0, 0 }, | |
| 261 { "magic mapping", 60, 150, 0, 5 }, | |
| 262 { "light", 60, 100, 15, 15 }, | |
| 263 { "hold monster", 30, 200, 20, 20 }, | |
| 264 { "sleep", 20, 150, 25, 0 }, | |
| 265 { "enchantment", 130, 200, 15, 15 }, | |
| 266 { "identify", 170, 100, 0, 20 }, | |
| 267 { "scare monster", 40, 250, 20, 30 }, | |
| 268 { "gold detection", 30, 110, 0, 0 }, | |
| 269 { "teleportation", 60, 165, 20, 20 }, | |
| 270 { "create monster", 20, 75, 0, 0 }, | |
| 271 { "remove curse", 80, 120, 15, 15 }, | |
| 272 { "petrification", 30, 185, 0, 0 }, | |
| 273 { "genocide", 10, 300, 0, 0 }, | |
| 274 { "cure disease", 80, 160, 0, 0 }, | |
| 275 { "acquirement", 10, 700, 0, 5 }, | |
| 276 { "protection", 30, 190, 10, 0 }, | |
| 277 { "trap finding", 50, 180, 0, 0 }, | |
| 278 { "runes", 20, 50, 0, 0 }, | |
| 279 { "charm monster", 30, 275, 0, 20 }, | |
| 280 }; | |
| 281 | |
| 282 struct magic_item p_magic[MAXPOTIONS] = { | |
| 283 { "clear thought", 50, 180, 10, 5 }, | |
| 284 { "gain ability", 160, 210, 10, 10 }, | |
| 285 { "see invisible", 40, 150, 20, 20 }, | |
| 286 { "healing", 140, 130, 15, 15 }, | |
| 287 { "monster detection", 40, 120, 0, 0 }, | |
| 288 { "magic detection", 70, 105, 0, 0 }, | |
| 289 { "raise level", 10, 450, 10, 5 }, | |
| 290 { "haste self", 50, 180, 20, 5 }, | |
| 291 { "restore abilities", 130, 140, 0, 15 }, | |
| 292 { "phasing", 60, 210, 10, 10 }, | |
| 293 { "invisibility", 20, 230, 0, 10 }, | |
| 294 { "flying", 50, 130, 0, 15 }, | |
| 295 { "food detection", 20, 150, 0, 0 }, | |
| 296 { "skill", 10, 200, 20, 5 }, | |
| 297 { "fire resistance", 40, 250, 10, 5 }, | |
| 298 { "cold resistance", 40, 250, 10, 5 }, | |
| 299 { "lightning protection", 40, 250, 20, 5 }, | |
| 300 { "poison", 30, 205, 25, 0 }, | |
| 301 }; | |
| 302 | |
| 303 struct magic_item r_magic[MAXRINGS] = { | |
| 304 { "protection", 60, 200, 25, 25 }, | |
| 305 { "add strength", 50, 200, 25, 25 }, | |
| 306 { "sustain ability", 50, 500, 0, 0 }, | |
| 307 { "searching", 40, 400, 0, 0 }, | |
| 308 { "extra sight", 60, 350, 0, 0 }, | |
| 309 { "alertness", 40, 380, 0, 0 }, | |
| 310 { "aggravate monster", 30, 100, 100, 0 }, | |
| 311 { "dexterity", 50, 220, 25, 25 }, | |
| 312 { "increase damage", 60, 220, 25, 25 }, | |
| 313 { "regeneration", 40, 600, 0, 0 }, | |
| 314 { "slow digestion", 50, 240, 20, 20 }, | |
| 315 { "teleportation", 20, 100, 90, 0 }, | |
| 316 { "stealth", 20, 300, 0, 0 }, | |
| 317 { "add intelligence", 50, 240, 25, 25 }, | |
| 318 { "increase wisdom", 40, 220, 25, 25 }, | |
| 319 { "sustain health", 80, 500, 0, 0 }, | |
| 320 { "carrying", 10, 100, 90, 0 }, | |
| 321 { "illumination", 30, 520, 0, 0 }, | |
| 322 { "delusion", 10, 100, 100, 0 }, | |
| 323 { "fear", 20, 100, 75, 0 }, | |
| 324 { "heroism", 50, 390, 0, 0 }, | |
| 325 { "fire resistance", 40, 400, 0, 0 }, | |
