OSDN Git Service

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