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 "game-option/text-display-options.h"
25 #include "grid/feature.h"
26 #include "grid/grid.h"
27 #include "inventory/inventory-object.h"
28 #include "inventory/inventory-slot-types.h"
29 #include "io/input-key-acceptor.h"
30 #include "io/write-diary.h"
31 #include "main/sound-definitions-table.h"
32 #include "main/sound-of-music.h"
33 #include "market/arena-info-table.h"
34 #include "mind/mind-force-trainer.h"
35 #include "mind/mind-ninja.h"
36 #include "monster-floor/monster-lite.h"
37 #include "monster-floor/monster-remover.h"
38 #include "monster-race/monster-race-hook.h"
39 #include "monster-race/monster-race.h"
40 #include "monster-race/race-flags1.h"
41 #include "monster-race/race-flags2.h"
42 #include "monster-race/race-flags3.h"
43 #include "monster-race/race-flags7.h"
44 #include "monster/monster-info.h"
45 #include "monster/monster-status.h"
46 #include "monster/monster-update.h"
47 #include "monster/smart-learn-types.h"
48 #include "mutation/mutation-calculator.h"
49 #include "mutation/mutation-flag-types.h"
50 #include "mutation/mutation-investor-remover.h"
51 #include "object-enchant/object-ego.h"
52 #include "object-enchant/special-object-flags.h"
53 #include "object-enchant/tr-types.h"
54 #include "object-enchant/trc-types.h"
55 #include "object-hook/hook-armor.h"
56 #include "object-hook/hook-checker.h"
57 #include "object-hook/hook-weapon.h"
58 #include "object/object-flags.h"
59 #include "object/object-info.h"
60 #include "object/object-mark-types.h"
61 #include "perception/object-perception.h"
62 #include "pet/pet-util.h"
63 #include "player-info/avatar.h"
64 #include "player-status/player-basic-statistics.h"
65 #include "player-status/player-hand-types.h"
66 #include "player-status/player-infravision.h"
67 #include "player-status/player-speed.h"
68 #include "player-status/player-stealth.h"
69 #include "player/attack-defense-types.h"
70 #include "player/digestion-processor.h"
71 #include "player/mimic-info-table.h"
72 #include "player/patron.h"
73 #include "player/player-class.h"
74 #include "player/player-damage.h"
75 #include "player/player-move.h"
76 #include "player/player-personality-types.h"
77 #include "player/player-personality.h"
78 #include "player/player-race-types.h"
79 #include "player/player-skill.h"
80 #include "player/player-status-flags.h"
81 #include "player/player-status-table.h"
82 #include "player/player-view.h"
83 #include "player/race-info-table.h"
84 #include "player/special-defense-types.h"
85 #include "realm/realm-hex-numbers.h"
86 #include "realm/realm-names-table.h"
87 #include "realm/realm-song-numbers.h"
88 #include "specific-object/bow.h"
89 #include "specific-object/torch.h"
90 #include "spell-realm/spells-hex.h"
91 #include "spell-realm/spells-song.h"
92 #include "spell/range-calc.h"
93 #include "spell/spells-describer.h"
94 #include "spell/spells-execution.h"
95 #include "spell/spells-status.h"
96 #include "spell/technic-info-table.h"
97 #include "status/action-setter.h"
98 #include "status/base-status.h"
99 #include "sv-definition/sv-lite-types.h"
100 #include "sv-definition/sv-weapon-types.h"
101 #include "system/floor-type-definition.h"
102 #include "system/monster-race-definition.h"
103 #include "system/monster-type-definition.h"
104 #include "system/object-type-definition.h"
105 #include "system/player-type-definition.h"
106 #include "term/screen-processor.h"
107 #include "util/bit-flags-calculator.h"
108 #include "util/quarks.h"
109 #include "util/string-processor.h"
110 #include "view/display-messages.h"
111 #include "world/world.h"
113 static const int extra_magic_glove_reduce_mana = 1;
115 static bool is_martial_arts_mode(player_type *creature_ptr);
117 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
118 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
119 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
120 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
121 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
122 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
123 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
124 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
125 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
126 static bool is_heavy_wield(player_type *creature_ptr, int i);
127 static s16b calc_num_blow(player_type *creature_ptr, int i);
128 static s16b calc_to_magic_chance(player_type *creature_ptr);
129 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
130 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value);
131 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
132 static bool is_riding_two_hands(player_type *creature_ptr);
133 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
134 static void put_equipment_warning(player_type *creature_ptr);
136 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
137 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
139 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value);
141 static s16b calc_to_damage_misc(player_type *creature_ptr);
142 static s16b calc_to_hit_misc(player_type *creature_ptr);
144 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
145 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
147 static player_hand main_attack_hand(player_type *creature_ptr);
149 /*** Player information ***/
152 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
153 * @param weapon_exp 経験値
156 int weapon_exp_level(int weapon_exp)
158 if (weapon_exp < WEAPON_EXP_BEGINNER)
159 return EXP_LEVEL_UNSKILLED;
160 else if (weapon_exp < WEAPON_EXP_SKILLED)
161 return EXP_LEVEL_BEGINNER;
162 else if (weapon_exp < WEAPON_EXP_EXPERT)
163 return EXP_LEVEL_SKILLED;
164 else if (weapon_exp < WEAPON_EXP_MASTER)
165 return EXP_LEVEL_EXPERT;
167 return EXP_LEVEL_MASTER;
171 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
172 * @param weapon_exp 経験値
175 int riding_exp_level(int riding_exp)
177 if (riding_exp < RIDING_EXP_BEGINNER)
178 return EXP_LEVEL_UNSKILLED;
179 else if (riding_exp < RIDING_EXP_SKILLED)
180 return EXP_LEVEL_BEGINNER;
181 else if (riding_exp < RIDING_EXP_EXPERT)
182 return EXP_LEVEL_SKILLED;
183 else if (riding_exp < RIDING_EXP_MASTER)
184 return EXP_LEVEL_EXPERT;
186 return EXP_LEVEL_MASTER;
190 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
191 * @param spell_exp 経験値
194 int spell_exp_level(int spell_exp)
196 if (spell_exp < SPELL_EXP_BEGINNER)
197 return EXP_LEVEL_UNSKILLED;
198 else if (spell_exp < SPELL_EXP_SKILLED)
199 return EXP_LEVEL_BEGINNER;
200 else if (spell_exp < SPELL_EXP_EXPERT)
201 return EXP_LEVEL_SKILLED;
202 else if (spell_exp < SPELL_EXP_MASTER)
203 return EXP_LEVEL_EXPERT;
205 return EXP_LEVEL_MASTER;
209 * @brief 遅延描画更新 / Delayed visual update
210 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
211 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
212 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
215 static void delayed_visual_update(player_type *player_ptr)
217 floor_type *floor_ptr = player_ptr->current_floor_ptr;
218 for (int i = 0; i < floor_ptr->redraw_n; i++) {
219 POSITION y = floor_ptr->redraw_y[i];
220 POSITION x = floor_ptr->redraw_x[i];
222 g_ptr = &floor_ptr->grid_array[y][x];
223 if (none_bits(g_ptr->info, CAVE_REDRAW))
226 if (any_bits(g_ptr->info, CAVE_NOTE))
227 note_spot(player_ptr, y, x);
229 lite_spot(player_ptr, y, x);
231 update_monster(player_ptr, g_ptr->m_idx, FALSE);
233 reset_bits(g_ptr->info, (CAVE_NOTE | CAVE_REDRAW));
236 floor_ptr->redraw_n = 0;
240 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
241 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
242 * @return 重すぎるならばTRUE
244 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
246 int hold = adj_str_hold[creature_ptr->stat_index[A_STR]];
247 return (hold < o_ptr->weight / 10);
252 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
255 WEIGHT calc_inventory_weight(player_type *creature_ptr)
260 for (int i = 0; i < INVEN_TOTAL; i++) {
261 o_ptr = &creature_ptr->inventory_list[i];
264 weight += o_ptr->weight * o_ptr->number;
269 * @brief プレイヤーの全ステータスを更新する /
270 * Calculate the players current "state", taking into account
271 * not only race/class intrinsics, but also objects being worn
272 * and temporary spell effects.
276 * See also update_max_mana() and update_max_hitpoints().
278 * Take note of the new "speed code", in particular, a very strong
279 * player will start slowing down as soon as he reaches 150 pounds,
280 * but not until he reaches 450 pounds will he be half as fast as
281 * a normal kobold. This both hurts and helps the player, hurts
282 * because in the old days a player could just avoid 300 pounds,
283 * and helps because now carrying 300 pounds is not very painful.
285 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
286 * damage, since that would affect non-combat things. These values
287 * are actually added in later, at the appropriate place.
289 * This function induces various "status" messages.
291 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
293 static void update_bonuses(player_type *creature_ptr)
295 int empty_hands_status = empty_hands(creature_ptr, TRUE);
298 /* Save the old vision stuff */
299 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
300 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
301 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
302 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
303 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
304 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
305 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
306 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
307 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
308 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
309 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
310 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
311 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
312 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
313 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
314 s16b old_speed = creature_ptr->pspeed;
316 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
317 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
319 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
320 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
321 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
322 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
323 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
324 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
325 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
326 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
327 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
328 creature_ptr->esp_human = has_esp_human(creature_ptr);
329 creature_ptr->esp_good = has_esp_good(creature_ptr);
330 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
331 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
332 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
333 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
334 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
335 creature_ptr->down_saving = has_down_saving(creature_ptr);
336 creature_ptr->yoiyami = has_no_ac(creature_ptr);
337 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
338 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
339 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
340 creature_ptr->warning = has_warning(creature_ptr);
341 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
342 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
343 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
344 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
345 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
346 creature_ptr->see_inv = has_see_inv(creature_ptr);
347 creature_ptr->free_act = has_free_act(creature_ptr);
348 creature_ptr->levitation = has_levitation(creature_ptr);
349 creature_ptr->can_swim = has_can_swim(creature_ptr);
350 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
351 creature_ptr->regenerate = has_regenerate(creature_ptr);
352 update_curses(creature_ptr);
353 creature_ptr->impact = has_impact(creature_ptr);
354 creature_ptr->earthquake = has_earthquake(creature_ptr);
355 update_extra_blows(creature_ptr);
357 creature_ptr->lite = has_lite(creature_ptr);
359 if (any_bits(creature_ptr->special_defense, KAMAE_MASK)) {
360 if (none_bits(empty_hands_status, EMPTY_HAND_MAIN)) {
361 set_action(creature_ptr, ACTION_NONE);
365 creature_ptr->stat_add[A_STR] = PlayerStrength(creature_ptr).modification_value();
366 creature_ptr->stat_add[A_INT] = PlayerIntelligence(creature_ptr).modification_value();
367 creature_ptr->stat_add[A_WIS] = PlayerWisdom(creature_ptr).modification_value();
368 creature_ptr->stat_add[A_DEX] = PlayerDexterity(creature_ptr).modification_value();
369 creature_ptr->stat_add[A_CON] = PlayerConstitution(creature_ptr).modification_value();
370 creature_ptr->stat_add[A_CHR] = PlayerCharisma(creature_ptr).modification_value();
372 PlayerStrength(creature_ptr).update_value();
373 PlayerIntelligence(creature_ptr).update_value();
374 PlayerWisdom(creature_ptr).update_value();
375 PlayerDexterity(creature_ptr).update_value();
376 PlayerConstitution(creature_ptr).update_value();
377 PlayerCharisma(creature_ptr).update_value();
379 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
381 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
382 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
383 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
387 for (int i = 0; i < 2; i++) {
388 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
389 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
390 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
391 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
392 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
393 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_MAIN_HAND + i);
396 creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value();
397 creature_ptr->see_infra = PlayerInfravision(creature_ptr).get_value();
398 creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value();
399 creature_ptr->skill_dis = calc_disarming(creature_ptr);
400 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
401 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
402 creature_ptr->skill_srh = calc_search(creature_ptr);
403 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
404 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
405 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
406 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
407 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
408 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, TRUE);
409 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, TRUE);
410 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, FALSE);
411 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, FALSE);
412 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, TRUE);
413 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, TRUE);
414 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, FALSE);
415 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, FALSE);
416 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
417 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
418 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
419 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
420 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
421 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
422 creature_ptr->ac = calc_base_ac(creature_ptr);
423 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
424 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
425 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
427 if (old_mighty_throw != creature_ptr->mighty_throw) {
428 creature_ptr->window_flags |= PW_INVEN;
431 if (creature_ptr->telepathy != old_telepathy) {
432 set_bits(creature_ptr->update, PU_MONSTERS);
435 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
436 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
437 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
438 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
439 set_bits(creature_ptr->update, PU_MONSTERS);
442 if (creature_ptr->see_inv != old_see_inv) {
443 set_bits(creature_ptr->update, PU_MONSTERS);
446 if (creature_ptr->pspeed != old_speed) {
447 set_bits(creature_ptr->redraw, PR_SPEED);
450 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
451 set_bits(creature_ptr->redraw, PR_ARMOR);
452 set_bits(creature_ptr->window_flags, PW_PLAYER);
455 if (current_world_ptr->character_xtra)
458 put_equipment_warning(creature_ptr);
459 check_no_flowed(creature_ptr);
462 static void update_alignment(player_type *creature_ptr)
464 creature_ptr->alignment = 0;
465 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
466 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
469 m_ptr = &floor_ptr->m_list[m_idx];
470 if (!monster_is_valid(m_ptr))
472 r_ptr = &r_info[m_ptr->r_idx];
477 if (any_bits(r_ptr->flags3, RF3_GOOD))
478 creature_ptr->alignment += r_ptr->level;
479 if (any_bits(r_ptr->flags3, RF3_EVIL))
480 creature_ptr->alignment -= r_ptr->level;
483 if (creature_ptr->mimic_form) {
484 switch (creature_ptr->mimic_form) {
486 creature_ptr->alignment -= 200;
488 case MIMIC_DEMON_LORD:
489 creature_ptr->alignment -= 200;
493 switch (creature_ptr->prace) {
495 creature_ptr->alignment += 200;
498 creature_ptr->alignment -= 200;
506 for (int i = 0; i < 2; i++) {
507 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i))
509 if (creature_ptr->inventory_list[INVEN_MAIN_HAND + i].name1 != ART_IRON_BALL)
511 creature_ptr->alignment -= 1000;
516 for (int i = 0; i < 8; i++) {
517 switch (creature_ptr->vir_types[i]) {
519 creature_ptr->alignment += creature_ptr->virtues[i] * 2;
528 creature_ptr->alignment -= creature_ptr->virtues[i];
531 creature_ptr->alignment += creature_ptr->virtues[i];
536 for (int i = 0; i < j; i++) {
537 if (creature_ptr->alignment > 0) {
538 creature_ptr->alignment -= creature_ptr->virtues[neutral[i]] / 2;
539 if (creature_ptr->alignment < 0)
540 creature_ptr->alignment = 0;
541 } else if (creature_ptr->alignment < 0) {
542 creature_ptr->alignment += creature_ptr->virtues[neutral[i]] / 2;
543 if (creature_ptr->alignment > 0)
544 creature_ptr->alignment = 0;
550 * @brief プレイヤーの最大HPを更新する /
551 * Update the players maximal hit points
552 * Adjust current hitpoints if necessary
556 static void update_max_hitpoints(player_type *creature_ptr)
558 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_index[A_CON]]) - 128) * creature_ptr->lev / 4;
559 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
562 if (creature_ptr->mimic_form) {
563 if (creature_ptr->pclass == CLASS_SORCERER)
564 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
566 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
567 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
570 if (creature_ptr->pclass == CLASS_SORCERER) {
571 if (creature_ptr->lev < 30)
572 mhp = (mhp * (45 + creature_ptr->lev) / 100);
574 mhp = (mhp * 75 / 100);
575 bonus = (bonus * 65 / 100);
580 if (creature_ptr->pclass == CLASS_BERSERKER) {
581 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
584 if (mhp < creature_ptr->lev + 1)
585 mhp = creature_ptr->lev + 1;
586 if (is_hero(creature_ptr))
588 if (is_shero(creature_ptr))
590 if (creature_ptr->tsuyoshi)
592 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
594 if (hex_spelling(creature_ptr, HEX_BUILDING))
596 if (creature_ptr->mhp == mhp)
599 if (creature_ptr->chp >= mhp) {
600 creature_ptr->chp = mhp;
601 creature_ptr->chp_frac = 0;
605 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
606 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
609 creature_ptr->mhp = mhp;
611 creature_ptr->redraw |= PR_HP;
612 creature_ptr->window_flags |= PW_PLAYER;
616 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
617 * Calculate number of spells player should have, and forget,
618 * or remember, spells until that number is properly reflected.
621 * Note that this function induces various "status" messages,
622 * which must be bypasses until the character is created.
624 static void update_num_of_spells(player_type *creature_ptr)
626 if (!mp_ptr->spell_book)
628 if (!current_world_ptr->character_generated)
630 if (current_world_ptr->character_xtra)
632 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
633 creature_ptr->new_spells = 0;
637 concptr p = spell_category_name(mp_ptr->spell_book);
638 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
642 int num_allowed = (adj_mag_study[creature_ptr->stat_index[mp_ptr->spell_stat]] * levels / 2);
644 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
648 if (creature_ptr->pclass == CLASS_SAMURAI) {
650 } else if (creature_ptr->realm2 == REALM_NONE) {
651 num_allowed = (num_allowed + 1) / 2;
652 if (num_allowed > (32 + bonus))
653 num_allowed = 32 + bonus;
654 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
655 if (num_allowed > (96 + bonus))
656 num_allowed = 96 + bonus;
658 if (num_allowed > (80 + bonus))
659 num_allowed = 80 + bonus;
662 int num_boukyaku = 0;
663 for (int j = 0; j < 64; j++) {
664 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
669 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
670 for (int i = 63; i >= 0; i--) {
671 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
674 int j = creature_ptr->spell_order[i];
678 const magic_type *s_ptr;
679 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
681 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
683 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
685 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
687 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
689 if (s_ptr->slevel <= creature_ptr->lev)
692 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
693 if (!is_spell_learned)
698 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
699 which = creature_ptr->realm1;
701 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
702 which = creature_ptr->realm2;
706 reset_bits(creature_ptr->spell_learned1, (1UL << j));
707 which = creature_ptr->realm1;
709 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
710 which = creature_ptr->realm2;
714 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
716 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
718 creature_ptr->new_spells++;
721 /* Forget spells if we know too many spells */
722 for (int i = 63; i >= 0; i--) {
723 if (creature_ptr->new_spells >= 0)
725 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
728 int j = creature_ptr->spell_order[i];
732 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
733 if (!is_spell_learned)
738 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
739 which = creature_ptr->realm1;
741 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
742 which = creature_ptr->realm2;
746 reset_bits(creature_ptr->spell_learned1, (1UL << j));
747 which = creature_ptr->realm1;
749 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
750 which = creature_ptr->realm2;
754 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
756 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
758 creature_ptr->new_spells++;
761 /* Check for spells to remember */
762 for (int i = 0; i < 64; i++) {
763 if (creature_ptr->new_spells <= 0)
765 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
767 int j = creature_ptr->spell_order[i];
771 const magic_type *s_ptr;
772 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
774 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
776 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
778 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
780 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
782 if (s_ptr->slevel > creature_ptr->lev)
785 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
786 if (!is_spell_learned)
791 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
792 which = creature_ptr->realm1;
794 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
795 which = creature_ptr->realm2;
799 set_bits(creature_ptr->spell_learned1, (1UL << j));
800 which = creature_ptr->realm1;
802 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
803 which = creature_ptr->realm2;
807 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
809 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
811 creature_ptr->new_spells--;
814 if (creature_ptr->realm2 == REALM_NONE) {
816 for (int j = 0; j < 32; j++) {
817 const magic_type *s_ptr;
818 if (!is_magic(creature_ptr->realm1))
819 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
821 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
823 if (s_ptr->slevel > creature_ptr->lev)
826 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
835 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
836 creature_ptr->new_spells = (s16b)k;
840 if (creature_ptr->new_spells < 0)
841 creature_ptr->new_spells = 0;
843 if (creature_ptr->old_spells == creature_ptr->new_spells)
846 if (creature_ptr->new_spells) {
848 if (creature_ptr->new_spells < 10) {
849 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
851 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
854 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
858 creature_ptr->old_spells = creature_ptr->new_spells;
859 set_bits(creature_ptr->redraw, PR_STUDY);
860 set_bits(creature_ptr->window_flags, PW_OBJECT);
864 * @brief プレイヤーの最大MPを更新する /
865 * Update maximum mana. You do not need to know any spells.
866 * Note that mana is lowered by heavy (or inappropriate) armor.
869 * This function induces status messages.
871 static void update_max_mana(player_type *creature_ptr)
873 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
877 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)
878 || creature_ptr->pclass == CLASS_ELEMENTALIST) {
879 levels = creature_ptr->lev;
881 if (mp_ptr->spell_first > creature_ptr->lev) {
882 creature_ptr->msp = 0;
883 set_bits(creature_ptr->redraw, PR_MANA);
887 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
891 if (creature_ptr->pclass == CLASS_SAMURAI) {
892 msp = (adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] + 10) * 2;
894 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
896 msp = adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] * (levels + 3) / 4;
900 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
901 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
903 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
905 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
906 msp += msp * (25 + creature_ptr->lev) / 100;
909 if (any_bits(mp_ptr->spell_xtra, extra_magic_glove_reduce_mana)) {
910 BIT_FLAGS flgs[TR_FLAG_SIZE];
911 creature_ptr->cumber_glove = FALSE;
913 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
914 object_flags(creature_ptr, o_ptr, flgs);
915 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
916 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
917 creature_ptr->cumber_glove = TRUE;
922 creature_ptr->cumber_armor = FALSE;
925 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
926 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
927 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
928 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
929 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
930 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
931 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
932 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
933 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
935 switch (creature_ptr->pclass) {
937 case CLASS_HIGH_MAGE:
938 case CLASS_BLUE_MAGE:
940 case CLASS_FORCETRAINER:
942 case CLASS_ELEMENTALIST: {
943 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
944 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
945 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
946 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
951 case CLASS_TOURIST: {
952 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
953 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
954 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
955 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
958 case CLASS_MINDCRAFTER:
959 case CLASS_BEASTMASTER:
960 case CLASS_MIRROR_MASTER: {
961 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
962 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
963 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
964 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
970 case CLASS_WARRIOR_MAGE: {
971 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
972 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
973 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
974 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
978 case CLASS_CHAOS_WARRIOR: {
979 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
980 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
981 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
982 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
990 int max_wgt = mp_ptr->spell_weight;
991 if ((cur_wgt - max_wgt) > 0) {
992 creature_ptr->cumber_armor = TRUE;
993 switch (creature_ptr->pclass) {
995 case CLASS_HIGH_MAGE:
996 case CLASS_BLUE_MAGE:
997 case CLASS_ELEMENTALIST: {
998 msp -= msp * (cur_wgt - max_wgt) / 600;
1002 case CLASS_MINDCRAFTER:
1003 case CLASS_BEASTMASTER:
1005 case CLASS_FORCETRAINER:
1007 case CLASS_MIRROR_MASTER: {
1008 msp -= msp * (cur_wgt - max_wgt) / 800;
1011 case CLASS_SORCERER: {
1012 msp -= msp * (cur_wgt - max_wgt) / 900;
1018 case CLASS_RED_MAGE: {
1019 msp -= msp * (cur_wgt - max_wgt) / 1000;
1023 case CLASS_CHAOS_WARRIOR:
1024 case CLASS_WARRIOR_MAGE: {
1025 msp -= msp * (cur_wgt - max_wgt) / 1200;
1028 case CLASS_SAMURAI: {
1029 creature_ptr->cumber_armor = FALSE;
1033 msp -= msp * (cur_wgt - max_wgt) / 800;
1042 if (creature_ptr->msp != msp) {
1043 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1044 creature_ptr->csp = msp;
1045 creature_ptr->csp_frac = 0;
1049 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1050 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1053 creature_ptr->msp = msp;
1054 set_bits(creature_ptr->redraw, PR_MANA);
1055 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
1058 if (current_world_ptr->character_xtra)
1061 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1062 if (creature_ptr->cumber_glove)
1063 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1065 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1067 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1070 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1073 if (creature_ptr->cumber_armor)
1074 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1076 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1078 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1082 * @brief 装備中の射撃武器の威力倍率を返す /
1083 * calcurate the fire rate of target object
1084 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1085 * @return 射撃倍率の値(100で1.00倍)
1087 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1089 int extra_shots = 0;
1090 BIT_FLAGS flgs[TR_FLAG_SIZE];
1092 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1094 q_ptr = &creature_ptr->inventory_list[i];
1101 object_flags(creature_ptr, q_ptr, flgs);
1102 if (has_flag(flgs, TR_XTRA_SHOTS))
1106 object_flags(creature_ptr, o_ptr, flgs);
1107 if (has_flag(flgs, TR_XTRA_SHOTS))
1111 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1115 num += (extra_shots * 100);
1117 tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
1118 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1119 num += (creature_ptr->lev * 4);
1122 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1123 num += (creature_ptr->lev * 3);
1126 if (creature_ptr->pclass == CLASS_ARCHER) {
1127 if (tval_ammo == TV_ARROW)
1128 num += ((creature_ptr->lev * 5) + 50);
1129 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1130 num += (creature_ptr->lev * 4);
1133 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1134 num += (creature_ptr->lev * 2);
1137 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1138 num += (creature_ptr->lev * 4);
1146 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1150 * * 職業と性格とレベルによる追加加算
1151 * * 器用さに応じたadj_dex_disテーブルによる加算
1152 * * 知力に応じたadj_int_disテーブルによる加算
1154 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1156 ACTION_SKILL_POWER pow;
1157 const player_race *tmp_rp_ptr;
1159 if (creature_ptr->mimic_form)
1160 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1162 tmp_rp_ptr = &race_info[creature_ptr->prace];
1163 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1164 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1166 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1167 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1168 pow += adj_dex_dis[creature_ptr->stat_index[A_DEX]];
1169 pow += adj_int_dis[creature_ptr->stat_index[A_INT]];
1175 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1179 * * 職業と性格とレベルによる追加加算
1180 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1181 * * 知力に応じたadj_int_devテーブルによる加算
1184 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1186 ACTION_SKILL_POWER pow;
1187 const player_race *tmp_rp_ptr;
1189 if (creature_ptr->mimic_form)
1190 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1192 tmp_rp_ptr = &race_info[creature_ptr->prace];
1193 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1194 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1196 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1197 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1199 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1201 BIT_FLAGS flgs[TR_FLAG_SIZE];
1202 o_ptr = &creature_ptr->inventory_list[i];
1205 object_flags(creature_ptr, o_ptr, flgs);
1206 if (has_flag(flgs, TR_MAGIC_MASTERY))
1207 pow += 8 * o_ptr->pval;
1210 pow += adj_int_dev[creature_ptr->stat_index[A_INT]];
1212 if (is_shero(creature_ptr)) {
1220 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1224 * * 職業と性格とレベルによる追加加算
1225 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1226 * * 呪力耐性の装備による加算(30)
1227 * * 祝福された装備による加算(5 + レベル / 10)
1228 * * 賢さによるadj_wis_savテーブル加算
1230 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1231 * * クターのつぶれ状態なら(10に上書き)
1232 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1233 * * 呪いのdown_savingがかかっているなら半減
1235 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1237 ACTION_SKILL_POWER pow;
1238 const player_race *tmp_rp_ptr;
1240 if (creature_ptr->mimic_form)
1241 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1243 tmp_rp_ptr = &race_info[creature_ptr->prace];
1244 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1245 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1247 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1248 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1250 if (creature_ptr->muta.has(MUTA::MAGIC_RES))
1251 pow += (15 + (creature_ptr->lev / 5));
1253 if (has_resist_curse(creature_ptr))
1256 if (creature_ptr->blessed)
1257 pow += 6 + (creature_ptr->lev - 1) / 10;
1259 pow += adj_wis_sav[creature_ptr->stat_index[A_WIS]];
1261 if (is_shero(creature_ptr))
1264 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1265 pow = 90 + creature_ptr->lev;
1267 if (creature_ptr->tsubureru)
1270 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1271 pow = 95 + creature_ptr->lev;
1273 if (creature_ptr->down_saving)
1281 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1286 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1288 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1290 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1292 ACTION_SKILL_POWER pow;
1293 const player_race *tmp_rp_ptr;
1295 if (creature_ptr->mimic_form)
1296 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1298 tmp_rp_ptr = &race_info[creature_ptr->prace];
1299 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1300 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1302 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1303 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1305 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1307 BIT_FLAGS flgs[TR_FLAG_SIZE];
1308 o_ptr = &creature_ptr->inventory_list[i];
1311 object_flags(creature_ptr, o_ptr, flgs);
1312 if (has_flag(flgs, TR_SEARCH))
1313 pow += (o_ptr->pval * 5);
1316 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1320 if (is_shero(creature_ptr)) {
1329 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1334 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1336 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1338 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1340 ACTION_SKILL_POWER pow;
1341 const player_race *tmp_rp_ptr;
1343 if (creature_ptr->mimic_form)
1344 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1346 tmp_rp_ptr = &race_info[creature_ptr->prace];
1347 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1348 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1350 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1351 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1353 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1355 BIT_FLAGS flgs[TR_FLAG_SIZE];
1356 o_ptr = &creature_ptr->inventory_list[i];
1359 object_flags(creature_ptr, o_ptr, flgs);
1360 if (has_flag(flgs, TR_SEARCH))
1361 pow += (o_ptr->pval * 5);
1364 if (is_shero(creature_ptr)) {
1368 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1377 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1380 * * 種族/職業/性格による加算とレベルによる追加加算
1382 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1384 ACTION_SKILL_POWER pow;
1385 const player_race *tmp_rp_ptr;
1386 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1387 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1389 if (creature_ptr->mimic_form)
1390 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1392 tmp_rp_ptr = &race_info[creature_ptr->prace];
1394 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1395 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1401 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1404 * * 種族/職業/性格による加算とレベルによる追加加算
1406 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1408 ACTION_SKILL_POWER pow;
1409 const player_race *tmp_rp_ptr;
1410 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1411 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1413 if (creature_ptr->mimic_form)
1414 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1416 tmp_rp_ptr = &race_info[creature_ptr->prace];
1418 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1419 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1425 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1428 * * 種族/職業/性格による加算とレベルによる追加加算
1431 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1433 ACTION_SKILL_POWER pow;
1434 const player_race *tmp_rp_ptr;
1435 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1436 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1438 if (creature_ptr->mimic_form)
1439 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1441 tmp_rp_ptr = &race_info[creature_ptr->prace];
1443 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1444 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1446 if (is_shero(creature_ptr)) {
1455 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1466 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1469 BIT_FLAGS flgs[TR_FLAG_SIZE];
1471 ACTION_SKILL_POWER pow;
1475 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1476 pow += creature_ptr->lev * 10;
1479 if (is_shero(creature_ptr))
1482 pow += adj_str_dig[creature_ptr->stat_index[A_STR]];
1484 if (creature_ptr->pclass == CLASS_BERSERKER)
1485 pow += (100 + creature_ptr->lev * 8);
1487 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1488 o_ptr = &creature_ptr->inventory_list[i];
1491 object_flags(creature_ptr, o_ptr, flgs);
1492 if (has_flag(flgs, TR_TUNNEL))
1493 pow += (o_ptr->pval * 20);
1496 for (int i = 0; i < 2; i++) {
1497 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1498 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1499 pow += (o_ptr->weight / 10);
1503 if (is_shero(creature_ptr)) {
1513 static bool is_martial_arts_mode(player_type *creature_ptr)
1515 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1516 && (any_bits(empty_hands(creature_ptr, TRUE), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1519 static bool is_heavy_wield(player_type *creature_ptr, int i)
1521 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1523 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1526 static s16b calc_num_blow(player_type *creature_ptr, int i)
1529 BIT_FLAGS flgs[TR_FLAG_SIZE];
1532 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1533 object_flags(creature_ptr, o_ptr, flgs);
1534 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1535 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1536 int str_index, dex_index;
1537 int num = 0, wgt = 0, mul = 0, div = 0;
1539 num = class_info[creature_ptr->pclass].num;
1540 wgt = class_info[creature_ptr->pclass].wgt;
1541 mul = class_info[creature_ptr->pclass].mul;
1543 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1549 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1555 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1556 str_index = (adj_str_blow[creature_ptr->stat_index[A_STR]] * mul / div);
1558 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1560 if (creature_ptr->pclass == CLASS_NINJA)
1561 str_index = MAX(0, str_index - 1);
1565 dex_index = (adj_dex_blow[creature_ptr->stat_index[A_DEX]]);
1569 num_blow = blows_table[str_index][dex_index];
1571 num_blow = (s16b)num;
1573 num_blow += (s16b)creature_ptr->extra_blows[i];
1574 if (creature_ptr->pclass == CLASS_WARRIOR)
1575 num_blow += (creature_ptr->lev / 40);
1576 else if (creature_ptr->pclass == CLASS_BERSERKER)
1577 num_blow += (creature_ptr->lev / 23);
1578 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_index[A_DEX] >= 30))
1581 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1584 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1594 /* Different calculation for monks with empty hands */
1595 if (is_martial_arts_mode(creature_ptr)) {
1596 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_index[A_DEX]];
1599 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1625 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1628 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1630 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1634 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1638 num_blow += 1 + creature_ptr->extra_blows[0];
1641 if (has_not_ninja_weapon(creature_ptr, i)) {
1652 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1655 * * 性格なまけものなら加算(+10)
1657 * * 性格ちからじまんとがまんづよいなら加算(+1)
1658 * * 性格チャージマンなら加算(+5)
1659 * * 装備品にTRC_HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
1661 static s16b calc_to_magic_chance(player_type *creature_ptr)
1665 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
1667 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
1669 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
1671 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
1674 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1676 BIT_FLAGS flgs[TR_FLAG_SIZE];
1677 o_ptr = &creature_ptr->inventory_list[i];
1680 object_flags(creature_ptr, o_ptr, flgs);
1681 if (any_bits(o_ptr->curse_flags, TRC_HARD_SPELL)) {
1682 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
1692 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
1694 ARMOUR_CLASS ac = 0;
1695 if (creature_ptr->yoiyami)
1698 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1700 o_ptr = &creature_ptr->inventory_list[i];
1706 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
1707 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1708 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
1714 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
1716 ARMOUR_CLASS ac = 0;
1717 BIT_FLAGS flags[TR_FLAG_SIZE];
1718 if (creature_ptr->yoiyami)
1721 ac += ((int)(adj_dex_ta[creature_ptr->stat_index[A_DEX]]) - 128);
1723 if (creature_ptr->mimic_form) {
1724 switch (creature_ptr->mimic_form) {
1728 case MIMIC_DEMON_LORD:
1736 if (creature_ptr->pclass == CLASS_BERSERKER) {
1737 ac += 10 + creature_ptr->lev / 2;
1739 if (creature_ptr->pclass == CLASS_SORCERER) {
1743 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1745 o_ptr = &creature_ptr->inventory_list[i];
1746 object_flags(creature_ptr, o_ptr, flags);
1749 if (is_real_value || object_is_known(o_ptr))
1752 if (any_bits(o_ptr->curse_flags, TRC_LOW_AC)) {
1753 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
1754 if (is_real_value || object_is_fully_known(o_ptr))
1757 if (is_real_value || object_is_fully_known(o_ptr))
1762 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
1767 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
1768 ac += 10 + (creature_ptr->lev * 2 / 5);
1771 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
1775 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1776 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1780 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
1784 if (creature_ptr->muta.has(MUTA::WART_SKIN)) {
1788 if (creature_ptr->muta.has(MUTA::SCALES)) {
1792 if (creature_ptr->muta.has(MUTA::IRON_SKIN)) {
1796 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
1797 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
1798 ac += (creature_ptr->lev * 3) / 2;
1800 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
1801 ac += ((creature_ptr->lev - 13) / 3);
1803 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
1804 ac += ((creature_ptr->lev - 8) / 3);
1806 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
1807 ac += (creature_ptr->lev - 2) / 3;
1809 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
1810 ac += (creature_ptr->lev / 2);
1812 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
1813 ac += (creature_ptr->lev / 3);
1817 if (creature_ptr->realm1 == REALM_HEX) {
1818 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
1822 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
1823 object_type *o_ptr = &creature_ptr->inventory_list[i];
1826 if (!object_is_armour(creature_ptr, o_ptr))
1828 if (!object_is_cursed(o_ptr))
1830 if (any_bits(o_ptr->curse_flags, TRC_CURSED))
1832 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE))
1834 if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE))
1839 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1840 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
1841 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1843 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
1845 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1849 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
1851 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
1855 if (is_blessed(creature_ptr)) {
1859 if (is_shero(creature_ptr)) {
1863 if (creature_ptr->pclass == CLASS_NINJA) {
1864 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1865 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1866 ac += creature_ptr->lev / 2 + 5;
1874 * @brief 二刀流ペナルティ量計算
1875 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1876 * @param slot ペナルティ量を計算する武器スロット
1881 * * EASY2_WEAPONによる軽減
1882 * * SUPPORTIVEを左に装備した場合の軽減
1886 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
1889 BIT_FLAGS flags[TR_FLAG_SIZE];
1891 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1892 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
1894 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
1895 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
1896 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
1897 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
1898 penalty = penalty / 2 - 5;
1901 for (unsigned int i = FLAG_CAUSE_INVEN_MAIN_HAND; i < FLAG_CAUSE_MAX; i <<= 1)
1902 if (penalty > 0 && any_bits(creature_ptr->easy_2weapon, i))
1905 if (has_flag(flags, TR_SUPPORTIVE))
1906 penalty = MAX(0, penalty - 10);
1908 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1909 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1910 penalty = MIN(0, penalty);
1913 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
1916 return (s16b)penalty;
1919 static bool is_riding_two_hands(player_type *creature_ptr)
1921 if (!creature_ptr->riding) {
1925 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
1927 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
1928 switch (creature_ptr->pclass) {
1930 case CLASS_FORCETRAINER:
1931 case CLASS_BERSERKER:
1932 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
1933 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
1944 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
1946 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1947 if (!creature_ptr->riding)
1952 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
1953 if (creature_ptr->tval_ammo != TV_ARROW)
1956 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
1962 if (creature_ptr->tval_ammo == TV_BOLT)
1968 void put_equipment_warning(player_type *creature_ptr)
1970 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
1971 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
1973 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
1974 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
1975 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
1977 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
1979 creature_ptr->old_heavy_shoot = heavy_shoot;
1982 for (int i = 0; i < 2; i++) {
1983 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
1984 if (creature_ptr->heavy_wield[i]) {
1985 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
1986 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1987 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
1988 } else if (creature_ptr->heavy_wield[1 - i]) {
1989 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
1991 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
1994 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
1997 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
1998 if (creature_ptr->riding_wield[i]) {
1999 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2000 } else if (!creature_ptr->riding) {
2001 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
2002 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2003 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2006 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
2009 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
2012 if (creature_ptr->icky_wield[i]) {
2013 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2014 if (current_world_ptr->is_loading_now) {
2015 chg_virtue(creature_ptr, V_FAITH, -1);
2017 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2018 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2020 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2023 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
2026 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
2027 if (creature_ptr->riding_ryoute) {
2029 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2031 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
2035 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2037 msg_print("You began to control the pet you're riding with one hand.");
2041 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
2044 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
2045 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
2046 if (heavy_armor(creature_ptr)) {
2047 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2048 if (current_world_ptr->is_loading_now) {
2049 chg_virtue(creature_ptr, V_HARMONY, -1);
2052 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2055 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
2059 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2061 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2062 BIT_FLAGS flgs[TR_FLAG_SIZE];
2063 object_flags(creature_ptr, o_ptr, flgs);
2065 player_hand calc_hand = PLAYER_HAND_OTHER;
2066 if (slot == INVEN_MAIN_HAND)
2067 calc_hand = PLAYER_HAND_MAIN;
2068 if (slot == INVEN_SUB_HAND)
2069 calc_hand = PLAYER_HAND_SUB;
2072 damage += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2074 if (is_shero(creature_ptr)) {
2075 damage += 3 + (creature_ptr->lev / 5);
2078 if (creature_ptr->stun > 50) {
2080 } else if (creature_ptr->stun) {
2084 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2086 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2087 damage += creature_ptr->lev / 6;
2088 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2089 damage += creature_ptr->lev / 6;
2091 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2092 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2097 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
2098 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
2099 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2100 damage += get_current_ki(creature_ptr) / 5;
2104 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2105 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2106 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
2109 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
2112 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
2118 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2120 o_ptr = &creature_ptr->inventory_list[i];
2121 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2122 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2125 if (!object_is_known(o_ptr) && !is_real_value)
2127 bonus_to_d = o_ptr->to_d;
2129 if (creature_ptr->pclass == CLASS_NINJA) {
2130 if (o_ptr->to_d > 0)
2131 bonus_to_d = (o_ptr->to_d + 1) / 2;
2134 switch (player_melee_type(creature_ptr)) {
2135 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2136 case MELEE_TYPE_WEAPON_TWOHAND:
2137 if (calc_hand == main_attack_hand(creature_ptr))
2138 damage += (s16b)bonus_to_d;
2141 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2142 case MELEE_TYPE_WEAPON_MAIN:
2143 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2144 damage += (s16b)bonus_to_d;
2147 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2148 case MELEE_TYPE_WEAPON_SUB:
2149 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2150 damage += (s16b)bonus_to_d;
2153 case MELEE_TYPE_WEAPON_DOUBLE:
2154 if (calc_hand == PLAYER_HAND_MAIN) {
2155 if (i == INVEN_MAIN_RING) {
2156 damage += (s16b)bonus_to_d;
2157 } else if (i != INVEN_SUB_RING) {
2158 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2161 if (calc_hand == PLAYER_HAND_SUB) {
2162 if (i == INVEN_SUB_RING) {
2163 damage += (s16b)bonus_to_d;
2164 } else if (i != INVEN_MAIN_RING) {
2165 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2170 case MELEE_TYPE_SHIELD_DOUBLE:
2178 if (main_attack_hand(creature_ptr) == calc_hand) {
2179 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2180 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2182 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128) / 2;
2183 damage += MAX(bonus_to_d, 1);
2187 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2188 damage += (creature_ptr->lev / 6);
2191 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
2192 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2193 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2194 damage -= (creature_ptr->lev / 6);
2202 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
2204 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
2206 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2211 hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2212 hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2214 /* Temporary bonuses */
2215 if (is_blessed(creature_ptr)) {
2219 if (is_hero(creature_ptr)) {
2223 if (is_shero(creature_ptr)) {
2227 if (creature_ptr->stun > 50) {
2229 } else if (creature_ptr->stun) {
2233 player_hand calc_hand = PLAYER_HAND_OTHER;
2234 if (slot == INVEN_MAIN_HAND)
2235 calc_hand = PLAYER_HAND_MAIN;
2236 if (slot == INVEN_SUB_HAND)
2237 calc_hand = PLAYER_HAND_SUB;
2239 /* Default hand bonuses */
2240 if (main_attack_hand(creature_ptr) == calc_hand) {
2241 switch (player_melee_type(creature_ptr)) {
2242 case MELEE_TYPE_BAREHAND_MAIN:
2243 if (creature_ptr->riding)
2246 case MELEE_TYPE_BAREHAND_SUB:
2247 if (creature_ptr->riding)
2250 case MELEE_TYPE_BAREHAND_TWO:
2251 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2258 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2259 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2261 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);
2262 hit += MAX(bonus_to_h, 1);
2266 /* Bonuses and penalties by weapon */
2267 if (has_melee_weapon(creature_ptr, slot)) {
2268 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2269 BIT_FLAGS flgs[TR_FLAG_SIZE];
2270 object_flags(creature_ptr, o_ptr, flgs);
2272 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
2273 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
2275 /* Traind bonuses */
2276 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2278 /* Weight penalty */
2279 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
2280 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2283 /* Low melee penalty */
2284 if ((object_is_fully_known(o_ptr) || is_real_value) && any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
2285 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2292 /* Riding bonus and penalty */
2293 if (creature_ptr->riding) {
2294 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2299 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2300 && !has_flag(flgs, TR_RIDING)) {
2302 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2305 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2310 hit -= (s16b)penalty;
2313 /* Class penalties */
2314 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2316 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2317 hit += creature_ptr->lev / 5;
2318 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2319 hit += creature_ptr->lev / 5;
2321 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2322 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2329 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
2333 /* Hex realm bonuses */
2334 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2335 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
2338 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
2341 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
2344 if (any_bits(o_ptr->curse_flags, (TRC_TY_CURSE))) {
2350 /* Bonuses from inventory */
2351 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2352 object_type *o_ptr = &creature_ptr->inventory_list[i];
2354 /* Ignore empty hands, handed weapons, bows and capture balls */
2355 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2356 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2359 /* Fake value does not include unknown objects' value */
2360 if (!object_is_known(o_ptr) && !is_real_value)
2363 int bonus_to_h = o_ptr->to_h;
2365 /* When wields only a weapon */
2366 if (creature_ptr->pclass == CLASS_NINJA) {
2367 if (o_ptr->to_h > 0)
2368 bonus_to_h = (o_ptr->to_h + 1) / 2;
2371 switch (player_melee_type(creature_ptr)) {
2372 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2373 case MELEE_TYPE_WEAPON_TWOHAND:
2374 if (calc_hand == main_attack_hand(creature_ptr))
2375 hit += (s16b)bonus_to_h;
2378 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2379 case MELEE_TYPE_WEAPON_MAIN:
2380 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2381 hit += (s16b)bonus_to_h;
2384 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2385 case MELEE_TYPE_WEAPON_SUB:
2386 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2387 hit += (s16b)bonus_to_h;
2390 case MELEE_TYPE_WEAPON_DOUBLE:
2391 if (calc_hand == PLAYER_HAND_MAIN) {
2392 if (i == INVEN_MAIN_RING) {
2393 hit += (s16b)bonus_to_h;
2394 } else if (i != INVEN_SUB_RING) {
2395 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2398 if (calc_hand == PLAYER_HAND_SUB) {
2399 if (i == INVEN_SUB_RING) {
2400 hit += (s16b)bonus_to_h;
2401 } else if (i != INVEN_MAIN_RING) {
2402 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2407 case MELEE_TYPE_SHIELD_DOUBLE:
2415 /* Martial arts bonus */
2416 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2417 hit += (creature_ptr->lev / 3);
2420 /* Two handed combat penalty */
2421 hit -= calc_double_weapon_penalty(creature_ptr, slot);
2423 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
2424 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2425 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2426 hit -= (creature_ptr->lev / 3);
2433 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
2437 pow += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2438 pow += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2442 BIT_FLAGS flgs[TR_FLAG_SIZE];
2443 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2445 object_flags(creature_ptr, o_ptr, flgs);
2447 if (any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
2448 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2457 if (creature_ptr->stun > 50) {
2459 } else if (creature_ptr->stun) {
2463 if (is_blessed(creature_ptr)) {
2467 if (is_hero(creature_ptr)) {
2471 if (is_shero(creature_ptr)) {
2475 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2477 if (is_heavy_shoot(creature_ptr, o_ptr)) {
2478 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2482 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
2483 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
2484 pow += (10 + (creature_ptr->lev / 5));
2490 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2492 o_ptr = &creature_ptr->inventory_list[i];
2493 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2494 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2497 bonus_to_h = o_ptr->to_h;
2499 if (creature_ptr->pclass == CLASS_NINJA) {
2500 if (o_ptr->to_h > 0)
2501 bonus_to_h = (o_ptr->to_h + 1) / 2;
2504 if (is_real_value || object_is_known(o_ptr))
2505 pow += (s16b)bonus_to_h;
2508 pow -= calc_riding_bow_penalty(creature_ptr);
2513 static s16b calc_to_damage_misc(player_type *creature_ptr)
2516 BIT_FLAGS flgs[TR_FLAG_SIZE];
2520 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2521 o_ptr = &creature_ptr->inventory_list[i];
2525 object_flags(creature_ptr, o_ptr, flgs);
2527 int bonus_to_d = o_ptr->to_d;
2528 if (creature_ptr->pclass == CLASS_NINJA) {
2529 if (o_ptr->to_d > 0)
2530 bonus_to_d = (o_ptr->to_d + 1) / 2;
2532 to_dam += (s16b)bonus_to_d;
2535 if (is_shero(creature_ptr)) {
2536 to_dam += 3 + (creature_ptr->lev / 5);
2539 if (creature_ptr->stun > 50) {
2541 } else if (creature_ptr->stun) {
2545 to_dam += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2549 static s16b calc_to_hit_misc(player_type *creature_ptr)
2552 BIT_FLAGS flgs[TR_FLAG_SIZE];
2556 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2557 o_ptr = &creature_ptr->inventory_list[i];
2561 object_flags(creature_ptr, o_ptr, flgs);
2563 int bonus_to_h = o_ptr->to_h;
2564 if (creature_ptr->pclass == CLASS_NINJA) {
2565 if (o_ptr->to_h > 0)
2566 bonus_to_h = (o_ptr->to_h + 1) / 2;
2568 to_hit += (s16b)bonus_to_h;
2571 if (is_blessed(creature_ptr)) {
2575 if (is_hero(creature_ptr)) {
2579 if (is_shero(creature_ptr)) {
2583 if (creature_ptr->stun > 50) {
2585 } else if (creature_ptr->stun) {
2589 to_hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2590 to_hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2595 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
2597 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2600 if (creature_ptr->riding) {
2601 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2609 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
2611 (void)creature_ptr; // unused
2612 (void)slot; // unused
2617 * @brief プレイヤーの所持重量制限を計算する /
2618 * Computes current weight limit.
2621 WEIGHT calc_weight_limit(player_type *creature_ptr)
2623 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_index[A_STR]] * 50;
2624 if (creature_ptr->pclass == CLASS_BERSERKER)
2630 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
2631 * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND)
2632 * @return 持っているならばTRUE
2634 bool has_melee_weapon(player_type *creature_ptr, int slot)
2636 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
2640 * @brief プレイヤーの現在開いている手の状態を返す
2641 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
2642 * @return 開いている手のビットフラグ
2644 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
2646 BIT_FLAGS16 status = EMPTY_HAND_NONE;
2647 if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx)
2648 status |= EMPTY_HAND_MAIN;
2649 if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx)
2650 status |= EMPTY_HAND_SUB;
2652 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
2653 if (any_bits(status, EMPTY_HAND_SUB))
2654 reset_bits(status, EMPTY_HAND_SUB);
2655 else if (any_bits(status, EMPTY_HAND_MAIN))
2656 reset_bits(status, EMPTY_HAND_MAIN);
2663 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
2664 * @return ペナルティが適用されるならばTRUE。
2666 bool heavy_armor(player_type *creature_ptr)
2668 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
2671 WEIGHT monk_arm_wgt = 0;
2672 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
2673 monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
2674 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
2675 monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
2676 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
2677 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
2678 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
2679 monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
2680 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
2682 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
2686 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
2688 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
2690 void update_creature(player_type *creature_ptr)
2692 if (!creature_ptr->update)
2695 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2696 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
2697 reset_bits(creature_ptr->update, PU_AUTODESTROY);
2698 autopick_delayed_alter(creature_ptr);
2701 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
2702 reset_bits(creature_ptr->update, PU_COMBINE);
2703 combine_pack(creature_ptr);
2706 if (any_bits(creature_ptr->update, (PU_REORDER))) {
2707 reset_bits(creature_ptr->update, PU_REORDER);
2708 reorder_pack(creature_ptr);
2711 if (any_bits(creature_ptr->update, (PU_BONUS))) {
2712 reset_bits(creature_ptr->update, PU_BONUS);
2713 update_alignment(creature_ptr);
2714 update_bonuses(creature_ptr);
2717 if (any_bits(creature_ptr->update, (PU_TORCH))) {
2718 reset_bits(creature_ptr->update, PU_TORCH);
2719 update_lite_radius(creature_ptr);
2722 if (any_bits(creature_ptr->update, (PU_HP))) {
2723 reset_bits(creature_ptr->update, PU_HP);
2724 update_max_hitpoints(creature_ptr);
2727 if (any_bits(creature_ptr->update, (PU_MANA))) {
2728 reset_bits(creature_ptr->update, PU_MANA);
2729 update_max_mana(creature_ptr);
2732 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
2733 reset_bits(creature_ptr->update, PU_SPELLS);
2734 update_num_of_spells(creature_ptr);
2737 if (!current_world_ptr->character_generated)
2739 if (current_world_ptr->character_icky_depth > 0)
2741 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
2742 reset_bits(creature_ptr->update, PU_UN_LITE);
2743 forget_lite(floor_ptr);
2746 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
2747 reset_bits(creature_ptr->update, PU_UN_VIEW);
2748 forget_view(floor_ptr);
2751 if (any_bits(creature_ptr->update, (PU_VIEW))) {
2752 reset_bits(creature_ptr->update, PU_VIEW);
2753 update_view(creature_ptr);
2756 if (any_bits(creature_ptr->update, (PU_LITE))) {
2757 reset_bits(creature_ptr->update, PU_LITE);
2758 update_lite(creature_ptr);
2761 if (any_bits(creature_ptr->update, (PU_FLOW))) {
2762 reset_bits(creature_ptr->update, PU_FLOW);
2763 update_flow(creature_ptr);
2766 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
2767 reset_bits(creature_ptr->update, PU_DISTANCE);
2769 update_monsters(creature_ptr, TRUE);
2772 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
2773 reset_bits(creature_ptr->update, PU_MON_LITE);
2774 update_mon_lite(creature_ptr);
2777 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
2778 reset_bits(creature_ptr->update, PU_DELAY_VIS);
2779 delayed_visual_update(creature_ptr);
2782 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
2783 reset_bits(creature_ptr->update, PU_MONSTERS);
2784 update_monsters(creature_ptr, FALSE);
2789 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
2790 * @return 魔道書を一冊も持っていないならTRUEを返す
2792 bool player_has_no_spellbooks(player_type *creature_ptr)
2795 for (int i = 0; i < INVEN_PACK; i++) {
2796 o_ptr = &creature_ptr->inventory_list[i];
2797 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2801 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2802 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
2803 o_ptr = &floor_ptr->o_list[i];
2804 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2812 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
2815 * @return 配置に成功したらTRUE
2817 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
2819 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
2822 /* Save player location */
2823 creature_ptr->y = y;
2824 creature_ptr->x = x;
2829 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
2832 void wreck_the_pattern(player_type *creature_ptr)
2834 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2835 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
2836 if (pattern_type == PATTERN_TILE_WRECKED)
2839 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
2840 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
2842 if (!is_invuln(creature_ptr))
2843 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"));
2845 int to_ruin = randint1(45) + 35;
2848 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
2850 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
2851 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
2855 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
2859 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
2860 * Advance experience levels and print experience
2863 void check_experience(player_type *creature_ptr)
2865 if (creature_ptr->exp < 0)
2866 creature_ptr->exp = 0;
2867 if (creature_ptr->max_exp < 0)
2868 creature_ptr->max_exp = 0;
2869 if (creature_ptr->max_max_exp < 0)
2870 creature_ptr->max_max_exp = 0;
2872 if (creature_ptr->exp > PY_MAX_EXP)
2873 creature_ptr->exp = PY_MAX_EXP;
2874 if (creature_ptr->max_exp > PY_MAX_EXP)
2875 creature_ptr->max_exp = PY_MAX_EXP;
2876 if (creature_ptr->max_max_exp > PY_MAX_EXP)
2877 creature_ptr->max_max_exp = PY_MAX_EXP;
2879 if (creature_ptr->exp > creature_ptr->max_exp)
2880 creature_ptr->max_exp = creature_ptr->exp;
2881 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
2882 creature_ptr->max_max_exp = creature_ptr->max_exp;
2884 set_bits(creature_ptr->redraw, PR_EXP);
2885 handle_stuff(creature_ptr);
2887 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
2888 PLAYER_LEVEL old_lev = creature_ptr->lev;
2889 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
2890 creature_ptr->lev--;
2891 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2892 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
2893 set_bits(creature_ptr->window_flags, PW_PLAYER);
2894 handle_stuff(creature_ptr);
2897 bool level_reward = FALSE;
2898 bool level_mutation = FALSE;
2899 bool level_inc_stat = FALSE;
2900 while ((creature_ptr->lev < PY_MAX_LEVEL)
2901 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
2902 creature_ptr->lev++;
2903 if (creature_ptr->lev > creature_ptr->max_plv) {
2904 creature_ptr->max_plv = creature_ptr->lev;
2906 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || creature_ptr->muta.has(MUTA::CHAOS_GIFT)) {
2907 level_reward = TRUE;
2909 if (creature_ptr->prace == RACE_BEASTMAN) {
2911 level_mutation = TRUE;
2913 level_inc_stat = TRUE;
2915 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
2919 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
2920 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
2921 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
2922 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
2923 creature_ptr->level_up_message = TRUE;
2924 handle_stuff(creature_ptr);
2926 creature_ptr->level_up_message = FALSE;
2927 if (level_inc_stat) {
2928 if (!(creature_ptr->max_plv % 10)) {
2935 cnv_stat(creature_ptr->stat_max[0], tmp);
2936 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
2937 cnv_stat(creature_ptr->stat_max[1], tmp);
2938 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
2939 cnv_stat(creature_ptr->stat_max[2], tmp);
2940 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
2941 cnv_stat(creature_ptr->stat_max[3], tmp);
2942 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
2943 cnv_stat(creature_ptr->stat_max[4], tmp);
2944 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
2945 cnv_stat(creature_ptr->stat_max[5], tmp);
2946 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
2949 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
2953 if ((choice >= 'a') && (choice <= 'f'))
2956 for (n = 0; n < A_MAX; n++)
2957 if (n != choice - 'a')
2959 if (get_check(_("よろしいですか?", "Are you sure? ")))
2962 do_inc_stat(creature_ptr, choice - 'a');
2964 } else if (!(creature_ptr->max_plv % 2))
2965 do_inc_stat(creature_ptr, randint0(6));
2968 if (level_mutation) {
2969 msg_print(_("あなたは変わった気がする...", "You feel different..."));
2970 (void)gain_mutation(creature_ptr, 0);
2971 level_mutation = FALSE;
2975 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
2979 gain_level_reward(creature_ptr, 0);
2980 level_reward = FALSE;
2983 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2984 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
2985 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
2986 handle_stuff(creature_ptr);
2989 if (old_lev != creature_ptr->lev)
2990 autopick_load_pref(creature_ptr, FALSE);
2994 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
2996 * @param out_val 出力先文字列ポインタ
2999 void cnv_stat(int val, char *out_val)
3002 sprintf(out_val, " %2d", val);
3006 int bonus = (val - 18);
3008 sprintf(out_val, "18/%3s", "***");
3009 } else if (bonus >= 100) {
3010 sprintf(out_val, "18/%03d", bonus);
3012 sprintf(out_val, " 18/%02d", bonus);
3017 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
3018 * Modify a stat value by a "modifier", return new value
3020 * @param amount 加減算値
3024 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
3025 * Or even: 18/13, 18/23, 18/33, ..., 18/220
3026 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
3027 * Or even: 18/13, 18/03, 18, 17, ..., 3
3030 s16b modify_stat_value(int value, int amount)
3033 for (int i = 0; i < amount; i++) {
3039 } else if (amount < 0) {
3040 for (int i = 0; i < (0 - amount); i++) {
3041 if (value >= 18 + 10)
3043 else if (value > 18)
3055 * Hack -- Calculates the total number of points earned -JWT-
3059 long calc_score(player_type *creature_ptr)
3061 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
3074 if (ironman_small_levels)
3076 if (ironman_empty_levels)
3082 if (ironman_nightmare)
3089 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
3090 if (max_dlv[i] > max_dl)
3091 max_dl = max_dlv[i];
3093 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
3094 u32b point_h = point_l / 0x10000L;
3095 point_l = point_l % 0x10000L;
3098 point_h += point_l / 0x10000L;
3099 point_l %= 0x10000L;
3101 point_l += ((point_h % 100) << 16);
3105 u32b point = (point_h << 16) + (point_l);
3106 if (creature_ptr->arena_number >= 0)
3107 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
3109 if (ironman_downward)
3111 if (creature_ptr->pclass == CLASS_BERSERKER) {
3112 if (creature_ptr->prace == RACE_SPECTRE)
3116 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
3118 if (current_world_ptr->total_winner)
3123 point = (0 - point);
3129 * @param creature_ptr プレーヤーへの参照ポインタ
3130 * @return 祝福状態ならばTRUE
3132 bool is_blessed(player_type *creature_ptr)
3134 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
3137 bool is_tim_esp(player_type *creature_ptr)
3139 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3142 bool is_tim_stealth(player_type *creature_ptr)
3144 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
3147 bool is_time_limit_esp(player_type *creature_ptr)
3149 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3152 bool is_time_limit_stealth(player_type *creature_ptr)
3154 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
3157 bool can_two_hands_wielding(player_type *creature_ptr)
3159 return !creature_ptr->riding || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS);
3163 * @brief 口を使う継続的な処理を中断する
3164 * @param caster_ptr プレーヤーへの参照ポインタ
3167 void stop_mouth(player_type *caster_ptr)
3169 if (music_singing_any(caster_ptr))
3170 stop_singing(caster_ptr);
3171 if (hex_spelling_any(caster_ptr))
3172 stop_hex_spell_all(caster_ptr);
3175 bool is_fast(player_type *creature_ptr)
3177 return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO);
3180 bool is_invuln(player_type *creature_ptr)
3182 return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN);
3185 bool is_hero(player_type *creature_ptr)
3187 return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO);
3190 bool is_shero(player_type *creature_ptr)
3192 return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER;
3195 bool is_echizen(player_type *creature_ptr)
3197 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
3200 int calc_weapon_weight_limit(player_type *creature_ptr)
3202 int weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3204 if (has_two_handed_weapons(creature_ptr))
3210 static player_hand main_attack_hand(player_type *creature_ptr)
3212 switch (player_melee_type(creature_ptr)) {
3213 case MELEE_TYPE_BAREHAND_TWO:
3214 return PLAYER_HAND_MAIN;
3215 case MELEE_TYPE_BAREHAND_MAIN:
3216 return PLAYER_HAND_MAIN;
3217 case MELEE_TYPE_BAREHAND_SUB:
3218 return PLAYER_HAND_SUB;
3219 case MELEE_TYPE_WEAPON_MAIN:
3220 return PLAYER_HAND_MAIN;
3221 case MELEE_TYPE_WEAPON_SUB:
3222 return PLAYER_HAND_SUB;
3223 case MELEE_TYPE_WEAPON_TWOHAND:
3224 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
3225 case MELEE_TYPE_WEAPON_DOUBLE:
3226 return PLAYER_HAND_MAIN;
3227 case MELEE_TYPE_SHIELD_DOUBLE:
3228 return PLAYER_HAND_MAIN;
3230 return PLAYER_HAND_MAIN;