OSDN Git Service

fix #48255
[jnethack/source.git] / include / you.h
1 /* NetHack 3.6  you.h   $NHDT-Date: 1547514642 2019/01/15 01:10:42 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.35 $ */
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 <  urole.xlev */
27     xchar hifix, hirnd; /* gained per level >= urole.xlev */
28 };
29
30 struct u_have {
31     Bitfield(amulet, 1);   /* carrying Amulet   */
32     Bitfield(bell, 1);     /* carrying Bell     */
33     Bitfield(book, 1);     /* carrying Book     */
34     Bitfield(menorah, 1);  /* carrying Candelabrum */
35     Bitfield(questart, 1); /* carrying the Quest Artifact */
36     Bitfield(unused, 3);
37 };
38
39 struct u_event {
40     Bitfield(minor_oracle, 1); /* received at least 1 cheap oracle */
41     Bitfield(major_oracle, 1); /*  "  expensive oracle */
42     Bitfield(read_tribute, 1); /* read a passage from a novel */
43     Bitfield(qcalled, 1);      /* called by Quest leader to do task */
44     Bitfield(qexpelled, 1);    /* expelled from the Quest dungeon */
45     Bitfield(qcompleted, 1);   /* successfully completed Quest task */
46     Bitfield(uheard_tune, 2);  /* 1=know about, 2=heard passtune */
47
48     Bitfield(uopened_dbridge, 1);   /* opened the drawbridge */
49     Bitfield(invoked, 1);           /* invoked Gate to the Sanctum level */
50     Bitfield(gehennom_entered, 1);  /* entered Gehennom via Valley */
51     Bitfield(uhand_of_elbereth, 2); /* became Hand of Elbereth */
52     Bitfield(udemigod, 1);          /* killed the wiz */
53     Bitfield(uvibrated, 1);         /* stepped on "vibrating square" */
54     Bitfield(ascended, 1);          /* has offered the Amulet */
55 };
56
57 struct u_achieve {
58     Bitfield(amulet, 1);  /* touched Amulet */
59     Bitfield(bell, 1);    /* touched Bell */
60     Bitfield(book, 1);    /* touched Book */
61     Bitfield(menorah, 1); /* touched Candelabrum */
62     Bitfield(enter_gehennom,
63              1);           /* entered Gehennom (or Valley) by any means */
64     Bitfield(ascended, 1); /* not quite the same as u.uevent.ascended */
65     Bitfield(mines_luckstone, 1); /* got a luckstone at end of mines */
66     Bitfield(finish_sokoban, 1);  /* obtained the sokoban prize */
67
68     Bitfield(killed_medusa, 1);
69 };
70
71 struct u_realtime {
72     long   realtime;     /* accumulated playing time in seconds */
73     time_t start_timing; /* time game was started or restored or 'realtime'
74                             was last updated (savegamestate for checkpoint) */
75     time_t finish_time;  /* end of 'realtime' interval: time of save or
76                             end of game; used for topten/logfile/xlogfile */
77 };
78
79 /* KMH, conduct --
80  * These are voluntary challenges.  Each field denotes the number of
81  * times a challenge has been violated.
82  */
83 struct u_conduct {     /* number of times... */
84     long unvegetarian; /* eaten any animal */
85     long unvegan;      /* ... or any animal byproduct */
86     long food;         /* ... or any comestible */
87     long gnostic;      /* used prayer, priest, or altar */
88     long weaphit;      /* hit a monster with a weapon */
89     long killer;       /* killed a monster yourself */
90     long literate;     /* read something (other than BotD) */
91     long polypiles;    /* polymorphed an object */
92     long polyselfs;    /* transformed yourself */
93     long wishes;       /* used a wish */
94     long wisharti;     /* wished for an artifact */
95     /* genocides already listed at end of game */
96 };
97
98 struct u_roleplay {
99     boolean blind;  /* permanently blind */
100     boolean nudist; /* has not worn any armor, ever */
101     long numbones;  /* # of bones files loaded  */
102 };
103
104 /*** Unified structure containing role information ***/
105 struct Role {
106     /*** Strings that name various things ***/
107 #if 1 /*JP*/
108     struct RoleName opt;     /* \83I\83v\83V\83\87\83\93\8ew\92è\95\8e\9a\97ñ */
109 #endif
110     struct RoleName name;    /* the role's name (from u_init.c) */
111     struct RoleName rank[9]; /* names for experience levels (from botl.c) */
112     const char *lgod, *ngod, *cgod; /* god names (from pray.c) */
113     const char *filecode;           /* abbreviation for use in file names */
114     const char *homebase; /* quest leader's location (from questpgr.c) */
115     const char *intermed; /* quest intermediate goal (from questpgr.c) */
116
117     /*** Indices of important monsters and objects ***/
118     short malenum, /* index (PM_) as a male (botl.c) */
119         femalenum, /* ...or as a female (NON_PM == same) */
120         petnum,    /* PM_ of preferred pet (NON_PM == random) */
121         ldrnum,    /* PM_ of quest leader (questpgr.c) */
122         guardnum,  /* PM_ of quest guardians (questpgr.c) */
123         neminum,   /* PM_ of quest nemesis (questpgr.c) */
124         enemy1num, /* specific quest enemies (NON_PM == random) */
125         enemy2num;
126     char enemy1sym, /* quest enemies by class (S_) */
127         enemy2sym;
128     short questarti; /* index (ART_) of quest artifact (questpgr.c) */
129
130     /*** Bitmasks ***/
131     short allow;                  /* bit mask of allowed variations */
132 #define ROLE_RACEMASK  0x0ff8     /* allowable races */
133 #define ROLE_GENDMASK  0xf000     /* allowable genders */
134 #define ROLE_MALE      0x1000
135 #define ROLE_FEMALE    0x2000
136 #define ROLE_NEUTER    0x4000
137 #define ROLE_ALIGNMASK AM_MASK    /* allowable alignments */
138 #define ROLE_LAWFUL    AM_LAWFUL
139 #define ROLE_NEUTRAL   AM_NEUTRAL
140 #define ROLE_CHAOTIC   AM_CHAOTIC
141
142     /*** Attributes (from attrib.c and exper.c) ***/
143     xchar attrbase[A_MAX];    /* lowest initial attributes */
144     xchar attrdist[A_MAX];    /* distribution of initial attributes */
145     struct RoleAdvance hpadv; /* hit point advancement */
146     struct RoleAdvance enadv; /* energy advancement */
147     xchar xlev;               /* cutoff experience level */
148     xchar initrecord;         /* initial alignment record */
149
150     /*** Spell statistics (from spell.c) ***/
151     int spelbase; /* base spellcasting penalty */
152     int spelheal; /* penalty (-bonus) for healing spells */
153     int spelshld; /* penalty for wearing any shield */
154     int spelarmr; /* penalty for wearing metal armour */
155     int spelstat; /* which stat (A_) is used */
156     int spelspec; /* spell (SPE_) the class excels at */
157     int spelsbon; /* penalty (-bonus) for that spell */
158
159     /*** Properties in variable-length arrays ***/
160     /* intrinsics (see attrib.c) */
161     /* initial inventory (see u_init.c) */
162     /* skills (see u_init.c) */
163
164     /*** Don't forget to add... ***/
165     /* quest leader, guardians, nemesis (monst.c) */
166     /* quest artifact (artilist.h) */
167     /* quest dungeon definition (dat/Xyz.dat) */
168     /* quest text (dat/quest.txt) */
169     /* dictionary entries (dat/data.bas) */
170 };
171
172 extern const struct Role roles[]; /* table of available roles */
173 extern struct Role urole;
174 #define Role_if(X) (urole.malenum == (X))
175 #define Role_switch (urole.malenum)
176
177 /* used during initialization for race, gender, and alignment
178    as well as for character class */
179 #define ROLE_NONE (-1)
180 #define ROLE_RANDOM (-2)
181
182 /*** Unified structure specifying race information ***/
183
184 struct Race {
185     /*** Strings that name various things ***/
186 #if 1 /*JP*/
187     const char *opt;      /* \83I\83v\83V\83\87\83\93\8ew\92è\95\8e\9a\97ñ */
188 #endif
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 #if 1 /*JP*/
240     const char *opt;      /* \83I\83v\83V\83\87\83\93\8ew\92è\95\8e\9a\97ñ */
241 #endif
242     short allow;          /* equivalent ROLE_ mask */
243 };
244 #define ROLE_GENDERS 2    /* number of permitted player genders
245                              increment to 3 if you allow neuter roles */
246
247 extern const struct Gender genders[]; /* table of available genders */
248 /* pronouns for the hero */
249 #define uhe()      (genders[flags.female ? 1 : 0].he)
250 #define uhim()     (genders[flags.female ? 1 : 0].him)
251 #define uhis()     (genders[flags.female ? 1 : 0].his)
252 /* corresponding pronouns for monsters; yields "it" when mtmp can't be seen */
253 #define mhe(mtmp)  (genders[pronoun_gender(mtmp, FALSE)].he)
254 #define mhim(mtmp) (genders[pronoun_gender(mtmp, FALSE)].him)
255 #define mhis(mtmp) (genders[pronoun_gender(mtmp, FALSE)].his)
256 /* override "it" if reason is lack of visibility rather than neuter species */
257 #define noit_mhe(mtmp)  (genders[pronoun_gender(mtmp, TRUE)].he)
258 #define noit_mhim(mtmp) (genders[pronoun_gender(mtmp, TRUE)].him)
259 #define noit_mhis(mtmp) (genders[pronoun_gender(mtmp, TRUE)].his)
260
261 /*** Unified structure specifying alignment information ***/
262 struct Align {
263     const char *noun;     /* law/balance/chaos */
264     const char *adj;      /* lawful/neutral/chaotic */
265     const char *filecode; /* file code */
266 #if 1 /*JP*/
267     const char *opt;      /* \83I\83v\83V\83\87\83\93\8ew\92è\95\8e\9a\97ñ */
268 #endif
269     short allow;          /* equivalent ROLE_ mask */
270     aligntyp value;       /* equivalent A_ value */
271 };
272 #define ROLE_ALIGNS 3     /* number of permitted player alignments */
273
274 extern const struct Align aligns[]; /* table of available alignments */
275
276 enum utraptypes {
277     TT_BEARTRAP   = 0,
278     TT_PIT        = 1,
279     TT_WEB        = 2,
280     TT_LAVA       = 3,
281     TT_INFLOOR    = 4,
282     TT_BURIEDBALL = 5
283 };
284
285 /*** Information about the player ***/
286 struct you {
287     xchar ux, uy;       /* current map coordinates */
288     schar dx, dy, dz;   /* direction of move (or zap or ... ) */
289     schar di;           /* direction of FF */
290     xchar tx, ty;       /* destination of travel */
291     xchar ux0, uy0;     /* initial position FF */
292     d_level uz, uz0;    /* your level on this and the previous turn */
293     d_level utolev;     /* level monster teleported you to, or uz */
294     uchar utotype;      /* bitmask of goto_level() flags for utolev */
295     boolean umoved;     /* changed map location (post-move) */
296     int last_str_turn;  /* 0: none, 1: half turn, 2: full turn
297                            +: turn right, -: turn left */
298     int ulevel;         /* 1 to MAXULEV */
299     int ulevelmax;
300     unsigned utrap;     /* trap timeout */
301     unsigned utraptype; /* defined if utrap nonzero. one of utraptypes */
302     char urooms[5];         /* rooms (roomno + 3) occupied now */
303     char urooms0[5];        /* ditto, for previous position */
304     char uentered[5];       /* rooms (roomno + 3) entered this turn */
305     char ushops[5];         /* shop rooms (roomno + 3) occupied now */
306     char ushops0[5];        /* ditto, for previous position */
307     char ushops_entered[5]; /* ditto, shops entered this turn */
308     char ushops_left[5];    /* ditto, shops exited this turn */
309
310     int uhunger;  /* refd only in eat.c and shk.c */
311     unsigned uhs; /* hunger state - see eat.c */
312
313     struct prop uprops[LAST_PROP + 1];
314
315     unsigned umconf;
316     Bitfield(usick_type, 2);
317 #define SICK_VOMITABLE 0x01
318 #define SICK_NONVOMITABLE 0x02
319 #define SICK_ALL 0x03
320
321     /* These ranges can never be more than MAX_RANGE (vision.h). */
322     int nv_range;   /* current night vision range */
323     int xray_range; /* current xray vision range */
324
325 /*
326  * These variables are valid globally only when punished and blind.
327  */
328 #define BC_BALL 0x01  /* bit mask for ball  in 'bc_felt' below */
329 #define BC_CHAIN 0x02 /* bit mask for chain in 'bc_felt' below */
330     int bglyph;       /* glyph under the ball */
331     int cglyph;       /* glyph under the chain */
332     int bc_order;     /* ball & chain order [see bc_order() in ball.c] */
333     int bc_felt;      /* mask for ball/chain being felt */
334
335     int umonster;               /* hero's "real" monster num */
336     int umonnum;                /* current monster number */
337
338     int mh, mhmax, mtimedone;   /* for polymorph-self */
339     struct attribs macurr,      /* for monster attribs */
340                    mamax;       /* for monster attribs */
341     int ulycn;                  /* lycanthrope type */
342
343     unsigned ucreamed;
344     unsigned uswldtim;          /* time you have been swallowed */
345
346     Bitfield(uswallow, 1);      /* true if swallowed */
347     Bitfield(uinwater, 1);      /* if you're currently in water (only
348                                    underwater possible currently) */
349     Bitfield(uundetected, 1);   /* if you're a hiding monster/piercer */
350     Bitfield(mfemale, 1);       /* saved human value of flags.female */
351     Bitfield(uinvulnerable, 1); /* you're invulnerable (praying) */
352     Bitfield(uburied, 1);       /* you're buried */
353     Bitfield(uedibility, 1);    /* blessed food detect; sense unsafe food */
354     /* 1 free bit! */
355
356     unsigned udg_cnt;           /* how long you have been demigod */
357     struct u_achieve uachieve;  /* achievements */
358     struct u_event uevent;      /* certain events have happened */
359     struct u_have uhave;        /* you're carrying special objects */
360     struct u_conduct uconduct;  /* KMH, conduct */
361     struct u_roleplay uroleplay;
362     struct attribs acurr,       /* your current attributes (eg. str)*/
363                     aexe,       /* for gain/loss via "exercise" */
364                     abon,       /* your bonus attributes (eg. str) */
365                     amax,       /* your max attributes (eg. str) */
366                    atemp,       /* used for temporary loss/gain */
367                    atime;       /* used for loss/gain countdown */
368     align ualign;               /* character alignment */
369 #define CONVERT    2
370 #define A_ORIGINAL 1
371 #define A_CURRENT  0
372     aligntyp ualignbase[CONVERT]; /* for ualign conversion record */
373     schar uluck, moreluck;        /* luck and luck bonus */
374 #define Luck (u.uluck + u.moreluck)
375 #define LUCKADD    3  /* value of u.moreluck when carrying luck stone;
376                          + when blessed or uncursed, - when cursed */
377 #define LUCKMAX   10  /* maximum value of u.ulUck */
378 #define LUCKMIN (-10) /* minimum value of u.uluck */
379     schar uhitinc;
380     schar udaminc;
381     schar uac;
382     uchar uspellprot;        /* protection by SPE_PROTECTION */
383     uchar usptime;           /* #moves until uspellprot-- */
384     uchar uspmtime;          /* #moves between uspellprot-- */
385     int uhp, uhpmax;         /* hit points, aka health */
386     int uen, uenmax;         /* magical energy - M. Stephenson */
387     xchar uhpinc[MAXULEV],   /* increases to uhpmax for each level gain */
388           ueninc[MAXULEV];   /* increases to uenmax for each level gain */
389     int ugangr;              /* if the gods are angry at you */
390     int ugifts;              /* number of artifacts bestowed */
391     int ublessed, ublesscnt; /* blessing/duration from #pray */
392     long umoney0;
393     long uspare1;
394     long uexp, urexp;
395     long ucleansed;          /* to record moves when player was cleansed */
396     long usleep;             /* sleeping; monstermove you last started */
397     int uinvault;
398     struct monst *ustuck;    /* engulfer or grabber, maybe grabbee if Upolyd */
399     struct monst *usteed;    /* mount when riding */
400     long ugallop;            /* turns steed will run after being kicked */
401     int urideturns;          /* time spent riding, for skill advancement */
402     int umortality;          /* how many times you died */
403     int ugrave_arise;    /* you die and become something aside from a ghost */
404     int weapon_slots;        /* unused skill slots */
405     int skills_advanced;     /* # of advances made so far */
406     xchar skill_record[P_SKILL_LIMIT]; /* skill advancements */
407     struct skills weapon_skills[P_NUM_SKILLS];
408     boolean twoweap;         /* KMH -- Using two-weapon combat */
409
410 }; /* end of `struct you' */
411
412 #define Upolyd (u.umonnum != u.umonster)
413
414 #endif /* YOU_H */