1 #include "player/player-status.h"
2 #include "artifact/fixed-art-types.h"
3 #include "autopick/autopick-reader-writer.h"
4 #include "autopick/autopick.h"
5 #include "avatar/avatar.h"
6 #include "cmd-action/cmd-pet.h"
7 #include "cmd-action/cmd-spell.h"
8 #include "cmd-io/cmd-dump.h"
9 #include "cmd-item/cmd-magiceat.h"
10 #include "combat/attack-power-table.h"
11 #include "core/asking-player.h"
12 #include "core/player-redraw-types.h"
13 #include "core/player-update-types.h"
14 #include "core/stuff-handler.h"
15 #include "core/window-redrawer.h"
16 #include "dungeon/dungeon-flag-types.h"
17 #include "dungeon/dungeon.h"
18 #include "effect/effect-characteristics.h"
19 #include "floor/cave.h"
20 #include "floor/floor-events.h"
21 #include "floor/floor-leaver.h"
22 #include "floor/floor-save.h"
23 #include "floor/floor-util.h"
24 #include "game-option/birth-options.h"
25 #include "grid/feature.h"
26 #include "grid/grid.h"
27 #include "inventory/inventory-object.h"
28 #include "io/input-key-acceptor.h"
29 #include "io/write-diary.h"
30 #include "main/sound-definitions-table.h"
31 #include "main/sound-of-music.h"
32 #include "market/arena-info-table.h"
33 #include "mind/mind-force-trainer.h"
34 #include "mind/mind-ninja.h"
35 #include "monster-floor/monster-lite.h"
36 #include "monster-floor/monster-remover.h"
37 #include "monster-race/monster-race-hook.h"
38 #include "monster-race/monster-race.h"
39 #include "monster-race/race-flags1.h"
40 #include "monster-race/race-flags2.h"
41 #include "monster-race/race-flags7.h"
42 #include "monster/monster-update.h"
43 #include "monster/smart-learn-types.h"
44 #include "mutation/mutation-calculator.h"
45 #include "mutation/mutation-flag-types.h"
46 #include "mutation/mutation-investor-remover.h"
47 #include "object-enchant/object-ego.h"
48 #include "object-enchant/special-object-flags.h"
49 #include "object-enchant/tr-types.h"
50 #include "object-enchant/trc-types.h"
51 #include "object-hook/hook-armor.h"
52 #include "object-hook/hook-checker.h"
53 #include "object-hook/hook-weapon.h"
54 #include "object/object-flags.h"
55 #include "object/object-info.h"
56 #include "object/object-mark-types.h"
57 #include "perception/object-perception.h"
58 #include "pet/pet-util.h"
59 #include "player-info/alignment.h"
60 #include "player-info/equipment-info.h"
61 #include "player-status/player-basic-statistics.h"
62 #include "player-status/player-hand-types.h"
63 #include "player-status/player-infravision.h"
64 #include "player-status/player-speed.h"
65 #include "player-status/player-stealth.h"
66 #include "player/attack-defense-types.h"
67 #include "player/digestion-processor.h"
68 #include "player/mimic-info-table.h"
69 #include "player/patron.h"
70 #include "player/player-class.h"
71 #include "player/player-damage.h"
72 #include "player/player-move.h"
73 #include "player/player-personality-types.h"
74 #include "player/player-personality.h"
75 #include "player/player-race-types.h"
76 #include "player/player-skill.h"
77 #include "player/player-status-flags.h"
78 #include "player/player-status-table.h"
79 #include "player/player-view.h"
80 #include "player/race-info-table.h"
81 #include "player/special-defense-types.h"
82 #include "realm/realm-hex-numbers.h"
83 #include "realm/realm-names-table.h"
84 #include "realm/realm-song-numbers.h"
85 #include "specific-object/bow.h"
86 #include "specific-object/torch.h"
87 #include "spell-realm/spells-hex.h"
88 #include "spell-realm/spells-song.h"
89 #include "spell/range-calc.h"
90 #include "spell/spells-describer.h"
91 #include "spell/spells-execution.h"
92 #include "spell/spells-status.h"
93 #include "spell/technic-info-table.h"
94 #include "status/action-setter.h"
95 #include "status/base-status.h"
96 #include "sv-definition/sv-lite-types.h"
97 #include "sv-definition/sv-weapon-types.h"
98 #include "system/floor-type-definition.h"
99 #include "system/grid-type-definition.h"
100 #include "system/monster-race-definition.h"
101 #include "system/monster-type-definition.h"
102 #include "system/object-type-definition.h"
103 #include "system/player-type-definition.h"
104 #include "term/screen-processor.h"
105 #include "util/bit-flags-calculator.h"
106 #include "util/quarks.h"
107 #include "util/string-processor.h"
108 #include "view/display-messages.h"
109 #include "world/world.h"
111 static const int extra_magic_glove_reduce_mana = 1;
113 static bool is_martial_arts_mode(player_type *creature_ptr);
115 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
116 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
117 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
118 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
119 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
120 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
121 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
122 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
123 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
124 static bool is_heavy_wield(player_type *creature_ptr, int i);
125 static int16_t calc_num_blow(player_type *creature_ptr, int i);
126 static int16_t calc_to_magic_chance(player_type *creature_ptr);
127 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
128 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value);
129 static int16_t calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
130 static bool is_riding_two_hands(player_type *creature_ptr);
131 static int16_t calc_riding_bow_penalty(player_type *creature_ptr);
132 static void put_equipment_warning(player_type *creature_ptr);
134 static int16_t calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
135 static int16_t calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
137 static int16_t calc_to_hit_bow(player_type *creature_ptr, bool is_real_value);
139 static int16_t calc_to_damage_misc(player_type *creature_ptr);
140 static int16_t calc_to_hit_misc(player_type *creature_ptr);
142 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
143 static player_hand main_attack_hand(player_type *creature_ptr);
145 /*** Player information ***/
148 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
149 * @param weapon_exp 経験値
152 int weapon_exp_level(int weapon_exp)
154 if (weapon_exp < WEAPON_EXP_BEGINNER)
155 return EXP_LEVEL_UNSKILLED;
156 else if (weapon_exp < WEAPON_EXP_SKILLED)
157 return EXP_LEVEL_BEGINNER;
158 else if (weapon_exp < WEAPON_EXP_EXPERT)
159 return EXP_LEVEL_SKILLED;
160 else if (weapon_exp < WEAPON_EXP_MASTER)
161 return EXP_LEVEL_EXPERT;
163 return EXP_LEVEL_MASTER;
167 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
168 * @param weapon_exp 経験値
171 int riding_exp_level(int riding_exp)
173 if (riding_exp < RIDING_EXP_BEGINNER)
174 return EXP_LEVEL_UNSKILLED;
175 else if (riding_exp < RIDING_EXP_SKILLED)
176 return EXP_LEVEL_BEGINNER;
177 else if (riding_exp < RIDING_EXP_EXPERT)
178 return EXP_LEVEL_SKILLED;
179 else if (riding_exp < RIDING_EXP_MASTER)
180 return EXP_LEVEL_EXPERT;
182 return EXP_LEVEL_MASTER;
186 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
187 * @param spell_exp 経験値
190 int spell_exp_level(int spell_exp)
192 if (spell_exp < SPELL_EXP_BEGINNER)
193 return EXP_LEVEL_UNSKILLED;
194 else if (spell_exp < SPELL_EXP_SKILLED)
195 return EXP_LEVEL_BEGINNER;
196 else if (spell_exp < SPELL_EXP_EXPERT)
197 return EXP_LEVEL_SKILLED;
198 else if (spell_exp < SPELL_EXP_MASTER)
199 return EXP_LEVEL_EXPERT;
201 return EXP_LEVEL_MASTER;
205 * @brief 遅延描画更新 / Delayed visual update
206 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
207 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
208 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
210 static void delayed_visual_update(player_type *player_ptr)
212 floor_type *floor_ptr = player_ptr->current_floor_ptr;
213 for (int i = 0; i < floor_ptr->redraw_n; i++) {
214 POSITION y = floor_ptr->redraw_y[i];
215 POSITION x = floor_ptr->redraw_x[i];
217 g_ptr = &floor_ptr->grid_array[y][x];
218 if (none_bits(g_ptr->info, CAVE_REDRAW))
221 if (any_bits(g_ptr->info, CAVE_NOTE))
222 note_spot(player_ptr, y, x);
224 lite_spot(player_ptr, y, x);
226 update_monster(player_ptr, g_ptr->m_idx, false);
228 reset_bits(g_ptr->info, (CAVE_NOTE | CAVE_REDRAW));
231 floor_ptr->redraw_n = 0;
235 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
236 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
237 * @return 重すぎるならばTRUE
239 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
241 return (calc_bow_weight_limit(creature_ptr) < o_ptr->weight / 10);
246 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
249 WEIGHT calc_inventory_weight(player_type *creature_ptr)
254 for (int i = 0; i < INVEN_TOTAL; i++) {
255 o_ptr = &creature_ptr->inventory_list[i];
258 weight += o_ptr->weight * o_ptr->number;
263 * @brief プレイヤーの全ステータスを更新する /
264 * Calculate the players current "state", taking into account
265 * not only race/class intrinsics, but also objects being worn
266 * and temporary spell effects.
269 * See also update_max_mana() and update_max_hitpoints().
271 * Take note of the new "speed code", in particular, a very strong
272 * player will start slowing down as soon as he reaches 150 pounds,
273 * but not until he reaches 450 pounds will he be half as fast as
274 * a normal kobold. This both hurts and helps the player, hurts
275 * because in the old days a player could just avoid 300 pounds,
276 * and helps because now carrying 300 pounds is not very painful.
278 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
279 * damage, since that would affect non-combat things. These values
280 * are actually added in later, at the appropriate place.
282 * This function induces various "status" messages.
284 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
286 static void update_bonuses(player_type *creature_ptr)
288 auto empty_hands_status = empty_hands(creature_ptr, true);
291 /* Save the old vision stuff */
292 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
293 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
294 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
295 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
296 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
297 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
298 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
299 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
300 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
301 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
302 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
303 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
304 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
305 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
306 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
307 int16_t old_speed = creature_ptr->pspeed;
309 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
310 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
312 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
313 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
314 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
315 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
316 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
317 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
318 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
319 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
320 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
321 creature_ptr->esp_human = has_esp_human(creature_ptr);
322 creature_ptr->esp_good = has_esp_good(creature_ptr);
323 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
324 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
325 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
326 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
327 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
328 creature_ptr->down_saving = has_down_saving(creature_ptr);
329 creature_ptr->yoiyami = has_no_ac(creature_ptr);
330 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
331 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
332 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
333 creature_ptr->warning = has_warning(creature_ptr);
334 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
335 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
336 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
337 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
338 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
339 creature_ptr->see_inv = has_see_inv(creature_ptr);
340 creature_ptr->free_act = has_free_act(creature_ptr);
341 creature_ptr->levitation = has_levitation(creature_ptr);
342 creature_ptr->can_swim = has_can_swim(creature_ptr);
343 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
344 creature_ptr->regenerate = has_regenerate(creature_ptr);
345 update_curses(creature_ptr);
346 creature_ptr->impact = has_impact(creature_ptr);
347 creature_ptr->earthquake = has_earthquake(creature_ptr);
348 update_extra_blows(creature_ptr);
350 creature_ptr->lite = has_lite(creature_ptr);
352 if (any_bits(creature_ptr->special_defense, KAMAE_MASK)) {
353 if (none_bits(empty_hands_status, EMPTY_HAND_MAIN)) {
354 set_action(creature_ptr, ACTION_NONE);
358 creature_ptr->stat_add[A_STR] = PlayerStrength(creature_ptr).modification_value();
359 creature_ptr->stat_add[A_INT] = PlayerIntelligence(creature_ptr).modification_value();
360 creature_ptr->stat_add[A_WIS] = PlayerWisdom(creature_ptr).modification_value();
361 creature_ptr->stat_add[A_DEX] = PlayerDexterity(creature_ptr).modification_value();
362 creature_ptr->stat_add[A_CON] = PlayerConstitution(creature_ptr).modification_value();
363 creature_ptr->stat_add[A_CHR] = PlayerCharisma(creature_ptr).modification_value();
365 PlayerStrength(creature_ptr).update_value();
366 PlayerIntelligence(creature_ptr).update_value();
367 PlayerWisdom(creature_ptr).update_value();
368 PlayerDexterity(creature_ptr).update_value();
369 PlayerConstitution(creature_ptr).update_value();
370 PlayerCharisma(creature_ptr).update_value();
372 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
374 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
375 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
378 for (int i = 0; i < 2; i++) {
379 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
380 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
381 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
382 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
383 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
384 creature_ptr->to_ds[i] = 0;
387 creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value();
388 creature_ptr->see_infra = PlayerInfravision(creature_ptr).get_value();
389 creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value();
390 creature_ptr->skill_dis = calc_disarming(creature_ptr);
391 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
392 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
393 creature_ptr->skill_srh = calc_search(creature_ptr);
394 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
395 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
396 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
397 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
398 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
399 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, true);
400 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, true);
401 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, false);
402 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, false);
403 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, true);
404 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, true);
405 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, false);
406 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, false);
407 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, true);
408 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, false);
409 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
410 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
411 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
412 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
413 creature_ptr->ac = calc_base_ac(creature_ptr);
414 creature_ptr->to_a = calc_to_ac(creature_ptr, true);
415 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
416 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, false);
418 if (old_mighty_throw != creature_ptr->mighty_throw) {
419 creature_ptr->window_flags |= PW_INVEN;
422 if (creature_ptr->telepathy != old_telepathy) {
423 set_bits(creature_ptr->update, PU_MONSTERS);
426 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
427 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
428 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
429 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
430 set_bits(creature_ptr->update, PU_MONSTERS);
433 if (creature_ptr->see_inv != old_see_inv) {
434 set_bits(creature_ptr->update, PU_MONSTERS);
437 if (creature_ptr->pspeed != old_speed) {
438 set_bits(creature_ptr->redraw, PR_SPEED);
441 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
442 set_bits(creature_ptr->redraw, PR_ARMOR);
443 set_bits(creature_ptr->window_flags, PW_PLAYER);
446 if (current_world_ptr->character_xtra)
449 put_equipment_warning(creature_ptr);
450 check_no_flowed(creature_ptr);
454 * @brief プレイヤーの最大HPを更新する /
455 * Update the players maximal hit points
456 * Adjust current hitpoints if necessary
459 static void update_max_hitpoints(player_type *creature_ptr)
461 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_index[A_CON]]) - 128) * creature_ptr->lev / 4;
462 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
465 if (creature_ptr->mimic_form) {
466 if (creature_ptr->pclass == CLASS_SORCERER)
467 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
469 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
470 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
473 if (creature_ptr->pclass == CLASS_SORCERER) {
474 if (creature_ptr->lev < 30)
475 mhp = (mhp * (45 + creature_ptr->lev) / 100);
477 mhp = (mhp * 75 / 100);
478 bonus = (bonus * 65 / 100);
483 if (creature_ptr->pclass == CLASS_BERSERKER) {
484 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
487 if (mhp < creature_ptr->lev + 1)
488 mhp = creature_ptr->lev + 1;
489 if (is_hero(creature_ptr))
491 if (is_shero(creature_ptr))
493 if (creature_ptr->tsuyoshi)
495 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
497 if (hex_spelling(creature_ptr, HEX_BUILDING))
499 if (creature_ptr->mhp == mhp)
502 if (creature_ptr->chp >= mhp) {
503 creature_ptr->chp = mhp;
504 creature_ptr->chp_frac = 0;
508 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
509 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
512 creature_ptr->mhp = mhp;
514 creature_ptr->redraw |= PR_HP;
515 creature_ptr->window_flags |= PW_PLAYER;
519 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
520 * Calculate number of spells player should have, and forget,
521 * or remember, spells until that number is properly reflected.
523 * Note that this function induces various "status" messages,
524 * which must be bypasses until the character is created.
526 static void update_num_of_spells(player_type *creature_ptr)
528 if (!mp_ptr->spell_book)
530 if (!current_world_ptr->character_generated)
532 if (current_world_ptr->character_xtra)
534 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
535 creature_ptr->new_spells = 0;
539 concptr p = spell_category_name(mp_ptr->spell_book);
540 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
544 int num_allowed = (adj_mag_study[creature_ptr->stat_index[mp_ptr->spell_stat]] * levels / 2);
546 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
550 if (creature_ptr->pclass == CLASS_SAMURAI) {
552 } else if (creature_ptr->realm2 == REALM_NONE) {
553 num_allowed = (num_allowed + 1) / 2;
554 if (num_allowed > (32 + bonus))
555 num_allowed = 32 + bonus;
556 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
557 if (num_allowed > (96 + bonus))
558 num_allowed = 96 + bonus;
560 if (num_allowed > (80 + bonus))
561 num_allowed = 80 + bonus;
564 int num_boukyaku = 0;
565 for (int j = 0; j < 64; j++) {
566 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
571 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
572 for (int i = 63; i >= 0; i--) {
573 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
576 int j = creature_ptr->spell_order[i];
580 const magic_type *s_ptr;
581 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
583 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
585 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
587 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
589 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
591 if (s_ptr->slevel <= creature_ptr->lev)
594 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
595 if (!is_spell_learned)
600 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
601 which = creature_ptr->realm1;
603 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
604 which = creature_ptr->realm2;
608 reset_bits(creature_ptr->spell_learned1, (1UL << j));
609 which = creature_ptr->realm1;
611 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
612 which = creature_ptr->realm2;
616 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
618 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
620 creature_ptr->new_spells++;
623 /* Forget spells if we know too many spells */
624 for (int i = 63; i >= 0; i--) {
625 if (creature_ptr->new_spells >= 0)
627 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
630 int j = creature_ptr->spell_order[i];
634 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
635 if (!is_spell_learned)
640 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
641 which = creature_ptr->realm1;
643 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
644 which = creature_ptr->realm2;
648 reset_bits(creature_ptr->spell_learned1, (1UL << j));
649 which = creature_ptr->realm1;
651 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
652 which = creature_ptr->realm2;
656 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
658 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
660 creature_ptr->new_spells++;
663 /* Check for spells to remember */
664 for (int i = 0; i < 64; i++) {
665 if (creature_ptr->new_spells <= 0)
667 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
669 int j = creature_ptr->spell_order[i];
673 const magic_type *s_ptr;
674 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
676 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
678 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
680 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
682 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
684 if (s_ptr->slevel > creature_ptr->lev)
687 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
688 if (!is_spell_learned)
693 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
694 which = creature_ptr->realm1;
696 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
697 which = creature_ptr->realm2;
701 set_bits(creature_ptr->spell_learned1, (1UL << j));
702 which = creature_ptr->realm1;
704 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
705 which = creature_ptr->realm2;
709 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
711 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
713 creature_ptr->new_spells--;
716 if (creature_ptr->realm2 == REALM_NONE) {
718 for (int j = 0; j < 32; j++) {
719 const magic_type *s_ptr;
720 if (!is_magic(creature_ptr->realm1))
721 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
723 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
725 if (s_ptr->slevel > creature_ptr->lev)
728 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
737 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
738 creature_ptr->new_spells = (int16_t)k;
742 if (creature_ptr->new_spells < 0)
743 creature_ptr->new_spells = 0;
745 if (creature_ptr->old_spells == creature_ptr->new_spells)
748 if (creature_ptr->new_spells) {
750 if (creature_ptr->new_spells < 10) {
751 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
753 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
756 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
760 creature_ptr->old_spells = creature_ptr->new_spells;
761 set_bits(creature_ptr->redraw, PR_STUDY);
762 set_bits(creature_ptr->window_flags, PW_OBJECT);
766 * @brief プレイヤーの最大MPを更新する /
767 * Update maximum mana. You do not need to know any spells.
768 * Note that mana is lowered by heavy (or inappropriate) armor.
770 * This function induces status messages.
772 static void update_max_mana(player_type *creature_ptr)
774 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
778 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)
779 || creature_ptr->pclass == CLASS_ELEMENTALIST) {
780 levels = creature_ptr->lev;
782 if (mp_ptr->spell_first > creature_ptr->lev) {
783 creature_ptr->msp = 0;
784 set_bits(creature_ptr->redraw, PR_MANA);
788 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
792 if (creature_ptr->pclass == CLASS_SAMURAI) {
793 msp = (adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] + 10) * 2;
795 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
797 msp = adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] * (levels + 3) / 4;
801 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
802 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
804 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
806 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
807 msp += msp * (25 + creature_ptr->lev) / 100;
810 if (any_bits(mp_ptr->spell_xtra, extra_magic_glove_reduce_mana)) {
811 BIT_FLAGS flgs[TR_FLAG_SIZE];
812 creature_ptr->cumber_glove = false;
814 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
815 object_flags(creature_ptr, o_ptr, flgs);
816 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
817 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
818 creature_ptr->cumber_glove = true;
823 creature_ptr->cumber_armor = false;
826 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
827 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
828 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
829 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
830 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
831 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
832 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
833 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
834 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
836 switch (creature_ptr->pclass) {
838 case CLASS_HIGH_MAGE:
839 case CLASS_BLUE_MAGE:
841 case CLASS_FORCETRAINER:
843 case CLASS_ELEMENTALIST: {
844 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
845 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
846 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
847 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
852 case CLASS_TOURIST: {
853 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
854 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
855 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
856 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
859 case CLASS_MINDCRAFTER:
860 case CLASS_BEASTMASTER:
861 case CLASS_MIRROR_MASTER: {
862 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
863 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
864 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
865 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
871 case CLASS_WARRIOR_MAGE: {
872 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
873 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
874 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
875 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
879 case CLASS_CHAOS_WARRIOR: {
880 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
881 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
882 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
883 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
891 int max_wgt = mp_ptr->spell_weight;
892 if ((cur_wgt - max_wgt) > 0) {
893 creature_ptr->cumber_armor = true;
894 switch (creature_ptr->pclass) {
896 case CLASS_HIGH_MAGE:
897 case CLASS_BLUE_MAGE:
898 case CLASS_ELEMENTALIST: {
899 msp -= msp * (cur_wgt - max_wgt) / 600;
903 case CLASS_MINDCRAFTER:
904 case CLASS_BEASTMASTER:
906 case CLASS_FORCETRAINER:
908 case CLASS_MIRROR_MASTER: {
909 msp -= msp * (cur_wgt - max_wgt) / 800;
912 case CLASS_SORCERER: {
913 msp -= msp * (cur_wgt - max_wgt) / 900;
919 case CLASS_RED_MAGE: {
920 msp -= msp * (cur_wgt - max_wgt) / 1000;
924 case CLASS_CHAOS_WARRIOR:
925 case CLASS_WARRIOR_MAGE: {
926 msp -= msp * (cur_wgt - max_wgt) / 1200;
929 case CLASS_SAMURAI: {
930 creature_ptr->cumber_armor = false;
934 msp -= msp * (cur_wgt - max_wgt) / 800;
943 if (creature_ptr->msp != msp) {
944 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
945 creature_ptr->csp = msp;
946 creature_ptr->csp_frac = 0;
950 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
951 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
954 creature_ptr->msp = msp;
955 set_bits(creature_ptr->redraw, PR_MANA);
956 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
959 if (current_world_ptr->character_xtra)
962 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
963 if (creature_ptr->cumber_glove)
964 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
966 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
968 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
971 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
974 if (creature_ptr->cumber_armor)
975 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
977 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
979 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
983 * @brief 装備中の射撃武器の威力倍率を返す /
984 * calcurate the fire rate of target object
985 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
986 * @return 射撃倍率の値(100で1.00倍)
988 int16_t calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
991 BIT_FLAGS flgs[TR_FLAG_SIZE];
993 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
995 q_ptr = &creature_ptr->inventory_list[i];
1002 object_flags(creature_ptr, q_ptr, flgs);
1003 if (has_flag(flgs, TR_XTRA_SHOTS))
1007 object_flags(creature_ptr, o_ptr, flgs);
1008 if (has_flag(flgs, TR_XTRA_SHOTS))
1012 if (o_ptr->k_idx == 0)
1013 return (int16_t)num;
1016 num += (extra_shots * 100);
1018 if (is_heavy_shoot(creature_ptr, o_ptr))
1019 return (int16_t)num;
1021 tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
1022 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1023 num += (creature_ptr->lev * 4);
1026 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1027 num += (creature_ptr->lev * 3);
1030 if (creature_ptr->pclass == CLASS_ARCHER) {
1031 if (tval_ammo == TV_ARROW)
1032 num += ((creature_ptr->lev * 5) + 50);
1033 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1034 num += (creature_ptr->lev * 4);
1037 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1038 num += (creature_ptr->lev * 2);
1041 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1042 num += (creature_ptr->lev * 4);
1045 return (int16_t)num;
1050 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1054 * * 職業と性格とレベルによる追加加算
1055 * * 器用さに応じたadj_dex_disテーブルによる加算
1056 * * 知力に応じたadj_int_disテーブルによる加算
1058 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1060 ACTION_SKILL_POWER pow;
1061 const player_race *tmp_rp_ptr;
1063 if (creature_ptr->mimic_form)
1064 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1066 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1067 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1068 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1070 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1071 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1072 pow += adj_dex_dis[creature_ptr->stat_index[A_DEX]];
1073 pow += adj_int_dis[creature_ptr->stat_index[A_INT]];
1079 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1083 * * 職業と性格とレベルによる追加加算
1084 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1085 * * 知力に応じたadj_int_devテーブルによる加算
1088 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1090 ACTION_SKILL_POWER pow;
1091 const player_race *tmp_rp_ptr;
1093 if (creature_ptr->mimic_form)
1094 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1096 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1097 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1098 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1100 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1101 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1103 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1105 BIT_FLAGS flgs[TR_FLAG_SIZE];
1106 o_ptr = &creature_ptr->inventory_list[i];
1109 object_flags(creature_ptr, o_ptr, flgs);
1110 if (has_flag(flgs, TR_MAGIC_MASTERY))
1111 pow += 8 * o_ptr->pval;
1114 pow += adj_int_dev[creature_ptr->stat_index[A_INT]];
1116 if (is_shero(creature_ptr)) {
1124 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1128 * * 職業と性格とレベルによる追加加算
1129 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1130 * * 呪力耐性の装備による加算(30)
1131 * * 祝福された装備による加算(5 + レベル / 10)
1132 * * 賢さによるadj_wis_savテーブル加算
1134 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1135 * * クターのつぶれ状態なら(10に上書き)
1136 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1137 * * 呪いのdown_savingがかかっているなら半減
1139 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1141 ACTION_SKILL_POWER pow;
1142 const player_race *tmp_rp_ptr;
1144 if (creature_ptr->mimic_form)
1145 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1147 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1148 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1149 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1151 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1152 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1154 if (creature_ptr->muta.has(MUTA::MAGIC_RES))
1155 pow += (15 + (creature_ptr->lev / 5));
1157 if (has_resist_curse(creature_ptr))
1160 if (creature_ptr->bless_blade)
1161 pow += 6 + (creature_ptr->lev - 1) / 10;
1163 pow += adj_wis_sav[creature_ptr->stat_index[A_WIS]];
1165 if (is_shero(creature_ptr))
1168 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1169 pow = 90 + creature_ptr->lev;
1171 if (creature_ptr->tsubureru)
1174 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1175 pow = 95 + creature_ptr->lev;
1177 if (creature_ptr->down_saving)
1185 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1190 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1192 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1194 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1196 ACTION_SKILL_POWER pow;
1197 const player_race *tmp_rp_ptr;
1199 if (creature_ptr->mimic_form)
1200 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1202 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1203 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1204 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1206 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1207 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1209 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1211 BIT_FLAGS flgs[TR_FLAG_SIZE];
1212 o_ptr = &creature_ptr->inventory_list[i];
1215 object_flags(creature_ptr, o_ptr, flgs);
1216 if (has_flag(flgs, TR_SEARCH))
1217 pow += (o_ptr->pval * 5);
1220 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1224 if (is_shero(creature_ptr)) {
1233 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1238 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1240 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1242 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1244 ACTION_SKILL_POWER pow;
1245 const player_race *tmp_rp_ptr;
1247 if (creature_ptr->mimic_form)
1248 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1250 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1251 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1252 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1254 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1255 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1257 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1259 BIT_FLAGS flgs[TR_FLAG_SIZE];
1260 o_ptr = &creature_ptr->inventory_list[i];
1263 object_flags(creature_ptr, o_ptr, flgs);
1264 if (has_flag(flgs, TR_SEARCH))
1265 pow += (o_ptr->pval * 5);
1268 if (is_shero(creature_ptr)) {
1272 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1281 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1284 * * 種族/職業/性格による加算とレベルによる追加加算
1286 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1288 ACTION_SKILL_POWER pow;
1289 const player_race *tmp_rp_ptr;
1290 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1291 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1293 if (creature_ptr->mimic_form)
1294 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1296 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1298 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1299 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1305 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1308 * * 種族/職業/性格による加算とレベルによる追加加算
1310 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1312 ACTION_SKILL_POWER pow;
1313 const player_race *tmp_rp_ptr;
1314 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1315 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1317 if (creature_ptr->mimic_form)
1318 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1320 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1322 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1323 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1329 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1332 * * 種族/職業/性格による加算とレベルによる追加加算
1335 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1337 ACTION_SKILL_POWER pow;
1338 const player_race *tmp_rp_ptr;
1339 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1340 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1342 if (creature_ptr->mimic_form)
1343 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1345 tmp_rp_ptr = &race_info[static_cast<int>(creature_ptr->prace)];
1347 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1348 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1350 if (is_shero(creature_ptr)) {
1359 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1370 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1373 BIT_FLAGS flgs[TR_FLAG_SIZE];
1375 ACTION_SKILL_POWER pow;
1379 if (!creature_ptr->mimic_form && creature_ptr->prace == player_race_type::ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1380 pow += creature_ptr->lev * 10;
1383 if (is_shero(creature_ptr))
1386 pow += adj_str_dig[creature_ptr->stat_index[A_STR]];
1388 if (creature_ptr->pclass == CLASS_BERSERKER)
1389 pow += (100 + creature_ptr->lev * 8);
1391 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1392 o_ptr = &creature_ptr->inventory_list[i];
1395 object_flags(creature_ptr, o_ptr, flgs);
1396 if (has_flag(flgs, TR_TUNNEL))
1397 pow += (o_ptr->pval * 20);
1400 for (int i = 0; i < 2; i++) {
1401 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1402 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1403 pow += (o_ptr->weight / 10);
1407 if (is_shero(creature_ptr)) {
1417 static bool is_martial_arts_mode(player_type *creature_ptr)
1419 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1420 && (any_bits(empty_hands(creature_ptr, true), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1423 static bool is_heavy_wield(player_type *creature_ptr, int i)
1425 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1427 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1430 static int16_t calc_num_blow(player_type *creature_ptr, int i)
1433 BIT_FLAGS flgs[TR_FLAG_SIZE];
1434 int16_t num_blow = 1;
1436 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1437 object_flags(creature_ptr, o_ptr, flgs);
1438 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1439 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1440 int str_index, dex_index;
1441 int num = 0, wgt = 0, mul = 0, div = 0;
1443 num = class_info[creature_ptr->pclass].num;
1444 wgt = class_info[creature_ptr->pclass].wgt;
1445 mul = class_info[creature_ptr->pclass].mul;
1447 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1453 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1459 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1460 str_index = (adj_str_blow[creature_ptr->stat_index[A_STR]] * mul / div);
1462 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1463 str_index += (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) ? (creature_ptr->lev / 23 + 1) : 1;
1464 if (creature_ptr->pclass == CLASS_NINJA)
1465 str_index = MAX(0, str_index - 1);
1469 dex_index = (adj_dex_blow[creature_ptr->stat_index[A_DEX]]);
1473 num_blow = blows_table[str_index][dex_index];
1475 num_blow = (int16_t)num;
1477 num_blow += (int16_t)creature_ptr->extra_blows[i];
1478 if (creature_ptr->pclass == CLASS_WARRIOR)
1479 num_blow += (creature_ptr->lev / 40);
1480 else if (creature_ptr->pclass == CLASS_BERSERKER)
1481 num_blow += (creature_ptr->lev / 23);
1482 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_index[A_DEX] >= 30))
1485 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1488 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1498 /* Different calculation for monks with empty hands */
1499 if (is_martial_arts_mode(creature_ptr)) {
1500 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_index[A_DEX]];
1503 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1529 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1532 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1534 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1538 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1542 num_blow += 1 + creature_ptr->extra_blows[0];
1545 if (has_not_ninja_weapon(creature_ptr, i)) {
1556 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1559 * * 性格なまけものなら加算(+10)
1561 * * 性格ちからじまんとがまんづよいなら加算(+1)
1562 * * 性格チャージマンなら加算(+5)
1563 * * 装備品にTRC::HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
1565 static int16_t calc_to_magic_chance(player_type *creature_ptr)
1569 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
1571 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
1573 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
1575 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
1578 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1580 BIT_FLAGS flgs[TR_FLAG_SIZE];
1581 o_ptr = &creature_ptr->inventory_list[i];
1584 object_flags(creature_ptr, o_ptr, flgs);
1585 if (o_ptr->curse_flags.has(TRC::HARD_SPELL)) {
1586 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
1596 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
1598 ARMOUR_CLASS ac = 0;
1599 if (creature_ptr->yoiyami)
1602 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1604 o_ptr = &creature_ptr->inventory_list[i];
1610 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
1611 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1612 ac += creature_ptr->skill_exp[SKILL_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
1618 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
1620 ARMOUR_CLASS ac = 0;
1621 BIT_FLAGS flags[TR_FLAG_SIZE];
1622 if (creature_ptr->yoiyami)
1625 ac += ((int)(adj_dex_ta[creature_ptr->stat_index[A_DEX]]) - 128);
1627 if (creature_ptr->mimic_form) {
1628 switch (creature_ptr->mimic_form) {
1632 case MIMIC_DEMON_LORD:
1640 if (creature_ptr->pclass == CLASS_BERSERKER) {
1641 ac += 10 + creature_ptr->lev / 2;
1643 if (creature_ptr->pclass == CLASS_SORCERER) {
1647 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1649 o_ptr = &creature_ptr->inventory_list[i];
1650 object_flags(creature_ptr, o_ptr, flags);
1653 if (is_real_value || object_is_known(o_ptr))
1656 if (o_ptr->curse_flags.has(TRC::LOW_AC)) {
1657 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
1658 if (is_real_value || object_is_fully_known(o_ptr))
1661 if (is_real_value || object_is_fully_known(o_ptr))
1666 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
1671 if (is_specific_player_race(creature_ptr, player_race_type::GOLEM) || is_specific_player_race(creature_ptr, player_race_type::ANDROID)) {
1672 ac += 10 + (creature_ptr->lev * 2 / 5);
1675 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
1679 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1680 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1684 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
1688 if (creature_ptr->muta.has(MUTA::WART_SKIN)) {
1692 if (creature_ptr->muta.has(MUTA::SCALES)) {
1696 if (creature_ptr->muta.has(MUTA::IRON_SKIN)) {
1700 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
1701 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
1702 ac += (creature_ptr->lev * 3) / 2;
1704 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
1705 ac += ((creature_ptr->lev - 13) / 3);
1707 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
1708 ac += ((creature_ptr->lev - 8) / 3);
1710 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
1711 ac += (creature_ptr->lev - 2) / 3;
1713 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
1714 ac += (creature_ptr->lev / 2);
1716 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
1717 ac += (creature_ptr->lev / 3);
1721 if (creature_ptr->realm1 == REALM_HEX) {
1722 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
1726 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
1727 object_type *o_ptr = &creature_ptr->inventory_list[i];
1730 if (!object_is_armour(creature_ptr, o_ptr))
1732 if (!object_is_cursed(o_ptr))
1734 if (o_ptr->curse_flags.has(TRC::CURSED))
1736 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
1738 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE))
1743 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1744 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
1745 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1747 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
1749 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1753 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
1755 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
1759 if (is_blessed(creature_ptr)) {
1763 if (is_shero(creature_ptr)) {
1767 if (creature_ptr->pclass == CLASS_NINJA) {
1768 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1769 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1770 ac += creature_ptr->lev / 2 + 5;
1778 * @brief 二刀流ペナルティ量計算
1779 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1780 * @param slot ペナルティ量を計算する武器スロット
1785 * * EASY2_WEAPONによる軽減
1786 * * SUPPORTIVEを左に装備した場合の軽減
1790 int16_t calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
1793 BIT_FLAGS flags[TR_FLAG_SIZE];
1795 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1796 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
1798 penalty = ((100 - creature_ptr->skill_exp[SKILL_TWO_WEAPON] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
1799 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
1800 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
1801 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
1802 penalty = penalty / 2 - 5;
1805 for (uint i = FLAG_CAUSE_INVEN_MAIN_HAND; i < FLAG_CAUSE_MAX; i <<= 1)
1806 if (penalty > 0 && any_bits(creature_ptr->easy_2weapon, i))
1809 if (has_flag(flags, TR_SUPPORTIVE))
1810 penalty = MAX(0, penalty - 10);
1812 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1813 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1814 penalty = MIN(0, penalty);
1817 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
1820 return (int16_t)penalty;
1823 static bool is_riding_two_hands(player_type *creature_ptr)
1825 if (!creature_ptr->riding) {
1829 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE))
1831 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
1832 switch (creature_ptr->pclass) {
1834 case CLASS_FORCETRAINER:
1835 case CLASS_BERSERKER:
1836 if ((empty_hands(creature_ptr, false) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
1837 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
1848 static int16_t calc_riding_bow_penalty(player_type *creature_ptr)
1850 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1851 if (!creature_ptr->riding)
1854 int16_t penalty = 0;
1856 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
1857 if (creature_ptr->tval_ammo != TV_ARROW)
1860 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[SKILL_RIDING] / 80;
1866 if (creature_ptr->tval_ammo == TV_BOLT)
1872 void put_equipment_warning(player_type *creature_ptr)
1874 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
1875 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
1877 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
1878 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
1879 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
1881 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
1883 creature_ptr->old_heavy_shoot = heavy_shoot;
1886 for (int i = 0; i < 2; i++) {
1887 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
1888 if (creature_ptr->heavy_wield[i]) {
1889 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
1890 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1891 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
1892 } else if (creature_ptr->heavy_wield[1 - i]) {
1893 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
1895 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
1898 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
1901 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
1902 if (creature_ptr->riding_wield[i]) {
1903 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
1904 } else if (!creature_ptr->riding) {
1905 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
1906 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1907 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
1910 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
1913 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
1916 if (creature_ptr->icky_wield[i]) {
1917 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
1918 if (current_world_ptr->is_loading_now) {
1919 chg_virtue(creature_ptr, V_FAITH, -1);
1921 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1922 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
1924 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
1927 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
1930 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
1931 if (creature_ptr->riding_ryoute) {
1933 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
1935 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
1939 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE) ? "手が空いて" : "");
1941 msg_print("You began to control the pet you're riding with one hand.");
1945 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
1948 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
1949 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
1950 if (heavy_armor(creature_ptr)) {
1951 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
1952 if (current_world_ptr->is_loading_now) {
1953 chg_virtue(creature_ptr, V_HARMONY, -1);
1956 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
1959 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
1963 static int16_t calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
1965 object_type *o_ptr = &creature_ptr->inventory_list[slot];
1966 BIT_FLAGS flgs[TR_FLAG_SIZE];
1967 object_flags(creature_ptr, o_ptr, flgs);
1969 player_hand calc_hand = PLAYER_HAND_OTHER;
1970 if (slot == INVEN_MAIN_HAND)
1971 calc_hand = PLAYER_HAND_MAIN;
1972 if (slot == INVEN_SUB_HAND)
1973 calc_hand = PLAYER_HAND_SUB;
1976 damage += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
1978 if (is_shero(creature_ptr)) {
1979 damage += 3 + (creature_ptr->lev / 5);
1982 if (creature_ptr->stun > 50) {
1984 } else if (creature_ptr->stun) {
1988 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1990 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
1991 damage += creature_ptr->lev / 6;
1992 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
1993 damage += creature_ptr->lev / 6;
1995 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1996 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2001 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
2002 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
2003 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2004 damage += get_current_ki(creature_ptr) / 5;
2008 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2009 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2010 if (o_ptr->curse_flags.has(TRC::CURSED)) {
2013 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2016 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
2022 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2024 o_ptr = &creature_ptr->inventory_list[i];
2025 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2026 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2029 if (!object_is_known(o_ptr) && !is_real_value)
2031 bonus_to_d = o_ptr->to_d;
2033 if (creature_ptr->pclass == CLASS_NINJA) {
2034 if (o_ptr->to_d > 0)
2035 bonus_to_d = (o_ptr->to_d + 1) / 2;
2038 switch (player_melee_type(creature_ptr)) {
2039 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2040 case MELEE_TYPE_WEAPON_TWOHAND:
2041 if (calc_hand == main_attack_hand(creature_ptr))
2042 damage += (int16_t)bonus_to_d;
2045 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2046 case MELEE_TYPE_WEAPON_MAIN:
2047 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2048 damage += (int16_t)bonus_to_d;
2051 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2052 case MELEE_TYPE_WEAPON_SUB:
2053 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2054 damage += (int16_t)bonus_to_d;
2057 case MELEE_TYPE_WEAPON_DOUBLE:
2058 if (calc_hand == PLAYER_HAND_MAIN) {
2059 if (i == INVEN_MAIN_RING) {
2060 damage += (int16_t)bonus_to_d;
2061 } else if (i != INVEN_SUB_RING) {
2062 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2065 if (calc_hand == PLAYER_HAND_SUB) {
2066 if (i == INVEN_SUB_RING) {
2067 damage += (int16_t)bonus_to_d;
2068 } else if (i != INVEN_MAIN_RING) {
2069 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2074 case MELEE_TYPE_SHIELD_DOUBLE:
2082 if (main_attack_hand(creature_ptr) == calc_hand) {
2083 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2084 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2086 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128) / 2;
2087 damage += MAX(bonus_to_d, 1);
2091 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2092 damage += (creature_ptr->lev / 6);
2095 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
2096 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2097 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2098 damage -= (creature_ptr->lev / 6);
2106 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
2108 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
2110 static int16_t calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2115 hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2116 hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2118 /* Temporary bonuses */
2119 if (is_blessed(creature_ptr)) {
2123 if (is_hero(creature_ptr)) {
2127 if (is_shero(creature_ptr)) {
2131 if (creature_ptr->stun > 50) {
2133 } else if (creature_ptr->stun) {
2137 player_hand calc_hand = PLAYER_HAND_OTHER;
2138 if (slot == INVEN_MAIN_HAND)
2139 calc_hand = PLAYER_HAND_MAIN;
2140 if (slot == INVEN_SUB_HAND)
2141 calc_hand = PLAYER_HAND_SUB;
2143 /* Default hand bonuses */
2144 if (main_attack_hand(creature_ptr) == calc_hand) {
2145 switch (player_melee_type(creature_ptr)) {
2146 case MELEE_TYPE_BAREHAND_MAIN:
2147 if (creature_ptr->riding)
2150 case MELEE_TYPE_BAREHAND_SUB:
2151 if (creature_ptr->riding)
2154 case MELEE_TYPE_BAREHAND_TWO:
2155 hit += (creature_ptr->skill_exp[SKILL_MARTIAL_ARTS] - WEAPON_EXP_BEGINNER) / 200;
2162 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2163 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2165 bonus_to_h = ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128) + ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2166 hit += MAX(bonus_to_h, 1);
2170 /* Bonuses and penalties by weapon */
2171 if (has_melee_weapon(creature_ptr, slot)) {
2172 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2173 BIT_FLAGS flgs[TR_FLAG_SIZE];
2174 object_flags(creature_ptr, o_ptr, flgs);
2176 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
2177 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
2179 /* Traind bonuses */
2180 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2182 /* Weight penalty */
2183 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
2184 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2187 /* Low melee penalty */
2188 if ((object_is_fully_known(o_ptr) || is_real_value) && o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
2189 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2196 /* Riding bonus and penalty */
2197 if (creature_ptr->riding) {
2198 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2203 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2204 && !has_flag(flgs, TR_RIDING)) {
2206 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2209 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[SKILL_RIDING] / 80;
2214 hit -= (int16_t)penalty;
2217 /* Class penalties */
2218 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2220 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2221 hit += creature_ptr->lev / 5;
2222 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2223 hit += creature_ptr->lev / 5;
2225 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2226 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2233 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
2237 /* Hex realm bonuses */
2238 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2239 if (o_ptr->curse_flags.has(TRC::CURSED)) {
2242 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2245 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
2248 if (o_ptr->curse_flags.has(TRC::TY_CURSE)) {
2254 /* Bonuses from inventory */
2255 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2256 object_type *o_ptr = &creature_ptr->inventory_list[i];
2258 /* Ignore empty hands, handed weapons, bows and capture balls */
2259 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2260 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2263 /* Fake value does not include unknown objects' value */
2264 if (!object_is_known(o_ptr) && !is_real_value)
2267 int bonus_to_h = o_ptr->to_h;
2269 /* When wields only a weapon */
2270 if (creature_ptr->pclass == CLASS_NINJA) {
2271 if (o_ptr->to_h > 0)
2272 bonus_to_h = (o_ptr->to_h + 1) / 2;
2275 switch (player_melee_type(creature_ptr)) {
2276 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2277 case MELEE_TYPE_WEAPON_TWOHAND:
2278 if (calc_hand == main_attack_hand(creature_ptr))
2279 hit += (int16_t)bonus_to_h;
2282 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2283 case MELEE_TYPE_WEAPON_MAIN:
2284 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2285 hit += (int16_t)bonus_to_h;
2288 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2289 case MELEE_TYPE_WEAPON_SUB:
2290 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2291 hit += (int16_t)bonus_to_h;
2294 case MELEE_TYPE_WEAPON_DOUBLE:
2295 if (calc_hand == PLAYER_HAND_MAIN) {
2296 if (i == INVEN_MAIN_RING) {
2297 hit += (int16_t)bonus_to_h;
2298 } else if (i != INVEN_SUB_RING) {
2299 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2302 if (calc_hand == PLAYER_HAND_SUB) {
2303 if (i == INVEN_SUB_RING) {
2304 hit += (int16_t)bonus_to_h;
2305 } else if (i != INVEN_MAIN_RING) {
2306 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2311 case MELEE_TYPE_SHIELD_DOUBLE:
2319 /* Martial arts bonus */
2320 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2321 hit += (creature_ptr->lev / 3);
2324 /* Two handed combat penalty */
2325 hit -= calc_double_weapon_penalty(creature_ptr, slot);
2327 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
2328 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2329 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2330 hit -= (creature_ptr->lev / 3);
2337 static int16_t calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
2341 pow += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2342 pow += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2346 BIT_FLAGS flgs[TR_FLAG_SIZE];
2347 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2349 object_flags(creature_ptr, o_ptr, flgs);
2351 if (o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
2352 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2361 if (creature_ptr->stun > 50) {
2363 } else if (creature_ptr->stun) {
2367 if (is_blessed(creature_ptr)) {
2371 if (is_hero(creature_ptr)) {
2375 if (is_shero(creature_ptr)) {
2379 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2381 if (is_heavy_shoot(creature_ptr, o_ptr)) {
2382 pow += 2 * (calc_bow_weight_limit(creature_ptr) - o_ptr->weight / 10);
2386 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
2387 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
2388 pow += (10 + (creature_ptr->lev / 5));
2394 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2396 o_ptr = &creature_ptr->inventory_list[i];
2397 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2398 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2401 bonus_to_h = o_ptr->to_h;
2403 if (creature_ptr->pclass == CLASS_NINJA) {
2404 if (o_ptr->to_h > 0)
2405 bonus_to_h = (o_ptr->to_h + 1) / 2;
2408 if (is_real_value || object_is_known(o_ptr))
2409 pow += (int16_t)bonus_to_h;
2412 pow -= calc_riding_bow_penalty(creature_ptr);
2417 static int16_t calc_to_damage_misc(player_type *creature_ptr)
2420 BIT_FLAGS flgs[TR_FLAG_SIZE];
2424 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2425 o_ptr = &creature_ptr->inventory_list[i];
2429 object_flags(creature_ptr, o_ptr, flgs);
2431 int bonus_to_d = o_ptr->to_d;
2432 if (creature_ptr->pclass == CLASS_NINJA) {
2433 if (o_ptr->to_d > 0)
2434 bonus_to_d = (o_ptr->to_d + 1) / 2;
2436 to_dam += (int16_t)bonus_to_d;
2439 if (is_shero(creature_ptr)) {
2440 to_dam += 3 + (creature_ptr->lev / 5);
2443 if (creature_ptr->stun > 50) {
2445 } else if (creature_ptr->stun) {
2449 to_dam += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2453 static int16_t calc_to_hit_misc(player_type *creature_ptr)
2456 BIT_FLAGS flgs[TR_FLAG_SIZE];
2460 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2461 o_ptr = &creature_ptr->inventory_list[i];
2465 object_flags(creature_ptr, o_ptr, flgs);
2467 int bonus_to_h = o_ptr->to_h;
2468 if (creature_ptr->pclass == CLASS_NINJA) {
2469 if (o_ptr->to_h > 0)
2470 bonus_to_h = (o_ptr->to_h + 1) / 2;
2472 to_hit += (int16_t)bonus_to_h;
2475 if (is_blessed(creature_ptr)) {
2479 if (is_hero(creature_ptr)) {
2483 if (is_shero(creature_ptr)) {
2487 if (creature_ptr->stun > 50) {
2489 } else if (creature_ptr->stun) {
2493 to_hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2494 to_hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2499 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
2501 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2504 if (creature_ptr->riding) {
2505 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2514 * @brief プレイヤーの所持重量制限を計算する /
2515 * Computes current weight limit.
2518 WEIGHT calc_weight_limit(player_type *creature_ptr)
2520 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_index[A_STR]] * 50;
2521 if (creature_ptr->pclass == CLASS_BERSERKER)
2527 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
2528 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
2530 void update_creature(player_type *creature_ptr)
2532 if (!creature_ptr->update)
2535 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2536 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
2537 reset_bits(creature_ptr->update, PU_AUTODESTROY);
2538 autopick_delayed_alter(creature_ptr);
2541 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
2542 reset_bits(creature_ptr->update, PU_COMBINE);
2543 combine_pack(creature_ptr);
2546 if (any_bits(creature_ptr->update, (PU_REORDER))) {
2547 reset_bits(creature_ptr->update, PU_REORDER);
2548 reorder_pack(creature_ptr);
2551 if (any_bits(creature_ptr->update, (PU_BONUS))) {
2552 reset_bits(creature_ptr->update, PU_BONUS);
2553 PlayerAlignment(creature_ptr).update_alignment();
2554 update_bonuses(creature_ptr);
2557 if (any_bits(creature_ptr->update, (PU_TORCH))) {
2558 reset_bits(creature_ptr->update, PU_TORCH);
2559 update_lite_radius(creature_ptr);
2562 if (any_bits(creature_ptr->update, (PU_HP))) {
2563 reset_bits(creature_ptr->update, PU_HP);
2564 update_max_hitpoints(creature_ptr);
2567 if (any_bits(creature_ptr->update, (PU_MANA))) {
2568 reset_bits(creature_ptr->update, PU_MANA);
2569 update_max_mana(creature_ptr);
2572 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
2573 reset_bits(creature_ptr->update, PU_SPELLS);
2574 update_num_of_spells(creature_ptr);
2577 if (!current_world_ptr->character_generated)
2579 if (current_world_ptr->character_icky_depth > 0)
2581 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
2582 reset_bits(creature_ptr->update, PU_UN_LITE);
2583 forget_lite(floor_ptr);
2586 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
2587 reset_bits(creature_ptr->update, PU_UN_VIEW);
2588 forget_view(floor_ptr);
2591 if (any_bits(creature_ptr->update, (PU_VIEW))) {
2592 reset_bits(creature_ptr->update, PU_VIEW);
2593 update_view(creature_ptr);
2596 if (any_bits(creature_ptr->update, (PU_LITE))) {
2597 reset_bits(creature_ptr->update, PU_LITE);
2598 update_lite(creature_ptr);
2601 if (any_bits(creature_ptr->update, (PU_FLOW))) {
2602 reset_bits(creature_ptr->update, PU_FLOW);
2603 update_flow(creature_ptr);
2606 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
2607 reset_bits(creature_ptr->update, PU_DISTANCE);
2609 update_monsters(creature_ptr, true);
2612 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
2613 reset_bits(creature_ptr->update, PU_MON_LITE);
2614 update_mon_lite(creature_ptr);
2617 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
2618 reset_bits(creature_ptr->update, PU_DELAY_VIS);
2619 delayed_visual_update(creature_ptr);
2622 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
2623 reset_bits(creature_ptr->update, PU_MONSTERS);
2624 update_monsters(creature_ptr, false);
2629 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
2630 * @return 魔道書を一冊も持っていないならTRUEを返す
2632 bool player_has_no_spellbooks(player_type *creature_ptr)
2635 for (int i = 0; i < INVEN_PACK; i++) {
2636 o_ptr = &creature_ptr->inventory_list[i];
2637 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2641 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2642 for (const auto this_o_idx : floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx_list) {
2643 o_ptr = &floor_ptr->o_list[this_o_idx];
2644 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2652 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
2655 * @return 配置に成功したらTRUE
2657 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
2659 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
2662 /* Save player location */
2663 creature_ptr->y = y;
2664 creature_ptr->x = x;
2669 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
2671 void wreck_the_pattern(player_type *creature_ptr)
2673 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2674 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
2675 if (pattern_type == PATTERN_TILE_WRECKED)
2678 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
2679 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
2681 if (!is_invuln(creature_ptr))
2682 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"));
2684 int to_ruin = randint1(45) + 35;
2687 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
2689 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
2690 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
2694 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
2698 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
2699 * Advance experience levels and print experience
2701 void check_experience(player_type *creature_ptr)
2703 if (creature_ptr->exp < 0)
2704 creature_ptr->exp = 0;
2705 if (creature_ptr->max_exp < 0)
2706 creature_ptr->max_exp = 0;
2707 if (creature_ptr->max_max_exp < 0)
2708 creature_ptr->max_max_exp = 0;
2710 if (creature_ptr->exp > PY_MAX_EXP)
2711 creature_ptr->exp = PY_MAX_EXP;
2712 if (creature_ptr->max_exp > PY_MAX_EXP)
2713 creature_ptr->max_exp = PY_MAX_EXP;
2714 if (creature_ptr->max_max_exp > PY_MAX_EXP)
2715 creature_ptr->max_max_exp = PY_MAX_EXP;
2717 if (creature_ptr->exp > creature_ptr->max_exp)
2718 creature_ptr->max_exp = creature_ptr->exp;
2719 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
2720 creature_ptr->max_max_exp = creature_ptr->max_exp;
2722 set_bits(creature_ptr->redraw, PR_EXP);
2723 handle_stuff(creature_ptr);
2725 bool android = (creature_ptr->prace == player_race_type::ANDROID ? true : false);
2726 PLAYER_LEVEL old_lev = creature_ptr->lev;
2727 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
2728 creature_ptr->lev--;
2729 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2730 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
2731 set_bits(creature_ptr->window_flags, PW_PLAYER);
2732 handle_stuff(creature_ptr);
2735 bool level_reward = false;
2736 bool level_mutation = false;
2737 bool level_inc_stat = false;
2738 while ((creature_ptr->lev < PY_MAX_LEVEL)
2739 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
2740 creature_ptr->lev++;
2741 if (creature_ptr->lev > creature_ptr->max_plv) {
2742 creature_ptr->max_plv = creature_ptr->lev;
2744 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || creature_ptr->muta.has(MUTA::CHAOS_GIFT)) {
2745 level_reward = true;
2747 if (creature_ptr->prace == player_race_type::BEASTMAN) {
2749 level_mutation = true;
2751 level_inc_stat = true;
2753 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
2757 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
2758 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
2759 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
2760 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
2761 creature_ptr->level_up_message = true;
2762 handle_stuff(creature_ptr);
2764 creature_ptr->level_up_message = false;
2765 if (level_inc_stat) {
2766 if (!(creature_ptr->max_plv % 10)) {
2773 cnv_stat(creature_ptr->stat_max[0], tmp);
2774 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
2775 cnv_stat(creature_ptr->stat_max[1], tmp);
2776 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
2777 cnv_stat(creature_ptr->stat_max[2], tmp);
2778 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
2779 cnv_stat(creature_ptr->stat_max[3], tmp);
2780 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
2781 cnv_stat(creature_ptr->stat_max[4], tmp);
2782 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
2783 cnv_stat(creature_ptr->stat_max[5], tmp);
2784 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
2787 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
2791 if ((choice >= 'a') && (choice <= 'f'))
2794 for (n = 0; n < A_MAX; n++)
2795 if (n != choice - 'a')
2797 if (get_check(_("よろしいですか?", "Are you sure? ")))
2800 do_inc_stat(creature_ptr, choice - 'a');
2802 } else if (!(creature_ptr->max_plv % 2))
2803 do_inc_stat(creature_ptr, randint0(6));
2806 if (level_mutation) {
2807 msg_print(_("あなたは変わった気がする...", "You feel different..."));
2808 (void)gain_mutation(creature_ptr, 0);
2809 level_mutation = false;
2813 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
2817 gain_level_reward(creature_ptr, 0);
2818 level_reward = false;
2821 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2822 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
2823 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
2824 handle_stuff(creature_ptr);
2827 if (old_lev != creature_ptr->lev)
2828 autopick_load_pref(creature_ptr, false);
2832 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
2834 * @param out_val 出力先文字列ポインタ
2836 void cnv_stat(int val, char *out_val)
2839 sprintf(out_val, " %2d", val);
2843 int bonus = (val - 18);
2845 sprintf(out_val, "18/%3s", "***");
2846 } else if (bonus >= 100) {
2847 sprintf(out_val, "18/%03d", bonus);
2849 sprintf(out_val, " 18/%02d", bonus);
2854 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
2855 * Modify a stat value by a "modifier", return new value
2857 * @param amount 加減算値
2861 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
2862 * Or even: 18/13, 18/23, 18/33, ..., 18/220
2863 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
2864 * Or even: 18/13, 18/03, 18, 17, ..., 3
2867 int16_t modify_stat_value(int value, int amount)
2870 for (int i = 0; i < amount; i++) {
2876 } else if (amount < 0) {
2877 for (int i = 0; i < (0 - amount); i++) {
2878 if (value >= 18 + 10)
2880 else if (value > 18)
2887 return (int16_t)value;
2892 * Hack -- Calculates the total number of points earned -JWT-
2895 long calc_score(player_type *creature_ptr)
2897 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
2910 if (ironman_small_levels)
2912 if (ironman_empty_levels)
2918 if (ironman_nightmare)
2925 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
2926 if (max_dlv[i] > max_dl)
2927 max_dl = max_dlv[i];
2929 uint32_t point_l = (creature_ptr->max_max_exp + (100 * max_dl));
2930 uint32_t point_h = point_l / 0x10000L;
2931 point_l = point_l % 0x10000L;
2934 point_h += point_l / 0x10000L;
2935 point_l %= 0x10000L;
2937 point_l += ((point_h % 100) << 16);
2941 uint32_t point = (point_h << 16) + (point_l);
2942 if (creature_ptr->arena_number >= 0)
2943 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
2945 if (ironman_downward)
2947 if (creature_ptr->pclass == CLASS_BERSERKER) {
2948 if (creature_ptr->prace == player_race_type::SPECTRE)
2952 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
2954 if (current_world_ptr->total_winner)
2959 point = (0 - point);
2965 * @param creature_ptr プレーヤーへの参照ポインタ
2966 * @return 祝福状態ならばTRUE
2968 bool is_blessed(player_type *creature_ptr)
2970 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
2973 bool is_tim_esp(player_type *creature_ptr)
2975 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
2978 bool is_tim_stealth(player_type *creature_ptr)
2980 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
2983 bool is_time_limit_esp(player_type *creature_ptr)
2985 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
2988 bool is_time_limit_stealth(player_type *creature_ptr)
2990 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
2994 * @brief 口を使う継続的な処理を中断する
2995 * @param caster_ptr プレーヤーへの参照ポインタ
2997 void stop_mouth(player_type *caster_ptr)
2999 if (music_singing_any(caster_ptr))
3000 stop_singing(caster_ptr);
3001 if (hex_spelling_any(caster_ptr))
3002 stop_hex_spell_all(caster_ptr);
3005 bool is_fast(player_type *creature_ptr)
3007 return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO);
3010 bool is_invuln(player_type *creature_ptr)
3012 return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN);
3015 bool is_hero(player_type *creature_ptr)
3017 return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO);
3020 bool is_shero(player_type *creature_ptr)
3022 return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER;
3025 bool is_echizen(player_type *creature_ptr)
3027 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
3030 bool is_chargeman(player_type *creature_ptr)
3032 return creature_ptr->pseikaku == PERSONALITY_CHARGEMAN;
3035 WEIGHT calc_weapon_weight_limit(player_type *creature_ptr)
3037 WEIGHT weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3039 if (has_two_handed_weapons(creature_ptr))
3045 WEIGHT calc_bow_weight_limit(player_type *creature_ptr)
3047 WEIGHT weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3052 static player_hand main_attack_hand(player_type *creature_ptr)
3054 switch (player_melee_type(creature_ptr)) {
3055 case MELEE_TYPE_BAREHAND_TWO:
3056 return PLAYER_HAND_MAIN;
3057 case MELEE_TYPE_BAREHAND_MAIN:
3058 return PLAYER_HAND_MAIN;
3059 case MELEE_TYPE_BAREHAND_SUB:
3060 return PLAYER_HAND_SUB;
3061 case MELEE_TYPE_WEAPON_MAIN:
3062 return PLAYER_HAND_MAIN;
3063 case MELEE_TYPE_WEAPON_SUB:
3064 return PLAYER_HAND_SUB;
3065 case MELEE_TYPE_WEAPON_TWOHAND:
3066 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
3067 case MELEE_TYPE_WEAPON_DOUBLE:
3068 return PLAYER_HAND_MAIN;
3069 case MELEE_TYPE_SHIELD_DOUBLE:
3070 return PLAYER_HAND_MAIN;
3072 return PLAYER_HAND_MAIN;