1 /* NetHack 3.7	you.h	$NHDT-Date: 1596498576 2020/08/03 23:49:36 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.48 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2016. */
4 /* NetHack may be freely redistributed.  See license for details. */
5 
6 #ifndef YOU_H
7 #define YOU_H
8 
9 #include "attrib.h"
10 #include "monst.h"
11 #ifndef PROP_H
12 #include "prop.h" /* (needed here for util/makedefs.c) */
13 #endif
14 #include "skills.h"
15 
16 /*** Substructures ***/
17 
18 struct RoleName {
19     const char *m; /* name when character is male */
20     const char *f; /* when female; null if same as male */
21 };
22 
23 struct RoleAdvance {
24     /* "fix" is the fixed amount, "rnd" is the random amount */
25     xchar infix, inrnd; /* at character initialization */
26     xchar lofix, lornd; /* gained per level <  xlvl 12 */
27     xchar hifix, hirnd; /* gained per level >= xlvl 12 */
28 };
29 /* determines at which level lofix, lornd cease to be used and hifix, hirnd
30  * start to be used */
31 #define ROLE_XLEV_CUTOFF 12
32 
33 struct u_have {
34     Bitfield(amulet, 1);   /* carrying Amulet   */
35     Bitfield(bell, 1);     /* carrying Bell     */
36     Bitfield(book, 1);     /* carrying Book     */
37     Bitfield(menorah, 1);  /* carrying Candelabrum */
38     Bitfield(questart, 1); /* carrying the Quest Artifact */
39     Bitfield(unused, 3);
40 };
41 
42 struct u_event {
43     Bitfield(minor_oracle, 1); /* received at least 1 cheap oracle */
44     Bitfield(major_oracle, 1); /*  "  expensive oracle */
45     Bitfield(read_tribute, 1); /* read a passage from a novel */
46     Bitfield(qcalled, 1);      /* called by Quest leader to do task */
47     Bitfield(qexpelled, 1);    /* expelled from the Quest dungeon */
48     Bitfield(qcompleted, 1);   /* successfully completed Quest task */
49     Bitfield(uheard_tune, 2);  /* 1=know about, 2=heard passtune */
50 
51     Bitfield(uopened_dbridge, 1);   /* opened the drawbridge */
52     Bitfield(invoked, 1);           /* invoked Gate to the Sanctum level */
53     Bitfield(gehennom_entered, 1);  /* entered Gehennom via Valley */
54     Bitfield(uhand_of_elbereth, 2); /* became Hand of Elbereth */
55     Bitfield(udemigod, 1);          /* killed the wiz */
56     Bitfield(uvibrated, 1);         /* stepped on "vibrating square" */
57     Bitfield(ascended, 1);          /* has offered the Amulet */
58 };
59 
60 /*
61  * Achievements:  milestones reached during the current game.
62  * Numerical order of these matters because they've been encoded in
63  * a bitmask in xlogfile.  Reordering would break decoding that.
64  * Aside from that, the number isn't significant--they're recorded
65  * and eventually disclosed in the order achieved.
66  *
67  * Since xlogfile could be post-processed by unknown tools, we should
68  * limit these to 31 total (it's possible that 32-bit signed longs are
69  * the best such tools can offer).  Eventually that is likely to need
70  * to change, probably by giving xlogfile an achieve2 field rather
71  * than by assuming that 64-bit longs are viable or by squeezing in a
72  * 32nd entry by switching to unsigned long.
73  */
74 enum achivements {
75     ACH_BELL =  1, /* acquired Bell of Opening */
76     ACH_HELL =  2, /* entered Gehennom */
77     ACH_CNDL =  3, /* acquired Candelabrum of Invocation */
78     ACH_BOOK =  4, /* acquired Book of the Dead */
79     ACH_INVK =  5, /* performed invocation to gain access to Sanctum */
80     ACH_AMUL =  6, /* acquired The Amulet */
81     ACH_ENDG =  7, /* entered end game */
82     ACH_ASTR =  8, /* entered Astral Plane */
83     ACH_UWIN =  9, /* ascended */
84     ACH_MINE_PRIZE = 10, /* acquired Mines' End luckstone */
85     ACH_SOKO_PRIZE = 11, /* acquired Sokoban bag or amulet */
86     ACH_MEDU = 12, /* killed Medusa */
87     ACH_BLND = 13, /* hero was always blind */
88     ACH_NUDE = 14, /* hero never wore armor */
89     /* 1 through 14 were present in 3.6.x; the rest are newer; first,
90        some easier ones so less skilled players can have achievements */
91     ACH_MINE = 15, /* entered Gnomish Mines */
92     ACH_TOWN = 16, /* reached Minetown */
93     ACH_SHOP = 17, /* entered a shop */
94     ACH_TMPL = 18, /* entered a temple */
95     ACH_ORCL = 19, /* consulted the Oracle */
96     ACH_NOVL = 20, /* read at least one passage from a Discworld novel */
97     ACH_SOKO = 21, /* entered Sokoban */
98     ACH_BGRM = 22, /* entered Bigroom (not guaranteed to be in every dgn) */
99     /* role's rank titles, beyond first (#0 at level one, not an achievement);
100        23..30 are negated if hero is female at the time new rank is gained
101        so that disclosing them can use the gender which applied at the time */
102     ACH_RNK1 = 23, ACH_RNK2 = 24, ACH_RNK3 = 25, ACH_RNK4 = 26,
103     ACH_RNK5 = 27, ACH_RNK6 = 28, ACH_RNK7 = 29, ACH_RNK8 = 30,
104     /* foo=31, 1 available potential achievement; #32 currently off-limits */
105     N_ACH = 32     /* allocate room for 31 plus a slot for 0 terminator */
106 };
107     /*
108      * Other potential achievements to track (this comment briefly resided
109      * in encodeachieve(topten.c) and has been revised since moving here:
110      *  AC <= 0, AC <= -10, AC <= -20 (stop there; lower is better but
111      *    not something to encourage with achievements),
112      *  got quest summons,
113      *  entered quest branch,
114      *  chatted with leader,
115      *  entered second or lower quest level (implies leader gave the Ok),
116      *  entered last quest level,
117      *  defeated nemesis (not same as acquiring Bell or artifact),
118      *  completed quest (formally, by bringing artifact to leader),
119      *  entered rogue level,
120      *  entered Fort Ludios level/branch (not guaranteed to be achieveable),
121      *  entered Medusa level,
122      *  entered castle level,
123      *  opened castle drawbridge,
124      *  obtained castle wand (handle similarly to mines and sokoban prizes),
125      *  passed Valley level (entered-Gehennom already covers Valley itself),
126      *  [assorted demon lairs?],
127      *  entered Vlad's tower branch,
128      *  defeated Vlad (not same as acquiring Candelabrum),
129      *  entered Wizard's tower area within relevant level,
130      *  defeated Wizard,
131      *  found vibrating square,
132      *  entered sanctum level (maybe not; too close to performed-invocation),
133      *  [defeated Famine, defeated Pestilence, defeated Death]
134      */
135 
136 struct u_realtime {
137     long   realtime;     /* accumulated playing time in seconds */
138     time_t start_timing; /* time game was started or restored or 'realtime'
139                             was last updated (savegamestate for checkpoint) */
140     time_t finish_time;  /* end of 'realtime' interval: time of save or
141                             end of game; used for topten/logfile/xlogfile */
142 };
143 
144 /* KMH, conduct --
145  * These are voluntary challenges.  Each field denotes the number of
146  * times a challenge has been violated.
147  */
148 struct u_conduct {     /* number of times... */
149     long unvegetarian; /* eaten any animal */
150     long unvegan;      /* ... or any animal byproduct */
151     long food;         /* ... or any comestible */
152     long gnostic;      /* used prayer, priest, or altar */
153     long weaphit;      /* hit a monster with a weapon */
154     long killer;       /* killed a monster yourself */
155     long literate;     /* read something (other than BotD) */
156     long polypiles;    /* polymorphed an object */
157     long polyselfs;    /* transformed yourself */
158     long wishes;       /* used a wish */
159     long wisharti;     /* wished for an artifact */
160     long artitouch;    /* touched an artifact in any way */
161     long pets;         /* obtained a pet */
162     long scares;       /* scared a monster by standing in a certain spot */
163     long uncelibate;   /* interacted with a foocubus */
164     long conflicting;  /* generated conflict */
165     long sokocheat;    /* violated special 'rules' in Sokoban */
166     /* genocides already listed at end of game */
167 };
168 
169 struct u_roleplay {
170     boolean blind;  /* permanently blind */
171     boolean nudist; /* has not worn any armor, ever */
172     boolean hallu;  /* permanently hallucinating */
173     boolean deaf;   /* permanently deaf */
174     long numbones;  /* # of bones files loaded  */
175 };
176 
177 /*** Unified structure containing role information ***/
178 struct Role {
179     /*** Strings that name various things ***/
180     struct RoleName name;    /* the role's name (from u_init.c) */
181     struct RoleName rank[9]; /* names for experience levels (from botl.c) */
182     const char *lgod, *ngod, *cgod; /* god names (from pray.c) */
183     const char *filecode;           /* abbreviation for use in file names */
184     const char *homebase; /* quest leader's location (from questpgr.c) */
185     const char *intermed; /* quest intermediate goal (from questpgr.c) */
186 
187     /*** Indices of important monsters and objects ***/
188     short malenum, /* index (PM_) as a male (botl.c) */
189         femalenum, /* ...or as a female (NON_PM == same) */
190         petnum,    /* PM_ of preferred pet (NON_PM == random) */
191         ldrnum,    /* PM_ of quest leader (questpgr.c) */
192         guardnum,  /* PM_ of quest guardians (questpgr.c) */
193         neminum,   /* PM_ of quest nemesis (questpgr.c) */
194         enemy1num, /* specific quest enemies (NON_PM == random) */
195         enemy2num;
196     char enemy1sym, /* quest enemies by class (S_) */
197         enemy2sym;
198     short questarti; /* index (ART_) of quest artifact (questpgr.c) */
199 
200     /*** Bitmasks ***/
201     short allow;                  /* bit mask of allowed variations */
202 #define ROLE_RACEMASK  0x0ff8     /* allowable races */
203 #define ROLE_GENDMASK  0xf000     /* allowable genders */
204 #define ROLE_MALE      0x1000
205 #define ROLE_FEMALE    0x2000
206 #define ROLE_NEUTER    0x4000
207 #define ROLE_ALIGNMASK AM_MASK    /* allowable alignments */
208 #define ROLE_LAWFUL    AM_LAWFUL
209 #define ROLE_NEUTRAL   AM_NEUTRAL
210 #define ROLE_CHAOTIC   AM_CHAOTIC
211 
212     /*** Attributes (from attrib.c and exper.c) ***/
213     xchar attrbase[A_MAX];    /* lowest initial attributes */
214     xchar attrdist[A_MAX];    /* distribution of initial attributes */
215     struct RoleAdvance hpadv; /* hit point advancement */
216     struct RoleAdvance enadv; /* energy advancement */
217     xchar initrecord;         /* initial alignment record */
218 
219     /*** Spell statistics (from spell.c) ***/
220     int spelbase; /* base spellcasting bonus */
221 
222     /*** Properties in variable-length arrays ***/
223     /* intrinsics (see attrib.c) */
224     /* initial inventory (see u_init.c) */
225     /* skills (see u_init.c) */
226 
227     /*** Don't forget to add... ***/
228     /* quest leader, guardians, nemesis (monst.c) */
229     /* quest artifact (artilist.h) */
230     /* quest dungeon definition (dat/Xyz.dat) */
231     /* quest text (dat/quest.txt) */
232     /* dictionary entries (dat/data.bas) */
233 };
234 
235 extern const struct Role roles[]; /* table of available roles */
236 #define Role_if(X) (g.urole.malenum == (X))
237 #define Role_switch (g.urole.malenum)
238 
239 /* used during initialization for race, gender, and alignment
240    as well as for character class */
241 #define ROLE_NONE (-1)
242 #define ROLE_RANDOM (-2)
243 
244 /*** Unified structure specifying race information ***/
245 
246 struct Race {
247     /*** Strings that name various things ***/
248     const char *noun;           /* noun ("human", "elf") */
249     const char *adj;            /* adjective ("human", "elven") */
250     const char *coll;           /* collective ("humanity", "elvenkind") */
251     const char *filecode;       /* code for filenames */
252     struct RoleName individual; /* individual as a noun ("man", "elf") */
253 
254     /*** Indices of important monsters and objects ***/
255     short malenum, /* PM_ as a male monster */
256         femalenum, /* ...or as a female (NON_PM == same) */
257         mummynum,  /* PM_ as a mummy */
258         zombienum; /* PM_ as a zombie */
259 
260     /*** Bitmasks ***/
261     short allow;    /* bit mask of allowed variations */
262     short selfmask, /* your own race's bit mask */
263         lovemask,   /* bit mask of always peaceful */
264         hatemask;   /* bit mask of always hostile */
265 
266     /*** Attributes ***/
267     xchar attrmin[A_MAX];     /* minimum allowable attribute */
268     xchar attrmax[A_MAX];     /* maximum allowable attribute */
269     struct RoleAdvance hpadv; /* hit point advancement */
270     struct RoleAdvance enadv; /* energy advancement */
271 #if 0 /* DEFERRED */
272     int   nv_range;           /* night vision range */
273     int   xray_range;         /* X-ray vision range */
274 #endif
275 
276     /*** Properties in variable-length arrays ***/
277     /* intrinsics (see attrib.c) */
278 
279     /*** Don't forget to add... ***/
280     /* quest leader, guardians, nemesis (monst.c) */
281     /* quest dungeon definition (dat/Xyz.dat) */
282     /* quest text (dat/quest.txt) */
283     /* dictionary entries (dat/data.bas) */
284 };
285 
286 extern const struct Race races[]; /* Table of available races */
287 #define Race_if(X) (g.urace.malenum == (X))
288 #define Race_switch (g.urace.malenum)
289 
290 /*** Unified structure specifying gender information ***/
291 struct Gender {
292     const char *adj;      /* male/female/neuter */
293     const char *he;       /* he/she/it */
294     const char *him;      /* him/her/it */
295     const char *his;      /* his/her/its */
296     const char *filecode; /* file code */
297     short allow;          /* equivalent ROLE_ mask */
298 };
299 struct Orientation {
300     const char* adj;       /* gay/straight/bi */
301     const char* technical; /* homosexual/heterosexual/bisexual */
302     xchar mapping;         /* equivalent constant, e.g. ORIENT_STRAIGHT */
303 };
304 #define ROLE_GENDERS 2    /* number of permitted player genders
305                              increment to 3 if you allow neuter roles */
306 #define ROLE_ORIENTATIONS 3 /* number of defined player orientations */
307 
308 extern const struct Gender genders[]; /* table of available genders */
309 extern const struct Orientation orientations[]; /* table of available genders */
310 /* pronouns for the hero */
311 #define uhe()      (genders[flags.female ? 1 : 0].he)
312 #define uhim()     (genders[flags.female ? 1 : 0].him)
313 #define uhis()     (genders[flags.female ? 1 : 0].his)
314 /* pronoun_gender() flag masks */
315 #define PRONOUN_NORMAL 0 /* none of the below */
316 #define PRONOUN_NO_IT  1
317 #define PRONOUN_HALLU  2
318 /* corresponding pronouns for monsters; yields "it" when mtmp can't be seen */
319 #define mhe(mtmp)  (genders[pronoun_gender(mtmp, PRONOUN_HALLU)].he)
320 #define mhim(mtmp) (genders[pronoun_gender(mtmp, PRONOUN_HALLU)].him)
321 #define mhis(mtmp) (genders[pronoun_gender(mtmp, PRONOUN_HALLU)].his)
322 /* override "it" if reason is lack of visibility rather than neuter species */
323 #define noit_mhe(mtmp) \
324     (genders[pronoun_gender(mtmp, (PRONOUN_NO_IT | PRONOUN_HALLU))].he)
325 #define noit_mhim(mtmp) \
326     (genders[pronoun_gender(mtmp, (PRONOUN_NO_IT | PRONOUN_HALLU))].him)
327 #define noit_mhis(mtmp) \
328     (genders[pronoun_gender(mtmp, (PRONOUN_NO_IT | PRONOUN_HALLU))].his)
329 
330 /*** Unified structure specifying alignment information ***/
331 struct Align {
332     const char *noun;     /* law/balance/chaos */
333     const char *adj;      /* lawful/neutral/chaotic */
334     const char *filecode; /* file code */
335     short allow;          /* equivalent ROLE_ mask */
336     aligntyp value;       /* equivalent A_ value */
337 };
338 #define ROLE_ALIGNS 3     /* number of permitted player alignments */
339 
340 extern const struct Align aligns[]; /* table of available alignments */
341 
342 enum utraptypes {
343     TT_BEARTRAP   = 0,
344     TT_PIT        = 1,
345     TT_WEB        = 2,
346     TT_LAVA       = 3,
347     TT_INFLOOR    = 4,
348     TT_BURIEDBALL = 5
349 };
350 
351 enum utotypes {
352     UTOTYPE_NONE     = 0x00,
353     UTOTYPE_ATSTAIRS = 0x01,
354     UTOTYPE_FALLING  = 0x02,
355     UTOTYPE_PORTAL   = 0x04,
356     UTOTYPE_RMPORTAL = 0x10,  /* remove portal */
357     UTOTYPE_DEFERRED = 0x20   /* deferred_goto */
358 };
359 
360 /*** Information about the player ***/
361 struct you {
362     xchar ux, uy;       /* current map coordinates */
363     schar dx, dy, dz;   /* direction of move (or zap or ... ) */
364     schar di;           /* direction of FF */
365     xchar tx, ty;       /* destination of travel */
366     xchar ux0, uy0;     /* initial position FF */
367     d_level uz, uz0;    /* your level on this and the previous turn */
368     d_level utolev;     /* level monster teleported you to, or uz */
369     uchar utotype;      /* bitmask of goto_level() flags for utolev */
370     boolean umoved;     /* changed map location (post-move) */
371     int last_str_turn;  /* 0: none, 1: half turn, 2: full turn
372                            +: turn right, -: turn left */
373     int ulevel;         /* 1 to MAXULEV */
374     int ulevelmax;
375     unsigned utrap;     /* trap timeout */
376     unsigned utraptype; /* defined if utrap nonzero. one of utraptypes */
377     char urooms[5];         /* rooms (roomno + 3) occupied now */
378     char urooms0[5];        /* ditto, for previous position */
379     char uentered[5];       /* rooms (roomno + 3) entered this turn */
380     char ushops[5];         /* shop rooms (roomno + 3) occupied now */
381     char ushops0[5];        /* ditto, for previous position */
382     char ushops_entered[5]; /* ditto, shops entered this turn */
383     char ushops_left[5];    /* ditto, shops exited this turn */
384 
385     int uhunger;  /* refd only in eat.c and shk.c (also insight.c) */
386     unsigned uhs; /* hunger state - see eat.c */
387 
388     struct prop uprops[LAST_PROP + 1];
389 
390     unsigned umconf;
391     Bitfield(usick_type, 2);
392 #define SICK_VOMITABLE 0x01
393 #define SICK_NONVOMITABLE 0x02
394 #define SICK_ALL 0x03
395 
396     /* These ranges can never be more than MAX_RANGE (vision.h). */
397     int nv_range;   /* current night vision range */
398     int xray_range; /* current xray vision range */
399 
400 /*
401  * These variables are valid globally only when punished and blind.
402  */
403 #define BC_BALL 0x01  /* bit mask for ball  in 'bc_felt' below */
404 #define BC_CHAIN 0x02 /* bit mask for chain in 'bc_felt' below */
405     int bglyph;       /* glyph under the ball */
406     int cglyph;       /* glyph under the chain */
407     int bc_order;     /* ball & chain order [see bc_order() in ball.c] */
408     int bc_felt;      /* mask for ball/chain being felt */
409 
410     int umonster;               /* hero's "real" monster num */
411     int umonnum;                /* current monster number */
412 
413     int mh, mhmax, mtimedone;   /* for polymorph-self */
414     struct attribs macurr,      /* for monster attribs */
415                    mamax;       /* for monster attribs */
416     int ulycn;                  /* lycanthrope type */
417 
418     unsigned ucreamed;
419     unsigned uswldtim;          /* time you have been swallowed */
420 
421     Bitfield(uswallow, 1);      /* true if swallowed */
422     Bitfield(uinwater, 1);      /* if you're currently in water (only
423                                    underwater possible currently) */
424     Bitfield(uundetected, 1);   /* if you're a hiding monster/piercer */
425     Bitfield(mfemale, 1);       /* saved human value of flags.female */
426     Bitfield(uinvulnerable, 1); /* you're invulnerable (praying) */
427     Bitfield(uburied, 1);       /* you're buried */
428     Bitfield(uedibility, 1);    /* blessed food detect; sense unsafe food */
429     /* 1 free bit! */
430 
431     unsigned udg_cnt;           /* how long you have been demigod */
432     struct u_event uevent;      /* certain events have happened */
433     struct u_have uhave;        /* you're carrying special objects */
434     struct u_conduct uconduct;  /* KMH, conduct */
435     struct u_roleplay uroleplay;
436     struct attribs acurr,       /* your current attributes (eg. str)*/
437                     aexe,       /* for gain/loss via "exercise" */
438                     abon,       /* your bonus attributes (eg. str) */
439                     amax,       /* your max attributes (eg. str) */
440                    atemp,       /* used for temporary loss/gain */
441                    atime;       /* used for loss/gain countdown */
442     align ualign;               /* character alignment */
443 #define CONVERT    2
444 #define A_ORIGINAL 1
445 #define A_CURRENT  0
446     aligntyp ualignbase[CONVERT]; /* for ualign conversion record */
447     schar uluck, moreluck;        /* luck and luck bonus */
448     /* default u.uluck is 0 except on special days (full moon: +1, Fri 13: -1,
449        both: 0); equilibrium for luck timeout is changed to those values,
450        but Luck max and min stay at 10+3 and -10-3 even on those days */
451 #define Luck (u.uluck + u.moreluck)
452 #define LUCKADD    3  /* value of u.moreluck when carrying luck stone;
453                        * +3 when blessed or uncursed, -3 when cursed */
454 #define LUCKMAX   10  /* maximum value of u.uluck */
455 #define LUCKMIN (-10) /* minimum value of u.uluck */
456     schar uhitinc;
457     schar udaminc;
458     schar uac;
459 #define AC_MAX    99  /* abs(u.uac) <= 99; likewise for monster AC */
460     uchar uspellprot; /* protection by SPE_PROTECTION */
461     uchar usptime;    /* #moves until uspellprot-- */
462     uchar uspmtime;   /* #moves between uspellprot-- */
463     int uhp, uhpmax;
464     int uen, uenmax; /* magical energy - M. Stephenson */
465     xchar uhpinc[MAXULEV], ueninc[MAXULEV]; /* increases from level gain */
466     int ugangr;                             /* if the gods are angry at you */
467     int ugifts;                             /* number of artifacts bestowed */
468     int ublessed, ublesscnt;                /* blessing/duration from #pray */
469     long ulastprayed;                       /* the turn you last prayed */
470     long umoney0;
471     long uspare1;
472     long uexp, urexp;
473     long ucleansed;          /* to record moves when player was cleansed */
474     long usleep;             /* sleeping; monstermove you last started */
475     int uinvault;
476     struct monst *ustuck;    /* engulfer or grabber, maybe grabbee if Upolyd */
477     struct monst *usteed;    /* mount when riding */
478     long ugallop;            /* turns steed will run after being kicked */
479     int urideturns;          /* time spent riding, for skill advancement */
480     int umortality;          /* how many times you died */
481     int ugrave_arise;    /* you die and become something aside from a ghost */
482     int weapon_slots;        /* unused skill slots */
483     int skills_advanced;     /* # of advances made so far */
484     xchar skill_record[P_SKILL_LIMIT]; /* skill advancements */
485     struct skills weapon_skills[P_NUM_SKILLS];
486     boolean twoweap;         /* KMH -- Using two-weapon combat */
487     short mcham;             /* vampire mndx if shapeshifted to bat/cloud */
488     schar uachieved[N_ACH];  /* list of achievements in the order attained */
489 }; /* end of `struct you' */
490 
491 #define Upolyd (u.umonnum != u.umonster)
492 #define Ugender ((Upolyd ? u.mfemale : flags.female) ? 1 : 0)
493 #define Polyinit_mode (flags.polyinit_mnum != NON_PM)
494 
495 #endif /* YOU_H */
496