Mercurial > hg > early-roguelike
comparison arogue5/rogue.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 | a98834ce7e04 |
comparison
equal
deleted
inserted
replaced
| 62:0ef99244acb8 | 63:0ed67132cf10 |
|---|---|
| 1 /* | |
| 2 * global variable declaration | |
| 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 <ctype.h> | |
| 16 #include "curses.h" | |
| 17 #include "rogue.h" | |
| 18 | |
| 19 /* | |
| 20 * Now all the global variables | |
| 21 */ | |
| 22 struct trap traps[MAXTRAPS]; | |
| 23 struct room rooms[MAXROOMS]; /* One for each room -- A level */ | |
| 24 struct room *oldrp; /* Roomin(&player.t_oldpos) */ | |
| 25 struct thing player; /* The rogue */ | |
| 26 struct object *cur_armor; /* What a well dresssed rogue wears */ | |
| 27 struct object *cur_ring[NUM_FINGERS]; /* Which rings are being worn */ | |
| 28 struct object *cur_misc[NUM_MM]; /* which MM's are in use */ | |
| 29 int cur_relic[MAXRELIC]; /* Currently used relics */ | |
| 30 struct linked_list *lvl_obj = NULL; | |
| 31 struct linked_list *mlist = NULL; | |
| 32 struct linked_list *tlist = NULL; /* list of monsters fallen down traps */ | |
| 33 struct linked_list *monst_dead = NULL; /* monster killed by monster */ | |
| 34 struct object *cur_weapon = NULL; | |
| 35 int char_type = -1; /* what type of character is player */ | |
| 36 int foodlev = 1; /* how fast he eats food */ | |
| 37 int ntraps; /* Number of traps on this level */ | |
| 38 int trader = 0; /* no. of purchases */ | |
| 39 int curprice = -1; /* current price of item */ | |
| 40 int no_move; /* Number of turns held in place */ | |
| 41 int seed; /* Random number seed */ | |
| 42 int dnum; /* Dungeon number */ | |
| 43 int max_level; /* Deepest player has gone ever */ | |
| 44 int cur_max; /* Deepest player has gone currently */ | |
| 45 int lost_dext; /* amount of lost dexterity */ | |
| 46 int mpos = 0; | |
| 47 int no_command = 0; | |
| 48 int level = 1; | |
| 49 int purse = 0; | |
| 50 int inpack = 0; | |
| 51 int total = 0; | |
| 52 int no_food = 0; /* how long has he gone with no food */ | |
| 53 int foods_this_level = 0; /* foods made per level */ | |
| 54 int count = 0; | |
| 55 int food_left = HUNGERTIME; | |
| 56 int group = 1; | |
| 57 int hungry_state = F_OKAY; | |
| 58 int infest_dam=0; | |
| 59 int lost_str=0; | |
| 60 int lastscore = -1; | |
| 61 int hold_count = 0; | |
| 62 int trap_tries = 0; | |
| 63 int pray_time = 0; | |
| 64 int spell_power = 0; | |
| 65 int turns = 0; /* Number of turns player has taken */ | |
| 66 int quest_item = 0; /* Item player is looking for */ | |
| 67 char nfloors = -1; /* Number of floors in this dungeon */ | |
| 68 char curpurch[15]; /* name of item ready to buy */ | |
| 69 char PLAYER = VPLAYER; /* what the player looks like */ | |
| 70 char take; /* Thing the rogue is taking */ | |
| 71 char prbuf[LINELEN*2]; /* Buffer for sprintfs */ | |
| 72 char outbuf[BUFSIZ]; /* Output buffer for stdout */ | |
| 73 char runch; /* Direction player is running */ | |
| 74 char *s_names[MAXSCROLLS]; /* Names of the scrolls */ | |
| 75 char *p_colors[MAXPOTIONS]; /* Colors of the potions */ | |
| 76 char *r_stones[MAXRINGS]; /* Stone settings of the rings */ | |
| 77 char *ws_made[MAXSTICKS]; /* What sticks are made of */ | |
| 78 char whoami[LINELEN]; /* Name of player */ | |
| 79 char fruit[LINELEN]; /* Favorite fruit */ | |
| 80 char huh[LINELEN]; /* The last message printed */ | |
| 81 char *s_guess[MAXSCROLLS]; /* Players guess at what scroll is */ | |
| 82 char *p_guess[MAXPOTIONS]; /* Players guess at what potion is */ | |
| 83 char *r_guess[MAXRINGS]; /* Players guess at what ring is */ | |
| 84 char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */ | |
| 85 char *m_guess[MAXMM]; /* Players guess at what MM is */ | |
| 86 char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ | |
| 87 char file_name[LINELEN]; /* Save file name */ | |
| 88 char score_file[LINELEN]; /* Score file name */ | |
| 89 char home[LINELEN]; /* User's home directory */ | |
| 90 WINDOW *cw; /* Window that the player sees */ | |
| 91 WINDOW *hw; /* Used for the help command */ | |
| 92 WINDOW *mw; /* Used to store mosnters */ | |
| 93 WINDOW *msgw; /* Used to display messages */ | |
| 94 bool pool_teleport = FALSE; /* just teleported from a pool */ | |
| 95 bool inwhgt = FALSE; /* true if from wghtchk() */ | |
| 96 bool after; /* True if we want after daemons */ | |
| 97 bool waswizard; /* Was a wizard sometime */ | |
| 98 bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */ | |
| 99 bool p_know[MAXPOTIONS]; /* Does he know what a potion does */ | |
| 100 bool r_know[MAXRINGS]; /* Does he know what a ring does */ | |
| 101 bool ws_know[MAXSTICKS]; /* Does he know what a stick does */ | |
| 102 bool m_know[MAXMM]; /* Does he know what a MM does */ | |
| 103 bool playing = TRUE; | |
| 104 bool running = FALSE; | |
| 105 bool wizard = FALSE; | |
| 106 bool notify = TRUE; | |
| 107 bool fight_flush = FALSE; | |
| 108 bool terse = FALSE; | |
| 109 bool auto_pickup = TRUE; | |
| 110 bool door_stop = FALSE; | |
| 111 bool jump = FALSE; | |
| 112 bool slow_invent = FALSE; | |
| 113 bool firstmove = FALSE; | |
| 114 bool askme = FALSE; | |
| 115 bool in_shell = FALSE; | |
| 116 bool daytime = TRUE; | |
| 117 coord delta; /* Change indicated to get_dir() */ | |
| 118 LEVTYPE levtype; /* type of level i'm on */ | |
| 119 | |
| 120 char *nothing = "Nothing seems to happen."; | |
| 121 char *spacemsg = "--Press space to continue--"; | |
| 122 char *morestr = "-- More --"; | |
| 123 char *retstr = "[Press return to continue]"; | |
| 124 | |
| 125 | |
| 126 /* | |
| 127 * NOTE: the ordering of the points in this array is critical. They MUST | |
| 128 * be listed in the following sequence: | |
| 129 * | |
| 130 * 7 4 6 | |
| 131 * 1 0 2 | |
| 132 * 5 3 8 | |
| 133 */ | |
| 134 | |
| 135 coord grid[9] = {{0,0}, | |
| 136 { 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, | |
| 137 {-1,-1}, { 1, 1}, { 1,-1}, {-1, 1} | |
| 138 }; | |
| 139 | |
| 140 struct death_type deaths[DEATHNUM] = { | |
| 141 { D_ARROW, "an arrow"}, | |
| 142 { D_DART, "a dart"}, | |
| 143 { D_BOLT, "a bolt"}, | |
| 144 { D_POISON, "poison"}, | |
| 145 { D_POTION, "a cursed potion"}, | |
| 146 { D_PETRIFY, "petrification"}, | |
| 147 { D_SUFFOCATION, "suffocation"}, | |
| 148 { D_INFESTATION, "a parasite"}, | |
| 149 { D_DROWN, "drowning"}, | |
| 150 { D_ROT, "body rot"}, | |
| 151 { D_CONSTITUTION, "poor health"}, | |
| 152 { D_STRENGTH, "being too weak"}, | |
| 153 { D_SIGNAL, "a bug"}, | |
| 154 { D_CHOKE, "dust of choking"}, | |
| 155 { D_STRANGLE, "strangulation"}, | |
| 156 { D_FALL, "a fall"}, | |
| 157 { D_RELIC, "an artifact's wrath"}, | |
| 158 }; | |
| 159 | |
| 160 | |
| 161 /* | |
| 162 * weapons and their attributes | |
| 163 */ | |
| 164 struct init_weps weaps[MAXWEAPONS] = { | |
| 165 { "mace", "2d4", "1d3", NONE, ISMETAL, 100, 8 }, | |
| 166 { "long sword", "1d12", "1d2", NONE, ISMETAL, 60, 18 }, | |
| 167 { "short bow", "1d1", "1d1", NONE, 0, 40, 15 }, | |
| 168 { "arrow", "1d1", "1d6", BOW, ISMANY|ISMISL, 5, 1 }, | |
| 169 { "dagger", "1d6", "1d4", NONE, ISMETAL|ISMISL|ISMANY, 10, 2 }, | |
| 170 { "rock", "1d2", "1d4", SLING, ISMANY|ISMISL, 5, 1 }, | |
| 171 { "two-handed sword","3d6", "1d2", NONE, ISMETAL, 250, 40 }, | |
| 172 { "sling", "0d0", "0d0", NONE, 0, 5, 1 }, | |
| 173 { "dart", "1d1", "1d3", NONE, ISMANY|ISMISL, 5, 1 }, | |
| 174 { "crossbow", "1d1", "1d1", NONE, 0, 100, 15 }, | |
| 175 { "crossbow bolt", "1d2", "1d12", CROSSBOW, ISMANY|ISMISL, 7, 1 }, | |
| 176 { "spear", "1d6", "1d8", NONE, ISMETAL|ISMISL, 50, 8 }, | |
| 177 { "trident", "3d4", "1d4", NONE, ISMETAL, 50, 20 }, | |
| 178 { "spetum", "2d6", "1d3", NONE, ISMETAL, 50, 20 }, | |
| 179 { "bardiche", "3d4", "1d2", NONE, ISMETAL, 125, 20 }, | |
| 180 { "pike", "1d12", "1d8", NONE, ISMETAL, 80, 18 }, | |
| 181 { "bastard sword", "2d8", "1d2", NONE, ISMETAL, 100, 30 }, | |
| 182 { "halberd", "2d6", "1d3", NONE, ISMETAL, 175, 10 }, | |
| 183 { "battle axe", "1d8", "1d3", NONE, ISMETAL, 80, 10 }, | |
| 184 }; | |
| 185 | |
| 186 struct init_armor armors[MAXARMORS] = { | |
| 187 { "leather armor", 11, 8, 70, 100 }, | |
| 188 { "ring mail", 22, 7, 50, 250 }, | |
| 189 { "studded leather armor", 33, 7, 50, 200 }, | |
| 190 { "scale mail", 45, 6, 70, 250 }, | |
| 191 { "padded armor", 57, 6, 150, 150 }, | |
| 192 { "chain mail", 69, 5, 100, 300 }, | |
| 193 { "splint mail", 80, 4, 150, 350 }, | |
| 194 { "banded mail", 90, 4, 150, 350 }, | |
| 195 { "plate mail", 96, 3, 400, 400 }, | |
| 196 { "plate armor", 100, 2, 650, 450 }, | |
| 197 }; | |
| 198 | |
| 199 struct magic_item things[NUMTHINGS] = { | |
| 200 { "potion", 260, 10 }, /* potion */ | |
| 201 { "scroll", 260, 30 }, /* scroll */ | |
| 202 { "food", 180, 20 }, /* food */ | |
| 203 { "weapon", 80, 0 }, /* weapon */ | |
| 204 { "armor", 80, 0 }, /* armor */ | |
| 205 { "ring", 50, 5 }, /* ring */ | |
| 206 { "stick", 60, 0 }, /* stick */ | |
| 207 { "miscellaneous magic", 30, 50 }, /* miscellaneous magic */ | |
| 208 { "artifact", 0, 10 }, /* artifact */ | |
| 209 }; | |
| 210 | |
| 211 struct magic_item s_magic[MAXSCROLLS] = { | |
| 212 { "monster confusion", 60, 125, 0, 0 }, | |
| 213 { "magic mapping", 50, 150, 0, 0 }, | |
| 214 { "light", 80, 100, 21, 15 }, | |
| 215 { "hold monster", 30, 200, 33, 20 }, | |
| 216 { "sleep", 30, 150, 20, 0 }, | |
| 217 { "enchantment", 180, 200, 9, 9 }, | |
| 218 { "identify", 200, 100, 0, 25 }, | |
| 219 { "scare monster", 40, 250, 27, 21 }, | |
| 220 { "gold detection", 30, 110, 0, 0 }, | |
| 221 { "teleportation", 60, 165, 10, 20 }, | |
| 222 { "create monster", 30, 75, 0, 0 }, | |
| 223 { "remove curse", 70, 120, 9, 15 }, | |
| 224 { "petrification", 10, 185, 0, 0 }, | |
| 225 { "genocide", 10, 300, 0, 0 }, | |
| 226 { "cure disease", 80, 160, 0, 0 }, | |
| 227 { "acquirement", 10, 400, 0, 0 }, | |
| 228 { "protection", 30, 190, 20, 0 }, | |
| 229 }; | |
| 230 | |
| 231 struct magic_item p_magic[MAXPOTIONS] = { | |
| 232 { "clear thought", 60, 180, 27, 10 }, | |
| 233 { "gain ability", 160, 210, 15, 15 }, | |
| 234 { "see invisible", 60, 150, 25, 15 }, | |
| 235 { "healing", 170, 130, 27, 27 }, | |
| 236 { "monster detection", 60, 120, 0, 0 }, | |
| 237 { "magic detection", 60, 105, 0, 0 }, | |
| 238 { "raise level", 20, 350, 11, 10 }, | |
| 239 { "haste self", 100, 180, 30, 5 }, | |
| 240 { "restore abilities", 160, 140, 0, 0 }, | |
| 241 { "phasing", 50, 210, 21, 20 }, | |
| 242 { "invisibility", 50, 230, 0, 15 }, | |
| 243 { "flying", 50, 130, 0, 20 }, | |
| 244 }; | |
| 245 | |
| 246 struct magic_item r_magic[MAXRINGS] = { | |
| 247 { "protection", 50, 200, 33, 25 }, | |
| 248 { "add strength", 60, 200, 33, 25 }, | |
| 249 { "sustain ability", 50, 500, 0, 0 }, | |
| 250 { "searching", 60, 400, 0, 0 }, | |
| 251 { "extra sight", 40, 350, 0, 0 }, | |
| 252 { "alertness", 40, 380, 0, 0 }, | |
| 253 { "aggravate monster", 30, 100, 100, 0 }, | |
| 254 { "dexterity", 60, 220, 33, 25 }, | |
| 255 { "increase damage", 60, 220, 33, 25 }, | |
| 256 { "regeneration", 40, 600, 0, 0 }, | |
| 257 { "slow digestion", 40, 240, 15, 15 }, | |
| 258 { "teleportation", 20, 100, 100, 0 }, | |
| 259 { "stealth", 40, 300, 0, 0 }, | |
| 260 { "add intelligence", 60, 240, 33, 25 }, | |
| 261 { "increase wisdom", 60, 220, 33, 25 }, | |
| 262 { "sustain health", 80, 500, 0, 0 }, | |
| 263 { "burden", 20, 100, 100, 0 }, | |
| 264 { "illumination", 30, 520, 0, 0 }, | |
| 265 { "delusion", 20, 100, 75, 0 }, | |
| 266 { "fear", 20, 100, 100, 0}, | |
| 267 { "heroism", 30, 390, 0, 0 }, | |
| 268 { "fire resistance", 40, 400, 0, 0 }, | |
| 269 { "warmth", 40, 400, 0, 0 }, | |
| 270 { "vampiric regeneration", 10,1000, 0, 0}, | |
| 271 }; | |
| 272 | |
| 273 struct magic_item ws_magic[MAXSTICKS] = { | |
| 274 { "light", 90, 120, 20, 20 }, | |
| 275 { "striking", 60, 115, 0, 0 }, | |
| 276 { "lightning", 35, 200, 0, 0 }, | |
| 277 { "fire", 35, 200, 0, 0 }, | |
| 278 { "cold", 35, 200, 0, 0 }, | |
| 279 { "polymorph", 80, 150, 0, 0 }, | |
| 280 { "magic missile", 80, 170, 0, 0 }, | |
| 281 { "slow monster", 80, 220, 25, 20 }, | |
| 282 { "drain life", 90, 210, 20, 0 }, | |
| 283 { "charging", 80, 400, 0, 0 }, | |
| 284 { "teleport monster", 90, 140, 25, 20 }, | |
| 285 { "cancellation", 40, 130, 0, 0 }, | |
| 286 { "confuse monster", 35, 100, 15, 0}, | |
| 287 { "disintegration", 10, 300, 33, 0}, | |
| 288 { "petrification", 10, 300, 0, 0}, | |
| 289 { "paralyze monster", 30, 180, 15, 0}, | |
| 290 { "degenerate monster", 30, 250, 30, 0}, | |
| 291 { "curing", 10, 250, 25, 0}, | |
| 292 { "wonder", 50, 110, 0, 0}, | |
| 293 { "fear", 30, 180, 0, 0}, | |
| 294 }; | |
| 295 | |
| 296 /* | |
| 297 * WARNING: unique miscellaneous magic items must be put at the end | |
| 298 * of this list. They MUST be the last items. The function | |
| 299 * create_obj() in wizard.c depends on it. | |
| 300 */ | |
| 301 struct magic_item m_magic[MAXMM] = { | |
| 302 { "alchemy jug", 40, 240, 0, 0}, | |
| 303 { "beaker of potions", 60, 300, 0, 0}, | |
| 304 { "book of spells", 60, 300, 0, 0}, | |
| 305 { "boots of elvenkind", 50, 500, 0, 0}, | |
| 306 { "bracers of defense", 140, 100, 15, 0}, | |
| 307 { "chime of opening", 50, 250, 0, 0}, | |
| 308 { "chime of hunger", 50, 100,100, 0}, | |
| 309 { "cloak of displacement", 60, 500, 0, 0}, | |
| 310 { "cloak of protection", 70, 200, 15, 0}, | |
| 311 { "drums of panic", 40, 350, 0, 0}, | |
| 312 { "dust of disappearance", 40, 300, 0, 0}, | |
| 313 { "dust of choking", 30, 100,100, 0}, | |
| 314 { "gauntlets of dexterity", 30, 600, 25, 0}, | |
| 315 { "gauntlets of ogre power", 30, 600, 25, 0}, | |
| 316 { "jewel of attacks", 40, 150,100, 0}, | |
| 317 { "keoghtoms ointment", 50, 200, 0, 0}, | |
| 318 { "robe of powerlessness", 30, 100,100, 0}, | |
| 319 { "gauntlets of fumbling", 30, 100,100, 0}, | |
| 320 { "necklace of adaptation", 20, 500, 0, 0}, | |
| 321 { "necklace of strangulation",30, 110,100, 0}, | |
| 322 { "boots of dancing", 30, 120,100, 0}, | |
| 323 { "book of skills", 20, 650, 0, 0}, | |
| 324 }; | |
| 325 | |
| 326 | |
| 327 struct magic_item rel_magic[MAXRELIC] = { | |
| 328 { "Daggers of Musty Doit", 0, 50000, 0, 0}, | |
| 329 { "Cloak of Emori", 0, 50000, 0, 0}, | |
| 330 { "Ankh of Heil", 0, 50000, 0, 0}, | |
| 331 { "Staff of Ming", 0, 50000, 0, 0}, | |
| 332 { "Wand of Orcus", 0, 50000, 0, 0}, | |
| 333 { "Rod of Asmodeus", 0, 50000, 0, 0}, | |
| 334 { "Amulet of Yendor", 0, 50000, 0, 0}, | |
| 335 { "Mandolin of Brian", 0, 50000, 0, 0}, | |
| 336 { "Horn of Geryon", 0, 50000, 0, 0}, | |
| 337 { "Morning Star of Hruggek", 0, 50000, 0, 0}, | |
| 338 { "Flail of Yeenoghu", 0, 50000, 0, 0}, | |
