3 #include "system/angband.h"
5 /* 人畜無害なenumヘッダを先に読み込む */
6 #include "player-info/base-status-types.h"
7 #include "player/player-classes-types.h"
8 #include "player/player-personalities-types.h"
9 #include "player/player-race-types.h"
10 #include "spell/spells-util.h"
13 * Most of the "player" information goes here.
15 * This stucture gives us a large collection of player variables.
17 * This structure contains several "blocks" of information.
18 * (1) the "permanent" info
19 * (2) the "variable" info
20 * (3) the "transient" info
22 * All of the "permanent" info, and most of the "variable" info,
23 * is saved in the savefile. The "transient" info is recomputed
24 * whenever anything important changes.
30 #define PY_MAX_EXP 99999999L /*!< プレイヤー経験値の最大値 / Maximum exp */
31 #define PY_MAX_GOLD 999999999L /*!< プレイヤー所持金の最大値 / Maximum gold */
32 #define PY_MAX_LEVEL 50 /*!< プレイヤーレベルの最大値 / Maximum level */
37 #define MAGIC_GLOVE_REDUCE_MANA 0x0001
38 #define MAGIC_FAIL_5PERCENT 0x0002
39 #define MAGIC_GAIN_EXP 0x0004
41 /* no_flowed 判定対象となるスペル */
47 /*!< Empty hand status */
48 enum empty_hand_status {
49 EMPTY_HAND_NONE = 0x0000, /*!<Both hands are used */
50 EMPTY_HAND_LARM = 0x0001, /*!<Left hand is empty */
51 EMPTY_HAND_RARM = 0x0002 /*!<Right hand is empty */
55 * Player sex constants (hard-coded by save-files, arrays, etc)
59 #define MAX_SEXES 2 /*!< 性別の定義最大数 / Maximum number of player "sex" types (see "table.c", etc) */
61 typedef struct floor_type floor_type;
62 typedef struct object_type object_type;
63 typedef struct player_type {
68 floor_type *current_floor_ptr;
69 POSITION oldpy; /* Previous player location -KMW- */
70 POSITION oldpx; /* Previous player location -KMW- */
72 SEX_IDX psex; /* Sex index */
73 player_race_type prace; /* Race index */
74 player_class_type pclass; /* Class index */
75 player_personality_type pseikaku; /* Seikaku index */
76 REALM_IDX realm1; /* First magic realm */
77 REALM_IDX realm2; /* Second magic realm */
78 player_personality_type oops; /* Unused */
80 DICE_SID hitdie; /* Hit dice (sides) */
81 u16b expfact; /* Experience factor
82 * Note: was byte, causing overflow for Amberite
83 * characters (such as Amberite Paladins)
86 s16b age; /* Characters age */
89 s16b sc; /* Social Class */
91 PRICE au; /* Current Gold */
93 EXP max_max_exp; /* Max max experience (only to calculate score) */
94 EXP max_exp; /* Max experience */
95 EXP exp; /* Cur experience */
96 u32b exp_frac; /* Cur exp frac (times 2^16) */
98 PLAYER_LEVEL lev; /* Level */
100 TOWN_IDX town_num; /* Current town number */
101 s16b arena_number; /* monster number in on_defeat_arena_monster -KMW- */
102 bool phase_out; /*!< フェイズアウト状態(闘技場観戦状態などに利用、NPCの処理の対象にならず自身もほとんどの行動ができない) */
104 DUNGEON_IDX dungeon_idx; /* current dungeon index */
105 POSITION wilderness_x; /* Coordinates in the wilderness */
106 POSITION wilderness_y;
109 HIT_POINT mhp; /* Max hit pts */
110 HIT_POINT chp; /* Cur hit pts */
111 u32b chp_frac; /* Cur hit frac (times 2^16) */
112 PERCENTAGE mutant_regenerate_mod;
114 MANA_POINT msp; /* Max mana pts */
115 MANA_POINT csp; /* Cur mana pts */
116 u32b csp_frac; /* Cur mana frac (times 2^16) */
118 s16b max_plv; /* Max Player Level */
120 BASE_STATUS stat_max[A_MAX]; /* Current "maximal" stat values */
121 BASE_STATUS stat_max_max[A_MAX]; /* Maximal "maximal" stat values */
122 BASE_STATUS stat_cur[A_MAX]; /* Current "natural" stat values */
129 TIME_EFFECT fast; /* Timed -- Fast */
130 TIME_EFFECT slow; /* Timed -- Slow */
131 TIME_EFFECT blind; /* Timed -- Blindness */
132 TIME_EFFECT paralyzed; /* Timed -- Paralysis */
133 TIME_EFFECT confused; /* Timed -- Confusion */
134 TIME_EFFECT afraid; /* Timed -- Fear */
135 TIME_EFFECT image; /* Timed -- Hallucination */
136 TIME_EFFECT poisoned; /* Timed -- Poisoned */
137 TIME_EFFECT cut; /* Timed -- Cut */
138 TIME_EFFECT stun; /* Timed -- Stun */
140 TIME_EFFECT protevil; /* Timed -- Protection */
141 TIME_EFFECT invuln; /* Timed -- Invulnerable */
142 TIME_EFFECT ult_res; /* Timed -- Ultimate Resistance */
143 TIME_EFFECT hero; /* Timed -- Heroism */
144 TIME_EFFECT shero; /* Timed -- Super Heroism */
145 TIME_EFFECT shield; /* Timed -- Shield Spell */
146 TIME_EFFECT blessed; /* Timed -- Blessed */
147 TIME_EFFECT tim_invis; /* Timed -- See Invisible */
148 TIME_EFFECT tim_infra; /* Timed -- Infra Vision */
149 TIME_EFFECT tsuyoshi; /* Timed -- Tsuyoshi Special */
150 TIME_EFFECT ele_attack; /* Timed -- Elemental Attack */
151 TIME_EFFECT ele_immune; /* Timed -- Elemental Immune */
153 TIME_EFFECT oppose_acid; /* Timed -- oppose acid */
154 TIME_EFFECT oppose_elec; /* Timed -- oppose lightning */
155 TIME_EFFECT oppose_fire; /* Timed -- oppose heat */
156 TIME_EFFECT oppose_cold; /* Timed -- oppose cold */
157 TIME_EFFECT oppose_pois; /* Timed -- oppose poison */
159 TIME_EFFECT tim_esp; /* Timed ESP */
160 TIME_EFFECT wraith_form; /* Timed wraithform */
162 TIME_EFFECT resist_magic; /* Timed Resist Magic (later) */
163 TIME_EFFECT tim_regen;
164 TIME_EFFECT tim_pass_wall;
165 TIME_EFFECT tim_stealth;
166 TIME_EFFECT tim_levitation;
167 TIME_EFFECT tim_sh_touki;
168 TIME_EFFECT lightspeed;
169 TIME_EFFECT tsubureru;
170 TIME_EFFECT magicdef;
171 TIME_EFFECT tim_res_nether; /* Timed -- Nether resistance */
172 TIME_EFFECT tim_res_time; /* Timed -- Time resistance */
173 MIMIC_RACE_IDX mimic_form;
174 TIME_EFFECT tim_mimic;
175 TIME_EFFECT tim_sh_fire;
176 TIME_EFFECT tim_sh_holy;
177 TIME_EFFECT tim_eyeeye;
179 /* for mirror master */
180 TIME_EFFECT tim_reflect; /* Timed -- Reflect */
181 TIME_EFFECT multishadow; /* Timed -- Multi-shadow */
182 TIME_EFFECT dustrobe; /* Timed -- Robe of dust */
186 #define COMMAND_ARG_REST_UNTIL_DONE -2 /*!<休憩コマンド引数 … 必要な分だけ回復 */
187 #define COMMAND_ARG_REST_FULL_HEALING -1 /*!<休憩コマンド引数 … HPとMPが全回復するまで */
188 GAME_TURN resting; /* Current counter for resting, if any */
190 PATRON_IDX chaos_patron;
192 BIT_FLAGS muta1; /*!< レイシャル型の変異 / "Activatable" mutations must be in MUT1_* */
193 BIT_FLAGS muta2; /*!< 常時効果つきの変異1 / Randomly activating mutations must be MUT2_* */
194 BIT_FLAGS muta3; /*!< 常時効果つきの変異2 / Other mutations will be mainly in MUT3_* */
199 TIME_EFFECT word_recall; /* Word of recall counter */
200 TIME_EFFECT alter_reality; /* Alter reality counter */
201 DUNGEON_IDX recall_dungeon; /* Dungeon set to be recalled */
203 ENERGY energy_need; /* Energy needed for next move */
204 ENERGY enchant_energy_need; /* Energy needed for next upkeep effect */
206 FEED food; /* Current nutrition */
209 * p_ptr->special_attackによるプレイヤーの攻撃状態の定義 / Bit flags for the "p_ptr->special_attack" variable. -LM-
211 * Note: The elemental and poison attacks should be managed using the
212 * function "set_ele_attack", in spell2.c. This provides for timeouts and
213 * prevents the player from getting more than one at a time.
215 BIT_FLAGS special_attack;
217 /* プレイヤーの防御状態の定義 / Bit flags for the "p_ptr->special_defense" variable. -LM- */
218 BIT_FLAGS special_defense;
219 ACTION_IDX action; /* Currently action */
220 BIT_FLAGS spell_learned1; /* bit mask of spells learned */
221 BIT_FLAGS spell_learned2; /* bit mask of spells learned */
222 BIT_FLAGS spell_worked1; /* bit mask of spells tried and worked */
223 BIT_FLAGS spell_worked2; /* bit mask of spells tried and worked */
224 BIT_FLAGS spell_forgotten1; /* bit mask of spells learned but forgotten */
225 BIT_FLAGS spell_forgotten2; /* bit mask of spells learned but forgotten */
226 SPELL_IDX spell_order[64]; /* order spells learned/remembered/forgotten */
228 SUB_EXP spell_exp[64]; /* Proficiency of spells */
229 SUB_EXP weapon_exp[5][64]; /* Proficiency of weapons */
230 SUB_EXP skill_exp[GINOU_MAX]; /* Proficiency of misc. skill */
232 MAGIC_NUM1 magic_num1[MAX_SPELLS]; /*!< Array for non-spellbook type magic */
233 MAGIC_NUM2 magic_num2[MAX_SPELLS]; /*!< 魔道具術師の取り込み済魔道具使用回数 / Flags for non-spellbook type magics */
235 SPELL_IDX mane_spell[MAX_MANE];
236 HIT_POINT mane_dam[MAX_MANE];
240 #define CONCENT_RADAR_THRESHOLD 2
241 #define CONCENT_TELE_THRESHOLD 5
242 s16b concent; /* Sniper's concentration level */
244 HIT_POINT player_hp[PY_MAX_LEVEL];
245 char died_from[80]; /* What killed the player */
246 concptr last_message; /* Last message on death or retirement */
247 char history[4][60]; /* Textual "history" for the Player */
249 u16b panic_save; /* Panic save */
251 bool wait_report_score; /* Waiting to report score */
252 bool is_dead; /* Player is dead */
255 BIT_FLAGS change_floor_mode; /*!<フロア移行処理に関するフラグ / Mode flags for changing floor */
257 bool reset_concent; /* Concentration reset flag */
259 MONSTER_IDX riding; /* Riding on a monster of this index */
261 #define KNOW_STAT 0x01
262 #define KNOW_HPRATE 0x02
263 BIT_FLAGS8 knowledge; /* Knowledge about yourself */
264 BIT_FLAGS visit; /* Visited towns */
266 player_race_type start_race; /* Race at birth */
267 BIT_FLAGS old_race1; /* Record of race changes */
268 BIT_FLAGS old_race2; /* Record of race changes */
269 s16b old_realm; /* Record of realm changes */
271 s16b pet_follow_distance; /* Length of the imaginary "leash" for pets */
272 s16b pet_extra_flags; /* Various flags for controling pets */
274 s16b today_mon; /* Wanted monster */
276 bool dtrap; /* Whether you are on trap-safe grids */
277 FLOOR_IDX floor_id; /* Current floor location */
279 bool autopick_autoregister; /* auto register is in-use or not */
281 byte feeling; /* Most recent dungeon feeling */
282 s32b feeling_turn; /* The turn of the last dungeon feeling */
284 object_type *inventory_list; /* The player's inventory */
285 s16b inven_cnt; /* Number of items in inventory */
286 s16b equip_cnt; /* Number of items in equipment */
288 /*** Temporary fields ***/
290 bool select_ring_slot;
292 bool playing; /* True if player is playing */
293 bool leaving; /* True if player is leaving */
295 bool monk_notify_aux;
298 byte exit_bldg; /* Goal obtained in on_defeat_arena_monster? -KMW- */
300 bool leaving_dungeon; /* True if player is leaving the dungeon */
302 bool enter_dungeon; /* Just enter the dungeon */
304 IDX health_who; /* Health bar trackee */
306 MONRACE_IDX monster_race_idx; /* Monster race trackee */
308 KIND_OBJECT_IDX object_kind_idx; /* Object kind trackee */
310 s16b new_spells; /* Number of spells available */
313 s16b old_food_aux; /* Old value of food */
315 bool old_cumber_armor;
316 bool old_cumber_glove;
317 bool old_heavy_wield[2];
318 bool old_heavy_shoot;
319 bool old_icky_wield[2];
320 bool old_riding_wield[2];
321 bool old_riding_ryoute;
325 POSITION old_lite; /* Old radius of lite (if any) */
327 bool cumber_armor; /* Mana draining armor */
328 bool cumber_glove; /* Mana draining gloves */
329 bool heavy_wield[2]; /* Heavy weapon */
330 bool icky_wield[2]; /* Icky weapon */
331 bool riding_wield[2]; /* Riding weapon */
332 bool riding_ryoute; /* Riding weapon */
335 BIT_FLAGS easy_2weapon;
336 BIT_FLAGS down_saving;
338 POSITION cur_lite; /* Radius of lite (if any) */
340 BIT_FLAGS update; /* Pending Updates */
341 BIT_FLAGS redraw; /* Normal Redraws */
342 BIT_FLAGS window; /* Window Redraws */
343 s16b stat_use[A_MAX]; /* Current modified stats */
344 s16b stat_top[A_MAX]; /* Maximal modified stats */
349 ALIGNMENT align; /* Good/evil/neutral */
352 DIRECTION fishing_dir;
354 MONSTER_IDX pet_t_m_idx;
355 MONSTER_IDX riding_t_m_idx;
357 /*** Extracted fields ***/
359 s16b running; /* Current counter for running, if any */
360 bool suppress_multi_reward; /*!< 複数レベルアップ時のパトロンからの報酬多重受け取りを防止 */
362 s16b stat_add[A_MAX]; /* Modifiers to stat values */
363 s16b stat_ind[A_MAX]; /* Indexes into stat tables */
367 bool level_up_message;
369 BIT_FLAGS anti_magic; /* Anti-magic */
370 BIT_FLAGS anti_tele; /* Prevent teleportation */
372 BIT_FLAGS sustain_wis; /* Keep wisdom */
373 BIT_FLAGS sustain_dex; /* Keep dexterity */
374 BIT_FLAGS sustain_con; /* Keep constitution */
375 BIT_FLAGS sustain_chr; /* Keep charisma */
377 BIT_FLAGS cursed; /* Player is cursed */
379 bool can_swim; /* No damage falling */
380 BIT_FLAGS levitation; /* No damage falling */
381 BIT_FLAGS lite; /* Permanent light */
382 BIT_FLAGS free_act; /* Never paralyzed */
383 BIT_FLAGS see_inv; /* Can see invisible */
384 BIT_FLAGS regenerate; /* Regenerate hit pts */
385 BIT_FLAGS hold_exp; /* Resist exp draining */
387 BIT_FLAGS telepathy; /* Telepathy */
388 BIT_FLAGS esp_animal;
389 BIT_FLAGS esp_undead;
394 BIT_FLAGS esp_dragon;
398 BIT_FLAGS esp_nonliving;
399 BIT_FLAGS esp_unique;
401 BIT_FLAGS slow_digest; /* Slower digestion */
402 BIT_FLAGS bless_blade; /* Blessed blade */
403 BIT_FLAGS xtra_might; /* Extra might bow */
404 BIT_FLAGS impact; /* Earthquake blows */
405 bool pass_wall; /* Permanent wraithform */
408 BIT_FLAGS easy_spell;
409 BIT_FLAGS heavy_spell;
411 BIT_FLAGS mighty_throw;
412 BIT_FLAGS see_nocto; /* Noctovision */
413 bool invoking_midnight_curse;
415 DICE_NUMBER to_dd[2]; /* Extra dice/sides */
418 HIT_PROB dis_to_h[2]; /*!< 判明している現在の表記上の近接武器命中修正値 / Known bonus to hit (wield) */
419 HIT_PROB dis_to_h_b; /*!< 判明している現在の表記上の射撃武器命中修正値 / Known bonus to hit (bow) */
420 HIT_POINT dis_to_d[2]; /*!< 判明している現在の表記上の近接武器ダメージ修正値 / Known bonus to dam (wield) */
421 ARMOUR_CLASS dis_to_a; /*!< 判明している現在の表記上の装備AC修正値 / Known bonus to ac */
422 ARMOUR_CLASS dis_ac; /*!< 判明している現在の表記上の装備AC基礎値 / Known base ac */
424 s16b to_h[2]; /* Bonus to hit (wield) */
425 s16b to_h_b; /* Bonus to hit (bow) */
426 s16b to_h_m; /* Bonus to hit (misc) */
427 s16b to_d[2]; /* Bonus to dam (wield) */
428 s16b to_d_m; /* Bonus to dam (misc) */
429 ARMOUR_CLASS to_a; /* Bonus to ac */
431 s16b to_m_chance; /* Minusses to cast chance */
435 ARMOUR_CLASS ac; /*!< 装備無しの基本AC / Base ac */
437 ACTION_SKILL_POWER see_infra; /*!< 赤外線視能力の強さ /Infravision range */
438 ACTION_SKILL_POWER skill_dis; /*!< 行動技能値:解除能力 / Skill: Disarming */
439 ACTION_SKILL_POWER skill_dev; /*!< 行動技能値:魔道具使用 / Skill: Magic Devices */
440 ACTION_SKILL_POWER skill_sav; /*!< 行動技能値:魔法防御 / Skill: Saving throw */
441 ACTION_SKILL_POWER skill_stl; /*!< 行動技能値:隠密 / Skill: Stealth factor */
444 * 行動技能値:知覚 / Skill: Searching ability
445 * この値はsearch()による地形の隠し要素発見処理などで混乱、盲目、幻覚、無光源などの
446 * 状態異常がない限り、難易度修正などがないままそのままパーセンテージ値として使われる。
447 * 100以上ならば必ず全てのトラップなどを見つけることが出来る。
449 ACTION_SKILL_POWER skill_srh;
451 ACTION_SKILL_POWER skill_fos; /*!< 行動技能値:探索 / Skill: Searching frequency */
452 ACTION_SKILL_POWER skill_thn; /*!< 行動技能値:打撃命中能力 / Skill: To hit (normal) */
453 ACTION_SKILL_POWER skill_thb; /*!< 行動技能値:射撃命中能力 / Skill: To hit (shooting) */
454 ACTION_SKILL_POWER skill_tht; /*!< 行動技能値:投射命中能力 / Skill: To hit (throwing) */
455 ACTION_SKILL_POWER skill_dig; /*!< 行動技能値:掘削 / Skill: Digging */
457 s16b num_blow[2]; /* Number of blows */
458 s16b num_fire; /* Number of shots */
460 byte tval_xtra; /* (Unused)Correct xtra tval */
461 byte tval_ammo; /* Correct ammo tval */
463 s16b pspeed; /*!< 現在の速度 / Current speed */
465 ENERGY energy_use; /*!< 直近のターンに消費したエネルギー / Energy use this turn */
467 POSITION y; /*!< ダンジョンの現在Y座標 / Player location in dungeon */
468 POSITION x; /*!< ダンジョンの現在X座標 / Player location in dungeon */
469 GAME_TEXT name[32]; /*!< 現在のプレイヤー名 / Current player's character name */
470 char base_name[32]; /*!< Stripped version of "player_name" */
474 extern player_type *p_ptr;
476 extern concptr your_alignment(player_type *creature_ptr);
477 extern int weapon_exp_level(int weapon_exp);
478 extern int riding_exp_level(int riding_exp);
479 extern int spell_exp_level(int spell_exp);
481 extern int calc_weapon_weight_limit(player_type *creature_ptr);
482 extern WEIGHT calc_inventory_weight(player_type *creature_ptr);
484 extern s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr);
485 extern void calc_bonuses(player_type *creature_ptr);
486 extern WEIGHT calc_weight_limit(player_type *creature_ptr);
487 extern bool has_melee_weapon(player_type *creature_ptr, int i);
489 extern bool heavy_armor(player_type *creature_ptr);
490 extern void update_creature(player_type *creature_ptr);
491 extern BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control);
492 extern bool player_has_no_spellbooks(player_type *creature_ptr);
494 extern void take_turn(player_type *creature_ptr, PERCENTAGE need_cost);
495 extern void free_turn(player_type *creature_ptr);
497 extern bool player_place(player_type *creature_ptr, POSITION y, POSITION x);
499 extern void check_experience(player_type *creature_ptr);
500 extern void wreck_the_pattern(player_type *creature_ptr);
501 extern void cnv_stat(int val, char *out_val);
502 extern s16b modify_stat_value(int value, int amount);
503 extern long calc_score(player_type *creature_ptr);
505 extern bool is_blessed(player_type *creature_ptr);
506 extern bool is_time_limit_esp(player_type *creature_ptr);
507 extern bool is_time_limit_stealth(player_type *creature_ptr);
508 extern bool can_two_hands_wielding(player_type *creature_ptr);
509 bool is_fast(player_type *creature_ptr);
510 bool is_invuln(player_type *creature_ptr);
511 bool is_hero(player_type *creature_ptr);
512 bool is_shero(player_type *creature_ptr);
513 bool is_echizen(player_type *creature_ptr);
516 * Player "food" crucial values
518 #define PY_FOOD_MAX 15000 /*!< 食べ過ぎ~満腹の閾値 / Food value (Bloated) */
519 #define PY_FOOD_FULL 10000 /*!< 満腹~平常の閾値 / Food value (Normal) */
520 #define PY_FOOD_ALERT 2000 /*!< 平常~空腹の閾値 / Food value (Hungry) */
521 #define PY_FOOD_WEAK 1000 /*!< 空腹~衰弱の閾値 / Food value (Weak) */
522 #define PY_FOOD_FAINT 500 /*!< 衰弱~衰弱(赤表示/麻痺)の閾値 / Food value (Fainting) */
523 #define PY_FOOD_STARVE 100 /*!< 衰弱(赤表示/麻痺)~飢餓ダメージの閾値 / Food value (Starving) */
526 * Player regeneration constants
528 #define PY_REGEN_NORMAL 197 /* Regen factor*2^16 when full */
529 #define PY_REGEN_WEAK 98 /* Regen factor*2^16 when weak */
530 #define PY_REGEN_FAINT 33 /* Regen factor*2^16 when fainting */
531 #define PY_REGEN_HPBASE 1442 /* Min amount hp regen*2^16 */
532 #define PY_REGEN_MNBASE 524 /* Min amount mana regen*2^16 */
534 extern void stop_singing(player_type *creature_ptr);
535 extern void stop_mouth(player_type *caster_ptr);
536 extern PERCENTAGE calculate_upkeep(player_type *creature_ptr);
537 extern bool music_singing(player_type *caster_ptr, int music_songs);
539 #define SINGING_SONG_EFFECT(P_PTR) ((P_PTR)->magic_num1[0])
540 #define INTERUPTING_SONG_EFFECT(P_PTR) ((P_PTR)->magic_num1[1])
541 #define SINGING_COUNT(P_PTR) ((P_PTR)->magic_num1[2])
542 #define SINGING_SONG_ID(P_PTR) ((P_PTR)->magic_num2[0])
543 #define music_singing_any(CREATURE_PTR) (((CREATURE_PTR)->pclass == CLASS_BARD) && (CREATURE_PTR)->magic_num1[0])