OSDN Git Service

5dccb16cf1e91f152c56a4524e55abce1ad6d66e
[hengband/hengband.git] / src / types.h
1 #pragma once
2
3 /*!
4  * @file types.h
5  * @brief グローバルな構造体の定義 / global type declarations
6  * @date 2014/08/10
7  * @author
8  * <pre>
9  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
10  * This software may be copied and distributed for educational, research,
11  * and not for profit purposes provided that this copyright and statement
12  * are included in all such copies.  Other copyrights may also apply.
13  * </pre>
14  * @details
15  * <pre>
16  * このファイルはangband.hでのみインクルードすること。
17  * This file should ONLY be included by "angband.h"
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 "grid_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  * </pre>
46  */
47
48 #include "h-type.h"
49 #include "defines.h"
50 #include "object.h"
51
52 //#include "player-skill.h"
53
54
55
56 typedef struct mbe_info_type mbe_info_type;
57
58 struct mbe_info_type
59 {
60         int power;        /* The attack "power" */
61         int explode_type; /* Explosion effect */
62 };
63
64
65 /*
66  * An entry for the object/monster allocation functions
67  *
68  * Pass 1 is determined from allocation information
69  * Pass 2 is determined from allocation restriction
70  * Pass 3 is determined from allocation calculation
71  */
72
73 typedef struct alloc_entry alloc_entry;
74
75 struct alloc_entry
76 {
77         KIND_OBJECT_IDX index;          /* The actual index */
78
79         DEPTH level;            /* Base dungeon level */
80         PROB prob1;             /* Probability, pass 1 */
81         PROB prob2;             /* Probability, pass 2 */
82         PROB prob3;             /* Probability, pass 3 */
83
84         u16b total;             /* Unused for now */
85 };
86
87
88
89 /*
90  * A store, with an owner, various state flags, a current stock
91  * of items, and a table of items that are often purchased.
92  */
93 typedef struct store_type store_type;
94
95 struct store_type
96 {
97         byte type;                              /* Store type */
98
99         byte owner;                             /* Owner index */
100         byte extra;                             /* Unused for now */
101
102         s16b insult_cur;                /* Insult counter */
103
104         s16b good_buy;                  /* Number of "good" buys */
105         s16b bad_buy;                   /* Number of "bad" buys */
106
107         s32b store_open;                /* Closed until this current_world_ptr->game_turn */
108
109         s32b last_visit;                /* Last visited on this current_world_ptr->game_turn */
110
111         s16b table_num;                 /* Table -- Number of entries */
112         s16b table_size;                /* Table -- Total Size of Array */
113         s16b *table;                    /* Table -- Legal item kinds */
114
115         s16b stock_num;                 /* Stock -- Number of entries */
116         s16b stock_size;                /* Stock -- Total Size of Array */
117         object_type *stock;             /* Stock -- Actual stock items */
118 };
119
120
121 /*
122  * The "name" of spell 'N' is stored as spell_names[X][N],
123  * where X is 0 for mage-spells and 1 for priest-spells.
124  */
125 typedef struct magic_type magic_type;
126
127 struct magic_type
128 {
129         PLAYER_LEVEL slevel;    /* Required level (to learn) */
130         MANA_POINT smana;               /* Required mana (to cast) */
131         PERCENTAGE sfail;               /* Minimum chance of failure */
132         EXP sexp;                               /* Encoded experience bonus */
133 };
134
135
136 /*
137  * Player sex info
138  */
139
140 typedef struct player_sex player_sex;
141
142 struct player_sex
143 {
144         concptr title;                  /* Type of sex */
145         concptr winner;         /* Name of winner */
146 #ifdef JP
147         concptr E_title;                /* 英語性別 */
148         concptr E_winner;               /* 英語性別 */
149 #endif
150 };
151
152
153 /*
154  * Player racial info
155  */
156
157 typedef struct player_race player_race;
158
159 struct player_race
160 {
161         concptr title;                  /* Type of race */
162
163 #ifdef JP
164         concptr E_title;                /* 英語種族 */
165 #endif
166         s16b r_adj[6];          /* Racial stat bonuses */
167
168         s16b r_dis;                     /* disarming */
169         s16b r_dev;                     /* magic devices */
170         s16b r_sav;                     /* saving throw */
171         s16b r_stl;                     /* stealth */
172         s16b r_srh;                     /* search ability */
173         s16b r_fos;                     /* search frequency */
174         s16b r_thn;                     /* combat (normal) */
175         s16b r_thb;                     /* combat (shooting) */
176
177         byte r_mhp;                     /* Race hit-dice modifier */
178         byte r_exp;                     /* Race experience factor */
179
180         byte b_age;                     /* base age */
181         byte m_age;                     /* mod age */
182
183         byte m_b_ht;            /* base height (males) */
184         byte m_m_ht;            /* mod height (males) */
185         byte m_b_wt;            /* base weight (males) */
186         byte m_m_wt;            /* mod weight (males) */
187
188         byte f_b_ht;            /* base height (females) */
189         byte f_m_ht;            /* mod height (females)   */
190         byte f_b_wt;            /* base weight (females) */
191         byte f_m_wt;            /* mod weight (females) */
192
193         byte infra;                     /* Infra-vision range */
194
195         u32b choice;        /* Legal class choices */
196 /*    byte choice_xtra;   */
197 };
198
199
200 typedef struct player_seikaku player_seikaku;
201 struct player_seikaku
202 {
203         concptr title;                  /* Type of seikaku */
204
205 #ifdef JP
206         concptr E_title;                /* 英語性格 */
207 #endif
208
209         s16b a_adj[6];          /* seikaku stat bonuses */
210
211         s16b a_dis;                     /* seikaku disarming */
212         s16b a_dev;                     /* seikaku magic devices */
213         s16b a_sav;                     /* seikaku saving throw */
214         s16b a_stl;                     /* seikaku stealth */
215         s16b a_srh;                     /* seikaku search ability */
216         s16b a_fos;                     /* seikaku search frequency */
217         s16b a_thn;                     /* seikaku combat (normal) */
218         s16b a_thb;                     /* seikaku combat (shooting) */
219
220         s16b a_mhp;                     /* Race hit-dice modifier */
221
222         byte no;                        /* の */
223         byte sex;                       /* seibetu seigen */
224 };
225
226
227
228 /*
229  * A structure to hold "rolled" information
230  */
231 typedef struct birther birther;
232
233 struct birther
234 {
235         SEX_IDX psex;           /* Sex index */
236         RACE_IDX prace;         /* Race index */
237         CLASS_IDX pclass;       /* Class index */
238         CHARACTER_IDX pseikaku; /* Seikaku index */
239         REALM_IDX realm1;       /* First magic realm */
240         REALM_IDX realm2;       /* Second magic realm */
241
242         s16b age;
243         s16b ht;
244         s16b wt;
245         s16b sc;
246
247         PRICE au; /*!< 初期の所持金 */
248
249         BASE_STATUS stat_max[6];        /* Current "maximal" stat values */
250         BASE_STATUS stat_max_max[6];    /* Maximal "maximal" stat values */
251         HIT_POINT player_hp[PY_MAX_LEVEL];
252
253         PATRON_IDX chaos_patron;
254
255         s16b vir_types[8];
256
257         char history[4][60];
258
259         bool quick_ok;
260 };
261
262
263 /* For Monk martial arts */
264
265 typedef struct martial_arts martial_arts;
266
267 struct martial_arts
268 {
269         concptr desc;       /* A verbose attack description */
270         PLAYER_LEVEL min_level;  /* Minimum level to use */
271         int chance;     /* Chance of 'success' */
272         int dd;         /* Damage dice */
273         int ds;         /* Damage sides */
274         int effect;     /* Special effects */
275 };
276
277 typedef struct kamae kamae;
278
279 struct kamae
280 {
281         concptr desc;       /* A verbose kamae description */
282         PLAYER_LEVEL min_level;  /* Minimum level to use */
283         concptr info;
284 };
285
286
287 /* Imitator */
288
289 typedef struct monster_power monster_power;
290 struct monster_power
291 {
292         PLAYER_LEVEL level;
293         MANA_POINT smana;
294         PERCENTAGE fail;
295         int     manedam;
296         int     manefail;
297         int     use_stat;
298         concptr    name;
299 };
300
301
302 /*
303  * Sort-array element
304  */
305 typedef struct tag_type tag_type;
306
307 struct tag_type
308 {
309         int tag;
310         int index;
311 };
312
313 typedef bool (*monsterrace_hook_type)(MONRACE_IDX r_idx);
314
315
316 /*
317  * This seems like a pretty standard "typedef"
318  */
319 typedef int (*inven_func)(object_type *);
320
321
322 typedef struct
323 {
324         FEAT_IDX feat;    /* Feature tile */
325         PERCENTAGE percent; /* Chance of type */
326 }
327 feat_prob;
328
329 typedef struct {
330         int flag;
331         int type;
332         concptr name;
333 } dragonbreath_type;