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 "inventory/inventory-object.h"
27 #include "inventory/inventory-slot-types.h"
28 #include "io/input-key-acceptor.h"
29 #include "io/write-diary.h"
30 #include "main/sound-definitions-table.h"
31 #include "main/sound-of-music.h"
32 #include "market/arena-info-table.h"
33 #include "mind/mind-force-trainer.h"
34 #include "mind/mind-ninja.h"
35 #include "monster-floor/monster-lite.h"
36 #include "monster-floor/monster-remover.h"
37 #include "monster-race/monster-race-hook.h"
38 #include "monster-race/monster-race.h"
39 #include "monster-race/race-flags1.h"
40 #include "monster-race/race-flags2.h"
41 #include "monster-race/race-flags3.h"
42 #include "monster-race/race-flags7.h"
43 #include "monster/monster-info.h"
44 #include "monster/monster-status.h"
45 #include "monster/monster-update.h"
46 #include "monster/smart-learn-types.h"
47 #include "mutation/mutation-calculator.h"
48 #include "mutation/mutation-flag-types.h"
49 #include "mutation/mutation-investor-remover.h"
50 #include "object-enchant/object-ego.h"
51 #include "object-enchant/special-object-flags.h"
52 #include "object-enchant/tr-types.h"
53 #include "object-enchant/trc-types.h"
54 #include "object-hook/hook-armor.h"
55 #include "object-hook/hook-checker.h"
56 #include "object-hook/hook-weapon.h"
57 #include "object/object-flags.h"
58 #include "object/object-info.h"
59 #include "object/object-mark-types.h"
60 #include "perception/object-perception.h"
61 #include "pet/pet-util.h"
62 #include "player-info/avatar.h"
63 #include "player-status/player-basic-statistics.h"
64 #include "player-status/player-speed.h"
65 #include "player-status/player-stealth.h"
66 #include "player/attack-defense-types.h"
67 #include "player/digestion-processor.h"
68 #include "player/mimic-info-table.h"
69 #include "player/patron.h"
70 #include "player/player-class.h"
71 #include "player/player-damage.h"
72 #include "player/player-move.h"
73 #include "player/player-personalities-types.h"
74 #include "player/player-personality.h"
75 #include "player/player-race-types.h"
76 #include "player/player-skill.h"
77 #include "player/player-status-flags.h"
78 #include "player/player-status-table.h"
79 #include "player/player-view.h"
80 #include "player/race-info-table.h"
81 #include "player/special-defense-types.h"
82 #include "realm/realm-hex-numbers.h"
83 #include "realm/realm-names-table.h"
84 #include "realm/realm-song-numbers.h"
85 #include "specific-object/bow.h"
86 #include "specific-object/torch.h"
87 #include "spell-realm/spells-hex.h"
88 #include "spell/range-calc.h"
89 #include "spell/spells-describer.h"
90 #include "spell/spells-execution.h"
91 #include "spell/spells-status.h"
92 #include "spell/technic-info-table.h"
93 #include "status/action-setter.h"
94 #include "status/base-status.h"
95 #include "sv-definition/sv-lite-types.h"
96 #include "sv-definition/sv-weapon-types.h"
97 #include "system/angband.h"
98 #include "system/floor-type-definition.h"
99 #include "term/screen-processor.h"
100 #include "util/bit-flags-calculator.h"
101 #include "util/quarks.h"
102 #include "util/string-processor.h"
103 #include "view/display-messages.h"
104 #include "world/world.h"
106 static bool is_martial_arts_mode(player_type *creature_ptr);
108 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr);
109 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
110 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
111 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
112 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
113 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
114 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
115 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
116 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
117 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
118 static bool is_heavy_wield(player_type *creature_ptr, int i);
119 static s16b calc_num_blow(player_type *creature_ptr, int i);
120 static s16b calc_to_magic_chance(player_type *creature_ptr);
121 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
122 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value);
123 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
124 static bool is_riding_two_hands(player_type *creature_ptr);
125 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
126 static void put_equipment_warning(player_type *creature_ptr);
128 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
129 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
131 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value);
133 static s16b calc_to_damage_misc(player_type *creature_ptr);
134 static s16b calc_to_hit_misc(player_type *creature_ptr);
136 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
137 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
139 static player_hand main_attack_hand(player_type *creature_ptr);
141 /*** Player information ***/
144 * @brief プレイヤー用のクリーチャー構造体実体 / Static player info record
149 * @brief プレイヤー用のクリーチャー構造体参照ポインタ / Pointer to the player info
151 player_type *p_ptr = &p_body;
154 * @brief クリーチャーの抽象的善悪アライメントの表記名のみを返す。 / Return only alignment title
155 * @param creature_ptr 算出するクリーチャーの参照ポインタ。
158 concptr alignment_label(player_type *creature_ptr)
160 if (creature_ptr->align > 150)
161 return _("大善", "Lawful");
162 else if (creature_ptr->align > 50)
163 return _("中善", "Good");
164 else if (creature_ptr->align > 10)
165 return _("小善", "Neutral Good");
166 else if (creature_ptr->align > -11)
167 return _("中立", "Neutral");
168 else if (creature_ptr->align > -51)
169 return _("小悪", "Neutral Evil");
170 else if (creature_ptr->align > -151)
171 return _("中悪", "Evil");
173 return _("大悪", "Chaotic");
177 * @brief クリーチャーの抽象的善悪アライメントの表記を返す。 / Return alignment title
178 * @param creature_ptr 算出するクリーチャーの参照ポインタ。
179 * @return アライメントの表記を返す。
181 concptr your_alignment(player_type *creature_ptr, bool with_value)
183 auto s = alignment_label(creature_ptr);
184 if (with_value || show_actual_value)
185 return format(_("%s(%ld)", "%s (%ld)"), s, static_cast<long>(creature_ptr->align));
191 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
192 * @param weapon_exp 経験値
195 int weapon_exp_level(int weapon_exp)
197 if (weapon_exp < WEAPON_EXP_BEGINNER)
198 return EXP_LEVEL_UNSKILLED;
199 else if (weapon_exp < WEAPON_EXP_SKILLED)
200 return EXP_LEVEL_BEGINNER;
201 else if (weapon_exp < WEAPON_EXP_EXPERT)
202 return EXP_LEVEL_SKILLED;
203 else if (weapon_exp < WEAPON_EXP_MASTER)
204 return EXP_LEVEL_EXPERT;
206 return EXP_LEVEL_MASTER;
210 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
211 * @param weapon_exp 経験値
214 int riding_exp_level(int riding_exp)
216 if (riding_exp < RIDING_EXP_BEGINNER)
217 return EXP_LEVEL_UNSKILLED;
218 else if (riding_exp < RIDING_EXP_SKILLED)
219 return EXP_LEVEL_BEGINNER;
220 else if (riding_exp < RIDING_EXP_EXPERT)
221 return EXP_LEVEL_SKILLED;
222 else if (riding_exp < RIDING_EXP_MASTER)
223 return EXP_LEVEL_EXPERT;
225 return EXP_LEVEL_MASTER;
229 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
230 * @param spell_exp 経験値
233 int spell_exp_level(int spell_exp)
235 if (spell_exp < SPELL_EXP_BEGINNER)
236 return EXP_LEVEL_UNSKILLED;
237 else if (spell_exp < SPELL_EXP_SKILLED)
238 return EXP_LEVEL_BEGINNER;
239 else if (spell_exp < SPELL_EXP_EXPERT)
240 return EXP_LEVEL_SKILLED;
241 else if (spell_exp < SPELL_EXP_MASTER)
242 return EXP_LEVEL_EXPERT;
244 return EXP_LEVEL_MASTER;
248 * @brief 遅延描画更新 / Delayed visual update
249 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
250 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
251 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
254 static void delayed_visual_update(player_type *player_ptr)
256 floor_type *floor_ptr = player_ptr->current_floor_ptr;
257 for (int i = 0; i < floor_ptr->redraw_n; i++) {
258 POSITION y = floor_ptr->redraw_y[i];
259 POSITION x = floor_ptr->redraw_x[i];
261 g_ptr = &floor_ptr->grid_array[y][x];
262 if (none_bits(g_ptr->info, CAVE_REDRAW))
265 if (any_bits(g_ptr->info, CAVE_NOTE))
266 note_spot(player_ptr, y, x);
268 lite_spot(player_ptr, y, x);
270 update_monster(player_ptr, g_ptr->m_idx, FALSE);
272 reset_bits(g_ptr->info, (CAVE_NOTE | CAVE_REDRAW));
275 floor_ptr->redraw_n = 0;
279 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
280 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
281 * @return 重すぎるならばTRUE
283 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
285 int hold = adj_str_hold[creature_ptr->stat_index[A_STR]];
286 return (hold < o_ptr->weight / 10);
291 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
294 WEIGHT calc_inventory_weight(player_type *creature_ptr)
299 for (int i = 0; i < INVEN_TOTAL; i++) {
300 o_ptr = &creature_ptr->inventory_list[i];
303 weight += o_ptr->weight * o_ptr->number;
308 * @brief プレイヤーの全ステータスを更新する /
309 * Calculate the players current "state", taking into account
310 * not only race/class intrinsics, but also objects being worn
311 * and temporary spell effects.
315 * See also update_max_mana() and update_max_hitpoints().
317 * Take note of the new "speed code", in particular, a very strong
318 * player will start slowing down as soon as he reaches 150 pounds,
319 * but not until he reaches 450 pounds will he be half as fast as
320 * a normal kobold. This both hurts and helps the player, hurts
321 * because in the old days a player could just avoid 300 pounds,
322 * and helps because now carrying 300 pounds is not very painful.
324 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
325 * damage, since that would affect non-combat things. These values
326 * are actually added in later, at the appropriate place.
328 * This function induces various "status" messages.
330 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
332 static void update_bonuses(player_type *creature_ptr)
334 int empty_hands_status = empty_hands(creature_ptr, TRUE);
337 /* Save the old vision stuff */
338 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
339 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
340 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
341 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
342 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
343 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
344 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
345 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
346 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
347 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
348 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
349 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
350 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
351 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
352 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
353 s16b old_speed = creature_ptr->pspeed;
355 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
356 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
358 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
359 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
360 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
361 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
362 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
363 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
364 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
365 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
366 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
367 creature_ptr->esp_human = has_esp_human(creature_ptr);
368 creature_ptr->esp_good = has_esp_good(creature_ptr);
369 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
370 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
371 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
372 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
373 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
374 creature_ptr->down_saving = has_down_saving(creature_ptr);
375 creature_ptr->yoiyami = has_no_ac(creature_ptr);
376 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
377 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
378 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
379 creature_ptr->warning = has_warning(creature_ptr);
380 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
381 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
382 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
383 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
384 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
385 creature_ptr->see_inv = has_see_inv(creature_ptr);
386 creature_ptr->free_act = has_free_act(creature_ptr);
387 creature_ptr->levitation = has_levitation(creature_ptr);
388 creature_ptr->can_swim = has_can_swim(creature_ptr);
389 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
390 creature_ptr->regenerate = has_regenerate(creature_ptr);
391 update_curses(creature_ptr);
392 creature_ptr->impact = has_impact(creature_ptr);
393 update_extra_blows(creature_ptr);
395 creature_ptr->lite = has_lite(creature_ptr);
397 if (any_bits(creature_ptr->special_defense, KAMAE_MASK)) {
398 if (none_bits(empty_hands_status, EMPTY_HAND_MAIN)) {
399 set_action(creature_ptr, ACTION_NONE);
403 creature_ptr->stat_add[A_STR] = PlayerStrength(creature_ptr).modification_value();
404 creature_ptr->stat_add[A_INT] = PlayerIntelligence(creature_ptr).modification_value();
405 creature_ptr->stat_add[A_WIS] = PlayerWisdom(creature_ptr).modification_value();
406 creature_ptr->stat_add[A_DEX] = PlayerDextarity(creature_ptr).modification_value();
407 creature_ptr->stat_add[A_CON] = PlayerConstitution(creature_ptr).modification_value();
408 creature_ptr->stat_add[A_CHR] = PlayerCharisma(creature_ptr).modification_value();
410 PlayerStrength(creature_ptr).update_value();
411 PlayerIntelligence(creature_ptr).update_value();
412 PlayerWisdom(creature_ptr).update_value();
413 PlayerDextarity(creature_ptr).update_value();
414 PlayerConstitution(creature_ptr).update_value();
415 PlayerCharisma(creature_ptr).update_value();
417 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
419 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
420 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
421 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
425 for (int i = 0; i < 2; i++) {
426 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
427 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
428 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
429 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
430 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
431 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_MAIN_HAND + i);
434 creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value();
435 creature_ptr->see_infra = calc_intra_vision(creature_ptr);
436 creature_ptr->skill_stl = PlayerStealth(creature_ptr).get_value();
437 creature_ptr->skill_dis = calc_disarming(creature_ptr);
438 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
439 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
440 creature_ptr->skill_srh = calc_search(creature_ptr);
441 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
442 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
443 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
444 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
445 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
446 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, TRUE);
447 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, TRUE);
448 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, FALSE);
449 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, FALSE);
450 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, TRUE);
451 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, TRUE);
452 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, FALSE);
453 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, FALSE);
454 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
455 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
456 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
457 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
458 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
459 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
460 creature_ptr->ac = calc_base_ac(creature_ptr);
461 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
462 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
463 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
465 if (old_mighty_throw != creature_ptr->mighty_throw) {
466 creature_ptr->window_flags |= PW_INVEN;
469 if (creature_ptr->telepathy != old_telepathy) {
470 set_bits(creature_ptr->update, PU_MONSTERS);
473 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
474 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
475 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
476 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
477 set_bits(creature_ptr->update, PU_MONSTERS);
480 if (creature_ptr->see_inv != old_see_inv) {
481 set_bits(creature_ptr->update, PU_MONSTERS);
484 if (creature_ptr->pspeed != old_speed) {
485 set_bits(creature_ptr->redraw, PR_SPEED);
488 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
489 set_bits(creature_ptr->redraw, PR_ARMOR);
490 set_bits(creature_ptr->window_flags, PW_PLAYER);
493 if (current_world_ptr->character_xtra)
496 put_equipment_warning(creature_ptr);
497 check_no_flowed(creature_ptr);
500 static void update_alignment(player_type *creature_ptr)
502 creature_ptr->align = 0;
503 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
504 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
507 m_ptr = &floor_ptr->m_list[m_idx];
508 if (!monster_is_valid(m_ptr))
510 r_ptr = &r_info[m_ptr->r_idx];
515 if (any_bits(r_ptr->flags3, RF3_GOOD))
516 creature_ptr->align += r_ptr->level;
517 if (any_bits(r_ptr->flags3, RF3_EVIL))
518 creature_ptr->align -= r_ptr->level;
521 if (creature_ptr->mimic_form) {
522 switch (creature_ptr->mimic_form) {
524 creature_ptr->align -= 200;
526 case MIMIC_DEMON_LORD:
527 creature_ptr->align -= 200;
531 switch (creature_ptr->prace) {
533 creature_ptr->align += 200;
536 creature_ptr->align -= 200;
544 for (int i = 0; i < 2; i++) {
545 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i))
547 if (creature_ptr->inventory_list[INVEN_MAIN_HAND + i].name1 != ART_IRON_BALL)
549 creature_ptr->align -= 1000;
554 for (int i = 0; i < 8; i++) {
555 switch (creature_ptr->vir_types[i]) {
557 creature_ptr->align += creature_ptr->virtues[i] * 2;
566 creature_ptr->align -= creature_ptr->virtues[i];
569 creature_ptr->align += creature_ptr->virtues[i];
574 for (int i = 0; i < j; i++) {
575 if (creature_ptr->align > 0) {
576 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
577 if (creature_ptr->align < 0)
578 creature_ptr->align = 0;
579 } else if (creature_ptr->align < 0) {
580 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
581 if (creature_ptr->align > 0)
582 creature_ptr->align = 0;
588 * @brief プレイヤーの最大HPを更新する /
589 * Update the players maximal hit points
590 * Adjust current hitpoints if necessary
594 static void update_max_hitpoints(player_type *creature_ptr)
596 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_index[A_CON]]) - 128) * creature_ptr->lev / 4;
597 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
600 if (creature_ptr->mimic_form) {
601 if (creature_ptr->pclass == CLASS_SORCERER)
602 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
604 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
605 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
608 if (creature_ptr->pclass == CLASS_SORCERER) {
609 if (creature_ptr->lev < 30)
610 mhp = (mhp * (45 + creature_ptr->lev) / 100);
612 mhp = (mhp * 75 / 100);
613 bonus = (bonus * 65 / 100);
618 if (creature_ptr->pclass == CLASS_BERSERKER) {
619 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
622 if (mhp < creature_ptr->lev + 1)
623 mhp = creature_ptr->lev + 1;
624 if (is_hero(creature_ptr))
626 if (is_shero(creature_ptr))
628 if (creature_ptr->tsuyoshi)
630 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
632 if (hex_spelling(creature_ptr, HEX_BUILDING))
634 if (creature_ptr->mhp == mhp)
637 if (creature_ptr->chp >= mhp) {
638 creature_ptr->chp = mhp;
639 creature_ptr->chp_frac = 0;
643 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
644 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
647 creature_ptr->mhp = mhp;
649 creature_ptr->redraw |= PR_HP;
650 creature_ptr->window_flags |= PW_PLAYER;
654 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
655 * Calculate number of spells player should have, and forget,
656 * or remember, spells until that number is properly reflected.
659 * Note that this function induces various "status" messages,
660 * which must be bypasses until the character is created.
662 static void update_num_of_spells(player_type *creature_ptr)
664 if (!mp_ptr->spell_book)
666 if (!current_world_ptr->character_generated)
668 if (current_world_ptr->character_xtra)
670 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
671 creature_ptr->new_spells = 0;
675 concptr p = spell_category_name(mp_ptr->spell_book);
676 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
680 int num_allowed = (adj_mag_study[creature_ptr->stat_index[mp_ptr->spell_stat]] * levels / 2);
682 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
686 if (creature_ptr->pclass == CLASS_SAMURAI) {
688 } else if (creature_ptr->realm2 == REALM_NONE) {
689 num_allowed = (num_allowed + 1) / 2;
690 if (num_allowed > (32 + bonus))
691 num_allowed = 32 + bonus;
692 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
693 if (num_allowed > (96 + bonus))
694 num_allowed = 96 + bonus;
696 if (num_allowed > (80 + bonus))
697 num_allowed = 80 + bonus;
700 int num_boukyaku = 0;
701 for (int j = 0; j < 64; j++) {
702 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
707 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
708 for (int i = 63; i >= 0; i--) {
709 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
712 int j = creature_ptr->spell_order[i];
716 const magic_type *s_ptr;
717 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
719 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
721 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
723 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
725 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
727 if (s_ptr->slevel <= creature_ptr->lev)
730 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
731 if (!is_spell_learned)
736 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
737 which = creature_ptr->realm1;
739 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
740 which = creature_ptr->realm2;
744 reset_bits(creature_ptr->spell_learned1, (1UL << j));
745 which = creature_ptr->realm1;
747 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
748 which = creature_ptr->realm2;
752 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
754 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
756 creature_ptr->new_spells++;
759 /* Forget spells if we know too many spells */
760 for (int i = 63; i >= 0; i--) {
761 if (creature_ptr->new_spells >= 0)
763 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
766 int j = creature_ptr->spell_order[i];
770 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
771 if (!is_spell_learned)
776 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
777 which = creature_ptr->realm1;
779 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
780 which = creature_ptr->realm2;
784 reset_bits(creature_ptr->spell_learned1, (1UL << j));
785 which = creature_ptr->realm1;
787 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
788 which = creature_ptr->realm2;
792 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
794 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
796 creature_ptr->new_spells++;
799 /* Check for spells to remember */
800 for (int i = 0; i < 64; i++) {
801 if (creature_ptr->new_spells <= 0)
803 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
805 int j = creature_ptr->spell_order[i];
809 const magic_type *s_ptr;
810 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
812 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
814 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
816 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
818 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
820 if (s_ptr->slevel > creature_ptr->lev)
823 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
824 if (!is_spell_learned)
829 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
830 which = creature_ptr->realm1;
832 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
833 which = creature_ptr->realm2;
837 set_bits(creature_ptr->spell_learned1, (1UL << j));
838 which = creature_ptr->realm1;
840 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
841 which = creature_ptr->realm2;
845 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
847 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
849 creature_ptr->new_spells--;
852 if (creature_ptr->realm2 == REALM_NONE) {
854 for (int j = 0; j < 32; j++) {
855 const magic_type *s_ptr;
856 if (!is_magic(creature_ptr->realm1))
857 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
859 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
861 if (s_ptr->slevel > creature_ptr->lev)
864 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
873 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
874 creature_ptr->new_spells = (s16b)k;
878 if (creature_ptr->new_spells < 0)
879 creature_ptr->new_spells = 0;
881 if (creature_ptr->old_spells == creature_ptr->new_spells)
884 if (creature_ptr->new_spells) {
886 if (creature_ptr->new_spells < 10) {
887 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
889 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
892 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
896 creature_ptr->old_spells = creature_ptr->new_spells;
897 set_bits(creature_ptr->redraw, PR_STUDY);
898 set_bits(creature_ptr->window_flags, PW_OBJECT);
902 * @brief プレイヤーの最大MPを更新する /
903 * Update maximum mana. You do not need to know any spells.
904 * Note that mana is lowered by heavy (or inappropriate) armor.
907 * This function induces status messages.
909 static void update_max_mana(player_type *creature_ptr)
911 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
915 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)
916 || creature_ptr->pclass == CLASS_ELEMENTALIST) {
917 levels = creature_ptr->lev;
919 if (mp_ptr->spell_first > creature_ptr->lev) {
920 creature_ptr->msp = 0;
921 set_bits(creature_ptr->redraw, PR_MANA);
925 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
929 if (creature_ptr->pclass == CLASS_SAMURAI) {
930 msp = (adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] + 10) * 2;
932 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
934 msp = adj_mag_mana[creature_ptr->stat_index[mp_ptr->spell_stat]] * (levels + 3) / 4;
938 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
939 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
941 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
943 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
944 msp += msp * (25 + creature_ptr->lev) / 100;
947 if (any_bits(mp_ptr->spell_xtra, MAGIC_GLOVE_REDUCE_MANA)) {
948 BIT_FLAGS flgs[TR_FLAG_SIZE];
949 creature_ptr->cumber_glove = FALSE;
951 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
952 object_flags(creature_ptr, o_ptr, flgs);
953 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
954 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
955 creature_ptr->cumber_glove = TRUE;
960 creature_ptr->cumber_armor = FALSE;
963 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
964 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
965 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
966 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
967 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
968 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
969 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
970 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
971 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
973 switch (creature_ptr->pclass) {
975 case CLASS_HIGH_MAGE:
976 case CLASS_BLUE_MAGE:
978 case CLASS_FORCETRAINER:
980 case CLASS_ELEMENTALIST: {
981 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
982 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
983 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
984 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
989 case CLASS_TOURIST: {
990 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
991 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
992 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
993 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
996 case CLASS_MINDCRAFTER:
997 case CLASS_BEASTMASTER:
998 case CLASS_MIRROR_MASTER: {
999 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
1000 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
1001 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
1002 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
1007 case CLASS_RED_MAGE:
1008 case CLASS_WARRIOR_MAGE: {
1009 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
1010 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
1011 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
1012 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
1016 case CLASS_CHAOS_WARRIOR: {
1017 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
1018 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
1019 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
1020 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
1028 int max_wgt = mp_ptr->spell_weight;
1029 if ((cur_wgt - max_wgt) > 0) {
1030 creature_ptr->cumber_armor = TRUE;
1031 switch (creature_ptr->pclass) {
1033 case CLASS_HIGH_MAGE:
1034 case CLASS_BLUE_MAGE:
1035 case CLASS_ELEMENTALIST: {
1036 msp -= msp * (cur_wgt - max_wgt) / 600;
1040 case CLASS_MINDCRAFTER:
1041 case CLASS_BEASTMASTER:
1043 case CLASS_FORCETRAINER:
1045 case CLASS_MIRROR_MASTER: {
1046 msp -= msp * (cur_wgt - max_wgt) / 800;
1049 case CLASS_SORCERER: {
1050 msp -= msp * (cur_wgt - max_wgt) / 900;
1056 case CLASS_RED_MAGE: {
1057 msp -= msp * (cur_wgt - max_wgt) / 1000;
1061 case CLASS_CHAOS_WARRIOR:
1062 case CLASS_WARRIOR_MAGE: {
1063 msp -= msp * (cur_wgt - max_wgt) / 1200;
1066 case CLASS_SAMURAI: {
1067 creature_ptr->cumber_armor = FALSE;
1071 msp -= msp * (cur_wgt - max_wgt) / 800;
1080 if (creature_ptr->msp != msp) {
1081 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1082 creature_ptr->csp = msp;
1083 creature_ptr->csp_frac = 0;
1087 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1088 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1091 creature_ptr->msp = msp;
1092 set_bits(creature_ptr->redraw, PR_MANA);
1093 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
1096 if (current_world_ptr->character_xtra)
1099 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1100 if (creature_ptr->cumber_glove)
1101 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1103 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1105 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1108 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1111 if (creature_ptr->cumber_armor)
1112 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1114 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1116 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1120 * @brief 装備中の射撃武器の威力倍率を返す /
1121 * calcurate the fire rate of target object
1122 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1123 * @return 射撃倍率の値(100で1.00倍)
1125 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1127 int extra_shots = 0;
1128 BIT_FLAGS flgs[TR_FLAG_SIZE];
1130 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1132 q_ptr = &creature_ptr->inventory_list[i];
1139 object_flags(creature_ptr, q_ptr, flgs);
1140 if (has_flag(flgs, TR_XTRA_SHOTS))
1144 object_flags(creature_ptr, o_ptr, flgs);
1145 if (has_flag(flgs, TR_XTRA_SHOTS))
1149 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1153 num += (extra_shots * 100);
1155 tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
1156 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1157 num += (creature_ptr->lev * 4);
1160 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1161 num += (creature_ptr->lev * 3);
1164 if (creature_ptr->pclass == CLASS_ARCHER) {
1165 if (tval_ammo == TV_ARROW)
1166 num += ((creature_ptr->lev * 5) + 50);
1167 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1168 num += (creature_ptr->lev * 4);
1171 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1172 num += (creature_ptr->lev * 2);
1175 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1176 num += (creature_ptr->lev * 4);
1184 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1188 * * 変異MUT3_INFRAVISによる加算(+3)
1189 * * 魔法効果tim_infraによる加算(+3)
1190 * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1)
1192 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr)
1194 ACTION_SKILL_POWER pow;
1195 const player_race *tmp_rp_ptr;
1197 if (creature_ptr->mimic_form)
1198 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1200 tmp_rp_ptr = &race_info[creature_ptr->prace];
1202 pow = tmp_rp_ptr->infra;
1204 if (creature_ptr->muta.has(MUTA::INFRAVIS)) {
1208 if (creature_ptr->tim_infra) {
1212 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1214 BIT_FLAGS flgs[TR_FLAG_SIZE];
1215 o_ptr = &creature_ptr->inventory_list[i];
1218 object_flags(creature_ptr, o_ptr, flgs);
1219 if (has_flag(flgs, TR_INFRA))
1228 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1232 * * 職業と性格とレベルによる追加加算
1233 * * 器用さに応じたadj_dex_disテーブルによる加算
1234 * * 知力に応じたadj_int_disテーブルによる加算
1236 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1238 ACTION_SKILL_POWER pow;
1239 const player_race *tmp_rp_ptr;
1241 if (creature_ptr->mimic_form)
1242 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1244 tmp_rp_ptr = &race_info[creature_ptr->prace];
1245 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1246 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1248 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1249 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1250 pow += adj_dex_dis[creature_ptr->stat_index[A_DEX]];
1251 pow += adj_int_dis[creature_ptr->stat_index[A_INT]];
1257 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1261 * * 職業と性格とレベルによる追加加算
1262 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1263 * * 知力に応じたadj_int_devテーブルによる加算
1266 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1268 ACTION_SKILL_POWER pow;
1269 const player_race *tmp_rp_ptr;
1271 if (creature_ptr->mimic_form)
1272 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1274 tmp_rp_ptr = &race_info[creature_ptr->prace];
1275 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1276 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1278 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1279 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1281 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1283 BIT_FLAGS flgs[TR_FLAG_SIZE];
1284 o_ptr = &creature_ptr->inventory_list[i];
1287 object_flags(creature_ptr, o_ptr, flgs);
1288 if (has_flag(flgs, TR_MAGIC_MASTERY))
1289 pow += 8 * o_ptr->pval;
1292 pow += adj_int_dev[creature_ptr->stat_index[A_INT]];
1294 if (is_shero(creature_ptr)) {
1302 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1306 * * 職業と性格とレベルによる追加加算
1307 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1308 * * 賢さによるadj_wis_savテーブル加算
1310 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1311 * * クターのつぶれ状態なら(10に上書き)
1312 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1313 * * 呪いのdown_savingがかかっているなら半減
1315 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1317 ACTION_SKILL_POWER pow;
1318 const player_race *tmp_rp_ptr;
1320 if (creature_ptr->mimic_form)
1321 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1323 tmp_rp_ptr = &race_info[creature_ptr->prace];
1324 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1325 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1327 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1328 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1330 if (creature_ptr->muta.has(MUTA::MAGIC_RES))
1331 pow += (15 + (creature_ptr->lev / 5));
1333 pow += adj_wis_sav[creature_ptr->stat_index[A_WIS]];
1335 if (is_shero(creature_ptr))
1338 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1339 pow = 90 + creature_ptr->lev;
1341 if (creature_ptr->tsubureru)
1344 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1345 pow = 95 + creature_ptr->lev;
1347 if (creature_ptr->down_saving)
1355 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1360 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1362 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1364 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1366 ACTION_SKILL_POWER pow;
1367 const player_race *tmp_rp_ptr;
1369 if (creature_ptr->mimic_form)
1370 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1372 tmp_rp_ptr = &race_info[creature_ptr->prace];
1373 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1374 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1376 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1377 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1379 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1381 BIT_FLAGS flgs[TR_FLAG_SIZE];
1382 o_ptr = &creature_ptr->inventory_list[i];
1385 object_flags(creature_ptr, o_ptr, flgs);
1386 if (has_flag(flgs, TR_SEARCH))
1387 pow += (o_ptr->pval * 5);
1390 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1394 if (is_shero(creature_ptr)) {
1403 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1408 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1410 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1412 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1414 ACTION_SKILL_POWER pow;
1415 const player_race *tmp_rp_ptr;
1417 if (creature_ptr->mimic_form)
1418 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1420 tmp_rp_ptr = &race_info[creature_ptr->prace];
1421 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1422 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1424 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1425 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1427 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1429 BIT_FLAGS flgs[TR_FLAG_SIZE];
1430 o_ptr = &creature_ptr->inventory_list[i];
1433 object_flags(creature_ptr, o_ptr, flgs);
1434 if (has_flag(flgs, TR_SEARCH))
1435 pow += (o_ptr->pval * 5);
1438 if (is_shero(creature_ptr)) {
1442 if (creature_ptr->muta.has(MUTA::XTRA_EYES)) {
1451 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1454 * * 種族/職業/性格による加算とレベルによる追加加算
1456 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1458 ACTION_SKILL_POWER pow;
1459 const player_race *tmp_rp_ptr;
1460 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1461 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1463 if (creature_ptr->mimic_form)
1464 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1466 tmp_rp_ptr = &race_info[creature_ptr->prace];
1468 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1469 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1475 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1478 * * 種族/職業/性格による加算とレベルによる追加加算
1480 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1482 ACTION_SKILL_POWER pow;
1483 const player_race *tmp_rp_ptr;
1484 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1485 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1487 if (creature_ptr->mimic_form)
1488 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1490 tmp_rp_ptr = &race_info[creature_ptr->prace];
1492 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1493 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1499 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1502 * * 種族/職業/性格による加算とレベルによる追加加算
1505 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1507 ACTION_SKILL_POWER pow;
1508 const player_race *tmp_rp_ptr;
1509 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1510 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1512 if (creature_ptr->mimic_form)
1513 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1515 tmp_rp_ptr = &race_info[creature_ptr->prace];
1517 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1518 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1520 if (is_shero(creature_ptr)) {
1529 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1540 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1543 BIT_FLAGS flgs[TR_FLAG_SIZE];
1545 ACTION_SKILL_POWER pow;
1549 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1550 pow += creature_ptr->lev * 10;
1553 if (is_shero(creature_ptr))
1556 pow += adj_str_dig[creature_ptr->stat_index[A_STR]];
1558 if (creature_ptr->pclass == CLASS_BERSERKER)
1559 pow += (100 + creature_ptr->lev * 8);
1561 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1562 o_ptr = &creature_ptr->inventory_list[i];
1565 object_flags(creature_ptr, o_ptr, flgs);
1566 if (has_flag(flgs, TR_TUNNEL))
1567 pow += (o_ptr->pval * 20);
1570 for (int i = 0; i < 2; i++) {
1571 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1572 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1573 pow += (o_ptr->weight / 10);
1577 if (is_shero(creature_ptr)) {
1587 static bool is_martial_arts_mode(player_type *creature_ptr)
1589 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1590 && (any_bits(empty_hands(creature_ptr, TRUE), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1593 static bool is_heavy_wield(player_type *creature_ptr, int i)
1595 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1597 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1600 static s16b calc_num_blow(player_type *creature_ptr, int i)
1603 BIT_FLAGS flgs[TR_FLAG_SIZE];
1606 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1607 object_flags(creature_ptr, o_ptr, flgs);
1608 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1609 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1610 int str_index, dex_index;
1611 int num = 0, wgt = 0, mul = 0, div = 0;
1613 num = class_info[creature_ptr->pclass].num;
1614 wgt = class_info[creature_ptr->pclass].wgt;
1615 mul = class_info[creature_ptr->pclass].mul;
1617 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1623 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1629 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1630 str_index = (adj_str_blow[creature_ptr->stat_index[A_STR]] * mul / div);
1632 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1634 if (creature_ptr->pclass == CLASS_NINJA)
1635 str_index = MAX(0, str_index - 1);
1639 dex_index = (adj_dex_blow[creature_ptr->stat_index[A_DEX]]);
1643 num_blow = blows_table[str_index][dex_index];
1645 num_blow = (s16b)num;
1647 num_blow += (s16b)creature_ptr->extra_blows[i];
1648 if (creature_ptr->pclass == CLASS_WARRIOR)
1649 num_blow += (creature_ptr->lev / 40);
1650 else if (creature_ptr->pclass == CLASS_BERSERKER)
1651 num_blow += (creature_ptr->lev / 23);
1652 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_index[A_DEX] >= 30))
1655 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1658 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1668 /* Different calculation for monks with empty hands */
1669 if (is_martial_arts_mode(creature_ptr)) {
1670 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_index[A_DEX]];
1673 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1699 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1702 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1704 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1708 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1712 num_blow += 1 + creature_ptr->extra_blows[0];
1715 if (has_not_ninja_weapon(creature_ptr, i)) {
1726 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1729 * * 性格なまけものなら加算(+10)
1731 * * 性格ちからじまんとがまんづよいなら加算(+1)
1732 * * 性格チャージマンなら加算(+5)
1733 * * 装備品にTRC_HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
1735 static s16b calc_to_magic_chance(player_type *creature_ptr)
1739 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
1741 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
1743 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
1745 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
1748 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1750 BIT_FLAGS flgs[TR_FLAG_SIZE];
1751 o_ptr = &creature_ptr->inventory_list[i];
1754 object_flags(creature_ptr, o_ptr, flgs);
1755 if (any_bits(o_ptr->curse_flags, TRC_HARD_SPELL)) {
1756 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
1766 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
1768 ARMOUR_CLASS ac = 0;
1769 if (creature_ptr->yoiyami)
1772 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1774 o_ptr = &creature_ptr->inventory_list[i];
1780 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
1781 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
1782 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
1788 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
1790 ARMOUR_CLASS ac = 0;
1791 BIT_FLAGS flags[TR_FLAG_SIZE];
1792 if (creature_ptr->yoiyami)
1795 ac += ((int)(adj_dex_ta[creature_ptr->stat_index[A_DEX]]) - 128);
1797 if (creature_ptr->mimic_form) {
1798 switch (creature_ptr->mimic_form) {
1802 case MIMIC_DEMON_LORD:
1810 if (creature_ptr->pclass == CLASS_BERSERKER) {
1811 ac += 10 + creature_ptr->lev / 2;
1813 if (creature_ptr->pclass == CLASS_SORCERER) {
1817 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1819 o_ptr = &creature_ptr->inventory_list[i];
1820 object_flags(creature_ptr, o_ptr, flags);
1823 if (is_real_value || object_is_known(o_ptr))
1826 if (any_bits(o_ptr->curse_flags, TRC_LOW_AC)) {
1827 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
1828 if (is_real_value || object_is_fully_known(o_ptr))
1831 if (is_real_value || object_is_fully_known(o_ptr))
1836 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
1841 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
1842 ac += 10 + (creature_ptr->lev * 2 / 5);
1845 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
1849 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1850 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1854 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
1858 if (creature_ptr->muta.has(MUTA::WART_SKIN)) {
1862 if (creature_ptr->muta.has(MUTA::SCALES)) {
1866 if (creature_ptr->muta.has(MUTA::IRON_SKIN)) {
1870 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
1871 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
1872 ac += (creature_ptr->lev * 3) / 2;
1874 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
1875 ac += ((creature_ptr->lev - 13) / 3);
1877 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
1878 ac += ((creature_ptr->lev - 8) / 3);
1880 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
1881 ac += (creature_ptr->lev - 2) / 3;
1883 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
1884 ac += (creature_ptr->lev / 2);
1886 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
1887 ac += (creature_ptr->lev / 3);
1891 if (creature_ptr->realm1 == REALM_HEX) {
1892 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
1896 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
1897 object_type *o_ptr = &creature_ptr->inventory_list[i];
1900 if (!object_is_armour(creature_ptr, o_ptr))
1902 if (!object_is_cursed(o_ptr))
1904 if (any_bits(o_ptr->curse_flags, TRC_CURSED))
1906 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE))
1908 if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE))
1913 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1914 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
1915 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1917 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
1919 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1923 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
1925 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
1929 if (is_blessed(creature_ptr)) {
1933 if (is_shero(creature_ptr)) {
1937 if (creature_ptr->pclass == CLASS_NINJA) {
1938 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1939 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1940 ac += creature_ptr->lev / 2 + 5;
1948 * @brief 二刀流ペナルティ量計算
1949 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1950 * @param slot ペナルティ量を計算する武器スロット
1955 * * EASY2_WEAPONによる軽減
1956 * * SUPPORTIVEを左に装備した場合の軽減
1960 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
1963 BIT_FLAGS flags[TR_FLAG_SIZE];
1965 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
1966 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
1968 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
1969 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
1970 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
1971 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
1972 penalty = penalty / 2 - 5;
1975 for (unsigned int i = FLAG_CAUSE_INVEN_MAIN_HAND; i < FLAG_CAUSE_MAX; i <<= 1)
1976 if (penalty > 0 && any_bits(creature_ptr->easy_2weapon, i))
1979 if (has_flag(flags, TR_SUPPORTIVE))
1980 penalty = MAX(0, penalty - 10);
1982 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
1983 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
1984 penalty = MIN(0, penalty);
1987 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
1990 return (s16b)penalty;
1994 static bool is_riding_two_hands(player_type *creature_ptr)
1996 if (!creature_ptr->riding) {
2000 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
2002 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
2003 switch (creature_ptr->pclass) {
2005 case CLASS_FORCETRAINER:
2006 case CLASS_BERSERKER:
2007 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
2008 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
2019 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
2021 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2022 if (!creature_ptr->riding)
2027 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2028 if (creature_ptr->tval_ammo != TV_ARROW)
2031 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2037 if (creature_ptr->tval_ammo == TV_BOLT)
2043 void put_equipment_warning(player_type *creature_ptr)
2045 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
2046 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
2048 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2049 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
2050 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2052 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2054 creature_ptr->old_heavy_shoot = heavy_shoot;
2057 for (int i = 0; i < 2; i++) {
2058 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
2059 if (creature_ptr->heavy_wield[i]) {
2060 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2061 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2062 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2063 } else if (creature_ptr->heavy_wield[1 - i]) {
2064 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
2066 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2069 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
2072 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
2073 if (creature_ptr->riding_wield[i]) {
2074 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2075 } else if (!creature_ptr->riding) {
2076 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
2077 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2078 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2081 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
2084 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
2087 if (creature_ptr->icky_wield[i]) {
2088 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2089 if (current_world_ptr->is_loading_now) {
2090 chg_virtue(creature_ptr, V_FAITH, -1);
2092 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
2093 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2095 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2098 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
2101 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
2102 if (creature_ptr->riding_ryoute) {
2104 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2106 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
2110 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2112 msg_print("You began to control the pet you're riding with one hand.");
2116 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
2119 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
2120 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
2121 if (heavy_armor(creature_ptr)) {
2122 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2123 if (current_world_ptr->is_loading_now) {
2124 chg_virtue(creature_ptr, V_HARMONY, -1);
2127 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2130 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
2134 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2136 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2137 BIT_FLAGS flgs[TR_FLAG_SIZE];
2138 object_flags(creature_ptr, o_ptr, flgs);
2140 player_hand calc_hand = PLAYER_HAND_OTHER;
2141 if (slot == INVEN_MAIN_HAND)
2142 calc_hand = PLAYER_HAND_MAIN;
2143 if (slot == INVEN_SUB_HAND)
2144 calc_hand = PLAYER_HAND_SUB;
2147 damage += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2149 if (is_shero(creature_ptr)) {
2150 damage += 3 + (creature_ptr->lev / 5);
2153 if (creature_ptr->stun > 50) {
2155 } else if (creature_ptr->stun) {
2159 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2161 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2162 damage += creature_ptr->lev / 6;
2163 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2164 damage += creature_ptr->lev / 6;
2166 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2167 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2172 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
2173 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
2174 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2175 damage += get_current_ki(creature_ptr) / 5;
2179 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2180 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
2181 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
2184 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
2187 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
2193 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2195 o_ptr = &creature_ptr->inventory_list[i];
2196 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2197 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2200 if (!object_is_known(o_ptr) && !is_real_value)
2202 bonus_to_d = o_ptr->to_d;
2204 if (creature_ptr->pclass == CLASS_NINJA) {
2205 if (o_ptr->to_d > 0)
2206 bonus_to_d = (o_ptr->to_d + 1) / 2;
2209 switch (player_melee_type(creature_ptr)) {
2210 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2211 case MELEE_TYPE_WEAPON_TWOHAND:
2212 if (calc_hand == main_attack_hand(creature_ptr))
2213 damage += (s16b)bonus_to_d;
2216 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2217 case MELEE_TYPE_WEAPON_MAIN:
2218 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2219 damage += (s16b)bonus_to_d;
2222 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2223 case MELEE_TYPE_WEAPON_SUB:
2224 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2225 damage += (s16b)bonus_to_d;
2228 case MELEE_TYPE_WEAPON_DOUBLE:
2229 if (calc_hand == PLAYER_HAND_MAIN) {
2230 if (i == INVEN_MAIN_RING) {
2231 damage += (s16b)bonus_to_d;
2232 } else if (i != INVEN_SUB_RING) {
2233 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2236 if (calc_hand == PLAYER_HAND_SUB) {
2237 if (i == INVEN_SUB_RING) {
2238 damage += (s16b)bonus_to_d;
2239 } else if (i != INVEN_MAIN_RING) {
2240 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2245 case MELEE_TYPE_SHIELD_DOUBLE:
2253 if (main_attack_hand(creature_ptr) == calc_hand) {
2254 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2255 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2257 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128) / 2;
2258 damage += MAX(bonus_to_d, 1);
2262 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2263 damage += (creature_ptr->lev / 6);
2266 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
2267 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2268 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2269 damage -= (creature_ptr->lev / 6);
2277 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
2279 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
2281 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
2286 hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2287 hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2289 /* Temporary bonuses */
2290 if (is_blessed(creature_ptr)) {
2294 if (is_hero(creature_ptr)) {
2298 if (is_shero(creature_ptr)) {
2302 if (creature_ptr->stun > 50) {
2304 } else if (creature_ptr->stun) {
2308 player_hand calc_hand = PLAYER_HAND_OTHER;
2309 if (slot == INVEN_MAIN_HAND)
2310 calc_hand = PLAYER_HAND_MAIN;
2311 if (slot == INVEN_SUB_HAND)
2312 calc_hand = PLAYER_HAND_SUB;
2314 /* Default hand bonuses */
2315 if (main_attack_hand(creature_ptr) == calc_hand) {
2316 switch (player_melee_type(creature_ptr)) {
2317 case MELEE_TYPE_BAREHAND_MAIN:
2318 if (creature_ptr->riding)
2321 case MELEE_TYPE_BAREHAND_SUB:
2322 if (creature_ptr->riding)
2325 case MELEE_TYPE_BAREHAND_TWO:
2326 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2333 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
2334 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
2336 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);
2337 hit += MAX(bonus_to_h, 1);
2341 /* Bonuses and penalties by weapon */
2342 if (has_melee_weapon(creature_ptr, slot)) {
2343 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2344 BIT_FLAGS flgs[TR_FLAG_SIZE];
2345 object_flags(creature_ptr, o_ptr, flgs);
2347 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
2348 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
2350 /* Traind bonuses */
2351 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2353 /* Weight penalty */
2354 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
2355 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2358 /* Low melee penalty */
2359 if ((object_is_fully_known(o_ptr) || is_real_value) && any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
2360 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2367 /* Riding bonus and penalty */
2368 if (creature_ptr->riding) {
2369 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2374 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
2375 && !has_flag(flgs, TR_RIDING)) {
2377 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
2380 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
2385 hit -= (s16b)penalty;
2388 /* Class penalties */
2389 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
2391 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
2392 hit += creature_ptr->lev / 5;
2393 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
2394 hit += creature_ptr->lev / 5;
2396 } else if (creature_ptr->pclass == CLASS_SORCERER) {
2397 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
2404 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
2408 /* Hex realm bonuses */
2409 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
2410 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
2413 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
2416 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
2419 if (any_bits(o_ptr->curse_flags, (TRC_TY_CURSE))) {
2425 /* Bonuses from inventory */
2426 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2427 object_type *o_ptr = &creature_ptr->inventory_list[i];
2429 /* Ignore empty hands, handed weapons, bows and capture balls */
2430 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2431 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2434 /* Fake value does not include unknown objects' value */
2435 if (!object_is_known(o_ptr) && !is_real_value)
2438 int bonus_to_h = o_ptr->to_h;
2440 /* When wields only a weapon */
2441 if (creature_ptr->pclass == CLASS_NINJA) {
2442 if (o_ptr->to_h > 0)
2443 bonus_to_h = (o_ptr->to_h + 1) / 2;
2446 switch (player_melee_type(creature_ptr)) {
2447 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
2448 case MELEE_TYPE_WEAPON_TWOHAND:
2449 if (calc_hand == main_attack_hand(creature_ptr))
2450 hit += (s16b)bonus_to_h;
2453 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
2454 case MELEE_TYPE_WEAPON_MAIN:
2455 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
2456 hit += (s16b)bonus_to_h;
2459 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
2460 case MELEE_TYPE_WEAPON_SUB:
2461 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
2462 hit += (s16b)bonus_to_h;
2465 case MELEE_TYPE_WEAPON_DOUBLE:
2466 if (calc_hand == PLAYER_HAND_MAIN) {
2467 if (i == INVEN_MAIN_RING) {
2468 hit += (s16b)bonus_to_h;
2469 } else if (i != INVEN_SUB_RING) {
2470 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2473 if (calc_hand == PLAYER_HAND_SUB) {
2474 if (i == INVEN_SUB_RING) {
2475 hit += (s16b)bonus_to_h;
2476 } else if (i != INVEN_MAIN_RING) {
2477 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2482 case MELEE_TYPE_SHIELD_DOUBLE:
2490 /* Martial arts bonus */
2491 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
2492 hit += (creature_ptr->lev / 3);
2495 /* Two handed combat penalty */
2496 hit -= calc_double_weapon_penalty(creature_ptr, slot);
2498 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
2499 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2500 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
2501 hit -= (creature_ptr->lev / 3);
2508 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
2512 pow += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2513 pow += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2517 BIT_FLAGS flgs[TR_FLAG_SIZE];
2518 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2520 object_flags(creature_ptr, o_ptr, flgs);
2522 if (any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
2523 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2532 if (creature_ptr->stun > 50) {
2534 } else if (creature_ptr->stun) {
2538 if (is_blessed(creature_ptr)) {
2542 if (is_hero(creature_ptr)) {
2546 if (is_shero(creature_ptr)) {
2550 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2552 if (is_heavy_shoot(creature_ptr, o_ptr)) {
2553 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
2557 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
2558 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
2559 pow += (10 + (creature_ptr->lev / 5));
2565 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2567 o_ptr = &creature_ptr->inventory_list[i];
2568 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
2569 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
2572 bonus_to_h = o_ptr->to_h;
2574 if (creature_ptr->pclass == CLASS_NINJA) {
2575 if (o_ptr->to_h > 0)
2576 bonus_to_h = (o_ptr->to_h + 1) / 2;
2579 if (is_real_value || object_is_known(o_ptr))
2580 pow += (s16b)bonus_to_h;
2583 pow -= calc_riding_bow_penalty(creature_ptr);
2588 static s16b calc_to_damage_misc(player_type *creature_ptr)
2591 BIT_FLAGS flgs[TR_FLAG_SIZE];
2595 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2596 o_ptr = &creature_ptr->inventory_list[i];
2600 object_flags(creature_ptr, o_ptr, flgs);
2602 int bonus_to_d = o_ptr->to_d;
2603 if (creature_ptr->pclass == CLASS_NINJA) {
2604 if (o_ptr->to_d > 0)
2605 bonus_to_d = (o_ptr->to_d + 1) / 2;
2607 to_dam += (s16b)bonus_to_d;
2610 if (is_shero(creature_ptr)) {
2611 to_dam += 3 + (creature_ptr->lev / 5);
2614 if (creature_ptr->stun > 50) {
2616 } else if (creature_ptr->stun) {
2620 to_dam += ((int)(adj_str_td[creature_ptr->stat_index[A_STR]]) - 128);
2624 static s16b calc_to_hit_misc(player_type *creature_ptr)
2627 BIT_FLAGS flgs[TR_FLAG_SIZE];
2631 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2632 o_ptr = &creature_ptr->inventory_list[i];
2636 object_flags(creature_ptr, o_ptr, flgs);
2638 int bonus_to_h = o_ptr->to_h;
2639 if (creature_ptr->pclass == CLASS_NINJA) {
2640 if (o_ptr->to_h > 0)
2641 bonus_to_h = (o_ptr->to_h + 1) / 2;
2643 to_hit += (s16b)bonus_to_h;
2646 if (is_blessed(creature_ptr)) {
2650 if (is_hero(creature_ptr)) {
2654 if (is_shero(creature_ptr)) {
2658 if (creature_ptr->stun > 50) {
2660 } else if (creature_ptr->stun) {
2664 to_hit += ((int)(adj_dex_th[creature_ptr->stat_index[A_DEX]]) - 128);
2665 to_hit += ((int)(adj_str_th[creature_ptr->stat_index[A_STR]]) - 128);
2670 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
2672 object_type *o_ptr = &creature_ptr->inventory_list[slot];
2675 if (creature_ptr->riding) {
2676 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
2684 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
2686 (void)creature_ptr; // unused
2687 (void)slot; // unused
2692 * @brief プレイヤーの所持重量制限を計算する /
2693 * Computes current weight limit.
2696 WEIGHT calc_weight_limit(player_type *creature_ptr)
2698 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_index[A_STR]] * 50;
2699 if (creature_ptr->pclass == CLASS_BERSERKER)
2705 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
2706 * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND)
2707 * @return 持っているならばTRUE
2709 bool has_melee_weapon(player_type *creature_ptr, int slot)
2711 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
2715 * @brief プレイヤーの現在開いている手の状態を返す
2716 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
2717 * @return 開いている手のビットフラグ
2719 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
2721 BIT_FLAGS16 status = EMPTY_HAND_NONE;
2722 if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx)
2723 status |= EMPTY_HAND_MAIN;
2724 if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx)
2725 status |= EMPTY_HAND_SUB;
2727 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
2728 if (any_bits(status, EMPTY_HAND_SUB))
2729 reset_bits(status, EMPTY_HAND_SUB);
2730 else if (any_bits(status, EMPTY_HAND_MAIN))
2731 reset_bits(status, EMPTY_HAND_MAIN);
2738 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
2739 * @return ペナルティが適用されるならばTRUE。
2741 bool heavy_armor(player_type *creature_ptr)
2743 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
2746 WEIGHT monk_arm_wgt = 0;
2747 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
2748 monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
2749 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
2750 monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
2751 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
2752 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
2753 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
2754 monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
2755 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
2757 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
2761 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
2763 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
2765 void update_creature(player_type *creature_ptr)
2767 if (!creature_ptr->update)
2770 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2771 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
2772 reset_bits(creature_ptr->update, PU_AUTODESTROY);
2773 autopick_delayed_alter(creature_ptr);
2776 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
2777 reset_bits(creature_ptr->update, PU_COMBINE);
2778 combine_pack(creature_ptr);
2781 if (any_bits(creature_ptr->update, (PU_REORDER))) {
2782 reset_bits(creature_ptr->update, PU_REORDER);
2783 reorder_pack(creature_ptr);
2786 if (any_bits(creature_ptr->update, (PU_BONUS))) {
2787 reset_bits(creature_ptr->update, PU_BONUS);
2788 update_alignment(creature_ptr);
2789 update_bonuses(creature_ptr);
2792 if (any_bits(creature_ptr->update, (PU_TORCH))) {
2793 reset_bits(creature_ptr->update, PU_TORCH);
2794 update_lite_radius(creature_ptr);
2797 if (any_bits(creature_ptr->update, (PU_HP))) {
2798 reset_bits(creature_ptr->update, PU_HP);
2799 update_max_hitpoints(creature_ptr);
2802 if (any_bits(creature_ptr->update, (PU_MANA))) {
2803 reset_bits(creature_ptr->update, PU_MANA);
2804 update_max_mana(creature_ptr);
2807 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
2808 reset_bits(creature_ptr->update, PU_SPELLS);
2809 update_num_of_spells(creature_ptr);
2812 if (!current_world_ptr->character_generated)
2814 if (current_world_ptr->character_icky_depth > 0)
2816 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
2817 reset_bits(creature_ptr->update, PU_UN_LITE);
2818 forget_lite(floor_ptr);
2821 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
2822 reset_bits(creature_ptr->update, PU_UN_VIEW);
2823 forget_view(floor_ptr);
2826 if (any_bits(creature_ptr->update, (PU_VIEW))) {
2827 reset_bits(creature_ptr->update, PU_VIEW);
2828 update_view(creature_ptr);
2831 if (any_bits(creature_ptr->update, (PU_LITE))) {
2832 reset_bits(creature_ptr->update, PU_LITE);
2833 update_lite(creature_ptr);
2836 if (any_bits(creature_ptr->update, (PU_FLOW))) {
2837 reset_bits(creature_ptr->update, PU_FLOW);
2838 update_flow(creature_ptr);
2841 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
2842 reset_bits(creature_ptr->update, PU_DISTANCE);
2844 update_monsters(creature_ptr, TRUE);
2847 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
2848 reset_bits(creature_ptr->update, PU_MON_LITE);
2849 update_mon_lite(creature_ptr);
2852 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
2853 reset_bits(creature_ptr->update, PU_DELAY_VIS);
2854 delayed_visual_update(creature_ptr);
2857 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
2858 reset_bits(creature_ptr->update, PU_MONSTERS);
2859 update_monsters(creature_ptr, FALSE);
2864 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
2865 * @return 魔道書を一冊も持っていないならTRUEを返す
2867 bool player_has_no_spellbooks(player_type *creature_ptr)
2870 for (int i = 0; i < INVEN_PACK; i++) {
2871 o_ptr = &creature_ptr->inventory_list[i];
2872 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2876 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2877 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
2878 o_ptr = &floor_ptr->o_list[i];
2879 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
2886 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
2888 creature_ptr->energy_use = (ENERGY)need_cost;
2891 void free_turn(player_type *creature_ptr)
2893 creature_ptr->energy_use = 0;
2897 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
2900 * @return 配置に成功したらTRUE
2902 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
2904 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
2907 /* Save player location */
2908 creature_ptr->y = y;
2909 creature_ptr->x = x;
2914 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
2917 void wreck_the_pattern(player_type *creature_ptr)
2919 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2920 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
2921 if (pattern_type == PATTERN_TILE_WRECKED)
2924 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
2925 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
2927 if (!is_invuln(creature_ptr))
2928 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
2930 int to_ruin = randint1(45) + 35;
2933 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
2935 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
2936 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
2940 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
2944 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
2945 * Advance experience levels and print experience
2948 void check_experience(player_type *creature_ptr)
2950 if (creature_ptr->exp < 0)
2951 creature_ptr->exp = 0;
2952 if (creature_ptr->max_exp < 0)
2953 creature_ptr->max_exp = 0;
2954 if (creature_ptr->max_max_exp < 0)
2955 creature_ptr->max_max_exp = 0;
2957 if (creature_ptr->exp > PY_MAX_EXP)
2958 creature_ptr->exp = PY_MAX_EXP;
2959 if (creature_ptr->max_exp > PY_MAX_EXP)
2960 creature_ptr->max_exp = PY_MAX_EXP;
2961 if (creature_ptr->max_max_exp > PY_MAX_EXP)
2962 creature_ptr->max_max_exp = PY_MAX_EXP;
2964 if (creature_ptr->exp > creature_ptr->max_exp)
2965 creature_ptr->max_exp = creature_ptr->exp;
2966 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
2967 creature_ptr->max_max_exp = creature_ptr->max_exp;
2969 set_bits(creature_ptr->redraw, PR_EXP);
2970 handle_stuff(creature_ptr);
2972 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
2973 PLAYER_LEVEL old_lev = creature_ptr->lev;
2974 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
2975 creature_ptr->lev--;
2976 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2977 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
2978 set_bits(creature_ptr->window_flags, PW_PLAYER);
2979 handle_stuff(creature_ptr);
2982 bool level_reward = FALSE;
2983 bool level_mutation = FALSE;
2984 bool level_inc_stat = FALSE;
2985 while ((creature_ptr->lev < PY_MAX_LEVEL)
2986 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
2987 creature_ptr->lev++;
2988 if (creature_ptr->lev > creature_ptr->max_plv) {
2989 creature_ptr->max_plv = creature_ptr->lev;
2991 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || creature_ptr->muta.has(MUTA::CHAOS_GIFT)) {
2992 level_reward = TRUE;
2994 if (creature_ptr->prace == RACE_BEASTMAN) {
2996 level_mutation = TRUE;
2998 level_inc_stat = TRUE;
3000 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
3004 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
3005 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
3006 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
3007 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
3008 creature_ptr->level_up_message = TRUE;
3009 handle_stuff(creature_ptr);
3011 creature_ptr->level_up_message = FALSE;
3012 if (level_inc_stat) {
3013 if (!(creature_ptr->max_plv % 10)) {
3020 cnv_stat(creature_ptr->stat_max[0], tmp);
3021 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
3022 cnv_stat(creature_ptr->stat_max[1], tmp);
3023 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
3024 cnv_stat(creature_ptr->stat_max[2], tmp);
3025 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
3026 cnv_stat(creature_ptr->stat_max[3], tmp);
3027 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
3028 cnv_stat(creature_ptr->stat_max[4], tmp);
3029 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
3030 cnv_stat(creature_ptr->stat_max[5], tmp);
3031 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
3034 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
3038 if ((choice >= 'a') && (choice <= 'f'))
3041 for (n = 0; n < A_MAX; n++)
3042 if (n != choice - 'a')
3044 if (get_check(_("よろしいですか?", "Are you sure? ")))
3047 do_inc_stat(creature_ptr, choice - 'a');
3049 } else if (!(creature_ptr->max_plv % 2))
3050 do_inc_stat(creature_ptr, randint0(6));
3053 if (level_mutation) {
3054 msg_print(_("あなたは変わった気がする...", "You feel different..."));
3055 (void)gain_mutation(creature_ptr, 0);
3056 level_mutation = FALSE;
3060 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
3064 gain_level_reward(creature_ptr, 0);
3065 level_reward = FALSE;
3068 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3069 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
3070 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
3071 handle_stuff(creature_ptr);
3074 if (old_lev != creature_ptr->lev)
3075 autopick_load_pref(creature_ptr, FALSE);
3079 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
3081 * @param out_val 出力先文字列ポインタ
3084 void cnv_stat(int val, char *out_val)
3087 sprintf(out_val, " %2d", val);
3091 int bonus = (val - 18);
3093 sprintf(out_val, "18/%3s", "***");
3094 } else if (bonus >= 100) {
3095 sprintf(out_val, "18/%03d", bonus);
3097 sprintf(out_val, " 18/%02d", bonus);
3102 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
3103 * Modify a stat value by a "modifier", return new value
3105 * @param amount 加減算値
3109 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
3110 * Or even: 18/13, 18/23, 18/33, ..., 18/220
3111 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
3112 * Or even: 18/13, 18/03, 18, 17, ..., 3
3115 s16b modify_stat_value(int value, int amount)
3118 for (int i = 0; i < amount; i++) {
3124 } else if (amount < 0) {
3125 for (int i = 0; i < (0 - amount); i++) {
3126 if (value >= 18 + 10)
3128 else if (value > 18)
3140 * Hack -- Calculates the total number of points earned -JWT-
3144 long calc_score(player_type *creature_ptr)
3146 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
3159 if (ironman_small_levels)
3161 if (ironman_empty_levels)
3167 if (ironman_nightmare)
3174 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
3175 if (max_dlv[i] > max_dl)
3176 max_dl = max_dlv[i];
3178 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
3179 u32b point_h = point_l / 0x10000L;
3180 point_l = point_l % 0x10000L;
3183 point_h += point_l / 0x10000L;
3184 point_l %= 0x10000L;
3186 point_l += ((point_h % 100) << 16);
3190 u32b point = (point_h << 16) + (point_l);
3191 if (creature_ptr->arena_number >= 0)
3192 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
3194 if (ironman_downward)
3196 if (creature_ptr->pclass == CLASS_BERSERKER) {
3197 if (creature_ptr->prace == RACE_SPECTRE)
3201 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
3203 if (current_world_ptr->total_winner)
3208 point = (0 - point);
3214 * @param creature_ptr プレーヤーへの参照ポインタ
3215 * @return 祝福状態ならばTRUE
3217 bool is_blessed(player_type *creature_ptr)
3219 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
3222 bool is_tim_esp(player_type *creature_ptr)
3224 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3227 bool is_tim_stealth(player_type *creature_ptr)
3229 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
3232 bool is_time_limit_esp(player_type *creature_ptr)
3234 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
3237 bool is_time_limit_stealth(player_type *creature_ptr)
3239 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
3242 bool can_two_hands_wielding(player_type *creature_ptr)
3244 return !creature_ptr->riding || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS);
3248 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
3251 void stop_singing(player_type *creature_ptr)
3253 if (creature_ptr->pclass != CLASS_BARD)
3256 /* Are there interupted song? */
3257 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
3258 /* Forget interupted song */
3259 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3263 /* The player is singing? */
3264 if (!SINGING_SONG_EFFECT(creature_ptr))
3267 /* Hack -- if called from set_action(), avoid recursive loop */
3268 if (creature_ptr->action == ACTION_SING)
3269 set_action(creature_ptr, ACTION_NONE);
3271 /* Message text of each song or etc. */
3272 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
3274 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
3275 SINGING_SONG_ID(creature_ptr) = 0;
3276 set_bits(creature_ptr->update, PU_BONUS);
3277 set_bits(creature_ptr->redraw, PR_STATUS);
3281 * @brief 口を使う継続的な処理を中断する
3282 * @param caster_ptr プレーヤーへの参照ポインタ
3285 void stop_mouth(player_type *caster_ptr)
3287 if (music_singing_any(caster_ptr))
3288 stop_singing(caster_ptr);
3289 if (hex_spelling_any(caster_ptr))
3290 stop_hex_spell_all(caster_ptr);
3294 * @brief ペットの維持コスト計算
3297 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
3300 bool has_a_unique = FALSE;
3301 DEPTH total_friend_levels = 0;
3305 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
3306 monster_type *m_ptr;
3307 monster_race *r_ptr;
3309 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
3310 if (!monster_is_valid(m_ptr))
3312 r_ptr = &r_info[m_ptr->r_idx];
3314 if (is_pet(m_ptr)) {
3316 if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
3317 if (creature_ptr->pclass == CLASS_CAVALRY) {
3318 if (creature_ptr->riding == m_idx)
3319 total_friend_levels += (r_ptr->level + 5) * 2;
3320 else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
3321 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
3323 total_friend_levels += (r_ptr->level + 5) * 10;
3324 has_a_unique = TRUE;
3326 total_friend_levels += (r_ptr->level + 5) * 10;
3328 total_friend_levels += r_ptr->level;
3332 if (total_friends) {
3334 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
3335 if (upkeep_factor < 0)
3337 if (upkeep_factor > 1000)
3338 upkeep_factor = 1000;
3339 return upkeep_factor;
3344 bool music_singing(player_type *caster_ptr, int music_songs)
3346 return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);
3349 bool is_fast(player_type *creature_ptr)
3351 return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO);
3354 bool is_invuln(player_type *creature_ptr)
3356 return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN);
3359 bool is_hero(player_type *creature_ptr)
3361 return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO);
3364 bool is_shero(player_type *creature_ptr)
3366 return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER;
3369 bool is_echizen(player_type *creature_ptr)
3371 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
3374 int calc_weapon_weight_limit(player_type *creature_ptr)
3376 int weight = adj_str_hold[creature_ptr->stat_index[A_STR]];
3378 if (has_two_handed_weapons(creature_ptr))
3384 static player_hand main_attack_hand(player_type *creature_ptr)
3386 switch (player_melee_type(creature_ptr)) {
3387 case MELEE_TYPE_BAREHAND_TWO:
3388 return PLAYER_HAND_MAIN;
3389 case MELEE_TYPE_BAREHAND_MAIN:
3390 return PLAYER_HAND_MAIN;
3391 case MELEE_TYPE_BAREHAND_SUB:
3392 return PLAYER_HAND_SUB;
3393 case MELEE_TYPE_WEAPON_MAIN:
3394 return PLAYER_HAND_MAIN;
3395 case MELEE_TYPE_WEAPON_SUB:
3396 return PLAYER_HAND_SUB;
3397 case MELEE_TYPE_WEAPON_TWOHAND:
3398 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
3399 case MELEE_TYPE_WEAPON_DOUBLE:
3400 return PLAYER_HAND_MAIN;
3401 case MELEE_TYPE_SHIELD_DOUBLE:
3402 return PLAYER_HAND_MAIN;
3404 return PLAYER_HAND_MAIN;
3408 * @brief プレイヤーが現在ダンジョンに潜っているかどうかを返す。
3409 * @memo 現在はdun_levelが0でないかそうでないかに限るが可読性を高めるため。
3411 bool is_in_dungeon(player_type *creature_ptr)
3413 return creature_ptr->current_floor_ptr->dun_level > 0;