comparison xrogue/rogue.c @ 142:6b5fbd7c3ece

Merge arogue7 and xrogue trees.
author John "Elwin" Edwards
date Tue, 12 May 2015 21:39:39 -0400
parents 1fbdefa82533
children aac28331e71d
comparison
equal deleted inserted replaced
132:66b0263af424 142:6b5fbd7c3ece
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 use_savedir = FALSE; /* Use common save location? */
103 bool waswizard; /* Was a wizard sometime */
104 bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */
105 bool p_know[MAXPOTIONS]; /* Does he know what a potion does */
106 bool r_know[MAXRINGS]; /* Does he know what a ring does */
107 bool ws_know[MAXSTICKS]; /* Does he know what a stick does */
108 bool m_know[MAXMM]; /* Does he know what a MM does */
109
110 /* options */
111 bool playing = TRUE; /* Defaults */
112 bool running = FALSE;
113 bool wizard = FALSE;
114 bool notify = TRUE;
115 bool fight_flush = FALSE;
116 bool terse = FALSE;
117 bool auto_pickup = FALSE;
118 bool def_attr = FALSE; /* default attributes */
119 bool menu_overlay = TRUE;
120 bool door_stop = TRUE;
121 bool jump = TRUE;
122 bool slow_invent = FALSE;
123 bool firstmove = FALSE;
124 bool askme = TRUE;
125 bool in_shell = FALSE;
126 bool daytime = TRUE;
127 bool funfont = FALSE;
128
129 LEVTYPE levtype; /* what type of level am i'm on? */
130
131 char *nothing = "Nothing seems to happen. ";
132 char *spacemsg = "--Press space to continue--";
133 char *morestr = " --More--";
134 char *retstr = "[Press return to continue]";
135
136 /*
137 * This lays out all the class specific details
138 *
139 * Here are the beginning experience levels for all players.
140 * All further experience levels are computed by muliplying by 2
141 * up through MAXDOUBLE. Then exp pts are calculated by adding
142 * in the cap figure. You must change MAXDOUBLE if you change the
143 * cap figure.
144 */
145
146 struct character_types char_class[NUM_CHARTYPES] = {
147 /* name exppts cap hitpts Base Maxlvl, Factor, Offset, Range */
148 { "fighter", 90, 1310720, 13, 10, 30, 2, 1, 3 },
149 { "ranger", 110, 2293760, 10, 10, 22, 2, 1, 2 },
150 { "paladin", 110, 1966080, 10, 10, 23, 2, 1, 2 },
151 { "magician", 105, 2129920, 9, 10, 24, 2, 1, 2 },
152 { "cleric", 105, 1802240, 9, 10, 24, 2, 1, 2 },
153 { "thief", 95, 1228800, 11, 10, 28, 2, 1, 3 },
154 { "assassin", 95, 1392640, 11, 10, 26, 2, 1, 3 },
155 { "druid", 105, 1638400, 9, 10, 24, 2, 1, 2 },
156 { "monk", 100, 1556480, 10, 10, 25, 2, 1, 2 },
157 { "monster", 0, 0, 8, 10, 20, 1, 0, 2 },
158 };
159
160 /*
161 * This array lists the names of the character's abilities. It must be ordered
162 * according to the ability definitions in rogue.h.
163 */
164
165 struct words abilities[NUMABILITIES] = {
166 "Intelligence", "Strength", "Wisdom", "Dexterity", "Constitution", "Charisma"
167 };
168
169 /*
170 * NOTE: the ordering of the points in this array is critical. They MUST
171 * be listed in the following sequence:
172 *
173 * 7 4 6
174 * 1 0 2
175 * 5 3 8
176 */
177
178 coord grid[9] = {{0,0},
179 { 0,-1}, { 0, 1}, {-1, 0}, { 1, 0},
180 {-1,-1}, { 1, 1}, { 1,-1}, {-1, 1}
181 };
182
183 struct death_type deaths[DEATHNUM] = {
184 { D_ARROW, "an arrow"},
185 { D_DART, "a dart"},
186 { D_BOLT, "a bolt"},
187 { D_POISON, "poison"},
188 { D_POTION, "a cursed potion"},
189 { D_PETRIFY, "petrification"},
190 { D_SUFFOCATION, "suffocation"},
191 { D_INFESTATION, "a parasite"},
192 { D_DROWN, "drowning"},
193 { D_ROT, "body rot"},
194 { D_CONSTITUTION, "poor health"},
195 { D_STRENGTH, "being too weak"},
196 { D_SIGNAL, "a bug"},
197 { D_CHOKE, "dust of choking"},
198 { D_STRANGLE, "strangulation"},
199 { D_FALL, "a fall"},
200 { D_RELIC, "an artifact's wrath"},
201 { D_STARVATION, "starvation"},
202 { D_FOOD_CHOKE, "choking on food"},
203 { D_SCROLL, "reading a scroll"},
204 { D_FRIGHT, "being too frightened"},
205 { D_CRYSTAL, "being absorbed"},
206 { D_CARD, "the face of death"},
207 };
208
209 /*
210 * weapons and their attributes
211 */
212
213 struct init_weps weaps[MAXWEAPONS] = {
214 { "mace", "2d10","2d10", NONE, ISMETAL, 6, 150, 15 },
215 { "long sword", "3d4", "2d8", NONE, ISMETAL, 5, 200, 25 },
216 { "short bow", "1d1", "1d1", NONE, 0, 8, 50, 4 },
217 { "arrow", "2d4", "1d6", BOW, ISMANY|ISMISL, 1, 5, 4 },
218 { "dagger", "2d8", "1d6", NONE, ISMETAL|ISMISL|ISMANY, 2,10,7},
219 { "rock", "2d4", "1d6", SLING, ISMANY|ISMISL, 1, 20, 3 },
220 { "two-handed sword","3d10","3d8", NONE, ISMETAL, 4, 250, 40 },
221 { "sling", "1d1", "1d1", NONE, 0, 8, 25, 3 },
222 { "dart", "2d4", "2d6", NONE, ISMANY|ISMISL, 2, 15, 7 },
223 { "crossbow", "1d1", "1d1", NONE, 0, 8, 75, 5 },
224 { "crossbow bolt", "2d4", "2d4", CROSSBOW, ISMANY|ISMISL, 1, 10, 5 },
225 { "spear", "2d6", "3d10", NONE, ISMISL, 7, 100, 15 },
226 { "trident", "3d6", "3d4", NONE, ISMETAL, 4, 200, 30 },
227 { "spetum", "2d6", "2d8", NONE, ISMETAL, 6, 150, 20 },
228 { "bardiche", "3d4", "2d10", NONE, ISMETAL, 5, 150, 25 },
229 { "pike", "2d8", "2d8", NONE, ISMETAL, 7, 100, 15 },
230 { "bastard sword", "3d8", "3d6", NONE, ISMETAL, 4, 175, 30 },
231 { "halberd", "2d8", "2d4", NONE, ISMETAL, 6, 100, 10 },
232 { "battle axe", "2d8", "3d8", NONE, ISMETAL, 5, 150, 15 },
233 } ;
234
235 struct init_armor armors[MAXARMORS] = {
236 { "leather armor", 10, 8, 200, 100 },
237 { "ring mail", 20, 7, 250, 200 },
238 { "studded leather armor", 30, 5, 320, 250 },
239 { "scale mail", 40, 7, 280, 250 },
240 { "padded armor", 50, 6, 350, 300 },
241 { "chain mail", 60, 6, 350, 600 },
242 { "splint mail", 70, 5, 370, 400 },
243 { "banded mail", 80, 5, 370, 350 },
244 { "plate mail", 90, 4, 400, 400 },
245 { "plate armor", 100, 3, 500, 450 },
246 };
247
248 struct magic_item things[NUMTHINGS] = {
249 { "potion", 220, 10 }, /* potion */
250 { "scroll", 220, 30 }, /* scroll */
251 { "food", 190, 20 }, /* food */
252 { "weapon", 90, 0 }, /* weapon */
253 { "armor", 90, 0 }, /* armor */
254 { "ring", 70, 5 }, /* ring */
255 { "stick", 70, 0 }, /* stick */
256 { "miscellaneous magic", 50, 50 }, /* miscellaneous magic */
257 { "artifact", 0, 10 }, /* artifact */
258 };
259
260 struct magic_item s_magic[MAXSCROLLS] = {
261 { "monster confusion", 40, 125, 0, 0 },
262 { "magic mapping", 60, 150, 0, 5 },
263 { "light", 60, 100, 15, 15 },
264 { "hold monster", 30, 200, 20, 20 },
265 { "sleep", 20, 150, 25, 0 },
266 { "enchantment", 130, 200, 15, 15 },
267 { "identify", 170, 100, 0, 20 },
268 { "scare monster", 40, 250, 20, 30 },
269 { "gold detection", 30, 110, 0, 0 },
270 { "teleportation", 60, 165, 20, 20 },
271 { "create monster", 20, 75, 0, 0 },
272 { "remove curse", 80, 120, 15, 15 },
273 { "petrification", 30, 185, 0, 0 },
274 { "genocide", 10, 300, 0, 0 },
275 { "cure disease", 80, 160, 0, 0 },
276 { "acquirement", 10, 700, 0, 5 },
277 { "protection", 30, 190, 10, 0 },
278 { "trap finding", 50, 180, 0, 0 },
279 { "runes", 20, 50, 0, 0 },
280 { "charm monster", 30, 275, 0, 20 },
281 };
282
283 struct magic_item p_magic[MAXPOTIONS] = {
284 { "clear thought", 50, 180, 10, 5 },
285 { "gain ability", 160, 210, 10, 10 },
286 { "see invisible", 40, 150, 20, 20 },
287 { "healing", 140, 130, 15, 15 },
288 { "monster detection", 40, 120, 0, 0 },
289 { "magic detection", 70, 105, 0, 0 },
290 { "raise level", 10, 450, 10, 5 },
291 { "haste self", 50, 180, 20, 5 },
292 { "restore abilities", 130, 140, 0, 15 },
293 { "phasing", 60, 210, 10, 10 },
294 { "invisibility", 20, 230, 0, 10 },
295 { "flying", 50, 130, 0, 15 },
296 { "food detection", 20, 150, 0, 0 },
297 { "skill", 10, 200, 20, 5 },
298 { "fire resistance", 40, 250, 10, 5 },
299 { "cold resistance", 40, 250, 10, 5 },
300 { "lightning protection", 40, 250, 20, 5 },
301 { "poison", 30, 205, 25, 0 },
302 };
303
304 struct magic_item r_magic[MAXRINGS] = {
305 { "protection", 60, 200, 25, 25 },
306 { "add strength", 50, 200, 25, 25 },
307 { "sustain ability", 50, 500, 0, 0 },
308 { "searching", 40, 400, 0, 0 },
309 { "extra sight", 60, 350, 0, 0 },
310 { "alertness", 40, 380, 0, 0 },
311 { "aggravate monster", 30, 100, 100, 0 },
312 { "dexterity", 50, 220, 25, 25 },
313 { "increase damage", 60, 220, 25, 25 },
314 { "regeneration", 40, 600, 0, 0 },
315 { "slow digestion", 50, 240, 20, 20 },
316 { "teleportation", 20, 100, 90, 0 },
317 { "stealth", 20, 300, 0, 0 },
318 { "add intelligence", 50, 240, 25, 25 },
319 { "increase wisdom", 40, 220, 25, 25 },
320 { "sustain health", 80, 500, 0, 0 },
321 { "carrying", 10, 100, 90, 0 },
322 { "illumination", 30, 520, 0, 0 },
323 { "delusion", 10, 100, 100, 0 },
324 { "fear", 20, 100, 75, 0 },
325 { "heroism", 50, 390, 0, 0 },