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 return (calc_bow_weight_limit(creature_ptr) < o_ptr->weight / 10);
245 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
248 WEIGHT calc_inventory_weight(player_type *creature_ptr)
253 for (int i = 0; i < INVEN_TOTAL; i++) {
254 o_ptr = &creature_ptr->inventory_list[i];
257 weight += o_ptr->weight * o_ptr->number;
262 * @brief プレイヤーの全ステータスを更新する /
263 * Calculate the players current "state", taking into account
264 * not only race/class intrinsics, but also objects being worn
265 * and temporary spell effects.
268 * See also update_max_mana() and update_max_hitpoints().
270 * Take note of the new "speed code", in particular, a very strong
271 * player will start slowing down as soon as he reaches 150 pounds,
272 * but not until he reaches 450 pounds will he be half as fast as
273 * a normal kobold. This both hurts and helps the player, hurts
274 * because in the old days a player could just avoid 300 pounds,
275 * and helps because now carrying 300 pounds is not very painful.
277 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
278 * damage, since that would affect non-combat things. These values
279 * are actually added in later, at the appropriate place.
281 * This function induces various "status" messages.
283 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
285 static void update_bonuses(player_type *creature_ptr)
287 int empty_hands_status = empty_hands(creature_ptr, true);
290 /* Save the old vision stuff */
291 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
292 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
293 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
294 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
295 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
296 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
297 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
298 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
299 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
300 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
301 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
302 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
303 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
304 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
305 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
306 s16b old_speed = creature_ptr->pspeed;
308 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
309 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
311 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
312 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
313 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
314 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
315 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
316 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
317 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
318 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
319 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
320 creature_ptr->esp_human = has_esp_human(creature_ptr);
321 creature_ptr->esp_good = has_esp_good(creature_ptr);
322 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
323 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
324 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
325 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
326 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
327 creature_ptr->down_saving = has_down_saving(creature_ptr);
328 creature_ptr->yoiyami = has_no_ac(creature_ptr);
329 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
330 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
331 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
332 creature_ptr->warning = has_warning(creature_ptr);
333 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
334 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
335 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
336 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
337 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
338 creature_ptr->see_inv = has_see_inv(creature_ptr);
339 creature_ptr->free_act = has_free_act(creature_ptr);
340 creature_ptr->levitation = has_levitation(creature_ptr);
341 creature_ptr->can_swim = has_can_swim(creature_ptr);
342 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
343 creature_ptr->regenerate = has_regenerate(creature_ptr);
344 update_curses(creature_ptr);
345 creature_ptr->impact = has_impact(creature_ptr);
346 creature_ptr->earthquake = has_earthquake(creature_ptr);
347 update_extra_blows(creature_ptr);
349 creature_ptr->lite = has_lite(creature_ptr);
351 if (any_bits(creature_ptr->special_defense, KAMAE_MASK)) {
352 if (none_bits(empty_hands_status, EMPTY_HAND_MAIN)) {
353 set_action(creature_ptr, ACTION_NONE);
357 creature_ptr->stat_add[A_STR] = PlayerStrength(creature_ptr).modification_value();
358 creature_ptr->stat_add[A_INT] = PlayerIntelligence(creature_ptr).modification_value();
359 creature_ptr->stat_add[A_WIS] = PlayerWisdom(creature_ptr).modification_value();
360 creature_ptr->stat_add[A_DEX] = PlayerDexterity(creature_ptr).modification_value();
361 creature_ptr->stat_add[A_CON] = PlayerConstitution(creature_ptr).modification_value();
362 creature_ptr->stat_add[A_CHR] = PlayerCharisma(creature_ptr).modification_value();
364 PlayerStrength(creature_ptr).update_value();
365 PlayerIntelligence(creature_ptr).update_value();
366 PlayerWisdom(creature_ptr).update_value();
367 PlayerDexterity(creature_ptr).update_value();
368 PlayerConstitution(creature_ptr).update_value();
369 PlayerCharisma(creature_ptr).update_value();
371 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
373 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
374 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
375 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
379 for (int i = 0; i < 2; i++) {
380 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
381 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
382 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
383 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
384 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
385 creature_ptr->to_ds[i] = 0;
388 creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value();
389 creature_ptr->see_infra = PlayerInfravision(creature_ptr).get_value();
390 creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value();
391 creature_ptr->skill_dis = calc_disarming(creature_ptr);
392 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
393 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
394 creature_ptr->skill_srh = calc_search(creature_ptr);
395 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
396 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
397 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
398 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
399 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
400 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, true);
401 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, true);
402 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, false);
403 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, false);
404 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, true);
405 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, true);
406 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, false);
407 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, false);
408 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, true);
409 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, false);
410 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
411 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
412 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
413 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
414 creature_ptr->ac = calc_base_ac(creature_ptr);
415 creature_ptr->to_a = calc_to_ac(creature_ptr, true);
416 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
417 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, false);
419 if (old_mighty_throw != creature_ptr->mighty_throw) {
420 creature_ptr->window_flags |= PW_INVEN;
423 if (creature_ptr->telepathy != old_telepathy) {
424 set_bits(creature_ptr->update, PU_MONSTERS);
427 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
428 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
429 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
430 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
431 set_bits(creature_ptr->update, PU_MONSTERS);
434 if (creature_ptr->see_inv != old_see_inv) {
435 set_bits(creature_ptr->update, PU_MONSTERS);
438 if (creature_ptr->pspeed != old_speed) {
439 set_bits(creature_ptr->redraw, PR_SPEED);
442 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
443 set_bits(creature_ptr->redraw, PR_ARMOR);
444 set_bits(creature_ptr->window_flags, PW_PLAYER);
447 if (current_world_ptr->character_xtra)
450 put_equipment_warning(creature_ptr);
451 check_no_flowed(creature_ptr);
455 * @brief プレイヤーの最大HPを更新する /
456 * Update the players maximal hit points
457 * Adjust current hitpoints if necessary
460 static void update_max_hitpoints(player_type *creature_ptr)
462 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_index[A_CON]]) - 128) * creature_ptr->lev / 4;
463 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
466 if (creature_ptr->mimic_form) {
467 if (creature_ptr->pclass == CLASS_SORCERER)
468 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
470 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
471 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
474 if (creature_ptr->pclass == CLASS_SORCERER) {
475 if (creature_ptr->lev < 30)
476 mhp = (mhp * (45 + creature_ptr->lev) / 100);
478 mhp = (mhp * 75 / 100);
479 bonus = (bonus * 65 / 100);
484 if (creature_ptr->pclass == CLASS_BERSERKER) {
485 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
488 if (mhp < creature_ptr->lev + 1)
489 mhp = creature_ptr->lev + 1;
490 if (is_hero(creature_ptr))
492 if (is_shero(creature_ptr))
494 if (creature_ptr->tsuyoshi)
496 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
498 if (hex_spelling(creature_ptr, HEX_BUILDING))
500 if (creature_ptr->mhp == mhp)
503 if (creature_ptr->chp >= mhp) {
504 creature_ptr->chp = mhp;
505 creature_ptr->chp_frac = 0;
509 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
510 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
513 creature_ptr->mhp = mhp;
515 creature_ptr->redraw |= PR_HP;
516 creature_ptr->window_flags |= PW_PLAYER;
520 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
521 * Calculate number of spells player should have, and forget,
522 * or remember, spells until that number is properly reflected.
524 * Note that this function induces various "status" messages,
525 * which must be bypasses until the character is created.
527 static void update_num_of_spells(player_type *creature_ptr)
529 if (!mp_ptr->spell_book)
531 if (!current_world_ptr->character_generated)
533 if (current_world_ptr->character_xtra)
535 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
536 creature_ptr->new_spells = 0;
540 concptr p = spell_category_name(mp_ptr->spell_book);
541 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
545 int num_allowed = (adj_mag_study[creature_ptr->stat_index[mp_ptr->spell_stat]] * levels / 2);
547 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
551 if (creature_ptr->pclass == CLASS_SAMURAI) {
553 } else if (creature_ptr->realm2 == REALM_NONE) {
554 num_allowed = (num_allowed + 1) / 2;
555 if (num_allowed > (32 + bonus))
556 num_allowed = 32 + bonus;
557 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
558 if (num_allowed > (96 + bonus))
559 num_allowed = 96 + bonus;
561 if (num_allowed > (80 + bonus))
562 num_allowed = 80 + bonus;
565 int num_boukyaku = 0;
566 for (int j = 0; j < 64; j++) {
567 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
572 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
573 for (int i = 63; i >= 0; i--) {
574 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
577 int j = creature_ptr->spell_order[i];
581 const magic_type *s_ptr;
582 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
584 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
586 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
588 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
590 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
592 if (s_ptr->slevel <= creature_ptr->lev)
595 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
596 if (!is_spell_learned)
601 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
602 which = creature_ptr->realm1;
604 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
605 which = creature_ptr->realm2;
609 reset_bits(creature_ptr->spell_learned1, (1UL << j));
610 which = creature_ptr->realm1;
612 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
613 which = creature_ptr->realm2;
617 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
619 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
621 creature_ptr->new_spells++;
624 /* Forget spells if we know too many spells */
625 for (int i = 63; i >= 0; i--) {
626 if (creature_ptr->new_spells >= 0)
628 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
631 int j = creature_ptr->spell_order[i];
635 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
636 if (!is_spell_learned)
641 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
642 which = creature_ptr->realm1;
644 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
645 which = creature_ptr->realm2;
649 reset_bits(creature_ptr->spell_learned1, (1UL << j));
650 which = creature_ptr->realm1;
652 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
653 which = creature_ptr->realm2;
657 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
659 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
661 creature_ptr->new_spells++;
664 /* Check for spells to remember */
665 for (int i = 0; i < 64; i++) {
666 if (creature_ptr->new_spells <= 0)
668 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
670 int j = creature_ptr->spell_order[i];
674 const magic_type *s_ptr;
675 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
677 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
679 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
681 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
683 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
685 if (s_ptr->slevel > creature_ptr->lev)
688 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
689 if (!is_spell_learned)
694 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
695 which = creature_ptr->realm1;
697 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
698 which = creature_ptr->realm2;
702 set_bits(creature_ptr->spell_learned1, (1UL << j));
703 which = creature_ptr->realm1;
705 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
706 which = creature_ptr->realm2;
710 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
712 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
714 creature_ptr->new_spells--;
717 if (creature_ptr->realm2 == REALM_NONE) {
719 for (int j = 0; j < 32; j++) {
720 const magic_type *s_ptr;
721 if (!is_magic(creature_ptr->realm1))
722 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
724 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
726 if (s_ptr->slevel > creature_ptr->lev)
729 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
738 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
739 creature_ptr->new_spells = (s16b)k;
743 if (creature_ptr->new_spells < 0)
744 creature_ptr->new_spells = 0;
746 if (creature_ptr->old_spells == creature_ptr->new_spells)
749 if (creature_ptr->new_spells) {
751 if (creature_ptr->new_spells < 10) {
752 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
754 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
757 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
761 creature_ptr->old_spells = creature_ptr->new_spells;
762 set_bits(creature_ptr->redraw, PR_STUDY);
763 set_bits(creature_ptr->window_flags, PW_OBJECT);
767 * @brief プレイヤーの最大MPを更新する /
768 * Update maximum mana. You do not need to know any spells.
769 * Note that mana is lowered by heavy (or inappropriate) armor.
771 * This function induces status messages.
773 static void update_max_mana(player_type *creature_ptr)
775 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
779 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)
780 || creature_ptr->pclass == CLASS_ELEMENTALIST) {
781 levels = creature_ptr->lev;
783 if (mp_ptr->spell_first > creature_ptr->lev) {
784 creature_ptr->msp = 0;
785 set_bits(creature_ptr->redraw, PR_MANA);
789 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
793 if (creature_ptr->pclass == CLASS_SAMURAI) {
794 msp = (adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] + 10) * 2;
796 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
798 msp = adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] * (levels + 3) / 4;
802 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
803 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
805 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
807 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
808 msp += msp * (25 + creature_ptr->lev) / 100;
811 if (any_bits(mp_ptr->spell_xtra, extra_magic_glove_reduce_mana)) {
812 BIT_FLAGS flgs[TR_FLAG_SIZE];
813 creature_ptr->cumber_glove = false;
815 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
816 object_flags(creature_ptr, o_ptr, flgs);
817 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
818 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
819 creature_ptr->cumber_glove = true;
824 creature_ptr->cumber_armor = false;
827 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
828 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
829 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
830 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
831 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
832 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
833 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
834 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
835 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
837 switch (creature_ptr->pclass) {
839 case CLASS_HIGH_MAGE:
840 case CLASS_BLUE_MAGE:
842 case CLASS_FORCETRAINER:
844 case CLASS_ELEMENTALIST: {
845 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
846 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
847 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
848 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
853 case CLASS_TOURIST: {
854 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
855 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
856 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
857 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
860 case CLASS_MINDCRAFTER:
861 case CLASS_BEASTMASTER:
862 case CLASS_MIRROR_MASTER: {
863 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
864 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
865 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
866 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
872 case CLASS_WARRIOR_MAGE: {
873 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
874 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
875 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
876 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
880 case CLASS_CHAOS_WARRIOR: {
881 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
882 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
883 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
884 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
892 int max_wgt = mp_ptr->spell_weight;
893 if ((cur_wgt - max_wgt) > 0) {
894 creature_ptr->cumber_armor = true;
895 switch (creature_ptr->pclass) {
897 case CLASS_HIGH_MAGE:
898 case CLASS_BLUE_MAGE:
899 case CLASS_ELEMENTALIST: {
900 msp -= msp * (cur_wgt - max_wgt) / 600;
904 case CLASS_MINDCRAFTER:
905 case CLASS_BEASTMASTER:
907 case CLASS_FORCETRAINER:
909 case CLASS_MIRROR_MASTER: {
910 msp -= msp * (cur_wgt - max_wgt) / 800;
913 case CLASS_SORCERER: {
914 msp -= msp * (cur_wgt - max_wgt) / 900;
920 case CLASS_RED_MAGE: {
921 msp -= msp * (cur_wgt - max_wgt) / 1000;
925 case CLASS_CHAOS_WARRIOR:
926 case CLASS_WARRIOR_MAGE: {
927 msp -= msp * (cur_wgt - max_wgt) / 1200;
930 case CLASS_SAMURAI: {
931 creature_ptr->cumber_armor = false;
935 msp -= msp * (cur_wgt - max_wgt) / 800;
944 if (creature_ptr->msp != msp) {
945 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
946 creature_ptr->csp = msp;
947 creature_ptr->csp_frac = 0;
951 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
952 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
955 creature_ptr->msp = msp;
956 set_bits(creature_ptr->redraw, PR_MANA);
957 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
960 if (current_world_ptr->character_xtra)
963 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
964 if (creature_ptr->cumber_glove)
965 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
967 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
969 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
972 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
975 if (creature_ptr->cumber_armor)
976 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
978 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
980 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
984 * @brief 装備中の射撃武器の威力倍率を返す /
985 * calcurate the fire rate of target object
986 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
987 * @return 射撃倍率の値(100で1.00倍)
989 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
992 BIT_FLAGS flgs[TR_FLAG_SIZE];
994 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
996 q_ptr = &creature_ptr->inventory_list[i];
1003 object_flags(creature_ptr, q_ptr, flgs);
1004 if (has_flag(flgs, TR_XTRA_SHOTS))
1008 object_flags(creature_ptr, o_ptr, flgs);
1009 if (has_flag(flgs, TR_XTRA_SHOTS))
1013 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1017 num += (extra_shots * 100);
1019 tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
1020 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1021 num += (creature_ptr->lev * 4);
1024 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1025 num += (creature_ptr->lev * 3);
1028 if (creature_ptr->pclass == CLASS_ARCHER) {
1029 if (tval_ammo == TV_ARROW)
1030 num += ((creature_ptr->lev * 5) + 50);
1031 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1032 num += (creature_ptr->lev * 4);
1035 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1036 num += (creature_ptr->lev * 2);
1039 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1040 num += (creature_ptr->lev * 4);
1048 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1052 * * 職業と性格とレベルによる追加加算
1053 * * 器用さに応じたadj_dex_disテーブルによる加算
1054 * * 知力に応じたadj_int_disテーブルによる加算
1056 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1058 ACTION_SKILL_POWER pow;
1059 const player_race *tmp_rp_ptr;
1061 if (creature_ptr->mimic_form)
1062 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1064 tmp_rp_ptr = &race_info[creature_ptr->prace];
1065 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1066 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1068 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1069 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1070 pow += adj_dex_dis[creature_ptr->stat_index[A_DEX]];
1071 pow += adj_int_dis[creature_ptr->stat_index[A_INT]];
1077 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1081 * * 職業と性格とレベルによる追加加算
1082 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1083 * * 知力に応じたadj_int_devテーブルによる加算
1086 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1088 ACTION_SKILL_POWER pow;
1089 const player_race *tmp_rp_ptr;
1091 if (creature_ptr->mimic_form)
1092 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1094 tmp_rp_ptr = &race_info[creature_ptr->prace];
1095 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1096 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1098 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1099 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1101 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1103 BIT_FLAGS flgs[TR_FLAG_SIZE];
1104 o_ptr = &creature_ptr->inventory_list[i];
1107 object_flags(creature_ptr, o_ptr, flgs);
1108 if (has_flag(flgs, TR_MAGIC_MASTERY))
1109 pow += 8 * o_ptr->pval;
1112 pow += adj_int_dev[creature_ptr->stat_index[A_INT]];
1114 if (is_shero(creature_ptr)) {
1122 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1126 * * 職業と性格とレベルによる追加加算
1127 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1128 * * 呪力耐性の装備による加算(30)
1129 * * 祝福された装備による加算(5 + レベル / 10)
1130 * * 賢さによるadj_wis_savテーブル加算
1132 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1133 * * クターのつぶれ状態なら(10に上書き)
1134 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1135 * * 呪いのdown_savingがかかっているなら半減
1137 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1139 ACTION_SKILL_POWER pow;
1140 const player_race *tmp_rp_ptr;
1142 if (creature_ptr->mimic_form)
1143 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1145 tmp_rp_ptr = &race_info[creature_ptr->prace];
1146 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1147 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1149 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1150 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1152 if (creature_ptr->muta.has(MUTA::MAGIC_RES))
1153 pow += (15 + (creature_ptr->lev / 5));
1155 if (has_resist_curse(creature_ptr))
1158 if (creature_ptr->bless_blade)
1159 pow += 6 + (creature_ptr->lev - 1) / 10;
1161 pow += adj_wis_sav[creature_ptr->stat_index[A_WIS]];
1163 if (is_shero(creature_ptr))
1166 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1167 pow = 90 + creature_ptr->lev;
1169 if (creature_ptr->tsubureru)
1172 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1173 pow = 95 + creature_ptr->lev;
1175 if (creature_ptr->down_saving)
1183 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1188 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1190 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1192 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1194 ACTION_SKILL_POWER pow;
1195 const player_race *tmp_rp_ptr;
1197 if (creature_ptr->mimic_form)
1198 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1200 tmp_rp_ptr = &race_info[creature_ptr->prace];
1201 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1202 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1204 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1205 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1207 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1209 BIT_FLAGS flgs[TR_FLAG_SIZE];
1210 o_ptr = &creature_ptr->inventory_list[i];
1213 object_flags(creature_ptr, o_ptr, flgs);
1214 if (has_flag(flgs, TR_SEARCH))
1215 pow += (o_ptr->pval * 5);
1218 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1222 if (is_shero(creature_ptr)) {
1231 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1236 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1238 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1240 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1242 ACTION_SKILL_POWER pow;
1243 const player_race *tmp_rp_ptr;
1245 if (creature_ptr->mimic_form)
1246 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1248 tmp_rp_ptr = &race_info[creature_ptr->prace];
1249 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1250 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1252 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1253 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1255 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1257 BIT_FLAGS flgs[TR_FLAG_SIZE];
1258 o_ptr = &creature_ptr->inventory_list[i];
1261 object_flags(creature_ptr, o_ptr, flgs);
1262 if (has_flag(flgs, TR_SEARCH))
1263 pow += (o_ptr->pval * 5);
1266 if (is_shero(creature_ptr)) {
1270 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1279 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1282 * * 種族/職業/性格による加算とレベルによる追加加算
1284 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1286 ACTION_SKILL_POWER pow;
1287 const player_race *tmp_rp_ptr;
1288 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1289 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1291 if (creature_ptr->mimic_form)
1292 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1294 tmp_rp_ptr = &race_info[creature_ptr->prace];
1296 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1297 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1303 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1306 * * 種族/職業/性格による加算とレベルによる追加加算
1308 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1310 ACTION_SKILL_POWER pow;
1311 const player_race *tmp_rp_ptr;
1312 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1313 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1315 if (creature_ptr->mimic_form)
1316 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1318 tmp_rp_ptr = &race_info[creature_ptr->prace];
1320 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1321 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1327 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1330 * * 種族/職業/性格による加算とレベルによる追加加算
1333 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1335 ACTION_SKILL_POWER pow;
1336 const player_race *tmp_rp_ptr;
1337 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1338 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1340 if (creature_ptr->mimic_form)
1341 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1343 tmp_rp_ptr = &race_info[creature_ptr->prace];
1345 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1346 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1348 if (is_shero(creature_ptr)) {
1357 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1368 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1371 BIT_FLAGS flgs[TR_FLAG_SIZE];
1373 ACTION_SKILL_POWER pow;
1377 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1378 pow += creature_ptr->lev * 10;
1381 if (is_shero(creature_ptr))
1384 pow += adj_str_dig[creature_ptr->stat_index[A_STR]];
1386 if (creature_ptr->pclass == CLASS_BERSERKER)
1387 pow += (100 + creature_ptr->lev * 8);
1389 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1390 o_ptr = &creature_ptr->inventory_list[i];
1393 object_flags(creature_ptr, o_ptr, flgs);
1394 if (has_flag(flgs, TR_TUNNEL))
1395 pow += (o_ptr->pval * 20);
1398 for (int i = 0; i < 2; i++) {
1399 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1400 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1401 pow += (o_ptr->weight / 10);
1405 if (is_shero(creature_ptr)) {
1415 static bool is_martial_arts_mode(player_type *creature_ptr)
1417 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1418 && (any_bits(empty_hands(creature_ptr, true), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1421 static bool is_heavy_wield(player_type *creature_ptr, int i)
1423 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1425 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1428 static s16b calc_num_blow(player_type *creature_ptr, int i)
1431 BIT_FLAGS flgs[TR_FLAG_SIZE];
1434 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1435 object_flags(creature_ptr, o_ptr, flgs);
1436 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1437 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1438 int str_index, dex_index;
1439 int num = 0, wgt = 0, mul = 0, div = 0;
1441 num = class_info[creature_ptr->pclass].num;
1442 wgt = class_info[creature_ptr->pclass].wgt;
1443 mul = class_info[creature_ptr->pclass].mul;
1445 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1451 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1457 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1458 str_index = (adj_str_blow[creature_ptr->stat_index[A_STR]] * mul / div);
1460 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1461 str_index += (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) ? (creature_ptr->lev / 23 + 1) : 1;
1462 if (creature_ptr->pclass == CLASS_NINJA)
1463 str_index = MAX(0, str_index - 1);
1467 dex_index = (adj_dex_blow[creature_ptr->stat_index[A_DEX]]);
1471 num_blow = blows_table[str_index][dex_index];
1473 num_blow = (s16b)num;
1475 num_blow += (s16b)creature_ptr->extra_blows[i];
1476 if (creature_ptr->pclass == CLASS_WARRIOR)
1477 num_blow += (creature_ptr->lev / 40);
1478 else if (creature_ptr->pclass == CLASS_BERSERKER)
1479 num_blow += (creature_ptr->lev / 23);
1480 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_index[A_DEX] >= 30))
1483 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1486 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1496 /* Different calculation for monks with empty hands */
1497 if (is_martial_arts_mode(creature_ptr)) {
1498 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_index[A_DEX]];
1501 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1527 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1530 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1532 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1536 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1540 num_blow += 1 + creature_ptr->extra_blows[0];
1543 if (has_not_ninja_weapon(creature_ptr, i)) {
1554 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1557 * * 性格なまけものなら加算(+10)
1559 * * 性格ちからじまんとがまんづよいなら加算(+1)
1560 * * 性格チャージマンなら加算(+5)
1561 * * 装備品にTRC::HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
1563 static s16b calc_to_magic_chance(player_type *creature_ptr)
1567 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
1569 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
1571 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
1573 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
1576 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1578 BIT_FLAGS flgs[TR_FLAG_SIZE];
1579 o_ptr = &creature_ptr->inventory_list[i];
1582 object_flags(creature_ptr, o_ptr, flgs);
1583 if (o_ptr->curse_flags.has(TRC::HARD_SPELL)) {
1584 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
1594 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
1596 ARMOUR_CLASS ac = 0;
1597 if (creature_ptr->yoiyami)
1600 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1602 o_ptr = &creature_ptr->inventory_list[i];
1608 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
1609 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1610 ac += creature_ptr->skill_exp[SKILL_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
1616 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
1618 ARMOUR_CLASS ac = 0;
1619 BIT_FLAGS flags[TR_FLAG_SIZE];
1620 if (creature_ptr->yoiyami)
1623 ac += ((int)(adj_dex_ta[creature_ptr->stat_index[A_DEX]]) - 128);
1625 if (creature_ptr->mimic_form) {
1626 switch (creature_ptr->mimic_form) {
1630 case MIMIC_DEMON_LORD:
1638 if (creature_ptr->pclass == CLASS_BERSERKER) {
1639 ac += 10 + creature_ptr->lev / 2;
1641 if (creature_ptr->pclass == CLASS_SORCERER) {
1645 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1647 o_ptr = &creature_ptr->inventory_list[i];
1648 object_flags(creature_ptr, o_ptr, flags);
1651 if (is_real_value || object_is_known(o_ptr))
1654 if (o_ptr->curse_flags.has(TRC::LOW_AC)) {
1655 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
1656 if (is_real_value || object_is_fully_known(o_ptr))
1659 if (is_real_value || object_is_fully_known(o_ptr))
1664 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
1669 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
1670 ac += 10 + (creature_ptr->lev * 2 / 5);
1673 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
1677 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1678 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1682 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
1686 if (creature_ptr->muta.has(MUTA::WART_SKIN)) {
1690 if (creature_ptr->muta.has(MUTA::SCALES)) {
1694 if (creature_ptr->muta.has(MUTA::IRON_SKIN)) {
1698 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
1699 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
1700 ac += (creature_ptr->lev * 3) / 2;
1702 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
1703 ac += ((creature_ptr->lev - 13) / 3);
1705 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
1706 ac += ((creature_ptr->lev - 8) / 3);
1708 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
1709 ac += (creature_ptr->lev - 2) / 3;
1711 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
1712 ac += (creature_ptr->lev / 2);
1714 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
1715 ac += (creature_ptr->lev / 3);
1719 if (creature_ptr->realm1 == REALM_HEX) {
1720 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
1724 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
1725 object_type *o_ptr = &creature_ptr->inventory_list[i];
1728 if (!object_is_armour(creature_ptr, o_ptr))
1730 if (!object_is_cursed(o_ptr))
1732 if (o_ptr->curse_flags.has(TRC::CURSED))
1734 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
1736 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE))
1741 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1742 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
1743 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1745 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
1747 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1751 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
1753 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
1757 if (is_blessed(creature_ptr)) {
1761 if (is_shero(creature_ptr)) {
1765 if (creature_ptr->pclass == CLASS_NINJA) {
1766 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1767 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1768 ac += creature_ptr->lev / 2 + 5;
1776 * @brief 二刀流ペナルティ量計算
1777 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1778 * @param slot ペナルティ量を計算する武器スロット
1783 * * EASY2_WEAPONによる軽減
1784 * * SUPPORTIVEを左に装備した場合の軽減
1788 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
1791 BIT_FLAGS flags[TR_FLAG_SIZE];
1793 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1794 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
1796 penalty = ((100 - creature_ptr->skill_exp[SKILL_TWO_WEAPON] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
1797 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
1798 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
1799 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
1800 penalty = penalty / 2 - 5;
1803 for (unsigned int i = FLAG_CAUSE_INVEN_MAIN_HAND; i < FLAG_CAUSE_MAX; i <<= 1)
1804 if (penalty > 0 && any_bits(creature_ptr->easy_2weapon, i))
1807 if (has_flag(flags, TR_SUPPORTIVE))
1808 penalty = MAX(0, penalty - 10);
1810 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1811 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1812 penalty = MIN(0, penalty);
1815 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
1818 return (s16b)penalty;
1821 static bool is_riding_two_hands(player_type *creature_ptr)
1823 if (!creature_ptr->riding) {
1827 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE))
1829 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
1830 switch (creature_ptr->pclass) {
1832 case CLASS_FORCETRAINER:
1833 case CLASS_BERSERKER:
1834 if ((empty_hands(creature_ptr, false) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
1835 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
1846 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
1848 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1849 if (!creature_ptr->riding)
1854 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
1855 if (creature_ptr->tval_ammo != TV_ARROW)
1858 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[SKILL_RIDING] / 80;
1864 if (creature_ptr->tval_ammo == TV_BOLT)
1870 void put_equipment_warning(player_type *creature_ptr)
1872 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
1873 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
1875 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
1876 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
1877 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
1879 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
1881 creature_ptr->old_heavy_shoot = heavy_shoot;
1884 for (int i = 0; i < 2; i++) {
1885 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
1886 if (creature_ptr->heavy_wield[i]) {
1887 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
1888 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1889 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
1890 } else if (creature_ptr->heavy_wield[1 - i]) {
1891 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
1893 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
1896 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
1899 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
1900 if (creature_ptr->riding_wield[i]) {
1901 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
1902 } else if (!creature_ptr->riding) {
1903 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
1904 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1905 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
1908 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
1911 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
1914 if (creature_ptr->icky_wield[i]) {
1915 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
1916 if (current_world_ptr->is_loading_now) {
1917 chg_virtue(creature_ptr, V_FAITH, -1);
1919 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1920 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
1922 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
1925 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
1928 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
1929 if (creature_ptr->riding_ryoute) {
1931 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
1933 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
1937 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, false) == EMPTY_HAND_NONE) ? "手が空いて" : "");
1939 msg_print("You began to control the pet you're riding with one hand.");
1943 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
1946 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
1947 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
1948 if (heavy_armor(creature_ptr)) {
1949 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
1950 if (current_world_ptr->is_loading_now) {
1951 chg_virtue(creature_ptr, V_HARMONY, -1);
1954 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
1957 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
1961 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
1963 object_type *o_ptr = &creature_ptr->inventory_list[slot];
1964 BIT_FLAGS flgs[TR_FLAG_SIZE];
1965 object_flags(creature_ptr, o_ptr, flgs);
1967 player_hand calc_hand = PLAYER_HAND_OTHER;
1968 if (slot == INVEN_MAIN_HAND)
1969 calc_hand = PLAYER_HAND_MAIN;
1970 if (slot == INVEN_SUB_HAND)
1971 calc_hand = PLAYER_HAND_SUB;
1974 damage += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
1976 if (is_shero(creature_ptr)) {
1977 damage += 3 + (creature_ptr->lev / 5);
1980 if (creature_ptr->stun > 50) {
1982 } else if (creature_ptr->stun) {
1986 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
1988 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
1989 damage += creature_ptr->lev / 6;
1990 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
1991 damage += creature_ptr->lev / 6;
1993 } else if (creature_ptr->pclass == CLASS_SORCERER) {
1994 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
1999 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
2000 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
2001 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2002 damage += get_current_ki(creature_ptr) / 5;
2006 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2007 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2008 if (o_ptr->curse_flags.has(TRC::CURSED)) {
2011 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2014 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
2020 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2022 o_ptr = &creature_ptr->inventory_list[i];
2023 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2024 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2027 if (!object_is_known(o_ptr) && !is_real_value)
2029 bonus_to_d = o_ptr->to_d;
2031 if (creature_ptr->pclass == CLASS_NINJA) {
2032 if (o_ptr->to_d > 0)
2033 bonus_to_d = (o_ptr->to_d + 1) / 2;
2036 switch (player_melee_type(creature_ptr)) {
2037 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2038 case MELEE_TYPE_WEAPON_TWOHAND:
2039 if (calc_hand == main_attack_hand(creature_ptr))
2040 damage += (s16b)bonus_to_d;
2043 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2044 case MELEE_TYPE_WEAPON_MAIN:
2045 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2046 damage += (s16b)bonus_to_d;
2049 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2050 case MELEE_TYPE_WEAPON_SUB:
2051 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2052 damage += (s16b)bonus_to_d;
2055 case MELEE_TYPE_WEAPON_DOUBLE:
2056 if (calc_hand == PLAYER_HAND_MAIN) {
2057 if (i == INVEN_MAIN_RING) {
2058 damage += (s16b)bonus_to_d;
2059 } else if (i != INVEN_SUB_RING) {
2060 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2063 if (calc_hand == PLAYER_HAND_SUB) {
2064 if (i == INVEN_SUB_RING) {
2065 damage += (s16b)bonus_to_d;
2066 } else if (i != INVEN_MAIN_RING) {
2067 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2072 case MELEE_TYPE_SHIELD_DOUBLE:
2080 if (main_attack_hand(creature_ptr) == calc_hand) {
2081 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2082 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2084 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128) / 2;
2085 damage += MAX(bonus_to_d, 1);
2089 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2090 damage += (creature_ptr->lev / 6);
2093 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
2094 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2095 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2096 damage -= (creature_ptr->lev / 6);
2104 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
2106 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
2108 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2113 hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2114 hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2116 /* Temporary bonuses */
2117 if (is_blessed(creature_ptr)) {
2121 if (is_hero(creature_ptr)) {
2125 if (is_shero(creature_ptr)) {
2129 if (creature_ptr->stun > 50) {
2131 } else if (creature_ptr->stun) {
2135 player_hand calc_hand = PLAYER_HAND_OTHER;
2136 if (slot == INVEN_MAIN_HAND)
2137 calc_hand = PLAYER_HAND_MAIN;
2138 if (slot == INVEN_SUB_HAND)
2139 calc_hand = PLAYER_HAND_SUB;
2141 /* Default hand bonuses */
2142 if (main_attack_hand(creature_ptr) == calc_hand) {
2143 switch (player_melee_type(creature_ptr)) {
2144 case MELEE_TYPE_BAREHAND_MAIN:
2145 if (creature_ptr->riding)
2148 case MELEE_TYPE_BAREHAND_SUB:
2149 if (creature_ptr->riding)
2152 case MELEE_TYPE_BAREHAND_TWO:
2153 hit += (creature_ptr->skill_exp[SKILL_MARTIAL_ARTS] - WEAPON_EXP_BEGINNER) / 200;
2160 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, false) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2161 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2163 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);
2164 hit += MAX(bonus_to_h, 1);
2168 /* Bonuses and penalties by weapon */
2169 if (has_melee_weapon(creature_ptr, slot)) {
2170 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2171 BIT_FLAGS flgs[TR_FLAG_SIZE];
2172 object_flags(creature_ptr, o_ptr, flgs);
2174 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
2175 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
2177 /* Traind bonuses */
2178 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2180 /* Weight penalty */
2181 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
2182 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2185 /* Low melee penalty */
2186 if ((object_is_fully_known(o_ptr) || is_real_value) && o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
2187 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2194 /* Riding bonus and penalty */
2195 if (creature_ptr->riding) {
2196 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2201 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2202 && !has_flag(flgs, TR_RIDING)) {
2204 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2207 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[SKILL_RIDING] / 80;
2212 hit -= (s16b)penalty;
2215 /* Class penalties */
2216 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2218 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2219 hit += creature_ptr->lev / 5;
2220 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2221 hit += creature_ptr->lev / 5;
2223 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2224 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2231 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
2235 /* Hex realm bonuses */
2236 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2237 if (o_ptr->curse_flags.has(TRC::CURSED)) {
2240 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2243 if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
2246 if (o_ptr->curse_flags.has(TRC::TY_CURSE)) {
2252 /* Bonuses from inventory */
2253 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2254 object_type *o_ptr = &creature_ptr->inventory_list[i];
2256 /* Ignore empty hands, handed weapons, bows and capture balls */
2257 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2258 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2261 /* Fake value does not include unknown objects' value */
2262 if (!object_is_known(o_ptr) && !is_real_value)
2265 int bonus_to_h = o_ptr->to_h;
2267 /* When wields only a weapon */
2268 if (creature_ptr->pclass == CLASS_NINJA) {
2269 if (o_ptr->to_h > 0)
2270 bonus_to_h = (o_ptr->to_h + 1) / 2;
2273 switch (player_melee_type(creature_ptr)) {
2274 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2275 case MELEE_TYPE_WEAPON_TWOHAND:
2276 if (calc_hand == main_attack_hand(creature_ptr))
2277 hit += (s16b)bonus_to_h;
2280 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2281 case MELEE_TYPE_WEAPON_MAIN:
2282 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2283 hit += (s16b)bonus_to_h;
2286 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2287 case MELEE_TYPE_WEAPON_SUB:
2288 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2289 hit += (s16b)bonus_to_h;
2292 case MELEE_TYPE_WEAPON_DOUBLE:
2293 if (calc_hand == PLAYER_HAND_MAIN) {
2294 if (i == INVEN_MAIN_RING) {
2295 hit += (s16b)bonus_to_h;
2296 } else if (i != INVEN_SUB_RING) {
2297 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2300 if (calc_hand == PLAYER_HAND_SUB) {
2301 if (i == INVEN_SUB_RING) {
2302 hit += (s16b)bonus_to_h;
2303 } else if (i != INVEN_MAIN_RING) {
2304 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2309 case MELEE_TYPE_SHIELD_DOUBLE:
2317 /* Martial arts bonus */
2318 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2319 hit += (creature_ptr->lev / 3);
2322 /* Two handed combat penalty */
2323 hit -= calc_double_weapon_penalty(creature_ptr, slot);
2325 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
2326 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2327 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2328 hit -= (creature_ptr->lev / 3);
2335 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
2339 pow += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2340 pow += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2344 BIT_FLAGS flgs[TR_FLAG_SIZE];
2345 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2347 object_flags(creature_ptr, o_ptr, flgs);
2349 if (o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
2350 if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
2359 if (creature_ptr->stun > 50) {
2361 } else if (creature_ptr->stun) {
2365 if (is_blessed(creature_ptr)) {
2369 if (is_hero(creature_ptr)) {
2373 if (is_shero(creature_ptr)) {
2377 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2379 if (is_heavy_shoot(creature_ptr, o_ptr)) {
2380 pow += 2 * (calc_bow_weight_limit(creature_ptr) - o_ptr->weight / 10);
2384 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
2385 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
2386 pow += (10 + (creature_ptr->lev / 5));
2392 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2394 o_ptr = &creature_ptr->inventory_list[i];
2395 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2396 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2399 bonus_to_h = o_ptr->to_h;
2401 if (creature_ptr->pclass == CLASS_NINJA) {
2402 if (o_ptr->to_h > 0)
2403 bonus_to_h = (o_ptr->to_h + 1) / 2;
2406 if (is_real_value || object_is_known(o_ptr))
2407 pow += (s16b)bonus_to_h;
2410 pow -= calc_riding_bow_penalty(creature_ptr);
2415 static s16b calc_to_damage_misc(player_type *creature_ptr)
2418 BIT_FLAGS flgs[TR_FLAG_SIZE];
2422 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2423 o_ptr = &creature_ptr->inventory_list[i];
2427 object_flags(creature_ptr, o_ptr, flgs);
2429 int bonus_to_d = o_ptr->to_d;
2430 if (creature_ptr->pclass == CLASS_NINJA) {
2431 if (o_ptr->to_d > 0)
2432 bonus_to_d = (o_ptr->to_d + 1) / 2;
2434 to_dam += (s16b)bonus_to_d;
2437 if (is_shero(creature_ptr)) {
2438 to_dam += 3 + (creature_ptr->lev / 5);
2441 if (creature_ptr->stun > 50) {
2443 } else if (creature_ptr->stun) {
2447 to_dam += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2451 static s16b calc_to_hit_misc(player_type *creature_ptr)
2454 BIT_FLAGS flgs[TR_FLAG_SIZE];
2458 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2459 o_ptr = &creature_ptr->inventory_list[i];
2463 object_flags(creature_ptr, o_ptr, flgs);
2465 int bonus_to_h = o_ptr->to_h;
2466 if (creature_ptr->pclass == CLASS_NINJA) {
2467 if (o_ptr->to_h > 0)
2468 bonus_to_h = (o_ptr->to_h + 1) / 2;
2470 to_hit += (s16b)bonus_to_h;
2473 if (is_blessed(creature_ptr)) {
2477 if (is_hero(creature_ptr)) {
2481 if (is_shero(creature_ptr)) {
2485 if (creature_ptr->stun > 50) {
2487 } else if (creature_ptr->stun) {
2491 to_hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2492 to_hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2497 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
2499 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2502 if (creature_ptr->riding) {
2503 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2512 * @brief プレイヤーの所持重量制限を計算する /
2513 * Computes current weight limit.
2516 WEIGHT calc_weight_limit(player_type *creature_ptr)
2518 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_index[A_STR]] * 50;
2519 if (creature_ptr->pclass == CLASS_BERSERKER)
2525 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
2526 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
2528 void update_creature(player_type *creature_ptr)
2530 if (!creature_ptr->update)
2533 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2534 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
2535 reset_bits(creature_ptr->update, PU_AUTODESTROY);
2536 autopick_delayed_alter(creature_ptr);
2539 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
2540 reset_bits(creature_ptr->update, PU_COMBINE);
2541 combine_pack(creature_ptr);
2544 if (any_bits(creature_ptr->update, (PU_REORDER))) {
2545 reset_bits(creature_ptr->update, PU_REORDER);
2546 reorder_pack(creature_ptr);
2549 if (any_bits(creature_ptr->update, (PU_BONUS))) {
2550 reset_bits(creature_ptr->update, PU_BONUS);
2551 PlayerAlignment(creature_ptr).update_alignment();
2552 update_bonuses(creature_ptr);
2555 if (any_bits(creature_ptr->update, (PU_TORCH))) {
2556 reset_bits(creature_ptr->update, PU_TORCH);
2557 update_lite_radius(creature_ptr);
2560 if (any_bits(creature_ptr->update, (PU_HP))) {
2561 reset_bits(creature_ptr->update, PU_HP);
2562 update_max_hitpoints(creature_ptr);
2565 if (any_bits(creature_ptr->update, (PU_MANA))) {
2566 reset_bits(creature_ptr->update, PU_MANA);
2567 update_max_mana(creature_ptr);
2570 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
2571 reset_bits(creature_ptr->update, PU_SPELLS);
2572 update_num_of_spells(creature_ptr);
2575 if (!current_world_ptr->character_generated)
2577 if (current_world_ptr->character_icky_depth > 0)
2579 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
2580 reset_bits(creature_ptr->update, PU_UN_LITE);
2581 forget_lite(floor_ptr);
2584 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
2585 reset_bits(creature_ptr->update, PU_UN_VIEW);
2586 forget_view(floor_ptr);
2589 if (any_bits(creature_ptr->update, (PU_VIEW))) {
2590 reset_bits(creature_ptr->update, PU_VIEW);
2591 update_view(creature_ptr);
2594 if (any_bits(creature_ptr->update, (PU_LITE))) {
2595 reset_bits(creature_ptr->update, PU_LITE);
2596 update_lite(creature_ptr);
2599 if (any_bits(creature_ptr->update, (PU_FLOW))) {
2600 reset_bits(creature_ptr->update, PU_FLOW);
2601 update_flow(creature_ptr);
2604 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
2605 reset_bits(creature_ptr->update, PU_DISTANCE);
2607 update_monsters(creature_ptr, true);
2610 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
2611 reset_bits(creature_ptr->update, PU_MON_LITE);
2612 update_mon_lite(creature_ptr);
2615 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
2616 reset_bits(creature_ptr->update, PU_DELAY_VIS);
2617 delayed_visual_update(creature_ptr);
2620 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
2621 reset_bits(creature_ptr->update, PU_MONSTERS);
2622 update_monsters(creature_ptr, false);
2627 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
2628 * @return 魔道書を一冊も持っていないならTRUEを返す
2630 bool player_has_no_spellbooks(player_type *creature_ptr)
2633 for (int i = 0; i < INVEN_PACK; i++) {
2634 o_ptr = &creature_ptr->inventory_list[i];
2635 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2639 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2640 for (const auto this_o_idx : floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx_list) {
2641 o_ptr = &floor_ptr->o_list[this_o_idx];
2642 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2650 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
2653 * @return 配置に成功したらTRUE
2655 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
2657 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
2660 /* Save player location */
2661 creature_ptr->y = y;
2662 creature_ptr->x = x;
2667 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
2669 void wreck_the_pattern(player_type *creature_ptr)
2671 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2672 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
2673 if (pattern_type == PATTERN_TILE_WRECKED)
2676 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
2677 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
2679 if (!is_invuln(creature_ptr))
2680 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"));
2682 int to_ruin = randint1(45) + 35;
2685 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
2687 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
2688 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
2692 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
2696 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
2697 * Advance experience levels and print experience
2699 void check_experience(player_type *creature_ptr)
2701 if (creature_ptr->exp < 0)
2702 creature_ptr->exp = 0;
2703 if (creature_ptr->max_exp < 0)
2704 creature_ptr->max_exp = 0;
2705 if (creature_ptr->max_max_exp < 0)
2706 creature_ptr->max_max_exp = 0;
2708 if (creature_ptr->exp > PY_MAX_EXP)
2709 creature_ptr->exp = PY_MAX_EXP;
2710 if (creature_ptr->max_exp > PY_MAX_EXP)
2711 creature_ptr->max_exp = PY_MAX_EXP;
2712 if (creature_ptr->max_max_exp > PY_MAX_EXP)
2713 creature_ptr->max_max_exp = PY_MAX_EXP;
2715 if (creature_ptr->exp > creature_ptr->max_exp)
2716 creature_ptr->max_exp = creature_ptr->exp;
2717 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
2718 creature_ptr->max_max_exp = creature_ptr->max_exp;
2720 set_bits(creature_ptr->redraw, PR_EXP);
2721 handle_stuff(creature_ptr);
2723 bool android = (creature_ptr->prace == RACE_ANDROID ? true : false);
2724 PLAYER_LEVEL old_lev = creature_ptr->lev;
2725 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
2726 creature_ptr->lev--;
2727 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2728 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
2729 set_bits(creature_ptr->window_flags, PW_PLAYER);
2730 handle_stuff(creature_ptr);
2733 bool level_reward = false;
2734 bool level_mutation = false;
2735 bool level_inc_stat = false;
2736 while ((creature_ptr->lev < PY_MAX_LEVEL)
2737 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
2738 creature_ptr->lev++;
2739 if (creature_ptr->lev > creature_ptr->max_plv) {
2740 creature_ptr->max_plv = creature_ptr->lev;
2742 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || creature_ptr->muta.has(MUTA::CHAOS_GIFT)) {
2743 level_reward = true;
2745 if (creature_ptr->prace == RACE_BEASTMAN) {
2747 level_mutation = true;
2749 level_inc_stat = true;
2751 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
2755 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
2756 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
2757 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
2758 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
2759 creature_ptr->level_up_message = true;
2760 handle_stuff(creature_ptr);
2762 creature_ptr->level_up_message = false;
2763 if (level_inc_stat) {
2764 if (!(creature_ptr->max_plv % 10)) {
2771 cnv_stat(creature_ptr->stat_max[0], tmp);
2772 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
2773 cnv_stat(creature_ptr->stat_max[1], tmp);
2774 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
2775 cnv_stat(creature_ptr->stat_max[2], tmp);
2776 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
2777 cnv_stat(creature_ptr->stat_max[3], tmp);
2778 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
2779 cnv_stat(creature_ptr->stat_max[4], tmp);
2780 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
2781 cnv_stat(creature_ptr->stat_max[5], tmp);
2782 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
2785 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
2789 if ((choice >= 'a') && (choice <= 'f'))
2792 for (n = 0; n < A_MAX; n++)
2793 if (n != choice - 'a')
2795 if (get_check(_("よろしいですか?", "Are you sure? ")))
2798 do_inc_stat(creature_ptr, choice - 'a');
2800 } else if (!(creature_ptr->max_plv % 2))
2801 do_inc_stat(creature_ptr, randint0(6));
2804 if (level_mutation) {
2805 msg_print(_("あなたは変わった気がする...", "You feel different..."));
2806 (void)gain_mutation(creature_ptr, 0);
2807 level_mutation = false;
2811 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
2815 gain_level_reward(creature_ptr, 0);
2816 level_reward = false;
2819 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2820 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
2821 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
2822 handle_stuff(creature_ptr);
2825 if (old_lev != creature_ptr->lev)
2826 autopick_load_pref(creature_ptr, false);
2830 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
2832 * @param out_val 出力先文字列ポインタ
2834 void cnv_stat(int val, char *out_val)
2837 sprintf(out_val, " %2d", val);
2841 int bonus = (val - 18);
2843 sprintf(out_val, "18/%3s", "***");
2844 } else if (bonus >= 100) {
2845 sprintf(out_val, "18/%03d", bonus);
2847 sprintf(out_val, " 18/%02d", bonus);
2852 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
2853 * Modify a stat value by a "modifier", return new value
2855 * @param amount 加減算値
2859 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
2860 * Or even: 18/13, 18/23, 18/33, ..., 18/220
2861 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
2862 * Or even: 18/13, 18/03, 18, 17, ..., 3
2865 s16b modify_stat_value(int value, int amount)
2868 for (int i = 0; i < amount; i++) {
2874 } else if (amount < 0) {
2875 for (int i = 0; i < (0 - amount); i++) {
2876 if (value >= 18 + 10)
2878 else if (value > 18)
2890 * Hack -- Calculates the total number of points earned -JWT-
2893 long calc_score(player_type *creature_ptr)
2895 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
2908 if (ironman_small_levels)
2910 if (ironman_empty_levels)
2916 if (ironman_nightmare)
2923 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
2924 if (max_dlv[i] > max_dl)
2925 max_dl = max_dlv[i];
2927 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
2928 u32b point_h = point_l / 0x10000L;
2929 point_l = point_l % 0x10000L;
2932 point_h += point_l / 0x10000L;
2933 point_l %= 0x10000L;
2935 point_l += ((point_h % 100) << 16);
2939 u32b point = (point_h << 16) + (point_l);
2940 if (creature_ptr->arena_number >= 0)
2941 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
2943 if (ironman_downward)
2945 if (creature_ptr->pclass == CLASS_BERSERKER) {
2946 if (creature_ptr->prace == RACE_SPECTRE)
2950 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
2952 if (current_world_ptr->total_winner)
2957 point = (0 - point);
2963 * @param creature_ptr プレーヤーへの参照ポインタ
2964 * @return 祝福状態ならばTRUE
2966 bool is_blessed(player_type *creature_ptr)
2968 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
2971 bool is_tim_esp(player_type *creature_ptr)
2973 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
2976 bool is_tim_stealth(player_type *creature_ptr)
2978 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
2981 bool is_time_limit_esp(player_type *creature_ptr)
2983 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
2986 bool is_time_limit_stealth(player_type *creature_ptr)
2988 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
2992 * @brief 口を使う継続的な処理を中断する
2993 * @param caster_ptr プレーヤーへの参照ポインタ
2995 void stop_mouth(player_type *caster_ptr)
2997 if (music_singing_any(caster_ptr))
2998 stop_singing(caster_ptr);
2999 if (hex_spelling_any(caster_ptr))
3000 stop_hex_spell_all(caster_ptr);
3003 bool is_fast(player_type *creature_ptr)
3005 return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO);
3008 bool is_invuln(player_type *creature_ptr)
3010 return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN);
3013 bool is_hero(player_type *creature_ptr)
3015 return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO);
3018 bool is_shero(player_type *creature_ptr)
3020 return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER;
3023 bool is_echizen(player_type *creature_ptr)
3025 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
3028 WEIGHT calc_weapon_weight_limit(player_type *creature_ptr)
3030 WEIGHT weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3032 if (has_two_handed_weapons(creature_ptr))
3038 WEIGHT calc_bow_weight_limit(player_type *creature_ptr)
3040 WEIGHT weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3045 static player_hand main_attack_hand(player_type *creature_ptr)
3047 switch (player_melee_type(creature_ptr)) {
3048 case MELEE_TYPE_BAREHAND_TWO:
3049 return PLAYER_HAND_MAIN;
3050 case MELEE_TYPE_BAREHAND_MAIN:
3051 return PLAYER_HAND_MAIN;
3052 case MELEE_TYPE_BAREHAND_SUB:
3053 return PLAYER_HAND_SUB;
3054 case MELEE_TYPE_WEAPON_MAIN:
3055 return PLAYER_HAND_MAIN;
3056 case MELEE_TYPE_WEAPON_SUB:
3057 return PLAYER_HAND_SUB;
3058 case MELEE_TYPE_WEAPON_TWOHAND:
3059 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
3060 case MELEE_TYPE_WEAPON_DOUBLE:
3061 return PLAYER_HAND_MAIN;
3062 case MELEE_TYPE_SHIELD_DOUBLE:
3063 return PLAYER_HAND_MAIN;
3065 return PLAYER_HAND_MAIN;