OSDN Git Service

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