comparison arogue7/rogue.c @ 125:adfa37e67084

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