Source:NetHack 5.0.0/include/mextra.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to mextra.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/mextra.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	mextra.h	$NHDT-Date: 1720717969 2024/07/11 17:12:49 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.40 $ */
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 MGIVENNAME, EGD, EPRI, ESHK, EMIN, or EDOG for
22.  *          examples).
23.  *       4. If your new field isn't a pointer and requires a non-zero value
24.  *          on initialization, add code to init_mextra() in src/makemon.c
25.  *       5. Create a newXX(mtmp) function and possibly a free_XX(mtmp)
26.  *          function in an appropriate new or existing source file and add
27.  *          a prototype for it to include/extern.h.
28.  *
29.  *              void newXX(struct monst *);
30.  *              void free_XX(struct monst *);
31.  *
32.  *              void
33.  *              newXX(mtmp)
34.  *              struct monst *mtmp;
35.  *              {
36.  *                  if (!mtmp->mextra)
37.  *                      mtmp->mextra = newmextra();
38.  *                  if (!XX(mtmp)) {
39.  *                      XX(mtmp) = (struct XX *) alloc(sizeof (struct XX));
40.  *                      (void) memset((genericptr_t) XX(mtmp),
41.  *                                    0, sizeof (struct XX));
42.  *                  }
43.  *              }
44.  *
45.  *       6. Consider adding a new makemon flag MM_XX flag to include/hack.h
46.  *          and a corresponding change to makemon() if you require your
47.  *          structure to be added at monster creation time.  Initialize your
48.  *          struct after a successful return from makemon().
49.  *
50.  *              src/makemon.c:  if (mmflags & MM_XX) newXX(mtmp);
51.  *              your new code:  mon = makemon(&mons[mnum], x, y, MM_XX);
52.  *
53.  *       7. Adjust size_monst() in src/wizcmds.c appropriately.
54.  *       8. Adjust dealloc_mextra() in src/mon.c to clean up
55.  *          properly during monst deallocation.
56.  *       9. Adjust copy_mextra() in src/mon.c to make duplicate
57.  *          copies of your struct or data on another monst struct.
58.  *      10. Adjust restmon() in src/restore.c to deal with your
59.  *          struct or data during a restore.
60.  *      11. Adjust savemon() in src/save.c to deal with your
61.  *          struct or data during a save.
62.  */
63. 
64. /***
65.  **     formerly vault.h -- vault guard extension
66.  */
67. #define FCSIZ (ROWNO + COLNO)
68. #define GD_EATGOLD 0x01
69. #define GD_DESTROYGOLD 0x02
70. 
71. struct fakecorridor {
72.     coordxy fx, fy;
73.     schar ftyp; /* from struct rm's typ */
74.     uchar flags; /* also from struct rm; an unsigned 5-bit field there */
75. };
76. 
77. struct egd {
78.     unsigned parentmid;   /* make clobber-detection possible */
79.     int fcbeg, fcend;     /* fcend: first unused pos */
80.     int vroom;            /* room number of the vault */
81.     coordxy gdx, gdy;     /* goal of guard's walk */
82.     coordxy ogx, ogy;     /* guard's last position */
83.     d_level gdlevel;      /* level (& dungeon) guard was created in */
84.     xint8 warncnt;        /* number of warnings to follow */
85.     xint8 dropgoldcnt;    /* number of demands to drop gold */
86.     Bitfield(gddone, 1);  /* true iff guard has released player */
87.     Bitfield(witness, 2); /* the guard saw you do something */
88.     Bitfield(unused, 5);
89.     struct fakecorridor fakecorr[FCSIZ];
90. };
91. 
92. /***
93.  **     formerly epri.h -- temple priest extension
94.  */
95. struct epri {
96.     unsigned parentmid;   /* make clobber-detection possible */
97.     aligntyp shralign; /* alignment of priest's shrine */
98.     schar shroom;      /* index in rooms */
99.     coord shrpos;      /* position of shrine */
100.     d_level shrlevel;  /* level (& dungeon) of shrine */
101.     unsigned cheapskate_count; /* number of cheapskate donations */
102.     long intone_time,  /* used to limit verbosity  +*/
103.         enter_time,    /*+ of temple entry messages */
104.         hostile_time,  /* forbidding feeling */
105.         peaceful_time; /* sense of peace */
106. };
107. /* note: roaming priests (no shrine) switch from ispriest to isminion
108.    (and emin extension) */
109. 
110. /***
111.  **     formerly eshk.h -- shopkeeper extension
112.  */
113. #define REPAIR_DELAY 5 /* minimum delay between shop damage & repair */
114. #define BILLSZ 200
115. 
116. struct bill_x {
117.     unsigned bo_id;
118.     boolean useup;
119.     long price; /* price per unit */
120.     long bquan; /* amount used up */
121. };
122. 
123. struct eshk {
124.     unsigned parentmid;   /* make clobber-detection possible */
125.     long robbed;          /* amount stolen by most recent customer */
126.     long credit;          /* amount credited to customer */
127.     long debit;           /* amount of debt for using unpaid items */
128.     long loan;            /* shop-gold picked (part of debit) */
129.     int shoptype;         /* the value of svr.rooms[shoproom].rtype */
130.     schar shoproom;       /* index in svr.rooms; set by inshop() */
131.     schar unused;         /* to force alignment for stupid compilers */
132.     boolean following;    /* following customer since he owes us sth */
133.     boolean surcharge;    /* angry shk inflates prices */
134.     boolean dismiss_kops; /* pacified shk sends kops away */
135.     coord shk;            /* usual position shopkeeper */
136.     coord shd;            /* position shop door */
137.     d_level shoplevel;    /* level (& dungeon) of his shop */
138.     int billct;           /* no. of entries of bill[] in use */
139.     struct bill_x bill[BILLSZ];
140.     struct bill_x *bill_p;  /* &(ESHK(shkp)->bill[0]) */
141.     long break_seq;         /* hero_seq value at time of object breakage */
142.     boolean seq_peaceful;   /* shkp->mpeaceful at start of break_seq */
143.     int visitct;            /* nr of visits by most recent customer */
144.     char customer[PL_NSIZ]; /* most recent customer */
145.     char shknam[PL_NSIZ];
146. };
147. 
148. /***
149.  **     formerly emin.h -- minion extension
150.  */
151. struct emin {
152.     unsigned parentmid;   /* make clobber-detection possible */
153.     aligntyp min_align; /* alignment of minion */
154.     boolean renegade;   /* hostile co-aligned priest or Angel */
155. };
156. 
157. /***
158.  **     formerly edog.h -- pet extension
159.  */
160. /*      various types of pet food, the lower the value, the better liked */
161. enum dogfood_types {
162.     DOGFOOD = 0,
163.     CADAVER = 1,
164.     ACCFOOD = 2,
165.     MANFOOD = 3,
166.     APPORT  = 4,
167.     POISON  = 5,
168.     UNDEF   = 6,
169.     TABU    = 7
170. };
171. 
172. struct edog {
173.     unsigned parentmid;       /* make clobber-detection possible */
174.     long droptime;            /* moment dog dropped object */
175.     unsigned dropdist;        /* dist of dropped obj from @ */
176.     int apport;               /* amount of training */
177.     long whistletime;         /* last time he whistled */
178.     long hungrytime;          /* will get hungry at this time */
179.     coord ogoal;              /* previous goal location */
180.     int abuse;                /* track abuses to this pet */
181.     int revivals;             /* count pet deaths */
182.     int mhpmax_penalty;       /* while starving, points reduced */
183.     Bitfield(killed_by_u, 1); /* you attempted to kill him */
184. };
185. 
186. /***
187.  **     extension tracking a player's remnant monster (ghost, mummy etc.)
188.  */
189. struct ebones {
190.     unsigned parentmid;     /* make clobber-detection possible */
191.     uchar role;             /* index into roles[] */
192.     uchar race;             /* index into races[] */
193.     align oldalign;         /* character alignment */
194.     uchar deathlevel;       /* level when dying (m_lev may differ) */
195.     schar luck;             /* luck when dying */
196.     short mnum;             /* monster type */
197.     Bitfield(female, 1);    /* was female */
198.     Bitfield(demigod, 1);   /* had killed wiz or invoked */
199.     Bitfield(crowned, 1);   /* had been crowned */
200. };
201. 
202. /***
203.  **     mextra.h -- collection of all monster extensions
204.  */
205. struct mextra {
206.     char *mgivenname;
207.     struct egd *egd;
208.     struct epri *epri;
209.     struct eshk *eshk;
210.     struct emin *emin;
211.     struct edog *edog;
212.     struct ebones *ebones;
213.     int mcorpsenm; /* obj->corpsenm for mimic posing as statue or corpse,
214.                     * obj->spe (fruit index) for one posing as a slime mold,
215.                     * or an alignment mask for one posing as an altar */
216. };
217. 
218. #define MGIVENNAME(mon) ((mon)->mextra->mgivenname)
219. #define EGD(mon) ((mon)->mextra->egd)
220. #define EPRI(mon) ((mon)->mextra->epri)
221. #define ESHK(mon) ((mon)->mextra->eshk)
222. #define EMIN(mon) ((mon)->mextra->emin)
223. #define EDOG(mon) ((mon)->mextra->edog)
224. #define EBONES(mon) ((mon)->mextra->ebones)
225. #define MCORPSENM(mon) ((mon)->mextra->mcorpsenm)
226. 
227. #define has_mgivenname(mon) ((mon)->mextra && MGIVENNAME(mon))
228. #define has_egd(mon)   ((mon)->mextra && EGD(mon))
229. #define has_epri(mon)  ((mon)->mextra && EPRI(mon))
230. #define has_eshk(mon)  ((mon)->mextra && ESHK(mon))
231. #define has_emin(mon)  ((mon)->mextra && EMIN(mon))
232. #define has_edog(mon)  ((mon)->mextra && EDOG(mon))
233. #define has_ebones(mon) ((mon)->mextra && EBONES(mon))
234. #define has_mcorpsenm(mon) ((mon)->mextra && MCORPSENM(mon) != NON_PM)
235. 
236. #endif /* MEXTRA_H */