OSDN Git Service

fbefefc59e247a77e6cc6d38a547fc056cf3e957
[hengband/hengband.git] / src / types.h
1 /* File: types.h */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.
9  */
10
11 /* Purpose: global type declarations */
12
13
14 /*
15  * This file should ONLY be included by "angband.h"
16  */
17
18 /*
19  * Note that "char" may or may not be signed, and that "signed char"
20  * may or may not work on all machines.  So always use "s16b" or "s32b"
21  * for signed values.  Also, note that unsigned values cause math problems
22  * in many cases, so try to only use "u16b" and "u32b" for "bit flags",
23  * unless you really need the extra bit of information, or you really
24  * need to restrict yourself to a single byte for storage reasons.
25  *
26  * Also, if possible, attempt to restrict yourself to sub-fields of
27  * known size (use "s16b" or "s32b" instead of "int", and "byte" instead
28  * of "bool"), and attempt to align all fields along four-byte words, to
29  * optimize storage issues on 32-bit machines.  Also, avoid "bit flags"
30  * since these increase the code size and slow down execution.  When
31  * you need to store bit flags, use one byte per flag, or, where space
32  * is an issue, use a "byte" or "u16b" or "u32b", and add special code
33  * to access the various bit flags.
34  *
35  * Many of these structures were developed to reduce the number of global
36  * variables, facilitate structured program design, allow the use of ascii
37  * template files, simplify access to indexed data, or facilitate efficient
38  * clearing of many variables at once.
39  *
40  * Certain data is saved in multiple places for efficient access, currently,
41  * this includes the tval/sval/weight fields in "object_type", various fields
42  * in "header_type", and the "m_idx" and "o_idx" fields in "cave_type".  All
43  * of these could be removed, but this would, in general, slow down the game
44  * and increase the complexity of the code.
45  */
46
47
48
49
50
51 /*
52  * Feature state structure
53  *
54  * - Action (FF_*)
55  * - Result (f_info ID)
56  */
57 typedef struct feature_state feature_state;
58
59 struct feature_state
60 {
61         byte action;
62         s16b result;
63 };
64
65
66 /*
67  * Information about terrain "features"
68  */
69
70 typedef struct feature_type feature_type;
71
72 struct feature_type
73 {
74         u32b name;                /* Name (offset) */
75         u32b text;                /* Text (offset) */
76         s16b tag;                 /* Tag (offset) */
77
78         s16b mimic;               /* Feature to mimic */
79
80         u32b flags[FF_FLAG_SIZE]; /* Flags */
81
82         u16b priority;            /* Map priority */
83         s16b destroyed;           /* Default destroyed state */
84
85         feature_state state[MAX_FEAT_STATES];
86
87         byte subtype;
88         byte power;
89
90         byte d_attr[F_LIT_MAX];   /* Default feature attribute */
91         byte d_char[F_LIT_MAX];   /* Default feature character */
92
93         byte x_attr[F_LIT_MAX];   /* Desired feature attribute */
94         byte x_char[F_LIT_MAX];   /* Desired feature character */
95 };
96
97
98 /*
99  * Information about object "kinds", including player knowledge.
100  *
101  * Only "aware" and "tried" are saved in the savefile
102  */
103
104 typedef struct object_kind object_kind;
105
106 struct object_kind
107 {
108         u32b name;                      /* Name (offset) */
109         u32b text;                      /* Text (offset) */
110         u32b flavor_name;               /* Flavor name (offset) */
111
112         byte tval;                      /* Object type */
113         byte sval;                      /* Object sub type */
114
115         s16b pval;                      /* Object extra info */
116
117         s16b to_h;                      /* Bonus to hit */
118         s16b to_d;                      /* Bonus to damage */
119         s16b to_a;                      /* Bonus to armor */
120
121         s16b ac;                        /* Base armor */
122
123         byte dd, ds;            /* Damage dice/sides */
124
125         s16b weight;            /* Weight */
126
127         s32b cost;                      /* Object "base cost" */
128
129         u32b flags[TR_FLAG_SIZE];       /* Flags */
130
131         u32b gen_flags;         /* flags for generate */
132
133         byte locale[4];         /* Allocation level(s) */
134         byte chance[4];         /* Allocation chance(s) */
135
136         byte level;                     /* Level */
137         byte extra;                     /* Something */
138
139
140         byte d_attr;            /* Default object attribute */
141         byte d_char;            /* Default object character */
142
143
144         byte x_attr;            /* Desired object attribute */
145         byte x_char;            /* Desired object character */
146
147
148         s16b flavor;            /* Special object flavor (or zero) */
149
150         bool easy_know;         /* This object is always known (if aware) */
151
152
153         bool aware;                     /* The player is "aware" of the item's effects */
154
155         bool tried;                     /* The player has "tried" one of the items */
156
157         byte act_idx;           /* Activative ability index */
158 };
159
160
161
162 /*
163  * Information about "artifacts".
164  *
165  * Note that the save-file only writes "cur_num" to the savefile.
166  *
167  * Note that "max_num" is always "1" (if that artifact "exists")
168  */
169
170 typedef struct artifact_type artifact_type;
171
172 struct artifact_type
173 {
174         u32b name;                      /* Name (offset) */
175         u32b text;                      /* Text (offset) */
176
177         byte tval;                      /* Artifact type */
178         byte sval;                      /* Artifact sub type */
179
180         s16b pval;                      /* Artifact extra info */
181
182         s16b to_h;                      /* Bonus to hit */
183         s16b to_d;                      /* Bonus to damage */
184         s16b to_a;                      /* Bonus to armor */
185
186         s16b ac;                        /* Base armor */
187
188         byte dd, ds;            /* Damage when hits */
189
190         s16b weight;            /* Weight */
191
192         s32b cost;                      /* Artifact "cost" */
193
194         u32b flags[TR_FLAG_SIZE];       /* Artifact Flags */
195
196         u32b gen_flags;         /* flags for generate */
197
198         byte level;                     /* Artifact level */
199         byte rarity;            /* Artifact rarity */
200
201         byte cur_num;           /* Number created (0 or 1) */
202         byte max_num;           /* Unused (should be "1") */
203
204         s16b floor_id;          /* Leaved on this location last time */
205
206         byte act_idx;           /* Activative ability index */
207 };
208
209
210 /*
211  * Information about "ego-items".
212  */
213
214 typedef struct ego_item_type ego_item_type;
215
216 struct ego_item_type
217 {
218         u32b name;                      /* Name (offset) */
219         u32b text;                      /* Text (offset) */
220
221         byte slot;                      /* Standard slot value */
222         byte rating;            /* Rating boost */
223
224         byte level;                     /* Minimum level */
225         byte rarity;            /* Object rarity */
226
227         byte max_to_h;          /* Maximum to-hit bonus */
228         byte max_to_d;          /* Maximum to-dam bonus */
229         byte max_to_a;          /* Maximum to-ac bonus */
230
231         byte max_pval;          /* Maximum pval */
232
233         s32b cost;                      /* Ego-item "cost" */
234
235         u32b flags[TR_FLAG_SIZE];       /* Ego-Item Flags */
236
237         u32b gen_flags;         /* flags for generate */
238
239         byte act_idx;           /* Activative ability index */
240 };
241
242
243
244
245 /*
246  * Monster blow structure
247  *
248  *      - Method (RBM_*)
249  *      - Effect (RBE_*)
250  *      - Damage Dice
251  *      - Damage Sides
252  */
253
254 typedef struct monster_blow monster_blow;
255
256 struct monster_blow
257 {
258         byte method;
259         byte effect;
260         byte d_dice;
261         byte d_side;
262 };
263
264
265 typedef struct mbe_info_type mbe_info_type;
266
267 struct mbe_info_type
268 {
269         int power;        /* The attack "power" */
270         int explode_type; /* Explosion effect */
271 };
272
273
274 /*
275  * Monster "race" information, including racial memories
276  *
277  * Note that "d_attr" and "d_char" are used for MORE than "visual" stuff.
278  *
279  * Note that "x_attr" and "x_char" are used ONLY for "visual" stuff.
280  *
281  * Note that "cur_num" (and "max_num") represent the number of monsters
282  * of the given race currently on (and allowed on) the current level.
283  * This information yields the "dead" flag for Unique monsters.
284  *
285  * Note that "max_num" is reset when a new player is created.
286  * Note that "cur_num" is reset when a new level is created.
287  *
288  * Note that several of these fields, related to "recall", can be
289  * scrapped if space becomes an issue, resulting in less "complete"
290  * monster recall (no knowledge of spells, etc).  All of the "recall"
291  * fields have a special prefix to aid in searching for them.
292  */
293
294
295 typedef struct monster_race monster_race;
296
297 struct monster_race
298 {
299         u32b name;                              /* Name (offset) */
300 #ifdef JP
301         u32b E_name;                    /* ±Ñ¸ì̾ (offset) */
302 #endif
303         u32b text;                              /* Text (offset) */
304
305         byte hdice;                             /* Creatures hit dice count */
306         byte hside;                             /* Creatures hit dice sides */
307
308         s16b ac;                                /* Armour Class */
309
310         s16b sleep;                             /* Inactive counter (base) */
311         byte aaf;                               /* Area affect radius (1-100) */
312         byte speed;                             /* Speed (normally 110) */
313
314         s32b mexp;                              /* Exp value for kill */
315
316         s16b extra;                             /* Unused (for now) */
317
318         byte freq_spell;                /* Spell frequency */
319
320         u32b flags1;                    /* Flags 1 (general) */
321         u32b flags2;                    /* Flags 2 (abilities) */
322         u32b flags3;                    /* Flags 3 (race/resist) */
323         u32b flags4;                    /* Flags 4 (inate/breath) */
324         u32b flags5;                    /* Flags 5 (normal spells) */
325         u32b flags6;                    /* Flags 6 (special spells) */
326         u32b flags7;                    /* Flags 7 (movement related abilities) */
327         u32b flags8;                    /* Flags 8 (wilderness info) */
328         u32b flags9;                    /* Flags 9 (drops info) */
329         u32b flagsr;                    /* Flags R (resistances info) */
330
331         monster_blow blow[4];   /* Up to four blows per round */
332
333         s16b next_r_idx;
334         u32b next_exp;
335
336         byte level;                             /* Level of creature */
337         byte rarity;                    /* Rarity of creature */
338
339
340         byte d_attr;                    /* Default monster attribute */
341         byte d_char;                    /* Default monster character */
342
343
344         byte x_attr;                    /* Desired monster attribute */
345         byte x_char;                    /* Desired monster character */
346
347
348         byte max_num;                   /* Maximum population allowed per level */
349
350         byte cur_num;                   /* Monster population on current level */
351
352         s16b floor_id;                  /* Location of unique monster */
353
354
355         s16b r_sights;                  /* Count sightings of this monster */
356         s16b r_deaths;                  /* Count deaths from this monster */
357
358         s16b r_pkills;                  /* Count visible monsters killed in this life */
359         s16b r_akills;                  /* Count all monsters killed in this life */
360         s16b r_tkills;                  /* Count monsters killed in all lives */
361
362         byte r_wake;                    /* Number of times woken up (?) */
363         byte r_ignore;                  /* Number of times ignored (?) */
364
365         byte r_xtra1;                   /* Something (unused) */
366         byte r_xtra2;                   /* Something (unused) */
367
368         byte r_drop_gold;               /* Max number of gold dropped at once */
369         byte r_drop_item;               /* Max number of item dropped at once */
370
371         byte r_cast_spell;              /* Max number of other spells seen */
372
373         byte r_blows[4];                /* Number of times each blow type was seen */
374
375         u32b r_flags1;                  /* Observed racial flags */
376         u32b r_flags2;                  /* Observed racial flags */
377         u32b r_flags3;                  /* Observed racial flags */
378         u32b r_flags4;                  /* Observed racial flags */
379         u32b r_flags5;                  /* Observed racial flags */
380         u32b r_flags6;                  /* Observed racial flags */
381         /* u32b r_flags7; */                    /* Observed racial flags */
382         u32b r_flagsr;                  /* Observed racial resistance flags */
383 };
384
385
386
387 /*
388  * Information about "vault generation"
389  */
390
391 typedef struct vault_type vault_type;
392
393 struct vault_type
394 {
395         u32b name;                      /* Name (offset) */
396         u32b text;                      /* Text (offset) */
397
398         byte typ;                       /* Vault type */
399
400         byte rat;                       /* Vault rating */
401
402         byte hgt;                       /* Vault height */
403         byte wid;                       /* Vault width */
404 };
405
406
407 /*
408  * Information about "skill"
409  */
410
411 typedef struct skill_table skill_table;
412
413 struct skill_table
414 {
415         s16b w_start[5][64];      /* start weapon exp */
416         s16b w_max[5][64];        /* max weapon exp */
417         s16b s_start[10];         /* start skill */
418         s16b s_max[10];           /* max skill */
419 };
420
421
422 /*
423  * A single "grid" in a Cave
424  *
425  * Note that several aspects of the code restrict the actual cave
426  * to a max size of 256 by 256.  In partcular, locations are often
427  * saved as bytes, limiting each coordinate to the 0-255 range.
428  *
429  * The "o_idx" and "m_idx" fields are very interesting.  There are
430  * many places in the code where we need quick access to the actual
431  * monster or object(s) in a given cave grid.  The easiest way to
432  * do this is to simply keep the index of the monster and object
433  * (if any) with the grid, but this takes 198*66*4 bytes of memory.
434  * Several other methods come to mind, which require only half this
435  * amound of memory, but they all seem rather complicated, and would
436  * probably add enough code that the savings would be lost.  So for
437  * these reasons, we simply store an index into the "o_list" and
438  * "m_list" arrays, using "zero" when no monster/object is present.
439  *
440  * Note that "o_idx" is the index of the top object in a stack of
441  * objects, using the "next_o_idx" field of objects (see below) to
442  * create the singly linked list of objects.  If "o_idx" is zero
443  * then there are no objects in the grid.
444  *
445  * Note the special fields for the "MONSTER_FLOW" code.
446  */
447
448 typedef struct cave_type cave_type;
449
450 struct cave_type
451 {
452         u16b info;              /* Hack -- cave flags */
453
454         s16b feat;              /* Hack -- feature type */
455
456         s16b o_idx;             /* Object in this grid */
457
458         s16b m_idx;             /* Monster in this grid */
459
460         s16b special;   /* Special cave info */
461
462         s16b mimic;             /* Feature to mimic */
463
464         byte cost;              /* Hack -- cost of flowing */
465         byte dist;              /* Hack -- distance from player */
466         byte when;              /* Hack -- when cost was computed */
467 };
468
469
470
471 /*
472  * Simple structure to hold a map location
473  */
474 typedef struct coord coord;
475
476 struct coord
477 {
478         byte y;
479         byte x;
480 };
481
482
483
484 /*
485  * Object information, for a specific object.
486  *
487  * Note that a "discount" on an item is permanent and never goes away.
488  *
489  * Note that inscriptions are now handled via the "quark_str()" function
490  * applied to the "note" field, which will return NULL if "note" is zero.
491  *
492  * Note that "object" records are "copied" on a fairly regular basis,
493  * and care must be taken when handling such objects.
494  *
495  * Note that "object flags" must now be derived from the object kind,
496  * the artifact and ego-item indexes, and the two "xtra" fields.
497  *
498  * Each cave grid points to one (or zero) objects via the "o_idx"
499  * field (above).  Each object then points to one (or zero) objects
500  * via the "next_o_idx" field, forming a singly linked list, which
501  * in game terms, represents a "stack" of objects in the same grid.
502  *
503  * Each monster points to one (or zero) objects via the "hold_o_idx"
504  * field (below).  Each object then points to one (or zero) objects
505  * via the "next_o_idx" field, forming a singly linked list, which
506  * in game terms, represents a pile of objects held by the monster.
507  *
508  * The "held_m_idx" field is used to indicate which monster, if any,
509  * is holding the object.  Objects being held have "ix=0" and "iy=0".
510  */
511
512 typedef struct object_type object_type;
513
514 struct object_type
515 {
516         s16b k_idx;                     /* Kind index (zero if "dead") */
517
518         byte iy;                        /* Y-position on map, or zero */
519         byte ix;                        /* X-position on map, or zero */
520
521         byte tval;                      /* Item type (from kind) */
522         byte sval;                      /* Item sub-type (from kind) */
523
524         s16b pval;                      /* Item extra-parameter */
525
526         byte discount;          /* Discount (if any) */
527
528         byte number;            /* Number of items */
529
530         s16b weight;            /* Item weight */
531
532         byte name1;                     /* Artifact type, if any */
533         byte name2;                     /* Ego-Item type, if any */
534
535         byte xtra1;                     /* Extra info type (now unused) */
536         byte xtra2;                     /* Extra info activation index */
537         byte xtra3;                     /* Extra info for weaponsmith */
538         s16b xtra4;                     /* Extra info fuel or captured monster's current HP */
539         s16b xtra5;                     /* Extra info captured monster's max HP */
540
541         s16b to_h;                      /* Plusses to hit */
542         s16b to_d;                      /* Plusses to damage */
543         s16b to_a;                      /* Plusses to AC */
544
545         s16b ac;                        /* Normal AC */
546
547         byte dd, ds;            /* Damage dice/sides */
548
549         s16b timeout;           /* Timeout Counter */
550
551         byte ident;                     /* Special flags  */
552
553         byte marked;            /* Object is marked */
554
555         u16b inscription;       /* Inscription index */
556         u16b art_name;      /* Artifact name (random artifacts) */
557
558         byte feeling;          /* Game generated inscription number (eg, pseudo-id) */
559
560         u32b art_flags[TR_FLAG_SIZE];        /* Extra Flags for ego and artifacts */
561
562         u32b curse_flags;        /* Flags for curse */
563
564         s16b next_o_idx;        /* Next object in stack (if any) */
565
566         s16b held_m_idx;        /* Monster holding us (if any) */
567 };
568
569
570
571 /*
572  * Monster information, for a specific monster.
573  *
574  * Note: fy, fx constrain dungeon size to 256x256
575  *
576  * The "hold_o_idx" field points to the first object of a stack
577  * of objects (if any) being carried by the monster (see above).
578  */
579
580 typedef struct monster_type monster_type;
581
582 struct monster_type
583 {
584         s16b r_idx;             /* Monster race index */
585         s16b ap_r_idx;          /* Monster race appearance index */
586         byte sub_align;         /* Sub-alignment for a neutral monster */
587
588         byte fy;                /* Y location on map */
589         byte fx;                /* X location on map */
590
591         s16b hp;                /* Current Hit points */
592         s16b maxhp;             /* Max Hit points */
593         s16b max_maxhp;         /* Max Max Hit points */
594
595         s16b mtimed[MAX_MTIMED];        /* Timed status counter */
596
597         byte mspeed;            /* Monster "speed" */
598         s16b energy_need;       /* Monster "energy" */
599
600         byte cdis;              /* Current dis from player */
601
602         byte mflag;             /* Extra monster flags */
603         byte mflag2;            /* Extra monster flags */
604
605         bool ml;                /* Monster is "visible" */
606
607         s16b hold_o_idx;        /* Object being held (if any) */
608
609         s16b target_y;          /* Can attack !los player */
610         s16b target_x;          /* Can attack !los player */
611
612         u16b nickname;          /* Monster's Nickname */
613
614         u32b exp;
615
616         u32b smart;                     /* Field for "smart_learn" */
617
618         s16b parent_m_idx;
619 };
620
621
622
623
624 /*
625  * An entry for the object/monster allocation functions
626  *
627  * Pass 1 is determined from allocation information
628  * Pass 2 is determined from allocation restriction
629  * Pass 3 is determined from allocation calculation
630  */
631
632 typedef struct alloc_entry alloc_entry;
633
634 struct alloc_entry
635 {
636         s16b index;             /* The actual index */
637
638         byte level;             /* Base dungeon level */
639         byte prob1;             /* Probability, pass 1 */
640         byte prob2;             /* Probability, pass 2 */
641         byte prob3;             /* Probability, pass 3 */
642
643         u16b total;             /* Unused for now */
644 };
645
646
647
648 /*
649  * Available "options"
650  *
651  *      - Address of actual option variable (or NULL)
652  *
653  *      - Normal Value (TRUE or FALSE)
654  *
655  *      - Option Page Number (or zero)
656  *
657  *      - Savefile Set (or zero)
658  *      - Savefile Bit in that set
659  *
660  *      - Textual name (or NULL)
661  *      - Textual description
662  */
663
664 typedef struct option_type option_type;
665
666 struct option_type
667 {
668         bool    *o_var;
669
670         byte    o_norm;
671
672         byte    o_page;
673
674         byte    o_set;
675         byte    o_bit;
676
677         cptr    o_text;
678         cptr    o_desc;
679 };
680
681
682 /*
683  * Structure for the "quests"
684  */
685 typedef struct quest_type quest_type;
686
687 struct quest_type
688 {
689         s16b status;            /* Is the quest taken, completed, finished? */
690
691         s16b type;              /* The quest type */
692
693         char name[60];          /* Quest name */
694         s16b level;             /* Dungeon level */
695         s16b r_idx;             /* Monster race */
696
697         s16b cur_num;           /* Number killed */
698         s16b max_num;           /* Number required */
699
700         s16b k_idx;             /* object index */
701         s16b num_mon;           /* number of monsters on level */
702
703         byte flags;             /* quest flags */
704         byte dungeon;           /* quest dungeon */
705
706         byte complev;           /* player level (complete) */
707 };
708
709
710 /*
711  * A store owner
712  */
713 typedef struct owner_type owner_type;
714
715 struct owner_type
716 {
717         cptr owner_name;        /* Name */
718
719         s16b max_cost;          /* Purse limit */
720
721         byte max_inflate;       /* Inflation (max) */
722         byte min_inflate;       /* Inflation (min) */
723
724         byte haggle_per;        /* Haggle unit */
725
726         byte insult_max;        /* Insult limit */
727
728         byte owner_race;        /* Owner race */
729 };
730
731
732
733
734 /*
735  * A store, with an owner, various state flags, a current stock
736  * of items, and a table of items that are often purchased.
737  */
738 typedef struct store_type store_type;
739
740 struct store_type
741 {
742         byte type;                              /* Store type */
743
744         byte owner;                             /* Owner index */
745         byte extra;                             /* Unused for now */
746
747         s16b insult_cur;                /* Insult counter */
748
749         s16b good_buy;                  /* Number of "good" buys */
750         s16b bad_buy;                   /* Number of "bad" buys */
751
752         s32b store_open;                /* Closed until this turn */
753
754         s32b last_visit;                /* Last visited on this turn */
755
756         s16b table_num;                 /* Table -- Number of entries */
757         s16b table_size;                /* Table -- Total Size of Array */
758         s16b *table;                    /* Table -- Legal item kinds */
759
760         s16b stock_num;                 /* Stock -- Number of entries */
761         s16b stock_size;                /* Stock -- Total Size of Array */
762         object_type *stock;             /* Stock -- Actual stock items */
763 };
764
765
766 /*
767  * The "name" of spell 'N' is stored as spell_names[X][N],
768  * where X is 0 for mage-spells and 1 for priest-spells.
769  */
770 typedef struct magic_type magic_type;
771
772 struct magic_type
773 {
774         byte slevel;            /* Required level (to learn) */
775         byte smana;                     /* Required mana (to cast) */
776         byte sfail;                     /* Minimum chance of failure */
777         byte sexp;                      /* Encoded experience bonus */
778 };
779
780
781 /*
782  * Information about the player's "magic"
783  *
784  * Note that a player with a "spell_book" of "zero" is illiterate.
785  */
786
787 typedef struct player_magic player_magic;
788
789 struct player_magic
790 {
791         int spell_book;         /* Tval of spell books (if any) */
792         int spell_xtra;         /* Something for later */
793
794         int spell_stat;         /* Stat for spells (if any)  */
795         int spell_type;         /* Spell type (mage/priest) */
796
797         int spell_first;                /* Level of first spell */
798         int spell_weight;               /* Weight that hurts spells */
799
800         magic_type info[MAX_MAGIC][32];    /* The available spells */
801 };
802
803
804
805 /*
806  * Player sex info
807  */
808
809 typedef struct player_sex player_sex;
810
811 struct player_sex
812 {
813         cptr title;                     /* Type of sex */
814         cptr winner;            /* Name of winner */
815 #ifdef JP
816         cptr E_title;           /* ±Ñ¸ìÀ­ÊÌ */
817         cptr E_winner;          /* ±Ñ¸ìÀ­ÊÌ */
818 #endif
819 };
820
821
822 /*
823  * Player racial info
824  */
825
826 typedef struct player_race player_race;
827
828 struct player_race
829 {
830         cptr title;                     /* Type of race */
831
832 #ifdef JP
833         cptr E_title;           /* ±Ñ¸ì¼ï² */
834 #endif
835         s16b r_adj[6];          /* Racial stat bonuses */
836
837         s16b r_dis;                     /* disarming */
838         s16b r_dev;                     /* magic devices */
839         s16b r_sav;                     /* saving throw */
840         s16b r_stl;                     /* stealth */
841         s16b r_srh;                     /* search ability */
842         s16b r_fos;                     /* search frequency */
843         s16b r_thn;                     /* combat (normal) */
844         s16b r_thb;                     /* combat (shooting) */
845
846         byte r_mhp;                     /* Race hit-dice modifier */
847         byte r_exp;                     /* Race experience factor */
848
849         byte b_age;                     /* base age */
850         byte m_age;                     /* mod age */
851
852         byte m_b_ht;            /* base height (males) */
853         byte m_m_ht;            /* mod height (males) */
854         byte m_b_wt;            /* base weight (males) */
855         byte m_m_wt;            /* mod weight (males) */
856
857         byte f_b_ht;            /* base height (females) */
858         byte f_m_ht;            /* mod height (females)   */
859         byte f_b_wt;            /* base weight (females) */
860         byte f_m_wt;            /* mod weight (females) */
861
862         byte infra;                     /* Infra-vision range */
863
864         u32b choice;        /* Legal class choices */
865 /*    byte choice_xtra;   */
866 };
867
868
869 /*
870  * Player class info
871  */
872
873 typedef struct player_class player_class;
874
875 struct player_class
876 {
877         cptr title;                     /* Type of class */
878
879 #ifdef JP
880         cptr E_title;           /* ±Ñ¸ì¿¦¶È */
881 #endif
882         s16b c_adj[6];          /* Class stat modifier */
883
884         s16b c_dis;                     /* class disarming */
885         s16b c_dev;                     /* class magic devices */
886         s16b c_sav;                     /* class saving throws */
887         s16b c_stl;                     /* class stealth */
888         s16b c_srh;                     /* class searching ability */
889         s16b c_fos;                     /* class searching frequency */
890         s16b c_thn;                     /* class to hit (normal) */
891         s16b c_thb;                     /* class to hit (bows) */
892
893         s16b x_dis;                     /* extra disarming */
894         s16b x_dev;                     /* extra magic devices */
895         s16b x_sav;                     /* extra saving throws */
896         s16b x_stl;                     /* extra stealth */
897         s16b x_srh;                     /* extra searching ability */
898         s16b x_fos;                     /* extra searching frequency */
899         s16b x_thn;                     /* extra to hit (normal) */
900         s16b x_thb;                     /* extra to hit (bows) */
901
902         s16b c_mhp;                     /* Class hit-dice adjustment */
903         s16b c_exp;                     /* Class experience factor */
904
905         byte pet_upkeep_div; /* Pet upkeep divider */
906 };
907
908
909 typedef struct player_seikaku player_seikaku;
910 struct player_seikaku
911 {
912         cptr title;                     /* Type of seikaku */
913
914 #ifdef JP
915         cptr E_title;           /* ±Ñ¸ìÀ­³Ê */
916 #endif
917
918         s16b a_adj[6];          /* seikaku stat bonuses */
919
920         s16b a_dis;                     /* seikaku disarming */
921         s16b a_dev;                     /* seikaku magic devices */
922         s16b a_sav;                     /* seikaku saving throw */
923         s16b a_stl;                     /* seikaku stealth */
924         s16b a_srh;                     /* seikaku search ability */
925         s16b a_fos;                     /* seikaku search frequency */
926         s16b a_thn;                     /* seikaku combat (normal) */
927         s16b a_thb;                     /* seikaku combat (shooting) */
928
929         s16b a_mhp;                     /* Race hit-dice modifier */
930
931         byte no;                        /* ¤Î */
932         byte sex;                       /* seibetu seigen */
933 };
934
935
936 /*
937  * Most of the "player" information goes here.
938  *
939  * This stucture gives us a large collection of player variables.
940  *
941  * This structure contains several "blocks" of information.
942  *   (1) the "permanent" info
943  *   (2) the "variable" info
944  *   (3) the "transient" info
945  *
946  * All of the "permanent" info, and most of the "variable" info,
947  * is saved in the savefile.  The "transient" info is recomputed
948  * whenever anything important changes.
949  */
950
951 typedef struct player_type player_type;
952
953 struct player_type
954 {
955         s16b oldpy;             /* Previous player location -KMW- */
956         s16b oldpx;             /* Previous player location -KMW- */
957
958         byte psex;                      /* Sex index */
959         byte prace;                     /* Race index */
960         byte pclass;            /* Class index */
961         byte pseikaku;          /* Seikaku index */
962         byte realm1;        /* First magic realm */
963         byte realm2;        /* Second magic realm */
964         byte oops;                      /* Unused */
965
966         byte hitdie;            /* Hit dice (sides) */
967         u16b expfact;       /* Experience factor
968                              * Note: was byte, causing overflow for Amberite
969                              * characters (such as Amberite Paladins)
970                              */
971
972         s16b age;                       /* Characters age */
973         s16b ht;                        /* Height */
974         s16b wt;                        /* Weight */
975         s16b sc;                        /* Social Class */
976
977
978         s32b au;                        /* Current Gold */
979
980         s32b max_max_exp;       /* Max max experience (only to calculate score) */
981         s32b max_exp;           /* Max experience */
982         s32b exp;                       /* Cur experience */
983         u32b exp_frac;          /* Cur exp frac (times 2^16) */
984
985         s16b lev;                       /* Level */
986
987         s16b town_num;                  /* Current town number */
988         s16b arena_number;              /* monster number in arena -KMW- */
989         bool inside_arena;              /* Is character inside arena? */
990         s16b inside_quest;              /* Inside quest level */
991         bool inside_battle;             /* Is character inside tougijou? */
992
993         s32b wilderness_x;      /* Coordinates in the wilderness */
994         s32b wilderness_y;
995         bool wild_mode;
996
997         s32b mhp;                       /* Max hit pts */
998         s32b chp;                       /* Cur hit pts */
999         u32b chp_frac;          /* Cur hit frac (times 2^16) */
1000
1001         s32b msp;                       /* Max mana pts */
1002         s32b csp;                       /* Cur mana pts */
1003         u32b csp_frac;          /* Cur mana frac (times 2^16) */
1004
1005         s16b max_plv;           /* Max Player Level */
1006
1007         s16b stat_max[6];       /* Current "maximal" stat values */
1008         s16b stat_max_max[6];   /* Maximal "maximal" stat values */
1009         s16b stat_cur[6];       /* Current "natural" stat values */
1010
1011         s16b learned_spells;
1012         s16b add_spells;
1013
1014         u32b count;
1015
1016         s16b fast;              /* Timed -- Fast */
1017         s16b slow;              /* Timed -- Slow */
1018         s16b blind;             /* Timed -- Blindness */
1019         s16b paralyzed;         /* Timed -- Paralysis */
1020         s16b confused;          /* Timed -- Confusion */
1021         s16b afraid;            /* Timed -- Fear */
1022         s16b image;             /* Timed -- Hallucination */
1023         s16b poisoned;          /* Timed -- Poisoned */
1024         s16b cut;               /* Timed -- Cut */
1025         s16b stun;              /* Timed -- Stun */
1026
1027         s16b protevil;          /* Timed -- Protection */
1028         s16b invuln;            /* Timed -- Invulnerable */
1029         s16b ult_res;           /* Timed -- Ultimate Resistance */
1030         s16b hero;              /* Timed -- Heroism */
1031         s16b shero;             /* Timed -- Super Heroism */
1032         s16b shield;            /* Timed -- Shield Spell */
1033         s16b blessed;           /* Timed -- Blessed */
1034         s16b tim_invis;         /* Timed -- See Invisible */
1035         s16b tim_infra;         /* Timed -- Infra Vision */
1036         s16b tsuyoshi;          /* Timed -- Tsuyoshi Special */
1037         s16b ele_attack;        /* Timed -- Elemental Attack */
1038         s16b ele_immune;        /* Timed -- Elemental Immune */
1039
1040         s16b oppose_acid;       /* Timed -- oppose acid */
1041         s16b oppose_elec;       /* Timed -- oppose lightning */
1042         s16b oppose_fire;       /* Timed -- oppose heat */
1043         s16b oppose_cold;       /* Timed -- oppose cold */
1044         s16b oppose_pois;       /* Timed -- oppose poison */
1045
1046
1047         s16b tim_esp;       /* Timed ESP */
1048         s16b wraith_form;   /* Timed wraithform */
1049
1050         s16b resist_magic;  /* Timed Resist Magic (later) */
1051         s16b tim_regen;
1052         s16b kabenuke;
1053         s16b tim_stealth;
1054         s16b tim_levitation;
1055         s16b tim_sh_touki;
1056         s16b lightspeed;
1057         s16b tsubureru;
1058         s16b magicdef;
1059         s16b tim_res_nether;    /* Timed -- Nether resistance */
1060         s16b tim_res_time;      /* Timed -- Time resistance */
1061         byte mimic_form;
1062         s16b tim_mimic;
1063         s16b tim_sh_fire;
1064         s16b tim_sh_holy;
1065         s16b tim_eyeeye;
1066
1067         /* for mirror master */
1068         s16b tim_reflect;       /* Timed -- Reflect */
1069         s16b multishadow;       /* Timed -- Multi-shadow */
1070         s16b dustrobe;          /* Timed -- Robe of dust */
1071
1072         s16b chaos_patron;
1073         u32b muta1;
1074         u32b muta2;
1075         u32b muta3;
1076
1077         s16b virtues[8];
1078         s16b vir_types[8];
1079
1080         s16b word_recall;         /* Word of recall counter */
1081         s16b alter_reality;       /* Alter reality counter */
1082         byte recall_dungeon;      /* Dungeon set to be recalled */
1083
1084         s16b energy_need;         /* Energy needed for next move */
1085         s16b enchant_energy_need;         /* Energy needed for next upkeep effect        */
1086
1087         s16b food;                /* Current nutrition */
1088
1089         u32b special_attack;      /* Special attack capacity -LM- */
1090         u32b special_defense;     /* Special block capacity -LM- */
1091         byte action;              /* Currently action */
1092
1093         u32b spell_learned1;      /* bit mask of spells learned */
1094         u32b spell_learned2;      /* bit mask of spells learned */
1095         u32b spell_worked1;       /* bit mask of spells tried and worked */
1096         u32b spell_worked2;       /* bit mask of spells tried and worked */
1097         u32b spell_forgotten1;    /* bit mask of spells learned but forgotten */
1098         u32b spell_forgotten2;    /* bit mask of spells learned but forgotten */
1099         byte spell_order[64];     /* order spells learned/remembered/forgotten */
1100
1101         s16b spell_exp[64];       /* Proficiency of spells */
1102         s16b weapon_exp[5][64];   /* Proficiency of weapons */
1103         s16b skill_exp[10];       /* Proficiency of misc. skill */
1104
1105         s32b magic_num1[108];     /* Array for non-spellbook type magic */
1106         byte magic_num2[108];     /* Flags for non-spellbook type magics */
1107
1108         s16b mane_spell[MAX_MANE];
1109         s16b mane_dam[MAX_MANE];
1110         s16b mane_num;
1111
1112         s16b concent;      /* Sniper's concentration level */
1113
1114         s16b player_hp[PY_MAX_LEVEL];
1115         char died_from[80];       /* What killed the player */
1116         cptr last_message;        /* Last message on death or retirement */
1117         char history[4][60];      /* Textual "history" for the Player */
1118
1119         u16b total_winner;        /* Total winner */
1120         u16b panic_save;          /* Panic save */
1121
1122         u16b noscore;             /* Cheating flags */
1123
1124         bool wait_report_score;   /* Waiting to report score */
1125         bool is_dead;             /* Player is dead */
1126
1127         bool wizard;              /* Player is in wizard mode */
1128
1129         s16b riding;              /* Riding on a monster of this index */
1130         byte knowledge;           /* Knowledge about yourself */
1131         s32b visit;               /* Visited towns */
1132
1133         byte start_race;          /* Race at birth */
1134         s32b old_race1;           /* Record of race changes */
1135         s32b old_race2;           /* Record of race changes */
1136         s16b old_realm;           /* Record of realm changes */
1137
1138         s16b pet_follow_distance; /* Length of the imaginary "leash" for pets */
1139         s16b pet_extra_flags;     /* Various flags for controling pets */
1140
1141         s16b today_mon;           /* Wanted monster */
1142
1143         bool dtrap;               /* Whether you are on trap-safe grids */
1144         s16b floor_id;            /* Current floor location */ 
1145
1146         bool autopick_autoregister; /* auto register is in-use or not */
1147
1148         byte feeling;           /* Most recent dungeon feeling */
1149         s32b feeling_turn;      /* The turn of the last dungeon feeling */
1150
1151
1152         /*** Temporary fields ***/
1153
1154         bool playing;                   /* True if player is playing */
1155         bool leaving;                   /* True if player is leaving */
1156
1157         byte exit_bldg;                 /* Goal obtained in arena? -KMW- */
1158
1159         bool leaving_dungeon;   /* True if player is leaving the dungeon */
1160         bool teleport_town;
1161         bool enter_dungeon;     /* Just enter the dungeon */
1162
1163         s16b health_who;        /* Health bar trackee */
1164
1165         s16b monster_race_idx;  /* Monster race trackee */
1166
1167         s16b object_kind_idx;   /* Object kind trackee */
1168
1169         s16b new_spells;        /* Number of spells available */
1170         s16b old_spells;
1171
1172         s16b old_food_aux;      /* Old value of food */
1173
1174         bool old_cumber_armor;
1175         bool old_cumber_glove;
1176         bool old_heavy_wield[2];
1177         bool old_heavy_shoot;
1178         bool old_icky_wield[2];
1179         bool old_riding_wield[2];
1180         bool old_riding_ryoute;
1181         bool old_monlite;
1182
1183         s16b old_lite;          /* Old radius of lite (if any) */
1184
1185         bool cumber_armor;      /* Mana draining armor */
1186         bool cumber_glove;      /* Mana draining gloves */
1187         bool heavy_wield[2];    /* Heavy weapon */
1188         bool heavy_shoot;       /* Heavy shooter */
1189         bool icky_wield[2];     /* Icky weapon */
1190         bool riding_wield[2];   /* Riding weapon */
1191         bool riding_ryoute;     /* Riding weapon */
1192         bool monlite;
1193
1194         s16b cur_lite;          /* Radius of lite (if any) */
1195
1196
1197         u32b notice;            /* Special Updates (bit flags) */
1198         u32b update;            /* Pending Updates (bit flags) */
1199         u32b redraw;            /* Normal Redraws (bit flags) */
1200         u32b window;            /* Window Redraws (bit flags) */
1201
1202         s16b stat_use[6];       /* Current modified stats */
1203         s16b stat_top[6];       /* Maximal modified stats */
1204
1205         bool sutemi;
1206         bool counter;
1207
1208         s32b align;                             /* Good/evil/neutral */
1209         s16b run_py;
1210         s16b run_px;
1211
1212
1213         /*** Extracted fields ***/
1214
1215         u32b total_weight;      /* Total weight being carried */
1216
1217         s16b stat_add[6];       /* Modifiers to stat values */
1218         s16b stat_ind[6];       /* Indexes into stat tables */
1219
1220         bool immune_acid;       /* Immunity to acid */
1221         bool immune_elec;       /* Immunity to lightning */
1222         bool immune_fire;       /* Immunity to fire */
1223         bool immune_cold;       /* Immunity to cold */
1224
1225         bool resist_acid;       /* Resist acid */
1226         bool resist_elec;       /* Resist lightning */
1227         bool resist_fire;       /* Resist fire */
1228         bool resist_cold;       /* Resist cold */
1229         bool resist_pois;       /* Resist poison */
1230
1231         bool resist_conf;       /* Resist confusion */
1232         bool resist_sound;      /* Resist sound */
1233         bool resist_lite;       /* Resist light */
1234         bool resist_dark;       /* Resist darkness */
1235         bool resist_chaos;      /* Resist chaos */
1236         bool resist_disen;      /* Resist disenchant */
1237         bool resist_shard;      /* Resist shards */
1238         bool resist_nexus;      /* Resist nexus */
1239         bool resist_blind;      /* Resist blindness */
1240         bool resist_neth;       /* Resist nether */
1241         bool resist_fear;       /* Resist fear */
1242         bool resist_time;       /* Resist time */
1243
1244         bool reflect;       /* Reflect 'bolt' attacks */
1245         bool sh_fire;       /* Fiery 'immolation' effect */
1246         bool sh_elec;       /* Electric 'immolation' effect */
1247         bool sh_cold;       /* Cold 'immolation' effect */
1248
1249         bool anti_magic;    /* Anti-magic */
1250         bool anti_tele;     /* Prevent teleportation */
1251
1252         bool sustain_str;       /* Keep strength */
1253         bool sustain_int;       /* Keep intelligence */
1254         bool sustain_wis;       /* Keep wisdom */
1255         bool sustain_dex;       /* Keep dexterity */
1256         bool sustain_con;       /* Keep constitution */
1257         bool sustain_chr;       /* Keep charisma */
1258
1259         u32b cursed;            /* Player is cursed */
1260
1261         bool can_swim;          /* No damage falling */
1262         bool levitation;                /* No damage falling */
1263         bool lite;              /* Permanent light */
1264         bool free_act;          /* Never paralyzed */
1265         bool see_inv;           /* Can see invisible */
1266         bool regenerate;        /* Regenerate hit pts */
1267         bool hold_life;         /* Resist life draining */
1268
1269         bool telepathy;         /* Telepathy */
1270         bool esp_animal;
1271         bool esp_undead;
1272         bool esp_demon;
1273         bool esp_orc;
1274         bool esp_troll;
1275         bool esp_giant;
1276         bool esp_dragon;
1277         bool esp_human;
1278         bool esp_evil;
1279         bool esp_good;
1280         bool esp_nonliving;
1281         bool esp_unique;
1282
1283         bool slow_digest;       /* Slower digestion */
1284         bool bless_blade;       /* Blessed blade */
1285         bool xtra_might;        /* Extra might bow */
1286         bool impact[2];         /* Earthquake blows */
1287         bool pass_wall;     /* Permanent wraithform */
1288         bool kill_wall;
1289         bool dec_mana;
1290         bool easy_spell;
1291         bool heavy_spell;
1292         bool warning;
1293         bool mighty_throw;
1294         bool see_nocto;         /* Noctovision */
1295
1296         s16b to_dd[2]; /* Extra dice/sides */
1297         s16b to_ds[2];
1298
1299         s16b dis_to_h[2];       /* Known bonus to hit (wield) */
1300         s16b dis_to_h_b;        /* Known bonus to hit (bow) */
1301         s16b dis_to_d[2];       /* Known bonus to dam (wield) */
1302         s16b dis_to_a;          /* Known bonus to ac */
1303
1304         s16b dis_ac;            /* Known base ac */
1305
1306         s16b to_h[2];                   /* Bonus to hit (wield) */
1307         s16b to_h_b;                    /* Bonus to hit (bow) */
1308         s16b to_h_m;                    /* Bonus to hit (misc) */
1309         s16b to_d[2];                   /* Bonus to dam (wield) */
1310         s16b to_d_m;                    /* Bonus to dam (misc) */
1311         s16b to_a;                      /* Bonus to ac */
1312
1313         s16b to_m_chance;               /* Minusses to cast chance */
1314
1315         bool ryoute;
1316         bool migite;
1317         bool hidarite;
1318         bool no_flowed;
1319
1320         s16b ac;                        /* Base ac */
1321
1322         s16b see_infra;         /* Infravision range */
1323
1324         s16b skill_dis;         /* Skill: Disarming */
1325         s16b skill_dev;         /* Skill: Magic Devices */
1326         s16b skill_sav;         /* Skill: Saving throw */
1327         s16b skill_stl;         /* Skill: Stealth factor */
1328         s16b skill_srh;         /* Skill: Searching ability */
1329         s16b skill_fos;         /* Skill: Searching frequency */
1330         s16b skill_thn;         /* Skill: To hit (normal) */
1331         s16b skill_thb;         /* Skill: To hit (shooting) */
1332         s16b skill_tht;         /* Skill: To hit (throwing) */
1333         s16b skill_dig;         /* Skill: Digging */
1334
1335         s16b num_blow[2];       /* Number of blows */
1336         s16b num_fire;          /* Number of shots */
1337
1338         byte tval_xtra;         /* Correct xtra tval */
1339
1340         byte tval_ammo;         /* Correct ammo tval */
1341
1342         byte pspeed;            /* Current speed */
1343 };
1344
1345
1346 /*
1347  * A structure to hold "rolled" information
1348  */
1349 typedef struct birther birther;
1350
1351 struct birther
1352 {
1353         byte psex;         /* Sex index */
1354         byte prace;        /* Race index */
1355         byte pclass;       /* Class index */
1356         byte pseikaku;     /* Seikaku index */
1357         byte realm1;       /* First magic realm */
1358         byte realm2;       /* Second magic realm */
1359
1360         s16b age;
1361         s16b ht;
1362         s16b wt;
1363         s16b sc;
1364
1365         s32b au;
1366
1367         s16b stat_max[6];       /* Current "maximal" stat values */
1368         s16b stat_max_max[6];   /* Maximal "maximal" stat values */
1369         s16b player_hp[PY_MAX_LEVEL];
1370
1371         s16b chaos_patron;
1372
1373         s16b vir_types[8];
1374
1375         char history[4][60];
1376
1377         bool quick_ok;
1378 };
1379
1380
1381 /* For Monk martial arts */
1382
1383 typedef struct martial_arts martial_arts;
1384
1385 struct martial_arts
1386 {
1387         cptr    desc;       /* A verbose attack description */
1388         int     min_level;  /* Minimum level to use */
1389         int     chance;     /* Chance of 'success' */
1390         int     dd;         /* Damage dice */
1391         int     ds;         /* Damage sides */
1392         int     effect;     /* Special effects */
1393 };
1394
1395 typedef struct kamae kamae;
1396
1397 struct kamae
1398 {
1399         cptr    desc;       /* A verbose kamae description */
1400         int     min_level;  /* Minimum level to use */
1401         cptr    info;
1402 };
1403
1404 /* Mindcrafters */
1405 typedef struct mind_type mind_type;
1406 struct mind_type
1407 {
1408         int     min_lev;
1409         int     mana_cost;
1410         int     fail;
1411         cptr    name;
1412 };
1413
1414 typedef struct mind_power mind_power;
1415 struct mind_power
1416 {
1417         mind_type info[MAX_MIND_POWERS];
1418 };
1419
1420 /* Imitator */
1421
1422 typedef struct monster_power monster_power;
1423 struct monster_power
1424 {
1425         int     level;
1426         int     smana;
1427         int     fail;
1428         int     manedam;
1429         int     manefail;
1430         int     use_stat;
1431         cptr    name;
1432 };
1433
1434
1435 /*
1436  * A structure to describe a building.
1437  * From Kamband
1438  */
1439 typedef struct building_type building_type;
1440
1441 struct building_type
1442 {
1443         char name[20];                  /* proprietor name */
1444         char owner_name[20];            /* proprietor name */
1445         char owner_race[20];            /* proprietor race */
1446
1447         char act_names[8][30];          /* action names */
1448         s32b member_costs[8];           /* Costs for class members of building */
1449         s32b other_costs[8];                /* Costs for nonguild members */
1450         char letters[8];                /* action letters */
1451         s16b actions[8];                /* action codes */
1452         s16b action_restr[8];           /* action restrictions */
1453
1454         s16b member_class[MAX_CLASS];   /* which classes are part of guild */
1455         s16b member_race[MAX_RACES];    /* which classes are part of guild */
1456         s16b member_realm[MAX_MAGIC+1]; /* which realms are part of guild */
1457 };
1458
1459
1460 /* Border */
1461 typedef struct border_type border_type;
1462 struct border_type
1463 {
1464         s16b north[MAX_WID];
1465         s16b south[MAX_WID];
1466         s16b east[MAX_HGT];
1467         s16b west[MAX_HGT];
1468         s16b north_west;
1469         s16b north_east;
1470         s16b south_west;
1471         s16b south_east;
1472 };
1473
1474
1475 /*
1476  * A structure describing a wilderness area
1477  * with a terrain or a town
1478  */
1479 typedef struct wilderness_type wilderness_type;
1480 struct wilderness_type
1481 {
1482         int         terrain;
1483         int         town;
1484         int         road;
1485         u32b        seed;
1486         s16b        level;
1487         byte        entrance;
1488 };
1489
1490
1491 /*
1492  * A structure describing a town with
1493  * stores and buildings
1494  */
1495 typedef struct town_type town_type;
1496 struct town_type
1497 {
1498         char        name[32];
1499         u32b        seed;      /* Seed for RNG */
1500         store_type      *store;    /* The stores [MAX_STORES] */
1501         byte        numstores;
1502 };
1503
1504 /* Dungeons */
1505 typedef struct dun_type dun_type;
1506 struct dun_type
1507 {
1508         byte min_level; /* Minimum level in the dungeon */
1509         byte max_level; /* Maximum dungeon level allowed */
1510
1511         cptr name;      /* The name of the dungeon */
1512 };
1513
1514 /*
1515  * Sort-array element
1516  */
1517 typedef struct tag_type tag_type;
1518
1519 struct tag_type
1520 {
1521         int     tag;
1522         int     index;
1523 };
1524
1525 typedef bool (*monster_hook_type)(int r_idx);
1526
1527
1528 /*
1529  * This seems like a pretty standard "typedef"
1530  */
1531 typedef int (*inven_func)(object_type *);
1532
1533
1534 /*
1535  * Semi-Portable High Score List Entry (128 bytes) -- BEN
1536  *
1537  * All fields listed below are null terminated ascii strings.
1538  *
1539  * In addition, the "number" fields are right justified, and
1540  * space padded, to the full available length (minus the "null").
1541  *
1542  * Note that "string comparisons" are thus valid on "pts".
1543  */
1544
1545 typedef struct high_score high_score;
1546
1547 struct high_score
1548 {
1549         char what[8];           /* Version info (string) */
1550
1551         char pts[10];           /* Total Score (number) */
1552
1553         char gold[10];          /* Total Gold (number) */
1554
1555         char turns[10];         /* Turns Taken (number) */
1556
1557         char day[10];           /* Time stamp (string) */
1558
1559         char who[16];           /* Player Name (string) */
1560
1561         char uid[8];            /* Player UID (number) */
1562
1563         char sex[2];            /* Player Sex (string) */
1564         char p_r[3];            /* Player Race (number) */
1565         char p_c[3];            /* Player Class (number) */
1566         char p_a[3];            /* Player Seikaku (number) */
1567
1568         char cur_lev[4];                /* Current Player Level (number) */
1569         char cur_dun[4];                /* Current Dungeon Level (number) */
1570         char max_lev[4];                /* Max Player Level (number) */
1571         char max_dun[4];                /* Max Dungeon Level (number) */
1572
1573         char how[40];           /* Method of death (string) */
1574 };
1575
1576
1577 typedef struct
1578 {
1579         s16b feat;    /* Feature tile */
1580         byte percent; /* Chance of type */
1581 }
1582 feat_prob;
1583
1584
1585 /* A structure for the != dungeon types */
1586 typedef struct dungeon_info_type dungeon_info_type;
1587 struct dungeon_info_type {
1588         u32b name;              /* Name */
1589         u32b text;              /* Description */
1590
1591         byte dy;
1592         byte dx;
1593
1594         feat_prob floor[DUNGEON_FEAT_PROB_NUM]; /* Floor probability */
1595         feat_prob fill[DUNGEON_FEAT_PROB_NUM];  /* Cave wall probability */
1596         s16b outer_wall;                        /* Outer wall tile */
1597         s16b inner_wall;                        /* Inner wall tile */
1598         s16b stream1;                           /* stream tile */
1599         s16b stream2;                           /* stream tile */
1600
1601         s16b mindepth;         /* Minimal depth */
1602         s16b maxdepth;         /* Maximal depth */
1603         byte min_plev;         /* Minimal plev needed to enter -- it's an anti-cheating mesure */
1604         s16b pit;
1605         s16b nest;
1606         byte mode;              /* Mode of combinaison of the monster flags */
1607
1608         int min_m_alloc_level;  /* Minimal number of monsters per level */
1609         int max_m_alloc_chance; /* There is a 1/max_m_alloc_chance chance per round of creating a new monster */
1610
1611         u32b flags1;            /* Flags 1 */
1612
1613         u32b mflags1;           /* The monster flags that are allowed */
1614         u32b mflags2;
1615         u32b mflags3;
1616         u32b mflags4;
1617         u32b mflags5;
1618         u32b mflags6;
1619         u32b mflags7;
1620         u32b mflags8;
1621         u32b mflags9;
1622         u32b mflagsr;
1623
1624         char r_char[5];         /* Monster race allowed */
1625         int final_object;       /* The object you'll find at the bottom */
1626         int final_artifact;     /* The artifact you'll find at the bottom */
1627         int final_guardian;     /* The artifact's guardian. If an artifact is specified, then it's NEEDED */
1628
1629         byte special_div;       /* % of monsters affected by the flags/races allowed, to add some variety */
1630         int tunnel_percent;
1631         int obj_great;
1632         int obj_good;
1633 };
1634
1635
1636 /*
1637  *  A structure type for entry of auto-picker/destroyer
1638  */
1639 typedef struct {
1640         cptr name;          /* Items which have 'name' as part of its name match */
1641         cptr insc;          /* Items will be auto-inscribed as 'insc' */
1642         u32b flag[2];       /* Misc. keyword to be matched */
1643         byte action;        /* Auto-pickup or Destroy or Leave items */
1644         byte dice;          /* Weapons which have more than 'dice' dice match */
1645         byte bonus;         /* Items which have more than 'bonus' magical bonus match */
1646 } autopick_type;
1647
1648
1649 /*
1650  *  A structure type for the saved floor
1651  */
1652 typedef struct 
1653 {
1654         s16b floor_id;        /* No recycle until 65536 IDs are all used */
1655         byte savefile_id;     /* ID for savefile (from 0 to MAX_SAVED_FLOOR) */
1656         s16b dun_level;
1657         s32b last_visit;      /* Time count of last visit. 0 for new floor. */
1658         u32b visit_mark;      /* Older has always smaller mark. */
1659         s16b upper_floor_id;  /* a floor connected with level teleportation */
1660         s16b lower_floor_id;  /* a floor connected with level tel. and trap door */
1661 } saved_floor_type;
1662
1663
1664 /*
1665  *  A structure type for terrain template of saving dungeon floor
1666  */
1667 typedef struct
1668 {
1669         u16b info;
1670         s16b feat;
1671         s16b mimic;
1672         s16b special;
1673         u16b occurrence;
1674 } cave_template_type;
1675
1676
1677 /*
1678  * A structure type for arena entry
1679  */
1680 typedef struct
1681 {
1682         s16b r_idx; /* Monster (0 means victory prizing) */
1683         byte tval;  /* tval of prize (0 means no prize) */
1684         byte sval;  /* sval of prize */
1685 } arena_type;
1686
1687
1688 /*
1689  * A structure type for doors
1690  */
1691 typedef struct
1692 {
1693         s16b open;
1694         s16b broken;
1695         s16b closed;
1696         s16b locked[MAX_LJ_DOORS];
1697         s16b num_locked;
1698         s16b jammed[MAX_LJ_DOORS];
1699         s16b num_jammed;
1700 } door_type;
1701
1702
1703 #ifdef TRAVEL
1704 /*
1705  *  A structure type for travel command
1706  */
1707 typedef struct {
1708         int run; /* Remaining grid number */
1709         int cost[MAX_HGT][MAX_WID];
1710         int x; /* Target X */
1711         int y; /* Target Y */
1712         int dir; /* Running direction */
1713 } travel_type;
1714 #endif
1715
1716 typedef struct {
1717         cptr flag;
1718         byte index;
1719         byte level;
1720         s32b value;
1721         struct {
1722                 int constant;
1723                 int dice;
1724         } timeout;
1725         cptr desc;
1726 } activation_type;
1727
1728 typedef struct {
1729         int flag;
1730         int type;
1731         cptr name;
1732 } dragonbreath_type;