1 /* File: types.h */
2 
3 /* Purpose: global type declarations */
4 
5 /*
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research, and
9  * not for profit purposes provided that this copyright and statement are
10  * included in all such copies.
11  */
12 
13 
14 /*
15  * Note that "char" may or may not be signed, and that "signed char"
16  * may or may not work on all machines.  So always use "s16b" or "s32b"
17  * for signed values.  Also, note that unsigned values cause math problems
18  * in many cases, so try to only use "u16b" and "u32b" for "bit flags",
19  * unless you really need the extra bit of information, or you really
20  * need to restrict yourself to a single byte for storage reasons.
21  *
22  * Also, if possible, attempt to restrict yourself to sub-fields of
23  * known size (use "s16b" or "s32b" instead of "int", and "byte" instead
24  * of "bool"), and attempt to align all fields along four-byte words, to
25  * optimize storage issues on 32-bit machines.  Also, avoid "bit flags"
26  * since these increase the code size and slow down execution.  When
27  * you need to store bit flags, use one byte per flag, or, where space
28  * is an issue, use a "byte" or "u16b" or "u32b", and add special code
29  * to access the various bit flags.
30  *
31  * Many of these structures were developed to reduce the number of global
32  * variables, facilitate structured program design, allow the use of ascii
33  * template files, simplify access to indexed data, or facilitate efficient
34  * clearing of many variables at once.
35  *
36  * Certain data is saved in multiple places for efficient access, currently,
37  * this includes the tval/sval/weight fields in "object_type", various fields
38  * in "header_type", and the "m_idx" and "o_idx" fields in "cave_type".  All
39  * of these could be removed, but this would, in general, slow down the game
40  * and increase the complexity of the code.
41  */
42 
43 
44 
45 
46 
47 /*
48  * Information about maximal indices of certain arrays
49  * Actually, these are not the maxima, but the maxima plus one
50  */
51 
52 typedef struct maxima maxima;
53 
54 struct maxima
55 {
56 	u32b fake_text_size;
57 	u32b fake_name_size;
58 
59 	u16b f_max;	/* Max size for "f_info[]" */
60 	u16b k_max;	/* Max size for "k_info[]" */
61 	u16b a_max;	/* Max size for "a_info[]" */
62 	u16b e_max;	/* Max size for "e_info[]" */
63 	u16b r_max;	/* Max size for "r_info[]" */
64 	u16b v_max;	/* Max size for "v_info[]" */
65 
66 	u16b q_max;	/* Max size for quest array */
67 
68 	u16b t_max;	/* Max size for field types array */
69 	u16b fld_max;	/* Max size for field list */
70 	u16b rg_max;	/* Max size for region list */
71 
72 	u16b wn_max;	/* Max size for wilderness tree nodes */
73 	u16b wt_max;	/* Max size for wilderness gen types */
74 	u16b wp_max;	/* Max places in the wilderness */
75 
76 	u16b o_max;	/* Max size for "o_list[]" */
77 	u16b m_max;	/* Max size for "m_list[]" */
78 };
79 
80 
81 /*
82  * Structure used to store information required for LOS
83  * calculatations.  The same data can be inverted to
84  * get the squares affected by a projection.  Those squares
85  * can be iterated over to get a 'flight path' for arrows
86  * and thrown items...
87  */
88 
89 typedef struct project_type project_type;
90 
91 struct project_type
92 {
93 	/* Offset of square */
94 	byte x;
95 	byte y;
96 
97 	/* Index into array if this square is a wall */
98 	byte slope;
99 	byte square;
100 };
101 
102 
103 /*
104  * Information about terrain "features"
105  */
106 
107 typedef struct feature_type feature_type;
108 
109 struct feature_type
110 {
111 	u32b name;	/* Name (offset) */
112 	u32b text;	/* Text (offset) */
113 
114 	byte d_attr;	/* Default feature attribute */
115 	char d_char;	/* Default feature character */
116 
117 
118 	byte x_attr;	/* Desired feature attribute */
119 	char x_char;	/* Desired feature character */
120 
121 	byte w_attr;	/* Desired extra feature attribute */
122 	char w_char;	/* Desired extra feature character */
123 
124 	byte flags;	/* Properties of the feature */
125 };
126 
127 
128 /*
129  * Hack - a type for 'object flags'
130  */
131 typedef struct object_flags object_flags;
132 
133 struct object_flags
134 {
135 	u32b flags[4];
136 };
137 
138 
139 /*
140  * Information about object "kinds", including player knowledge.
141  *
142  * Only "aware" and "tried" are saved in the savefile
143  */
144 
145 typedef struct object_kind object_kind;
146 
147 struct object_kind
148 {
149 	u32b name;	/* Name (offset) */
150 	u32b text;	/* Text (offset) */
151 
152 	byte tval;	/* Object type */
153 	byte sval;	/* Object sub type */
154 
155 	s16b pval;	/* Object extra info */
156 
157 	s16b to_h;	/* Bonus to hit */
158 	s16b to_d;	/* Bonus to damage */
159 	s16b to_a;	/* Bonus to armor */
160 
161 	s16b ac;	/* Base armor */
162 
163 	byte dd, ds;	/* Damage dice/sides */
164 
165 	s16b weight;	/* Weight */
166 
167 	s32b cost;	/* Object "base cost" */
168 
169 	u32b flags[4];	/* Flags */
170 
171 	byte locale[4];	/* Allocation level(s) */
172 	byte chance[4];	/* Allocation chance(s) */
173 
174 	byte level;	/* Level */
175 
176 	byte extra;	/* Rarity (for special randarts) */
177 
178 	u32b trigger[MAX_TRIGGER]; /* Special object scripts */
179 
180 	byte d_attr;	/* Default object attribute */
181 	char d_char;	/* Default object character */
182 
183 
184 	byte x_attr;	/* Desired object attribute */
185 	char x_char;	/* Desired object character */
186 
187 
188 	byte flavor;	/* Special object flavor (or zero) */
189 
190 	bool easy_know;	/* This object is always known (if aware) */
191 
192 
193 	bool aware;	/* The player is "aware" of the item's effects */
194 
195 	bool tried;	/* The player has "tried" one of the items */
196 };
197 
198 
199 /*
200  * "Themed" objects.
201  * Probability in percent for each class of objects to be dropped.
202  * This could perhaps be an array - but that wouldn't be as clear.
203  */
204 typedef struct obj_theme obj_theme;
205 
206 struct obj_theme
207 {
208 	byte treasure;
209 	byte combat;
210 	byte magic;
211 	byte tools;
212 };
213 
214 
215 /*
216  * Information about "artifacts".
217  *
218  * Note that the save-file only writes "cur_num" to the savefile.
219  *
220  * Note that "max_num" is always "1" (if that artifact "exists")
221  */
222 
223 typedef struct artifact_type artifact_type;
224 
225 struct artifact_type
226 {
227 	u32b name;	/* Name (offset) */
228 	u32b text;	/* Text (offset) */
229 
230 	byte tval;	/* Artifact type */
231 	byte sval;	/* Artifact sub type */
232 
233 	s16b pval;	/* Artifact extra info */
234 
235 	s16b to_h;	/* Bonus to hit */
236 	s16b to_d;	/* Bonus to damage */
237 	s16b to_a;	/* Bonus to armor */
238 
239 	s16b ac;	/* Base armor */
240 
241 	byte dd, ds;	/* Damage when hits */
242 
243 	s16b weight;	/* Weight */
244 
245 	s32b cost;	/* Artifact "cost" */
246 
247 	u32b flags[4];	/* Artifact Flags */
248 
249 	byte level;	/* Artifact level */
250 	byte rarity;	/* Artifact rarity */
251 
252 	u32b trigger[MAX_TRIGGER]; /* Special object scripts */
253 
254 	byte cur_num;	/* Number created (0 or 1) */
255 	byte max_num;	/* Unused (should be "1") */
256 };
257 
258 
259 /*
260  * Information about "ego-items".
261  */
262 
263 typedef struct ego_item_type ego_item_type;
264 
265 struct ego_item_type
266 {
267 	u32b name;	/* Name (offset) */
268 	u32b text;	/* Text (offset) */
269 
270 	byte slot;	/* Standard slot value */
271 	byte rating;	/* Rating boost */
272 
273 	byte level;	/* Minimum level */
274 	byte rarity;	/* Object rarity */
275 
276 	s16b max_to_h;	/* Maximum to-hit bonus */
277 	s16b max_to_d;	/* Maximum to-dam bonus */
278 	s16b max_to_a;	/* Maximum to-ac bonus */
279 
280 	s16b max_pval;	/* Maximum pval */
281 
282 	s32b cost;	/* Ego-item "cost" */
283 
284 	u32b flags[4];	/* Ego-Item Flags */
285 
286 	u32b trigger[MAX_TRIGGER]; /* Special object scripts */
287 };
288 
289 
290 /*
291  * Monster blow structure
292  *
293  *	- Method (RBM_*)
294  *	- Effect (RBE_*)
295  *	- Damage Dice
296  *	- Damage Sides
297  */
298 
299 typedef struct monster_blow monster_blow;
300 
301 struct monster_blow
302 {
303 	byte method;
304 	byte effect;
305 	byte d_dice;
306 	byte d_side;
307 };
308 
309 
310 
311 /*
312  * Monster "race" information, including racial memories
313  *
314  * Note that "d_attr" and "d_char" are used for MORE than "visual" stuff.
315  *
316  * Note that "x_attr" and "x_char" are used ONLY for "visual" stuff.
317  *
318  * Note that "cur_num" (and "max_num") represent the number of monsters
319  * of the given race currently on (and allowed on) the current level.
320  * This information yields the "dead" flag for Unique monsters.
321  *
322  * Note that "max_num" is reset when a new player is created.
323  * Note that "cur_num" is reset when a new level is created.
324  *
325  * Note that several of these fields, related to "recall", can be
326  * scrapped if space becomes an issue, resulting in less "complete"
327  * monster recall (no knowledge of spells, etc).  All of the "recall"
328  * fields have a special prefix to aid in searching for them.
329  */
330 
331 
332 typedef struct monster_race monster_race;
333 
334 struct monster_race
335 {
336 	u32b name;	/* Name (offset) */
337 	u32b text;	/* Text (offset) */
338 
339 	s16b hdice;	/* Creatures hit dice count */
340 	s16b hside;	/* Creatures hit dice sides */
341 
342 	s16b ac;	/* Armour Class */
343 
344 	s16b sleep;	/* Inactive counter (base) */
345 	byte aaf;	/* Area affect radius (1-100) */
346 	byte speed;	/* Speed (normally 110) */
347 
348 	s32b mexp;	/* Exp value for kill */
349 
350 	s16b extra;	/* Unused (for now) */
351 
352 	byte freq_inate;	/* Inate spell frequency */
353 	byte freq_spell;	/* Other spell frequency */
354 
355 	u32b flags[9];	/* Flags 1 (general) */
356 			/* Flags 2 (abilities) */
357 			/* Flags 3 (race/resist) */
358 			/* Flags 4 (inate/breath) */
359 			/* Flags 5 (normal spells) */
360 			/* Flags 6 (special spells) */
361 			/* Flags 7 (movement related abilities) */
362 			/* Flags 8 (wilderness info) */
363 			/* Flags 9 (drops info) */
364 
365 	monster_blow blow[4];	/* Up to four blows per round */
366 
367 
368 	byte level;	/* Level of creature */
369 	byte rarity;	/* Rarity of creature */
370 
371 
372 	byte d_attr;	/* Default monster attribute */
373 	char d_char;	/* Default monster character */
374 
375 
376 	byte x_attr;	/* Desired monster attribute */
377 	char x_char;	/* Desired monster character */
378 
379 
380 	byte max_num;	/* Maximum population allowed per level */
381 
382 	byte cur_num;	/* Monster population on current level */
383 
384 
385 	s16b r_sights;	/* Count sightings of this monster */
386 	s16b r_deaths;	/* Count deaths from this monster */
387 
388 	s16b r_pkills;	/* Count monsters killed in this life */
389 	s16b r_tkills;	/* Count monsters killed in all lives */
390 
391 	byte r_wake;	/* Number of times woken up (?) */
392 	byte r_ignore;	/* Number of times ignored (?) */
393 
394 	byte r_xtra1;	/* Something (unused) */
395 	byte r_xtra2;	/* Something (unused) */
396 
397 	byte r_drop_gold;	/* Max number of gold dropped at once */
398 	byte r_drop_item;	/* Max number of item dropped at once */
399 
400 	byte r_cast_inate;	/* Max number of inate spells seen */
401 	byte r_cast_spell;	/* Max number of other spells seen */
402 
403 	byte r_blows[4];	/* Number of times each blow type was seen */
404 
405 	u32b r_flags[9];	/* Observed racial flags */
406 
407 	obj_theme obj_drop;	/* Type of objects to drop when killed */
408 
409 	u16b r_see;	/* Number of monsters of this type visible */
410 };
411 
412 
413 
414 /*
415  * Information about "vault generation"
416  */
417 
418 typedef struct vault_type vault_type;
419 
420 struct vault_type
421 {
422 	u32b name;	/* Name (offset) */
423 	u32b text;	/* Text (offset) */
424 
425 	byte typ;	/* Vault type */
426 
427 	byte rat;	/* Vault rating */
428 
429 	byte hgt;	/* Vault height */
430 	byte wid;	/* Vault width */
431 };
432 
433 
434 
435 
436 
437 /*
438  * A single "grid" in a Cave
439  *
440  * Note that several aspects of the code restrict the actual cave
441  * to a max size of 256 by 256.  In partcular, locations are often
442  * saved as bytes, limiting each coordinate to the 0-255 range.
443  *
444  * The "o_idx" and "m_idx" fields are very interesting.  There are
445  * many places in the code where we need quick access to the actual
446  * monster or object(s) in a given cave grid.  The easiest way to
447  * do this is to simply keep the index of the monster and object
448  * (if any) with the grid, but this takes 198*66*4 bytes of memory.
449  * Several other methods come to mind, which require only half this
450  * amound of memory, but they all seem rather complicated, and would
451  * probably add enough code that the savings would be lost.  So for
452  * these reasons, we simply store an index into the "o_list" and
453  * "m_list" arrays, using "zero" when no monster/object is present.
454  *
455  * Note that "o_idx" is the index of the top object in a stack of
456  * objects, using the "next_o_idx" field of objects (see below) to
457  * create the singly linked list of objects.  If "o_idx" is zero
458  * then there are no objects in the grid.
459  *
460  * Note the special fields for the "MONSTER_FLOW" code.
461  */
462 
463 typedef struct cave_type cave_type;
464 
465 struct cave_type
466 {
467 	byte info;	/* Hack -- cave flags */
468 
469 	byte feat;	/* Hack -- feature type */
470 
471 	s16b o_idx;	/* Object in this grid */
472 
473 	s16b m_idx;	/* Monster in this grid */
474 
475 	s16b fld_idx;	/* Field in this grid */
476 
477 	byte cost;	/* Hack -- cost of flowing */
478 	byte when;	/* Hack -- when cost was computed */
479 };
480 
481 
482 /*
483  * Cave data that is player-specific
484  *
485  * The feat is the memorized feat on this square
486  */
487 
488 typedef struct pcave_type pcave_type;
489 
490 struct pcave_type
491 {
492 	byte player;	/* Player-specific flags */
493 	byte feat;	/* Memorized feature */
494 };
495 
496 
497 /*
498  * Simple structure to hold a map location
499  */
500 typedef struct coord coord;
501 
502 struct coord
503 {
504 	u16b y;
505 	u16b x;
506 };
507 
508 
509 /*
510  * Pointer to a 16x16 block of cave grids.
511  * The grids are allocated and deallocated in large
512  * blocks for speed.
513  *
514  * Note - blocks also do not use the region code
515  * because of speed.  (We don't need to constantly
516  * allocate and deallocate everything.)
517  */
518 typedef cave_type **blk_ptr;
519 
520 /*
521  * Alias of block pointer - region type
522  *
523  * Whilst these are the same type as blk_ptr, they
524  * are used in a different way.  (Allocating large
525  * chucks at a time.)
526  */
527 typedef cave_type **region_type;
528 
529 /*
530  * Pointer to a 16x16 block of grids of player information.
531  * The grids are allocated and deallocated in large
532  * blocks for speed.
533  */
534 typedef pcave_type **pblk_ptr;
535 
536 
537 /*
538  * Region equivalent of the above.
539  */
540 typedef pcave_type **pregion_type;
541 
542 
543 /*
544  * Region information
545  *
546  * Note - most of this stuff is dungeon specific.
547  *
548  * Note - the reason why this isn't part of region_type
549  * is because we don't want to have to add offsets all
550  * the time for every cave access.  That would be slow.
551  */
552 typedef struct region_info region_info;
553 
554 struct region_info
555 {
556 	u16b xsize;
557 	u16b ysize;
558 
559 	u16b refcount;
560 
561 	byte flags;
562 };
563 
564 /*
565  * Structure used to generate the wilderness.
566  * This stores the "height", "population" and "law" results
567  * after the initial plasma fractal routines.
568  * These values are then converted into simple look up numbers
569  * for the wilderness generation type and wandering monster type.
570  */
571 typedef struct wild_gen1_type wild_gen1_type;
572 
573 struct wild_gen1_type
574 {
575 	u16b hgt_map;
576 	u16b pop_map;
577 	u16b law_map;
578 };
579 
580 /*
581  * Structure used during creation of wilderness.
582  * It contains the transition state between the above
583  * structure and the one that follows.
584  */
585 typedef struct wild_gen2_type wild_gen2_type;
586 
587 struct wild_gen2_type
588 {
589 	byte hgt_map;
590 	byte pop_map;
591 	byte law_map;
592 	byte place;
593 	byte dummy;
594 	byte info;
595 };
596 
597 
598 /* Structure used to hold the completed wilderness */
599 
600 typedef struct wild_done_type wild_done_type;
601 
602 struct wild_done_type
603 {
604 	u16b wild;
605 	byte place;
606 	byte info;
607 	byte mon_gen;
608 	byte mon_prob;
609 };
610 
611 /*
612  * To save room, the above three structures are combined to form the completed
613  * wilderness type.
614  */
615 
616 typedef union wild_type wild_type;
617 union wild_type
618 {
619 	wild_gen1_type gen;
620 	wild_gen2_type trans;
621 	wild_done_type done;
622 };
623 
624 
625 /*
626  * An array of this structure is used to work out what wilderness type
627  * is at each 16x16 block.
628  */
629 typedef struct wild_choice_tree_type wild_choice_tree_type;
630 
631 struct wild_choice_tree_type
632 {
633 	/*
634 	 * Stores what type of node this is -
635 	 * both what type of cutoff (hgt,pop,law)
636 	 * and whether the pointers reference
637 	 * another tree node- or a wilderness
638 	 * generation type.
639 	 */
640 	byte info;
641 
642 	/* cutoff for the split of the virtual BSP tree */
643 	byte cutoff;
644 
645 	/*
646 	 * chance1/(chance1+chance2) = prob. of going down
647 	 * the "left" branch.  (This is used when several
648 	 * wilderness generation functions inhabit the same
649 	 * area of parameter space.  This is used to select
650 	 * between the possibilities randomly.
651 	 */
652 	byte chance1;
653 	byte chance2;
654 
655 	/*
656 	 * These point to the left and right branches of the tree.
657 	 * Note - that since these also need to reference a wild.gen.type.
658 	 * these are index numbers of the "choice" or "gen" arrays.
659 	 * (depending on the value of info)
660 	 */
661 	u16b ptrnode1;
662 	u16b ptrnode2;
663 };
664 
665 
666 /*
667  * This type is used to describe a region in parameter space
668  * for wilderness generation.
669  */
670 typedef struct wild_bound_box_type wild_bound_box_type;
671 
672 struct wild_bound_box_type
673 {
674 	/* Min and max values for the cuboid in the parameter space */
675 
676 	byte hgtmin;
677 	byte hgtmax;
678 
679 	byte popmin;
680 	byte popmax;
681 
682 	byte lawmin;
683 	byte lawmax;
684 };
685 /*
686  * This data type stores the information on a particular
687  * wilderness generation type for 16x16 blocks, so the
688  * blocks can be
689  * 1) Made.
690  * 2) Looked at on the overhead map.
691  */
692 typedef struct wild_gen_data_type wild_gen_data_type;
693 
694 struct wild_gen_data_type
695 {
696 	byte feat;	/* The feature to look like on the overhead map */
697 
698 	byte gen_routine;	/* Generation routine number */
699 
700 	/*
701 	 * Course type - used in testing to see where monsters go
702 	 * in the wilderness.
703 	 */
704 	byte rough_type;
705 
706 	byte chance;	/* Chance for this type vs others */
707 
708 	byte data[8];	/* data for generation routine */
709 };
710 
711 
712 /*
713  * Object information, for a specific object.
714  *
715  * Note that a "discount" on an item is permanent and never goes away.
716  *
717  * Note that inscriptions are now handled via the "quark_str()" function
718  * applied to the "note" field, which will return NULL if "note" is zero.
719  *
720  * Note that "object" records are "copied" on a fairly regular basis,
721  * and care must be taken when handling such objects.
722  *
723  * "object flags" are now stored in the object data type, as are the
724  * known flags.  This allows the identification status of each flag
725  * to be stored seperately.
726  *
727  * Each cave grid points to one (or zero) objects via the "o_idx"
728  * field (above).  Each object then points to one (or zero) objects
729  * via the "next_o_idx" field, forming a singly linked list, which
730  * in game terms, represents a "stack" of objects in the same grid.
731  *
732  * Each monster points to one (or zero) objects via the "hold_o_idx"
733  * field (below).  Each object then points to one (or zero) objects
734  * via the "next_o_idx" field, forming a singly linked list, which
735  * in game terms, represents a pile of objects held by the monster.
736  *
737  * The "held_m_idx" field is used to indicate which monster, if any,
738  * is holding the object.  Objects being held have "ix=0" and "iy=0".
739  */
740 
741 typedef struct object_type object_type;
742 
743 struct object_type
744 {
745 	s16b k_idx;	/* Kind index (zero if "dead") */
746 
747 	s16b ix;	/* X-position on map, or zero */
748 	s16b iy;	/* Y-position on map, or zero */
749 
750 	s16b weight;	/* Item weight */
751 
752 	byte tval;	/* Item type (from kind) */
753 	byte sval;	/* Item sub-type (from kind) */
754 
755 	s16b pval;	/* Item extra-parameter */
756 
757 	byte discount;	/* Discount (if any) */
758 
759 	byte number;	/* Number of items */
760 
761 	s16b to_h;	/* Plusses to hit */
762 	s16b to_d;	/* Plusses to damage */
763 	s16b to_a;	/* Plusses to AC */
764 
765 	s16b ac;	/* Normal AC */
766 
767 	s16b timeout;	/* Timeout Counter */
768 
769 	byte dd, ds;	/* Damage dice/sides */
770 
771 	s16b next_o_idx;	/* Next object in stack (if any) */
772 
773 	s16b inscription;	/* Inscription index */
774 	s16b xtra_name;	/* Extra Name (Artifacts and ego items) */
775 
776 	u32b flags[4];	/* Flags */
777 
778 	u32b kn_flags[4];	/* Known Flags */
779 
780 	s32b cost;	/* Object "base cost" */
781 	s32b temp_cost;	/* Cost including shopkeeper effects */
782 
783 	s16b region;	/* Region */
784 
785 	byte feeling;	/* Game generated inscription number (eg, pseudo-id) */
786 
787 	byte a_idx;	/* Artifact type */
788 
789 	byte info;	/* Special flags */
790 
791 	s16b trigger[MAX_TRIGGER]; /* Special object scripts */
792 
793 	bool allocated;	/* Held in the o_list[] array */
794 };
795 
796 
797 
798 /*
799  * Monster information, for a specific monster.
800  *
801  * The "hold_o_idx" field points to the first object of a stack
802  * of objects (if any) being carried by the monster (see above).
803  */
804 
805 typedef struct monster_type monster_type;
806 
807 struct monster_type
808 {
809 	s16b r_idx;	/* Monster race index */
810 
811 	s16b csleep;	/* Inactive counter */
812 
813 	s16b fx;	/* X location on map */
814 	s16b fy;	/* Y location on map */
815 
816 
817 	s16b tx;	/* Target X location on map */
818 	s16b ty;	/* Target Y location on map */
819 
820 	s16b hp;	/* Current Hit points */
821 	s16b maxhp;	/* Max Hit points */
822 
823 
824 	byte mspeed;	/* Monster "speed" */
825 	byte energy;	/* Monster "energy" */
826 
827 	byte stunned;	/* Monster is stunned */
828 	byte confused;	/* Monster is confused */
829 
830 	byte monfear;	/* Monster is afraid */
831 	byte invulner;	/* Monster is temporarily invulnerable */
832 
833 	s16b hold_o_idx;	/* Object being held (if any) */
834 
835 	u32b smart;	/* Field for "smart_learn" */
836 
837 	s16b region;	/* Region */
838 
839 	byte cdis;	/* Current dis from player */
840 
841 	byte mflag;	/* Extra monster flags */
842 
843 	bool ml;	/* Monster is "visible" */
844 };
845 
846 /*
847  * Monster Race blow-method types
848  */
849 typedef struct rbm_type rbm_type;
850 struct rbm_type
851 {
852 	cptr name;
853 	cptr action;
854 
855 	u16b sound;
856 
857 	bool touched;
858 	bool cut;
859 	bool stun;
860 };
861 
862 
863 /*
864  * The thaumaturgical list of fields.
865  *
866  * (Equivalent to monster races, or object kinds.
867  *  They had to be called something. ;-) )
868  *
869  * Eventually most of this, and the following struct
870  * will be wrapped inside a python object.  Only things
871  * that need to be accessed quickly will be left as is.
872  */
873 
874 typedef struct field_thaum field_thaum;
875 struct field_thaum
876 {
877 	char *name;	/* The name of the field */
878 
879 	byte f_attr;	/* attribute */
880 	char f_char;	/* character */
881 
882 	byte d_attr;	/* Default attribute */
883 	char d_char;	/* Default char */
884 
885 	byte priority;	/* LOS priority higher = more visible */
886 
887 	byte type;	/* Type of field */
888 
889 	s16b count_init;	/* Counter for timed effects */
890 
891 	s16b action[FIELD_ACTION_MAX];	/* Action scripts */
892 
893 	/* Storage space for the actions to interact with. */
894 	byte data_init[8];
895 
896 	u16b info;	/* Information flags */
897 };
898 
899 
900 /*
901  * The field structure.
902  *
903  * Fields will be used to create a variety of effects from
904  * the ability to place traps on _all_ terrains (not just
905  * dungeon floor), to the nightmare mode automatic corpse raising.
906  *
907  * The new building / store code will use this structure.
908  *
909  */
910 typedef struct field_type field_type;
911 struct field_type
912 {
913 	byte f_attr;	/* attribute */
914 	char f_char;	/* character */
915 
916 	s16b t_idx;	/* field type index */
917 
918 	s16b fy;	/* Y location on map */
919 	s16b fx;	/* X location on map */
920 
921 	s16b next_f_idx;	/* Pointer to next field in list */
922 
923 	u16b info;	/* quick access flags */
924 
925 	/* Storage space for the actions to interact with. */
926 	byte data[8];
927 
928 	s16b counter;	/* Counter for timed effects */
929 
930 	s16b region;	/* Region */
931 
932 	byte priority;	/* LOS priority higher = more visible */
933 };
934 
935 
936 /*
937  * An entry for the object/monster allocation functions
938  *
939  * Pass 1 is determined from allocation information
940  * Pass 2 is determined from allocation restriction
941  * Pass 3 is determined from allocation calculation
942  */
943 
944 typedef struct alloc_entry alloc_entry;
945 
946 struct alloc_entry
947 {
948 	s16b index;	/* The actual index */
949 
950 	byte level;	/* Base dungeon level */
951 	byte prob1;	/* Probability, pass 1 */
952 	byte prob2;	/* Probability, pass 2 */
953 	byte prob3;	/* Probability, pass 3 */
954 };
955 
956 
957 /*
958  * Available "options"
959  *
960  *	- Normal and Current Value (TRUE or FALSE)
961  *
962  *	- Option Page Number (or zero)
963  *
964  *	- Textual name (or NULL)
965  *	- Textual description
966  */
967 
968 typedef struct option_type option_type;
969 
970 struct option_type
971 {
972 	bool o_val;
973 
974 	byte o_page;
975 
976 	cptr o_text;
977 	cptr o_desc;
978 };
979 
980 
981 /*
982  * There are three types of quest:
983  * General quests, Dungeon and wilderness quests.
984  * Each has its own type of data it needs to store
985  */
986 
987 /*
988  * Quest type-specific data.
989  */
990 
991 /* Bounty */
992 typedef struct quest_bnt quest_bnt;
993 
994 struct quest_bnt
995 {
996 	u16b r_idx;	/* Monster */
997 	u16b cur_num;	/* Number killed */
998 	u16b max_num;	/* Number required */
999 };
1000 
1001 /* Dungeon */
1002 typedef struct quest_dun quest_dun;
1003 
1004 struct quest_dun
1005 {
1006 	u16b r_idx;	/* Monster race */
1007 	u16b level;	/* Dungeon level */
1008 
1009 	s16b cur_num;	/* Number killed */
1010 	s16b max_num;	/* Number required */
1011 	s16b num_mon;	/* Number on the level */
1012 };
1013 
1014 /* Wilderness */
1015 typedef struct quest_wld quest_wld;
1016 
1017 struct quest_wld
1018 {
1019 	u16b refcount;	/* Refcount for wilderness code */
1020 	u16b place;	/* Equivalent "place number" */
1021 
1022 	u16b data;	/* Data so can choose completion */
1023 	byte depth;	/* Power of monsters */
1024 };
1025 
1026 /* Message */
1027 typedef struct quest_msg quest_msg;
1028 
1029 struct quest_msg
1030 {
1031 	u16b place;	/* Town to go to */
1032 	u16b shop;	/* Person to give it to */
1033 };
1034 
1035 
1036 /* Find item */
1037 typedef struct quest_fit quest_fit;
1038 
1039 struct quest_fit
1040 {
1041 	u16b a_idx;	/* Artifact index */
1042 	u16b place;	/* Dungeon it is in */
1043 };
1044 
1045 
1046 /* Find place */
1047 typedef struct quest_fpl quest_fpl;
1048 
1049 struct quest_fpl
1050 {
1051 	u16b place;	/* Place to find */
1052 };
1053 
1054 
1055 /* The union holding the quest-specific data */
1056 typedef union quest_data_type quest_data_type;
1057 union quest_data_type
1058 {
1059 	quest_bnt bnt;
1060 	quest_dun dun;
1061 	quest_wld wld;
1062 	quest_msg msg;
1063 	quest_fit fit;
1064 	quest_fpl fpl;
1065 };
1066 
1067 /*
1068  * Structure for the "quests"
1069  */
1070 typedef struct quest_type quest_type;
1071 
1072 struct quest_type
1073 {
1074 	byte status;	/* Is the quest taken, completed, finished? */
1075 
1076 	byte flags;	/* Quest flags */
1077 	byte type;	/* The quest type (gen/dun/wild) */
1078 
1079 	byte item;	/* Artificial quest item number */
1080 
1081 	u16b place;	/* Town where given */
1082 	u16b shop;	/* Quest-giver */
1083 	u16b reward;	/* Reward level */
1084 
1085 	byte c_type;	/* Type of creation trigger */
1086 	byte x_type;	/* Type of action trigger */
1087 
1088 	u32b timeout;	/* Time limits */
1089 
1090 	char name[128];	/* Quest name */
1091 
1092 	quest_data_type data;	/* Quest-specific data */
1093 };
1094 
1095 
1096 typedef struct magic_type magic_type;
1097 
1098 struct magic_type
1099 {
1100 	byte slevel;	/* Required level (to learn) */
1101 	byte smana;	/* Required mana (to cast) */
1102 };
1103 
1104 
1105 /*
1106  * Information about the player's "magic"
1107  *
1108  * Note that a player with a "spell_book" of "zero" is illiterate.
1109  */
1110 
1111 typedef struct player_magic player_magic;
1112 
1113 struct player_magic
1114 {
1115 	int spell_book;	/* Tval of spell books (if any) */
1116 	int spell_xtra;	/* Something for later */
1117 
1118 	int spell_stat;	/* Stat for spells (if any) */
1119 	int spell_type;	/* Spell type (mage/priest) */
1120 
1121 	int spell_first;	/* Level of first spell */
1122 	int spell_weight;	/* Weight that hurts spells */
1123 
1124 	magic_type info[MAX_REALM][32];	/* The available spells */
1125 };
1126 
1127 
1128 
1129 /*
1130  * Player sex info
1131  */
1132 
1133 typedef struct player_sex player_sex;
1134 
1135 struct player_sex
1136 {
1137 	cptr title;	/* Type of sex */
1138 
1139 	cptr winner;	/* Name of winner */
1140 };
1141 
1142 
1143 /*
1144  * Player racial info
1145  */
1146 
1147 typedef struct player_race player_race;
1148 
1149 struct player_race
1150 {
1151 	cptr title;	/* Type of race */
1152 
1153 	s16b r_adj[A_MAX];	/* Racial stat bonuses */
1154 
1155 	s16b r_dis;	/* disarming */
1156 	s16b r_dev;	/* magic devices */
1157 	s16b r_sav;	/* saving throw */
1158 	s16b r_stl;	/* stealth */
1159 	s16b r_sns;	/* sensing ability */
1160 	s16b r_fos;	/* search frequency */
1161 	s16b r_thn;	/* combat (normal) */
1162 	s16b r_thb;	/* combat (shooting) */
1163 
1164 	byte r_mhp;	/* Race hit-dice modifier */
1165 	byte r_exp;	/* Race experience factor */
1166 
1167 	byte b_age;	/* base age */
1168 	byte m_age;	/* mod age */
1169 
1170 	byte m_b_ht;	/* base height (males) */
1171 	byte m_m_ht;	/* mod height (males) */
1172 	byte m_b_wt;	/* base weight (males) */
1173 	byte m_m_wt;	/* mod weight (males) */
1174 
1175 	byte f_b_ht;	/* base height (females) */
1176 	byte f_m_ht;	/* mod height (females) */
1177 	byte f_b_wt;	/* base weight (females) */
1178 	byte f_m_wt;	/* mod weight (females) */
1179 
1180 	byte infra;	/* Infra-vision range */
1181 };
1182 
1183 
1184 /*
1185  * Player class info
1186  */
1187 
1188 typedef struct player_class player_class;
1189 
1190 struct player_class
1191 {
1192 	cptr title;	/* Type of class */
1193 
1194 	s16b c_adj[A_MAX];	/* Class stat modifier */
1195 
1196 	s16b c_dis;	/* class disarming */
1197 	s16b c_dev;	/* class magic devices */
1198 	s16b c_sav;	/* class saving throws */
1199 	s16b c_stl;	/* class stealth */
1200 	s16b c_sns;	/* class sensing ability */
1201 	s16b c_fos;	/* class searching frequency */
1202 	s16b c_thn;	/* class to hit (normal) */
1203 	s16b c_thb;	/* class to hit (bows) */
1204 
1205 	s16b x_dis;	/* extra disarming */
1206 	s16b x_dev;	/* extra magic devices */
1207 	s16b x_sav;	/* extra saving throws */
1208 	s16b x_stl;	/* extra stealth */
1209 	s16b x_sns;	/* extra sensing ability */
1210 	s16b x_fos;	/* extra searching frequency */
1211 	s16b x_thn;	/* extra to hit (normal) */
1212 	s16b x_thb;	/* extra to hit (bows) */
1213 
1214 	s16b c_mhp;	/* Class hit-dice adjustment */
1215 	s16b c_exp;	/* Class experience factor */
1216 
1217 	byte pet_upkeep_div;	/* Pet upkeep divider */
1218 	bool heavy_sense;
1219 };
1220 
1221 
1222 /*
1223  * Data describing the character.
1224  *
1225  * (Mostly roll-playing information)
1226  */
1227 typedef struct player_data player_data;
1228 
1229 struct player_data
1230 {
1231 	s16b age;	/* Characters age */
1232 	s16b ht;	/* Height */
1233 	s16b wt;	/* Weight */
1234 	s16b sc;	/* Social Class */
1235 
1236 	byte hitdie;	/* Hit dice (sides) */
1237 
1238 	byte psex;	/* Sex index */
1239 	byte prace;	/* Race index */
1240 	byte pclass;	/* Class index */
1241 };
1242 
1243 
1244 /*
1245  * Player spell data
1246  */
1247 typedef struct player_realm player_realm;
1248 
1249 struct player_realm
1250 {
1251 	u32b learned;	/* Spell flags */
1252 	u32b worked;	/* Spell flags */
1253 	u32b forgotten;	/* Spell flags */
1254 
1255 	byte realm;	/* Realm number */
1256 };
1257 
1258 typedef struct player_spell player_spell;
1259 
1260 struct player_spell
1261 {
1262 	player_realm r[2];	/* Magic realms */
1263 	byte order[PY_MAX_SPELLS];	/* Spell order */
1264 };
1265 
1266 /*
1267  * Timed effects acting on the player
1268  */
1269 typedef struct player_timed player_timed;
1270 
1271 struct player_timed
1272 {
1273 	s16b fast;	/* Timed -- Fast */
1274 	s16b slow;	/* Timed -- Slow */
1275 	s16b blind;	/* Timed -- Blindness */
1276 	s16b paralyzed;	/* Timed -- Paralysis */
1277 	s16b confused;	/* Timed -- Confusion */
1278 	s16b afraid;	/* Timed -- Fear */
1279 	s16b image;	/* Timed -- Hallucination */
1280 	s16b poisoned;	/* Timed -- Poisoned */
1281 	s16b cut;	/* Timed -- Cut */
1282 	s16b stun;	/* Timed -- Stun */
1283 
1284 	s16b protevil;	/* Timed -- Protection */
1285 	s16b invuln;	/* Timed -- Invulnerable */
1286 	s16b hero;	/* Timed -- Heroism */
1287 	s16b shero;	/* Timed -- Super Heroism */
1288 	s16b shield;	/* Timed -- Shield Spell */
1289 	s16b blessed;	/* Timed -- Blessed */
1290 	s16b invis;	/* Timed -- See Invisible */
1291 	s16b infra;	/* Timed -- Infra Vision */
1292 
1293 	s16b oppose_acid;	/* Timed -- oppose acid */
1294 	s16b oppose_elec;	/* Timed -- oppose lightning */
1295 	s16b oppose_fire;	/* Timed -- oppose heat */
1296 	s16b oppose_cold;	/* Timed -- oppose cold */
1297 	s16b oppose_pois;	/* Timed -- oppose poison */
1298 	s16b esp;	/* Timed ESP */
1299 	s16b wraith_form;	/* Timed wraithform */
1300 	s16b resist_magic;	/* Timed Resist Magic (later) */
1301 
1302 	s16b word_recall;	/* Word of recall counter */
1303 };
1304 
1305 /*
1306  * The state of the player
1307  */
1308 typedef struct player_state player_state;
1309 
1310 struct player_state
1311 {
1312 	char died_from[80];	/* Cause of death */
1313 
1314 	s16b resting;	/* Resting counter */
1315 	s16b running;	/* Running counter */
1316 
1317 	byte confusing;	/* Glowing hands */
1318 	byte searching;	/* Currently searching */
1319 
1320 	u16b total_winner;	/* Total winner */
1321 
1322 	u16b panic_save;	/* Panic save */
1323 	u16b noscore;	/* Cheating flags */
1324 
1325 	bool is_dead;	/* Player is dead */
1326 	bool wizard;	/* Player is in wizard mode */
1327 
1328 	bool playing;	/* True if player is playing */
1329 	bool leaving;	/* True if player is leaving */
1330 
1331 	bool create_up_stair;	/* Create up stair on next level */
1332 	bool create_down_stair;	/* Create down stair on next level */
1333 
1334 	byte feeling;	/* Most recent feeling */
1335 
1336 	s16b energy_use;	/* Energy use this turn */
1337 
1338 	bool cumber_armor;	/* Mana draining armor */
1339 	bool cumber_glove;	/* Mana draining gloves */
1340 	bool heavy_wield;	/* Heavy weapon */
1341 	bool heavy_shoot;	/* Heavy shooter */
1342 	bool icky_wield;	/* Icky weapon */
1343 	bool detected;	/* Detected for traps? */
1344 
1345 	bool skip_more;	/* Skip the --more-- prompt */
1346 	bool mon_fight;	/* Monster fighting indicator */
1347 
1348 	bool monk_armour_stat;	/* Status of monk armour */
1349 
1350 	byte noise_level;	/* Amount of noise since last update */
1351 
1352 	u16b store_top;		/* Top of store inventory list */
1353 };
1354 
1355 /*
1356  * Information about the player state for the running code
1357  */
1358 typedef struct player_run player_run;
1359 
1360 struct player_run
1361 {
1362 	s16b cur_dir;	/* Direction we are running */
1363 	s16b old_dir;	/* Direction we came from */
1364 	int  mode;      /* Current running algorithm */
1365 };
1366 
1367 /*
1368  * The current state of the command being executed
1369  * and the keys being pressed
1370  */
1371 typedef struct player_command player_command;
1372 
1373 struct player_command
1374 {
1375 	s16b cmd;	/* Gives identity of current command */
1376 	s16b arg;	/* Gives argument of current command */
1377 	s16b rep;	/* Gives repetition of current command */
1378 	s16b dir;	/* Gives direction of current command */
1379 
1380 	s16b new;	/* Hack -- command chaining XXX XXX */
1381 
1382 	/* Inkey status */
1383 	bool inkey_base;	/* See the "inkey()" function */
1384 	bool inkey_xtra;	/* See the "inkey()" function */
1385 	bool inkey_scan;	/* See the "inkey()" function */
1386 	bool inkey_flag;	/* See the "inkey()" function */
1387 };
1388 
1389 /*
1390  * The player stats
1391  */
1392 typedef struct player_stat player_stat;
1393 
1394 struct player_stat
1395 {
1396 	s16b max;	/* Current "maximal" stat values */
1397 	s16b cur;	/* Current "natural" stat values */
1398 
1399 	s16b use;	/* Current modified stats */
1400 	s16b top;	/* Maximal modified stats */
1401 
1402 	s16b add;	/* Equipment stat bonuses */
1403 	s16b ind;	/* Indexes into stat tables */
1404 };
1405 
1406 
1407 /*
1408  * Most of the "player" information goes here.
1409  *
1410  * This stucture gives us a large collection of player variables.
1411  *
1412  * This structure contains several "blocks" of information.
1413  *   (1) the "permanent" info
1414  *   (2) the "variable" info
1415  *   (3) the "transient" info
1416  *
1417  * All of the "permanent" info, and most of the "variable" info,
1418  * is saved in the savefile.  The "transient" info is recomputed
1419  * whenever anything important changes.
1420  */
1421 
1422 typedef struct player_type player_type;
1423 
1424 struct player_type
1425 {
1426 	s16b px;	/* Player location */
1427 	s16b py;	/* Player location */
1428 
1429 	player_data rp;	/* Role-play information */
1430 
1431 	s16b depth;	/* Cur depth */
1432 
1433 	s16b max_lev;	/* Max level */
1434 	s16b lev;	/* Cur level */
1435 
1436 	u16b exp_frac;	/* Cur exp frac (times 2^16) */
1437 
1438 	s32b max_exp;	/* Max experience */
1439 	s32b exp;	/* Cur experience */
1440 
1441 	s32b au;	/* Current Gold */
1442 
1443 	s16b place_num;	/* Current place number in the wilderness */
1444 
1445 	s32b wilderness_x;	/* Coordinates in the wilderness */
1446 	s32b wilderness_y;
1447 
1448 	s16b old_wild_x;	/* Previous block coords in the wilderness */
1449 	s16b old_wild_y;
1450 
1451 	s16b panel_x1;	/* Coordinates of top left hand corner of panel */
1452 	s16b panel_y1;
1453 
1454 	s16b panel_x2;	/* Coordinates of bottom right hand corner of panel */
1455 	s16b panel_y2;
1456 
1457 	s16b mhp;	/* Max hit pts */
1458 	s16b chp;	/* Cur hit pts */
1459 	u16b chp_frac;	/* Cur hit frac (times 2^16) */
1460 
1461 	s16b msp;	/* Max mana pts */
1462 	s16b csp;	/* Cur mana pts */
1463 	u16b csp_frac;	/* Cur mana frac (times 2^16) */
1464 
1465 	player_spell spell;	/* Spell information */
1466 
1467 	u32b muta1;	/* Mutations */
1468 	u32b muta2;	/* Mutations */
1469 	u32b muta3;	/* Mutations */
1470 
1471 	s16b virtues[MAX_PLAYER_VIRTUES];
1472 	s16b vir_types[MAX_PLAYER_VIRTUES];
1473 
1474 	s16b energy;	/* Current energy */
1475 	s16b food;	/* Current nutrition */
1476 
1477 	s16b player_hp[PY_MAX_LEVEL];	/* HP Array */
1478 
1479 	u16b expfact;	/* Experience factor
1480 					 * Note: was byte, causing overflow for Amberite
1481 					 * characters (such as Amberite Paladins)
1482 					 */
1483 	s16b chaos_patron;	/* Players Chaos Patron */
1484 
1485 	player_timed tim;	/* Timed effects */
1486 
1487 	player_state state;	/* Internal state of the player */
1488 
1489 	s16b skills[MAX_SKILL];	/* Player skills */
1490 
1491 	player_command cmd;	/* The current command status */
1492 
1493 	player_stat stat[A_MAX];	/* The player's stats */
1494 
1495 	/*** Pointers to player grid information ***/
1496 
1497 	pcave_type *pcave[MAX_HGT];
1498 	pblk_ptr **pwild;
1499 
1500 	/*** Boundary of player-known area ****/
1501 	u16b max_hgt;
1502 	u16b min_hgt;
1503 	u16b max_wid;
1504 	u16b min_wid;
1505 
1506 	/*** Temporary fields ***/
1507 
1508 	s32b align;	/* Good/evil/neutral */
1509 
1510 	s16b total_weight;	/* Total weight being carried */
1511 
1512 	s16b inventory;	/* Index to inventory item list */
1513 	object_type equipment[EQUIP_MAX];	/* Equipment */
1514 
1515 	s16b target_set;	/* Target flag */
1516 	s16b target_who;	/* Target identity */
1517 	s16b target_row;	/* Target location */
1518 	s16b target_col;	/* Target location */
1519 
1520 	s16b health_who;	/* Health bar trackee */
1521 
1522 	s16b monster_race_idx;	/* Monster race trackee */
1523 	u16b max_seen_r_idx;	/* Most powerful monster visible */
1524 
1525 	s16b object_kind_idx;	/* Object kind trackee */
1526 
1527 	player_run run;		/* Current stat of the running routine */
1528 
1529 	s16b new_spells;	/* Number of spells available */
1530 
1531 	s16b cur_lite;	/* Radius of lite (if any) */
1532 
1533 	u32b notice;	/* Special Updates (bit flags) */
1534 	u32b update;	/* Pending Updates (bit flags) */
1535 	u32b redraw;	/* Normal Redraws (bit flags) */
1536 	u32b window;	/* Window Redraws (bit flags) */
1537 	u32b change;	/* Once per turn (bit flags) */
1538 
1539 	/*
1540 	 * Flags on equipment items and the racial/class
1541 	 * effects logical-ored together.
1542 	 */
1543 	u32b flags[4];
1544 
1545 	/*** Extracted fields ***/
1546 	s16b dis_to_h;	/* Known bonus to hit */
1547 	s16b dis_to_d;	/* Known bonus to dam */
1548 	s16b dis_to_a;	/* Known bonus to ac */
1549 
1550 	s16b dis_ac;	/* Known base ac */
1551 
1552 	s16b to_h;	/* Bonus to hit */
1553 	s16b to_d;	/* Bonus to dam */
1554 	s16b to_a;	/* Bonus to ac */
1555 
1556 	s16b ac;	/* Base ac */
1557 
1558 	s16b see_infra;	/* Infravision range */
1559 
1560 	u32b noise;	/* Derived from stealth */
1561 
1562 	s16b num_blow;	/* Number of blows */
1563 	s16b num_fire;	/* Number of shots */
1564 
1565 	byte ammo_mult;	/* Ammo multiplier */
1566 	byte ammo_tval;	/* Ammo variety */
1567 	byte bow_energy;	/* shooter speed */
1568 
1569 	s16b pspeed;	/* Current speed */
1570 
1571 	s16b sp_bonus;  /* Extra mana per level */
1572 
1573 	/*** Pet commands ***/
1574 
1575 	s16b pet_follow_distance;	/* Length of the imaginary "leash" for pets */
1576 	byte pet_open_doors;	/* flag - allow pets to open doors */
1577 	byte pet_pickup_items;	/* flag - allow pets to pickup items */
1578 
1579 	/* Options */
1580 	bool options[OPT_PLAYER];
1581 	bool birth[OPT_BIRTH];
1582 };
1583 
1584 
1585 /*
1586  * For multiplayer use.
1587  *
1588  * Various information must be stored on the server
1589  * when a multiplayer version is created.
1590  *
1591  * This structure contains such information.
1592  * At the moment, this only has dungeon-specific options.
1593  * (Which are not already "birth" options.)
1594  */
1595 typedef struct server_type server_type;
1596 
1597 struct server_type
1598 {
1599 	bool options[OPT_SERVER];
1600 };
1601 
1602 
1603 
1604 /* For Monk martial arts */
1605 
1606 typedef struct martial_arts martial_arts;
1607 
1608 struct martial_arts
1609 {
1610 	cptr desc;	/* A verbose attack description */
1611 	int min_level;	/* Minimum level to use */
1612 	int chance;	/* Chance of 'success' */
1613 	int dd;	/* Damage dice */
1614 	int ds;	/* Damage sides */
1615 	int effect;	/* Special effects */
1616 };
1617 
1618 
1619 
1620 /* Mindcrafters */
1621 
1622 typedef struct mindcraft_power mindcraft_power;
1623 struct mindcraft_power
1624 {
1625 	int min_lev;
1626 	int mana_cost;
1627 	int fail;
1628 	cptr name;
1629 };
1630 
1631 #if 0
1632 /*
1633  * A store owner
1634  */
1635 typedef struct owner_type owner_type;
1636 
1637 struct owner_type
1638 {
1639 	cptr owner_name;	/* Name */
1640 
1641 	s16b max_cost;	/* Purse limit / 100 */
1642 
1643 	byte greed;	/* Greed level */
1644 };
1645 
1646 
1647 /*
1648  * A building owner
1649  */
1650 typedef struct b_own_type b_own_type;
1651 
1652 struct b_own_type
1653 {
1654 	cptr owner_name;	/* Name */
1655 
1656 	byte inflate;	/* Inflation */
1657 };
1658 #endif /* 0 */
1659 
1660 
1661 /*
1662  * A store, with an owner, various state flags, a current stock
1663  * of items, and a table of items that are often purchased.
1664  */
1665 typedef struct store_type store_type;
1666 
1667 struct store_type
1668 {
1669 	byte type;	/* Store type */
1670 
1671 	byte greed;	/* Greed value */
1672 	s16b max_cost;	/* Purse limit / 100 */
1673 	s16b owner_name;	/* Owner name */
1674 
1675 	s16b data;	/* Data used for various things */
1676 
1677 	s32b last_visit;	/* Last visited on this turn */
1678 
1679 	s16b stock;	/* Stock -- list of items in o_list[] */
1680 
1681 	u16b x;	/* Location x coord. */
1682 	u16b y;	/* Location y coord. */
1683 
1684 	byte max_stock;	/* Stock -- Max number of entries */
1685 };
1686 
1687 
1688 /* Dungeons */
1689 typedef struct dun_type dun_type;
1690 struct dun_type
1691 {
1692 	obj_theme theme;	/* Dungeon object theme */
1693 
1694 	u32b habitat;	/* Flags describing habitat */
1695 
1696 	byte min_level;	/* Minimum level in the dungeon */
1697 	byte max_level;	/* Maximum dungeon level allowed */
1698 
1699 	s16b rating;	/* Level's current rating */
1700 
1701 	s16b region;	/* Hack - Region for current level */
1702 
1703 	u16b rooms;		/* Room types available */
1704 
1705 	byte recall_depth;	/* Recall depth */
1706 
1707 	bool good_item_flag;	/* True if "Artifact" on this level */
1708 
1709 	byte floor;		/* Floor terrain type */
1710 
1711 	byte liquid;	/* Liquid type for lakes/ rivers etc. */
1712 
1713 	byte flags;		/* Extra flags */
1714 };
1715 
1716 
1717 /* Type holding dungeon type information */
1718 typedef struct dun_gen_type dun_gen_type;
1719 
1720 struct dun_gen_type
1721 {
1722 	/* Theme information */
1723 	obj_theme theme;
1724 	u32b habitat;
1725 
1726 	/* Level bounds for fixed dungeons */
1727 	int min_level;
1728 	int max_level;
1729 
1730 	/* Probability (inverse rarity) */
1731 	int chance;
1732 
1733 	/* Wilderness location */
1734 	byte pop;
1735 	byte height;
1736 
1737 	/* Room types available */
1738 	u16b rooms;
1739 
1740 	/* Floor terrain type */
1741 	byte floor;
1742 
1743 	/* Liquid type for lakes/ rivers etc. */
1744 	byte liquid;
1745 
1746 	/* Extra flags */
1747 	byte flags;
1748 };
1749 
1750 
1751 /*
1752  * A structure describing a place with
1753  * stores and buildings.
1754  */
1755 typedef struct place_type place_type;
1756 struct place_type
1757 {
1758 	u32b seed;	/* Seed for RNG */
1759 	store_type *store;	/* The stores[numstores] */
1760 
1761 	dun_type *dungeon;
1762 
1763 	byte type;	/* Type of place */
1764 
1765 	byte numstores;
1766 	u16b quest_num;	/* Quest number if is special */
1767 
1768 	byte x;	/* Location mod 16 in wilderness */
1769 	byte y;
1770 
1771 	byte xsize;	/* Size in wilderness */
1772 	byte ysize;	/* Size in wilderness */
1773 
1774 	byte data;	/* pop for towns, generic for quests */
1775 	byte monst_type;	/* Type of population (monsters/people etc.) */
1776 
1777 	s16b region;	/* Region */
1778 
1779 	byte gates_x[MAX_GATES];	/* Position of the town gates */
1780 	byte gates_y[MAX_GATES];
1781 
1782 	char name[T_NAME_LEN];	/* Town name */
1783 };
1784 
1785 
1786 /* Various function pointer types */
1787 typedef bool (*monster_hook_type) (int r_idx);
1788 typedef byte (*object_hook_type) (int k_idx);
1789 typedef int (*inven_func) (object_type *);
1790 typedef bool (*cave_hook_type) (const cave_type *c_ptr);
1791 typedef bool (*object_comp) (const object_type *, const object_type *);
1792 
1793 
1794 
1795 /*
1796  * Semi-Portable High Score List Entry (128 bytes) -- BEN
1797  *
1798  * All fields listed below are null terminated ascii strings.
1799  *
1800  * In addition, the "number" fields are right justified, and
1801  * space padded, to the full available length (minus the "null").
1802  *
1803  * Note that "string comparisons" are thus valid on "pts".
1804  */
1805 
1806 typedef struct high_score high_score;
1807 
1808 struct high_score
1809 {
1810 	char what[8];	/* Version info (string) */
1811 
1812 	char pts[10];	/* Total Score (number) */
1813 
1814 	char gold[10];	/* Total Gold (number) */
1815 
1816 	char turns[10];	/* Turns Taken (number) */
1817 
1818 	char day[10];	/* Time stamp (string) */
1819 
1820 	char who[16];	/* Player Name (string) */
1821 
1822 	char uid[8];	/* Player UID (number) */
1823 
1824 	char sex[2];	/* Player Sex (string) */
1825 	char p_r[3];	/* Player Race (number) */
1826 	char p_c[3];	/* Player Class (number) */
1827 
1828 	char cur_lev[4];	/* Current Player Level (number) */
1829 	char cur_dun[4];	/* Current Dungeon Level (number) */
1830 	char max_lev[4];	/* Max Player Level (number) */
1831 	char max_dun[4];	/* Max Dungeon Level (number) */
1832 
1833 	char how[32];	/* Method of death (string) */
1834 };
1835 
1836 /*
1837  * Struct for mutations and racial powers
1838  */
1839 
1840 typedef struct mutation_type mutation_type;
1841 
1842 struct mutation_type
1843 {
1844 	u32b which;	/* Actual mutation (mask) */
1845 
1846 	cptr desc_text;	/* Text describing mutation */
1847 	cptr gain_text;	/* Text displayed on gaining the mutation */
1848 	cptr lose_text;	/* Text displayed on losing the mutation */
1849 
1850 	char name[39];	/* Short description (activatable mutations) */
1851 	byte level;	/* Minimum level (activatable mutations) */
1852 
1853 	int cost;	/* Mana/HP Cost (activatable mutations) */
1854 	int stat;	/* Stat dependency (activatable mutations) */
1855 	int diff;	/* Difficulty (activatable mutations) */
1856 	int chance;	/* Chance of occuring (random mutations) / 100 */
1857 
1858 };
1859 
1860 
1861 /*
1862  * A function pointer used in displaying menus
1863  *
1864  * The function takes a number for the option chosen
1865  * and will return TRUE if the selection works, and FALSE
1866  * if the menu should stay up.
1867  */
1868 typedef bool (*menu_select_type) (int option);
1869 
1870 typedef struct menu_type menu_type;
1871 
1872 struct menu_type
1873 {
1874 	cptr text;					/* Option text */
1875 	cptr help;					/* Help file to use */
1876 	menu_select_type action;	/* Action to do */
1877 
1878 	byte flags;					/* Flags controling option behaviour */
1879 };
1880 
1881 
1882 /*
1883  * Object bonuses to various stuff
1884  */
1885 typedef struct bonuses_type bonuses_type;
1886 
1887 struct bonuses_type
1888 {
1889 	int stat[6];
1890 	int sp_bonus;
1891 	int skills[MAX_SKILL];
1892 	int see_infra;
1893 	int pspeed;
1894 	int extra_blows;
1895 	int extra_shots;
1896 };
1897