OSDN Git Service

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