Source:Hack 1.0/hack.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to hack.h from the source code of Hack 1.0. To link to a particular line, write [[Hack 1.0/hack.h#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

Screenshots and source code from Hack are used under the CWI license.

1.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
2.    
3.    #include "mklev.h"
4.    #include "hack.onames.h"
5.    
6.    #define ON 1
7.    #define OFF 0
8.    
9.    extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg, 
10.   	*uleft, *uright, *fcobj;
11.   extern struct obj *uchain;	/* defined iff PUNISHED */
12.   extern struct obj *uball;	/* defined if PUNISHED */
13.   struct obj *o_at(), *getobj(), *sobj_at();
14.   
15.   struct flag {
16.   	unsigned ident;		/* social security number for each monster */
17.   	unsigned topl:2;	/* a top line (message) has been printed */
18.   				/* 0: top line empty; 2: no --More-- reqd. */
19.   	unsigned cbreak:1;	/* in cbreak mode, rogue format */
20.   	unsigned oneline:1;	/* give inventories 1 line at a time */
21.   	unsigned move:1;
22.   	unsigned mv:1;
23.   	unsigned run:3;		/* 0: h (etc), 1: H (etc), 2: fh (etc) */
24.   				/* 3: FH, 4: ff+, 5: ff-, 6: FF+, 7: FF- */
25.   	unsigned nopick:1;	/* do not pickup objects */
26.   	unsigned echo:1;	/* 1 to echo characters */
27.   	unsigned botl:1;	/* partially redo status line */
28.   	unsigned botlx:1;	/* print an entirely new bottom line */
29.   	unsigned nscrinh:1;	/* inhibit nscr() in pline(); */
30.   };
31.   extern struct flag flags;
32.   
33.   struct prop {
34.   #define	TIMEOUT		007777	/* mask */
35.   #define	LEFT_RING	W_RINGL	/* 010000L */
36.   #define	RIGHT_RING	W_RINGR	/* 020000L */
37.   #define	INTRINSIC	040000L
38.   #define	LEFT_SIDE	LEFT_RING
39.   #define	RIGHT_SIDE	RIGHT_RING
40.   #define	BOTH_SIDES	(LEFT_SIDE | RIGHT_SIDE)
41.   	long p_flgs;
42.   	int (*p_tofn)();	/* called after timeout */
43.   };
44.   
45.   struct you {
46.   	xchar ux, uy;
47.   	schar dx, dy;		/* direction of fast move */
48.   #ifdef QUEST
49.   	schar di;		/* direction of FF */
50.   	xchar ux0, uy0;		/* initial position FF */
51.   #endif QUEST
52.   	xchar udisx, udisy;	/* last display pos */
53.   	char usym;		/* usually '@' */
54.   	schar uluck;
55.   	int last_str_turn:3;	/* 0: none, 1: half turn, 2: full turn */
56.   				/* +: turn right, -: turn left */
57.   	unsigned udispl:1;	/* @ on display */
58.   	unsigned ulevel:5;
59.   #ifdef QUEST
60.   	unsigned uhorizon:7;
61.   #endif QUEST
62.   	unsigned utrap:3;	/* trap timeout */
63.   	unsigned utraptype:1;	/* defined if utrap nonzero */
64.   #define	TT_BEARTRAP	0
65.   #define	TT_PIT		1
66.   	unsigned uinshop:1;
67.   
68.   
69.   /* perhaps these #define's should also be generated by makedefs */
70.   #define	TELEPAT		LAST_RING		/* not a ring */
71.   #define	Telepat		u.uprops[TELEPAT].p_flgs
72.   #define	FAST		(LAST_RING+1)		/* not a ring */
73.   #define	Fast		u.uprops[FAST].p_flgs
74.   #define	CONFUSION	(LAST_RING+2)		/* not a ring */
75.   #define	Confusion	u.uprops[CONFUSION].p_flgs
76.   #define	INVIS		(LAST_RING+3)		/* not a ring */
77.   #define	Invis		u.uprops[INVIS].p_flgs
78.   #define	GLIB		(LAST_RING+4)		/* not a ring */
79.   #define	Glib		u.uprops[GLIB].p_flgs
80.   #define	PUNISHED	(LAST_RING+5)		/* not a ring */
81.   #define	Punished	u.uprops[PUNISHED].p_flgs
82.   #define	SICK		(LAST_RING+6)		/* not a ring */
83.   #define	Sick		u.uprops[SICK].p_flgs
84.   #define	BLIND		(LAST_RING+7)		/* not a ring */
85.   #define	Blind		u.uprops[BLIND].p_flgs
86.   #define	WOUNDED_LEGS	(LAST_RING+8)		/* not a ring */
87.   #define Wounded_legs	u.uprops[WOUNDED_LEGS].p_flgs
88.   #define PROP(x) (x-RIN_ADORNMENT)       /* convert ring to index in uprops */
89.   	unsigned umconf:1;
90.   	char *usick_cause;
91.   	struct prop uprops[LAST_RING+9];
92.   
93.   	unsigned uswallow:1;		/* set if swallowed by a monster */
94.   	unsigned uswldtim:4;		/* time you have been swallowed */
95.   	unsigned uhs:3;			/* hunger state - see hack.eat.c */
96.   	schar ustr,ustrmax;
97.   	schar udaminc;
98.   	schar uac;
99.   	int uhp,uhpmax;
100.  	long int ugold,ugold0,uexp,urexp;
101.  	int uhunger;			/* refd only in eat.c and shk.c */
102.  	int uinvault;
103.  	struct monst *ustuck;
104.  	int nr_killed[CMNUM+2];		/* used for experience bookkeeping */
105.  };
106.  
107.  extern struct you u;
108.  
109.  extern char *traps[];
110.  extern char *plur(), *monnam(), *Monnam(), *amonnam(), *Amonnam(),
111.  	*doname(), *aobjnam();
112.  extern char readchar();
113.  extern char vowels[];
114.  
115.  extern xchar curx,cury;	/* cursor location on screen */
116.  
117.  extern coord bhitpos;	/* place where thrown weapon falls to the ground */
118.  
119.  extern xchar seehx,seelx,seehy,seely; /* where to see*/
120.  extern char *save_cm,*killer;
121.  
122.  extern xchar dlevel, maxdlevel; /* dungeon level */
123.  
124.  extern long moves;
125.  
126.  extern int multi;
127.  
128.  
129.  extern char lock[];
130.  
131.  
132.  #define DIST(x1,y1,x2,y2)       (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
133.  
134.  #define	PL_CSIZ		20	/* sizeof pl_character */
135.  #define	MAX_CARR_CAP	120	/* so that boulders can be heavier */
136.  #define	FAR	(COLNO+2)	/* position outside screen */