1 #include "player/player-status.h"
2 #include "artifact/fixed-art-types.h"
3 #include "autopick/autopick-reader-writer.h"
4 #include "autopick/autopick.h"
5 #include "cmd-action/cmd-pet.h"
6 #include "cmd-action/cmd-spell.h"
7 #include "cmd-io/cmd-dump.h"
8 #include "cmd-item/cmd-magiceat.h"
9 #include "combat/attack-power-table.h"
10 #include "core/asking-player.h"
11 #include "core/player-redraw-types.h"
12 #include "core/player-update-types.h"
13 #include "core/stuff-handler.h"
14 #include "core/window-redrawer.h"
15 #include "dungeon/dungeon-flag-types.h"
16 #include "dungeon/dungeon.h"
17 #include "effect/effect-characteristics.h"
18 #include "floor/cave.h"
19 #include "floor/floor-events.h"
20 #include "floor/floor-leaver.h"
21 #include "floor/floor-save.h"
22 #include "floor/floor-util.h"
23 #include "game-option/birth-options.h"
24 #include "grid/feature.h"
25 #include "inventory/inventory-object.h"
26 #include "inventory/inventory-slot-types.h"
27 #include "io/input-key-acceptor.h"
28 #include "io/write-diary.h"
29 #include "main/sound-definitions-table.h"
30 #include "main/sound-of-music.h"
31 #include "market/arena-info-table.h"
32 #include "mind/mind-force-trainer.h"
33 #include "mind/mind-ninja.h"
34 #include "monster-floor/monster-lite.h"
35 #include "monster-floor/monster-remover.h"
36 #include "monster-race/monster-race-hook.h"
37 #include "monster-race/monster-race.h"
38 #include "monster-race/race-flags1.h"
39 #include "monster-race/race-flags2.h"
40 #include "monster-race/race-flags3.h"
41 #include "monster-race/race-flags7.h"
42 #include "monster/monster-info.h"
43 #include "monster/monster-status.h"
44 #include "monster/monster-update.h"
45 #include "monster/smart-learn-types.h"
46 #include "mutation/mutation-calculator.h"
47 #include "mutation/mutation-flag-types.h"
48 #include "mutation/mutation-investor-remover.h"
49 #include "object-enchant/object-ego.h"
50 #include "object-enchant/special-object-flags.h"
51 #include "object-enchant/tr-types.h"
52 #include "object-enchant/trc-types.h"
53 #include "object-hook/hook-armor.h"
54 #include "object-hook/hook-checker.h"
55 #include "object-hook/hook-weapon.h"
56 #include "object/object-flags.h"
57 #include "object/object-info.h"
58 #include "object/object-mark-types.h"
59 #include "perception/object-perception.h"
60 #include "pet/pet-util.h"
61 #include "player-info/avatar.h"
62 #include "player/attack-defense-types.h"
63 #include "player/digestion-processor.h"
64 #include "player/mimic-info-table.h"
65 #include "player/patron.h"
66 #include "player/player-class.h"
67 #include "player/player-damage.h"
68 #include "player/player-move.h"
69 #include "player/player-personalities-types.h"
70 #include "player/player-personality.h"
71 #include "player/player-race-types.h"
72 #include "player/player-skill.h"
73 #include "player/player-status-flags.h"
74 #include "player/player-status-table.h"
75 #include "player/player-view.h"
76 #include "player/race-info-table.h"
77 #include "player/special-defense-types.h"
78 #include "realm/realm-hex-numbers.h"
79 #include "realm/realm-names-table.h"
80 #include "realm/realm-song-numbers.h"
81 #include "specific-object/bow.h"
82 #include "specific-object/torch.h"
83 #include "spell-realm/spells-hex.h"
84 #include "spell/range-calc.h"
85 #include "spell/spells-describer.h"
86 #include "spell/spells-execution.h"
87 #include "spell/spells-status.h"
88 #include "spell/technic-info-table.h"
89 #include "status/action-setter.h"
90 #include "status/base-status.h"
91 #include "sv-definition/sv-lite-types.h"
92 #include "sv-definition/sv-weapon-types.h"
93 #include "system/angband.h"
94 #include "system/floor-type-definition.h"
95 #include "term/screen-processor.h"
96 #include "util/bit-flags-calculator.h"
97 #include "util/quarks.h"
98 #include "util/string-processor.h"
99 #include "view/display-messages.h"
100 #include "world/world.h"
102 static bool is_martial_arts_mode(player_type *creature_ptr);
104 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr);
105 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr);
106 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr);
107 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr);
108 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr);
109 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr);
110 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr);
111 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr);
112 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr);
113 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr);
114 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr);
115 static bool is_heavy_wield(player_type *creature_ptr, int i);
116 static s16b calc_num_blow(player_type *creature_ptr, int i);
117 static s16b calc_strength_addition(player_type *creature_ptr);
118 static s16b calc_intelligence_addition(player_type *creature_ptr);
119 static s16b calc_wisdom_addition(player_type *creature_ptr);
120 static s16b calc_dexterity_addition(player_type *creature_ptr);
121 static s16b calc_constitution_addition(player_type *creature_ptr);
122 static s16b calc_charisma_addition(player_type *creature_ptr);
123 static s16b calc_to_magic_chance(player_type *creature_ptr);
124 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
125 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value);
126 static s16b calc_speed(player_type *creature_ptr);
127 static s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot);
128 static void update_use_status(player_type *creature_ptr, int status);
129 static void update_top_status(player_type *creature_ptr, int status);
130 static void update_ind_status(player_type *creature_ptr, int status);
131 static bool is_riding_two_hands(player_type *creature_ptr);
132 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
133 static void put_equipment_warning(player_type *creature_ptr);
135 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
136 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value);
138 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value);
140 static s16b calc_to_damage_misc(player_type *creature_ptr);
141 static s16b calc_to_hit_misc(player_type *creature_ptr);
143 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
144 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
146 static player_hand main_attack_hand(player_type *creature_ptr);
148 /*** Player information ***/
151 * @brief プレイヤー用のクリーチャー構造体実体 / Static player info record
156 * @brief プレイヤー用のクリーチャー構造体参照ポインタ / Pointer to the player info
158 player_type *p_ptr = &p_body;
161 * @brief クリーチャーの抽象的善悪アライメントの表記を返す。 / Return alignment title
162 * @param creature_ptr 算出するクリーチャーの参照ポインタ。
163 * @return アライメントの表記を返す。
165 concptr your_alignment(player_type *creature_ptr)
167 if (creature_ptr->align > 150)
168 return _("大善", "Lawful");
169 else if (creature_ptr->align > 50)
170 return _("中善", "Good");
171 else if (creature_ptr->align > 10)
172 return _("小善", "Neutral Good");
173 else if (creature_ptr->align > -11)
174 return _("中立", "Neutral");
175 else if (creature_ptr->align > -51)
176 return _("小悪", "Neutral Evil");
177 else if (creature_ptr->align > -151)
178 return _("中悪", "Evil");
180 return _("大悪", "Chaotic");
184 * @brief 武器や各種スキル(騎乗以外)の抽象的表現ランクを返す。 / Return proficiency level of weapons and misc. skills (except riding)
185 * @param weapon_exp 経験値
188 int weapon_exp_level(int weapon_exp)
190 if (weapon_exp < WEAPON_EXP_BEGINNER)
191 return EXP_LEVEL_UNSKILLED;
192 else if (weapon_exp < WEAPON_EXP_SKILLED)
193 return EXP_LEVEL_BEGINNER;
194 else if (weapon_exp < WEAPON_EXP_EXPERT)
195 return EXP_LEVEL_SKILLED;
196 else if (weapon_exp < WEAPON_EXP_MASTER)
197 return EXP_LEVEL_EXPERT;
199 return EXP_LEVEL_MASTER;
203 * @brief 騎乗スキルの抽象的ランクを返す。 / Return proficiency level of riding
204 * @param weapon_exp 経験値
207 int riding_exp_level(int riding_exp)
209 if (riding_exp < RIDING_EXP_BEGINNER)
210 return EXP_LEVEL_UNSKILLED;
211 else if (riding_exp < RIDING_EXP_SKILLED)
212 return EXP_LEVEL_BEGINNER;
213 else if (riding_exp < RIDING_EXP_EXPERT)
214 return EXP_LEVEL_SKILLED;
215 else if (riding_exp < RIDING_EXP_MASTER)
216 return EXP_LEVEL_EXPERT;
218 return EXP_LEVEL_MASTER;
222 * @brief クリーチャーの呪文レベルの抽象的ランクを返す。 / Return proficiency level of spells
223 * @param spell_exp 経験値
226 int spell_exp_level(int spell_exp)
228 if (spell_exp < SPELL_EXP_BEGINNER)
229 return EXP_LEVEL_UNSKILLED;
230 else if (spell_exp < SPELL_EXP_SKILLED)
231 return EXP_LEVEL_BEGINNER;
232 else if (spell_exp < SPELL_EXP_EXPERT)
233 return EXP_LEVEL_SKILLED;
234 else if (spell_exp < SPELL_EXP_MASTER)
235 return EXP_LEVEL_EXPERT;
237 return EXP_LEVEL_MASTER;
241 * @brief 遅延描画更新 / Delayed visual update
242 * @details update_view(), update_lite(), update_mon_lite() においてのみ更新すること / Only used if update_view(), update_lite() or update_mon_lite() was called
243 * @param player_ptr 主観となるプレイヤー構造体参照ポインタ
244 * @todo 将来独自インターフェース実装にはz-term系に追い出すべきか?
247 static void delayed_visual_update(player_type *player_ptr)
249 floor_type *floor_ptr = player_ptr->current_floor_ptr;
250 for (int i = 0; i < floor_ptr->redraw_n; i++) {
251 POSITION y = floor_ptr->redraw_y[i];
252 POSITION x = floor_ptr->redraw_x[i];
254 g_ptr = &floor_ptr->grid_array[y][x];
255 if (none_bits(g_ptr->info, CAVE_REDRAW))
258 if (any_bits(g_ptr->info, CAVE_NOTE))
259 note_spot(player_ptr, y, x);
261 lite_spot(player_ptr, y, x);
263 update_monster(player_ptr, g_ptr->m_idx, FALSE);
265 reset_bits(g_ptr->info, (CAVE_NOTE | CAVE_REDRAW));
268 floor_ptr->redraw_n = 0;
272 * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
273 * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
274 * @return 重すぎるならばTRUE
276 static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
278 int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
279 return (hold < o_ptr->weight / 10);
284 * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
287 WEIGHT calc_inventory_weight(player_type *creature_ptr)
292 for (inventory_slot_type i = 0; i < INVEN_TOTAL; i++) {
293 o_ptr = &creature_ptr->inventory_list[i];
296 weight += o_ptr->weight * o_ptr->number;
301 * @brief プレイヤーの全ステータスを更新する /
302 * Calculate the players current "state", taking into account
303 * not only race/class intrinsics, but also objects being worn
304 * and temporary spell effects.
308 * See also update_max_mana() and update_max_hitpoints().
310 * Take note of the new "speed code", in particular, a very strong
311 * player will start slowing down as soon as he reaches 150 pounds,
312 * but not until he reaches 450 pounds will he be half as fast as
313 * a normal kobold. This both hurts and helps the player, hurts
314 * because in the old days a player could just avoid 300 pounds,
315 * and helps because now carrying 300 pounds is not very painful.
317 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
318 * damage, since that would affect non-combat things. These values
319 * are actually added in later, at the appropriate place.
321 * This function induces various "status" messages.
323 * @todo ここで計算していた各値は一部の状態変化メッセージ処理を除き、今後必要な時に適示計算する形に移行するためほぼすべて削られる。
325 static void update_bonuses(player_type *creature_ptr)
327 int empty_hands_status = empty_hands(creature_ptr, TRUE);
330 /* Save the old vision stuff */
331 BIT_FLAGS old_telepathy = creature_ptr->telepathy;
332 BIT_FLAGS old_esp_animal = creature_ptr->esp_animal;
333 BIT_FLAGS old_esp_undead = creature_ptr->esp_undead;
334 BIT_FLAGS old_esp_demon = creature_ptr->esp_demon;
335 BIT_FLAGS old_esp_orc = creature_ptr->esp_orc;
336 BIT_FLAGS old_esp_troll = creature_ptr->esp_troll;
337 BIT_FLAGS old_esp_giant = creature_ptr->esp_giant;
338 BIT_FLAGS old_esp_dragon = creature_ptr->esp_dragon;
339 BIT_FLAGS old_esp_human = creature_ptr->esp_human;
340 BIT_FLAGS old_esp_evil = creature_ptr->esp_evil;
341 BIT_FLAGS old_esp_good = creature_ptr->esp_good;
342 BIT_FLAGS old_esp_nonliving = creature_ptr->esp_nonliving;
343 BIT_FLAGS old_esp_unique = creature_ptr->esp_unique;
344 BIT_FLAGS old_see_inv = creature_ptr->see_inv;
345 BIT_FLAGS old_mighty_throw = creature_ptr->mighty_throw;
346 s16b old_speed = creature_ptr->pspeed;
348 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
349 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
351 creature_ptr->xtra_might = has_xtra_might(creature_ptr);
352 creature_ptr->esp_evil = has_esp_evil(creature_ptr);
353 creature_ptr->esp_animal = has_esp_animal(creature_ptr);
354 creature_ptr->esp_undead = has_esp_undead(creature_ptr);
355 creature_ptr->esp_demon = has_esp_demon(creature_ptr);
356 creature_ptr->esp_orc = has_esp_orc(creature_ptr);
357 creature_ptr->esp_troll = has_esp_troll(creature_ptr);
358 creature_ptr->esp_giant = has_esp_giant(creature_ptr);
359 creature_ptr->esp_dragon = has_esp_dragon(creature_ptr);
360 creature_ptr->esp_human = has_esp_human(creature_ptr);
361 creature_ptr->esp_good = has_esp_good(creature_ptr);
362 creature_ptr->esp_nonliving = has_esp_nonliving(creature_ptr);
363 creature_ptr->esp_unique = has_esp_unique(creature_ptr);
364 creature_ptr->telepathy = has_esp_telepathy(creature_ptr);
365 creature_ptr->bless_blade = has_bless_blade(creature_ptr);
366 creature_ptr->easy_2weapon = has_easy2_weapon(creature_ptr);
367 creature_ptr->down_saving = has_down_saving(creature_ptr);
368 creature_ptr->yoiyami = has_no_ac(creature_ptr);
369 creature_ptr->mighty_throw = has_mighty_throw(creature_ptr);
370 creature_ptr->dec_mana = has_dec_mana(creature_ptr);
371 creature_ptr->see_nocto = has_see_nocto(creature_ptr);
372 creature_ptr->warning = has_warning(creature_ptr);
373 creature_ptr->anti_magic = has_anti_magic(creature_ptr);
374 creature_ptr->anti_tele = has_anti_tele(creature_ptr);
375 creature_ptr->easy_spell = has_easy_spell(creature_ptr);
376 creature_ptr->heavy_spell = has_heavy_spell(creature_ptr);
377 creature_ptr->hold_exp = has_hold_exp(creature_ptr);
378 creature_ptr->see_inv = has_see_inv(creature_ptr);
379 creature_ptr->free_act = has_free_act(creature_ptr);
380 creature_ptr->levitation = has_levitation(creature_ptr);
381 creature_ptr->can_swim = has_can_swim(creature_ptr);
382 creature_ptr->slow_digest = has_slow_digest(creature_ptr);
383 creature_ptr->regenerate = has_regenerate(creature_ptr);
384 update_curses(creature_ptr);
385 creature_ptr->impact = has_impact(creature_ptr);
386 update_extra_blows(creature_ptr);
388 creature_ptr->lite = has_lite(creature_ptr);
390 if (any_bits(creature_ptr->special_defense, KAMAE_MASK)) {
391 if (none_bits(empty_hands_status, EMPTY_HAND_MAIN)) {
392 set_action(creature_ptr, ACTION_NONE);
396 creature_ptr->stat_add[A_STR] = calc_strength_addition(creature_ptr);
397 creature_ptr->stat_add[A_INT] = calc_intelligence_addition(creature_ptr);
398 creature_ptr->stat_add[A_WIS] = calc_wisdom_addition(creature_ptr);
399 creature_ptr->stat_add[A_DEX] = calc_dexterity_addition(creature_ptr);
400 creature_ptr->stat_add[A_CON] = calc_constitution_addition(creature_ptr);
401 creature_ptr->stat_add[A_CHR] = calc_charisma_addition(creature_ptr);
403 for (int i = 0; i < A_MAX; i++) {
404 update_top_status(creature_ptr, i);
405 update_use_status(creature_ptr, i);
406 update_ind_status(creature_ptr, i);
409 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
411 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
412 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
413 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
417 for (int i = 0; i < 2; i++) {
418 creature_ptr->icky_wield[i] = has_icky_wield_weapon(creature_ptr, i);
419 creature_ptr->riding_wield[i] = has_riding_wield_weapon(creature_ptr, i);
420 creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i);
421 creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i);
422 creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i);
423 creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_MAIN_HAND + i);
426 creature_ptr->pspeed = calc_speed(creature_ptr);
427 creature_ptr->see_infra = calc_intra_vision(creature_ptr);
428 creature_ptr->skill_stl = calc_stealth(creature_ptr);
429 creature_ptr->skill_dis = calc_disarming(creature_ptr);
430 creature_ptr->skill_dev = calc_device_ability(creature_ptr);
431 creature_ptr->skill_sav = calc_saving_throw(creature_ptr);
432 creature_ptr->skill_srh = calc_search(creature_ptr);
433 creature_ptr->skill_fos = calc_search_freq(creature_ptr);
434 creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
435 creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
436 creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
437 creature_ptr->riding_ryoute = is_riding_two_hands(creature_ptr);
438 creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, TRUE);
439 creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, TRUE);
440 creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_MAIN_HAND, FALSE);
441 creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_SUB_HAND, FALSE);
442 creature_ptr->to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, TRUE);
443 creature_ptr->to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, TRUE);
444 creature_ptr->dis_to_h[0] = calc_to_hit(creature_ptr, INVEN_MAIN_HAND, FALSE);
445 creature_ptr->dis_to_h[1] = calc_to_hit(creature_ptr, INVEN_SUB_HAND, FALSE);
446 creature_ptr->to_h_b = calc_to_hit_bow(creature_ptr, TRUE);
447 creature_ptr->dis_to_h_b = calc_to_hit_bow(creature_ptr, FALSE);
448 creature_ptr->to_d_m = calc_to_damage_misc(creature_ptr);
449 creature_ptr->to_h_m = calc_to_hit_misc(creature_ptr);
450 creature_ptr->skill_dig = calc_skill_dig(creature_ptr);
451 creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
452 creature_ptr->ac = calc_base_ac(creature_ptr);
453 creature_ptr->to_a = calc_to_ac(creature_ptr, TRUE);
454 creature_ptr->dis_ac = calc_base_ac(creature_ptr);
455 creature_ptr->dis_to_a = calc_to_ac(creature_ptr, FALSE);
457 if (old_mighty_throw != creature_ptr->mighty_throw) {
458 creature_ptr->window_flags |= PW_INVEN;
461 if (creature_ptr->telepathy != old_telepathy) {
462 set_bits(creature_ptr->update, PU_MONSTERS);
465 if ((creature_ptr->esp_animal != old_esp_animal) || (creature_ptr->esp_undead != old_esp_undead) || (creature_ptr->esp_demon != old_esp_demon)
466 || (creature_ptr->esp_orc != old_esp_orc) || (creature_ptr->esp_troll != old_esp_troll) || (creature_ptr->esp_giant != old_esp_giant)
467 || (creature_ptr->esp_dragon != old_esp_dragon) || (creature_ptr->esp_human != old_esp_human) || (creature_ptr->esp_evil != old_esp_evil)
468 || (creature_ptr->esp_good != old_esp_good) || (creature_ptr->esp_nonliving != old_esp_nonliving) || (creature_ptr->esp_unique != old_esp_unique)) {
469 set_bits(creature_ptr->update, PU_MONSTERS);
472 if (creature_ptr->see_inv != old_see_inv) {
473 set_bits(creature_ptr->update, PU_MONSTERS);
476 if (creature_ptr->pspeed != old_speed) {
477 set_bits(creature_ptr->redraw, PR_SPEED);
480 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a)) {
481 set_bits(creature_ptr->redraw, PR_ARMOR);
482 set_bits(creature_ptr->window_flags, PW_PLAYER);
485 if (current_world_ptr->character_xtra)
488 put_equipment_warning(creature_ptr);
489 check_no_flowed(creature_ptr);
492 static void update_alignment(player_type *creature_ptr)
494 creature_ptr->align = 0;
495 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
496 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
499 m_ptr = &floor_ptr->m_list[m_idx];
500 if (!monster_is_valid(m_ptr))
502 r_ptr = &r_info[m_ptr->r_idx];
507 if (any_bits(r_ptr->flags3, RF3_GOOD))
508 creature_ptr->align += r_ptr->level;
509 if (any_bits(r_ptr->flags3, RF3_EVIL))
510 creature_ptr->align -= r_ptr->level;
513 if (creature_ptr->mimic_form) {
514 switch (creature_ptr->mimic_form) {
516 creature_ptr->align -= 200;
518 case MIMIC_DEMON_LORD:
519 creature_ptr->align -= 200;
523 switch (creature_ptr->prace) {
525 creature_ptr->align += 200;
528 creature_ptr->align -= 200;
533 for (int i = 0; i < 2; i++) {
534 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i))
536 if (creature_ptr->inventory_list[INVEN_MAIN_HAND + i].name1 != ART_IRON_BALL)
538 creature_ptr->align -= 1000;
543 for (int i = 0; i < 8; i++) {
544 switch (creature_ptr->vir_types[i]) {
546 creature_ptr->align += creature_ptr->virtues[i] * 2;
555 creature_ptr->align -= creature_ptr->virtues[i];
558 creature_ptr->align += creature_ptr->virtues[i];
563 for (int i = 0; i < j; i++) {
564 if (creature_ptr->align > 0) {
565 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
566 if (creature_ptr->align < 0)
567 creature_ptr->align = 0;
568 } else if (creature_ptr->align < 0) {
569 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
570 if (creature_ptr->align > 0)
571 creature_ptr->align = 0;
577 * @brief プレイヤーの最大HPを更新する /
578 * Update the players maximal hit points
579 * Adjust current hitpoints if necessary
583 static void update_max_hitpoints(player_type *creature_ptr)
585 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
586 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
589 if (creature_ptr->mimic_form) {
590 if (creature_ptr->pclass == CLASS_SORCERER)
591 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
593 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
594 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
597 if (creature_ptr->pclass == CLASS_SORCERER) {
598 if (creature_ptr->lev < 30)
599 mhp = (mhp * (45 + creature_ptr->lev) / 100);
601 mhp = (mhp * 75 / 100);
602 bonus = (bonus * 65 / 100);
607 if (creature_ptr->pclass == CLASS_BERSERKER) {
608 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
611 if (mhp < creature_ptr->lev + 1)
612 mhp = creature_ptr->lev + 1;
613 if (is_hero(creature_ptr))
615 if (is_shero(creature_ptr))
617 if (creature_ptr->tsuyoshi)
619 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT))
621 if (hex_spelling(creature_ptr, HEX_BUILDING))
623 if (creature_ptr->mhp == mhp)
626 if (creature_ptr->chp >= mhp) {
627 creature_ptr->chp = mhp;
628 creature_ptr->chp_frac = 0;
632 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp)) {
633 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
636 creature_ptr->mhp = mhp;
638 creature_ptr->redraw |= PR_HP;
639 creature_ptr->window_flags |= PW_PLAYER;
643 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
644 * Calculate number of spells player should have, and forget,
645 * or remember, spells until that number is properly reflected.
648 * Note that this function induces various "status" messages,
649 * which must be bypasses until the character is created.
651 static void update_num_of_spells(player_type *creature_ptr)
653 if (!mp_ptr->spell_book)
655 if (!current_world_ptr->character_generated)
657 if (current_world_ptr->character_xtra)
659 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)) {
660 creature_ptr->new_spells = 0;
664 concptr p = spell_category_name(mp_ptr->spell_book);
665 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
669 int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
671 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK)) {
675 if (creature_ptr->pclass == CLASS_SAMURAI) {
677 } else if (creature_ptr->realm2 == REALM_NONE) {
678 num_allowed = (num_allowed + 1) / 2;
679 if (num_allowed > (32 + bonus))
680 num_allowed = 32 + bonus;
681 } else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST)) {
682 if (num_allowed > (96 + bonus))
683 num_allowed = 96 + bonus;
685 if (num_allowed > (80 + bonus))
686 num_allowed = 80 + bonus;
689 int num_boukyaku = 0;
690 for (int j = 0; j < 64; j++) {
691 if ((j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)))) {
696 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
697 for (int i = 63; i >= 0; i--) {
698 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
701 int j = creature_ptr->spell_order[i];
705 const magic_type *s_ptr;
706 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
708 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
710 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
712 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
714 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
716 if (s_ptr->slevel <= creature_ptr->lev)
719 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
720 if (!is_spell_learned)
725 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
726 which = creature_ptr->realm1;
728 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
729 which = creature_ptr->realm2;
733 reset_bits(creature_ptr->spell_learned1, (1UL << j));
734 which = creature_ptr->realm1;
736 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
737 which = creature_ptr->realm2;
741 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
743 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
745 creature_ptr->new_spells++;
748 /* Forget spells if we know too many spells */
749 for (int i = 63; i >= 0; i--) {
750 if (creature_ptr->new_spells >= 0)
752 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2)
755 int j = creature_ptr->spell_order[i];
759 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_learned1, (1UL << j)) : any_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
760 if (!is_spell_learned)
765 set_bits(creature_ptr->spell_forgotten1, (1UL << j));
766 which = creature_ptr->realm1;
768 set_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
769 which = creature_ptr->realm2;
773 reset_bits(creature_ptr->spell_learned1, (1UL << j));
774 which = creature_ptr->realm1;
776 reset_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
777 which = creature_ptr->realm2;
781 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
783 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
785 creature_ptr->new_spells++;
788 /* Check for spells to remember */
789 for (int i = 0; i < 64; i++) {
790 if (creature_ptr->new_spells <= 0)
792 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2)
794 int j = creature_ptr->spell_order[i];
798 const magic_type *s_ptr;
799 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2)) {
801 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
803 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
805 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
807 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
809 if (s_ptr->slevel > creature_ptr->lev)
812 bool is_spell_learned = (j < 32) ? any_bits(creature_ptr->spell_forgotten1, (1UL << j)) : any_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
813 if (!is_spell_learned)
818 reset_bits(creature_ptr->spell_forgotten1, (1UL << j));
819 which = creature_ptr->realm1;
821 reset_bits(creature_ptr->spell_forgotten2, (1UL << (j - 32)));
822 which = creature_ptr->realm2;
826 set_bits(creature_ptr->spell_learned1, (1UL << j));
827 which = creature_ptr->realm1;
829 set_bits(creature_ptr->spell_learned2, (1UL << (j - 32)));
830 which = creature_ptr->realm2;
834 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
836 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
838 creature_ptr->new_spells--;
841 if (creature_ptr->realm2 == REALM_NONE) {
843 for (int j = 0; j < 32; j++) {
844 const magic_type *s_ptr;
845 if (!is_magic(creature_ptr->realm1))
846 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
848 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
850 if (s_ptr->slevel > creature_ptr->lev)
853 if (any_bits(creature_ptr->spell_learned1, (1UL << j))) {
862 if ((creature_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) {
863 creature_ptr->new_spells = (s16b)k;
867 if (creature_ptr->new_spells < 0)
868 creature_ptr->new_spells = 0;
870 if (creature_ptr->old_spells == creature_ptr->new_spells)
873 if (creature_ptr->new_spells) {
875 if (creature_ptr->new_spells < 10) {
876 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
878 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
881 msg_format("You can learn %d more %s%s.", creature_ptr->new_spells, p, (creature_ptr->new_spells != 1) ? "s" : "");
885 creature_ptr->old_spells = creature_ptr->new_spells;
886 set_bits(creature_ptr->redraw, PR_STUDY);
887 set_bits(creature_ptr->window_flags, PW_OBJECT);
891 * @brief プレイヤーの最大MPを更新する /
892 * Update maximum mana. You do not need to know any spells.
893 * Note that mana is lowered by heavy (or inappropriate) armor.
896 * This function induces status messages.
898 static void update_max_mana(player_type *creature_ptr)
900 if (!mp_ptr->spell_book && mp_ptr->spell_first == SPELL_FIRST_NO_SPELL)
904 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_MIRROR_MASTER) || (creature_ptr->pclass == CLASS_BLUE_MAGE)) {
905 levels = creature_ptr->lev;
907 if (mp_ptr->spell_first > creature_ptr->lev) {
908 creature_ptr->msp = 0;
909 set_bits(creature_ptr->redraw, PR_MANA);
913 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
917 if (creature_ptr->pclass == CLASS_SAMURAI) {
918 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
920 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
922 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
926 msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
927 if (msp && (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN))
929 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE))
931 if (msp && (creature_ptr->pclass == CLASS_SORCERER))
932 msp += msp * (25 + creature_ptr->lev) / 100;
935 if (any_bits(mp_ptr->spell_xtra, MAGIC_GLOVE_REDUCE_MANA)) {
936 BIT_FLAGS flgs[TR_FLAG_SIZE];
937 creature_ptr->cumber_glove = FALSE;
939 o_ptr = &creature_ptr->inventory_list[INVEN_ARMS];
940 object_flags(creature_ptr, o_ptr, flgs);
941 if (o_ptr->k_idx && !(has_flag(flgs, TR_FREE_ACT)) && !(has_flag(flgs, TR_DEC_MANA)) && !(has_flag(flgs, TR_EASY_SPELL))
942 && !((has_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) && !((has_flag(flgs, TR_DEX)) && (o_ptr->pval > 0))) {
943 creature_ptr->cumber_glove = TRUE;
948 creature_ptr->cumber_armor = FALSE;
951 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
952 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
953 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
954 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
955 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
956 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
957 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
958 cur_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
959 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
961 switch (creature_ptr->pclass) {
963 case CLASS_HIGH_MAGE:
964 case CLASS_BLUE_MAGE:
966 case CLASS_FORCETRAINER:
967 case CLASS_SORCERER: {
968 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
969 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
970 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
971 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
976 case CLASS_TOURIST: {
977 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
978 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight * 2 / 3;
979 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
980 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight * 2 / 3;
983 case CLASS_MINDCRAFTER:
984 case CLASS_BEASTMASTER:
985 case CLASS_MIRROR_MASTER: {
986 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
987 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 2;
988 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
989 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 2;
995 case CLASS_WARRIOR_MAGE: {
996 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
997 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 3;
998 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
999 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 3;
1003 case CLASS_CHAOS_WARRIOR: {
1004 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval <= TV_SWORD)
1005 cur_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight / 5;
1006 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval <= TV_SWORD)
1007 cur_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight / 5;
1015 int max_wgt = mp_ptr->spell_weight;
1016 if ((cur_wgt - max_wgt) > 0) {
1017 creature_ptr->cumber_armor = TRUE;
1018 switch (creature_ptr->pclass) {
1020 case CLASS_HIGH_MAGE:
1021 case CLASS_BLUE_MAGE: {
1022 msp -= msp * (cur_wgt - max_wgt) / 600;
1026 case CLASS_MINDCRAFTER:
1027 case CLASS_BEASTMASTER:
1029 case CLASS_FORCETRAINER:
1031 case CLASS_MIRROR_MASTER: {
1032 msp -= msp * (cur_wgt - max_wgt) / 800;
1035 case CLASS_SORCERER: {
1036 msp -= msp * (cur_wgt - max_wgt) / 900;
1042 case CLASS_RED_MAGE: {
1043 msp -= msp * (cur_wgt - max_wgt) / 1000;
1047 case CLASS_CHAOS_WARRIOR:
1048 case CLASS_WARRIOR_MAGE: {
1049 msp -= msp * (cur_wgt - max_wgt) / 1200;
1052 case CLASS_SAMURAI: {
1053 creature_ptr->cumber_armor = FALSE;
1057 msp -= msp * (cur_wgt - max_wgt) / 800;
1066 if (creature_ptr->msp != msp) {
1067 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI)) {
1068 creature_ptr->csp = msp;
1069 creature_ptr->csp_frac = 0;
1073 if (creature_ptr->level_up_message && (msp > creature_ptr->msp)) {
1074 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
1077 creature_ptr->msp = msp;
1078 set_bits(creature_ptr->redraw, PR_MANA);
1079 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
1082 if (current_world_ptr->character_xtra)
1085 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove) {
1086 if (creature_ptr->cumber_glove)
1087 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
1089 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
1091 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
1094 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor)
1097 if (creature_ptr->cumber_armor)
1098 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
1100 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
1102 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
1106 * @brief 装備中の射撃武器の威力倍率を返す /
1107 * calcurate the fire rate of target object
1108 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
1109 * @return 射撃倍率の値(100で1.00倍)
1111 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
1113 int extra_shots = 0;
1114 BIT_FLAGS flgs[TR_FLAG_SIZE];
1116 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1118 q_ptr = &creature_ptr->inventory_list[i];
1125 object_flags(creature_ptr, q_ptr, flgs);
1126 if (has_flag(flgs, TR_XTRA_SHOTS))
1130 object_flags(creature_ptr, o_ptr, flgs);
1131 if (has_flag(flgs, TR_XTRA_SHOTS))
1135 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
1139 num += (extra_shots * 100);
1141 tval_type tval_ammo = bow_tval_ammo(o_ptr);
1142 if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
1143 num += (creature_ptr->lev * 4);
1146 if ((creature_ptr->pclass == CLASS_CAVALRY) && (tval_ammo == TV_ARROW)) {
1147 num += (creature_ptr->lev * 3);
1150 if (creature_ptr->pclass == CLASS_ARCHER) {
1151 if (tval_ammo == TV_ARROW)
1152 num += ((creature_ptr->lev * 5) + 50);
1153 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
1154 num += (creature_ptr->lev * 4);
1157 if (creature_ptr->pclass == CLASS_WARRIOR && (tval_ammo <= TV_BOLT) && (tval_ammo >= TV_SHOT)) {
1158 num += (creature_ptr->lev * 2);
1161 if ((creature_ptr->pclass == CLASS_ROGUE) && (tval_ammo == TV_SHOT)) {
1162 num += (creature_ptr->lev * 4);
1170 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1174 * * 変異MUT3_INFRAVISによる加算(+3)
1175 * * 魔法効果tim_infraによる加算(+3)
1176 * * 装備がTR_INFRAフラグ持ちなら加算(+pval*1)
1178 static ACTION_SKILL_POWER calc_intra_vision(player_type *creature_ptr)
1180 ACTION_SKILL_POWER pow;
1181 const player_race *tmp_rp_ptr;
1183 if (creature_ptr->mimic_form)
1184 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1186 tmp_rp_ptr = &race_info[creature_ptr->prace];
1188 pow = tmp_rp_ptr->infra;
1190 if (any_bits(creature_ptr->muta3, MUT3_INFRAVIS)) {
1194 if (creature_ptr->tim_infra) {
1198 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1200 BIT_FLAGS flgs[TR_FLAG_SIZE];
1201 o_ptr = &creature_ptr->inventory_list[i];
1204 object_flags(creature_ptr, o_ptr, flgs);
1205 if (has_flag(flgs, TR_INFRA))
1214 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1220 * * 装備による修正(TR_STEALTHがあれば+pval*1)
1221 * * 変異MUT3_XTRA_NOISで減算(-3)
1222 * * 変異MUT3_MOTIONで加算(+1)
1223 * * 呪術を唱えていると減算(-(詠唱数+1))
1224 * * セクシーギャルでない影フェアリーがTRC_AGGRAVATE持ちの時、別処理でTRC_AGGRAVATEを無効にする代わりに減算(-3か3未満なら(現在値+2)/2)
1226 * * 忍者がheavy_armorならば減算(-レベル/10)
1227 * * 忍者がheavy_armorでなく適正な武器を持っていれば加算(+レベル/10)
1231 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
1233 ACTION_SKILL_POWER pow;
1234 const player_race *tmp_rp_ptr;
1236 if (creature_ptr->mimic_form)
1237 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1239 tmp_rp_ptr = &race_info[creature_ptr->prace];
1240 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1241 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1243 pow = 1 + tmp_rp_ptr->r_stl + c_ptr->c_stl + a_ptr->a_stl;
1244 pow += (c_ptr->x_stl * creature_ptr->lev / 10);
1246 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1248 BIT_FLAGS flgs[TR_FLAG_SIZE];
1249 o_ptr = &creature_ptr->inventory_list[i];
1252 object_flags(creature_ptr, o_ptr, flgs);
1253 if (has_flag(flgs, TR_STEALTH))
1257 if (any_bits(creature_ptr->muta3, MUT3_XTRA_NOIS)) {
1260 if (any_bits(creature_ptr->muta3, MUT3_MOTION)) {
1263 if (creature_ptr->realm1 == REALM_HEX) {
1264 if (hex_spelling_any(creature_ptr))
1265 pow -= (1 + casting_hex_num(creature_ptr));
1267 if (player_aggravate_state(creature_ptr) == AGGRAVATE_S_FAIRY) {
1268 pow = MIN(pow - 3, (pow + 2) / 2);
1271 if (is_shero(creature_ptr)) {
1275 if (creature_ptr->pclass == CLASS_NINJA) {
1276 if (heavy_armor(creature_ptr)) {
1277 pow -= (creature_ptr->lev) / 10;
1278 } else if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1279 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1280 pow += (creature_ptr->lev) / 10;
1284 if (is_time_limit_stealth(creature_ptr))
1297 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1301 * * 職業と性格とレベルによる追加加算
1302 * * 器用さに応じたadj_dex_disテーブルによる加算
1303 * * 知力に応じたadj_int_disテーブルによる加算
1305 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1307 ACTION_SKILL_POWER pow;
1308 const player_race *tmp_rp_ptr;
1310 if (creature_ptr->mimic_form)
1311 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1313 tmp_rp_ptr = &race_info[creature_ptr->prace];
1314 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1315 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1317 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1318 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1319 pow += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
1320 pow += adj_int_dis[creature_ptr->stat_ind[A_INT]];
1326 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1330 * * 職業と性格とレベルによる追加加算
1331 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1332 * * 知力に応じたadj_int_devテーブルによる加算
1335 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1337 ACTION_SKILL_POWER pow;
1338 const player_race *tmp_rp_ptr;
1340 if (creature_ptr->mimic_form)
1341 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1343 tmp_rp_ptr = &race_info[creature_ptr->prace];
1344 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1345 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1347 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1348 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1350 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1352 BIT_FLAGS flgs[TR_FLAG_SIZE];
1353 o_ptr = &creature_ptr->inventory_list[i];
1356 object_flags(creature_ptr, o_ptr, flgs);
1357 if (has_flag(flgs, TR_MAGIC_MASTERY))
1358 pow += 8 * o_ptr->pval;
1361 pow += adj_int_dev[creature_ptr->stat_ind[A_INT]];
1363 if (is_shero(creature_ptr)) {
1371 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1375 * * 職業と性格とレベルによる追加加算
1376 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1377 * * 賢さによるadj_wis_savテーブル加算
1379 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1380 * * クターのつぶれ状態なら(10に上書き)
1381 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1382 * * 呪いのdown_savingがかかっているなら半減
1384 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1386 ACTION_SKILL_POWER pow;
1387 const player_race *tmp_rp_ptr;
1389 if (creature_ptr->mimic_form)
1390 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1392 tmp_rp_ptr = &race_info[creature_ptr->prace];
1393 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1394 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1396 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1397 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1399 if (any_bits(creature_ptr->muta3, MUT3_MAGIC_RES))
1400 pow += (15 + (creature_ptr->lev / 5));
1402 pow += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
1404 if (is_shero(creature_ptr))
1407 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1408 pow = 90 + creature_ptr->lev;
1410 if (creature_ptr->tsubureru)
1413 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1414 pow = 95 + creature_ptr->lev;
1416 if (creature_ptr->down_saving)
1424 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1429 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1431 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1433 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1435 ACTION_SKILL_POWER pow;
1436 const player_race *tmp_rp_ptr;
1438 if (creature_ptr->mimic_form)
1439 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1441 tmp_rp_ptr = &race_info[creature_ptr->prace];
1442 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1443 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1445 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1446 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1448 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1450 BIT_FLAGS flgs[TR_FLAG_SIZE];
1451 o_ptr = &creature_ptr->inventory_list[i];
1454 object_flags(creature_ptr, o_ptr, flgs);
1455 if (has_flag(flgs, TR_SEARCH))
1456 pow += (o_ptr->pval * 5);
1459 if (any_bits(creature_ptr->muta3, MUT3_XTRA_EYES)) {
1463 if (is_shero(creature_ptr)) {
1472 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1477 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1479 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1481 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1483 ACTION_SKILL_POWER pow;
1484 const player_race *tmp_rp_ptr;
1486 if (creature_ptr->mimic_form)
1487 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1489 tmp_rp_ptr = &race_info[creature_ptr->prace];
1490 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1491 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1493 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1494 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1496 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1498 BIT_FLAGS flgs[TR_FLAG_SIZE];
1499 o_ptr = &creature_ptr->inventory_list[i];
1502 object_flags(creature_ptr, o_ptr, flgs);
1503 if (has_flag(flgs, TR_SEARCH))
1504 pow += (o_ptr->pval * 5);
1507 if (is_shero(creature_ptr)) {
1511 if (any_bits(creature_ptr->muta3, MUT3_XTRA_EYES)) {
1520 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1523 * * 種族/職業/性格による加算とレベルによる追加加算
1525 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1527 ACTION_SKILL_POWER pow;
1528 const player_race *tmp_rp_ptr;
1529 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1530 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1532 if (creature_ptr->mimic_form)
1533 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1535 tmp_rp_ptr = &race_info[creature_ptr->prace];
1537 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1538 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1544 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1547 * * 種族/職業/性格による加算とレベルによる追加加算
1549 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1551 ACTION_SKILL_POWER pow;
1552 const player_race *tmp_rp_ptr;
1553 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1554 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1556 if (creature_ptr->mimic_form)
1557 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1559 tmp_rp_ptr = &race_info[creature_ptr->prace];
1561 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1562 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1568 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1571 * * 種族/職業/性格による加算とレベルによる追加加算
1574 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1576 ACTION_SKILL_POWER pow;
1577 const player_race *tmp_rp_ptr;
1578 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1579 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1581 if (creature_ptr->mimic_form)
1582 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1584 tmp_rp_ptr = &race_info[creature_ptr->prace];
1586 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1587 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1589 if (is_shero(creature_ptr)) {
1598 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1609 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1612 BIT_FLAGS flgs[TR_FLAG_SIZE];
1614 ACTION_SKILL_POWER pow;
1618 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1619 pow += creature_ptr->lev * 10;
1622 if (is_shero(creature_ptr))
1625 pow += adj_str_dig[creature_ptr->stat_ind[A_STR]];
1627 if (creature_ptr->pclass == CLASS_BERSERKER)
1628 pow += (100 + creature_ptr->lev * 8);
1630 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1631 o_ptr = &creature_ptr->inventory_list[i];
1634 object_flags(creature_ptr, o_ptr, flgs);
1635 if (has_flag(flgs, TR_TUNNEL))
1636 pow += (o_ptr->pval * 20);
1639 for (int i = 0; i < 2; i++) {
1640 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1641 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1642 pow += (o_ptr->weight / 10);
1646 if (is_shero(creature_ptr)) {
1656 static bool is_martial_arts_mode(player_type *creature_ptr)
1658 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1659 && (any_bits(empty_hands(creature_ptr, TRUE), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1662 static bool is_heavy_wield(player_type *creature_ptr, int i)
1664 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1666 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1669 static s16b calc_num_blow(player_type *creature_ptr, int i)
1672 BIT_FLAGS flgs[TR_FLAG_SIZE];
1675 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1676 object_flags(creature_ptr, o_ptr, flgs);
1677 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1678 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1679 int str_index, dex_index;
1680 int num = 0, wgt = 0, mul = 0, div = 0;
1682 num = class_info[creature_ptr->pclass].num;
1683 wgt = class_info[creature_ptr->pclass].wgt;
1684 mul = class_info[creature_ptr->pclass].mul;
1686 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1692 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1698 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1699 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
1701 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1703 if (creature_ptr->pclass == CLASS_NINJA)
1704 str_index = MAX(0, str_index - 1);
1708 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
1712 num_blow = blows_table[str_index][dex_index];
1714 num_blow = (s16b)num;
1716 num_blow += (s16b)creature_ptr->extra_blows[i];
1717 if (creature_ptr->pclass == CLASS_WARRIOR)
1718 num_blow += (creature_ptr->lev / 40);
1719 else if (creature_ptr->pclass == CLASS_BERSERKER)
1720 num_blow += (creature_ptr->lev / 23);
1721 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
1724 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1727 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1737 /* Different calculation for monks with empty hands */
1738 if (is_martial_arts_mode(creature_ptr)) {
1739 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
1742 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1768 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1771 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1773 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1777 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1781 num_blow += 1 + creature_ptr->extra_blows[0];
1784 if (has_not_ninja_weapon(creature_ptr, i)) {
1795 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1799 * * エントは別途レベル26,41,46到達ごとに加算(+1)
1800 * * 装備がTR_STRフラグを持っていれば加算(+pval*1)
1806 * * 変異MUT3_HYPER_STRで加算(+4)
1807 * * 変異MUT3_PUNYで減算(-4)
1808 * * ネオ・つよしスペシャル中で加算(+4)
1810 static s16b calc_strength_addition(player_type *creature_ptr)
1813 const player_race *tmp_rp_ptr;
1814 if (creature_ptr->mimic_form)
1815 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1817 tmp_rp_ptr = &race_info[creature_ptr->prace];
1818 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1819 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1820 pow = tmp_rp_ptr->r_adj[A_STR] + c_ptr->c_adj[A_STR] + a_ptr->a_adj[A_STR];
1822 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
1823 if (creature_ptr->lev > 25)
1825 if (creature_ptr->lev > 40)
1827 if (creature_ptr->lev > 45)
1831 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1833 BIT_FLAGS flgs[TR_FLAG_SIZE];
1834 o_ptr = &creature_ptr->inventory_list[i];
1837 object_flags(creature_ptr, o_ptr, flgs);
1838 if (has_flag(flgs, TR_STR)) {
1843 if (creature_ptr->realm1 == REALM_HEX) {
1844 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) {
1847 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
1852 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1856 if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1858 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1862 if (creature_ptr->muta3) {
1863 if (any_bits(creature_ptr->muta3, MUT3_HYPER_STR)) {
1867 if (any_bits(creature_ptr->muta3, MUT3_PUNY)) {
1872 if (creature_ptr->tsuyoshi) {
1880 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1884 * * 装備がTR_INTフラグを持っていれば加算(+pval*1)
1890 * * 変異MUT3_HYPER_INTで加算(+4)
1891 * * 変異MUT3_MORONICで減算(-4)
1893 s16b calc_intelligence_addition(player_type *creature_ptr)
1896 const player_race *tmp_rp_ptr;
1897 if (creature_ptr->mimic_form)
1898 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1900 tmp_rp_ptr = &race_info[creature_ptr->prace];
1901 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1902 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1903 pow = tmp_rp_ptr->r_adj[A_INT] + c_ptr->c_adj[A_INT] + a_ptr->a_adj[A_INT];
1905 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1907 BIT_FLAGS flgs[TR_FLAG_SIZE];
1908 o_ptr = &creature_ptr->inventory_list[i];
1911 object_flags(creature_ptr, o_ptr, flgs);
1912 if (has_flag(flgs, TR_INT)) {
1917 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1921 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1923 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1927 if (creature_ptr->muta3) {
1928 if (any_bits(creature_ptr->muta3, MUT3_HYPER_INT)) {
1932 if (any_bits(creature_ptr->muta3, MUT3_MORONIC)) {
1942 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1946 * * 装備がTR_WISフラグを持っていれば加算(+pval*1)
1952 * * 変異MUT3_HYPER_INTで加算(+4)
1953 * * 変異MUT3_MORONICで減算(-4)
1955 static s16b calc_wisdom_addition(player_type *creature_ptr)
1958 const player_race *tmp_rp_ptr;
1959 if (creature_ptr->mimic_form)
1960 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1962 tmp_rp_ptr = &race_info[creature_ptr->prace];
1963 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1964 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1965 pow = tmp_rp_ptr->r_adj[A_WIS] + c_ptr->c_adj[A_WIS] + a_ptr->a_adj[A_WIS];
1967 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1969 BIT_FLAGS flgs[TR_FLAG_SIZE];
1970 o_ptr = &creature_ptr->inventory_list[i];
1973 object_flags(creature_ptr, o_ptr, flgs);
1974 if (has_flag(flgs, TR_WIS)) {
1979 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1983 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1985 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1989 if (creature_ptr->muta3) {
1990 if (any_bits(creature_ptr->muta3, MUT3_HYPER_INT)) {
1994 if (any_bits(creature_ptr->muta3, MUT3_MORONIC)) {
2004 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2008 * * エントは別途レベル26,41,46到達ごとに減算(-1)
2009 * * 装備がTR_DEXフラグを持っていれば加算(+pval*1)
2015 * * 変異MUT3_IRON_SKINで減算(-1)
2016 * * 変異MUT3_LIMBERで加算(+3)
2017 * * 変異MUT3_ARTHRITISで減算(-3)
2019 static s16b calc_dexterity_addition(player_type *creature_ptr)
2022 const player_race *tmp_rp_ptr;
2023 if (creature_ptr->mimic_form)
2024 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2026 tmp_rp_ptr = &race_info[creature_ptr->prace];
2027 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2028 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2029 pow = tmp_rp_ptr->r_adj[A_DEX] + c_ptr->c_adj[A_DEX] + a_ptr->a_adj[A_DEX];
2031 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2032 if (creature_ptr->lev > 25)
2034 if (creature_ptr->lev > 40)
2036 if (creature_ptr->lev > 45)
2040 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2042 BIT_FLAGS flgs[TR_FLAG_SIZE];
2043 o_ptr = &creature_ptr->inventory_list[i];
2046 object_flags(creature_ptr, o_ptr, flgs);
2047 if (has_flag(flgs, TR_DEX)) {
2052 if (creature_ptr->realm1 == REALM_HEX) {
2053 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2058 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2062 if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
2064 } else if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2066 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2070 if (any_bits(creature_ptr->muta3, MUT3_IRON_SKIN)) {
2074 if (any_bits(creature_ptr->muta3, MUT3_LIMBER)) {
2078 if (any_bits(creature_ptr->muta3, MUT3_ARTHRITIS)) {
2087 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2091 * * エントは別途レベル26,41,46到達ごとに加算(+1)
2092 * * 装備がTR_CONフラグを持っていれば加算(+pval*1)
2098 * * 変異MUT3_RESILIENTで加算(+4)
2099 * * 変異MUT3_ALBINOで減算(-4)
2100 * * 変異MUT3_XTRA_FATで加算(+2)
2101 * * 変異MUT3_FLESH_ROTで減算(-2)
2102 * * ネオ・つよしスペシャル中で加算(+4)
2104 static s16b calc_constitution_addition(player_type *creature_ptr)
2107 const player_race *tmp_rp_ptr;
2108 if (creature_ptr->mimic_form)
2109 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2111 tmp_rp_ptr = &race_info[creature_ptr->prace];
2112 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2113 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2114 pow = tmp_rp_ptr->r_adj[A_CON] + c_ptr->c_adj[A_CON] + a_ptr->a_adj[A_CON];
2116 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2117 if (creature_ptr->lev > 25)
2119 if (creature_ptr->lev > 40)
2121 if (creature_ptr->lev > 45)
2125 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2127 BIT_FLAGS flgs[TR_FLAG_SIZE];
2128 o_ptr = &creature_ptr->inventory_list[i];
2131 object_flags(creature_ptr, o_ptr, flgs);
2132 if (has_flag(flgs, TR_CON))
2136 if (creature_ptr->realm1 == REALM_HEX) {
2137 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2142 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2146 if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
2148 } else if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2150 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2154 if (creature_ptr->muta3) {
2155 if (any_bits(creature_ptr->muta3, MUT3_RESILIENT)) {
2159 if (any_bits(creature_ptr->muta3, MUT3_ALBINO)) {
2163 if (any_bits(creature_ptr->muta3, MUT3_XTRA_FAT)) {
2167 if (any_bits(creature_ptr->muta3, MUT3_FLESH_ROT)) {
2172 if (creature_ptr->tsuyoshi) {
2181 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2185 * * 装備がTR_CHRフラグを持っていれば加算(+pval*1)
2188 * * 変異MUT3_FLESH_ROTで減算(-1)
2189 * * 変異MUT3_SILLY_VOIで減算(-4)
2190 * * 変異MUT3_BLANK_FACで減算(-1)
2191 * * 変異MUT3_WART_SKINで減算(-2)
2192 * * 変異MUT3_SCALESで減算(-1)
2193 * * 変異MUT3_ILL_NORMで0固定(後で個体値のみ上書きを行う)
2195 static s16b calc_charisma_addition(player_type *creature_ptr)
2198 const player_race *tmp_rp_ptr;
2199 if (creature_ptr->mimic_form)
2200 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2202 tmp_rp_ptr = &race_info[creature_ptr->prace];
2203 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2204 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2205 pow = tmp_rp_ptr->r_adj[A_CHR] + c_ptr->c_adj[A_CHR] + a_ptr->a_adj[A_CHR];
2207 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2209 BIT_FLAGS flgs[TR_FLAG_SIZE];
2210 o_ptr = &creature_ptr->inventory_list[i];
2213 object_flags(creature_ptr, o_ptr, flgs);
2214 if (has_flag(flgs, TR_CHR))
2218 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2222 if (creature_ptr->muta3) {
2223 if (any_bits(creature_ptr->muta3, MUT3_FLESH_ROT)) {
2226 if (any_bits(creature_ptr->muta3, MUT3_SILLY_VOI)) {
2229 if (any_bits(creature_ptr->muta3, MUT3_BLANK_FAC)) {
2232 if (any_bits(creature_ptr->muta3, MUT3_WART_SKIN)) {
2235 if (any_bits(creature_ptr->muta3, MUT3_SCALES)) {
2238 if (any_bits(creature_ptr->muta3, MUT3_ILL_NORM)) {
2248 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2251 * * 性格なまけものなら加算(+10)
2253 * * 性格ちからじまんとがまんづよいなら加算(+1)
2254 * * 性格チャージマンなら加算(+5)
2255 * * 装備品にTRC_LOW_MAGICがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
2257 static s16b calc_to_magic_chance(player_type *creature_ptr)
2261 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
2263 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
2265 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
2267 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
2270 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2272 BIT_FLAGS flgs[TR_FLAG_SIZE];
2273 o_ptr = &creature_ptr->inventory_list[i];
2276 object_flags(creature_ptr, o_ptr, flgs);
2277 if (any_bits(o_ptr->curse_flags, TRC_LOW_MAGIC)) {
2278 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2288 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
2290 ARMOUR_CLASS ac = 0;
2291 if (creature_ptr->yoiyami)
2294 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2296 o_ptr = &creature_ptr->inventory_list[i];
2302 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
2303 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
2304 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2310 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
2312 ARMOUR_CLASS ac = 0;
2313 BIT_FLAGS flags[TR_FLAG_SIZE];
2314 if (creature_ptr->yoiyami)
2317 ac += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2319 if (creature_ptr->mimic_form) {
2320 switch (creature_ptr->mimic_form) {
2324 case MIMIC_DEMON_LORD:
2332 if (creature_ptr->pclass == CLASS_BERSERKER) {
2333 ac += 10 + creature_ptr->lev / 2;
2335 if (creature_ptr->pclass == CLASS_SORCERER) {
2339 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2341 o_ptr = &creature_ptr->inventory_list[i];
2342 object_flags(creature_ptr, o_ptr, flags);
2345 if (is_real_value || object_is_known(o_ptr))
2348 if (any_bits(o_ptr->curse_flags, TRC_LOW_AC)) {
2349 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2350 if (is_real_value || object_is_fully_known(o_ptr))
2353 if (is_real_value || object_is_fully_known(o_ptr))
2358 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
2363 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
2364 ac += 10 + (creature_ptr->lev * 2 / 5);
2367 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
2371 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
2372 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
2376 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
2380 if (any_bits(creature_ptr->muta3, MUT3_WART_SKIN)) {
2384 if (any_bits(creature_ptr->muta3, MUT3_SCALES)) {
2388 if (any_bits(creature_ptr->muta3, MUT3_IRON_SKIN)) {
2392 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
2393 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
2394 ac += (creature_ptr->lev * 3) / 2;
2396 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
2397 ac += ((creature_ptr->lev - 13) / 3);
2399 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
2400 ac += ((creature_ptr->lev - 8) / 3);
2402 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
2403 ac += (creature_ptr->lev - 2) / 3;
2405 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
2406 ac += (creature_ptr->lev / 2);
2408 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
2409 ac += (creature_ptr->lev / 3);
2413 if (creature_ptr->realm1 == REALM_HEX) {
2414 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
2418 for (inventory_slot_type i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
2419 object_type *o_ptr = &creature_ptr->inventory_list[i];
2422 if (!object_is_armour(creature_ptr, o_ptr))
2424 if (!object_is_cursed(o_ptr))
2426 if (any_bits(o_ptr->curse_flags, TRC_CURSED))
2428 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE))
2430 if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE))
2435 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2436 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
2437 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
2439 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
2441 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2445 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
2447 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
2451 if (is_blessed(creature_ptr)) {
2455 if (is_shero(creature_ptr)) {
2459 if (creature_ptr->pclass == CLASS_NINJA) {
2460 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
2461 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
2462 ac += creature_ptr->lev / 2 + 5;
2471 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2474 * ** クラッコンと妖精に加算(+レベル/10)
2475 * ** 悪魔変化/吸血鬼変化で加算(+3)
2477 * ** マーフォークがFF_WATER地形にいれば加算(+2+レベル/10)
2478 * ** そうでなく浮遊を持っていないなら減算(-2)
2480 static SPEED calc_player_speed_by_race(player_type *creature_ptr)
2484 if (is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE))
2485 result += (creature_ptr->lev) / 10;
2487 if (is_specific_player_race(creature_ptr, RACE_MERFOLK)) {
2488 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2489 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
2490 if (has_flag(f_ptr->flags, FF_WATER)) {
2491 result += (2 + creature_ptr->lev / 10);
2492 } else if (!creature_ptr->levitation) {
2497 if (creature_ptr->mimic_form) {
2498 switch (creature_ptr->mimic_form) {
2502 case MIMIC_DEMON_LORD:
2513 static SPEED calc_speed_by_secial_weapon_set(player_type *creature_ptr)
2516 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
2517 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
2521 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
2530 * @brief 速度計算 - ACTION
2531 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2534 * ** 装備品にTR_SPEEDがあれば加算(+pval+1
2535 * ** 棘セット装備中ならば加算(+7)
2536 * ** アイシングデス-トゥインクル装備中ならば加算(+7)
2538 static SPEED calc_player_speed_by_equipment(player_type *creature_ptr)
2541 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2542 object_type *o_ptr = &creature_ptr->inventory_list[i];
2543 BIT_FLAGS flgs[TR_FLAG_SIZE];
2544 object_flags(creature_ptr, o_ptr, flgs);
2548 if (has_flag(flgs, TR_SPEED))
2549 result += o_ptr->pval;
2551 result += calc_speed_by_secial_weapon_set(creature_ptr);
2557 * @brief 速度計算 - ACTION
2558 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2561 * ** 忍者の装備が重ければ減算(-レベル/10)
2562 * ** 忍者の装備が適正ならば加算(+3)さらにクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2563 * ** 錬気術師で装備が重くなくクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2564 * ** 狂戦士なら加算(+3),レベル20/30/40/50ごとに+1
2566 static SPEED calc_player_speed_by_class(player_type *creature_ptr)
2570 if (creature_ptr->pclass == CLASS_NINJA) {
2571 if (heavy_armor(creature_ptr)) {
2572 result -= (creature_ptr->lev) / 10;
2573 } else if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
2574 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
2576 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2577 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2578 result += (creature_ptr->lev) / 10;
2582 if ((creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) && !(heavy_armor(creature_ptr))) {
2583 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2584 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2585 result += (creature_ptr->lev) / 10;
2588 if (creature_ptr->pclass == CLASS_BERSERKER) {
2590 if (creature_ptr->lev > 29)
2592 if (creature_ptr->lev > 39)
2594 if (creature_ptr->lev > 44)
2596 if (creature_ptr->lev > 49)
2604 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2610 static SPEED calc_player_speed_by_battleform(player_type *creature_ptr)
2613 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU))
2620 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2624 * ** 変異MUT3_XTRA_FATなら減算(-2)
2625 * ** 変異MUT3_XTRA_LEGなら加算(+3)
2626 * ** 変異MUT3_SHORT_LEGなら減算(-3)
2628 static SPEED calc_player_speed_by_mutation(player_type *creature_ptr)
2631 if (creature_ptr->muta3) {
2632 if (any_bits(creature_ptr->muta3, MUT3_XTRA_FAT)) {
2636 if (any_bits(creature_ptr->muta3, MUT3_XTRA_LEGS)) {
2640 if (any_bits(creature_ptr->muta3, MUT3_SHORT_LEG)) {
2648 * @brief 速度計算 - 一時的効果
2649 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2654 * ** 呪術「衝撃のクローク」で加算(+3)
2656 * ** 光速移動中は+999(最終的に+99になる)
2658 static SPEED calc_player_speed_by_time_effect(player_type *creature_ptr)
2662 if (is_fast(creature_ptr)) {
2666 if (creature_ptr->slow) {
2670 if (creature_ptr->realm1 == REALM_HEX) {
2671 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) {
2676 if (creature_ptr->food >= PY_FOOD_MAX)
2679 /* Temporary lightspeed forces to be maximum speed */
2680 if (creature_ptr->lightspeed)
2688 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2691 * ** いかさまでクラッコン/妖精以外なら加算(+5+レベル/10)
2693 static SPEED calc_player_speed_by_personality(player_type *creature_ptr)
2696 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN && creature_ptr->prace != RACE_KLACKON && creature_ptr->prace != RACE_SPRITE) {
2697 result += (creature_ptr->lev) / 10 + 5;
2704 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2707 * * 所持品の重量による減速処理。乗馬時は別計算。
2709 static SPEED calc_player_speed_by_inventory_weight(player_type *creature_ptr)
2713 int weight = calc_inventory_weight(creature_ptr);
2716 if (creature_ptr->riding) {
2717 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2718 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2719 count = 1500 + riding_r_ptr->level * 25;
2721 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) {
2722 weight += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2725 if (weight > count) {
2726 result -= ((weight - count) / (count / 5));
2729 count = (int)calc_weight_limit(creature_ptr);
2730 if (weight > count) {
2731 result -= ((weight - count) / (count / 5));
2740 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2743 * * 騎乗中ならばモンスターの加速に準拠、ただし騎乗技能値とモンスターレベルによるキャップ処理あり
2745 static SPEED calc_player_speed_by_riding(player_type *creature_ptr)
2747 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2748 SPEED speed = riding_m_ptr->mspeed;
2751 if (creature_ptr->riding) {
2755 if (riding_m_ptr->mspeed > 110) {
2756 result = (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2760 result = speed - 110;
2763 result += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2765 if (monster_fast_remaining(riding_m_ptr))
2767 if (monster_slow_remaining(riding_m_ptr))
2774 * @brief 速度計算 - ACTION
2775 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2780 static SPEED calc_player_speed_by_action(player_type *creature_ptr)
2783 if (creature_ptr->action == ACTION_SEARCH)
2788 BIT_FLAGS player_flags_speed(player_type *creature_ptr)
2790 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_SPEED);
2792 if (calc_speed_by_secial_weapon_set(creature_ptr) != 0)
2793 set_bits(result, FLAG_CAUSE_INVEN_MAIN_HAND | FLAG_CAUSE_INVEN_SUB_HAND);
2795 if (calc_player_speed_by_class(creature_ptr) != 0)
2796 set_bits(result, FLAG_CAUSE_CLASS);
2798 if (calc_player_speed_by_race(creature_ptr) != 0)
2799 set_bits(result, FLAG_CAUSE_RACE);
2801 if (calc_player_speed_by_battleform(creature_ptr) != 0)
2802 set_bits(result, FLAG_CAUSE_BATTLE_FORM);
2804 if (calc_player_speed_by_mutation(creature_ptr) != 0)
2805 set_bits(result, FLAG_CAUSE_MUTATION);
2807 if (calc_player_speed_by_time_effect(creature_ptr) != 0)
2808 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
2810 if (calc_player_speed_by_personality(creature_ptr) != 0)
2811 set_bits(result, FLAG_CAUSE_PERSONALITY);
2813 if (calc_player_speed_by_riding(creature_ptr) != 0)
2814 set_bits(result, FLAG_CAUSE_RIDING);
2816 if (calc_player_speed_by_inventory_weight(creature_ptr) != 0)
2817 set_bits(result, FLAG_CAUSE_INVEN_PACK);
2819 if (calc_player_speed_by_action(creature_ptr) != 0)
2820 set_bits(result, FLAG_CAUSE_ACTION);
2827 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2829 * @details 上限99、下限-99
2831 static SPEED calc_speed(player_type *creature_ptr)
2835 if (creature_ptr->riding) {
2836 pow += calc_player_speed_by_riding(creature_ptr);
2837 pow += calc_player_speed_by_inventory_weight(creature_ptr);
2839 pow += calc_player_speed_by_race(creature_ptr);
2840 pow += calc_player_speed_by_equipment(creature_ptr);
2841 pow += calc_player_speed_by_class(creature_ptr);
2842 pow += calc_player_speed_by_personality(creature_ptr);
2843 pow += calc_player_speed_by_time_effect(creature_ptr);
2844 pow += calc_player_speed_by_battleform(creature_ptr);
2845 pow += calc_player_speed_by_mutation(creature_ptr);
2846 pow += calc_player_speed_by_inventory_weight(creature_ptr);
2848 pow += calc_player_speed_by_action(creature_ptr);
2850 /* Maximum speed is (+99). (internally it's 110 + 99) */
2855 /* Minimum speed is (-99). (internally it's 110 - 99) */
2863 * @brief 二刀流ペナルティ量計算
2864 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2865 * @param slot ペナルティ量を計算する武器スロット
2871 * * マンゴーシュ/脇差を左に装備した場合の軽減
2875 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
2878 BIT_FLAGS flags[TR_FLAG_SIZE];
2880 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
2881 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
2883 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
2884 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
2885 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
2886 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
2887 penalty = penalty / 2 - 5;
2889 if (creature_ptr->easy_2weapon) {
2892 } else if (has_flag(flags, TR_SUPPORTIVE)) {
2893 penalty = MAX(0, penalty - 10);
2895 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
2896 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
2897 penalty = MIN(0, penalty);
2899 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA) && (penalty > 0))
2901 if ((creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI) && (penalty > 0))
2905 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
2908 return (s16b)penalty;
2911 static void update_ind_status(player_type *creature_ptr, int status)
2914 if (creature_ptr->stat_use[status] <= 18)
2915 ind = (creature_ptr->stat_use[status] - 3);
2916 else if (creature_ptr->stat_use[status] <= 18 + 219)
2917 ind = (15 + (creature_ptr->stat_use[status] - 18) / 10);
2921 if (creature_ptr->stat_ind[status] == ind)
2924 creature_ptr->stat_ind[status] = (s16b)ind;
2925 if (status == A_CON) {
2926 set_bits(creature_ptr->update, PU_HP);
2927 } else if (status == A_INT) {
2928 if (mp_ptr->spell_stat == A_INT) {
2929 set_bits(creature_ptr->update, (PU_MANA | PU_SPELLS));
2931 } else if (status == A_WIS) {
2932 if (mp_ptr->spell_stat == A_WIS) {
2933 set_bits(creature_ptr->update, (PU_MANA | PU_SPELLS));
2935 } else if (status == A_CHR) {
2936 if (mp_ptr->spell_stat == A_CHR) {
2937 set_bits(creature_ptr->update, (PU_MANA | PU_SPELLS));
2941 set_bits(creature_ptr->window_flags, PW_PLAYER);
2944 static void update_use_status(player_type *creature_ptr, int status)
2946 int use = modify_stat_value(creature_ptr->stat_cur[status], creature_ptr->stat_add[status]);
2948 if ((status == A_CHR) && (any_bits(creature_ptr->muta3, MUT3_ILL_NORM))) {
2949 /* 10 to 18/90 charisma, guaranteed, based on level */
2950 if (use < 8 + 2 * creature_ptr->lev) {
2951 use = 8 + 2 * creature_ptr->lev;
2955 if (creature_ptr->stat_use[status] != use) {
2956 creature_ptr->stat_use[status] = (s16b)use;
2957 set_bits(creature_ptr->redraw, PR_STATS);
2958 set_bits(creature_ptr->window_flags, PW_PLAYER);
2962 static void update_top_status(player_type *creature_ptr, int status)
2964 int top = modify_stat_value(creature_ptr->stat_max[status], creature_ptr->stat_add[status]);
2966 if (creature_ptr->stat_top[status] != top) {
2967 creature_ptr->stat_top[status] = (s16b)top;
2968 set_bits(creature_ptr->redraw, PR_STATS);
2969 set_bits(creature_ptr->window_flags, PW_PLAYER);
2973 static bool is_riding_two_hands(player_type *creature_ptr)
2975 if (!creature_ptr->riding) {
2979 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
2981 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
2982 switch (creature_ptr->pclass) {
2984 case CLASS_FORCETRAINER:
2985 case CLASS_BERSERKER:
2986 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
2987 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
2995 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
2997 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2998 if (!creature_ptr->riding)
3003 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
3004 if (creature_ptr->tval_ammo != TV_ARROW)
3007 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3013 if (creature_ptr->tval_ammo == TV_BOLT)
3019 void put_equipment_warning(player_type *creature_ptr)
3021 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
3022 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
3024 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
3025 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
3026 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
3028 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
3030 creature_ptr->old_heavy_shoot = heavy_shoot;
3033 for (int i = 0; i < 2; i++) {
3034 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
3035 if (creature_ptr->heavy_wield[i]) {
3036 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
3037 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
3038 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
3039 } else if (creature_ptr->heavy_wield[1 - i]) {
3040 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
3042 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
3045 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
3048 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
3049 if (creature_ptr->riding_wield[i]) {
3050 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
3051 } else if (!creature_ptr->riding) {
3052 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
3053 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
3054 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
3057 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
3060 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
3063 if (creature_ptr->icky_wield[i]) {
3064 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
3065 if (current_world_ptr->is_loading_now) {
3066 chg_virtue(creature_ptr, V_FAITH, -1);
3068 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
3069 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
3071 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
3074 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
3077 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
3078 if (creature_ptr->riding_ryoute) {
3080 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
3082 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
3086 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
3088 msg_print("You began to control the pet you're riding with one hand.");
3092 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
3095 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
3096 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
3097 if (heavy_armor(creature_ptr)) {
3098 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
3099 if (current_world_ptr->is_loading_now) {
3100 chg_virtue(creature_ptr, V_HARMONY, -1);
3103 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
3106 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
3110 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
3112 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3113 BIT_FLAGS flgs[TR_FLAG_SIZE];
3114 object_flags(creature_ptr, o_ptr, flgs);
3116 player_hand calc_hand = PLAYER_HAND_OTHER;
3117 if (slot == INVEN_MAIN_HAND)
3118 calc_hand = PLAYER_HAND_MAIN;
3119 if (slot == INVEN_SUB_HAND)
3120 calc_hand = PLAYER_HAND_SUB;
3123 damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3125 if (is_shero(creature_ptr)) {
3126 damage += 3 + (creature_ptr->lev / 5);
3129 if (creature_ptr->stun > 50) {
3131 } else if (creature_ptr->stun) {
3135 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3137 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3138 damage += creature_ptr->lev / 6;
3139 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3140 damage += creature_ptr->lev / 6;
3142 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3143 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3148 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
3149 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
3150 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
3151 damage += get_current_ki(creature_ptr) / 5;
3155 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3156 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
3157 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
3160 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
3163 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
3169 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3171 o_ptr = &creature_ptr->inventory_list[i];
3172 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
3173 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3176 if (!object_is_known(o_ptr) && !is_real_value)
3178 bonus_to_d = o_ptr->to_d;
3180 if (creature_ptr->pclass == CLASS_NINJA) {
3181 if (o_ptr->to_d > 0)
3182 bonus_to_d = (o_ptr->to_d + 1) / 2;
3185 switch (player_melee_type(creature_ptr)) {
3186 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
3187 case MELEE_TYPE_WEAPON_TWOHAND:
3188 if (calc_hand == main_attack_hand(creature_ptr))
3189 damage += (s16b)bonus_to_d;
3192 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
3193 case MELEE_TYPE_WEAPON_MAIN:
3194 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
3195 damage += (s16b)bonus_to_d;
3198 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
3199 case MELEE_TYPE_WEAPON_SUB:
3200 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
3201 damage += (s16b)bonus_to_d;
3204 case MELEE_TYPE_WEAPON_DOUBLE:
3205 if (calc_hand == PLAYER_HAND_MAIN) {
3206 if (i == INVEN_MAIN_RING) {
3207 damage += (s16b)bonus_to_d;
3208 } else if (i != INVEN_SUB_RING) {
3209 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
3212 if (calc_hand == PLAYER_HAND_SUB) {
3213 if (i == INVEN_SUB_RING) {
3214 damage += (s16b)bonus_to_d;
3215 } else if (i != INVEN_MAIN_RING) {
3216 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
3221 case MELEE_TYPE_SHIELD_DOUBLE:
3229 if (main_attack_hand(creature_ptr) == calc_hand) {
3230 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
3231 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
3233 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
3234 damage += MAX(bonus_to_d, 1);
3238 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3239 damage += (creature_ptr->lev / 6);
3242 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
3243 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
3244 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
3245 damage -= (creature_ptr->lev / 6);
3253 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
3255 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
3257 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
3262 hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3263 hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3265 /* Temporary bonuses */
3266 if (is_blessed(creature_ptr)) {
3270 if (is_hero(creature_ptr)) {
3274 if (is_shero(creature_ptr)) {
3278 if (creature_ptr->stun > 50) {
3280 } else if (creature_ptr->stun) {
3284 player_hand calc_hand = PLAYER_HAND_OTHER;
3285 if (slot == INVEN_MAIN_HAND)
3286 calc_hand = PLAYER_HAND_MAIN;
3287 if (slot == INVEN_SUB_HAND)
3288 calc_hand = PLAYER_HAND_SUB;
3290 /* Default hand bonuses */
3291 if (main_attack_hand(creature_ptr) == calc_hand) {
3292 switch (player_melee_type(creature_ptr)) {
3293 case MELEE_TYPE_BAREHAND_MAIN:
3294 if (creature_ptr->riding)
3297 case MELEE_TYPE_BAREHAND_SUB:
3298 if (creature_ptr->riding)
3301 case MELEE_TYPE_BAREHAND_TWO:
3302 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
3305 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
3306 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
3308 bonus_to_h = ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3309 hit += MAX(bonus_to_h, 1);
3313 /* Bonuses and penalties by weapon */
3314 if (has_melee_weapon(creature_ptr, slot)) {
3315 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3316 BIT_FLAGS flgs[TR_FLAG_SIZE];
3317 object_flags(creature_ptr, o_ptr, flgs);
3319 tval_type tval = o_ptr->tval - TV_WEAPON_BEGIN;
3320 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
3322 /* Traind bonuses */
3323 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3325 /* Weight penalty */
3326 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
3327 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3330 /* Low melee penalty */
3331 if ((object_is_fully_known(o_ptr) || is_real_value) && any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
3332 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
3339 /* Riding bonus and penalty */
3340 if (creature_ptr->riding) {
3341 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3346 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
3347 && !has_flag(flgs, TR_RIDING)) {
3349 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
3352 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3357 hit -= (s16b)penalty;
3360 /* Class penalties */
3361 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3363 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3364 hit += creature_ptr->lev / 5;
3365 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3366 hit += creature_ptr->lev / 5;
3368 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3369 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3376 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
3380 /* Hex realm bonuses */
3381 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3382 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
3385 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
3388 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
3391 if (any_bits(o_ptr->curse_flags, (TRC_TY_CURSE))) {
3397 /* Bonuses from inventory */
3398 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3399 object_type *o_ptr = &creature_ptr->inventory_list[i];
3401 /* Ignore empty hands, handed weapons, bows and capture balls */
3402 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
3403 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3406 /* Fake value does not include unknown objects' value */
3407 if (!object_is_known(o_ptr) && !is_real_value)
3410 int bonus_to_h = o_ptr->to_h;
3412 /* When wields only a weapon */
3413 if (creature_ptr->pclass == CLASS_NINJA) {
3414 if (o_ptr->to_h > 0)
3415 bonus_to_h = (o_ptr->to_h + 1) / 2;
3418 switch (player_melee_type(creature_ptr)) {
3419 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
3420 case MELEE_TYPE_WEAPON_TWOHAND:
3421 if (calc_hand == main_attack_hand(creature_ptr))
3422 hit += (s16b)bonus_to_h;
3425 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
3426 case MELEE_TYPE_WEAPON_MAIN:
3427 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
3428 hit += (s16b)bonus_to_h;
3431 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
3432 case MELEE_TYPE_WEAPON_SUB:
3433 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
3434 hit += (s16b)bonus_to_h;
3437 case MELEE_TYPE_WEAPON_DOUBLE:
3438 if (calc_hand == PLAYER_HAND_MAIN) {
3439 if (i == INVEN_MAIN_RING) {
3440 hit += (s16b)bonus_to_h;
3441 } else if (i != INVEN_SUB_RING) {
3442 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
3445 if (calc_hand == PLAYER_HAND_SUB) {
3446 if (i == INVEN_SUB_RING) {
3447 hit += (s16b)bonus_to_h;
3448 } else if (i != INVEN_MAIN_RING) {
3449 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
3454 case MELEE_TYPE_SHIELD_DOUBLE:
3462 /* Martial arts bonus */
3463 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3464 hit += (creature_ptr->lev / 3);
3467 /* Two handed combat penalty */
3468 hit -= calc_double_weapon_penalty(creature_ptr, slot);
3470 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
3471 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
3472 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
3473 hit -= (creature_ptr->lev / 3);
3480 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
3484 pow += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3485 pow += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3489 BIT_FLAGS flgs[TR_FLAG_SIZE];
3490 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3492 object_flags(creature_ptr, o_ptr, flgs);
3494 if (any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
3495 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
3504 if (creature_ptr->stun > 50) {
3506 } else if (creature_ptr->stun) {
3510 if (is_blessed(creature_ptr)) {
3514 if (is_hero(creature_ptr)) {
3518 if (is_shero(creature_ptr)) {
3522 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3524 if (is_heavy_shoot(creature_ptr, o_ptr)) {
3525 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3529 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
3530 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
3531 pow += (10 + (creature_ptr->lev / 5));
3537 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3539 o_ptr = &creature_ptr->inventory_list[i];
3540 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
3541 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3544 bonus_to_h = o_ptr->to_h;
3546 if (creature_ptr->pclass == CLASS_NINJA) {
3547 if (o_ptr->to_h > 0)
3548 bonus_to_h = (o_ptr->to_h + 1) / 2;
3551 if (is_real_value || object_is_known(o_ptr))
3552 pow += (s16b)bonus_to_h;
3555 pow -= calc_riding_bow_penalty(creature_ptr);
3560 static s16b calc_to_damage_misc(player_type *creature_ptr)
3563 BIT_FLAGS flgs[TR_FLAG_SIZE];
3567 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3568 o_ptr = &creature_ptr->inventory_list[i];
3572 object_flags(creature_ptr, o_ptr, flgs);
3574 int bonus_to_d = o_ptr->to_d;
3575 if (creature_ptr->pclass == CLASS_NINJA) {
3576 if (o_ptr->to_d > 0)
3577 bonus_to_d = (o_ptr->to_d + 1) / 2;
3579 to_dam += (s16b)bonus_to_d;
3582 if (is_shero(creature_ptr)) {
3583 to_dam += 3 + (creature_ptr->lev / 5);
3586 if (creature_ptr->stun > 50) {
3588 } else if (creature_ptr->stun) {
3592 to_dam += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3596 static s16b calc_to_hit_misc(player_type *creature_ptr)
3599 BIT_FLAGS flgs[TR_FLAG_SIZE];
3603 for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3604 o_ptr = &creature_ptr->inventory_list[i];
3608 object_flags(creature_ptr, o_ptr, flgs);
3610 int bonus_to_h = o_ptr->to_h;
3611 if (creature_ptr->pclass == CLASS_NINJA) {
3612 if (o_ptr->to_h > 0)
3613 bonus_to_h = (o_ptr->to_h + 1) / 2;
3615 to_hit += (s16b)bonus_to_h;
3618 if (is_blessed(creature_ptr)) {
3622 if (is_hero(creature_ptr)) {
3626 if (is_shero(creature_ptr)) {
3630 if (creature_ptr->stun > 50) {
3632 } else if (creature_ptr->stun) {
3636 to_hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3637 to_hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3642 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
3644 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3647 if (creature_ptr->riding) {
3648 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3656 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
3658 (void)creature_ptr; // unused
3659 (void)slot; // unused
3664 * @brief プレイヤーの所持重量制限を計算する /
3665 * Computes current weight limit.
3668 WEIGHT calc_weight_limit(player_type *creature_ptr)
3670 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
3671 if (creature_ptr->pclass == CLASS_BERSERKER)
3677 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3678 * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND)
3679 * @return 持っているならばTRUE
3681 bool has_melee_weapon(player_type *creature_ptr, int slot)
3683 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
3687 * @brief プレイヤーの現在開いている手の状態を返す
3688 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3689 * @return 開いている手のビットフラグ
3691 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
3693 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3694 if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx)
3695 status |= EMPTY_HAND_MAIN;
3696 if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx)
3697 status |= EMPTY_HAND_SUB;
3699 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
3700 if (any_bits(status, EMPTY_HAND_SUB))
3701 reset_bits(status, EMPTY_HAND_SUB);
3702 else if (any_bits(status, EMPTY_HAND_MAIN))
3703 reset_bits(status, EMPTY_HAND_MAIN);
3710 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3711 * @return ペナルティが適用されるならばTRUE。
3713 bool heavy_armor(player_type *creature_ptr)
3715 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
3718 WEIGHT monk_arm_wgt = 0;
3719 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
3720 monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
3721 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
3722 monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
3723 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
3724 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
3725 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
3726 monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
3727 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
3729 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
3733 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
3735 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3737 void update_creature(player_type *creature_ptr)
3739 if (!creature_ptr->update)
3742 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3743 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
3744 reset_bits(creature_ptr->update, PU_AUTODESTROY);
3745 autopick_delayed_alter(creature_ptr);
3748 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
3749 reset_bits(creature_ptr->update, PU_COMBINE);
3750 combine_pack(creature_ptr);
3753 if (any_bits(creature_ptr->update, (PU_REORDER))) {
3754 reset_bits(creature_ptr->update, PU_REORDER);
3755 reorder_pack(creature_ptr);
3758 if (any_bits(creature_ptr->update, (PU_BONUS))) {
3759 reset_bits(creature_ptr->update, PU_BONUS);
3760 update_alignment(creature_ptr);
3761 update_bonuses(creature_ptr);
3764 if (any_bits(creature_ptr->update, (PU_TORCH))) {
3765 reset_bits(creature_ptr->update, PU_TORCH);
3766 update_lite_radius(creature_ptr);
3769 if (any_bits(creature_ptr->update, (PU_HP))) {
3770 reset_bits(creature_ptr->update, PU_HP);
3771 update_max_hitpoints(creature_ptr);
3774 if (any_bits(creature_ptr->update, (PU_MANA))) {
3775 reset_bits(creature_ptr->update, PU_MANA);
3776 update_max_mana(creature_ptr);
3779 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
3780 reset_bits(creature_ptr->update, PU_SPELLS);
3781 update_num_of_spells(creature_ptr);
3784 if (!current_world_ptr->character_generated)
3786 if (current_world_ptr->character_icky_depth > 0)
3788 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
3789 reset_bits(creature_ptr->update, PU_UN_LITE);
3790 forget_lite(floor_ptr);
3793 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
3794 reset_bits(creature_ptr->update, PU_UN_VIEW);
3795 forget_view(floor_ptr);
3798 if (any_bits(creature_ptr->update, (PU_VIEW))) {
3799 reset_bits(creature_ptr->update, PU_VIEW);
3800 update_view(creature_ptr);
3803 if (any_bits(creature_ptr->update, (PU_LITE))) {
3804 reset_bits(creature_ptr->update, PU_LITE);
3805 update_lite(creature_ptr);
3808 if (any_bits(creature_ptr->update, (PU_FLOW))) {
3809 reset_bits(creature_ptr->update, PU_FLOW);
3810 update_flow(creature_ptr);
3813 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
3814 reset_bits(creature_ptr->update, PU_DISTANCE);
3816 update_monsters(creature_ptr, TRUE);
3819 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
3820 reset_bits(creature_ptr->update, PU_MON_LITE);
3821 update_mon_lite(creature_ptr);
3824 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
3825 reset_bits(creature_ptr->update, PU_DELAY_VIS);
3826 delayed_visual_update(creature_ptr);
3829 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
3830 reset_bits(creature_ptr->update, PU_MONSTERS);
3831 update_monsters(creature_ptr, FALSE);
3836 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
3837 * @return 魔道書を一冊も持っていないならTRUEを返す
3839 bool player_has_no_spellbooks(player_type *creature_ptr)
3842 for (int i = 0; i < INVEN_PACK; i++) {
3843 o_ptr = &creature_ptr->inventory_list[i];
3844 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3848 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3849 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
3850 o_ptr = &floor_ptr->o_list[i];
3851 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3858 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost) { creature_ptr->energy_use = (ENERGY)need_cost; }
3860 void free_turn(player_type *creature_ptr) { creature_ptr->energy_use = 0; }
3863 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
3866 * @return 配置に成功したらTRUE
3868 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
3870 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
3873 /* Save player location */
3874 creature_ptr->y = y;
3875 creature_ptr->x = x;
3880 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
3883 void wreck_the_pattern(player_type *creature_ptr)
3885 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3886 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
3887 if (pattern_type == PATTERN_TILE_WRECKED)
3890 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
3891 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
3893 if (!is_invuln(creature_ptr))
3894 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
3896 int to_ruin = randint1(45) + 35;
3899 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
3901 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
3902 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
3906 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
3910 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
3911 * Advance experience levels and print experience
3914 void check_experience(player_type *creature_ptr)
3916 if (creature_ptr->exp < 0)
3917 creature_ptr->exp = 0;
3918 if (creature_ptr->max_exp < 0)
3919 creature_ptr->max_exp = 0;
3920 if (creature_ptr->max_max_exp < 0)
3921 creature_ptr->max_max_exp = 0;
3923 if (creature_ptr->exp > PY_MAX_EXP)
3924 creature_ptr->exp = PY_MAX_EXP;
3925 if (creature_ptr->max_exp > PY_MAX_EXP)
3926 creature_ptr->max_exp = PY_MAX_EXP;
3927 if (creature_ptr->max_max_exp > PY_MAX_EXP)
3928 creature_ptr->max_max_exp = PY_MAX_EXP;
3930 if (creature_ptr->exp > creature_ptr->max_exp)
3931 creature_ptr->max_exp = creature_ptr->exp;
3932 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
3933 creature_ptr->max_max_exp = creature_ptr->max_exp;
3935 set_bits(creature_ptr->redraw, PR_EXP);
3936 handle_stuff(creature_ptr);
3938 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
3939 PLAYER_LEVEL old_lev = creature_ptr->lev;
3940 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
3941 creature_ptr->lev--;
3942 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
3943 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
3944 set_bits(creature_ptr->window_flags, PW_PLAYER);
3945 handle_stuff(creature_ptr);
3948 bool level_reward = FALSE;
3949 bool level_mutation = FALSE;
3950 bool level_inc_stat = FALSE;
3951 while ((creature_ptr->lev < PY_MAX_LEVEL)
3952 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
3953 creature_ptr->lev++;
3954 if (creature_ptr->lev > creature_ptr->max_plv) {
3955 creature_ptr->max_plv = creature_ptr->lev;
3957 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || any_bits(creature_ptr->muta2, MUT2_CHAOS_GIFT)) {
3958 level_reward = TRUE;
3960 if (creature_ptr->prace == RACE_BEASTMAN) {
3962 level_mutation = TRUE;
3964 level_inc_stat = TRUE;
3966 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
3970 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
3971 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
3972 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
3973 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
3974 creature_ptr->level_up_message = TRUE;
3975 handle_stuff(creature_ptr);
3977 creature_ptr->level_up_message = FALSE;
3978 if (level_inc_stat) {
3979 if (!(creature_ptr->max_plv % 10)) {
3986 cnv_stat(creature_ptr->stat_max[0], tmp);
3987 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
3988 cnv_stat(creature_ptr->stat_max[1], tmp);
3989 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
3990 cnv_stat(creature_ptr->stat_max[2], tmp);
3991 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
3992 cnv_stat(creature_ptr->stat_max[3], tmp);
3993 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
3994 cnv_stat(creature_ptr->stat_max[4], tmp);
3995 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
3996 cnv_stat(creature_ptr->stat_max[5], tmp);
3997 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
4000 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
4004 if ((choice >= 'a') && (choice <= 'f'))
4007 for (n = 0; n < A_MAX; n++)
4008 if (n != choice - 'a')
4010 if (get_check(_("よろしいですか?", "Are you sure? ")))
4013 do_inc_stat(creature_ptr, choice - 'a');
4015 } else if (!(creature_ptr->max_plv % 2))
4016 do_inc_stat(creature_ptr, randint0(6));
4019 if (level_mutation) {
4020 msg_print(_("あなたは変わった気がする...", "You feel different..."));
4021 (void)gain_mutation(creature_ptr, 0);
4022 level_mutation = FALSE;
4026 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
4030 gain_level_reward(creature_ptr, 0);
4031 level_reward = FALSE;
4034 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4035 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
4036 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
4037 handle_stuff(creature_ptr);
4040 if (old_lev != creature_ptr->lev)
4041 autopick_load_pref(creature_ptr, FALSE);
4045 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
4047 * @param out_val 出力先文字列ポインタ
4050 void cnv_stat(int val, char *out_val)
4053 sprintf(out_val, " %2d", val);
4057 int bonus = (val - 18);
4059 sprintf(out_val, "18/%3s", "***");
4060 } else if (bonus >= 100) {
4061 sprintf(out_val, "18/%03d", bonus);
4063 sprintf(out_val, " 18/%02d", bonus);
4068 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
4069 * Modify a stat value by a "modifier", return new value
4071 * @param amount 加減算値
4075 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
4076 * Or even: 18/13, 18/23, 18/33, ..., 18/220
4077 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
4078 * Or even: 18/13, 18/03, 18, 17, ..., 3
4081 s16b modify_stat_value(int value, int amount)
4084 for (int i = 0; i < amount; i++) {
4090 } else if (amount < 0) {
4091 for (int i = 0; i < (0 - amount); i++) {
4092 if (value >= 18 + 10)
4094 else if (value > 18)
4106 * Hack -- Calculates the total number of points earned -JWT-
4110 long calc_score(player_type *creature_ptr)
4112 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
4125 if (ironman_small_levels)
4127 if (ironman_empty_levels)
4133 if (ironman_nightmare)
4140 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
4141 if (max_dlv[i] > max_dl)
4142 max_dl = max_dlv[i];
4144 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
4145 u32b point_h = point_l / 0x10000L;
4146 point_l = point_l % 0x10000L;
4149 point_h += point_l / 0x10000L;
4150 point_l %= 0x10000L;
4152 point_l += ((point_h % 100) << 16);
4156 u32b point = (point_h << 16) + (point_l);
4157 if (creature_ptr->arena_number >= 0)
4158 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
4160 if (ironman_downward)
4162 if (creature_ptr->pclass == CLASS_BERSERKER) {
4163 if (creature_ptr->prace == RACE_SPECTRE)
4167 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
4169 if (current_world_ptr->total_winner)
4174 point = (0 - point);
4180 * @param creature_ptr プレーヤーへの参照ポインタ
4181 * @return 祝福状態ならばTRUE
4183 bool is_blessed(player_type *creature_ptr)
4185 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
4188 bool is_tim_esp(player_type *creature_ptr)
4190 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
4193 bool is_tim_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
4195 bool is_time_limit_esp(player_type *creature_ptr)
4197 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
4200 bool is_time_limit_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
4202 bool can_two_hands_wielding(player_type *creature_ptr) { return !creature_ptr->riding || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS); }
4205 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
4208 void stop_singing(player_type *creature_ptr)
4210 if (creature_ptr->pclass != CLASS_BARD)
4213 /* Are there interupted song? */
4214 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
4215 /* Forget interupted song */
4216 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
4220 /* The player is singing? */
4221 if (!SINGING_SONG_EFFECT(creature_ptr))
4224 /* Hack -- if called from set_action(), avoid recursive loop */
4225 if (creature_ptr->action == ACTION_SING)
4226 set_action(creature_ptr, ACTION_NONE);
4228 /* Message text of each song or etc. */
4229 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
4231 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
4232 SINGING_SONG_ID(creature_ptr) = 0;
4233 set_bits(creature_ptr->update, PU_BONUS);
4234 set_bits(creature_ptr->redraw, PR_STATUS);
4238 * @brief 口を使う継続的な処理を中断する
4239 * @param caster_ptr プレーヤーへの参照ポインタ
4242 void stop_mouth(player_type *caster_ptr)
4244 if (music_singing_any(caster_ptr))
4245 stop_singing(caster_ptr);
4246 if (hex_spelling_any(caster_ptr))
4247 stop_hex_spell_all(caster_ptr);
4251 * @brief ペットの維持コスト計算
4254 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
4257 bool has_a_unique = FALSE;
4258 DEPTH total_friend_levels = 0;
4262 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
4263 monster_type *m_ptr;
4264 monster_race *r_ptr;
4266 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
4267 if (!monster_is_valid(m_ptr))
4269 r_ptr = &r_info[m_ptr->r_idx];
4271 if (is_pet(m_ptr)) {
4273 if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
4274 if (creature_ptr->pclass == CLASS_CAVALRY) {
4275 if (creature_ptr->riding == m_idx)
4276 total_friend_levels += (r_ptr->level + 5) * 2;
4277 else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
4278 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
4280 total_friend_levels += (r_ptr->level + 5) * 10;
4281 has_a_unique = TRUE;
4283 total_friend_levels += (r_ptr->level + 5) * 10;
4285 total_friend_levels += r_ptr->level;
4289 if (total_friends) {
4291 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
4292 if (upkeep_factor < 0)
4294 if (upkeep_factor > 1000)
4295 upkeep_factor = 1000;
4296 return upkeep_factor;
4301 bool music_singing(player_type *caster_ptr, int music_songs) { return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs); }
4303 bool is_fast(player_type *creature_ptr) { return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO); }
4305 bool is_invuln(player_type *creature_ptr) { return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN); }
4307 bool is_hero(player_type *creature_ptr) { return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO); }
4309 bool is_shero(player_type *creature_ptr) { return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER; }
4311 bool is_echizen(player_type *creature_ptr)
4313 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
4316 int calc_weapon_weight_limit(player_type *creature_ptr)
4318 int weight = adj_str_hold[creature_ptr->stat_ind[A_STR]];
4320 if (has_two_handed_weapons(creature_ptr))
4326 static player_hand main_attack_hand(player_type *creature_ptr)
4328 switch (player_melee_type(creature_ptr)) {
4329 case MELEE_TYPE_BAREHAND_TWO:
4330 return PLAYER_HAND_MAIN;
4331 case MELEE_TYPE_BAREHAND_MAIN:
4332 return PLAYER_HAND_MAIN;
4333 case MELEE_TYPE_BAREHAND_SUB:
4334 return PLAYER_HAND_SUB;
4335 case MELEE_TYPE_WEAPON_MAIN:
4336 return PLAYER_HAND_MAIN;
4337 case MELEE_TYPE_WEAPON_SUB:
4338 return PLAYER_HAND_SUB;
4339 case MELEE_TYPE_WEAPON_TWOHAND:
4340 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
4341 case MELEE_TYPE_WEAPON_DOUBLE:
4342 return PLAYER_HAND_MAIN;
4343 case MELEE_TYPE_SHIELD_DOUBLE:
4344 return PLAYER_HAND_MAIN;