1 /*	SCCS Id: @(#)you.h	3.4	2000/05/21	*/
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4 
5 #ifndef YOU_H
6 #define YOU_H
7 
8 #include "attrib.h"
9 #include "monst.h"
10 #ifndef PROP_H
11 #include "prop.h"		/* (needed here for util/makedefs.c) */
12 #endif
13 #include "skills.h"
14 
15 /*** Substructures ***/
16 
17 struct RoleName {
18 	const char	*m;	/* name when character is male */
19 	const char	*f;	/* when female; null if same as male */
20 };
21 
22 struct RoleAdvance {
23 	/* "fix" is the fixed amount, "rnd" is the random amount */
24 	xchar infix, inrnd;	/* at character initialization */
25 	xchar lofix, lornd;	/* gained per level <  urole.xlev */
26 	xchar hifix, hirnd;	/* gained per level >= urole.xlev */
27 };
28 
29 struct u_have {
30 	Bitfield(amulet,1);	/* carrying Amulet	*/
31 	Bitfield(bell,1);	/* carrying Bell	*/
32 	Bitfield(book,1);	/* carrying Book	*/
33 	Bitfield(menorah,1);	/* carrying Candelabrum */
34 	Bitfield(questart,1);	/* carrying the Quest Artifact */
35 	Bitfield(unused,3);
36 };
37 
38 struct u_event {
39 	Bitfield(minor_oracle,1);	/* received at least 1 cheap oracle */
40 	Bitfield(major_oracle,1);	/*  "  expensive oracle */
41 	Bitfield(qcalled,1);		/* called by Quest leader to do task */
42 	Bitfield(qexpelled,1);		/* expelled from the Quest dungeon */
43 	Bitfield(qcompleted,1);		/* successfully completed Quest task */
44 	Bitfield(uheard_tune,2);	/* 1=know about, 2=heard passtune */
45 	Bitfield(uopened_dbridge,1);	/* opened the drawbridge */
46 
47 	Bitfield(invoked,1);		/* invoked Gate to the Sanctum level */
48 	Bitfield(gehennom_entered,1);	/* entered Gehennom via Valley */
49 #ifdef ELBERETH
50 	Bitfield(uhand_of_elbereth,2);	/* became Hand of Elbereth */
51 #endif
52 	Bitfield(udemigod,1);		/* killed the wiz */
53 	Bitfield(ascended,1);		/* has offered the Amulet */
54 };
55 
56 /* KMH, conduct --
57  * These are voluntary challenges.  Each field denotes the number of
58  * times a challenge has been violated.
59  */
60 struct u_conduct {		/* number of times... */
61 	long	unvegetarian;	/* eaten any animal */
62 	long	unvegan;	/* ... or any animal byproduct */
63 	long	food;		/* ... or any comestible */
64 	long	gnostic;	/* used prayer, priest, or altar */
65 	long	weaphit;	/* hit a monster with a weapon */
66 	long	killer;		/* killed a monster yourself */
67 	long	literate;	/* read something (other than BotD) */
68 	long	polypiles;	/* polymorphed an object */
69 	long	polyselfs;	/* transformed yourself */
70 	long	wishes;		/* used a wish */
71 	long	wisharti;	/* wished for an artifact */
72 	long	wishmagic;	/* wished for a magic object */
73 	long	armoruses;	/* put on a piece of armor */
74 	long	unblinded;	/* starting non-blindfolded and removing a blindfold */
75 	long	robbed;		/* killed an artifact-guardian (like an ordinary robber) */
76 	long	elbereths;	/* engraved Elbereth */
77 	long	bones;		/* encountered bones level */
78 	long	non_racial_armor;	/* put on non-racial armor */
79 	long	non_racial_weapons;	/* wielded non-racial weapons */
80 	long	sokoban;		/* how many times violated sokoban "rules" */
81 	long	heaven_or_hell;	/* heaven or hell mode */
82 	long	hell_and_hell;	/* hell and hell mode */
83 				/* genocides already listed at end of game */
84 };
85 
86 #define heaven_or_hell_mode u.uconduct.heaven_or_hell
87 #define hell_and_hell_mode u.uconduct.hell_and_hell
88 
89 /*             --- roleplay intrinsics ---
90  *
91  * In a lot of situations it makes sense to make special cases for
92  * conduct-characters. Here's the structure to store a character's
93  * abilities/intentions.
94  *
95  * These are allowed to change during gameplay. So e.g. it's possible
96  * to gain/lose the ability to read.
97  *
98  * It also allows to stop giving special treatment to characters which
99  * obviously abandoned a selected conduct. E.g vegetarians stop feeling
100  * guilty after eating a lot of corpses.
101 */
102 struct u_roleplay {		/* Your character is a/an ... */
103 	boolean ascet;		/* foodless character */
104 	boolean atheist;	/* atheist */
105 	boolean blindfolded;	/* blindfolded character */
106 	boolean illiterate;	/* illiterate character */
107 	boolean pacifist;	/* pacifist */
108 	boolean sadist;		/* sadist */
109 	boolean nudist;		/* nudist */
110 	boolean vegan;		/* vegan */
111 	boolean vegetarian;	/* vegetarian */
112 };
113 
114 /*** Unified structure containing role information ***/
115 struct Role {
116 	/*** Strings that name various things ***/
117 	struct RoleName name;	/* the role's name (from u_init.c) */
118 	struct RoleName rank[9]; /* names for experience levels (from botl.c) */
119 	const char *lgod, *ngod, *cgod; /* god names (from pray.c) */
120 	const char *filecode;	/* abbreviation for use in file names */
121 	const char *homebase;	/* quest leader's location (from questpgr.c) */
122 	const char *intermed;	/* quest intermediate goal (from questpgr.c) */
123 
124 	/*** Indices of important monsters and objects ***/
125 	short malenum,		/* index (PM_) as a male (botl.c) */
126 	      femalenum,	/* ...or as a female (NON_PM == same) */
127 	      petnum,		/* PM_ of preferred pet (NON_PM == random) */
128 	      ldrnum,		/* PM_ of quest leader (questpgr.c) */
129 	      guardnum,		/* PM_ of quest guardians (questpgr.c) */
130 	      neminum;		/* PM_ of quest nemesis (questpgr.c) */
131 	short questarti;	/* index (ART_) of quest artifact (questpgr.c) */
132 
133 	/*** Bitmasks ***/
134 	short allow;		/* bit mask of allowed variations */
135 #define ROLE_RACEMASK	0x0ff8		/* allowable races */
136 #define ROLE_GENDMASK	0xf000		/* allowable genders */
137 #define ROLE_MALE	0x1000
138 #define ROLE_FEMALE	0x2000
139 #define ROLE_NEUTER	0x4000
140 #define ROLE_ALIGNMASK	AM_MASK		/* allowable alignments */
141 #define ROLE_LAWFUL	AM_LAWFUL
142 #define ROLE_NEUTRAL	AM_NEUTRAL
143 #define ROLE_CHAOTIC	AM_CHAOTIC
144 
145 	/*** Attributes (from attrib.c and exper.c) ***/
146 	xchar attrbase[A_MAX];	/* lowest initial attributes */
147 	xchar attrdist[A_MAX];	/* distribution of initial attributes */
148 	struct RoleAdvance hpadv; /* hit point advancement */
149 	struct RoleAdvance enadv; /* energy advancement */
150 	xchar xlev;		/* cutoff experience level */
151 	xchar initrecord;	/* initial alignment record */
152 
153 	/*** Spell statistics (from spell.c) ***/
154 	int spelbase;		/* base spellcasting penalty */
155 	int spelheal;		/* penalty (-bonus) for healing spells */
156 	int spelshld;		/* penalty for wearing any shield */
157 	int spelarmr;		/* penalty for wearing metal armour */
158 	int spelstat;		/* which stat (A_) is used */
159 	int spelspec;		/* spell (SPE_) the class excels at */
160 	int spelsbon;		/* penalty (-bonus) for that spell */
161 
162 	/*** Properties in variable-length arrays ***/
163 	/* intrinsics (see attrib.c) */
164 	/* initial inventory (see u_init.c) */
165 	/* skills (see u_init.c) */
166 
167 	/*** Don't forget to add... ***/
168 	/* quest leader, guardians, nemesis (monst.c) */
169 	/* quest artifact (artilist.h) */
170 	/* quest dungeon definition (dat/Xyz.dat) */
171 	/* quest text (dat/quest.txt) */
172 	/* dictionary entries (dat/data.bas) */
173 };
174 
175 extern const struct Role roles[];	/* table of available roles */
176 extern struct Role urole;
177 #define Role_if(X)	(urole.malenum == (X))
178 #define Role_switch	(urole.malenum)
179 
180 /* used during initialization for race, gender, and alignment
181    as well as for character class */
182 #define ROLE_NONE	(-1)
183 #define ROLE_RANDOM	(-2)
184 
185 /*** Unified structure specifying race information ***/
186 
187 struct Race {
188 	/*** Strings that name various things ***/
189 	const char *noun;	/* noun ("human", "elf") */
190 	const char *adj;	/* adjective ("human", "elven") */
191 	const char *coll;	/* collective ("humanity", "elvenkind") */
192 	const char *filecode;	/* code for filenames */
193 	struct RoleName individual; /* individual as a noun ("man", "elf") */
194 
195 	/*** Indices of important monsters and objects ***/
196 	short malenum,		/* PM_ as a male monster */
197 	      femalenum,	/* ...or as a female (NON_PM == same) */
198 	      mummynum,		/* PM_ as a mummy */
199 	      zombienum;	/* PM_ as a zombie */
200 
201 	/*** Bitmasks ***/
202 	short allow;		/* bit mask of allowed variations */
203 	short selfmask,		/* your own race's bit mask */
204 	      lovemask,		/* bit mask of always peaceful */
205 	      hatemask;		/* bit mask of always hostile */
206 
207 	/*** Attributes ***/
208 	xchar attrmin[A_MAX];	/* minimum allowable attribute */
209 	xchar attrmax[A_MAX];	/* maximum allowable attribute */
210 	struct RoleAdvance hpadv; /* hit point advancement */
211 	struct RoleAdvance enadv; /* energy advancement */
212 #if 0	/* DEFERRED */
213 	int   nv_range;		/* night vision range */
214 	int   xray_range;	/* X-ray vision range */
215 #endif
216 
217 	/*** Properties in variable-length arrays ***/
218 	/* intrinsics (see attrib.c) */
219 
220 	/*** Don't forget to add... ***/
221 	/* quest leader, guardians, nemesis (monst.c) */
222 	/* quest dungeon definition (dat/Xyz.dat) */
223 	/* quest text (dat/quest.txt) */
224 	/* dictionary entries (dat/data.bas) */
225 };
226 
227 extern const struct Race races[];	/* Table of available races */
228 extern struct Race urace;
229 #define Race_if(X)	(urace.malenum == (X))
230 #define Race_switch	(urace.malenum)
231 
232 /*** Unified structure specifying gender information ***/
233 struct Gender {
234 	const char *adj;	/* male/female/neuter */
235 	const char *he;		/* he/she/it */
236 	const char *him;	/* him/her/it */
237 	const char *his;	/* his/her/its */
238 	const char *filecode;	/* file code */
239 	short allow;		/* equivalent ROLE_ mask */
240 };
241 #define ROLE_GENDERS	2	/* number of permitted player genders */
242 				/* increment to 3 if you allow neuter roles */
243 
244 extern const struct Gender genders[];	/* table of available genders */
245 #define uhe()	(genders[flags.female ? 1 : 0].he)
246 #define uhim()	(genders[flags.female ? 1 : 0].him)
247 #define uhis()	(genders[flags.female ? 1 : 0].his)
248 #define mhe(mtmp)	(genders[pronoun_gender(mtmp)].he)
249 #define mhim(mtmp)	(genders[pronoun_gender(mtmp)].him)
250 #define mhis(mtmp)	(genders[pronoun_gender(mtmp)].his)
251 
252 
253 /*** Unified structure specifying alignment information ***/
254 struct Align {
255 	const char *noun;	/* law/balance/chaos */
256 	const char *adj;	/* lawful/neutral/chaotic */
257 	const char *filecode;	/* file code */
258 	short allow;		/* equivalent ROLE_ mask */
259 	aligntyp value;		/* equivalent A_ value */
260 };
261 #define ROLE_ALIGNS	3	/* number of permitted player alignments */
262 
263 extern const struct Align aligns[];	/* table of available alignments */
264 
265 /*
266  * The following structure contains information about a conduct
267  *   - a name (e.g. for a conduct-menu at character creation)
268  *   - nouns and adjectives for the highscore
269  *   - a flag for 'worth mentioning in the highscore'
270  *   - all strings necessary for show_conduct()
271  */
272 /*** Unified structure specifying conduct information ***/
273 struct Conduct {
274 	const char *name;		/* pacifism/nudism/...	*/
275 	const char *noun;		/* pacifist/nudist/...	*/
276 	const char *adj;		/* peaceful/nude/...	*/
277 
278 	boolean highscore;		/* conduct appears in the highscore */
279 
280 	const char *prefix;		/* "You "	*/
281 	const char *presenttxt;		/* "have been "	*/
282 	const char *pasttxt;		/* "were "	*/
283 	const char *suffix;		/* "a pacifist"	*/
284 	const char *failtxt;		/* "pretended to be a pacifist" */
285 
286 };
287 
288 extern const struct Conduct conducts[];/* table of available roleplay conducts*/
289 
290 /*
291  * The following definitions get used to call violated(CONDUCT_XYZ),
292  * and to access the information contained in the conducts[] array.
293 */
294 
295 #define ROLE_CONDUCTS		10 	/* number of roleplay conducts */
296 
297 #define FIRST_CONDUCT		0
298 #define CONDUCT_PACIFISM	0
299 #define CONDUCT_SADISM		1
300 #define CONDUCT_ATHEISM 	2
301 #define CONDUCT_NUDISM		3
302 #define CONDUCT_BLINDFOLDED	4
303 #define CONDUCT_FOODLESS	5
304 #define CONDUCT_VEGAN		6
305 #define CONDUCT_VEGETARIAN	7
306 #define CONDUCT_ILLITERACY	8
307 #define CONDUCT_THIEVERY	9
308 #define LAST_CONDUCT	ROLE_CONDUCTS - 1
309 
310 /*** Information about the player ***/
311 struct you {
312 	xchar ux, uy;
313 	schar dx, dy, dz;	/* direction of move (or zap or ... ) */
314 	schar di;		/* direction of FF */
315 	xchar tx, ty;		/* destination of travel */
316 	xchar ux0, uy0;		/* initial position FF */
317 	d_level uz, uz0;	/* your level on this and the previous turn */
318 	d_level utolev;		/* level monster teleported you to, or uz */
319 	uchar utotype;		/* bitmask of goto_level() flags for utolev */
320 	boolean umoved;		/* changed map location (post-move) */
321 	int last_str_turn;	/* 0: none, 1: half turn, 2: full turn */
322 				/* +: turn right, -: turn left */
323 	int ulevel;		/* 1 to MAXULEV */
324 	int ulevelmax;
325 	unsigned utrap;		/* trap timeout */
326 	unsigned utraptype;	/* defined if utrap nonzero */
327 	unsigned ufeetfrozen;   /* feet frozen, works similarly to utrap */
328 #define TT_BEARTRAP	0
329 #define TT_PIT		1
330 #define TT_WEB		2
331 #define TT_LAVA		3
332 #define TT_INFLOOR	4
333 #define TT_SWAMP	5
334 #define TT_ICE		6
335 	char	urooms[5];	/* rooms (roomno + 3) occupied now */
336 	char	urooms0[5];	/* ditto, for previous position */
337 	char	uentered[5];	/* rooms (roomno + 3) entered this turn */
338 	char	ushops[5];	/* shop rooms (roomno + 3) occupied now */
339 	char	ushops0[5];	/* ditto, for previous position */
340 	char	ushops_entered[5]; /* ditto, shops entered this turn */
341 	char	ushops_left[5]; /* ditto, shops exited this turn */
342 
343 	int	 uhunger;	/* refd only in eat.c and shk.c */
344 	unsigned uhs;		/* hunger state - see eat.c */
345 
346 	struct prop uprops[LAST_PROP+1];
347 
348 	unsigned umconf;
349 	char usick_cause[PL_PSIZ+20]; /* sizeof "unicorn horn named "+1 */
350 	Bitfield(usick_type,2);
351 #define SICK_VOMITABLE 0x01
352 #define SICK_NONVOMITABLE 0x02
353 #define SICK_ALL 0x03
354 
355 	/* These ranges can never be more than MAX_RANGE (vision.h). */
356 	int nv_range;		/* current night vision range */
357 	int xray_range;		/* current xray vision range */
358 
359 	/*
360 	 * These variables are valid globally only when punished and blind.
361 	 */
362 #define BC_BALL  0x01	/* bit mask for ball  in 'bc_felt' below */
363 #define BC_CHAIN 0x02	/* bit mask for chain in 'bc_felt' below */
364 	int bglyph;	/* glyph under the ball */
365 	int cglyph;	/* glyph under the chain */
366 	int bc_order;	/* ball & chain order [see bc_order() in ball.c] */
367 	int bc_felt;	/* mask for ball/chain being felt */
368 
369 	int umonster;			/* hero's "real" monster num */
370 	int umonnum;			/* current monster number */
371 
372 	int mh, mhmax, mtimedone;	/* for polymorph-self */
373 	struct attribs	macurr,		/* for monster attribs */
374 			mamax;		/* for monster attribs */
375 	int ulycn;			/* lycanthrope type */
376 
377 	unsigned ucreamed;
378 	unsigned uswldtim;		/* time you have been swallowed */
379 
380 	Bitfield(uswallow,1);		/* true if swallowed */
381 	Bitfield(uinwater,1);		/* if you're currently in water (only
382 					   underwater possible currently) */
383 	Bitfield(uundetected,1);	/* if you're a hiding monster/piercer */
384 	Bitfield(mfemale,1);		/* saved human value of flags.female */
385 	Bitfield(uinvulnerable,1);	/* you're invulnerable (praying) */
386 	Bitfield(uburied,1);		/* you're buried */
387 	Bitfield(uedibility,1);		/* blessed food detection; sense unsafe food */
388 	/* 1 free bit! */
389 
390 	unsigned udg_cnt;		/* how long you have been demigod */
391 	struct u_event	uevent;		/* certain events have happened */
392 	struct u_have	uhave;		/* you're carrying special objects */
393 	struct u_conduct uconduct;	/* KMH, conduct */
394 	struct u_roleplay roleplay;	/* roleplay intrinsics */
395 	long   ulives;			/* heaven or hell mode, number of lives */
396 	struct attribs	acurr,		/* your current attributes (eg. str)*/
397 			aexe,		/* for gain/loss via "exercise" */
398 			abon,		/* your bonus attributes (eg. str) */
399 			amax,		/* your max attributes (eg. str) */
400 			atemp,		/* used for temporary loss/gain */
401 			atime;		/* used for loss/gain countdown */
402 	align	ualign;			/* character alignment */
403 #define CONVERT		2
404 #define A_ORIGINAL	1
405 #define A_CURRENT	0
406 	aligntyp ualignbase[CONVERT];	/* for ualign conversion record */
407 	schar uluck, moreluck;		/* luck and luck bonus */
408 	int luckturn;
409 #define Luck	(u.uluck + u.moreluck)
410 #define LUCKADD		3	/* added value when carrying luck stone */
411 #define LUCKMAX		10	/* on moonlit nights 11 */
412 #define LUCKMIN		(-10)
413 	schar	uhitinc;
414 	schar	udaminc;
415 	schar	uac;
416 	uchar	uspellprot;		/* protection by SPE_PROTECTION */
417 	uchar	usptime;		/* #moves until uspellprot-- */
418 	uchar	uspmtime;		/* #moves between uspellprot-- */
419 	int	uhp,uhpmax;
420 	int	uen, uenmax;		/* magical energy - M. Stephenson */
421 	int ugangr;			/* if the gods are angry at you */
422 	int ugifts;			/* number of artifacts bestowed */
423 	int ublessed, ublesscnt;	/* blessing/duration from #pray */
424 #ifndef GOLDOBJ
425 	long	ugold, ugold0;
426 #else
427 	long	umoney0;
428 #endif
429 	long	uexp, urexp;
430 	long	urscore;	/**< the current score */
431 	long	ucleansed;	/* to record moves when player was cleansed */
432 	long	usleep;		/* sleeping; monstermove you last started */
433 	int uinvault;
434 	struct monst *ustuck;
435 #ifdef STEED
436 	struct monst *usteed;
437 	long ugallop;
438 	int urideturns;
439 #endif
440 	int	umortality;		/* how many times you died */
441 	int ugrave_arise; /* you die and become something aside from a ghost */
442 	time_t	ubirthday;		/* real world time when game began */
443 	time_t	udeathday;		/* real world time when game ended */
444 
445 	int	weapon_slots;		/* unused skill slots */
446 	int	skills_advanced;		/* # of advances made so far */
447 	xchar	skill_record[P_SKILL_LIMIT];	/* skill advancements */
448 	struct skills weapon_skills[P_NUM_SKILLS];
449 	boolean twoweap;		/* KMH -- Using two-weapon combat */
450 
451 };	/* end of `struct you' */
452 
453 #define Upolyd (u.umonnum != u.umonster)
454 
455 #endif	/* YOU_H */
456