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-ability/player-basic-statistics.h"
64 #include "player-ability/player-speed.h"
65 #include "player-ability/player-stealth.h"
66 #include "player-info/avatar.h"
67 #include "player/attack-defense-types.h"
68 #include "player/digestion-processor.h"
69 #include "player/mimic-info-table.h"
70 #include "player/patron.h"
71 #include "player/player-class.h"
72 #include "player/player-damage.h"
73 #include "player/player-move.h"
74 #include "player/player-personalities-types.h"
75 #include "player/player-personality.h"
76 #include "player/player-race-types.h"
77 #include "player/player-skill.h"
78 #include "player/player-status-flags.h"
79 #include "player/player-status-table.h"
80 #include "player/player-view.h"
81 #include "player/race-info-table.h"
82 #include "player/special-defense-types.h"
83 #include "realm/realm-hex-numbers.h"
84 #include "realm/realm-names-table.h"
85 #include "realm/realm-song-numbers.h"
86 #include "specific-object/bow.h"
87 #include "specific-object/torch.h"
88 #include "spell-realm/spells-hex.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 bool is_martial_arts_mode(player_type *creature_ptr);
112 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr);
113 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
114 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
115 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
116 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
117 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
118 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
119 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
120 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
121 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
122 static bool is_heavy_wield(player_type *creature_ptr, int i);
123 static s16b calc_num_blow(player_type *creature_ptr, int i);
124 static s16b calc_to_magic_chance(player_type *creature_ptr);
125 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
126 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value);
127 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
128 static bool is_riding_two_hands(player_type *creature_ptr);
129 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
130 static void put_equipment_warning(player_type *creature_ptr);
132 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
133 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
135 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value);
137 static s16b calc_to_damage_misc(player_type *creature_ptr);
138 static s16b calc_to_hit_misc(player_type *creature_ptr);
140 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
141 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
143 static player_hand main_attack_hand(player_type *creature_ptr);
145 /*** Player information ***/
148 * @brief クリーチャーの抽象的善悪アライメントの表記名のみを返す。 / Return only alignment title
149 * @param creature_ptr 算出するクリーチャーの参照ポインタ。
152 concptr alignment_label(player_type *creature_ptr)
154 if (creature_ptr->align > 150)
155 return _("大善", "Lawful");
156 else if (creature_ptr->align > 50)
157 return _("中善", "Good");
158 else if (creature_ptr->align > 10)
159 return _("小善", "Neutral Good");
160 else if (creature_ptr->align > -11)
161 return _("中立", "Neutral");
162 else if (creature_ptr->align > -51)
163 return _("小悪", "Neutral Evil");
164 else if (creature_ptr->align > -151)
165 return _("中悪", "Evil");
167 return _("大悪", "Chaotic");
171 * @brief クリーチャーの抽象的善悪アライメントの表記を返す。 / Return alignment title
172 * @param creature_ptr 算出するクリーチャーの参照ポインタ。
173 * @return アライメントの表記を返す。
175 concptr your_alignment(player_type *creature_ptr, bool with_value)
177 auto s = alignment_label(creature_ptr);
178 if (with_value || show_actual_value)
179 return format(_("%s(%ld)", "%s (%ld)"), s, static_cast<long>(creature_ptr->align));
185 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
186 * @param weapon_exp 経験値
189 int weapon_exp_level(int weapon_exp)
191 if (weapon_exp < WEAPON_EXP_BEGINNER)
192 return EXP_LEVEL_UNSKILLED;
193 else if (weapon_exp < WEAPON_EXP_SKILLED)
194 return EXP_LEVEL_BEGINNER;
195 else if (weapon_exp < WEAPON_EXP_EXPERT)
196 return EXP_LEVEL_SKILLED;
197 else if (weapon_exp < WEAPON_EXP_MASTER)
198 return EXP_LEVEL_EXPERT;
200 return EXP_LEVEL_MASTER;
204 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
205 * @param weapon_exp 経験値
208 int riding_exp_level(int riding_exp)
210 if (riding_exp < RIDING_EXP_BEGINNER)
211 return EXP_LEVEL_UNSKILLED;
212 else if (riding_exp < RIDING_EXP_SKILLED)
213 return EXP_LEVEL_BEGINNER;
214 else if (riding_exp < RIDING_EXP_EXPERT)
215 return EXP_LEVEL_SKILLED;
216 else if (riding_exp < RIDING_EXP_MASTER)
217 return EXP_LEVEL_EXPERT;
219 return EXP_LEVEL_MASTER;
223 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
224 * @param spell_exp 経験値
227 int spell_exp_level(int spell_exp)
229 if (spell_exp < SPELL_EXP_BEGINNER)
230 return EXP_LEVEL_UNSKILLED;
231 else if (spell_exp < SPELL_EXP_SKILLED)
232 return EXP_LEVEL_BEGINNER;
233 else if (spell_exp < SPELL_EXP_EXPERT)
234 return EXP_LEVEL_SKILLED;
235 else if (spell_exp < SPELL_EXP_MASTER)
236 return EXP_LEVEL_EXPERT;
238 return EXP_LEVEL_MASTER;
242 * @brief 遅延描画更新 / Delayed visual update
243 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
244 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
245 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
248 static void delayed_visual_update(player_type *player_ptr)
250 floor_type *floor_ptr = player_ptr->current_floor_ptr;
251 for (int i = 0; i < floor_ptr->redraw_n; i++) {
252 POSITION y = floor_ptr->redraw_y[i];
253 POSITION x = floor_ptr->redraw_x[i];
255 g_ptr = &floor_ptr->grid_array[y][x];
256 if (none_bits(g_ptr->info, CAVE_REDRAW))
259 if (any_bits(g_ptr->info, CAVE_NOTE))
260 note_spot(player_ptr, y, x);
262 lite_spot(player_ptr, y, x);
264 update_monster(player_ptr, g_ptr->m_idx, FALSE);
266 reset_bits(g_ptr->info, (CAVE_NOTE | CAVE_REDRAW));
269 floor_ptr->redraw_n = 0;
273 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
274 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
275 * @return 重すぎるならばTRUE
277 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
279 int hold = adj_str_hold[creature_ptr->stat_index[A_STR]];
280 return (hold < o_ptr->weight / 10);
285 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
288 WEIGHT calc_inventory_weight(player_type *creature_ptr)
293 for (int i = 0; i < INVEN_TOTAL; i++) {
294 o_ptr = &creature_ptr->inventory_list[i];
297 weight += o_ptr->weight * o_ptr->number;
302 * @brief プレイヤーの全ステータスを更新する /
303 * Calculate the players current "state", taking into account
304 * not only race/class intrinsics, but also objects being worn
305 * and temporary spell effects.
309 * See also update_max_mana() and update_max_hitpoints().
311 * Take note of the new "speed code", in particular, a very strong
312 * player will start slowing down as soon as he reaches 150 pounds,
313 * but not until he reaches 450 pounds will he be half as fast as
314 * a normal kobold. This both hurts and helps the player, hurts
315 * because in the old days a player could just avoid 300 pounds,
316 * and helps because now carrying 300 pounds is not very painful.
318 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
319 * damage, since that would affect non-combat things. These values
320 * are actually added in later, at the appropriate place.
322 * This function induces various "status" messages.
324 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
326 static void update_bonuses(player_type *creature_ptr)
328 int empty_hands_status = empty_hands(creature_ptr, TRUE);
331 /* Save the old vision stuff */
332 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
333 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
334 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
335 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
336 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
337 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
338 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
339 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
340 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
341 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
342 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
343 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
344 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
345 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
346 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
347 s16b old_speed = creature_ptr->pspeed;
349 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
350 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
352 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
353 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
354 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
355 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
356 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
357 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
358 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
359 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
360 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
361 creature_ptr->esp_human = has_esp_human(creature_ptr);
362 creature_ptr->esp_good = has_esp_good(creature_ptr);
363 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
364 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
365 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
366 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
367 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
368 creature_ptr->down_saving = has_down_saving(creature_ptr);
369 creature_ptr->yoiyami = has_no_ac(creature_ptr);
370 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
371 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
372 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
373 creature_ptr->warning = has_warning(creature_ptr);
374 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
375 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
376 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
377 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
378 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
379 creature_ptr->see_inv = has_see_inv(creature_ptr);
380 creature_ptr->free_act = has_free_act(creature_ptr);
381 creature_ptr->levitation = has_levitation(creature_ptr);
382 creature_ptr->can_swim = has_can_swim(creature_ptr);
383 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
384 creature_ptr->regenerate = has_regenerate(creature_ptr);
385 update_curses(creature_ptr);
386 creature_ptr->impact = has_impact(creature_ptr);
387 creature_ptr->earthquake = has_earthquake(creature_ptr);
388 update_extra_blows(creature_ptr);
390 creature_ptr->lite = has_lite(creature_ptr);
392 if (any_bits(creature_ptr->special_defense, KAMAE_MASK)) {
393 if (none_bits(empty_hands_status, EMPTY_HAND_MAIN)) {
394 set_action(creature_ptr, ACTION_NONE);
398 creature_ptr->stat_add[A_STR] = PlayerStrength(creature_ptr).modification_value();
399 creature_ptr->stat_add[A_INT] = PlayerIntelligence(creature_ptr).modification_value();
400 creature_ptr->stat_add[A_WIS] = PlayerWisdom(creature_ptr).modification_value();
401 creature_ptr->stat_add[A_DEX] = PlayerDexterity(creature_ptr).modification_value();
402 creature_ptr->stat_add[A_CON] = PlayerConstitution(creature_ptr).modification_value();
403 creature_ptr->stat_add[A_CHR] = PlayerCharisma(creature_ptr).modification_value();
405 PlayerStrength(creature_ptr).update_value();
406 PlayerIntelligence(creature_ptr).update_value();
407 PlayerWisdom(creature_ptr).update_value();
408 PlayerDexterity(creature_ptr).update_value();
409 PlayerConstitution(creature_ptr).update_value();
410 PlayerCharisma(creature_ptr).update_value();
412 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
414 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
415 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
416 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
420 for (int i = 0; i < 2; i++) {
421 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
422 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
423 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
424 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
425 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
426 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_MAIN_HAND + i);
429 creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value();
430 creature_ptr->see_infra = calc_intra_vision(creature_ptr);
431 creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value();
432 creature_ptr->skill_dis = calc_disarming(creature_ptr);
433 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
434 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
435 creature_ptr->skill_srh = calc_search(creature_ptr);
436 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
437 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
438 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
439 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
440 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
441 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, TRUE);
442 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, TRUE);
443 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, FALSE);
444 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, FALSE);
445 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, TRUE);
446 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, TRUE);
447 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, FALSE);
448 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, FALSE);
449 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
450 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
451 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
452 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
453 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
454 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
455 creature_ptr->ac = calc_base_ac(creature_ptr);
456 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
457 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
458 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
460 if (old_mighty_throw != creature_ptr->mighty_throw) {
461 creature_ptr->window_flags |= PW_INVEN;
464 if (creature_ptr->telepathy != old_telepathy) {
465 set_bits(creature_ptr->update, PU_MONSTERS);
468 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
469 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
470 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
471 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
472 set_bits(creature_ptr->update, PU_MONSTERS);
475 if (creature_ptr->see_inv != old_see_inv) {
476 set_bits(creature_ptr->update, PU_MONSTERS);
479 if (creature_ptr->pspeed != old_speed) {
480 set_bits(creature_ptr->redraw, PR_SPEED);
483 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
484 set_bits(creature_ptr->redraw, PR_ARMOR);
485 set_bits(creature_ptr->window_flags, PW_PLAYER);
488 if (current_world_ptr->character_xtra)
491 put_equipment_warning(creature_ptr);
492 check_no_flowed(creature_ptr);
495 static void update_alignment(player_type *creature_ptr)
497 creature_ptr->align = 0;
498 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
499 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
502 m_ptr = &floor_ptr->m_list[m_idx];
503 if (!monster_is_valid(m_ptr))
505 r_ptr = &r_info[m_ptr->r_idx];
510 if (any_bits(r_ptr->flags3, RF3_GOOD))
511 creature_ptr->align += r_ptr->level;
512 if (any_bits(r_ptr->flags3, RF3_EVIL))
513 creature_ptr->align -= r_ptr->level;
516 if (creature_ptr->mimic_form) {
517 switch (creature_ptr->mimic_form) {
519 creature_ptr->align -= 200;
521 case MIMIC_DEMON_LORD:
522 creature_ptr->align -= 200;
526 switch (creature_ptr->prace) {
528 creature_ptr->align += 200;
531 creature_ptr->align -= 200;
539 for (int i = 0; i < 2; i++) {
540 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i))
542 if (creature_ptr->inventory_list[INVEN_MAIN_HAND + i].name1 != ART_IRON_BALL)
544 creature_ptr->align -= 1000;
549 for (int i = 0; i < 8; i++) {
550 switch (creature_ptr->vir_types[i]) {
552 creature_ptr->align += creature_ptr->virtues[i] * 2;
561 creature_ptr->align -= creature_ptr->virtues[i];
564 creature_ptr->align += creature_ptr->virtues[i];
569 for (int i = 0; i < j; i++) {
570 if (creature_ptr->align > 0) {
571 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
572 if (creature_ptr->align < 0)
573 creature_ptr->align = 0;
574 } else if (creature_ptr->align < 0) {
575 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
576 if (creature_ptr->align > 0)
577 creature_ptr->align = 0;
583 * @brief プレイヤーの最大HPを更新する /
584 * Update the players maximal hit points
585 * Adjust current hitpoints if necessary
589 static void update_max_hitpoints(player_type *creature_ptr)
591 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_index[A_CON]]) - 128) * creature_ptr->lev / 4;
592 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
595 if (creature_ptr->mimic_form) {
596 if (creature_ptr->pclass == CLASS_SORCERER)
597 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
599 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
600 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
603 if (creature_ptr->pclass == CLASS_SORCERER) {
604 if (creature_ptr->lev < 30)
605 mhp = (mhp * (45 + creature_ptr->lev) / 100);
607 mhp = (mhp * 75 / 100);
608 bonus = (bonus * 65 / 100);
613 if (creature_ptr->pclass == CLASS_BERSERKER) {
614 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
617 if (mhp < creature_ptr->lev + 1)
618 mhp = creature_ptr->lev + 1;
619 if (is_hero(creature_ptr))
621 if (is_shero(creature_ptr))
623 if (creature_ptr->tsuyoshi)
625 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
627 if (hex_spelling(creature_ptr, HEX_BUILDING))
629 if (creature_ptr->mhp == mhp)
632 if (creature_ptr->chp >= mhp) {
633 creature_ptr->chp = mhp;
634 creature_ptr->chp_frac = 0;
638 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
639 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
642 creature_ptr->mhp = mhp;
644 creature_ptr->redraw |= PR_HP;
645 creature_ptr->window_flags |= PW_PLAYER;
649 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
650 * Calculate number of spells player should have, and forget,
651 * or remember, spells until that number is properly reflected.
654 * Note that this function induces various "status" messages,
655 * which must be bypasses until the character is created.
657 static void update_num_of_spells(player_type *creature_ptr)
659 if (!mp_ptr->spell_book)
661 if (!current_world_ptr->character_generated)
663 if (current_world_ptr->character_xtra)
665 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
666 creature_ptr->new_spells = 0;
670 concptr p = spell_category_name(mp_ptr->spell_book);
671 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
675 int num_allowed = (adj_mag_study[creature_ptr->stat_index[mp_ptr->spell_stat]] * levels / 2);
677 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
681 if (creature_ptr->pclass == CLASS_SAMURAI) {
683 } else if (creature_ptr->realm2 == REALM_NONE) {
684 num_allowed = (num_allowed + 1) / 2;
685 if (num_allowed > (32 + bonus))
686 num_allowed = 32 + bonus;
687 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
688 if (num_allowed > (96 + bonus))
689 num_allowed = 96 + bonus;
691 if (num_allowed > (80 + bonus))
692 num_allowed = 80 + bonus;
695 int num_boukyaku = 0;
696 for (int j = 0; j < 64; j++) {
697 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
702 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
703 for (int i = 63; i >= 0; i--) {
704 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
707 int j = creature_ptr->spell_order[i];
711 const magic_type *s_ptr;
712 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
714 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
716 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
718 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
720 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
722 if (s_ptr->slevel <= creature_ptr->lev)
725 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
726 if (!is_spell_learned)
731 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
732 which = creature_ptr->realm1;
734 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
735 which = creature_ptr->realm2;
739 reset_bits(creature_ptr->spell_learned1, (1UL << j));
740 which = creature_ptr->realm1;
742 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
743 which = creature_ptr->realm2;
747 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
749 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
751 creature_ptr->new_spells++;
754 /* Forget spells if we know too many spells */
755 for (int i = 63; i >= 0; i--) {
756 if (creature_ptr->new_spells >= 0)
758 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
761 int j = creature_ptr->spell_order[i];
765 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
766 if (!is_spell_learned)
771 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
772 which = creature_ptr->realm1;
774 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
775 which = creature_ptr->realm2;
779 reset_bits(creature_ptr->spell_learned1, (1UL << j));
780 which = creature_ptr->realm1;
782 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
783 which = creature_ptr->realm2;
787 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
789 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
791 creature_ptr->new_spells++;
794 /* Check for spells to remember */
795 for (int i = 0; i < 64; i++) {
796 if (creature_ptr->new_spells <= 0)
798 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
800 int j = creature_ptr->spell_order[i];
804 const magic_type *s_ptr;
805 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
807 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
809 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
811 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
813 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
815 if (s_ptr->slevel > creature_ptr->lev)
818 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
819 if (!is_spell_learned)
824 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
825 which = creature_ptr->realm1;
827 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
828 which = creature_ptr->realm2;
832 set_bits(creature_ptr->spell_learned1, (1UL << j));
833 which = creature_ptr->realm1;
835 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
836 which = creature_ptr->realm2;
840 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
842 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
844 creature_ptr->new_spells--;
847 if (creature_ptr->realm2 == REALM_NONE) {
849 for (int j = 0; j < 32; j++) {
850 const magic_type *s_ptr;
851 if (!is_magic(creature_ptr->realm1))
852 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
854 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
856 if (s_ptr->slevel > creature_ptr->lev)
859 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
868 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
869 creature_ptr->new_spells = (s16b)k;
873 if (creature_ptr->new_spells < 0)
874 creature_ptr->new_spells = 0;
876 if (creature_ptr->old_spells == creature_ptr->new_spells)
879 if (creature_ptr->new_spells) {
881 if (creature_ptr->new_spells < 10) {
882 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
884 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
887 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
891 creature_ptr->old_spells = creature_ptr->new_spells;
892 set_bits(creature_ptr->redraw, PR_STUDY);
893 set_bits(creature_ptr->window_flags, PW_OBJECT);
897 * @brief プレイヤーの最大MPを更新する /
898 * Update maximum mana. You do not need to know any spells.
899 * Note that mana is lowered by heavy (or inappropriate) armor.
902 * This function induces status messages.
904 static void update_max_mana(player_type *creature_ptr)
906 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
910 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)
911 || creature_ptr->pclass == CLASS_ELEMENTALIST) {
912 levels = creature_ptr->lev;
914 if (mp_ptr->spell_first > creature_ptr->lev) {
915 creature_ptr->msp = 0;
916 set_bits(creature_ptr->redraw, PR_MANA);
920 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
924 if (creature_ptr->pclass == CLASS_SAMURAI) {
925 msp = (adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] + 10) * 2;
927 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
929 msp = adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] * (levels + 3) / 4;
933 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
934 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
936 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
938 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
939 msp += msp * (25 + creature_ptr->lev) / 100;
942 if (any_bits(mp_ptr->spell_xtra, MAGIC_GLOVE_REDUCE_MANA)) {
943 BIT_FLAGS flgs[TR_FLAG_SIZE];
944 creature_ptr->cumber_glove = FALSE;
946 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
947 object_flags(creature_ptr, o_ptr, flgs);
948 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
949 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
950 creature_ptr->cumber_glove = TRUE;
955 creature_ptr->cumber_armor = FALSE;
958 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
959 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
960 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
961 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
962 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
963 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
964 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
965 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
966 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
968 switch (creature_ptr->pclass) {
970 case CLASS_HIGH_MAGE:
971 case CLASS_BLUE_MAGE:
973 case CLASS_FORCETRAINER:
975 case CLASS_ELEMENTALIST: {
976 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
977 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
978 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
979 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
984 case CLASS_TOURIST: {
985 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
986 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
987 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
988 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
991 case CLASS_MINDCRAFTER:
992 case CLASS_BEASTMASTER:
993 case CLASS_MIRROR_MASTER: {
994 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
995 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
996 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
997 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
1002 case CLASS_RED_MAGE:
1003 case CLASS_WARRIOR_MAGE: {
1004 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
1005 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
1006 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
1007 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
1011 case CLASS_CHAOS_WARRIOR: {
1012 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
1013 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
1014 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
1015 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
1023 int max_wgt = mp_ptr->spell_weight;
1024 if ((cur_wgt - max_wgt) > 0) {
1025 creature_ptr->cumber_armor = TRUE;
1026 switch (creature_ptr->pclass) {
1028 case CLASS_HIGH_MAGE:
1029 case CLASS_BLUE_MAGE:
1030 case CLASS_ELEMENTALIST: {
1031 msp -= msp * (cur_wgt - max_wgt) / 600;
1035 case CLASS_MINDCRAFTER:
1036 case CLASS_BEASTMASTER:
1038 case CLASS_FORCETRAINER:
1040 case CLASS_MIRROR_MASTER: {
1041 msp -= msp * (cur_wgt - max_wgt) / 800;
1044 case CLASS_SORCERER: {
1045 msp -= msp * (cur_wgt - max_wgt) / 900;
1051 case CLASS_RED_MAGE: {
1052 msp -= msp * (cur_wgt - max_wgt) / 1000;
1056 case CLASS_CHAOS_WARRIOR:
1057 case CLASS_WARRIOR_MAGE: {
1058 msp -= msp * (cur_wgt - max_wgt) / 1200;
1061 case CLASS_SAMURAI: {
1062 creature_ptr->cumber_armor = FALSE;
1066 msp -= msp * (cur_wgt - max_wgt) / 800;
1075 if (creature_ptr->msp != msp) {
1076 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1077 creature_ptr->csp = msp;
1078 creature_ptr->csp_frac = 0;
1082 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1083 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1086 creature_ptr->msp = msp;
1087 set_bits(creature_ptr->redraw, PR_MANA);
1088 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
1091 if (current_world_ptr->character_xtra)
1094 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1095 if (creature_ptr->cumber_glove)
1096 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1098 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1100 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1103 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1106 if (creature_ptr->cumber_armor)
1107 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1109 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1111 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1115 * @brief 装備中の射撃武器の威力倍率を返す /
1116 * calcurate the fire rate of target object
1117 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1118 * @return 射撃倍率の値(100で1.00倍)
1120 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1122 int extra_shots = 0;
1123 BIT_FLAGS flgs[TR_FLAG_SIZE];
1125 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1127 q_ptr = &creature_ptr->inventory_list[i];
1134 object_flags(creature_ptr, q_ptr, flgs);
1135 if (has_flag(flgs, TR_XTRA_SHOTS))
1139 object_flags(creature_ptr, o_ptr, flgs);
1140 if (has_flag(flgs, TR_XTRA_SHOTS))
1144 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1148 num += (extra_shots * 100);
1150 tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
1151 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1152 num += (creature_ptr->lev * 4);
1155 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1156 num += (creature_ptr->lev * 3);
1159 if (creature_ptr->pclass == CLASS_ARCHER) {
1160 if (tval_ammo == TV_ARROW)
1161 num += ((creature_ptr->lev * 5) + 50);
1162 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1163 num += (creature_ptr->lev * 4);
1166 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1167 num += (creature_ptr->lev * 2);
1170 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1171 num += (creature_ptr->lev * 4);
1179 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1183 * * 変異MUT3_INFRAVISによる加算(+3)
1184 * * 魔法効果tim_infraによる加算(+3)
1185 * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1)
1187 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr)
1189 ACTION_SKILL_POWER pow;
1190 const player_race *tmp_rp_ptr;
1192 if (creature_ptr->mimic_form)
1193 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1195 tmp_rp_ptr = &race_info[creature_ptr->prace];
1197 pow = tmp_rp_ptr->infra;
1199 if (creature_ptr->muta.has(MUTA::INFRAVIS)) {
1203 if (creature_ptr->tim_infra) {
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_INFRA))
1223 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1227 * * 職業と性格とレベルによる追加加算
1228 * * 器用さに応じたadj_dex_disテーブルによる加算
1229 * * 知力に応じたadj_int_disテーブルによる加算
1231 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1233 ACTION_SKILL_POWER pow;
1234 const player_race *tmp_rp_ptr;
1236 if (creature_ptr->mimic_form)
1237 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1239 tmp_rp_ptr = &race_info[creature_ptr->prace];
1240 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1241 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1243 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1244 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1245 pow += adj_dex_dis[creature_ptr->stat_index[A_DEX]];
1246 pow += adj_int_dis[creature_ptr->stat_index[A_INT]];
1252 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1256 * * 職業と性格とレベルによる追加加算
1257 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1258 * * 知力に応じたadj_int_devテーブルによる加算
1261 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1263 ACTION_SKILL_POWER pow;
1264 const player_race *tmp_rp_ptr;
1266 if (creature_ptr->mimic_form)
1267 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1269 tmp_rp_ptr = &race_info[creature_ptr->prace];
1270 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1271 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1273 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1274 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1276 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1278 BIT_FLAGS flgs[TR_FLAG_SIZE];
1279 o_ptr = &creature_ptr->inventory_list[i];
1282 object_flags(creature_ptr, o_ptr, flgs);
1283 if (has_flag(flgs, TR_MAGIC_MASTERY))
1284 pow += 8 * o_ptr->pval;
1287 pow += adj_int_dev[creature_ptr->stat_index[A_INT]];
1289 if (is_shero(creature_ptr)) {
1297 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1301 * * 職業と性格とレベルによる追加加算
1302 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1303 * * 呪力耐性の装備による加算(30)
1304 * * 祝福された装備による加算(5 + レベル / 10)
1305 * * 賢さによるadj_wis_savテーブル加算
1307 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1308 * * クターのつぶれ状態なら(10に上書き)
1309 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1310 * * 呪いのdown_savingがかかっているなら半減
1312 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1314 ACTION_SKILL_POWER pow;
1315 const player_race *tmp_rp_ptr;
1317 if (creature_ptr->mimic_form)
1318 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1320 tmp_rp_ptr = &race_info[creature_ptr->prace];
1321 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1322 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1324 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1325 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1327 if (creature_ptr->muta.has(MUTA::MAGIC_RES))
1328 pow += (15 + (creature_ptr->lev / 5));
1330 if (has_resist_curse(creature_ptr))
1333 if (creature_ptr->blessed)
1334 pow += 6 + (creature_ptr->lev - 1) / 10;
1336 pow += adj_wis_sav[creature_ptr->stat_index[A_WIS]];
1338 if (is_shero(creature_ptr))
1341 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1342 pow = 90 + creature_ptr->lev;
1344 if (creature_ptr->tsubureru)
1347 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1348 pow = 95 + creature_ptr->lev;
1350 if (creature_ptr->down_saving)
1358 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1363 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1365 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1367 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1369 ACTION_SKILL_POWER pow;
1370 const player_race *tmp_rp_ptr;
1372 if (creature_ptr->mimic_form)
1373 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1375 tmp_rp_ptr = &race_info[creature_ptr->prace];
1376 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1377 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1379 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1380 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1382 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1384 BIT_FLAGS flgs[TR_FLAG_SIZE];
1385 o_ptr = &creature_ptr->inventory_list[i];
1388 object_flags(creature_ptr, o_ptr, flgs);
1389 if (has_flag(flgs, TR_SEARCH))
1390 pow += (o_ptr->pval * 5);
1393 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1397 if (is_shero(creature_ptr)) {
1406 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1411 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1413 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1415 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1417 ACTION_SKILL_POWER pow;
1418 const player_race *tmp_rp_ptr;
1420 if (creature_ptr->mimic_form)
1421 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1423 tmp_rp_ptr = &race_info[creature_ptr->prace];
1424 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1425 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1427 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1428 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1430 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1432 BIT_FLAGS flgs[TR_FLAG_SIZE];
1433 o_ptr = &creature_ptr->inventory_list[i];
1436 object_flags(creature_ptr, o_ptr, flgs);
1437 if (has_flag(flgs, TR_SEARCH))
1438 pow += (o_ptr->pval * 5);
1441 if (is_shero(creature_ptr)) {
1445 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1454 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1457 * * 種族/職業/性格による加算とレベルによる追加加算
1459 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1461 ACTION_SKILL_POWER pow;
1462 const player_race *tmp_rp_ptr;
1463 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1464 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1466 if (creature_ptr->mimic_form)
1467 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1469 tmp_rp_ptr = &race_info[creature_ptr->prace];
1471 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1472 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1478 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1481 * * 種族/職業/性格による加算とレベルによる追加加算
1483 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1485 ACTION_SKILL_POWER pow;
1486 const player_race *tmp_rp_ptr;
1487 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1488 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1490 if (creature_ptr->mimic_form)
1491 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1493 tmp_rp_ptr = &race_info[creature_ptr->prace];
1495 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1496 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1502 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1505 * * 種族/職業/性格による加算とレベルによる追加加算
1508 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1510 ACTION_SKILL_POWER pow;
1511 const player_race *tmp_rp_ptr;
1512 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1513 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1515 if (creature_ptr->mimic_form)
1516 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1518 tmp_rp_ptr = &race_info[creature_ptr->prace];
1520 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1521 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1523 if (is_shero(creature_ptr)) {
1532 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1543 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1546 BIT_FLAGS flgs[TR_FLAG_SIZE];
1548 ACTION_SKILL_POWER pow;
1552 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1553 pow += creature_ptr->lev * 10;
1556 if (is_shero(creature_ptr))
1559 pow += adj_str_dig[creature_ptr->stat_index[A_STR]];
1561 if (creature_ptr->pclass == CLASS_BERSERKER)
1562 pow += (100 + creature_ptr->lev * 8);
1564 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1565 o_ptr = &creature_ptr->inventory_list[i];
1568 object_flags(creature_ptr, o_ptr, flgs);
1569 if (has_flag(flgs, TR_TUNNEL))
1570 pow += (o_ptr->pval * 20);
1573 for (int i = 0; i < 2; i++) {
1574 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1575 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1576 pow += (o_ptr->weight / 10);
1580 if (is_shero(creature_ptr)) {
1590 static bool is_martial_arts_mode(player_type *creature_ptr)
1592 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1593 && (any_bits(empty_hands(creature_ptr, TRUE), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1596 static bool is_heavy_wield(player_type *creature_ptr, int i)
1598 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1600 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1603 static s16b calc_num_blow(player_type *creature_ptr, int i)
1606 BIT_FLAGS flgs[TR_FLAG_SIZE];
1609 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1610 object_flags(creature_ptr, o_ptr, flgs);
1611 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1612 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1613 int str_index, dex_index;
1614 int num = 0, wgt = 0, mul = 0, div = 0;
1616 num = class_info[creature_ptr->pclass].num;
1617 wgt = class_info[creature_ptr->pclass].wgt;
1618 mul = class_info[creature_ptr->pclass].mul;
1620 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1626 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1632 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1633 str_index = (adj_str_blow[creature_ptr->stat_index[A_STR]] * mul / div);
1635 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1637 if (creature_ptr->pclass == CLASS_NINJA)
1638 str_index = MAX(0, str_index - 1);
1642 dex_index = (adj_dex_blow[creature_ptr->stat_index[A_DEX]]);
1646 num_blow = blows_table[str_index][dex_index];
1648 num_blow = (s16b)num;
1650 num_blow += (s16b)creature_ptr->extra_blows[i];
1651 if (creature_ptr->pclass == CLASS_WARRIOR)
1652 num_blow += (creature_ptr->lev / 40);
1653 else if (creature_ptr->pclass == CLASS_BERSERKER)
1654 num_blow += (creature_ptr->lev / 23);
1655 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_index[A_DEX] >= 30))
1658 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1661 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1671 /* Different calculation for monks with empty hands */
1672 if (is_martial_arts_mode(creature_ptr)) {
1673 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_index[A_DEX]];
1676 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1702 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1705 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1707 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1711 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1715 num_blow += 1 + creature_ptr->extra_blows[0];
1718 if (has_not_ninja_weapon(creature_ptr, i)) {
1729 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1732 * * 性格なまけものなら加算(+10)
1734 * * 性格ちからじまんとがまんづよいなら加算(+1)
1735 * * 性格チャージマンなら加算(+5)
1736 * * 装備品にTRC_HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
1738 static s16b calc_to_magic_chance(player_type *creature_ptr)
1742 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
1744 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
1746 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
1748 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
1751 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1753 BIT_FLAGS flgs[TR_FLAG_SIZE];
1754 o_ptr = &creature_ptr->inventory_list[i];
1757 object_flags(creature_ptr, o_ptr, flgs);
1758 if (any_bits(o_ptr->curse_flags, TRC_HARD_SPELL)) {
1759 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
1769 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
1771 ARMOUR_CLASS ac = 0;
1772 if (creature_ptr->yoiyami)
1775 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1777 o_ptr = &creature_ptr->inventory_list[i];
1783 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
1784 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1785 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
1791 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
1793 ARMOUR_CLASS ac = 0;
1794 BIT_FLAGS flags[TR_FLAG_SIZE];
1795 if (creature_ptr->yoiyami)
1798 ac += ((int)(adj_dex_ta[creature_ptr->stat_index[A_DEX]]) - 128);
1800 if (creature_ptr->mimic_form) {
1801 switch (creature_ptr->mimic_form) {
1805 case MIMIC_DEMON_LORD:
1813 if (creature_ptr->pclass == CLASS_BERSERKER) {
1814 ac += 10 + creature_ptr->lev / 2;
1816 if (creature_ptr->pclass == CLASS_SORCERER) {
1820 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1822 o_ptr = &creature_ptr->inventory_list[i];
1823 object_flags(creature_ptr, o_ptr, flags);
1826 if (is_real_value || object_is_known(o_ptr))
1829 if (any_bits(o_ptr->curse_flags, TRC_LOW_AC)) {
1830 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
1831 if (is_real_value || object_is_fully_known(o_ptr))
1834 if (is_real_value || object_is_fully_known(o_ptr))
1839 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
1844 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
1845 ac += 10 + (creature_ptr->lev * 2 / 5);
1848 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
1852 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1853 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1857 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
1861 if (creature_ptr->muta.has(MUTA::WART_SKIN)) {
1865 if (creature_ptr->muta.has(MUTA::SCALES)) {
1869 if (creature_ptr->muta.has(MUTA::IRON_SKIN)) {
1873 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
1874 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
1875 ac += (creature_ptr->lev * 3) / 2;
1877 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
1878 ac += ((creature_ptr->lev - 13) / 3);
1880 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
1881 ac += ((creature_ptr->lev - 8) / 3);
1883 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
1884 ac += (creature_ptr->lev - 2) / 3;
1886 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
1887 ac += (creature_ptr->lev / 2);
1889 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
1890 ac += (creature_ptr->lev / 3);
1894 if (creature_ptr->realm1 == REALM_HEX) {
1895 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
1899 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
1900 object_type *o_ptr = &creature_ptr->inventory_list[i];
1903 if (!object_is_armour(creature_ptr, o_ptr))
1905 if (!object_is_cursed(o_ptr))
1907 if (any_bits(o_ptr->curse_flags, TRC_CURSED))
1909 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE))
1911 if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE))
1916 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1917 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
1918 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1920 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
1922 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1926 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
1928 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
1932 if (is_blessed(creature_ptr)) {
1936 if (is_shero(creature_ptr)) {
1940 if (creature_ptr->pclass == CLASS_NINJA) {
1941 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1942 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1943 ac += creature_ptr->lev / 2 + 5;
1951 * @brief 二刀流ペナルティ量計算
1952 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1953 * @param slot ペナルティ量を計算する武器スロット
1958 * * EASY2_WEAPONによる軽減
1959 * * SUPPORTIVEを左に装備した場合の軽減
1963 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
1966 BIT_FLAGS flags[TR_FLAG_SIZE];
1968 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1969 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
1971 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
1972 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
1973 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
1974 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
1975 penalty = penalty / 2 - 5;
1978 for (unsigned int i = FLAG_CAUSE_INVEN_MAIN_HAND; i < FLAG_CAUSE_MAX; i <<= 1)
1979 if (penalty > 0 && any_bits(creature_ptr->easy_2weapon, i))
1982 if (has_flag(flags, TR_SUPPORTIVE))
1983 penalty = MAX(0, penalty - 10);
1985 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1986 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1987 penalty = MIN(0, penalty);
1990 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
1993 return (s16b)penalty;
1996 static bool is_riding_two_hands(player_type *creature_ptr)
1998 if (!creature_ptr->riding) {
2002 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
2004 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
2005 switch (creature_ptr->pclass) {
2007 case CLASS_FORCETRAINER:
2008 case CLASS_BERSERKER:
2009 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
2010 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
2021 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
2023 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2024 if (!creature_ptr->riding)
2029 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2030 if (creature_ptr->tval_ammo != TV_ARROW)
2033 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2039 if (creature_ptr->tval_ammo == TV_BOLT)
2045 void put_equipment_warning(player_type *creature_ptr)
2047 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
2048 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
2050 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2051 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
2052 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2054 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2056 creature_ptr->old_heavy_shoot = heavy_shoot;
2059 for (int i = 0; i < 2; i++) {
2060 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
2061 if (creature_ptr->heavy_wield[i]) {
2062 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2063 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2064 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2065 } else if (creature_ptr->heavy_wield[1 - i]) {
2066 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
2068 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2071 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
2074 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
2075 if (creature_ptr->riding_wield[i]) {
2076 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2077 } else if (!creature_ptr->riding) {
2078 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
2079 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2080 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2083 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
2086 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
2089 if (creature_ptr->icky_wield[i]) {
2090 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2091 if (current_world_ptr->is_loading_now) {
2092 chg_virtue(creature_ptr, V_FAITH, -1);
2094 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2095 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2097 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2100 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
2103 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
2104 if (creature_ptr->riding_ryoute) {
2106 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2108 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
2112 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2114 msg_print("You began to control the pet you're riding with one hand.");
2118 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
2121 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
2122 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
2123 if (heavy_armor(creature_ptr)) {
2124 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2125 if (current_world_ptr->is_loading_now) {
2126 chg_virtue(creature_ptr, V_HARMONY, -1);
2129 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2132 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
2136 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2138 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2139 BIT_FLAGS flgs[TR_FLAG_SIZE];
2140 object_flags(creature_ptr, o_ptr, flgs);
2142 player_hand calc_hand = PLAYER_HAND_OTHER;
2143 if (slot == INVEN_MAIN_HAND)
2144 calc_hand = PLAYER_HAND_MAIN;
2145 if (slot == INVEN_SUB_HAND)
2146 calc_hand = PLAYER_HAND_SUB;
2149 damage += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2151 if (is_shero(creature_ptr)) {
2152 damage += 3 + (creature_ptr->lev / 5);
2155 if (creature_ptr->stun > 50) {
2157 } else if (creature_ptr->stun) {
2161 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2163 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2164 damage += creature_ptr->lev / 6;
2165 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2166 damage += creature_ptr->lev / 6;
2168 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2169 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2174 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
2175 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
2176 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2177 damage += get_current_ki(creature_ptr) / 5;
2181 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2182 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2183 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
2186 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
2189 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
2195 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2197 o_ptr = &creature_ptr->inventory_list[i];
2198 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2199 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2202 if (!object_is_known(o_ptr) && !is_real_value)
2204 bonus_to_d = o_ptr->to_d;
2206 if (creature_ptr->pclass == CLASS_NINJA) {
2207 if (o_ptr->to_d > 0)
2208 bonus_to_d = (o_ptr->to_d + 1) / 2;
2211 switch (player_melee_type(creature_ptr)) {
2212 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2213 case MELEE_TYPE_WEAPON_TWOHAND:
2214 if (calc_hand == main_attack_hand(creature_ptr))
2215 damage += (s16b)bonus_to_d;
2218 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2219 case MELEE_TYPE_WEAPON_MAIN:
2220 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2221 damage += (s16b)bonus_to_d;
2224 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2225 case MELEE_TYPE_WEAPON_SUB:
2226 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2227 damage += (s16b)bonus_to_d;
2230 case MELEE_TYPE_WEAPON_DOUBLE:
2231 if (calc_hand == PLAYER_HAND_MAIN) {
2232 if (i == INVEN_MAIN_RING) {
2233 damage += (s16b)bonus_to_d;
2234 } else if (i != INVEN_SUB_RING) {
2235 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2238 if (calc_hand == PLAYER_HAND_SUB) {
2239 if (i == INVEN_SUB_RING) {
2240 damage += (s16b)bonus_to_d;
2241 } else if (i != INVEN_MAIN_RING) {
2242 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2247 case MELEE_TYPE_SHIELD_DOUBLE:
2255 if (main_attack_hand(creature_ptr) == calc_hand) {
2256 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2257 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2259 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128) / 2;
2260 damage += MAX(bonus_to_d, 1);
2264 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2265 damage += (creature_ptr->lev / 6);
2268 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
2269 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2270 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2271 damage -= (creature_ptr->lev / 6);
2279 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
2281 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
2283 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2288 hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2289 hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2291 /* Temporary bonuses */
2292 if (is_blessed(creature_ptr)) {
2296 if (is_hero(creature_ptr)) {
2300 if (is_shero(creature_ptr)) {
2304 if (creature_ptr->stun > 50) {
2306 } else if (creature_ptr->stun) {
2310 player_hand calc_hand = PLAYER_HAND_OTHER;
2311 if (slot == INVEN_MAIN_HAND)
2312 calc_hand = PLAYER_HAND_MAIN;
2313 if (slot == INVEN_SUB_HAND)
2314 calc_hand = PLAYER_HAND_SUB;
2316 /* Default hand bonuses */
2317 if (main_attack_hand(creature_ptr) == calc_hand) {
2318 switch (player_melee_type(creature_ptr)) {
2319 case MELEE_TYPE_BAREHAND_MAIN:
2320 if (creature_ptr->riding)
2323 case MELEE_TYPE_BAREHAND_SUB:
2324 if (creature_ptr->riding)
2327 case MELEE_TYPE_BAREHAND_TWO:
2328 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2335 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2336 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2338 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);
2339 hit += MAX(bonus_to_h, 1);
2343 /* Bonuses and penalties by weapon */
2344 if (has_melee_weapon(creature_ptr, slot)) {
2345 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2346 BIT_FLAGS flgs[TR_FLAG_SIZE];
2347 object_flags(creature_ptr, o_ptr, flgs);
2349 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
2350 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
2352 /* Traind bonuses */
2353 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2355 /* Weight penalty */
2356 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
2357 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2360 /* Low melee penalty */
2361 if ((object_is_fully_known(o_ptr) || is_real_value) && any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
2362 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2369 /* Riding bonus and penalty */
2370 if (creature_ptr->riding) {
2371 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2376 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2377 && !has_flag(flgs, TR_RIDING)) {
2379 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2382 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2387 hit -= (s16b)penalty;
2390 /* Class penalties */
2391 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2393 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2394 hit += creature_ptr->lev / 5;
2395 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2396 hit += creature_ptr->lev / 5;
2398 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2399 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2406 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
2410 /* Hex realm bonuses */
2411 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2412 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
2415 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
2418 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
2421 if (any_bits(o_ptr->curse_flags, (TRC_TY_CURSE))) {
2427 /* Bonuses from inventory */
2428 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2429 object_type *o_ptr = &creature_ptr->inventory_list[i];
2431 /* Ignore empty hands, handed weapons, bows and capture balls */
2432 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2433 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2436 /* Fake value does not include unknown objects' value */
2437 if (!object_is_known(o_ptr) && !is_real_value)
2440 int bonus_to_h = o_ptr->to_h;
2442 /* When wields only a weapon */
2443 if (creature_ptr->pclass == CLASS_NINJA) {
2444 if (o_ptr->to_h > 0)
2445 bonus_to_h = (o_ptr->to_h + 1) / 2;
2448 switch (player_melee_type(creature_ptr)) {
2449 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2450 case MELEE_TYPE_WEAPON_TWOHAND:
2451 if (calc_hand == main_attack_hand(creature_ptr))
2452 hit += (s16b)bonus_to_h;
2455 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2456 case MELEE_TYPE_WEAPON_MAIN:
2457 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2458 hit += (s16b)bonus_to_h;
2461 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2462 case MELEE_TYPE_WEAPON_SUB:
2463 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2464 hit += (s16b)bonus_to_h;
2467 case MELEE_TYPE_WEAPON_DOUBLE:
2468 if (calc_hand == PLAYER_HAND_MAIN) {
2469 if (i == INVEN_MAIN_RING) {
2470 hit += (s16b)bonus_to_h;
2471 } else if (i != INVEN_SUB_RING) {
2472 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2475 if (calc_hand == PLAYER_HAND_SUB) {
2476 if (i == INVEN_SUB_RING) {
2477 hit += (s16b)bonus_to_h;
2478 } else if (i != INVEN_MAIN_RING) {
2479 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2484 case MELEE_TYPE_SHIELD_DOUBLE:
2492 /* Martial arts bonus */
2493 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2494 hit += (creature_ptr->lev / 3);
2497 /* Two handed combat penalty */
2498 hit -= calc_double_weapon_penalty(creature_ptr, slot);
2500 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
2501 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2502 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2503 hit -= (creature_ptr->lev / 3);
2510 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
2514 pow += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2515 pow += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2519 BIT_FLAGS flgs[TR_FLAG_SIZE];
2520 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2522 object_flags(creature_ptr, o_ptr, flgs);
2524 if (any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
2525 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2534 if (creature_ptr->stun > 50) {
2536 } else if (creature_ptr->stun) {
2540 if (is_blessed(creature_ptr)) {
2544 if (is_hero(creature_ptr)) {
2548 if (is_shero(creature_ptr)) {
2552 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2554 if (is_heavy_shoot(creature_ptr, o_ptr)) {
2555 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2559 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
2560 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
2561 pow += (10 + (creature_ptr->lev / 5));
2567 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2569 o_ptr = &creature_ptr->inventory_list[i];
2570 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2571 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2574 bonus_to_h = o_ptr->to_h;
2576 if (creature_ptr->pclass == CLASS_NINJA) {
2577 if (o_ptr->to_h > 0)
2578 bonus_to_h = (o_ptr->to_h + 1) / 2;
2581 if (is_real_value || object_is_known(o_ptr))
2582 pow += (s16b)bonus_to_h;
2585 pow -= calc_riding_bow_penalty(creature_ptr);
2590 static s16b calc_to_damage_misc(player_type *creature_ptr)
2593 BIT_FLAGS flgs[TR_FLAG_SIZE];
2597 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2598 o_ptr = &creature_ptr->inventory_list[i];
2602 object_flags(creature_ptr, o_ptr, flgs);
2604 int bonus_to_d = o_ptr->to_d;
2605 if (creature_ptr->pclass == CLASS_NINJA) {
2606 if (o_ptr->to_d > 0)
2607 bonus_to_d = (o_ptr->to_d + 1) / 2;
2609 to_dam += (s16b)bonus_to_d;
2612 if (is_shero(creature_ptr)) {
2613 to_dam += 3 + (creature_ptr->lev / 5);
2616 if (creature_ptr->stun > 50) {
2618 } else if (creature_ptr->stun) {
2622 to_dam += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2626 static s16b calc_to_hit_misc(player_type *creature_ptr)
2629 BIT_FLAGS flgs[TR_FLAG_SIZE];
2633 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2634 o_ptr = &creature_ptr->inventory_list[i];
2638 object_flags(creature_ptr, o_ptr, flgs);
2640 int bonus_to_h = o_ptr->to_h;
2641 if (creature_ptr->pclass == CLASS_NINJA) {
2642 if (o_ptr->to_h > 0)
2643 bonus_to_h = (o_ptr->to_h + 1) / 2;
2645 to_hit += (s16b)bonus_to_h;
2648 if (is_blessed(creature_ptr)) {
2652 if (is_hero(creature_ptr)) {
2656 if (is_shero(creature_ptr)) {
2660 if (creature_ptr->stun > 50) {
2662 } else if (creature_ptr->stun) {
2666 to_hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2667 to_hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2672 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
2674 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2677 if (creature_ptr->riding) {
2678 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2686 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
2688 (void)creature_ptr; // unused
2689 (void)slot; // unused
2694 * @brief プレイヤーの所持重量制限を計算する /
2695 * Computes current weight limit.
2698 WEIGHT calc_weight_limit(player_type *creature_ptr)
2700 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_index[A_STR]] * 50;
2701 if (creature_ptr->pclass == CLASS_BERSERKER)
2707 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
2708 * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND)
2709 * @return 持っているならばTRUE
2711 bool has_melee_weapon(player_type *creature_ptr, int slot)
2713 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
2717 * @brief プレイヤーの現在開いている手の状態を返す
2718 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
2719 * @return 開いている手のビットフラグ
2721 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
2723 BIT_FLAGS16 status = EMPTY_HAND_NONE;
2724 if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx)
2725 status |= EMPTY_HAND_MAIN;
2726 if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx)
2727 status |= EMPTY_HAND_SUB;
2729 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
2730 if (any_bits(status, EMPTY_HAND_SUB))
2731 reset_bits(status, EMPTY_HAND_SUB);
2732 else if (any_bits(status, EMPTY_HAND_MAIN))
2733 reset_bits(status, EMPTY_HAND_MAIN);
2740 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
2741 * @return ペナルティが適用されるならばTRUE。
2743 bool heavy_armor(player_type *creature_ptr)
2745 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
2748 WEIGHT monk_arm_wgt = 0;
2749 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
2750 monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
2751 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
2752 monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
2753 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
2754 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
2755 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
2756 monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
2757 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
2759 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
2763 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
2765 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
2767 void update_creature(player_type *creature_ptr)
2769 if (!creature_ptr->update)
2772 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2773 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
2774 reset_bits(creature_ptr->update, PU_AUTODESTROY);
2775 autopick_delayed_alter(creature_ptr);
2778 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
2779 reset_bits(creature_ptr->update, PU_COMBINE);
2780 combine_pack(creature_ptr);
2783 if (any_bits(creature_ptr->update, (PU_REORDER))) {
2784 reset_bits(creature_ptr->update, PU_REORDER);
2785 reorder_pack(creature_ptr);
2788 if (any_bits(creature_ptr->update, (PU_BONUS))) {
2789 reset_bits(creature_ptr->update, PU_BONUS);
2790 update_alignment(creature_ptr);
2791 update_bonuses(creature_ptr);
2794 if (any_bits(creature_ptr->update, (PU_TORCH))) {
2795 reset_bits(creature_ptr->update, PU_TORCH);
2796 update_lite_radius(creature_ptr);
2799 if (any_bits(creature_ptr->update, (PU_HP))) {
2800 reset_bits(creature_ptr->update, PU_HP);
2801 update_max_hitpoints(creature_ptr);
2804 if (any_bits(creature_ptr->update, (PU_MANA))) {
2805 reset_bits(creature_ptr->update, PU_MANA);
2806 update_max_mana(creature_ptr);
2809 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
2810 reset_bits(creature_ptr->update, PU_SPELLS);
2811 update_num_of_spells(creature_ptr);
2814 if (!current_world_ptr->character_generated)
2816 if (current_world_ptr->character_icky_depth > 0)
2818 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
2819 reset_bits(creature_ptr->update, PU_UN_LITE);
2820 forget_lite(floor_ptr);
2823 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
2824 reset_bits(creature_ptr->update, PU_UN_VIEW);
2825 forget_view(floor_ptr);
2828 if (any_bits(creature_ptr->update, (PU_VIEW))) {
2829 reset_bits(creature_ptr->update, PU_VIEW);
2830 update_view(creature_ptr);
2833 if (any_bits(creature_ptr->update, (PU_LITE))) {
2834 reset_bits(creature_ptr->update, PU_LITE);
2835 update_lite(creature_ptr);
2838 if (any_bits(creature_ptr->update, (PU_FLOW))) {
2839 reset_bits(creature_ptr->update, PU_FLOW);
2840 update_flow(creature_ptr);
2843 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
2844 reset_bits(creature_ptr->update, PU_DISTANCE);
2846 update_monsters(creature_ptr, TRUE);
2849 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
2850 reset_bits(creature_ptr->update, PU_MON_LITE);
2851 update_mon_lite(creature_ptr);
2854 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
2855 reset_bits(creature_ptr->update, PU_DELAY_VIS);
2856 delayed_visual_update(creature_ptr);
2859 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
2860 reset_bits(creature_ptr->update, PU_MONSTERS);
2861 update_monsters(creature_ptr, FALSE);
2866 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
2867 * @return 魔道書を一冊も持っていないならTRUEを返す
2869 bool player_has_no_spellbooks(player_type *creature_ptr)
2872 for (int i = 0; i < INVEN_PACK; i++) {
2873 o_ptr = &creature_ptr->inventory_list[i];
2874 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2878 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2879 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
2880 o_ptr = &floor_ptr->o_list[i];
2881 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2888 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
2890 creature_ptr->energy_use = (ENERGY)need_cost;
2893 void free_turn(player_type *creature_ptr)
2895 creature_ptr->energy_use = 0;
2899 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
2902 * @return 配置に成功したらTRUE
2904 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
2906 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
2909 /* Save player location */
2910 creature_ptr->y = y;
2911 creature_ptr->x = x;
2916 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
2919 void wreck_the_pattern(player_type *creature_ptr)
2921 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2922 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
2923 if (pattern_type == PATTERN_TILE_WRECKED)
2926 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
2927 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
2929 if (!is_invuln(creature_ptr))
2930 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"));
2932 int to_ruin = randint1(45) + 35;
2935 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
2937 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
2938 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
2942 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
2946 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
2947 * Advance experience levels and print experience
2950 void check_experience(player_type *creature_ptr)
2952 if (creature_ptr->exp < 0)
2953 creature_ptr->exp = 0;
2954 if (creature_ptr->max_exp < 0)
2955 creature_ptr->max_exp = 0;
2956 if (creature_ptr->max_max_exp < 0)
2957 creature_ptr->max_max_exp = 0;
2959 if (creature_ptr->exp > PY_MAX_EXP)
2960 creature_ptr->exp = PY_MAX_EXP;
2961 if (creature_ptr->max_exp > PY_MAX_EXP)
2962 creature_ptr->max_exp = PY_MAX_EXP;
2963 if (creature_ptr->max_max_exp > PY_MAX_EXP)
2964 creature_ptr->max_max_exp = PY_MAX_EXP;
2966 if (creature_ptr->exp > creature_ptr->max_exp)
2967 creature_ptr->max_exp = creature_ptr->exp;
2968 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
2969 creature_ptr->max_max_exp = creature_ptr->max_exp;
2971 set_bits(creature_ptr->redraw, PR_EXP);
2972 handle_stuff(creature_ptr);
2974 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
2975 PLAYER_LEVEL old_lev = creature_ptr->lev;
2976 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
2977 creature_ptr->lev--;
2978 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2979 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
2980 set_bits(creature_ptr->window_flags, PW_PLAYER);
2981 handle_stuff(creature_ptr);
2984 bool level_reward = FALSE;
2985 bool level_mutation = FALSE;
2986 bool level_inc_stat = FALSE;
2987 while ((creature_ptr->lev < PY_MAX_LEVEL)
2988 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
2989 creature_ptr->lev++;
2990 if (creature_ptr->lev > creature_ptr->max_plv) {
2991 creature_ptr->max_plv = creature_ptr->lev;
2993 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || creature_ptr->muta.has(MUTA::CHAOS_GIFT)) {
2994 level_reward = TRUE;
2996 if (creature_ptr->prace == RACE_BEASTMAN) {
2998 level_mutation = TRUE;
3000 level_inc_stat = TRUE;
3002 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
3006 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
3007 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
3008 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
3009 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
3010 creature_ptr->level_up_message = TRUE;
3011 handle_stuff(creature_ptr);
3013 creature_ptr->level_up_message = FALSE;
3014 if (level_inc_stat) {
3015 if (!(creature_ptr->max_plv % 10)) {
3022 cnv_stat(creature_ptr->stat_max[0], tmp);
3023 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
3024 cnv_stat(creature_ptr->stat_max[1], tmp);
3025 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
3026 cnv_stat(creature_ptr->stat_max[2], tmp);
3027 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
3028 cnv_stat(creature_ptr->stat_max[3], tmp);
3029 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
3030 cnv_stat(creature_ptr->stat_max[4], tmp);
3031 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
3032 cnv_stat(creature_ptr->stat_max[5], tmp);
3033 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
3036 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
3040 if ((choice >= 'a') && (choice <= 'f'))
3043 for (n = 0; n < A_MAX; n++)
3044 if (n != choice - 'a')
3046 if (get_check(_("よろしいですか?", "Are you sure? ")))
3049 do_inc_stat(creature_ptr, choice - 'a');
3051 } else if (!(creature_ptr->max_plv % 2))
3052 do_inc_stat(creature_ptr, randint0(6));
3055 if (level_mutation) {
3056 msg_print(_("あなたは変わった気がする...", "You feel different..."));
3057 (void)gain_mutation(creature_ptr, 0);
3058 level_mutation = FALSE;
3062 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
3066 gain_level_reward(creature_ptr, 0);
3067 level_reward = FALSE;
3070 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3071 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
3072 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
3073 handle_stuff(creature_ptr);
3076 if (old_lev != creature_ptr->lev)
3077 autopick_load_pref(creature_ptr, FALSE);
3081 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
3083 * @param out_val 出力先文字列ポインタ
3086 void cnv_stat(int val, char *out_val)
3089 sprintf(out_val, " %2d", val);
3093 int bonus = (val - 18);
3095 sprintf(out_val, "18/%3s", "***");
3096 } else if (bonus >= 100) {
3097 sprintf(out_val, "18/%03d", bonus);
3099 sprintf(out_val, " 18/%02d", bonus);
3104 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
3105 * Modify a stat value by a "modifier", return new value
3107 * @param amount 加減算値
3111 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
3112 * Or even: 18/13, 18/23, 18/33, ..., 18/220
3113 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
3114 * Or even: 18/13, 18/03, 18, 17, ..., 3
3117 s16b modify_stat_value(int value, int amount)
3120 for (int i = 0; i < amount; i++) {
3126 } else if (amount < 0) {
3127 for (int i = 0; i < (0 - amount); i++) {
3128 if (value >= 18 + 10)
3130 else if (value > 18)
3142 * Hack -- Calculates the total number of points earned -JWT-
3146 long calc_score(player_type *creature_ptr)
3148 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
3161 if (ironman_small_levels)
3163 if (ironman_empty_levels)
3169 if (ironman_nightmare)
3176 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
3177 if (max_dlv[i] > max_dl)
3178 max_dl = max_dlv[i];
3180 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
3181 u32b point_h = point_l / 0x10000L;
3182 point_l = point_l % 0x10000L;
3185 point_h += point_l / 0x10000L;
3186 point_l %= 0x10000L;
3188 point_l += ((point_h % 100) << 16);
3192 u32b point = (point_h << 16) + (point_l);
3193 if (creature_ptr->arena_number >= 0)
3194 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
3196 if (ironman_downward)
3198 if (creature_ptr->pclass == CLASS_BERSERKER) {
3199 if (creature_ptr->prace == RACE_SPECTRE)
3203 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
3205 if (current_world_ptr->total_winner)
3210 point = (0 - point);
3216 * @param creature_ptr プレーヤーへの参照ポインタ
3217 * @return 祝福状態ならばTRUE
3219 bool is_blessed(player_type *creature_ptr)
3221 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
3224 bool is_tim_esp(player_type *creature_ptr)
3226 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3229 bool is_tim_stealth(player_type *creature_ptr)
3231 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
3234 bool is_time_limit_esp(player_type *creature_ptr)
3236 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3239 bool is_time_limit_stealth(player_type *creature_ptr)
3241 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
3244 bool can_two_hands_wielding(player_type *creature_ptr)
3246 return !creature_ptr->riding || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS);
3250 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
3253 void stop_singing(player_type *creature_ptr)
3255 if (creature_ptr->pclass != CLASS_BARD)
3258 /* Are there interupted song? */
3259 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
3260 /* Forget interupted song */
3261 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3265 /* The player is singing? */
3266 if (!SINGING_SONG_EFFECT(creature_ptr))
3269 /* Hack -- if called from set_action(), avoid recursive loop */
3270 if (creature_ptr->action == ACTION_SING)
3271 set_action(creature_ptr, ACTION_NONE);
3273 /* Message text of each song or etc. */
3274 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
3276 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3277 SINGING_SONG_ID(creature_ptr) = 0;
3278 set_bits(creature_ptr->update, PU_BONUS);
3279 set_bits(creature_ptr->redraw, PR_STATUS);
3283 * @brief 口を使う継続的な処理を中断する
3284 * @param caster_ptr プレーヤーへの参照ポインタ
3287 void stop_mouth(player_type *caster_ptr)
3289 if (music_singing_any(caster_ptr))
3290 stop_singing(caster_ptr);
3291 if (hex_spelling_any(caster_ptr))
3292 stop_hex_spell_all(caster_ptr);
3296 * @brief ペットの維持コスト計算
3299 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
3302 bool has_a_unique = FALSE;
3303 DEPTH total_friend_levels = 0;
3307 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
3308 monster_type *m_ptr;
3309 monster_race *r_ptr;
3311 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
3312 if (!monster_is_valid(m_ptr))
3314 r_ptr = &r_info[m_ptr->r_idx];
3316 if (is_pet(m_ptr)) {
3318 if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
3319 if (creature_ptr->pclass == CLASS_CAVALRY) {
3320 if (creature_ptr->riding == m_idx)
3321 total_friend_levels += (r_ptr->level + 5) * 2;
3322 else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
3323 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
3325 total_friend_levels += (r_ptr->level + 5) * 10;
3326 has_a_unique = TRUE;
3328 total_friend_levels += (r_ptr->level + 5) * 10;
3330 total_friend_levels += r_ptr->level;
3334 if (total_friends) {
3336 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
3337 if (upkeep_factor < 0)
3339 if (upkeep_factor > 1000)
3340 upkeep_factor = 1000;
3341 return upkeep_factor;
3346 bool music_singing(player_type *caster_ptr, int music_songs)
3348 return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);
3351 bool is_fast(player_type *creature_ptr)
3353 return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO);
3356 bool is_invuln(player_type *creature_ptr)
3358 return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN);
3361 bool is_hero(player_type *creature_ptr)
3363 return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO);
3366 bool is_shero(player_type *creature_ptr)
3368 return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER;
3371 bool is_echizen(player_type *creature_ptr)
3373 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
3376 int calc_weapon_weight_limit(player_type *creature_ptr)
3378 int weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3380 if (has_two_handed_weapons(creature_ptr))
3386 static player_hand main_attack_hand(player_type *creature_ptr)
3388 switch (player_melee_type(creature_ptr)) {
3389 case MELEE_TYPE_BAREHAND_TWO:
3390 return PLAYER_HAND_MAIN;
3391 case MELEE_TYPE_BAREHAND_MAIN:
3392 return PLAYER_HAND_MAIN;
3393 case MELEE_TYPE_BAREHAND_SUB:
3394 return PLAYER_HAND_SUB;
3395 case MELEE_TYPE_WEAPON_MAIN:
3396 return PLAYER_HAND_MAIN;
3397 case MELEE_TYPE_WEAPON_SUB:
3398 return PLAYER_HAND_SUB;
3399 case MELEE_TYPE_WEAPON_TWOHAND:
3400 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
3401 case MELEE_TYPE_WEAPON_DOUBLE:
3402 return PLAYER_HAND_MAIN;
3403 case MELEE_TYPE_SHIELD_DOUBLE:
3404 return PLAYER_HAND_MAIN;
3406 return PLAYER_HAND_MAIN;
3410 * @brief プレイヤーが現在ダンジョンに潜っているかどうかを返す。
3411 * @memo 現在はdun_levelが0でないかそうでないかに限るが可読性を高めるため。
3413 bool is_in_dungeon(player_type *creature_ptr)
3415 return creature_ptr->current_floor_ptr->dun_level > 0;