OSDN Git Service

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