OSDN Git Service

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