OSDN Git Service

7f193a2cdf7fb420aa17e2e7ef5bb035cb369677
[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  * Information about "ego-items".
57  */
58
59 typedef struct ego_item_type ego_item_type;
60
61 struct ego_item_type
62 {
63         STR_OFFSET name;                        /* Name (offset) */
64         STR_OFFSET text;                        /* Text (offset) */
65
66         INVENTORY_IDX slot;             /*!< 装備部位 / Standard slot value */
67         PRICE rating;           /*!< ベースアイテムからの価値加速 / Rating boost */
68
69         DEPTH level;                    /* Minimum level */
70         RARITY rarity;          /* Object rarity */
71
72         HIT_PROB max_to_h;              /* Maximum to-hit bonus */
73         HIT_POINT max_to_d;             /* Maximum to-dam bonus */
74         ARMOUR_CLASS max_to_a;          /* Maximum to-ac bonus */
75
76         PARAMETER_VALUE max_pval;               /* Maximum pval */
77
78         PRICE cost;                     /* Ego-item "cost" */
79
80         BIT_FLAGS flags[TR_FLAG_SIZE];  /* Ego-Item Flags */
81         BIT_FLAGS gen_flags;            /* flags for generate */
82
83         IDX act_idx;            /* Activative ability index */
84 };
85
86
87 typedef struct mbe_info_type mbe_info_type;
88
89 struct mbe_info_type
90 {
91         int power;        /* The attack "power" */
92         int explode_type; /* Explosion effect */
93 };
94
95
96 /*
97  * An entry for the object/monster allocation functions
98  *
99  * Pass 1 is determined from allocation information
100  * Pass 2 is determined from allocation restriction
101  * Pass 3 is determined from allocation calculation
102  */
103
104 typedef struct alloc_entry alloc_entry;
105
106 struct alloc_entry
107 {
108         KIND_OBJECT_IDX index;          /* The actual index */
109
110         DEPTH level;            /* Base dungeon level */
111         PROB prob1;             /* Probability, pass 1 */
112         PROB prob2;             /* Probability, pass 2 */
113         PROB prob3;             /* Probability, pass 3 */
114
115         u16b total;             /* Unused for now */
116 };
117
118
119
120 /*
121  * A store, with an owner, various state flags, a current stock
122  * of items, and a table of items that are often purchased.
123  */
124 typedef struct store_type store_type;
125
126 struct store_type
127 {
128         byte type;                              /* Store type */
129
130         byte owner;                             /* Owner index */
131         byte extra;                             /* Unused for now */
132
133         s16b insult_cur;                /* Insult counter */
134
135         s16b good_buy;                  /* Number of "good" buys */
136         s16b bad_buy;                   /* Number of "bad" buys */
137
138         s32b store_open;                /* Closed until this current_world_ptr->game_turn */
139
140         s32b last_visit;                /* Last visited on this current_world_ptr->game_turn */
141
142         s16b table_num;                 /* Table -- Number of entries */
143         s16b table_size;                /* Table -- Total Size of Array */
144         s16b *table;                    /* Table -- Legal item kinds */
145
146         s16b stock_num;                 /* Stock -- Number of entries */
147         s16b stock_size;                /* Stock -- Total Size of Array */
148         object_type *stock;             /* Stock -- Actual stock items */
149 };
150
151
152 /*
153  * The "name" of spell 'N' is stored as spell_names[X][N],
154  * where X is 0 for mage-spells and 1 for priest-spells.
155  */
156 typedef struct magic_type magic_type;
157
158 struct magic_type
159 {
160         PLAYER_LEVEL slevel;    /* Required level (to learn) */
161         MANA_POINT smana;               /* Required mana (to cast) */
162         PERCENTAGE sfail;               /* Minimum chance of failure */
163         EXP sexp;                               /* Encoded experience bonus */
164 };
165
166
167 /*
168  * Player sex info
169  */
170
171 typedef struct player_sex player_sex;
172
173 struct player_sex
174 {
175         concptr title;                  /* Type of sex */
176         concptr winner;         /* Name of winner */
177 #ifdef JP
178         concptr E_title;                /* 英語性別 */
179         concptr E_winner;               /* 英語性別 */
180 #endif
181 };
182
183
184 /*
185  * Player racial info
186  */
187
188 typedef struct player_race player_race;
189
190 struct player_race
191 {
192         concptr title;                  /* Type of race */
193
194 #ifdef JP
195         concptr E_title;                /* 英語種族 */
196 #endif
197         s16b r_adj[6];          /* Racial stat bonuses */
198
199         s16b r_dis;                     /* disarming */
200         s16b r_dev;                     /* magic devices */
201         s16b r_sav;                     /* saving throw */
202         s16b r_stl;                     /* stealth */
203         s16b r_srh;                     /* search ability */
204         s16b r_fos;                     /* search frequency */
205         s16b r_thn;                     /* combat (normal) */
206         s16b r_thb;                     /* combat (shooting) */
207
208         byte r_mhp;                     /* Race hit-dice modifier */
209         byte r_exp;                     /* Race experience factor */
210
211         byte b_age;                     /* base age */
212         byte m_age;                     /* mod age */
213
214         byte m_b_ht;            /* base height (males) */
215         byte m_m_ht;            /* mod height (males) */
216         byte m_b_wt;            /* base weight (males) */
217         byte m_m_wt;            /* mod weight (males) */
218
219         byte f_b_ht;            /* base height (females) */
220         byte f_m_ht;            /* mod height (females)   */
221         byte f_b_wt;            /* base weight (females) */
222         byte f_m_wt;            /* mod weight (females) */
223
224         byte infra;                     /* Infra-vision range */
225
226         u32b choice;        /* Legal class choices */
227 /*    byte choice_xtra;   */
228 };
229
230
231 typedef struct player_seikaku player_seikaku;
232 struct player_seikaku
233 {
234         concptr title;                  /* Type of seikaku */
235
236 #ifdef JP
237         concptr E_title;                /* 英語性格 */
238 #endif
239
240         s16b a_adj[6];          /* seikaku stat bonuses */
241
242         s16b a_dis;                     /* seikaku disarming */
243         s16b a_dev;                     /* seikaku magic devices */
244         s16b a_sav;                     /* seikaku saving throw */
245         s16b a_stl;                     /* seikaku stealth */
246         s16b a_srh;                     /* seikaku search ability */
247         s16b a_fos;                     /* seikaku search frequency */
248         s16b a_thn;                     /* seikaku combat (normal) */
249         s16b a_thb;                     /* seikaku combat (shooting) */
250
251         s16b a_mhp;                     /* Race hit-dice modifier */
252
253         byte no;                        /* の */
254         byte sex;                       /* seibetu seigen */
255 };
256
257
258
259 /*
260  * A structure to hold "rolled" information
261  */
262 typedef struct birther birther;
263
264 struct birther
265 {
266         SEX_IDX psex;           /* Sex index */
267         RACE_IDX prace;         /* Race index */
268         CLASS_IDX pclass;       /* Class index */
269         CHARACTER_IDX pseikaku; /* Seikaku index */
270         REALM_IDX realm1;       /* First magic realm */
271         REALM_IDX realm2;       /* Second magic realm */
272
273         s16b age;
274         s16b ht;
275         s16b wt;
276         s16b sc;
277
278         PRICE au; /*!< 初期の所持金 */
279
280         BASE_STATUS stat_max[6];        /* Current "maximal" stat values */
281         BASE_STATUS stat_max_max[6];    /* Maximal "maximal" stat values */
282         HIT_POINT player_hp[PY_MAX_LEVEL];
283
284         PATRON_IDX chaos_patron;
285
286         s16b vir_types[8];
287
288         char history[4][60];
289
290         bool quick_ok;
291 };
292
293
294 /* For Monk martial arts */
295
296 typedef struct martial_arts martial_arts;
297
298 struct martial_arts
299 {
300         concptr desc;       /* A verbose attack description */
301         PLAYER_LEVEL min_level;  /* Minimum level to use */
302         int chance;     /* Chance of 'success' */
303         int dd;         /* Damage dice */
304         int ds;         /* Damage sides */
305         int effect;     /* Special effects */
306 };
307
308 typedef struct kamae kamae;
309
310 struct kamae
311 {
312         concptr desc;       /* A verbose kamae description */
313         PLAYER_LEVEL min_level;  /* Minimum level to use */
314         concptr info;
315 };
316
317
318 /* Imitator */
319
320 typedef struct monster_power monster_power;
321 struct monster_power
322 {
323         PLAYER_LEVEL level;
324         MANA_POINT smana;
325         PERCENTAGE fail;
326         int     manedam;
327         int     manefail;
328         int     use_stat;
329         concptr    name;
330 };
331
332
333 /*
334  * A structure describing a town with
335  * stores and buildings
336  */
337 typedef struct town_type town_type;
338 struct town_type
339 {
340         GAME_TEXT name[32];
341         u32b seed;      /* Seed for RNG */
342         store_type *store;    /* The stores [MAX_STORES] */
343         byte numstores;
344 };
345
346 /*
347  * Sort-array element
348  */
349 typedef struct tag_type tag_type;
350
351 struct tag_type
352 {
353         int tag;
354         int index;
355 };
356
357 typedef bool (*monsterrace_hook_type)(MONRACE_IDX r_idx);
358
359
360 /*
361  * This seems like a pretty standard "typedef"
362  */
363 typedef int (*inven_func)(object_type *);
364
365
366 typedef struct
367 {
368         FEAT_IDX feat;    /* Feature tile */
369         PERCENTAGE percent; /* Chance of type */
370 }
371 feat_prob;
372
373 typedef struct {
374         int flag;
375         int type;
376         concptr name;
377 } dragonbreath_type;