rogue

Ken Arnold's Rogue
git clone https://git.woozle.org/neale/rogue.git

Neale Pickett  ·  2017-04-21

rmove.c

  1/*
  2 * global variable initializaton
  3 *
  4 * @(#)rmove.c	4.82 (Berkeley) 02/05/99
  5 */
  6
  7#include <curses.h>
  8#include "netprot.h"
  9
 10bool After;				/* True if we want after daemons */
 11bool Again;				/* Repeating the last command */
 12bool Noscore;				/* Was a wizard sometime */
 13bool Seenstairs;			/* Have seen the stairs (for lsd) */
 14bool Amulet = FALSE;			/* He found the amulet */
 15bool Door_stop = FALSE;			/* Stop running when we pass a door */
 16bool Fight_flush = FALSE;		/* True if toilet input */
 17bool Firstmove = FALSE;			/* First move after setting Door_stop */
 18bool Got_ltc = FALSE;			/* We have gotten the local tty chars */
 19bool Has_hit = FALSE;			/* Has a "hit" message pending in msg */
 20bool In_shell = FALSE;			/* True if executing a shell */
 21bool Inv_describe = TRUE;		/* Say which way items are being used */
 22bool Jump = FALSE;			/* Show running as series of jumps */
 23bool Kamikaze = FALSE;			/* To_death really to DEATH */
 24bool Lower_msg = FALSE;			/* Messages should start w/lower case */
 25bool Move_on = FALSE;			/* Next move shouldn't pick up items */
 26bool Msg_esc = FALSE;			/* Check for ESC from msg's --More-- */
 27bool Passgo = FALSE;			/* Follow passages */
 28bool Playing = TRUE;			/* True until he quits */
 29bool Q_comm = FALSE;			/* Are we executing a 'Q' command? */
 30bool Running = FALSE;			/* True if player is running */
 31bool Save_msg = TRUE;			/* Remember last msg */
 32bool See_floor = TRUE;			/* Show the lamp illuminated floor */
 33bool Stat_msg = FALSE;			/* Should status() print as a msg() */
 34bool Terse = FALSE;			/* True if we should be short */
 35bool To_death = FALSE;			/* Fighting is to the death! */
 36bool Tombstone = TRUE;			/* Print out tombstone at end */
 37#ifdef MASTER
 38bool Wizard = FALSE;			/* True if allows wizard commands */
 39#endif
 40bool Pack_used[26] = {			/* Is the character used in the pack? */
 41    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
 42    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
 43    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
 44};
 45
 46char Dir_ch;				/* Direction from last get_dir() call */
 47char File_name[MAXSTR];			/* Save file name */
 48char Huh[MAXSTR];			/* The last message printed */
 49char *P_colors[MAXPOTIONS];		/* Colors of the potions */
 50char Prbuf[2*MAXSTR];			/* Buffer for sprintfs */
 51char *R_stones[MAXRINGS];		/* Stone settings of the rings */
 52char *Release;				/* Release number of program */
 53char Runch;				/* Direction player is Running */
 54char *S_names[MAXSCROLLS];		/* Names of the scrolls */
 55char Take;				/* Thing she is taking */
 56char Whoami[MAXSTR];			/* Name of player */
 57char *Ws_made[MAXSTICKS];		/* What sticks are made of */
 58char *Ws_type[MAXSTICKS];		/* Is it a wand or a staff */
 59#ifdef TIOCSLTC
 60char Orig_dsusp;			/* Original dsusp char */
 61#endif
 62char Fruit[MAXSTR] =			/* Favorite fruit */
 63		{ 's', 'l', 'i', 'm', 'e', '-', 'm', 'o', 'l', 'd', '\0' };
 64char Home[MAXSTR] = { '\0' };		/* User's home directory */
 65char *Inv_t_name[] = {
 66	"Overwrite",
 67	"Slow",
 68	"Clear"
 69};
 70char L_last_comm = '\0';		/* Last Last_comm */
 71char L_last_dir = '\0';			/* Last Last_dir */
 72char Last_comm = '\0';			/* Last command typed */
 73char Last_dir = '\0';			/* Last direction given */
 74char *Tr_name[] = {			/* Names of the traps */
 75	"a trapdoor",
 76	"an arrow trap",
 77	"a sleeping gas trap",
 78	"a beartrap",
 79	"a teleport trap",
 80	"a poison dart trap",
 81	"a rust trap",
 82};
 83
 84
 85int N_objs;				/* # items listed in inventory() call */
 86int Ntraps;				/* Number of traps on this level */
 87int Hungry_state = 0;			/* How hungry is he */
 88int Inpack = 0;				/* Number of things in pack */
 89int Inv_type = 0;			/* Type of inventory to use */
 90int Level = 1;				/* What level she is on */
 91int Max_hit;				/* Max damage done to her in To_death */
 92int Max_level;				/* Deepest player has gone */
 93int Mpos = 0;				/* Where cursor is on top line */
 94int No_food = 0;			/* Number of levels without food */
 95int A_class[MAXARMORS] = {		/* Armor class for each armor type */
 96	8,	/* LEATHER */
 97	7,	/* RING_MAIL */
 98	7,	/* STUDDED_LEATHER */
 99	6,	/* SCALE_MAIL */
100	5,	/* CHAIN_MAIL */
101	4,	/* SPLINT_MAIL */
102	4,	/* BANDED_MAIL */
103	3,	/* PLATE_MAIL */
104};
105
106int Count = 0;				/* Number of times to repeat command */
107int Fd;					/* File descriptor for score file */
108int Food_left;				/* Amount of food in hero's stomach */
109int Lastscore = -1;			/* Score before this turn */
110int No_command = 0;			/* Number of turns asleep */
111int No_move = 0;			/* Number of turns held in place */
112int Purse = 0;				/* How much gold he has */
113int Quiet = 0;				/* Number of quiet turns */
114int Vf_hit = 0;				/* Number of time flytrap has hit */
115
116long Dnum;				/* Dungeon number */
117long Seed;				/* Random number seed */
118long E_levels[] = {
119        10L,
120	20L,
121	40L,
122	80L,
123       160L,
124       320L,
125       640L,
126      1300L,
127      2600L,
128      5200L,
129     13000L,
130     26000L,
131     50000L,
132    100000L,
133    200000L,
134    400000L,
135    800000L,
136   2000000L,
137   4000000L,
138   8000000L,
139	 0L
140};
141
142coord Delta;				/* Change indicated to get_dir() */
143coord Oldpos;				/* Position before last look() call */
144coord Stairs;				/* Location of staircase */
145
146PLACE Places[MAXLINES*MAXCOLS];		/* Level map */
147
148THING *Cur_armor;			/* What he is wearing */
149THING *Cur_ring[2];			/* Which rings are being worn */
150THING *Cur_weapon;			/* Which weapon he is weilding */
151THING *L_last_pick = NULL;		/* Last Last_pick */
152THING *Last_pick = NULL;		/* Last object picked in get_item() */
153THING *Lvl_obj = NULL;			/* List of objects on this level */
154THING *Mlist = NULL;			/* List of monsters on the level */
155THING Player;				/* His stats */
156					/* restart of game */
157
158WINDOW *Hw = NULL;			/* Used as a scratch window */
159
160#define INIT_STATS { 16, 0, 1, 10, 12, "1x4", 12 }
161
162struct stats Max_stats = INIT_STATS;	/* The maximum for the player */
163
164struct room *Oldrp;			/* Roomin(&Oldpos) */
165struct room Rooms[MAXROOMS];		/* One for each room -- A level */
166struct room Passages[MAXPASS] =		/* One for each passage */
167{
168    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
169    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
170    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
171    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
172    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
173    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
174    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
175    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
176    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
177    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
178    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 },
179    { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, 0 }
180};
181
182#define ___ 1
183#define XX 10
184struct monster Monsters[26] =
185    {
186/* Name		 CARRY	FLAG    str, exp, lvl, amr, hpt, dmg */
187{ "aquator",	   0,	ISMEAN,	{ XX, 20,   5,   2, ___, "0x0/0x0" } },
188{ "bat",	   0,	ISFLY,	{ XX,  1,   1,   3, ___, "1x2" } },
189{ "centaur",	  15,	0,	{ XX, 17,   4,   4, ___, "1x2/1x5/1x5" } },
190{ "dragon",	 100,	ISMEAN,	{ XX,5000, 10,  -1, ___, "1x8/1x8/3x10" } },
191{ "emu",	   0,	ISMEAN,	{ XX,  2,   1,   7, ___, "1x2" } },
192{ "venus flytrap", 0,	ISMEAN,	{ XX, 80,   8,   3, ___, "%%%x0" } },
193	/* NOTE: the damage is %%% so that xstr won't merge this */
194	/* string with others, since it is written on in the program */
195{ "griffin",	  20,	ISMEAN|ISFLY|ISREGEN, { XX,2000, 13,   2, ___, "4x3/3x5" } },
196{ "hobgoblin",	   0,	ISMEAN,	{ XX,  3,   1,   5, ___, "1x8" } },
197{ "ice monster",   0,	0,	{ XX,  5,   1,   9, ___, "0x0" } },
198{ "jabberwock",   70,	0,	{ XX,3000, 15,   6, ___, "2x12/2x4" } },
199{ "kestrel",	   0,	ISMEAN|ISFLY,	{ XX,  1,   1,   7, ___, "1x4" } },
200{ "leprechaun",	   0,	0,	{ XX, 10,   3,   8, ___, "1x1" } },
201{ "medusa",	  40,	ISMEAN,	{ XX,200,   8,   2, ___, "3x4/3x4/2x5" } },
202{ "nymph",	 100,	0,	{ XX, 37,   3,   9, ___, "0x0" } },
203{ "orc",	  15,	ISGREED,{ XX,  5,   1,   6, ___, "1x8" } },
204{ "phantom",	   0,	ISINVIS,{ XX,120,   8,   3, ___, "4x4" } },
205{ "quagga",	   0,	ISMEAN,	{ XX, 15,   3,   3, ___, "1x5/1x5" } },
206{ "rattlesnake",   0,	ISMEAN,	{ XX,  9,   2,   3, ___, "1x6" } },
207{ "snake",	   0,	ISMEAN,	{ XX,  2,   1,   5, ___, "1x3" } },
208{ "troll",	  50,	ISREGEN|ISMEAN,{ XX, 120, 6, 4, ___, "1x8/1x8/2x6" } },
209{ "black unicorn", 0,	ISMEAN,	{ XX,190,   7,  -2, ___, "1x9/1x9/2x9" } },
210{ "vampire",	  20,	ISREGEN|ISMEAN,{ XX,350,   8,   1, ___, "1x10" } },
211{ "wraith",	   0,	0,	{ XX, 55,   5,   4, ___, "1x6" } },
212{ "xeroc",	  30,	0,	{ XX,100,   7,   7, ___, "4x4" } },
213{ "yeti",	  30,	0,	{ XX, 50,   4,   6, ___, "1x6/1x6" } },
214{ "zombie",	   0,	ISMEAN,	{ XX,  6,   2,   8, ___, "1x8" } }
215    };
216#undef ___
217#undef XX
218
219struct obj_info Things[NUMTHINGS] = {
220    { 0,			26 },	/* potion */
221    { 0,			36 },	/* scroll */
222    { 0,			16 },	/* food */
223    { 0,			 7 },	/* weapon */
224    { 0,			 7 },	/* armor */
225    { 0,			 4 },	/* ring */
226    { 0,			 4 },	/* stick */
227};
228
229struct obj_info Arm_info[MAXARMORS] = {
230    { "leather armor",		 20,	 20, NULL, FALSE },
231    { "ring mail",		 15,	 25, NULL, FALSE },
232    { "studded leather armor",	 15,	 20, NULL, FALSE },
233    { "scale mail",		 13,	 30, NULL, FALSE },
234    { "chain mail",		 12,	 75, NULL, FALSE },
235    { "splint mail",		 10,	 80, NULL, FALSE },
236    { "banded mail",		 10,	 90, NULL, FALSE },
237    { "plate mail",		  5,	150, NULL, FALSE },
238};
239struct obj_info Pot_info[MAXPOTIONS] = {
240    { "confusion",		 7,   5, NULL, FALSE },
241    { "hallucination",		 8,   5, NULL, FALSE },
242    { "poison",			 8,   5, NULL, FALSE },
243    { "gain strength",		13, 150, NULL, FALSE },
244    { "see invisible",		 3, 100, NULL, FALSE },
245    { "healing",		13, 130, NULL, FALSE },
246    { "monster detection",	 6, 130, NULL, FALSE },
247    { "magic detection",	 6, 105, NULL, FALSE },
248    { "raise level",		 2, 250, NULL, FALSE },
249    { "extra healing",		 5, 200, NULL, FALSE },
250    { "haste self",		 5, 190, NULL, FALSE },
251    { "restore strength",	13, 130, NULL, FALSE },
252    { "blindness",		 5,   5, NULL, FALSE },
253    { "levitation",		 6,  75, NULL, FALSE },
254};
255struct obj_info Ring_info[MAXRINGS] = {
256    { "protection",		 9, 400, NULL, FALSE },
257    { "add strength",		 9, 400, NULL, FALSE },
258    { "sustain strength",	 5, 280, NULL, FALSE },
259    { "searching",		10, 420, NULL, FALSE },
260    { "see invisible",		10, 310, NULL, FALSE },
261    { "adornment",		 1,  10, NULL, FALSE },
262    { "aggravate monster",	10,  10, NULL, FALSE },
263    { "dexterity",		 8, 440, NULL, FALSE },
264    { "increase damage",	 8, 400, NULL, FALSE },
265    { "regeneration",		 4, 460, NULL, FALSE },
266    { "slow digestion",		 9, 240, NULL, FALSE },
267    { "teleportation",		 5,  30, NULL, FALSE },
268    { "stealth",		 7, 470, NULL, FALSE },
269    { "maintain armor",		 5, 380, NULL, FALSE },
270};
271struct obj_info Scr_info[MAXSCROLLS] = {
272    { "monster confusion",		 7, 140, NULL, FALSE },
273    { "magic mapping",			 4, 150, NULL, FALSE },
274    { "hold monster",			 2, 180, NULL, FALSE },
275    { "sleep",				 3,   5, NULL, FALSE },
276    { "enchant armor",			 7, 160, NULL, FALSE },
277    { "identify potion",		10,  80, NULL, FALSE },
278    { "identify scroll",		10,  80, NULL, FALSE },
279    { "identify weapon",		 6,  80, NULL, FALSE },
280    { "identify armor",		 	 7, 100, NULL, FALSE },
281    { "identify ring, wand or staff",	10, 115, NULL, FALSE },
282    { "scare monster",			 3, 200, NULL, FALSE },
283    { "food detection",			 2,  60, NULL, FALSE },
284    { "teleportation",			 5, 165, NULL, FALSE },
285    { "enchant weapon",			 8, 150, NULL, FALSE },
286    { "create monster",			 4,  75, NULL, FALSE },
287    { "remove curse",			 7, 105, NULL, FALSE },
288    { "aggravate monsters",		 3,  20, NULL, FALSE },
289    { "protect armor",			 2, 250, NULL, FALSE },
290};
291struct obj_info Weap_info[MAXWEAPONS + 1] = {
292    { "mace",				11,   8, NULL, FALSE },
293    { "long sword",			11,  15, NULL, FALSE },
294    { "short bow",			12,  15, NULL, FALSE },
295    { "arrow",				12,   1, NULL, FALSE },
296    { "dagger",				 8,   3, NULL, FALSE },
297    { "two handed sword",		10,  75, NULL, FALSE },
298    { "dart",				12,   2, NULL, FALSE },
299    { "shuriken",			12,   5, NULL, FALSE },
300    { "spear",				12,   5, NULL, FALSE },
301    { NULL, 0 },	/* DO NOT REMOVE: fake entry for dragon's breath */
302};
303struct obj_info Ws_info[MAXSTICKS] = {
304    { "light",			12, 250, NULL, FALSE },
305    { "invisibility",		 6,   5, NULL, FALSE },
306    { "lightning",		 3, 330, NULL, FALSE },
307    { "fire",			 3, 330, NULL, FALSE },
308    { "cold",			 3, 330, NULL, FALSE },
309    { "polymorph",		15, 310, NULL, FALSE },
310    { "magic missile",		10, 170, NULL, FALSE },
311    { "haste monster",		10,   5, NULL, FALSE },
312    { "slow monster",		11, 350, NULL, FALSE },
313    { "drain life",		 9, 300, NULL, FALSE },
314    { "nothing",		 1,   5, NULL, FALSE },
315    { "teleport away",		 6, 340, NULL, FALSE },
316    { "teleport to",		 6,  50, NULL, FALSE },
317    { "cancellation",		 5, 280, NULL, FALSE },
318};
319
320struct h_list Helpstr[] = {
321    '?',	"	prints help",				TRUE,
322    '/',	"	identify object",			TRUE,
323    'h',	"	left",					TRUE,
324    'j',	"	down",					TRUE,
325    'k',	"	up",					TRUE,
326    'l',	"	right",					TRUE,
327    'y',	"	up & left",				TRUE,
328    'u',	"	up & right",				TRUE,
329    'b',	"	down & left",				TRUE,
330    'n',	"	down & right",				TRUE,
331    'H',	"	run left",				FALSE,
332    'J',	"	run down",				FALSE,
333    'K',	"	run up",				FALSE,
334    'L',	"	run right",				FALSE,
335    'Y',	"	run up & left",				FALSE,
336    'U',	"	run up & right",			FALSE,
337    'B',	"	run down & left",			FALSE,
338    'N',	"	run down & right",			FALSE,
339    CTRL('H'),	"	run left until adjacent",		FALSE,
340    CTRL('J'),	"	run down until adjacent",		FALSE,
341    CTRL('K'),	"	run up until adjacent",			FALSE,
342    CTRL('L'),	"	run right until adjacent",		FALSE,
343    CTRL('Y'),	"	run up & left until adjacent",		FALSE,
344    CTRL('U'),	"	run up & right until adjacent",		FALSE,
345    CTRL('B'),	"	run down & left until adjacent",	FALSE,
346    CTRL('N'),	"	run down & right until adjacent",	FALSE,
347    '\0',	"	<SHIFT><dir>: run that way",		TRUE,
348    '\0',	"	<CTRL><dir>: run till adjacent",	TRUE,
349    'f',	"<dir>	fight till death or near death",	TRUE,
350    't',	"<dir>	throw something",			TRUE,
351    'm',	"<dir>	move onto without picking up",		TRUE,
352    'z',	"<dir>	zap a wand in a direction",		TRUE,
353    '^',	"<dir>	identify trap type",			TRUE,
354    's',	"	search for trap/secret door",		TRUE,
355    '>',	"	go down a staircase",			TRUE,
356    '<',	"	go up a staircase",			TRUE,
357    '.',	"	rest for a turn",			TRUE,
358    'i',	"	inventory",				TRUE,
359    'I',	"	inventory single item",			TRUE,
360    'q',	"	quaff potion",				TRUE,
361    'r',	"	read scroll",				TRUE,
362    'e',	"	eat food",				TRUE,
363    'w',	"	wield a weapon",			TRUE,
364    'W',	"	wear armor",				TRUE,
365    'T',	"	take armor off",			TRUE,
366    'P',	"	put on ring",				TRUE,
367    'R',	"	remove ring",				TRUE,
368    'd',	"	drop object",				TRUE,
369    'c',	"	call object",				TRUE,
370    'a',	"	repeat last command",			TRUE,
371    ')',	"	print current weapon",			TRUE,
372    ']',	"	print current armor",			TRUE,
373    '=',	"	print current rings",			TRUE,
374    '@',	"	print current stats",			TRUE,
375    'D',	"	recall what's been discovered",		TRUE,
376    'o',	"	examine/set options",			TRUE,
377    CTRL('R'),	"	redraw screen",				TRUE,
378    CTRL('P'),	"	repeat last message",			TRUE,
379    ESCAPE,	"	cancel command",			TRUE,
380    'S',	"	save game",				TRUE,
381    'Q',	"	quit",					TRUE,
382    '!',	"	shell escape",				TRUE,
383    'F',	"<dir>	fight till either of you dies",		TRUE,
384    'v',	"	print version number",			TRUE,
385    0,		NULL
386};
387
388#ifdef TIOCGLTC
389struct ltchars Ltc;		/* needed to change ^Y to not be suspchar */
390#endif /* TIOCGLTC */