Mercurial > hg > early-roguelike
comparison srogue/global.c @ 36:2128c7dc8a40
Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
author | elwin |
---|---|
date | Thu, 25 Nov 2010 12:21:41 +0000 |
parents | |
children | 34d7a614855e |
comparison
equal
deleted
inserted
replaced
35:05018c63a721 | 36:2128c7dc8a40 |
---|---|
1 /* | |
2 * global variable declaration | |
3 * | |
4 * @(#)global.c 9.0 (rdk) 7/17/84 | |
5 * | |
6 * Super-Rogue | |
7 * Copyright (C) 1984 Robert D. Kindelberger | |
8 * All rights reserved. | |
9 * | |
10 * Based on "Rogue: Exploring the Dungeons of Doom" | |
11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
12 * All rights reserved. | |
13 * | |
14 * See the file LICENSE.TXT for full copyright and licensing information. | |
15 */ | |
16 | |
17 #include "rogue.h" | |
18 | |
19 struct room rooms[MAXROOMS]; /* One for each room -- A level */ | |
20 struct room *oldrp; /* Roomin(&oldpos) */ | |
21 struct linked_list *mlist = NULL; /* monsters on this level */ | |
22 struct thing player; /* The rogue */ | |
23 struct stats max_stats; /* The maximum for the player */ | |
24 struct linked_list *lvl_obj = NULL; /* objects on this level */ | |
25 struct object *cur_weapon = NULL; /* Which weapon he is weilding */ | |
26 struct object *cur_armor = NULL; /* the rogue's armor */ | |
27 struct object *cur_ring[2]; /* Which rings are being worn */ | |
28 struct stats *him; /* pointer to hero stats */ | |
29 struct trap traps[MAXTRAPS]; /* traps on this level */ | |
30 | |
31 int playuid; /* uid of current player */ | |
32 int playgid; /* gid of current player */ | |
33 int level = 1; /* What level rogue is on */ | |
34 int levcount = 0; /* # of active mons this level */ | |
35 int levtype = NORMLEV; /* type of level this is, maze, etc. */ | |
36 int trader = 0; /* no. of purchases */ | |
37 int curprice = -1; /* current price of item */ | |
38 int purse = 0; /* How much gold the rogue has */ | |
39 int mpos = 0; /* Where cursor is on top line */ | |
40 int ntraps; /* # of traps on this level */ | |
41 int packvol = 0; /* volume of things in pack */ | |
42 int total = 0; /* Total dynamic memory bytes */ | |
43 int demoncnt = 0; /* number of active daemons */ | |
44 int lastscore = -1; /* Score before this turn */ | |
45 int no_food = 0; /* # of levels without food */ | |
46 int seed; /* Random number seed */ | |
47 int dnum; /* Dungeon number */ | |
48 int count = 0; /* # of times to repeat cmd */ | |
49 int fung_hit = 0; /* # of time fungi has hit */ | |
50 int quiet = 0; /* # of quiet turns */ | |
51 int max_level = 1; /* Deepest player has gone */ | |
52 int food_left = HUNGERTIME; /* Amount of food stomach */ | |
53 int group = NEWGROUP; /* Current group number */ | |
54 int hungry_state = F_OKAY; /* How hungry is he */ | |
55 int foodlev = 1; /* how fast he eats food */ | |
56 int ringfood = 0; /* rings affect on food consumption */ | |
57 char take; /* Thing the rogue is taking */ | |
58 char runch; /* Direction player is running */ | |
59 char curpurch[15]; /* name of item ready to buy */ | |
60 | |
61 char prbuf[LINLEN]; /* Buffer for sprintfs */ | |
62 char whoami[LINLEN]; /* Name of player */ | |
63 char fruit[LINLEN]; /* Favorite fruit */ | |
64 char huh[LINLEN]; /* The last message printed */ | |
65 char file_name[LINLEN]; /* Save file name */ | |
66 char scorefile[LINLEN]; /* place for scorefile */ | |
67 char home[LINLEN]; /* User's home directory */ | |
68 char outbuf[BUFSIZ]; /* Output buffer for stdout */ | |
69 | |
70 char *s_guess[MAXSCROLLS]; /* his guess at what scroll is */ | |
71 char *p_guess[MAXPOTIONS]; /* his guess at what potion is */ | |
72 char *r_guess[MAXRINGS]; /* his guess at what ring is */ | |
73 char *ws_guess[MAXSTICKS]; /* his guess at what wand is */ | |
74 | |
75 bool isfight = FALSE; /* true if player is fighting */ | |
76 bool nlmove = FALSE; /* true when transported to new level */ | |
77 bool inpool = FALSE; /* true if hero standing in pool */ | |
78 bool inwhgt = FALSE; /* true if from wghtchk() */ | |
79 bool running = FALSE; /* True if player is running */ | |
80 bool playing = TRUE; /* True until he quits */ | |
81 bool wizard = FALSE; /* True if he is a wizard */ | |
82 bool after = TRUE; /* True if we want after daemons */ | |
83 bool door_stop = FALSE; /* Stop run when we pass a door */ | |
84 bool firstmove = FALSE; /* First move after door_stop */ | |
85 bool waswizard = FALSE; /* Was a wizard sometime */ | |
86 bool amulet = FALSE; /* He found the amulet */ | |
87 bool in_shell = FALSE; /* True if executing a shell */ | |
88 bool nochange = FALSE; /* true if last stat same as now */ | |
89 | |
90 bool s_know[MAXSCROLLS]; /* Does he know about a scroll */ | |
91 bool p_know[MAXPOTIONS]; /* Does he know about a potion */ | |
92 bool r_know[MAXRINGS]; /* Does he know about a ring */ | |
93 bool ws_know[MAXSTICKS]; /* Does he know about a stick */ | |
94 | |
95 char spacemsg[] = { "-- Press space to continue --" }; | |
96 char morestr[] = { "-- More --" }; | |
97 char retstr[] = { "[Press return to continue]" }; | |
98 char wizstr[] = { "Wizards Password: " }; | |
99 char illegal[] = { "Illegal command '%s'." }; | |
100 char callit[] = { "Call it: " }; | |
101 char starlist[] = { " (* for a list)" }; | |
102 | |
103 struct coord oldpos; /* Pos before last look() call */ | |
104 struct coord delta; /* Change indicated to get_dir() */ | |
105 struct coord stairs; /* where the stairs are put */ | |
106 struct coord rndspot = { -1, -1 }; /* for random teleporting */ | |
107 | |
108 struct monster *mtlev[MONRANGE]; | |
109 | |
110 #define _r {10,10,10,10} /* real ability (unused) */ | |
111 #define _p 0,0,0,0 /* hit points, pack, carry (unused) */ | |
112 #define _c 10 /* constitution (unused) */ | |
113 | |
114 /* | |
115 * NAME SHOW CARRY {LEVEL} FLAGS _r {STR DEX WIS _c} EXP LVL ARM _p DMG | |
116 */ | |
117 struct monster monsters[MAXMONS + 1] = { | |
118 {"giant ant",'A',0,{3,12,1},ISMEAN,{_r,{10,16,5,_c},10,2,3,_p,"1d6"}}, | |
119 {"bat",'B',0,{1,6,1},ISHUH,{_r,{10,10,10,_c},1,1,3,_p,"1d2"}}, | |
120 {"centaur",'C',15,{8,17,1},0,{_r,{16,10,15,_c},15,4,4,_p,"1d6/1d6"}}, | |
121 {"red dragon",'D',100,{21,500,0},ISGREED,{_r,{17,10,17,_c},9000,11,-1,_p,"1d8/1d8/3d10"}}, | |
122 {"floating eye",'E',0,{2,11,0},0,{_r,{10,10,10,_c},5,1,9,_p,"0d0"}}, | |
123 {"violet fungi",'F',0,{15,24,0},ISMEAN|ISSTUCK,{_r,{10,5,3,_c},85,8,2,_p,"000d0"}}, | |
124 {"gnome",'G',10,{6,15,1},0,{_r,{10,10,11,_c},8,1,5,_p,"1d6"}}, | |
125 {"hobgoblin",'H',0,{1,8,1},ISMEAN,{_r,{10,10,10,_c},3,1,5,_p,"1d8"}}, | |
126 {"invisible stalker",'I',0,{16,25,1},ISINVIS|ISHUH,{_r,{10,15,15,_c},120,8,2,_p,"4d4"}}, | |
127 {"jackal",'J',0,{1,6,1},ISMEAN,{_r,{10,10,10,_c},2,1,7,_p,"1d2"}}, | |
128 {"kobold",'K',0,{1,6,1},ISMEAN,{_r,{10,10,10,_c},1,1,8,_p,"1d4"}}, | |
129 {"leprechaun",'L',0,{7,16,0},0,{_r,{10,15,16,_c},10,3,8,_p,"1d1"}}, | |
130 {"mimic",'M',30,{19,500,0},0,{_r,{10,10,10,_c},140,8,7,_p,"3d4"}}, | |
131 {"nymph",'N',100,{11,20,0},0,{_r,{10,18,18,_c},40,3,9,_p,"0d0"}}, | |
132 {"orc",'O',15,{4,13,1},0,{_r,{10,10,10,10},5,1,6,_p,"1d8"}}, | |
133 {"purple worm",'P',70,{22,500,0},0,{_r,{18,5,10,_c},7000,15,6,_p,"2d12/2d4"}}, | |
134 {"quasit",'Q',30,{10,19,1},ISMEAN,{_r,{10,15,16,_c},35,3,2,_p,"1d2/1d2/1d4"}}, | |
135 {"rust monster",'R',0,{9,18,1},ISMEAN,{_r,{10,10,10,_c},25,5,2,_p,"0d0/0d0"}}, | |
136 {"snake",'S',0,{1,7,1},ISMEAN,{_r,{10,10,10,_c},3,1,5,_p,"1d3"}}, | |
137 {"troll",'T',50,{13,22,0},ISMEAN|ISREGEN,{_r,{10,10,11,_c},55,6,4,_p,"1d8/1d8/2d6"}}, | |
138 {"umber hulk",'U',40,{18,500,1},ISMEAN,{_r,{17,10,10,_c},130,8,2,_p,"3d4/3d4/2d5"}}, | |
139 {"vampire",'V',20,{20,500,1},ISMEAN|ISREGEN,{_r,{21,16,16,_c},380,8,1,_p,"1d10"}}, | |
140 {"wraith",'W',0,{14,23,1},ISMEAN,{_r,{10,10,10,_c},55,5,4,_p,"1d6"}}, | |
141 {"xorn",'X',0,{17,26,1},ISMEAN,{_r,{17,6,11,_c},120,7,-2,_p,"1d3/1d3/1d3/4d6"}}, | |
142 {"yeti",'Y',30,{12,21,1},ISMEAN,{_r,{10,10,10,_c},50,4,6,_p,"1d6/1d6"}}, | |
143 {"zombie",'Z',0,{5,14,1},ISMEAN,{_r,{10,10,10,_c},7,2,8,_p,"1d8"}}, | |
144 {"anhkheg",'a',10,{7,16,1},ISMEAN,{_r,{10,15,3,_c},20,3,2,_p,"3d6"}}, | |
145 {"giant beetle",'b',0,{9,18,1},ISMEAN,{_r,{10,15,10,_c},30,5,3,_p,"4d4"}}, | |
146 {"cockatrice",'c',100,{8,17,0},0,{_r,{10,10,11,_c},200,5,6,_p,"1d3"}}, | |
147 {"bone devil",'d',0,{27,500,1},ISMEAN,{_r,{18,10,16,_c},8000,12,-1,_p,"5d4"}}, | |
148 {"elasmosaurus",'e',0,{28,500,1},ISMEAN,{_r,{17,5,3,_c},4500,12,7,_p,"4d6"}}, | |
149 {"killer frog",'f',0,{3,8,1},ISMEAN,{_r,{10,10,10,_c},4,3,8,_p,"2d3/1d4"}}, | |
150 {"green dragon",'g',50,{25,500,1},0,{_r,{18,10,18,_c},7500,10,2,_p,"1d6/1d6/2d10"}}, | |
151 {"hell hound",'h',20,{10,19,1},ISMEAN,{_r,{10,15,10,_c},30,5,4,_p,"1d10"}}, | |
152 {"imp",'i',20,{2,9,1},ISMEAN|ISREGEN,{_r,{10,14,11,_c},6,2,1,_p,"1d4"}}, | |
153 {"jaguar",'j',0,{10,19,0},0,{_r,{10,10,11,_c},25,8,6,_p,"2d3/2d5"}}, | |
154 {"koppleganger",'k',20,{8,17,1},ISMEAN,{_r,{10,10,16,_c},35,4,5,_p,"1d12"}}, | |
155 {"lonchu",'l',15,{2,9,1},ISMEAN,{_r,{10,4,18,_c},5,2,1,_p,"1d4/1d4"}}, | |
156 {"minotaur",'m',0,{12,21,1},ISMEAN,{_r,{10,10,11,_c},40,8,6,_p,"1d3/2d4"}}, | |
157 {"neotyugh",'n',10,{14,23,1},ISMEAN,{_r,{10,6,4,_c},50,6,3,_p,"1d8/1d8/2d3"}}, | |
158 {"ogre",'o',50,{7,16,1},0,{_r,{20,10,10,_c},15,4,5,_p,"2d6"}}, | |
159 {"pseudo dragon",'p',50,{9,18,1},0,{_r,{10,10,16,_c},20,4,2,_p,"2d3/1d6"}}, | |
160 {"quellit",'q',85,{30,500,1},0,{_r,{17,10,10,_c},12500,17,0,_p,"2d10/2d6"}}, | |
161 {"rhynosphinx",'r',40,{26,500,0},0,{_r,{19,6,18,_c},5000,13,-1,_p,"2d10/2d8"}}, | |
162 {"shadow",'s',15,{5,14,1},ISMEAN|ISREGEN|ISINVIS,{_r,{10,17,18,_c},6,3,5,_p,"1d6"}}, | |
163 {"titanothere",'t',0,{19,500,0},0,{_r,{17,6,3,_c},750,14,6,_p,"2d8/1d6"}}, | |
164 {"ulodyte",'u',10,{2,8,1},ISMEAN,{_r,{10,10,10,_c},3,2,5,_p,"1d3/1d3"}}, | |
165 {"vrock",'v',0,{4,13,1},ISMEAN,{_r,{10,10,11,_c},8,3,2,_p,"1d4/1d6"}}, | |
166 {"wuccubi",'w',0,{14,23,1},ISMEAN,{_r,{10,10,10,_c},90,6,0,_p,"1d4/1d10"}}, | |
167 {"xonoclon",'x',0,{20,500,0},0,{_r,{19,10,4,_c},1750,14,0,_p,"3d8"}}, | |
168 {"yeenoghu",'y',10,{15,24,1},ISMEAN,{_r,{17,15,10,_c},250,8,1,_p,"3d6"}}, | |
169 {"zemure",'z',0,{1,6,1},ISMEAN|ISREGEN,{_r,{10,10,10,_c},4,2,7,_p,"1d4"}}, | |
170 {"devil Asmodeus",'A',-1,{1,500,1},ISMEAN|ISREGEN,{_r,{24,18,18,_c},500000,40,-10,_p,"4d10/4d10"}}, | |
171 }; | |
172 | |
173 #undef _p /* erase these definitions */ | |
174 #undef _c | |
175 #undef _r | |
176 | |
177 struct h_list helpstr[] = { | |
178 '?', " prints help", | |
179 '/', " identify object", | |
180 'h', " left", | |
181 'j', " down", | |
182 'k', " up", | |
183 'l', " right", | |
184 'y', " up & left", | |
185 'u', " up & right", | |
186 'b', " down & left", | |
187 'n', " down & right", | |
188 'H', " run left", | |
189 'J', " run down", | |
190 'K', " run up", | |
191 'L', " run right", | |
192 'Y', " run up & left", | |
193 'U', " run up & right", | |
194 'B', " run down & left", | |
195 'N', " run down & right", | |
196 't', "<dir> throw something", | |
197 'f', "<dir> forward until find something", | |
198 'p', "<dir> zap a wand in a direction", | |
199 'z', " zap a wand or staff", | |
200 '>', " go down a staircase", | |
201 's', " search for trap/secret door", | |
202 '.', " (dot) rest for a while", | |
203 'i', " inventory pack", | |
204 'I', " inventory single item", | |
205 'q', " quaff potion", | |
206 'r', " read a scroll", | |
207 'e', " eat food", | |
208 'w', " wield a weapon", | |
209 'W', " wear armor", | |
210 'T', " take armor off", | |
211 'P', " put on ring", | |
212 'R', " remove ring", | |
213 'd', " drop object", | |
214 'c', " call object", | |
215 'O', " examine/set options", | |
216 'a', " display maximum stats", | |
217 'D', " dip object in pool", | |
218 CTRL('L')," redraw screen", | |
219 ESCAPE, " cancel command", | |
220 '!', " shell escape", | |
221 'S', " save game", | |
222 'Q', " quit", | |
223 0, 0 | |
224 }; | |
225 | |
226 char *s_names[MAXSCROLLS]; /* Names of the scrolls */ | |
227 char *p_colors[MAXPOTIONS]; /* Colors of the potions */ | |
228 char *r_stones[MAXRINGS]; /* Stone settings of the rings */ | |
229 struct rod ws_stuff[MAXSTICKS]; /* Stuff for sticks */ | |
230 | |
231 struct magic_item things[NUMTHINGS + 1] = { | |
232 { "potion", 257, 5, }, | |
233 { "scroll", 250, 30, }, | |
234 { "food", 185, 7, }, | |
235 { "weapon", 92, 0, }, | |
236 { "armor", 92, 0, }, | |
237 { "ring", 62, 5, }, | |
238 { "stick", 62, 0, }, | |
239 { "amulet", 0, -250, }, | |
240 { NULL, 0, 0, }, | |
241 }; | |
242 | |
243 struct magic_item a_magic[MAXARMORS + 1] = { | |
244 { "leather armor", 170, 5 }, | |
245 { "ring mail", 130, 30 }, | |
246 { "studded leather armor", 130, 20 }, | |
247 { "scale mail", 120, 3 }, | |
248 { "padded armor", 100, 250 }, | |
249 { "chain mail", 90, 75 }, | |
250 { "splint mail", 90, 80 }, | |
251 { "banded mail", 90, 90 }, | |
252 { "plate mail", 50, 400 }, | |
253 { "plate armor", 30, 650 }, | |
254 { NULL, 0, 0 }, | |
255 }; | |
256 struct init_armor armors[MAXARMORS] = { | |
257 { 8, 150, 500, }, | |
258 { 7, 250, 650, }, | |
259 { 7, 200, 550, }, | |
260 { 6, 400, 900, }, | |
261 { 6, 100, 450, }, | |
262 { 5, 300, 650, }, | |
263 { 4, 400, 700, }, | |
264 { 4, 350, 600, }, | |
265 { 3, 450, 950, }, | |
266 { 2, 350, 750, }, | |
267 }; | |
268 struct magic_item w_magic[MAXWEAPONS + 1] = { | |
269 { "mace", 70, 25 }, | |
270 { "long sword", 70, 60 }, | |
271 { "short bow", 60, 150 }, | |
272 { "arrow", 60, 2 }, | |
273 { "dagger", 20, 5 }, | |
274 { "rock", 20, 1 }, | |
275 { "two-handed sword", 50, 120 }, | |
276 { "sling", 20, 5 }, | |
277 { "dart", 30, 3 }, | |
278 { "crossbow", 60, 70 }, | |
279 { "crossbow bolt", 60, 3 }, | |
280 { "spear", 70, 8 }, | |
281 { "trident", 70, 90 }, | |
282 { "spetum", 70, 50 }, | |
283 { "bardiche", 70, 30 }, | |
284 { "pike", 70, 75 }, | |
285 { "bastard sword", 60, 100 }, | |
286 { "halberd", 70, 40 }, | |
287 { NULL, 0, 0 }, | |
288 }; | |
289 | |
290 struct init_weps weaps[MAXWEAPONS] = { | |
291 { "2d4", "1d3", 0, 100, 300, NONE }, | |
292 { "1d10", "1d2", 0, 60, 180, NONE }, | |
293 { "1d1", "1d1", 0, 40, 190, NONE }, | |
294 { "1d1", "1d6", ISMANY|ISMISL, 5, 8, BOW }, | |
295 { "1d6", "1d4", ISMISL, 10, 30, NONE }, | |
296 { "1d2", "1d4", ISMANY|ISMISL, 5, 10, SLING }, | |
297 { "3d6", "1d2", 0, 250, 550, NONE }, | |
298 { "0d0", "0d0", 0, 5, 7, NONE }, | |
299 { "1d1", "1d3", ISMANY|ISMISL, 5, 5, NONE }, | |
300 { "1d1", "1d1", 0, 100, 250, NONE }, | |
301 { "1d2", "1d10", ISMANY|ISMISL, 7, 11, CROSSBOW }, | |
302 { "1d8", "1d6", ISMISL, 50, 200, NONE }, | |
303 { "3d4", "1d4", 0, 50, 220, NONE }, | |
304 { "2d5", "1d3", 0, 50, 200, NONE }, | |
305 { "3d3", "1d2", 0, 125, 270, NONE }, | |
306 { "1d12", "1d8", 0, 80, 260, NONE }, | |
307 { "2d7", "1d2", 0, 100, 400, NONE }, | |
308 { "2d6", "1d3", 0, 175, 370, NONE }, | |
309 }; | |
310 | |
311 struct magic_item s_magic[MAXSCROLLS + 1] = { | |
312 { "monster confusion", 50, 200 }, | |
313 { "magic mapping", 52, 200 }, | |
314 { "light", 80, 100 }, | |
315 { "hold monster", 25, 200 }, | |
316 { "sleep", 41, 50 }, | |
317 { "enchant armor", 75, 175 }, | |
318 { "identify", 211, 150 }, | |
319 { "scare monster", 42, 300 }, | |
320 { "gold detection", 32, 100 }, | |
321 { "teleportation", 73, 200 }, | |
322 { "enchant weapon", 91, 175 }, | |
323 { "create monster", 34, 75 }, | |
324 { "remove curse", 82, 100 }, | |
325 { "aggravate monsters", 10, 50 }, | |
326 { "blank paper", 11, 50 }, | |
327 { "genocide", 5, 350 }, | |
328 { "item knowledge", 14, 250 }, | |
329 { "item protection", 9, 250 }, | |
330 { "demons curse", 5, 25 }, | |
331 { "transport", 11, 100 }, | |