OSDN Git Service

[Refactor] #1366 Removed type alias 'u16b' and replaced them all to 'uint16_t'
[hengbandforosx/hengbandosx.git] / src / system / player-type-definition.h
1 #pragma once
2
3 #include "mutation/mutation-flag-types.h"
4 #include "object-enchant/trc-types.h"
5 #include "player-ability/player-ability-types.h"
6 #include "player/player-race-types.h"
7 #include "player/player-class-types.h"
8 #include "player/player-personality-types.h"
9 #include "system/angband.h"
10 #include "system/system-variables.h"
11 #include "util/flag-group.h"
12
13 #define MAX_SKILLS 10
14 #define MAX_MANE 16
15
16 enum class RF_ABILITY;
17
18 typedef struct floor_type floor_type;
19 typedef struct object_type object_type;
20 typedef struct player_type {
21     int player_uid{};
22     int player_euid{};
23     int player_egid{};
24
25     floor_type *current_floor_ptr{};
26     POSITION oldpy{}; /* Previous player location -KMW- */
27     POSITION oldpx{}; /* Previous player location -KMW- */
28
29     SEX_IDX psex{}; /* Sex index */
30     player_race_type prace{}; /* Race index */
31     player_class_type pclass{}; /* Class index */
32     player_personality_type pseikaku{}; /* Seikaku index */
33     REALM_IDX realm1{}; /* First magic realm */
34     REALM_IDX realm2{}; /* Second magic realm */
35     REALM_IDX element{}; //!< 元素使い領域番号 / Elementalist system index
36     player_personality_type oops{}; /* Unused */
37
38     DICE_SID hitdie{}; /* Hit dice (sides) */
39     uint16_t expfact{}; /* Experience factor
40                      * Note: was byte, causing overflow for Amberite
41                      * characters (such as Amberite Paladins)
42                      */
43
44     int16_t age{}; /* Characters age */
45     int16_t ht{}; /* Height */
46     int16_t wt{}; /* Weight */
47     int16_t sc{}; /* Social Class */
48
49     PRICE au{}; /* Current Gold */
50
51     EXP max_max_exp{}; /* Max max experience (only to calculate score) */
52     EXP max_exp{}; /* Max experience */
53     EXP exp{}; /* Cur experience */
54     u32b exp_frac{}; /* Cur exp frac (times 2^16) */
55
56     PLAYER_LEVEL lev{}; /* Level */
57
58     TOWN_IDX town_num{}; /* Current town number */
59     int16_t arena_number{}; /* monster number in on_defeat_arena_monster -KMW- */
60     bool phase_out{}; /*!< フェイズアウト状態(闘技場観戦状態などに利用、NPCの処理の対象にならず自身もほとんどの行動ができない) */
61
62     DUNGEON_IDX dungeon_idx{}; /* current dungeon index */
63     POSITION wilderness_x{}; /* Coordinates in the wilderness */
64     POSITION wilderness_y{};
65     bool wild_mode{};
66
67     HIT_POINT mhp{}; /* Max hit pts */
68     HIT_POINT chp{}; /* Cur hit pts */
69     u32b chp_frac{}; /* Cur hit frac (times 2^16) */
70     PERCENTAGE mutant_regenerate_mod{};
71
72     MANA_POINT msp{}; /* Max mana pts */
73     MANA_POINT csp{}; /* Cur mana pts */
74     u32b csp_frac{}; /* Cur mana frac (times 2^16) */
75
76     int16_t max_plv{}; /* Max Player Level */
77
78     BASE_STATUS stat_max[A_MAX]{}; /* Current "maximal" stat values */
79     BASE_STATUS stat_max_max[A_MAX]{}; /* Maximal "maximal" stat values */
80     BASE_STATUS stat_cur[A_MAX]{}; /* Current "natural" stat values */
81
82     int16_t learned_spells{};
83     int16_t add_spells{};
84
85     u32b count{};
86
87     TIME_EFFECT fast{}; /* Timed -- Fast */
88     TIME_EFFECT slow{}; /* Timed -- Slow */
89     TIME_EFFECT blind{}; /* Timed -- Blindness */
90     TIME_EFFECT paralyzed{}; /* Timed -- Paralysis */
91     TIME_EFFECT confused{}; /* Timed -- Confusion */
92     TIME_EFFECT afraid{}; /* Timed -- Fear */
93     TIME_EFFECT image{}; /* Timed -- Hallucination */
94     TIME_EFFECT poisoned{}; /* Timed -- Poisoned */
95     TIME_EFFECT cut{}; /* Timed -- Cut */
96     TIME_EFFECT stun{}; /* Timed -- Stun */
97
98     TIME_EFFECT protevil{}; /* Timed -- Protection */
99     TIME_EFFECT invuln{}; /* Timed -- Invulnerable */
100     TIME_EFFECT ult_res{}; /* Timed -- Ultimate Resistance */
101     TIME_EFFECT hero{}; /* Timed -- Heroism */
102     TIME_EFFECT shero{}; /* Timed -- Super Heroism */
103     TIME_EFFECT shield{}; /* Timed -- Shield Spell */
104     TIME_EFFECT blessed{}; /* Timed -- Blessed */
105     TIME_EFFECT tim_invis{}; /* Timed -- See Invisible */
106     TIME_EFFECT tim_infra{}; /* Timed -- Infra Vision */
107     TIME_EFFECT tsuyoshi{}; /* Timed -- Tsuyoshi Special */
108     TIME_EFFECT ele_attack{}; /* Timed -- Elemental Attack */
109     TIME_EFFECT ele_immune{}; /* Timed -- Elemental Immune */
110
111     TIME_EFFECT oppose_acid{}; /* Timed -- oppose acid */
112     TIME_EFFECT oppose_elec{}; /* Timed -- oppose lightning */
113     TIME_EFFECT oppose_fire{}; /* Timed -- oppose heat */
114     TIME_EFFECT oppose_cold{}; /* Timed -- oppose cold */
115     TIME_EFFECT oppose_pois{}; /* Timed -- oppose poison */
116
117     TIME_EFFECT tim_esp{}; /* Timed ESP */
118     TIME_EFFECT wraith_form{}; /* Timed wraithform */
119
120     TIME_EFFECT resist_magic{}; /* Timed Resist Magic (later) */
121     TIME_EFFECT tim_regen{};
122     TIME_EFFECT tim_pass_wall{};
123     TIME_EFFECT tim_stealth{};
124     TIME_EFFECT tim_levitation{};
125     TIME_EFFECT tim_sh_touki{};
126     TIME_EFFECT lightspeed{};
127     TIME_EFFECT tsubureru{};
128     TIME_EFFECT magicdef{};
129     TIME_EFFECT tim_res_nether{}; /* Timed -- Nether resistance */
130     TIME_EFFECT tim_res_time{}; /* Timed -- Time resistance */
131     MIMIC_RACE_IDX mimic_form{};
132     TIME_EFFECT tim_mimic{};
133     TIME_EFFECT tim_sh_fire{};
134     TIME_EFFECT tim_sh_holy{};
135     TIME_EFFECT tim_eyeeye{};
136
137     /* for mirror master */
138     TIME_EFFECT tim_reflect{}; /* Timed -- Reflect */
139     TIME_EFFECT multishadow{}; /* Timed -- Multi-shadow */
140     TIME_EFFECT dustrobe{}; /* Timed -- Robe of dust */
141
142     bool timewalk{};
143
144 #define COMMAND_ARG_REST_UNTIL_DONE -2 /*!<休憩コマンド引数 … 必要な分だけ回復 */
145 #define COMMAND_ARG_REST_FULL_HEALING -1 /*!<休憩コマンド引数 … HPとMPが全回復するまで */
146     GAME_TURN resting{}; /* Current counter for resting, if any */
147
148     PATRON_IDX chaos_patron{};
149
150     EnumClassFlagGroup<MUTA> muta{}; /*!< 突然変異 / mutations */
151
152     int16_t virtues[8]{};
153     int16_t vir_types[8]{};
154
155     TIME_EFFECT word_recall{}; /* Word of recall counter */
156     TIME_EFFECT alter_reality{}; /* Alter reality counter */
157     DUNGEON_IDX recall_dungeon{}; /* Dungeon set to be recalled */
158
159     ENERGY energy_need{}; /* Energy needed for next move */
160     ENERGY enchant_energy_need{}; /* Energy needed for next upkeep effect        */
161
162     FEED food{}; /* Current nutrition */
163
164     /*
165      * p_ptr->special_attackによるプレイヤーの攻撃状態の定義 / Bit flags for the "p_ptr->special_attack" variable. -LM-
166      *
167      * Note:  The elemental and poison attacks should be managed using the
168      * function "set_ele_attack", in spell2.c.  This provides for timeouts and
169      * prevents the player from getting more than one at a time.
170      */
171     BIT_FLAGS special_attack{};
172
173     /* プレイヤーの防御状態の定義 / Bit flags for the "p_ptr->special_defense" variable. -LM- */
174     BIT_FLAGS special_defense{};
175     ACTION_IDX action{}; /* Currently action */
176     BIT_FLAGS spell_learned1{}; /* bit mask of spells learned */
177     BIT_FLAGS spell_learned2{}; /* bit mask of spells learned */
178     BIT_FLAGS spell_worked1{}; /* bit mask of spells tried and worked */
179     BIT_FLAGS spell_worked2{}; /* bit mask of spells tried and worked */
180     BIT_FLAGS spell_forgotten1{}; /* bit mask of spells learned but forgotten */
181     BIT_FLAGS spell_forgotten2{}; /* bit mask of spells learned but forgotten */
182     SPELL_IDX spell_order[64]{}; /* order spells learned/remembered/forgotten */
183
184     SUB_EXP spell_exp[64]{}; /* Proficiency of spells */
185     SUB_EXP weapon_exp[5][64]{}; /* Proficiency of weapons */
186     SUB_EXP skill_exp[MAX_SKILLS]{}; /* Proficiency of misc. skill */
187
188     s32b magic_num1[MAX_SPELLS]{}; /*!< Array for non-spellbook type magic */
189     byte magic_num2[MAX_SPELLS]{}; /*!< 魔道具術師の取り込み済魔道具使用回数 / Flags for non-spellbook type magics */
190
191     RF_ABILITY mane_spell[MAX_MANE]{};
192     HIT_POINT mane_dam[MAX_MANE]{};
193     int16_t mane_num{};
194     bool new_mane{};
195
196 #define CONCENT_RADAR_THRESHOLD 2
197 #define CONCENT_TELE_THRESHOLD 5
198     int16_t concent{}; /* Sniper's concentration level */
199
200     HIT_POINT player_hp[PY_MAX_LEVEL]{};
201     char died_from[MAX_MONSTER_NAME]{}; /* What killed the player */
202     concptr last_message{}; /* Last message on death or retirement */
203     char history[4][60]{}; /* Textual "history" for the Player */
204
205     uint16_t panic_save{}; /* Panic save */
206
207     bool wait_report_score{}; /* Waiting to report score */
208     bool is_dead{}; /* Player is dead */
209     bool now_damaged{};
210     bool ambush_flag{};
211     BIT_FLAGS change_floor_mode{}; /*!<フロア移行処理に関するフラグ / Mode flags for changing floor */
212
213     bool reset_concent{}; /* Concentration reset flag */
214
215     MONSTER_IDX riding{}; /* Riding on a monster of this index */
216
217 #define KNOW_STAT 0x01
218 #define KNOW_HPRATE 0x02
219     BIT_FLAGS8 knowledge{}; /* Knowledge about yourself */
220     BIT_FLAGS visit{}; /* Visited towns */
221
222     player_race_type start_race{}; /* Race at birth */
223     BIT_FLAGS old_race1{}; /* Record of race changes */
224     BIT_FLAGS old_race2{}; /* Record of race changes */
225     int16_t old_realm{}; /* Record of realm changes */
226
227     int16_t pet_follow_distance{}; /* Length of the imaginary "leash" for pets */
228     BIT_FLAGS16 pet_extra_flags{}; /* Various flags for controling pets */
229
230     MONSTER_IDX today_mon{}; //!< 日替わり賞金首を知っていればそのモンスターID、知らなければ 0
231
232     bool dtrap{}; /* Whether you are on trap-safe grids */
233     FLOOR_IDX floor_id{}; /* Current floor location */
234
235     bool autopick_autoregister{}; /* auto register is in-use or not */
236
237     byte feeling{}; /* Most recent dungeon feeling */
238     s32b feeling_turn{}; /* The turn of the last dungeon feeling */
239
240     object_type *inventory_list{}; /* The player's inventory */
241     int16_t inven_cnt{}; /* Number of items in inventory */
242     int16_t equip_cnt{}; /* Number of items in equipment */
243
244     /*** Temporary fields ***/
245
246     bool select_ring_slot{};
247
248     bool playing{}; /* True if player is playing */
249     bool leaving{}; /* True if player is leaving */
250
251     bool monk_notify_aux{};
252
253     byte leave_bldg{};
254     byte exit_bldg{}; /* Goal obtained in on_defeat_arena_monster? -KMW- */
255
256     bool leaving_dungeon{}; /* True if player is leaving the dungeon */
257     bool teleport_town{};
258     bool enter_dungeon{}; /* Just enter the dungeon */
259
260     IDX health_who{}; /* Health bar trackee */
261
262     MONRACE_IDX monster_race_idx{}; /* Monster race trackee */
263
264     KIND_OBJECT_IDX object_kind_idx{}; /* Object kind trackee */
265
266     int16_t new_spells{}; /* Number of spells available */
267     int16_t old_spells{};
268
269     int16_t old_food_aux{}; /* Old value of food */
270
271     bool old_cumber_armor{};
272     bool old_cumber_glove{};
273     bool old_heavy_wield[2]{};
274     bool old_heavy_shoot{};
275     bool old_icky_wield[2]{};
276     bool old_riding_wield[2]{};
277     bool old_riding_ryoute{};
278     bool old_monlite{};
279     int extra_blows[2]{};
280
281     POSITION old_lite{}; /* Old radius of lite (if any) */
282
283     bool cumber_armor{}; /* Mana draining armor */
284     bool cumber_glove{}; /* Mana draining gloves */
285     bool heavy_wield[2]{}; /* Heavy weapon */
286     bool icky_wield[2]{}; /* Icky weapon */
287     bool riding_wield[2]{}; /* Riding weapon */
288     bool riding_ryoute{}; /* Riding weapon */
289     bool monlite{};
290     BIT_FLAGS yoiyami{};
291     BIT_FLAGS easy_2weapon{};
292     BIT_FLAGS down_saving{};
293
294     POSITION cur_lite{}; /* Radius of lite (if any) */
295
296     BIT_FLAGS update{}; /* Pending Updates */
297     BIT_FLAGS redraw{}; /* Normal Redraws */
298     BIT_FLAGS window_flags{}; /* Window Redraws */
299     int16_t stat_use[A_MAX]{}; /* Current modified stats */
300     int16_t stat_top[A_MAX]{}; /* Maximal modified stats */
301
302     bool sutemi{};
303     bool counter{};
304
305     int alignment{}; /* Good/evil/neutral */
306     POSITION run_py{};
307     POSITION run_px{};
308     DIRECTION fishing_dir{};
309
310     MONSTER_IDX pet_t_m_idx{};
311     MONSTER_IDX riding_t_m_idx{};
312
313     /*** Extracted fields ***/
314
315     int16_t running{}; /* Current counter for running, if any */
316     bool suppress_multi_reward{}; /*!< 複数レベルアップ時のパトロンからの報酬多重受け取りを防止 */
317
318     int16_t stat_add[A_MAX]{}; /* Modifiers to stat values */
319     int16_t stat_index[A_MAX]{}; /* Indexes into stat tables */
320
321     bool hack_mutation{};
322     bool is_fired{};
323     bool level_up_message{};
324
325     BIT_FLAGS anti_magic{}; /* Anti-magic */
326     BIT_FLAGS anti_tele{}; /* Prevent teleportation */
327
328     EnumClassFlagGroup<TRC> cursed{}; /* Player is cursed */
329     EnumClassFlagGroup<TRCS> cursed_special{}; /* Player is special type cursed */
330
331     bool can_swim{}; /* No damage falling */
332     BIT_FLAGS levitation{}; /* No damage falling */
333     BIT_FLAGS lite{}; /* Permanent light */
334     BIT_FLAGS free_act{}; /* Never paralyzed */
335     BIT_FLAGS see_inv{}; /* Can see invisible */
336     BIT_FLAGS regenerate{}; /* Regenerate hit pts */
337     BIT_FLAGS hold_exp{}; /* Resist exp draining */
338
339     BIT_FLAGS telepathy{}; /* Telepathy */
340     BIT_FLAGS esp_animal{};
341     BIT_FLAGS esp_undead{};
342     BIT_FLAGS esp_demon{};
343     BIT_FLAGS esp_orc{};
344     BIT_FLAGS esp_troll{};
345     BIT_FLAGS esp_giant{};
346     BIT_FLAGS esp_dragon{};
347     BIT_FLAGS esp_human{};
348     BIT_FLAGS esp_evil{};
349     BIT_FLAGS esp_good{};
350     BIT_FLAGS esp_nonliving{};
351     BIT_FLAGS esp_unique{};
352
353     BIT_FLAGS slow_digest{}; /* Slower digestion */
354     BIT_FLAGS bless_blade{}; //!< 祝福された装備をしている / Blessed by inventory items
355     BIT_FLAGS xtra_might{}; /* Extra might bow */
356     BIT_FLAGS impact{}; //!< クリティカル率を上げる装備をしている / Critical blows
357     BIT_FLAGS earthquake{}; //!< 地震を起こす装備をしている / Earthquake blows
358     BIT_FLAGS dec_mana{};
359     BIT_FLAGS easy_spell{};
360     BIT_FLAGS heavy_spell{};
361     BIT_FLAGS warning{};
362     BIT_FLAGS mighty_throw{};
363     BIT_FLAGS see_nocto{}; /* Noctovision */
364     bool invoking_midnight_curse{};
365
366     DICE_NUMBER to_dd[2]{}; /* Extra dice/sides */
367     DICE_SID to_ds[2]{};
368
369     HIT_PROB dis_to_h[2]{}; /*!< 判明している現在の表記上の近接武器命中修正値 /  Known bonus to hit (wield) */
370     HIT_PROB dis_to_h_b{}; /*!< 判明している現在の表記上の射撃武器命中修正値 / Known bonus to hit (bow) */
371     HIT_POINT dis_to_d[2]{}; /*!< 判明している現在の表記上の近接武器ダメージ修正値 / Known bonus to dam (wield) */
372     ARMOUR_CLASS dis_to_a{}; /*!< 判明している現在の表記上の装備AC修正値 / Known bonus to ac */
373     ARMOUR_CLASS dis_ac{}; /*!< 判明している現在の表記上の装備AC基礎値 / Known base ac */
374
375     int16_t to_h[2]{}; /* Bonus to hit (wield) */
376     int16_t to_h_b{}; /* Bonus to hit (bow) */
377     int16_t to_h_m{}; /* Bonus to hit (misc) */
378     int16_t to_d[2]{}; /* Bonus to dam (wield) */
379     int16_t to_d_m{}; /* Bonus to dam (misc) */
380     ARMOUR_CLASS to_a{}; /* Bonus to ac */
381
382     int16_t to_m_chance{}; /* Minusses to cast chance */
383
384     bool no_flowed{};
385
386     ARMOUR_CLASS ac{}; /*!< 装備無しの基本AC / Base ac */
387
388     ACTION_SKILL_POWER see_infra{}; /*!< 赤外線視能力の強さ /Infravision range */
389     ACTION_SKILL_POWER skill_dis{}; /*!< 行動技能値:解除能力 / Skill: Disarming */
390     ACTION_SKILL_POWER skill_dev{}; /*!< 行動技能値:魔道具使用 / Skill: Magic Devices */
391     ACTION_SKILL_POWER skill_sav{}; /*!< 行動技能値:魔法防御 / Skill: Saving throw */
392     ACTION_SKILL_POWER skill_stl{}; /*!< 行動技能値:隠密 / Skill: Stealth factor */
393
394     /*!
395      * 行動技能値:知覚 / Skill: Searching ability
396      * この値はsearch()による地形の隠し要素発見処理などで混乱、盲目、幻覚、無光源などの
397      * 状態異常がない限り、難易度修正などがないままそのままパーセンテージ値として使われる。
398      * 100以上ならば必ず全てのトラップなどを見つけることが出来る。
399      */
400     ACTION_SKILL_POWER skill_srh{};
401
402     ACTION_SKILL_POWER skill_fos{}; /*!< 行動技能値:探索 / Skill: Searching frequency */
403     ACTION_SKILL_POWER skill_thn{}; /*!< 行動技能値:打撃命中能力 / Skill: To hit (normal) */
404     ACTION_SKILL_POWER skill_thb{}; /*!< 行動技能値:射撃命中能力 / Skill: To hit (shooting) */
405     ACTION_SKILL_POWER skill_tht{}; /*!< 行動技能値:投射命中能力 / Skill: To hit (throwing) */
406     ACTION_SKILL_POWER skill_dig{}; /*!< 行動技能値:掘削 / Skill: Digging */
407
408     int16_t num_blow[2]{}; /* Number of blows */
409     int16_t num_fire{}; /* Number of shots */
410
411     byte tval_xtra{}; /* (Unused)Correct xtra tval */
412     byte tval_ammo{}; /* Correct ammo tval */
413
414     int16_t pspeed{}; /*!< 現在の速度 / Current speed */
415
416     ENERGY energy_use{}; /*!< 直近のターンに消費したエネルギー / Energy use this turn */
417
418     POSITION y{}; /*!< ダンジョンの現在Y座標 / Player location in dungeon */
419     POSITION x{}; /*!< ダンジョンの現在X座標 / Player location in dungeon */
420     GAME_TEXT name[32]{}; /*!< 現在のプレイヤー名 / Current player's character name */
421     char base_name[32]{}; /*!< Stripped version of "player_name" */
422 } player_type;
423
424 extern player_type *p_ptr;