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 "cmd-action/cmd-pet.h"
6 #include "cmd-action/cmd-spell.h"
7 #include "cmd-io/cmd-dump.h"
8 #include "cmd-item/cmd-magiceat.h"
9 #include "combat/attack-power-table.h"
10 #include "core/asking-player.h"
11 #include "core/player-redraw-types.h"
12 #include "core/player-update-types.h"
13 #include "core/stuff-handler.h"
14 #include "core/window-redrawer.h"
15 #include "dungeon/dungeon-flag-types.h"
16 #include "dungeon/dungeon.h"
17 #include "effect/effect-characteristics.h"
18 #include "floor/cave.h"
19 #include "floor/floor-events.h"
20 #include "floor/floor-leaver.h"
21 #include "floor/floor-save.h"
22 #include "floor/floor-util.h"
23 #include "game-option/birth-options.h"
24 #include "grid/feature.h"
25 #include "grid/grid.h"
26 #include "inventory/inventory-object.h"
27 #include "io/input-key-acceptor.h"
28 #include "io/write-diary.h"
29 #include "main/sound-definitions-table.h"
30 #include "main/sound-of-music.h"
31 #include "market/arena-info-table.h"
32 #include "mind/mind-force-trainer.h"
33 #include "mind/mind-ninja.h"
34 #include "monster-floor/monster-lite.h"
35 #include "monster-floor/monster-remover.h"
36 #include "monster-race/monster-race-hook.h"
37 #include "monster-race/monster-race.h"
38 #include "monster-race/race-flags1.h"
39 #include "monster-race/race-flags2.h"
40 #include "monster-race/race-flags7.h"
41 #include "monster/monster-update.h"
42 #include "monster/smart-learn-types.h"
43 #include "mutation/mutation-calculator.h"
44 #include "mutation/mutation-flag-types.h"
45 #include "mutation/mutation-investor-remover.h"
46 #include "object-enchant/object-ego.h"
47 #include "object-enchant/special-object-flags.h"
48 #include "object-enchant/tr-types.h"
49 #include "object-enchant/trc-types.h"
50 #include "object-hook/hook-armor.h"
51 #include "object-hook/hook-checker.h"
52 #include "object-hook/hook-weapon.h"
53 #include "object/object-flags.h"
54 #include "object/object-info.h"
55 #include "object/object-mark-types.h"
56 #include "perception/object-perception.h"
57 #include "pet/pet-util.h"
58 #include "player-info/alignment.h"
59 #include "player-info/avatar.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/monster-race-definition.h"
100 #include "system/monster-type-definition.h"
101 #include "system/object-type-definition.h"
102 #include "system/player-type-definition.h"
103 #include "term/screen-processor.h"
104 #include "util/bit-flags-calculator.h"
105 #include "util/quarks.h"
106 #include "util/string-processor.h"
107 #include "view/display-messages.h"
108 #include "world/world.h"
110 static const int extra_magic_glove_reduce_mana = 1;
112 static bool is_martial_arts_mode(player_type *creature_ptr);
114 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
115 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
116 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
117 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
118 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
119 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
120 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
121 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
122 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
123 static bool is_heavy_wield(player_type *creature_ptr, int i);
124 static s16b calc_num_blow(player_type *creature_ptr, int i);
125 static s16b calc_to_magic_chance(player_type *creature_ptr);
126 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
127 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value);
128 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
129 static bool is_riding_two_hands(player_type *creature_ptr);
130 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
131 static void put_equipment_warning(player_type *creature_ptr);
133 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
134 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
136 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value);
138 static s16b calc_to_damage_misc(player_type *creature_ptr);
139 static s16b calc_to_hit_misc(player_type *creature_ptr);
141 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
142 static player_hand main_attack_hand(player_type *creature_ptr);
144 /*** Player information ***/
147 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
148 * @param weapon_exp 経験値
151 int weapon_exp_level(int weapon_exp)
153 if (weapon_exp < WEAPON_EXP_BEGINNER)
154 return EXP_LEVEL_UNSKILLED;
155 else if (weapon_exp < WEAPON_EXP_SKILLED)
156 return EXP_LEVEL_BEGINNER;
157 else if (weapon_exp < WEAPON_EXP_EXPERT)
158 return EXP_LEVEL_SKILLED;
159 else if (weapon_exp < WEAPON_EXP_MASTER)
160 return EXP_LEVEL_EXPERT;
162 return EXP_LEVEL_MASTER;
166 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
167 * @param weapon_exp 経験値
170 int riding_exp_level(int riding_exp)
172 if (riding_exp < RIDING_EXP_BEGINNER)
173 return EXP_LEVEL_UNSKILLED;
174 else if (riding_exp < RIDING_EXP_SKILLED)
175 return EXP_LEVEL_BEGINNER;
176 else if (riding_exp < RIDING_EXP_EXPERT)
177 return EXP_LEVEL_SKILLED;
178 else if (riding_exp < RIDING_EXP_MASTER)
179 return EXP_LEVEL_EXPERT;
181 return EXP_LEVEL_MASTER;
185 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
186 * @param spell_exp 経験値
189 int spell_exp_level(int spell_exp)
191 if (spell_exp < SPELL_EXP_BEGINNER)
192 return EXP_LEVEL_UNSKILLED;
193 else if (spell_exp < SPELL_EXP_SKILLED)
194 return EXP_LEVEL_BEGINNER;
195 else if (spell_exp < SPELL_EXP_EXPERT)
196 return EXP_LEVEL_SKILLED;
197 else if (spell_exp < SPELL_EXP_MASTER)
198 return EXP_LEVEL_EXPERT;
200 return EXP_LEVEL_MASTER;
204 * @brief 遅延描画更新 / Delayed visual update
205 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
206 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
207 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
209 static void delayed_visual_update(player_type *player_ptr)
211 floor_type *floor_ptr = player_ptr->current_floor_ptr;
212 for (int i = 0; i < floor_ptr->redraw_n; i++) {
213 POSITION y = floor_ptr->redraw_y[i];
214 POSITION x = floor_ptr->redraw_x[i];
216 g_ptr = &floor_ptr->grid_array[y][x];
217 if (none_bits(g_ptr->info, CAVE_REDRAW))
220 if (any_bits(g_ptr->info, CAVE_NOTE))
221 note_spot(player_ptr, y, x);
223 lite_spot(player_ptr, y, x);
225 update_monster(player_ptr, g_ptr->m_idx, false);
227 reset_bits(g_ptr->info, (CAVE_NOTE | CAVE_REDRAW));
230 floor_ptr->redraw_n = 0;
234 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
235 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
236 * @return 重すぎるならばTRUE
238 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
240 int hold = adj_str_hold[creature_ptr->stat_index[A_STR]];
241 return (hold < 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 int 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 s16b 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 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
376 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
380 for (int i = 0; i < 2; i++) {
381 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
382 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
383 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
384 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
385 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
386 creature_ptr->to_ds[i] = 0;
389 creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value();
390 creature_ptr->see_infra = PlayerInfravision(creature_ptr).get_value();
391 creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value();
392 creature_ptr->skill_dis = calc_disarming(creature_ptr);
393 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
394 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
395 creature_ptr->skill_srh = calc_search(creature_ptr);
396 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
397 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
398 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
399 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
400 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
401 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, true);
402 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, true);
403 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, false);
404 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, false);
405 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, true);
406 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, true);
407 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, false);
408 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, false);
409 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, true);
410 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, false);
411 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
412 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
413 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
414 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
415 creature_ptr->ac = calc_base_ac(creature_ptr);
416 creature_ptr->to_a = calc_to_ac(creature_ptr, true);
417 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
418 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, false);
420 if (old_mighty_throw != creature_ptr->mighty_throw) {
421 creature_ptr->window_flags |= PW_INVEN;
424 if (creature_ptr->telepathy != old_telepathy) {
425 set_bits(creature_ptr->update, PU_MONSTERS);
428 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
429 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
430 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
431 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
432 set_bits(creature_ptr->update, PU_MONSTERS);
435 if (creature_ptr->see_inv != old_see_inv) {
436 set_bits(creature_ptr->update, PU_MONSTERS);
439 if (creature_ptr->pspeed != old_speed) {
440 set_bits(creature_ptr->redraw, PR_SPEED);
443 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
444 set_bits(creature_ptr->redraw, PR_ARMOR);
445 set_bits(creature_ptr->window_flags, PW_PLAYER);
448 if (current_world_ptr->character_xtra)
451 put_equipment_warning(creature_ptr);
452 check_no_flowed(creature_ptr);
456 * @brief プレイヤーの最大HPを更新する /
457 * Update the players maximal hit points
458 * Adjust current hitpoints if necessary
461 static void update_max_hitpoints(player_type *creature_ptr)
463 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_index[A_CON]]) - 128) * creature_ptr->lev / 4;
464 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
467 if (creature_ptr->mimic_form) {
468 if (creature_ptr->pclass == CLASS_SORCERER)
469 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
471 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
472 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
475 if (creature_ptr->pclass == CLASS_SORCERER) {
476 if (creature_ptr->lev < 30)
477 mhp = (mhp * (45 + creature_ptr->lev) / 100);
479 mhp = (mhp * 75 / 100);
480 bonus = (bonus * 65 / 100);
485 if (creature_ptr->pclass == CLASS_BERSERKER) {
486 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
489 if (mhp < creature_ptr->lev + 1)
490 mhp = creature_ptr->lev + 1;
491 if (is_hero(creature_ptr))
493 if (is_shero(creature_ptr))
495 if (creature_ptr->tsuyoshi)
497 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
499 if (hex_spelling(creature_ptr, HEX_BUILDING))
501 if (creature_ptr->mhp == mhp)
504 if (creature_ptr->chp >= mhp) {
505 creature_ptr->chp = mhp;
506 creature_ptr->chp_frac = 0;
510 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
511 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
514 creature_ptr->mhp = mhp;
516 creature_ptr->redraw |= PR_HP;
517 creature_ptr->window_flags |= PW_PLAYER;
521 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
522 * Calculate number of spells player should have, and forget,
523 * or remember, spells until that number is properly reflected.
525 * Note that this function induces various "status" messages,
526 * which must be bypasses until the character is created.
528 static void update_num_of_spells(player_type *creature_ptr)
530 if (!mp_ptr->spell_book)
532 if (!current_world_ptr->character_generated)
534 if (current_world_ptr->character_xtra)
536 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
537 creature_ptr->new_spells = 0;
541 concptr p = spell_category_name(mp_ptr->spell_book);
542 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
546 int num_allowed = (adj_mag_study[creature_ptr->stat_index[mp_ptr->spell_stat]] * levels / 2);
548 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
552 if (creature_ptr->pclass == CLASS_SAMURAI) {
554 } else if (creature_ptr->realm2 == REALM_NONE) {
555 num_allowed = (num_allowed + 1) / 2;
556 if (num_allowed > (32 + bonus))
557 num_allowed = 32 + bonus;
558 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
559 if (num_allowed > (96 + bonus))
560 num_allowed = 96 + bonus;
562 if (num_allowed > (80 + bonus))
563 num_allowed = 80 + bonus;
566 int num_boukyaku = 0;
567 for (int j = 0; j < 64; j++) {
568 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
573 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
574 for (int i = 63; i >= 0; i--) {
575 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
578 int j = creature_ptr->spell_order[i];
582 const magic_type *s_ptr;
583 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
585 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
587 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
589 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
591 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
593 if (s_ptr->slevel <= creature_ptr->lev)
596 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
597 if (!is_spell_learned)
602 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
603 which = creature_ptr->realm1;
605 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
606 which = creature_ptr->realm2;
610 reset_bits(creature_ptr->spell_learned1, (1UL << j));
611 which = creature_ptr->realm1;
613 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
614 which = creature_ptr->realm2;
618 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
620 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
622 creature_ptr->new_spells++;
625 /* Forget spells if we know too many spells */
626 for (int i = 63; i >= 0; i--) {
627 if (creature_ptr->new_spells >= 0)
629 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
632 int j = creature_ptr->spell_order[i];
636 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
637 if (!is_spell_learned)
642 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
643 which = creature_ptr->realm1;
645 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
646 which = creature_ptr->realm2;
650 reset_bits(creature_ptr->spell_learned1, (1UL << j));
651 which = creature_ptr->realm1;
653 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
654 which = creature_ptr->realm2;
658 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
660 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
662 creature_ptr->new_spells++;
665 /* Check for spells to remember */
666 for (int i = 0; i < 64; i++) {
667 if (creature_ptr->new_spells <= 0)
669 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
671 int j = creature_ptr->spell_order[i];
675 const magic_type *s_ptr;
676 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
678 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
680 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
682 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
684 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
686 if (s_ptr->slevel > creature_ptr->lev)
689 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
690 if (!is_spell_learned)
695 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
696 which = creature_ptr->realm1;
698 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
699 which = creature_ptr->realm2;
703 set_bits(creature_ptr->spell_learned1, (1UL << j));
704 which = creature_ptr->realm1;
706 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
707 which = creature_ptr->realm2;
711 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
713 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
715 creature_ptr->new_spells--;
718 if (creature_ptr->realm2 == REALM_NONE) {
720 for (int j = 0; j < 32; j++) {
721 const magic_type *s_ptr;
722 if (!is_magic(creature_ptr->realm1))
723 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
725 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
727 if (s_ptr->slevel > creature_ptr->lev)
730 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
739 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
740 creature_ptr->new_spells = (s16b)k;
744 if (creature_ptr->new_spells < 0)
745 creature_ptr->new_spells = 0;
747 if (creature_ptr->old_spells == creature_ptr->new_spells)
750 if (creature_ptr->new_spells) {
752 if (creature_ptr->new_spells < 10) {
753 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
755 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
758 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
762 creature_ptr->old_spells = creature_ptr->new_spells;
763 set_bits(creature_ptr->redraw, PR_STUDY);
764 set_bits(creature_ptr->window_flags, PW_OBJECT);
768 * @brief プレイヤーの最大MPを更新する /
769 * Update maximum mana. You do not need to know any spells.
770 * Note that mana is lowered by heavy (or inappropriate) armor.
772 * This function induces status messages.
774 static void update_max_mana(player_type *creature_ptr)
776 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
780 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)
781 || creature_ptr->pclass == CLASS_ELEMENTALIST) {
782 levels = creature_ptr->lev;
784 if (mp_ptr->spell_first > creature_ptr->lev) {
785 creature_ptr->msp = 0;
786 set_bits(creature_ptr->redraw, PR_MANA);
790 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
794 if (creature_ptr->pclass == CLASS_SAMURAI) {
795 msp = (adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] + 10) * 2;
797 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
799 msp = adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] * (levels + 3) / 4;
803 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
804 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
806 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
808 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
809 msp += msp * (25 + creature_ptr->lev) / 100;
812 if (any_bits(mp_ptr->spell_xtra, extra_magic_glove_reduce_mana)) {
813 BIT_FLAGS flgs[TR_FLAG_SIZE];
814 creature_ptr->cumber_glove = false;
816 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
817 object_flags(creature_ptr, o_ptr, flgs);
818 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
819 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
820 creature_ptr->cumber_glove = true;
825 creature_ptr->cumber_armor = false;
828 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
829 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
830 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
831 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
832 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
833 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
834 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
835 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
836 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
838 switch (creature_ptr->pclass) {
840 case CLASS_HIGH_MAGE:
841 case CLASS_BLUE_MAGE:
843 case CLASS_FORCETRAINER:
845 case CLASS_ELEMENTALIST: {
846 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
847 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
848 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
849 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
854 case CLASS_TOURIST: {
855 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
856 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
857 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
858 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
861 case CLASS_MINDCRAFTER:
862 case CLASS_BEASTMASTER:
863 case CLASS_MIRROR_MASTER: {
864 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
865 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
866 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
867 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
873 case CLASS_WARRIOR_MAGE: {
874 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
875 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
876 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
877 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
881 case CLASS_CHAOS_WARRIOR: {
882 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
883 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
884 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
885 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
893 int max_wgt = mp_ptr->spell_weight;
894 if ((cur_wgt - max_wgt) > 0) {
895 creature_ptr->cumber_armor = true;
896 switch (creature_ptr->pclass) {
898 case CLASS_HIGH_MAGE:
899 case CLASS_BLUE_MAGE:
900 case CLASS_ELEMENTALIST: {
901 msp -= msp * (cur_wgt - max_wgt) / 600;
905 case CLASS_MINDCRAFTER:
906 case CLASS_BEASTMASTER:
908 case CLASS_FORCETRAINER:
910 case CLASS_MIRROR_MASTER: {
911 msp -= msp * (cur_wgt - max_wgt) / 800;
914 case CLASS_SORCERER: {
915 msp -= msp * (cur_wgt - max_wgt) / 900;
921 case CLASS_RED_MAGE: {
922 msp -= msp * (cur_wgt - max_wgt) / 1000;
926 case CLASS_CHAOS_WARRIOR:
927 case CLASS_WARRIOR_MAGE: {
928 msp -= msp * (cur_wgt - max_wgt) / 1200;
931 case CLASS_SAMURAI: {
932 creature_ptr->cumber_armor = false;
936 msp -= msp * (cur_wgt - max_wgt) / 800;
945 if (creature_ptr->msp != msp) {
946 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
947 creature_ptr->csp = msp;
948 creature_ptr->csp_frac = 0;
952 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
953 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
956 creature_ptr->msp = msp;
957 set_bits(creature_ptr->redraw, PR_MANA);
958 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
961 if (current_world_ptr->character_xtra)
964 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
965 if (creature_ptr->cumber_glove)
966 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
968 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
970 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
973 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
976 if (creature_ptr->cumber_armor)
977 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
979 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
981 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
985 * @brief 装備中の射撃武器の威力倍率を返す /
986 * calcurate the fire rate of target object
987 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
988 * @return 射撃倍率の値(100で1.00倍)
990 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
993 BIT_FLAGS flgs[TR_FLAG_SIZE];
995 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
997 q_ptr = &creature_ptr->inventory_list[i];
1004 object_flags(creature_ptr, q_ptr, flgs);
1005 if (has_flag(flgs, TR_XTRA_SHOTS))
1009 object_flags(creature_ptr, o_ptr, flgs);
1010 if (has_flag(flgs, TR_XTRA_SHOTS))
1014 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1018 num += (extra_shots * 100);
1020 tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
1021 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1022 num += (creature_ptr->lev * 4);
1025 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1026 num += (creature_ptr->lev * 3);
1029 if (creature_ptr->pclass == CLASS_ARCHER) {
1030 if (tval_ammo == TV_ARROW)
1031 num += ((creature_ptr->lev * 5) + 50);
1032 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1033 num += (creature_ptr->lev * 4);
1036 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1037 num += (creature_ptr->lev * 2);
1040 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1041 num += (creature_ptr->lev * 4);
1049 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1053 * * 職業と性格とレベルによる追加加算
1054 * * 器用さに応じたadj_dex_disテーブルによる加算
1055 * * 知力に応じたadj_int_disテーブルによる加算
1057 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1059 ACTION_SKILL_POWER pow;
1060 const player_race *tmp_rp_ptr;
1062 if (creature_ptr->mimic_form)
1063 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1065 tmp_rp_ptr = &race_info[creature_ptr->prace];
1066 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1067 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1069 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1070 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1071 pow += adj_dex_dis[creature_ptr->stat_index[A_DEX]];
1072 pow += adj_int_dis[creature_ptr->stat_index[A_INT]];
1078 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1082 * * 職業と性格とレベルによる追加加算
1083 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1084 * * 知力に応じたadj_int_devテーブルによる加算
1087 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1089 ACTION_SKILL_POWER pow;
1090 const player_race *tmp_rp_ptr;
1092 if (creature_ptr->mimic_form)
1093 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1095 tmp_rp_ptr = &race_info[creature_ptr->prace];
1096 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1097 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1099 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1100 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1102 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1104 BIT_FLAGS flgs[TR_FLAG_SIZE];
1105 o_ptr = &creature_ptr->inventory_list[i];
1108 object_flags(creature_ptr, o_ptr, flgs);
1109 if (has_flag(flgs, TR_MAGIC_MASTERY))
1110 pow += 8 * o_ptr->pval;
1113 pow += adj_int_dev[creature_ptr->stat_index[A_INT]];
1115 if (is_shero(creature_ptr)) {
1123 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1127 * * 職業と性格とレベルによる追加加算
1128 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1129 * * 呪力耐性の装備による加算(30)
1130 * * 祝福された装備による加算(5 + レベル / 10)
1131 * * 賢さによるadj_wis_savテーブル加算
1133 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1134 * * クターのつぶれ状態なら(10に上書き)
1135 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1136 * * 呪いのdown_savingがかかっているなら半減
1138 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1140 ACTION_SKILL_POWER pow;
1141 const player_race *tmp_rp_ptr;
1143 if (creature_ptr->mimic_form)
1144 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1146 tmp_rp_ptr = &race_info[creature_ptr->prace];
1147 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1148 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1150 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1151 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1153 if (creature_ptr->muta.has(MUTA::MAGIC_RES))
1154 pow += (15 + (creature_ptr->lev / 5));
1156 if (has_resist_curse(creature_ptr))
1159 if (creature_ptr->bless_blade)
1160 pow += 6 + (creature_ptr->lev - 1) / 10;
1162 pow += adj_wis_sav[creature_ptr->stat_index[A_WIS]];
1164 if (is_shero(creature_ptr))
1167 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1168 pow = 90 + creature_ptr->lev;
1170 if (creature_ptr->tsubureru)
1173 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1174 pow = 95 + creature_ptr->lev;
1176 if (creature_ptr->down_saving)
1184 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1189 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1191 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1193 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1195 ACTION_SKILL_POWER pow;
1196 const player_race *tmp_rp_ptr;
1198 if (creature_ptr->mimic_form)
1199 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1201 tmp_rp_ptr = &race_info[creature_ptr->prace];
1202 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1203 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1205 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1206 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1208 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1210 BIT_FLAGS flgs[TR_FLAG_SIZE];
1211 o_ptr = &creature_ptr->inventory_list[i];
1214 object_flags(creature_ptr, o_ptr, flgs);
1215 if (has_flag(flgs, TR_SEARCH))
1216 pow += (o_ptr->pval * 5);
1219 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1223 if (is_shero(creature_ptr)) {
1232 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1237 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1239 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1241 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1243 ACTION_SKILL_POWER pow;
1244 const player_race *tmp_rp_ptr;
1246 if (creature_ptr->mimic_form)
1247 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1249 tmp_rp_ptr = &race_info[creature_ptr->prace];
1250 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1251 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1253 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1254 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1256 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1258 BIT_FLAGS flgs[TR_FLAG_SIZE];
1259 o_ptr = &creature_ptr->inventory_list[i];
1262 object_flags(creature_ptr, o_ptr, flgs);
1263 if (has_flag(flgs, TR_SEARCH))
1264 pow += (o_ptr->pval * 5);
1267 if (is_shero(creature_ptr)) {
1271 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1280 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1283 * * 種族/職業/性格による加算とレベルによる追加加算
1285 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1287 ACTION_SKILL_POWER pow;
1288 const player_race *tmp_rp_ptr;
1289 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1290 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1292 if (creature_ptr->mimic_form)
1293 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1295 tmp_rp_ptr = &race_info[creature_ptr->prace];
1297 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1298 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1304 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1307 * * 種族/職業/性格による加算とレベルによる追加加算
1309 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1311 ACTION_SKILL_POWER pow;
1312 const player_race *tmp_rp_ptr;
1313 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1314 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1316 if (creature_ptr->mimic_form)
1317 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1319 tmp_rp_ptr = &race_info[creature_ptr->prace];
1321 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1322 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1328 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1331 * * 種族/職業/性格による加算とレベルによる追加加算
1334 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1336 ACTION_SKILL_POWER pow;
1337 const player_race *tmp_rp_ptr;
1338 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1339 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1341 if (creature_ptr->mimic_form)
1342 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1344 tmp_rp_ptr = &race_info[creature_ptr->prace];
1346 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1347 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1349 if (is_shero(creature_ptr)) {
1358 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1369 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1372 BIT_FLAGS flgs[TR_FLAG_SIZE];
1374 ACTION_SKILL_POWER pow;
1378 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1379 pow += creature_ptr->lev * 10;
1382 if (is_shero(creature_ptr))
1385 pow += adj_str_dig[creature_ptr->stat_index[A_STR]];
1387 if (creature_ptr->pclass == CLASS_BERSERKER)
1388 pow += (100 + creature_ptr->lev * 8);
1390 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1391 o_ptr = &creature_ptr->inventory_list[i];
1394 object_flags(creature_ptr, o_ptr, flgs);
1395 if (has_flag(flgs, TR_TUNNEL))
1396 pow += (o_ptr->pval * 20);
1399 for (int i = 0; i < 2; i++) {
1400 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1401 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1402 pow += (o_ptr->weight / 10);
1406 if (is_shero(creature_ptr)) {
1416 static bool is_martial_arts_mode(player_type *creature_ptr)
1418 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1419 && (any_bits(empty_hands(creature_ptr, true), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1422 static bool is_heavy_wield(player_type *creature_ptr, int i)
1424 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1426 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1429 static s16b calc_num_blow(player_type *creature_ptr, int i)
1432 BIT_FLAGS flgs[TR_FLAG_SIZE];
1435 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1436 object_flags(creature_ptr, o_ptr, flgs);
1437 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1438 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1439 int str_index, dex_index;
1440 int num = 0, wgt = 0, mul = 0, div = 0;
1442 num = class_info[creature_ptr->pclass].num;
1443 wgt = class_info[creature_ptr->pclass].wgt;
1444 mul = class_info[creature_ptr->pclass].mul;
1446 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1452 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1458 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1459 str_index = (adj_str_blow[creature_ptr->stat_index[A_STR]] * mul / div);
1461 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1463 if (creature_ptr->pclass == CLASS_NINJA)
1464 str_index = MAX(0, str_index - 1);
1468 dex_index = (adj_dex_blow[creature_ptr->stat_index[A_DEX]]);
1472 num_blow = blows_table[str_index][dex_index];
1474 num_blow = (s16b)num;
1476 num_blow += (s16b)creature_ptr->extra_blows[i];
1477 if (creature_ptr->pclass == CLASS_WARRIOR)
1478 num_blow += (creature_ptr->lev / 40);
1479 else if (creature_ptr->pclass == CLASS_BERSERKER)
1480 num_blow += (creature_ptr->lev / 23);
1481 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_index[A_DEX] >= 30))
1484 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1487 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1497 /* Different calculation for monks with empty hands */
1498 if (is_martial_arts_mode(creature_ptr)) {
1499 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_index[A_DEX]];
1502 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1528 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1531 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1533 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1537 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1541 num_blow += 1 + creature_ptr->extra_blows[0];
1544 if (has_not_ninja_weapon(creature_ptr, i)) {
1555 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1558 * * 性格なまけものなら加算(+10)
1560 * * 性格ちからじまんとがまんづよいなら加算(+1)
1561 * * 性格チャージマンなら加算(+5)
1562 * * 装備品にTRC::HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
1564 static s16b calc_to_magic_chance(player_type *creature_ptr)
1568 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
1570 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
1572 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
1574 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
1577 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1579 BIT_FLAGS flgs[TR_FLAG_SIZE];
1580 o_ptr = &creature_ptr->inventory_list[i];
1583 object_flags(creature_ptr, o_ptr, flgs);
1584 if (o_ptr->curse_flags.has(TRC::HARD_SPELL)) {
1585 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
1595 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
1597 ARMOUR_CLASS ac = 0;
1598 if (creature_ptr->yoiyami)
1601 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1603 o_ptr = &creature_ptr->inventory_list[i];
1609 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
1610 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1611 ac += creature_ptr->skill_exp[SKILL_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
1617 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
1619 ARMOUR_CLASS ac = 0;
1620 BIT_FLAGS flags[TR_FLAG_SIZE];
1621 if (creature_ptr->yoiyami)
1624 ac += ((int)(adj_dex_ta[creature_ptr->stat_index[A_DEX]]) - 128);
1626 if (creature_ptr->mimic_form) {
1627 switch (creature_ptr->mimic_form) {
1631 case MIMIC_DEMON_LORD:
1639 if (creature_ptr->pclass == CLASS_BERSERKER) {
1640 ac += 10 + creature_ptr->lev / 2;
1642 if (creature_ptr->pclass == CLASS_SORCERER) {
1646 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1648 o_ptr = &creature_ptr->inventory_list[i];
1649 object_flags(creature_ptr, o_ptr, flags);
1652 if (is_real_value || object_is_known(o_ptr))
1655 if (o_ptr->curse_flags.has(TRC::LOW_AC)) {
1656 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
1657 if (is_real_value || object_is_fully_known(o_ptr))
1660 if (is_real_value || object_is_fully_known(o_ptr))
1665 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
1670 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
1671 ac += 10 + (creature_ptr->lev * 2 / 5);
1674 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
1678 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1679 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1683 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
1687 if (creature_ptr->muta.has(MUTA::WART_SKIN)) {
1691 if (creature_ptr->muta.has(MUTA::SCALES)) {
1695 if (creature_ptr->muta.has(MUTA::IRON_SKIN)) {
1699 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
1700 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
1701 ac += (creature_ptr->lev * 3) / 2;
1703 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
1704 ac += ((creature_ptr->lev - 13) / 3);
1706 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
1707 ac += ((creature_ptr->lev - 8) / 3);
1709 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
1710 ac += (creature_ptr->lev - 2) / 3;
1712 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
1713 ac += (creature_ptr->lev / 2);
1715 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
1716 ac += (creature_ptr->lev / 3);
1720 if (creature_ptr->realm1 == REALM_HEX) {
1721 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
1725 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
1726 object_type *o_ptr = &creature_ptr->inventory_list[i];
1729 if (!object_is_armour(creature_ptr, o_ptr))
1731 if (!object_is_cursed(o_ptr))
1733 if (o_ptr->curse_flags.has(TRC::CURSED))
1735 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
1737 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE))
1742 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1743 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
1744 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1746 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
1748 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1752 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
1754 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
1758 if (is_blessed(creature_ptr)) {
1762 if (is_shero(creature_ptr)) {
1766 if (creature_ptr->pclass == CLASS_NINJA) {
1767 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1768 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1769 ac += creature_ptr->lev / 2 + 5;
1777 * @brief 二刀流ペナルティ量計算
1778 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1779 * @param slot ペナルティ量を計算する武器スロット
1784 * * EASY2_WEAPONによる軽減
1785 * * SUPPORTIVEを左に装備した場合の軽減
1789 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
1792 BIT_FLAGS flags[TR_FLAG_SIZE];
1794 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1795 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
1797 penalty = ((100 - creature_ptr->skill_exp[SKILL_TWO_WEAPON] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
1798 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
1799 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
1800 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
1801 penalty = penalty / 2 - 5;
1804 for (unsigned int i = FLAG_CAUSE_INVEN_MAIN_HAND; i < FLAG_CAUSE_MAX; i <<= 1)
1805 if (penalty > 0 && any_bits(creature_ptr->easy_2weapon, i))
1808 if (has_flag(flags, TR_SUPPORTIVE))
1809 penalty = MAX(0, penalty - 10);
1811 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1812 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1813 penalty = MIN(0, penalty);
1816 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
1819 return (s16b)penalty;
1822 static bool is_riding_two_hands(player_type *creature_ptr)
1824 if (!creature_ptr->riding) {
1828 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE))
1830 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
1831 switch (creature_ptr->pclass) {
1833 case CLASS_FORCETRAINER:
1834 case CLASS_BERSERKER:
1835 if ((empty_hands(creature_ptr, false) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
1836 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
1847 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
1849 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1850 if (!creature_ptr->riding)
1855 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
1856 if (creature_ptr->tval_ammo != TV_ARROW)
1859 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[SKILL_RIDING] / 80;
1865 if (creature_ptr->tval_ammo == TV_BOLT)
1871 void put_equipment_warning(player_type *creature_ptr)
1873 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
1874 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
1876 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
1877 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
1878 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
1880 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
1882 creature_ptr->old_heavy_shoot = heavy_shoot;
1885 for (int i = 0; i < 2; i++) {
1886 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
1887 if (creature_ptr->heavy_wield[i]) {
1888 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
1889 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1890 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
1891 } else if (creature_ptr->heavy_wield[1 - i]) {
1892 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
1894 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
1897 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
1900 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
1901 if (creature_ptr->riding_wield[i]) {
1902 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
1903 } else if (!creature_ptr->riding) {
1904 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
1905 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1906 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
1909 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
1912 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
1915 if (creature_ptr->icky_wield[i]) {
1916 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
1917 if (current_world_ptr->is_loading_now) {
1918 chg_virtue(creature_ptr, V_FAITH, -1);
1920 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1921 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
1923 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
1926 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
1929 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
1930 if (creature_ptr->riding_ryoute) {
1932 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
1934 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
1938 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE) ? "手が空いて" : "");
1940 msg_print("You began to control the pet you're riding with one hand.");
1944 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
1947 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
1948 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
1949 if (heavy_armor(creature_ptr)) {
1950 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
1951 if (current_world_ptr->is_loading_now) {
1952 chg_virtue(creature_ptr, V_HARMONY, -1);
1955 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
1958 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
1962 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
1964 object_type *o_ptr = &creature_ptr->inventory_list[slot];
1965 BIT_FLAGS flgs[TR_FLAG_SIZE];
1966 object_flags(creature_ptr, o_ptr, flgs);
1968 player_hand calc_hand = PLAYER_HAND_OTHER;
1969 if (slot == INVEN_MAIN_HAND)
1970 calc_hand = PLAYER_HAND_MAIN;
1971 if (slot == INVEN_SUB_HAND)
1972 calc_hand = PLAYER_HAND_SUB;
1975 damage += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
1977 if (is_shero(creature_ptr)) {
1978 damage += 3 + (creature_ptr->lev / 5);
1981 if (creature_ptr->stun > 50) {
1983 } else if (creature_ptr->stun) {
1987 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1989 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
1990 damage += creature_ptr->lev / 6;
1991 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
1992 damage += creature_ptr->lev / 6;
1994 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1995 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2000 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
2001 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
2002 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2003 damage += get_current_ki(creature_ptr) / 5;
2007 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2008 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2009 if (o_ptr->curse_flags.has(TRC::CURSED)) {
2012 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2015 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
2021 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2023 o_ptr = &creature_ptr->inventory_list[i];
2024 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2025 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2028 if (!object_is_known(o_ptr) && !is_real_value)
2030 bonus_to_d = o_ptr->to_d;
2032 if (creature_ptr->pclass == CLASS_NINJA) {
2033 if (o_ptr->to_d > 0)
2034 bonus_to_d = (o_ptr->to_d + 1) / 2;
2037 switch (player_melee_type(creature_ptr)) {
2038 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2039 case MELEE_TYPE_WEAPON_TWOHAND:
2040 if (calc_hand == main_attack_hand(creature_ptr))
2041 damage += (s16b)bonus_to_d;
2044 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2045 case MELEE_TYPE_WEAPON_MAIN:
2046 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2047 damage += (s16b)bonus_to_d;
2050 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2051 case MELEE_TYPE_WEAPON_SUB:
2052 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2053 damage += (s16b)bonus_to_d;
2056 case MELEE_TYPE_WEAPON_DOUBLE:
2057 if (calc_hand == PLAYER_HAND_MAIN) {
2058 if (i == INVEN_MAIN_RING) {
2059 damage += (s16b)bonus_to_d;
2060 } else if (i != INVEN_SUB_RING) {
2061 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2064 if (calc_hand == PLAYER_HAND_SUB) {
2065 if (i == INVEN_SUB_RING) {
2066 damage += (s16b)bonus_to_d;
2067 } else if (i != INVEN_MAIN_RING) {
2068 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2073 case MELEE_TYPE_SHIELD_DOUBLE:
2081 if (main_attack_hand(creature_ptr) == calc_hand) {
2082 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2083 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2085 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128) / 2;
2086 damage += MAX(bonus_to_d, 1);
2090 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2091 damage += (creature_ptr->lev / 6);
2094 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
2095 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2096 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2097 damage -= (creature_ptr->lev / 6);
2105 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
2107 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
2109 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2114 hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2115 hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2117 /* Temporary bonuses */
2118 if (is_blessed(creature_ptr)) {
2122 if (is_hero(creature_ptr)) {
2126 if (is_shero(creature_ptr)) {
2130 if (creature_ptr->stun > 50) {
2132 } else if (creature_ptr->stun) {
2136 player_hand calc_hand = PLAYER_HAND_OTHER;
2137 if (slot == INVEN_MAIN_HAND)
2138 calc_hand = PLAYER_HAND_MAIN;
2139 if (slot == INVEN_SUB_HAND)
2140 calc_hand = PLAYER_HAND_SUB;
2142 /* Default hand bonuses */
2143 if (main_attack_hand(creature_ptr) == calc_hand) {
2144 switch (player_melee_type(creature_ptr)) {
2145 case MELEE_TYPE_BAREHAND_MAIN:
2146 if (creature_ptr->riding)
2149 case MELEE_TYPE_BAREHAND_SUB:
2150 if (creature_ptr->riding)
2153 case MELEE_TYPE_BAREHAND_TWO:
2154 hit += (creature_ptr->skill_exp[SKILL_MARTIAL_ARTS] - WEAPON_EXP_BEGINNER) / 200;
2161 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2162 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2164 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);
2165 hit += MAX(bonus_to_h, 1);
2169 /* Bonuses and penalties by weapon */
2170 if (has_melee_weapon(creature_ptr, slot)) {
2171 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2172 BIT_FLAGS flgs[TR_FLAG_SIZE];
2173 object_flags(creature_ptr, o_ptr, flgs);
2175 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
2176 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
2178 /* Traind bonuses */
2179 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2181 /* Weight penalty */
2182 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
2183 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2186 /* Low melee penalty */
2187 if ((object_is_fully_known(o_ptr) || is_real_value) && o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
2188 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2195 /* Riding bonus and penalty */
2196 if (creature_ptr->riding) {
2197 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2202 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2203 && !has_flag(flgs, TR_RIDING)) {
2205 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2208 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[SKILL_RIDING] / 80;
2213 hit -= (s16b)penalty;
2216 /* Class penalties */
2217 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2219 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2220 hit += creature_ptr->lev / 5;
2221 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2222 hit += creature_ptr->lev / 5;
2224 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2225 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2232 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
2236 /* Hex realm bonuses */
2237 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2238 if (o_ptr->curse_flags.has(TRC::CURSED)) {
2241 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2244 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
2247 if (o_ptr->curse_flags.has(TRC::TY_CURSE)) {
2253 /* Bonuses from inventory */
2254 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2255 object_type *o_ptr = &creature_ptr->inventory_list[i];
2257 /* Ignore empty hands, handed weapons, bows and capture balls */
2258 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2259 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2262 /* Fake value does not include unknown objects' value */
2263 if (!object_is_known(o_ptr) && !is_real_value)
2266 int bonus_to_h = o_ptr->to_h;
2268 /* When wields only a weapon */
2269 if (creature_ptr->pclass == CLASS_NINJA) {
2270 if (o_ptr->to_h > 0)
2271 bonus_to_h = (o_ptr->to_h + 1) / 2;
2274 switch (player_melee_type(creature_ptr)) {
2275 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2276 case MELEE_TYPE_WEAPON_TWOHAND:
2277 if (calc_hand == main_attack_hand(creature_ptr))
2278 hit += (s16b)bonus_to_h;
2281 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2282 case MELEE_TYPE_WEAPON_MAIN:
2283 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2284 hit += (s16b)bonus_to_h;
2287 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2288 case MELEE_TYPE_WEAPON_SUB:
2289 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2290 hit += (s16b)bonus_to_h;
2293 case MELEE_TYPE_WEAPON_DOUBLE:
2294 if (calc_hand == PLAYER_HAND_MAIN) {
2295 if (i == INVEN_MAIN_RING) {
2296 hit += (s16b)bonus_to_h;
2297 } else if (i != INVEN_SUB_RING) {
2298 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2301 if (calc_hand == PLAYER_HAND_SUB) {
2302 if (i == INVEN_SUB_RING) {
2303 hit += (s16b)bonus_to_h;
2304 } else if (i != INVEN_MAIN_RING) {
2305 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2310 case MELEE_TYPE_SHIELD_DOUBLE:
2318 /* Martial arts bonus */
2319 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2320 hit += (creature_ptr->lev / 3);
2323 /* Two handed combat penalty */
2324 hit -= calc_double_weapon_penalty(creature_ptr, slot);
2326 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
2327 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2328 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2329 hit -= (creature_ptr->lev / 3);
2336 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
2340 pow += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2341 pow += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2345 BIT_FLAGS flgs[TR_FLAG_SIZE];
2346 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2348 object_flags(creature_ptr, o_ptr, flgs);
2350 if (o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
2351 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2360 if (creature_ptr->stun > 50) {
2362 } else if (creature_ptr->stun) {
2366 if (is_blessed(creature_ptr)) {
2370 if (is_hero(creature_ptr)) {
2374 if (is_shero(creature_ptr)) {
2378 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2380 if (is_heavy_shoot(creature_ptr, o_ptr)) {
2381 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2385 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
2386 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
2387 pow += (10 + (creature_ptr->lev / 5));
2393 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2395 o_ptr = &creature_ptr->inventory_list[i];
2396 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2397 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2400 bonus_to_h = o_ptr->to_h;
2402 if (creature_ptr->pclass == CLASS_NINJA) {
2403 if (o_ptr->to_h > 0)
2404 bonus_to_h = (o_ptr->to_h + 1) / 2;
2407 if (is_real_value || object_is_known(o_ptr))
2408 pow += (s16b)bonus_to_h;
2411 pow -= calc_riding_bow_penalty(creature_ptr);
2416 static s16b calc_to_damage_misc(player_type *creature_ptr)
2419 BIT_FLAGS flgs[TR_FLAG_SIZE];
2423 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2424 o_ptr = &creature_ptr->inventory_list[i];
2428 object_flags(creature_ptr, o_ptr, flgs);
2430 int bonus_to_d = o_ptr->to_d;
2431 if (creature_ptr->pclass == CLASS_NINJA) {
2432 if (o_ptr->to_d > 0)
2433 bonus_to_d = (o_ptr->to_d + 1) / 2;
2435 to_dam += (s16b)bonus_to_d;
2438 if (is_shero(creature_ptr)) {
2439 to_dam += 3 + (creature_ptr->lev / 5);
2442 if (creature_ptr->stun > 50) {
2444 } else if (creature_ptr->stun) {
2448 to_dam += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2452 static s16b calc_to_hit_misc(player_type *creature_ptr)
2455 BIT_FLAGS flgs[TR_FLAG_SIZE];
2459 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2460 o_ptr = &creature_ptr->inventory_list[i];
2464 object_flags(creature_ptr, o_ptr, flgs);
2466 int bonus_to_h = o_ptr->to_h;
2467 if (creature_ptr->pclass == CLASS_NINJA) {
2468 if (o_ptr->to_h > 0)
2469 bonus_to_h = (o_ptr->to_h + 1) / 2;
2471 to_hit += (s16b)bonus_to_h;
2474 if (is_blessed(creature_ptr)) {
2478 if (is_hero(creature_ptr)) {
2482 if (is_shero(creature_ptr)) {
2486 if (creature_ptr->stun > 50) {
2488 } else if (creature_ptr->stun) {
2492 to_hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2493 to_hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2498 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
2500 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2503 if (creature_ptr->riding) {
2504 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2513 * @brief プレイヤーの所持重量制限を計算する /
2514 * Computes current weight limit.
2517 WEIGHT calc_weight_limit(player_type *creature_ptr)
2519 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_index[A_STR]] * 50;
2520 if (creature_ptr->pclass == CLASS_BERSERKER)
2526 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
2527 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
2529 void update_creature(player_type *creature_ptr)
2531 if (!creature_ptr->update)
2534 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2535 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
2536 reset_bits(creature_ptr->update, PU_AUTODESTROY);
2537 autopick_delayed_alter(creature_ptr);
2540 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
2541 reset_bits(creature_ptr->update, PU_COMBINE);
2542 combine_pack(creature_ptr);
2545 if (any_bits(creature_ptr->update, (PU_REORDER))) {
2546 reset_bits(creature_ptr->update, PU_REORDER);
2547 reorder_pack(creature_ptr);
2550 if (any_bits(creature_ptr->update, (PU_BONUS))) {
2551 reset_bits(creature_ptr->update, PU_BONUS);
2552 PlayerAlignment(creature_ptr).update_alignment();
2553 update_bonuses(creature_ptr);
2556 if (any_bits(creature_ptr->update, (PU_TORCH))) {
2557 reset_bits(creature_ptr->update, PU_TORCH);
2558 update_lite_radius(creature_ptr);
2561 if (any_bits(creature_ptr->update, (PU_HP))) {
2562 reset_bits(creature_ptr->update, PU_HP);
2563 update_max_hitpoints(creature_ptr);
2566 if (any_bits(creature_ptr->update, (PU_MANA))) {
2567 reset_bits(creature_ptr->update, PU_MANA);
2568 update_max_mana(creature_ptr);
2571 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
2572 reset_bits(creature_ptr->update, PU_SPELLS);
2573 update_num_of_spells(creature_ptr);
2576 if (!current_world_ptr->character_generated)
2578 if (current_world_ptr->character_icky_depth > 0)
2580 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
2581 reset_bits(creature_ptr->update, PU_UN_LITE);
2582 forget_lite(floor_ptr);
2585 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
2586 reset_bits(creature_ptr->update, PU_UN_VIEW);
2587 forget_view(floor_ptr);
2590 if (any_bits(creature_ptr->update, (PU_VIEW))) {
2591 reset_bits(creature_ptr->update, PU_VIEW);
2592 update_view(creature_ptr);
2595 if (any_bits(creature_ptr->update, (PU_LITE))) {
2596 reset_bits(creature_ptr->update, PU_LITE);
2597 update_lite(creature_ptr);
2600 if (any_bits(creature_ptr->update, (PU_FLOW))) {
2601 reset_bits(creature_ptr->update, PU_FLOW);
2602 update_flow(creature_ptr);
2605 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
2606 reset_bits(creature_ptr->update, PU_DISTANCE);
2608 update_monsters(creature_ptr, true);
2611 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
2612 reset_bits(creature_ptr->update, PU_MON_LITE);
2613 update_mon_lite(creature_ptr);
2616 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
2617 reset_bits(creature_ptr->update, PU_DELAY_VIS);
2618 delayed_visual_update(creature_ptr);
2621 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
2622 reset_bits(creature_ptr->update, PU_MONSTERS);
2623 update_monsters(creature_ptr, false);
2628 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
2629 * @return 魔道書を一冊も持っていないならTRUEを返す
2631 bool player_has_no_spellbooks(player_type *creature_ptr)
2634 for (int i = 0; i < INVEN_PACK; i++) {
2635 o_ptr = &creature_ptr->inventory_list[i];
2636 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2640 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2641 for (const auto this_o_idx : floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx_list) {
2642 o_ptr = &floor_ptr->o_list[this_o_idx];
2643 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2651 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
2654 * @return 配置に成功したらTRUE
2656 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
2658 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
2661 /* Save player location */
2662 creature_ptr->y = y;
2663 creature_ptr->x = x;
2668 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
2670 void wreck_the_pattern(player_type *creature_ptr)
2672 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2673 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
2674 if (pattern_type == PATTERN_TILE_WRECKED)
2677 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
2678 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
2680 if (!is_invuln(creature_ptr))
2681 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"));
2683 int to_ruin = randint1(45) + 35;
2686 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
2688 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
2689 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
2693 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
2697 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
2698 * Advance experience levels and print experience
2700 void check_experience(player_type *creature_ptr)
2702 if (creature_ptr->exp < 0)
2703 creature_ptr->exp = 0;
2704 if (creature_ptr->max_exp < 0)
2705 creature_ptr->max_exp = 0;
2706 if (creature_ptr->max_max_exp < 0)
2707 creature_ptr->max_max_exp = 0;
2709 if (creature_ptr->exp > PY_MAX_EXP)
2710 creature_ptr->exp = PY_MAX_EXP;
2711 if (creature_ptr->max_exp > PY_MAX_EXP)
2712 creature_ptr->max_exp = PY_MAX_EXP;
2713 if (creature_ptr->max_max_exp > PY_MAX_EXP)
2714 creature_ptr->max_max_exp = PY_MAX_EXP;
2716 if (creature_ptr->exp > creature_ptr->max_exp)
2717 creature_ptr->max_exp = creature_ptr->exp;
2718 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
2719 creature_ptr->max_max_exp = creature_ptr->max_exp;
2721 set_bits(creature_ptr->redraw, PR_EXP);
2722 handle_stuff(creature_ptr);
2724 bool android = (creature_ptr->prace == RACE_ANDROID ? true : false);
2725 PLAYER_LEVEL old_lev = creature_ptr->lev;
2726 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
2727 creature_ptr->lev--;
2728 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2729 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
2730 set_bits(creature_ptr->window_flags, PW_PLAYER);
2731 handle_stuff(creature_ptr);
2734 bool level_reward = false;
2735 bool level_mutation = false;
2736 bool level_inc_stat = false;
2737 while ((creature_ptr->lev < PY_MAX_LEVEL)
2738 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
2739 creature_ptr->lev++;
2740 if (creature_ptr->lev > creature_ptr->max_plv) {
2741 creature_ptr->max_plv = creature_ptr->lev;
2743 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || creature_ptr->muta.has(MUTA::CHAOS_GIFT)) {
2744 level_reward = true;
2746 if (creature_ptr->prace == RACE_BEASTMAN) {
2748 level_mutation = true;
2750 level_inc_stat = true;
2752 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
2756 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
2757 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
2758 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
2759 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
2760 creature_ptr->level_up_message = true;
2761 handle_stuff(creature_ptr);
2763 creature_ptr->level_up_message = false;
2764 if (level_inc_stat) {
2765 if (!(creature_ptr->max_plv % 10)) {
2772 cnv_stat(creature_ptr->stat_max[0], tmp);
2773 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
2774 cnv_stat(creature_ptr->stat_max[1], tmp);
2775 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
2776 cnv_stat(creature_ptr->stat_max[2], tmp);
2777 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
2778 cnv_stat(creature_ptr->stat_max[3], tmp);
2779 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
2780 cnv_stat(creature_ptr->stat_max[4], tmp);
2781 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
2782 cnv_stat(creature_ptr->stat_max[5], tmp);
2783 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
2786 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
2790 if ((choice >= 'a') && (choice <= 'f'))
2793 for (n = 0; n < A_MAX; n++)
2794 if (n != choice - 'a')
2796 if (get_check(_("よろしいですか?", "Are you sure? ")))
2799 do_inc_stat(creature_ptr, choice - 'a');
2801 } else if (!(creature_ptr->max_plv % 2))
2802 do_inc_stat(creature_ptr, randint0(6));
2805 if (level_mutation) {
2806 msg_print(_("あなたは変わった気がする...", "You feel different..."));
2807 (void)gain_mutation(creature_ptr, 0);
2808 level_mutation = false;
2812 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
2816 gain_level_reward(creature_ptr, 0);
2817 level_reward = false;
2820 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2821 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
2822 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
2823 handle_stuff(creature_ptr);
2826 if (old_lev != creature_ptr->lev)
2827 autopick_load_pref(creature_ptr, false);
2831 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
2833 * @param out_val 出力先文字列ポインタ
2835 void cnv_stat(int val, char *out_val)
2838 sprintf(out_val, " %2d", val);
2842 int bonus = (val - 18);
2844 sprintf(out_val, "18/%3s", "***");
2845 } else if (bonus >= 100) {
2846 sprintf(out_val, "18/%03d", bonus);
2848 sprintf(out_val, " 18/%02d", bonus);
2853 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
2854 * Modify a stat value by a "modifier", return new value
2856 * @param amount 加減算値
2860 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
2861 * Or even: 18/13, 18/23, 18/33, ..., 18/220
2862 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
2863 * Or even: 18/13, 18/03, 18, 17, ..., 3
2866 s16b modify_stat_value(int value, int amount)
2869 for (int i = 0; i < amount; i++) {
2875 } else if (amount < 0) {
2876 for (int i = 0; i < (0 - amount); i++) {
2877 if (value >= 18 + 10)
2879 else if (value > 18)
2891 * Hack -- Calculates the total number of points earned -JWT-
2894 long calc_score(player_type *creature_ptr)
2896 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
2909 if (ironman_small_levels)
2911 if (ironman_empty_levels)
2917 if (ironman_nightmare)
2924 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
2925 if (max_dlv[i] > max_dl)
2926 max_dl = max_dlv[i];
2928 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
2929 u32b point_h = point_l / 0x10000L;
2930 point_l = point_l % 0x10000L;
2933 point_h += point_l / 0x10000L;
2934 point_l %= 0x10000L;
2936 point_l += ((point_h % 100) << 16);
2940 u32b point = (point_h << 16) + (point_l);
2941 if (creature_ptr->arena_number >= 0)
2942 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
2944 if (ironman_downward)
2946 if (creature_ptr->pclass == CLASS_BERSERKER) {
2947 if (creature_ptr->prace == RACE_SPECTRE)
2951 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
2953 if (current_world_ptr->total_winner)
2958 point = (0 - point);
2964 * @param creature_ptr プレーヤーへの参照ポインタ
2965 * @return 祝福状態ならばTRUE
2967 bool is_blessed(player_type *creature_ptr)
2969 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
2972 bool is_tim_esp(player_type *creature_ptr)
2974 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
2977 bool is_tim_stealth(player_type *creature_ptr)
2979 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
2982 bool is_time_limit_esp(player_type *creature_ptr)
2984 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
2987 bool is_time_limit_stealth(player_type *creature_ptr)
2989 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
2993 * @brief 口を使う継続的な処理を中断する
2994 * @param caster_ptr プレーヤーへの参照ポインタ
2996 void stop_mouth(player_type *caster_ptr)
2998 if (music_singing_any(caster_ptr))
2999 stop_singing(caster_ptr);
3000 if (hex_spelling_any(caster_ptr))
3001 stop_hex_spell_all(caster_ptr);
3004 bool is_fast(player_type *creature_ptr)
3006 return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO);
3009 bool is_invuln(player_type *creature_ptr)
3011 return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN);
3014 bool is_hero(player_type *creature_ptr)
3016 return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO);
3019 bool is_shero(player_type *creature_ptr)
3021 return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER;
3024 bool is_echizen(player_type *creature_ptr)
3026 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
3029 int calc_weapon_weight_limit(player_type *creature_ptr)
3031 int weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3033 if (has_two_handed_weapons(creature_ptr))
3039 static player_hand main_attack_hand(player_type *creature_ptr)
3041 switch (player_melee_type(creature_ptr)) {
3042 case MELEE_TYPE_BAREHAND_TWO:
3043 return PLAYER_HAND_MAIN;
3044 case MELEE_TYPE_BAREHAND_MAIN:
3045 return PLAYER_HAND_MAIN;
3046 case MELEE_TYPE_BAREHAND_SUB:
3047 return PLAYER_HAND_SUB;
3048 case MELEE_TYPE_WEAPON_MAIN:
3049 return PLAYER_HAND_MAIN;
3050 case MELEE_TYPE_WEAPON_SUB:
3051 return PLAYER_HAND_SUB;
3052 case MELEE_TYPE_WEAPON_TWOHAND:
3053 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
3054 case MELEE_TYPE_WEAPON_DOUBLE:
3055 return PLAYER_HAND_MAIN;
3056 case MELEE_TYPE_SHIELD_DOUBLE:
3057 return PLAYER_HAND_MAIN;
3059 return PLAYER_HAND_MAIN;