OSDN Git Service

upgrade to 3.6.1
[jnethack/source.git] / include / mextra.h
1 /* NetHack 3.6  mextra.h        $NHDT-Date: 1451836000 2016/01/03 15:46:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.18 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Michael Allison, 2006. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 #ifndef MEXTRA_H
7 #define MEXTRA_H
8
9 #ifndef ALIGN_H
10 #include "align.h"
11 #endif
12
13 /*
14  *  Adding new mextra structures:
15  *
16  *       1. Add the structure definition and any required macros in this
17  *          file above the mextra struct.
18  *       2. Add a pointer to your new struct to the mextra struct in this
19  *          file.
20  *       3. Add a referencing macro at bottom of this file after the mextra
21  *          struct (see MNAME, EGD, EPRI, ESHK, EMIN, or EDOG for examples).
22  *       4. Create a newXX(mtmp) function and possibly a free_XX(mtmp)
23  *          function in an appropriate new or existing source file and add
24  *          a prototype for it to include/extern.h.
25  *
26  *              void FDECL(newXX, (struct monst *));
27  *              void FDECL(free_XX, (struct monst *));
28  *
29  *              void
30  *              newXX(mtmp)
31  *              struct monst *mtmp;
32  *              {
33  *                  if (!mtmp->mextra)
34  *                      mtmp->mextra = newmextra();
35  *                  if (!XX(mtmp)) {
36  *                      XX(mtmp) = (struct XX *) alloc(sizeof (struct XX));
37  *                      (void) memset((genericptr_t) XX(mtmp),
38  *                                    0, sizeof (struct XX));
39  *                  }
40  *              }
41  *
42  *       5. Consider adding a new makemon flag MM_XX flag to include/hack.h
43  *          and a corresponding change to makemon() if you require your
44  *          structure to be added at monster creation time.  Initialize your
45  *          struct after a successful return from makemon().
46  *
47  *              src/makemon.c:  if (mmflags & MM_XX) newXX(mtmp);
48  *              your new code:  mon = makemon(&mons[mnum], x, y, MM_XX);
49  *
50  *       6. Adjust size_monst() in src/cmd.c appropriately.
51  *       7. Adjust dealloc_mextra() in src/mon.c to clean up
52  *          properly during monst deallocation.
53  *       8. Adjust copy_mextra() in src/mon.c to make duplicate
54  *          copies of your struct or data on another monst struct.
55  *       9. Adjust restmon() in src/restore.c to deal with your
56  *          struct or data during a restore.
57  *      10. Adjust savemon() in src/save.c to deal with your
58  *          struct or data during a save.
59  */
60
61 /***
62  **     formerly vault.h -- vault guard extension
63  */
64 #define FCSIZ (ROWNO + COLNO)
65 #define GD_EATGOLD 0x01
66 #define GD_DESTROYGOLD 0x02
67
68 struct fakecorridor {
69     xchar fx, fy, ftyp;
70 };
71
72 struct egd {
73     int fcbeg, fcend;     /* fcend: first unused pos */
74     int vroom;            /* room number of the vault */
75     xchar gdx, gdy;       /* goal of guard's walk */
76     xchar ogx, ogy;       /* guard's last position */
77     d_level gdlevel;      /* level (& dungeon) guard was created in */
78     xchar warncnt;        /* number of warnings to follow */
79     Bitfield(gddone, 1);  /* true iff guard has released player */
80     Bitfield(witness, 2); /* the guard saw you do something */
81     Bitfield(unused, 5);
82     struct fakecorridor fakecorr[FCSIZ];
83 };
84
85 /***
86  **     formerly epri.h -- temple priest extension
87  */
88 struct epri {
89     aligntyp shralign; /* alignment of priest's shrine */
90     schar shroom;      /* index in rooms */
91     coord shrpos;      /* position of shrine */
92     d_level shrlevel;  /* level (& dungeon) of shrine */
93     long intone_time,  /* used to limit verbosity  +*/
94         enter_time,    /*+ of temple entry messages */
95         hostile_time,  /* forbidding feeling */
96         peaceful_time; /* sense of peace */
97 };
98 /* note: roaming priests (no shrine) switch from ispriest to isminion
99    (and emin extension) */
100
101 /***
102  **     formerly eshk.h -- shopkeeper extension
103  */
104 #define REPAIR_DELAY 5 /* minimum delay between shop damage & repair */
105 #define BILLSZ 200
106
107 struct bill_x {
108     unsigned bo_id;
109     boolean useup;
110     long price; /* price per unit */
111     long bquan; /* amount used up */
112 };
113
114 struct eshk {
115     long robbed;          /* amount stolen by most recent customer */
116     long credit;          /* amount credited to customer */
117     long debit;           /* amount of debt for using unpaid items */
118     long loan;            /* shop-gold picked (part of debit) */
119     int shoptype;         /* the value of rooms[shoproom].rtype */
120     schar shoproom;       /* index in rooms; set by inshop() */
121     schar unused;         /* to force alignment for stupid compilers */
122     boolean following;    /* following customer since he owes us sth */
123     boolean surcharge;    /* angry shk inflates prices */
124     boolean dismiss_kops; /* pacified shk sends kops away */
125     coord shk;            /* usual position shopkeeper */
126     coord shd;            /* position shop door */
127     d_level shoplevel;    /* level (& dungeon) of his shop */
128     int billct;           /* no. of entries of bill[] in use */
129     struct bill_x bill[BILLSZ];
130     struct bill_x *bill_p;
131     int visitct;            /* nr of visits by most recent customer */
132     char customer[PL_NSIZ]; /* most recent customer */
133     char shknam[PL_NSIZ];
134 };
135
136 /***
137  **     formerly emin.h -- minion extension
138  */
139 struct emin {
140     aligntyp min_align; /* alignment of minion */
141     boolean renegade;   /* hostile co-aligned priest or Angel */
142 };
143
144 /***
145  **     formerly edog.h -- pet extension
146  */
147 /*      various types of pet food, the lower, the better liked */
148 enum dogfood_types {
149     DOGFOOD = 0,
150     CADAVER,
151     ACCFOOD,
152     MANFOOD,
153     APPORT,
154     POISON,
155     UNDEF,
156     TABU
157 };
158
159 struct edog {
160     long droptime;            /* moment dog dropped object */
161     unsigned dropdist;        /* dist of dropped obj from @ */
162     int apport;               /* amount of training */
163     long whistletime;         /* last time he whistled */
164     long hungrytime;          /* will get hungry at this time */
165     coord ogoal;              /* previous goal location */
166     int abuse;                /* track abuses to this pet */
167     int revivals;             /* count pet deaths */
168     int mhpmax_penalty;       /* while starving, points reduced */
169     Bitfield(killed_by_u, 1); /* you attempted to kill him */
170 };
171
172 /***
173  **     mextra.h -- collection of all monster extensions
174  */
175 struct mextra {
176     char *mname;
177     struct egd *egd;
178     struct epri *epri;
179     struct eshk *eshk;
180     struct emin *emin;
181     struct edog *edog;
182     int mcorpsenm; /* obj->corpsenm for mimic posing as statue or corpse */
183 };
184
185 #define MNAME(mon) ((mon)->mextra->mname)
186 #define EGD(mon) ((mon)->mextra->egd)
187 #define EPRI(mon) ((mon)->mextra->epri)
188 #define ESHK(mon) ((mon)->mextra->eshk)
189 #define EMIN(mon) ((mon)->mextra->emin)
190 #define EDOG(mon) ((mon)->mextra->edog)
191 #define MCORPSENM(mon) ((mon)->mextra->mcorpsenm)
192
193 #define has_mname(mon) ((mon)->mextra && MNAME(mon))
194 #define has_egd(mon)   ((mon)->mextra && EGD(mon))
195 #define has_epri(mon)  ((mon)->mextra && EPRI(mon))
196 #define has_eshk(mon)  ((mon)->mextra && ESHK(mon))
197 #define has_emin(mon)  ((mon)->mextra && EMIN(mon))
198 #define has_edog(mon)  ((mon)->mextra && EDOG(mon))
199 #define has_mcorpsenm(mon) ((mon)->mextra && MCORPSENM(mon) != NON_PM)
200
201 #endif /* MEXTRA_H */