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 (int 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 (int 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 = static_cast<tval_type>(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 (int 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 * @brief 隠密能力計算 - 種族
1215 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1220 static ACTION_SKILL_POWER calc_player_stealth_by_race(player_type *creature_ptr)
1222 const player_race *tmp_rp_ptr;
1224 if (creature_ptr->mimic_form)
1225 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1227 tmp_rp_ptr = &race_info[creature_ptr->prace];
1229 return tmp_rp_ptr->r_stl;
1234 * @brief 隠密能力計算 - 性格
1235 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1240 static ACTION_SKILL_POWER calc_player_stealth_by_personality(player_type *creature_ptr)
1242 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1244 return a_ptr->a_stl;
1248 * @brief 隠密能力計算 - 職業(基礎値)
1249 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1254 static ACTION_SKILL_POWER calc_player_base_stealth_by_class(player_type *creature_ptr)
1256 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1257 return c_ptr->c_stl + (c_ptr->x_stl * creature_ptr->lev / 10);
1262 * @brief 隠密能力計算 - 職業(追加分)
1263 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1266 * * 忍者がheavy_armorならば減算(-レベル/10)
1267 * * 忍者がheavy_armorでなく適正な武器を持っていれば加算(+レベル/10)
1269 static ACTION_SKILL_POWER calc_player_additional_stealth_by_class(player_type *creature_ptr)
1271 ACTION_SKILL_POWER result = 0;
1273 if (creature_ptr->pclass == CLASS_NINJA) {
1274 if (heavy_armor(creature_ptr)) {
1275 result -= (creature_ptr->lev) / 10;
1276 } else if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
1277 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
1278 result += (creature_ptr->lev) / 10;
1287 * @brief 隠密能力計算 - 装備
1288 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1291 * * 装備による修正(TR_STEALTHがあれば+pval*1)
1293 static ACTION_SKILL_POWER calc_player_stealth_by_equipment(player_type *creature_ptr)
1296 ACTION_SKILL_POWER result = 0;
1297 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1299 BIT_FLAGS flgs[TR_FLAG_SIZE];
1300 o_ptr = &creature_ptr->inventory_list[i];
1303 object_flags(creature_ptr, o_ptr, flgs);
1304 if (has_flag(flgs, TR_STEALTH))
1305 result += o_ptr->pval;
1312 * @brief 隠密能力計算 - 変異
1313 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1316 * * 変異MUT3_XTRA_NOISで減算(-3)
1317 * * 変異MUT3_MOTIONで加算(+1)
1319 static ACTION_SKILL_POWER calc_player_stealth_by_mutation(player_type *creature_ptr)
1321 ACTION_SKILL_POWER result = 0;
1322 if (any_bits(creature_ptr->muta3, MUT3_XTRA_NOIS)) {
1325 if (any_bits(creature_ptr->muta3, MUT3_MOTION)) {
1332 * @brief 隠密能力計算 - 一時効果
1333 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1336 * * 呪術を唱えていると減算(-(詠唱数+1))
1340 static ACTION_SKILL_POWER calc_player_stealth_by_time_effect(player_type *creature_ptr)
1342 ACTION_SKILL_POWER result = 0;
1343 if (creature_ptr->realm1 == REALM_HEX) {
1344 if (hex_spelling_any(creature_ptr))
1345 result -= (1 + casting_hex_num(creature_ptr));
1347 if (is_shero(creature_ptr)) {
1350 if (is_time_limit_stealth(creature_ptr))
1357 * @brief 隠密能力計算 - 影フェアリー反感処理
1358 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1361 * * セクシーギャルでない影フェアリーがTRC_AGGRAVATE持ちの時、別処理でTRC_AGGRAVATEを無効にする代わりに減算(-3か3未満なら(現在値+2)/2)
1363 static ACTION_SKILL_POWER calc_player_stealth_by_s_faiery(player_type *creature_ptr, ACTION_SKILL_POWER pow)
1365 if (player_aggravate_state(creature_ptr) == AGGRAVATE_S_FAIRY) {
1366 pow = MIN(pow - 3, (pow + 2) / 2);
1372 BIT_FLAGS player_flags_stealth(player_type *creature_ptr)
1374 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_STEALTH);
1376 if (calc_player_additional_stealth_by_class(creature_ptr) != 0)
1377 set_bits(result, FLAG_CAUSE_CLASS);
1379 if (calc_player_stealth_by_mutation(creature_ptr) != 0)
1380 set_bits(result, FLAG_CAUSE_MUTATION);
1382 if (calc_player_stealth_by_time_effect(creature_ptr) != 0)
1383 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
1385 if (calc_player_stealth_by_s_faiery(creature_ptr, 0) != 0)
1386 set_bits(result, FLAG_CAUSE_RACE);
1393 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1399 static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
1401 ACTION_SKILL_POWER pow = 1;
1402 pow += calc_player_base_stealth_by_class(creature_ptr);
1403 pow += calc_player_additional_stealth_by_class(creature_ptr);
1404 pow += calc_player_stealth_by_race(creature_ptr);
1405 pow += calc_player_stealth_by_personality(creature_ptr);
1406 pow += calc_player_stealth_by_equipment(creature_ptr);
1407 pow += calc_player_stealth_by_mutation(creature_ptr);
1408 pow += calc_player_stealth_by_time_effect(creature_ptr);
1409 pow = calc_player_stealth_by_s_faiery(creature_ptr, pow); /* Set New Value */
1421 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1425 * * 職業と性格とレベルによる追加加算
1426 * * 器用さに応じたadj_dex_disテーブルによる加算
1427 * * 知力に応じたadj_int_disテーブルによる加算
1429 static ACTION_SKILL_POWER calc_disarming(player_type *creature_ptr)
1431 ACTION_SKILL_POWER pow;
1432 const player_race *tmp_rp_ptr;
1434 if (creature_ptr->mimic_form)
1435 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1437 tmp_rp_ptr = &race_info[creature_ptr->prace];
1438 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1439 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1441 pow = tmp_rp_ptr->r_dis + c_ptr->c_dis + a_ptr->a_dis;
1442 pow += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
1443 pow += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
1444 pow += adj_int_dis[creature_ptr->stat_ind[A_INT]];
1450 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1454 * * 職業と性格とレベルによる追加加算
1455 * * 装備による加算(TR_MAGIC_MASTERYを持っていたら+pval*8)
1456 * * 知力に応じたadj_int_devテーブルによる加算
1459 static ACTION_SKILL_POWER calc_device_ability(player_type *creature_ptr)
1461 ACTION_SKILL_POWER pow;
1462 const player_race *tmp_rp_ptr;
1464 if (creature_ptr->mimic_form)
1465 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1467 tmp_rp_ptr = &race_info[creature_ptr->prace];
1468 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1469 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1471 pow = tmp_rp_ptr->r_dev + c_ptr->c_dev + a_ptr->a_dev;
1472 pow += ((c_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
1474 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1476 BIT_FLAGS flgs[TR_FLAG_SIZE];
1477 o_ptr = &creature_ptr->inventory_list[i];
1480 object_flags(creature_ptr, o_ptr, flgs);
1481 if (has_flag(flgs, TR_MAGIC_MASTERY))
1482 pow += 8 * o_ptr->pval;
1485 pow += adj_int_dev[creature_ptr->stat_ind[A_INT]];
1487 if (is_shero(creature_ptr)) {
1495 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1499 * * 職業と性格とレベルによる追加加算
1500 * * 変異MUT3_MAGIC_RESによる加算(15 + レベル / 5)
1501 * * 賢さによるadj_wis_savテーブル加算
1503 * * 反魔法持ちで大なり上書き(90+レベル未満ならその値に上書き)
1504 * * クターのつぶれ状態なら(10に上書き)
1505 * * 生命の「究極の耐性」や regist_magic,magicdef持ちなら大なり上書き(95+レベル未満ならその値に上書き)
1506 * * 呪いのdown_savingがかかっているなら半減
1508 static ACTION_SKILL_POWER calc_saving_throw(player_type *creature_ptr)
1510 ACTION_SKILL_POWER pow;
1511 const player_race *tmp_rp_ptr;
1513 if (creature_ptr->mimic_form)
1514 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1516 tmp_rp_ptr = &race_info[creature_ptr->prace];
1517 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1518 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1520 pow = tmp_rp_ptr->r_sav + c_ptr->c_sav + a_ptr->a_sav;
1521 pow += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
1523 if (any_bits(creature_ptr->muta3, MUT3_MAGIC_RES))
1524 pow += (15 + (creature_ptr->lev / 5));
1526 pow += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
1528 if (is_shero(creature_ptr))
1531 if (creature_ptr->anti_magic && (pow < (90 + creature_ptr->lev)))
1532 pow = 90 + creature_ptr->lev;
1534 if (creature_ptr->tsubureru)
1537 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (pow < (95 + creature_ptr->lev)))
1538 pow = 95 + creature_ptr->lev;
1540 if (creature_ptr->down_saving)
1548 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1553 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1555 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1557 static ACTION_SKILL_POWER calc_search(player_type *creature_ptr)
1559 ACTION_SKILL_POWER pow;
1560 const player_race *tmp_rp_ptr;
1562 if (creature_ptr->mimic_form)
1563 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1565 tmp_rp_ptr = &race_info[creature_ptr->prace];
1566 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1567 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1569 pow = tmp_rp_ptr->r_srh + c_ptr->c_srh + a_ptr->a_srh;
1570 pow += (c_ptr->x_srh * creature_ptr->lev / 10);
1572 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1574 BIT_FLAGS flgs[TR_FLAG_SIZE];
1575 o_ptr = &creature_ptr->inventory_list[i];
1578 object_flags(creature_ptr, o_ptr, flgs);
1579 if (has_flag(flgs, TR_SEARCH))
1580 pow += (o_ptr->pval * 5);
1583 if (any_bits(creature_ptr->muta3, MUT3_XTRA_EYES)) {
1587 if (is_shero(creature_ptr)) {
1596 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1601 * * 各装備による加算(TR_SEARCHがあれば+pval*5)
1603 * * 変異(MUT3_XTRA_EYES)による加算(+15)
1605 static ACTION_SKILL_POWER calc_search_freq(player_type *creature_ptr)
1607 ACTION_SKILL_POWER pow;
1608 const player_race *tmp_rp_ptr;
1610 if (creature_ptr->mimic_form)
1611 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1613 tmp_rp_ptr = &race_info[creature_ptr->prace];
1614 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1615 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1617 pow = tmp_rp_ptr->r_fos + c_ptr->c_fos + a_ptr->a_fos;
1618 pow += (c_ptr->x_fos * creature_ptr->lev / 10);
1620 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1622 BIT_FLAGS flgs[TR_FLAG_SIZE];
1623 o_ptr = &creature_ptr->inventory_list[i];
1626 object_flags(creature_ptr, o_ptr, flgs);
1627 if (has_flag(flgs, TR_SEARCH))
1628 pow += (o_ptr->pval * 5);
1631 if (is_shero(creature_ptr)) {
1635 if (any_bits(creature_ptr->muta3, MUT3_XTRA_EYES)) {
1644 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1647 * * 種族/職業/性格による加算とレベルによる追加加算
1649 static ACTION_SKILL_POWER calc_to_hit_melee(player_type *creature_ptr)
1651 ACTION_SKILL_POWER pow;
1652 const player_race *tmp_rp_ptr;
1653 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1654 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1656 if (creature_ptr->mimic_form)
1657 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1659 tmp_rp_ptr = &race_info[creature_ptr->prace];
1661 pow = tmp_rp_ptr->r_thn + c_ptr->c_thn + a_ptr->a_thn;
1662 pow += ((c_ptr->x_thn * creature_ptr->lev / 10) + (a_ptr->a_thn * creature_ptr->lev / 50));
1668 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1671 * * 種族/職業/性格による加算とレベルによる追加加算
1673 static ACTION_SKILL_POWER calc_to_hit_shoot(player_type *creature_ptr)
1675 ACTION_SKILL_POWER pow;
1676 const player_race *tmp_rp_ptr;
1677 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1678 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1680 if (creature_ptr->mimic_form)
1681 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1683 tmp_rp_ptr = &race_info[creature_ptr->prace];
1685 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1686 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1692 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1695 * * 種族/職業/性格による加算とレベルによる追加加算
1698 static ACTION_SKILL_POWER calc_to_hit_throw(player_type *creature_ptr)
1700 ACTION_SKILL_POWER pow;
1701 const player_race *tmp_rp_ptr;
1702 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1703 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1705 if (creature_ptr->mimic_form)
1706 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1708 tmp_rp_ptr = &race_info[creature_ptr->prace];
1710 pow = tmp_rp_ptr->r_thb + c_ptr->c_thb + a_ptr->a_thb;
1711 pow += ((c_ptr->x_thb * creature_ptr->lev / 10) + (a_ptr->a_thb * creature_ptr->lev / 50));
1713 if (is_shero(creature_ptr)) {
1722 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1733 static ACTION_SKILL_POWER calc_skill_dig(player_type *creature_ptr)
1736 BIT_FLAGS flgs[TR_FLAG_SIZE];
1738 ACTION_SKILL_POWER pow;
1742 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT && !creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) {
1743 pow += creature_ptr->lev * 10;
1746 if (is_shero(creature_ptr))
1749 pow += adj_str_dig[creature_ptr->stat_ind[A_STR]];
1751 if (creature_ptr->pclass == CLASS_BERSERKER)
1752 pow += (100 + creature_ptr->lev * 8);
1754 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1755 o_ptr = &creature_ptr->inventory_list[i];
1758 object_flags(creature_ptr, o_ptr, flgs);
1759 if (has_flag(flgs, TR_TUNNEL))
1760 pow += (o_ptr->pval * 20);
1763 for (int i = 0; i < 2; i++) {
1764 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1765 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && !creature_ptr->heavy_wield[i]) {
1766 pow += (o_ptr->weight / 10);
1770 if (is_shero(creature_ptr)) {
1780 static bool is_martial_arts_mode(player_type *creature_ptr)
1782 return ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER))
1783 && (any_bits(empty_hands(creature_ptr, TRUE), EMPTY_HAND_MAIN)) && !can_attack_with_sub_hand(creature_ptr);
1786 static bool is_heavy_wield(player_type *creature_ptr, int i)
1788 const object_type *o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1790 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i) && (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10);
1793 static s16b calc_num_blow(player_type *creature_ptr, int i)
1796 BIT_FLAGS flgs[TR_FLAG_SIZE];
1799 o_ptr = &creature_ptr->inventory_list[INVEN_MAIN_HAND + i];
1800 object_flags(creature_ptr, o_ptr, flgs);
1801 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
1802 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i]) {
1803 int str_index, dex_index;
1804 int num = 0, wgt = 0, mul = 0, div = 0;
1806 num = class_info[creature_ptr->pclass].num;
1807 wgt = class_info[creature_ptr->pclass].wgt;
1808 mul = class_info[creature_ptr->pclass].mul;
1810 if (creature_ptr->pclass == CLASS_CAVALRY && (creature_ptr->riding) && (has_flag(flgs, TR_RIDING))) {
1816 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) {
1822 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
1823 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
1825 if (has_two_handed_weapons(creature_ptr) && !has_disable_two_handed_bonus(creature_ptr, 0))
1827 if (creature_ptr->pclass == CLASS_NINJA)
1828 str_index = MAX(0, str_index - 1);
1832 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
1836 num_blow = blows_table[str_index][dex_index];
1838 num_blow = (s16b)num;
1840 num_blow += (s16b)creature_ptr->extra_blows[i];
1841 if (creature_ptr->pclass == CLASS_WARRIOR)
1842 num_blow += (creature_ptr->lev / 40);
1843 else if (creature_ptr->pclass == CLASS_BERSERKER)
1844 num_blow += (creature_ptr->lev / 23);
1845 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
1848 if (any_bits(creature_ptr->special_defense, KATA_FUUJIN))
1851 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
1861 /* Different calculation for monks with empty hands */
1862 if (is_martial_arts_mode(creature_ptr)) {
1863 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
1866 if (creature_ptr->pclass == CLASS_FORCETRAINER) {
1892 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
1895 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
1897 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42))
1901 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1905 num_blow += 1 + creature_ptr->extra_blows[0];
1908 if (has_not_ninja_weapon(creature_ptr, i)) {
1919 * @param creature_ptr 計算するクリーチャーの参照ポインタ
1923 * * エントは別途レベル26,41,46到達ごとに加算(+1)
1924 * * 装備がTR_STRフラグを持っていれば加算(+pval*1)
1930 * * 変異MUT3_HYPER_STRで加算(+4)
1931 * * 変異MUT3_PUNYで減算(-4)
1932 * * ネオ・つよしスペシャル中で加算(+4)
1934 static s16b calc_strength_addition(player_type *creature_ptr)
1937 const player_race *tmp_rp_ptr;
1938 if (creature_ptr->mimic_form)
1939 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1941 tmp_rp_ptr = &race_info[creature_ptr->prace];
1942 const player_class *c_ptr = &class_info[creature_ptr->pclass];
1943 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
1944 pow = tmp_rp_ptr->r_adj[A_STR] + c_ptr->c_adj[A_STR] + a_ptr->a_adj[A_STR];
1946 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
1947 if (creature_ptr->lev > 25)
1949 if (creature_ptr->lev > 40)
1951 if (creature_ptr->lev > 45)
1955 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
1957 BIT_FLAGS flgs[TR_FLAG_SIZE];
1958 o_ptr = &creature_ptr->inventory_list[i];
1961 object_flags(creature_ptr, o_ptr, flgs);
1962 if (has_flag(flgs, TR_STR)) {
1967 if (creature_ptr->realm1 == REALM_HEX) {
1968 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) {
1971 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
1976 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
1980 if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
1982 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
1986 if (creature_ptr->muta3) {
1987 if (any_bits(creature_ptr->muta3, MUT3_HYPER_STR)) {
1991 if (any_bits(creature_ptr->muta3, MUT3_PUNY)) {
1996 if (creature_ptr->tsuyoshi) {
2004 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2008 * * 装備がTR_INTフラグを持っていれば加算(+pval*1)
2014 * * 変異MUT3_HYPER_INTで加算(+4)
2015 * * 変異MUT3_MORONICで減算(-4)
2017 s16b calc_intelligence_addition(player_type *creature_ptr)
2020 const player_race *tmp_rp_ptr;
2021 if (creature_ptr->mimic_form)
2022 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2024 tmp_rp_ptr = &race_info[creature_ptr->prace];
2025 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2026 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2027 pow = tmp_rp_ptr->r_adj[A_INT] + c_ptr->c_adj[A_INT] + a_ptr->a_adj[A_INT];
2029 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2031 BIT_FLAGS flgs[TR_FLAG_SIZE];
2032 o_ptr = &creature_ptr->inventory_list[i];
2035 object_flags(creature_ptr, o_ptr, flgs);
2036 if (has_flag(flgs, TR_INT)) {
2041 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2045 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2047 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2051 if (creature_ptr->muta3) {
2052 if (any_bits(creature_ptr->muta3, MUT3_HYPER_INT)) {
2056 if (any_bits(creature_ptr->muta3, MUT3_MORONIC)) {
2066 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2070 * * 装備がTR_WISフラグを持っていれば加算(+pval*1)
2076 * * 変異MUT3_HYPER_INTで加算(+4)
2077 * * 変異MUT3_MORONICで減算(-4)
2079 static s16b calc_wisdom_addition(player_type *creature_ptr)
2082 const player_race *tmp_rp_ptr;
2083 if (creature_ptr->mimic_form)
2084 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2086 tmp_rp_ptr = &race_info[creature_ptr->prace];
2087 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2088 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2089 pow = tmp_rp_ptr->r_adj[A_WIS] + c_ptr->c_adj[A_WIS] + a_ptr->a_adj[A_WIS];
2091 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2093 BIT_FLAGS flgs[TR_FLAG_SIZE];
2094 o_ptr = &creature_ptr->inventory_list[i];
2097 object_flags(creature_ptr, o_ptr, flgs);
2098 if (has_flag(flgs, TR_WIS)) {
2103 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2107 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2109 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2113 if (creature_ptr->muta3) {
2114 if (any_bits(creature_ptr->muta3, MUT3_HYPER_INT)) {
2118 if (any_bits(creature_ptr->muta3, MUT3_MORONIC)) {
2128 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2132 * * エントは別途レベル26,41,46到達ごとに減算(-1)
2133 * * 装備がTR_DEXフラグを持っていれば加算(+pval*1)
2139 * * 変異MUT3_IRON_SKINで減算(-1)
2140 * * 変異MUT3_LIMBERで加算(+3)
2141 * * 変異MUT3_ARTHRITISで減算(-3)
2143 static s16b calc_dexterity_addition(player_type *creature_ptr)
2146 const player_race *tmp_rp_ptr;
2147 if (creature_ptr->mimic_form)
2148 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2150 tmp_rp_ptr = &race_info[creature_ptr->prace];
2151 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2152 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2153 pow = tmp_rp_ptr->r_adj[A_DEX] + c_ptr->c_adj[A_DEX] + a_ptr->a_adj[A_DEX];
2155 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2156 if (creature_ptr->lev > 25)
2158 if (creature_ptr->lev > 40)
2160 if (creature_ptr->lev > 45)
2164 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2166 BIT_FLAGS flgs[TR_FLAG_SIZE];
2167 o_ptr = &creature_ptr->inventory_list[i];
2170 object_flags(creature_ptr, o_ptr, flgs);
2171 if (has_flag(flgs, TR_DEX)) {
2176 if (creature_ptr->realm1 == REALM_HEX) {
2177 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2182 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2186 if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
2188 } else if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2190 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2194 if (any_bits(creature_ptr->muta3, MUT3_IRON_SKIN)) {
2198 if (any_bits(creature_ptr->muta3, MUT3_LIMBER)) {
2202 if (any_bits(creature_ptr->muta3, MUT3_ARTHRITIS)) {
2211 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2215 * * エントは別途レベル26,41,46到達ごとに加算(+1)
2216 * * 装備がTR_CONフラグを持っていれば加算(+pval*1)
2222 * * 変異MUT3_RESILIENTで加算(+4)
2223 * * 変異MUT3_ALBINOで減算(-4)
2224 * * 変異MUT3_XTRA_FATで加算(+2)
2225 * * 変異MUT3_FLESH_ROTで減算(-2)
2226 * * ネオ・つよしスペシャル中で加算(+4)
2228 static s16b calc_constitution_addition(player_type *creature_ptr)
2231 const player_race *tmp_rp_ptr;
2232 if (creature_ptr->mimic_form)
2233 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2235 tmp_rp_ptr = &race_info[creature_ptr->prace];
2236 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2237 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2238 pow = tmp_rp_ptr->r_adj[A_CON] + c_ptr->c_adj[A_CON] + a_ptr->a_adj[A_CON];
2240 if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ENT) {
2241 if (creature_ptr->lev > 25)
2243 if (creature_ptr->lev > 40)
2245 if (creature_ptr->lev > 45)
2249 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2251 BIT_FLAGS flgs[TR_FLAG_SIZE];
2252 o_ptr = &creature_ptr->inventory_list[i];
2255 object_flags(creature_ptr, o_ptr, flgs);
2256 if (has_flag(flgs, TR_CON))
2260 if (creature_ptr->realm1 == REALM_HEX) {
2261 if (hex_spelling(creature_ptr, HEX_BUILDING)) {
2266 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2270 if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
2272 } else if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2274 } else if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
2278 if (creature_ptr->muta3) {
2279 if (any_bits(creature_ptr->muta3, MUT3_RESILIENT)) {
2283 if (any_bits(creature_ptr->muta3, MUT3_ALBINO)) {
2287 if (any_bits(creature_ptr->muta3, MUT3_XTRA_FAT)) {
2291 if (any_bits(creature_ptr->muta3, MUT3_FLESH_ROT)) {
2296 if (creature_ptr->tsuyoshi) {
2305 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2309 * * 装備がTR_CHRフラグを持っていれば加算(+pval*1)
2312 * * 変異MUT3_FLESH_ROTで減算(-1)
2313 * * 変異MUT3_SILLY_VOIで減算(-4)
2314 * * 変異MUT3_BLANK_FACで減算(-1)
2315 * * 変異MUT3_WART_SKINで減算(-2)
2316 * * 変異MUT3_SCALESで減算(-1)
2317 * * 変異MUT3_ILL_NORMで0固定(後で個体値のみ上書きを行う)
2319 static s16b calc_charisma_addition(player_type *creature_ptr)
2322 const player_race *tmp_rp_ptr;
2323 if (creature_ptr->mimic_form)
2324 tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
2326 tmp_rp_ptr = &race_info[creature_ptr->prace];
2327 const player_class *c_ptr = &class_info[creature_ptr->pclass];
2328 const player_personality *a_ptr = &personality_info[creature_ptr->pseikaku];
2329 pow = tmp_rp_ptr->r_adj[A_CHR] + c_ptr->c_adj[A_CHR] + a_ptr->a_adj[A_CHR];
2331 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2333 BIT_FLAGS flgs[TR_FLAG_SIZE];
2334 o_ptr = &creature_ptr->inventory_list[i];
2337 object_flags(creature_ptr, o_ptr, flgs);
2338 if (has_flag(flgs, TR_CHR))
2342 if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2346 if (creature_ptr->muta3) {
2347 if (any_bits(creature_ptr->muta3, MUT3_FLESH_ROT)) {
2350 if (any_bits(creature_ptr->muta3, MUT3_SILLY_VOI)) {
2353 if (any_bits(creature_ptr->muta3, MUT3_BLANK_FAC)) {
2356 if (any_bits(creature_ptr->muta3, MUT3_WART_SKIN)) {
2359 if (any_bits(creature_ptr->muta3, MUT3_SCALES)) {
2362 if (any_bits(creature_ptr->muta3, MUT3_ILL_NORM)) {
2372 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2375 * * 性格なまけものなら加算(+10)
2377 * * 性格ちからじまんとがまんづよいなら加算(+1)
2378 * * 性格チャージマンなら加算(+5)
2379 * * 装備品にTRC_LOW_MAGICがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
2381 static s16b calc_to_magic_chance(player_type *creature_ptr)
2385 if (creature_ptr->pseikaku == PERSONALITY_LAZY)
2387 if (creature_ptr->pseikaku == PERSONALITY_SHREWD)
2389 if ((creature_ptr->pseikaku == PERSONALITY_PATIENT) || (creature_ptr->pseikaku == PERSONALITY_MIGHTY))
2391 if (creature_ptr->pseikaku == PERSONALITY_CHARGEMAN)
2394 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2396 BIT_FLAGS flgs[TR_FLAG_SIZE];
2397 o_ptr = &creature_ptr->inventory_list[i];
2400 object_flags(creature_ptr, o_ptr, flgs);
2401 if (any_bits(o_ptr->curse_flags, TRC_LOW_MAGIC)) {
2402 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2412 static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
2414 ARMOUR_CLASS ac = 0;
2415 if (creature_ptr->yoiyami)
2418 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2420 o_ptr = &creature_ptr->inventory_list[i];
2426 if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_MAIN_HAND])
2427 || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND])) {
2428 ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2434 static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
2436 ARMOUR_CLASS ac = 0;
2437 BIT_FLAGS flags[TR_FLAG_SIZE];
2438 if (creature_ptr->yoiyami)
2441 ac += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2443 if (creature_ptr->mimic_form) {
2444 switch (creature_ptr->mimic_form) {
2448 case MIMIC_DEMON_LORD:
2456 if (creature_ptr->pclass == CLASS_BERSERKER) {
2457 ac += 10 + creature_ptr->lev / 2;
2459 if (creature_ptr->pclass == CLASS_SORCERER) {
2463 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2465 o_ptr = &creature_ptr->inventory_list[i];
2466 object_flags(creature_ptr, o_ptr, flags);
2469 if (is_real_value || object_is_known(o_ptr))
2472 if (any_bits(o_ptr->curse_flags, TRC_LOW_AC)) {
2473 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
2474 if (is_real_value || object_is_fully_known(o_ptr))
2477 if (is_real_value || object_is_fully_known(o_ptr))
2482 if ((i == INVEN_SUB_HAND) && has_flag(flags, TR_SUPPORTIVE)) {
2487 if (is_specific_player_race(creature_ptr, RACE_GOLEM) || is_specific_player_race(creature_ptr, RACE_ANDROID)) {
2488 ac += 10 + (creature_ptr->lev * 2 / 5);
2491 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
2495 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
2496 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
2500 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
2504 if (any_bits(creature_ptr->muta3, MUT3_WART_SKIN)) {
2508 if (any_bits(creature_ptr->muta3, MUT3_SCALES)) {
2512 if (any_bits(creature_ptr->muta3, MUT3_IRON_SKIN)) {
2516 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr)) {
2517 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx)) {
2518 ac += (creature_ptr->lev * 3) / 2;
2520 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15)) {
2521 ac += ((creature_ptr->lev - 13) / 3);
2523 if (!(creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) && (creature_ptr->lev > 10)) {
2524 ac += ((creature_ptr->lev - 8) / 3);
2526 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4)) {
2527 ac += (creature_ptr->lev - 2) / 3;
2529 if (!(creature_ptr->inventory_list[INVEN_ARMS].k_idx)) {
2530 ac += (creature_ptr->lev / 2);
2532 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx)) {
2533 ac += (creature_ptr->lev / 3);
2537 if (creature_ptr->realm1 == REALM_HEX) {
2538 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) {
2542 for (int i = INVEN_MAIN_HAND; i <= INVEN_FEET; i++) {
2543 object_type *o_ptr = &creature_ptr->inventory_list[i];
2546 if (!object_is_armour(creature_ptr, o_ptr))
2548 if (!object_is_cursed(o_ptr))
2550 if (any_bits(o_ptr->curse_flags, TRC_CURSED))
2552 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE))
2554 if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE))
2559 if (any_bits(creature_ptr->special_defense, KAMAE_GENBU)) {
2560 ac += (creature_ptr->lev * creature_ptr->lev) / 50;
2561 } else if (any_bits(creature_ptr->special_defense, KAMAE_BYAKKO)) {
2563 } else if (any_bits(creature_ptr->special_defense, KAMAE_SEIRYU)) {
2565 } else if (any_bits(creature_ptr->special_defense, KATA_KOUKIJIN)) {
2569 if (creature_ptr->ult_res || (any_bits(creature_ptr->special_defense, KATA_MUSOU))) {
2571 } else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef) {
2575 if (is_blessed(creature_ptr)) {
2579 if (is_shero(creature_ptr)) {
2583 if (creature_ptr->pclass == CLASS_NINJA) {
2584 if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
2585 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
2586 ac += creature_ptr->lev / 2 + 5;
2595 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2598 * ** クラッコンと妖精に加算(+レベル/10)
2599 * ** 悪魔変化/吸血鬼変化で加算(+3)
2601 * ** マーフォークがFF_WATER地形にいれば加算(+2+レベル/10)
2602 * ** そうでなく浮遊を持っていないなら減算(-2)
2604 static SPEED calc_player_speed_by_race(player_type *creature_ptr)
2608 if (is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE))
2609 result += (creature_ptr->lev) / 10;
2611 if (is_specific_player_race(creature_ptr, RACE_MERFOLK)) {
2612 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
2613 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
2614 if (has_flag(f_ptr->flags, FF_WATER)) {
2615 result += (2 + creature_ptr->lev / 10);
2616 } else if (!creature_ptr->levitation) {
2621 if (creature_ptr->mimic_form) {
2622 switch (creature_ptr->mimic_form) {
2626 case MIMIC_DEMON_LORD:
2637 static SPEED calc_speed_by_secial_weapon_set(player_type *creature_ptr)
2640 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
2641 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN)) {
2645 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE)) {
2654 * @brief 速度計算 - ACTION
2655 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2658 * ** 装備品にTR_SPEEDがあれば加算(+pval+1
2659 * ** 棘セット装備中ならば加算(+7)
2660 * ** アイシングデス-トゥインクル装備中ならば加算(+7)
2662 static SPEED calc_player_speed_by_equipment(player_type *creature_ptr)
2665 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
2666 object_type *o_ptr = &creature_ptr->inventory_list[i];
2667 BIT_FLAGS flgs[TR_FLAG_SIZE];
2668 object_flags(creature_ptr, o_ptr, flgs);
2672 if (has_flag(flgs, TR_SPEED))
2673 result += o_ptr->pval;
2675 result += calc_speed_by_secial_weapon_set(creature_ptr);
2681 * @brief 速度計算 - ACTION
2682 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2685 * ** 忍者の装備が重ければ減算(-レベル/10)
2686 * ** 忍者の装備が適正ならば加算(+3)さらにクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2687 * ** 錬気術師で装備が重くなくクラッコン、妖精、いかさま以外なら加算(+レベル/10)
2688 * ** 狂戦士なら加算(+3),レベル20/30/40/50ごとに+1
2690 static SPEED calc_player_speed_by_class(player_type *creature_ptr)
2694 if (creature_ptr->pclass == CLASS_NINJA) {
2695 if (heavy_armor(creature_ptr)) {
2696 result -= (creature_ptr->lev) / 10;
2697 } else if ((!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx || can_attack_with_main_hand(creature_ptr))
2698 && (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx || can_attack_with_sub_hand(creature_ptr))) {
2700 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2701 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2702 result += (creature_ptr->lev) / 10;
2706 if ((creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) && !(heavy_armor(creature_ptr))) {
2707 if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
2708 || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
2709 result += (creature_ptr->lev) / 10;
2712 if (creature_ptr->pclass == CLASS_BERSERKER) {
2714 if (creature_ptr->lev > 29)
2716 if (creature_ptr->lev > 39)
2718 if (creature_ptr->lev > 44)
2720 if (creature_ptr->lev > 49)
2728 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2734 static SPEED calc_player_speed_by_battleform(player_type *creature_ptr)
2737 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU))
2744 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2748 * ** 変異MUT3_XTRA_FATなら減算(-2)
2749 * ** 変異MUT3_XTRA_LEGなら加算(+3)
2750 * ** 変異MUT3_SHORT_LEGなら減算(-3)
2752 static SPEED calc_player_speed_by_mutation(player_type *creature_ptr)
2755 if (creature_ptr->muta3) {
2756 if (any_bits(creature_ptr->muta3, MUT3_XTRA_FAT)) {
2760 if (any_bits(creature_ptr->muta3, MUT3_XTRA_LEGS)) {
2764 if (any_bits(creature_ptr->muta3, MUT3_SHORT_LEG)) {
2772 * @brief 速度計算 - 一時的効果
2773 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2778 * ** 呪術「衝撃のクローク」で加算(+3)
2780 * ** 光速移動中は+999(最終的に+99になる)
2782 static SPEED calc_player_speed_by_time_effect(player_type *creature_ptr)
2786 if (is_fast(creature_ptr)) {
2790 if (creature_ptr->slow) {
2794 if (creature_ptr->realm1 == REALM_HEX) {
2795 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) {
2800 if (creature_ptr->food >= PY_FOOD_MAX)
2803 /* Temporary lightspeed forces to be maximum speed */
2804 if (creature_ptr->lightspeed)
2812 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2815 * ** いかさまでクラッコン/妖精以外なら加算(+5+レベル/10)
2817 static SPEED calc_player_speed_by_personality(player_type *creature_ptr)
2820 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN && creature_ptr->prace != RACE_KLACKON && creature_ptr->prace != RACE_SPRITE) {
2821 result += (creature_ptr->lev) / 10 + 5;
2828 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2831 * * 所持品の重量による減速処理。乗馬時は別計算。
2833 static SPEED calc_player_speed_by_inventory_weight(player_type *creature_ptr)
2837 int weight = calc_inventory_weight(creature_ptr);
2840 if (creature_ptr->riding) {
2841 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2842 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2843 count = 1500 + riding_r_ptr->level * 25;
2845 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) {
2846 weight += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2849 if (weight > count) {
2850 result -= ((weight - count) / (count / 5));
2853 count = (int)calc_weight_limit(creature_ptr);
2854 if (weight > count) {
2855 result -= ((weight - count) / (count / 5));
2864 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2867 * * 騎乗中ならばモンスターの加速に準拠、ただし騎乗技能値とモンスターレベルによるキャップ処理あり
2869 static SPEED calc_player_speed_by_riding(player_type *creature_ptr)
2871 monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
2872 SPEED speed = riding_m_ptr->mspeed;
2875 if (creature_ptr->riding) {
2879 if (riding_m_ptr->mspeed > 110) {
2880 result = (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2884 result = speed - 110;
2887 result += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2889 if (monster_fast_remaining(riding_m_ptr))
2891 if (monster_slow_remaining(riding_m_ptr))
2898 * @brief 速度計算 - ACTION
2899 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2904 static SPEED calc_player_speed_by_action(player_type *creature_ptr)
2907 if (creature_ptr->action == ACTION_SEARCH)
2912 BIT_FLAGS player_flags_speed(player_type *creature_ptr)
2914 BIT_FLAGS result = check_equipment_flags(creature_ptr, TR_SPEED);
2916 if (calc_speed_by_secial_weapon_set(creature_ptr) != 0)
2917 set_bits(result, FLAG_CAUSE_INVEN_MAIN_HAND | FLAG_CAUSE_INVEN_SUB_HAND);
2919 if (calc_player_speed_by_class(creature_ptr) != 0)
2920 set_bits(result, FLAG_CAUSE_CLASS);
2922 if (calc_player_speed_by_race(creature_ptr) != 0)
2923 set_bits(result, FLAG_CAUSE_RACE);
2925 if (calc_player_speed_by_battleform(creature_ptr) != 0)
2926 set_bits(result, FLAG_CAUSE_BATTLE_FORM);
2928 if (calc_player_speed_by_mutation(creature_ptr) != 0)
2929 set_bits(result, FLAG_CAUSE_MUTATION);
2931 if (calc_player_speed_by_time_effect(creature_ptr) != 0)
2932 set_bits(result, FLAG_CAUSE_MAGIC_TIME_EFFECT);
2934 if (calc_player_speed_by_personality(creature_ptr) != 0)
2935 set_bits(result, FLAG_CAUSE_PERSONALITY);
2937 if (calc_player_speed_by_riding(creature_ptr) != 0)
2938 set_bits(result, FLAG_CAUSE_RIDING);
2940 if (calc_player_speed_by_inventory_weight(creature_ptr) != 0)
2941 set_bits(result, FLAG_CAUSE_INVEN_PACK);
2943 if (calc_player_speed_by_action(creature_ptr) != 0)
2944 set_bits(result, FLAG_CAUSE_ACTION);
2951 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2953 * @details 上限99、下限-99
2955 static SPEED calc_speed(player_type *creature_ptr)
2959 if (creature_ptr->riding) {
2960 pow += calc_player_speed_by_riding(creature_ptr);
2961 pow += calc_player_speed_by_inventory_weight(creature_ptr);
2963 pow += calc_player_speed_by_race(creature_ptr);
2964 pow += calc_player_speed_by_equipment(creature_ptr);
2965 pow += calc_player_speed_by_class(creature_ptr);
2966 pow += calc_player_speed_by_personality(creature_ptr);
2967 pow += calc_player_speed_by_time_effect(creature_ptr);
2968 pow += calc_player_speed_by_battleform(creature_ptr);
2969 pow += calc_player_speed_by_mutation(creature_ptr);
2970 pow += calc_player_speed_by_inventory_weight(creature_ptr);
2972 pow += calc_player_speed_by_action(creature_ptr);
2974 /* Maximum speed is (+99). (internally it's 110 + 99) */
2979 /* Minimum speed is (-99). (internally it's 110 - 99) */
2987 * @brief 二刀流ペナルティ量計算
2988 * @param creature_ptr 計算するクリーチャーの参照ポインタ
2989 * @param slot ペナルティ量を計算する武器スロット
2995 * * マンゴーシュ/脇差を左に装備した場合の軽減
2999 s16b calc_double_weapon_penalty(player_type *creature_ptr, INVENTORY_IDX slot)
3002 BIT_FLAGS flags[TR_FLAG_SIZE];
3004 if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
3005 object_flags(creature_ptr, &creature_ptr->inventory_list[INVEN_SUB_HAND], flags);
3007 penalty = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[slot].weight) / 8);
3008 if (((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TINYTHORN))
3009 || ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_ICINGDEATH)
3010 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_TWINKLE))) {
3011 penalty = penalty / 2 - 5;
3013 if (creature_ptr->easy_2weapon) {
3016 } else if (has_flag(flags, TR_SUPPORTIVE)) {
3017 penalty = MAX(0, penalty - 10);
3019 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA)
3020 && (creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI)) {
3021 penalty = MIN(0, penalty);
3023 if ((creature_ptr->inventory_list[INVEN_MAIN_HAND].name1 == ART_MUSASI_KATANA) && (penalty > 0))
3025 if ((creature_ptr->inventory_list[INVEN_SUB_HAND].name1 == ART_MUSASI_WAKIZASI) && (penalty > 0))
3029 if (creature_ptr->inventory_list[slot].tval == TV_POLEARM)
3032 return (s16b)penalty;
3035 static void update_ind_status(player_type *creature_ptr, int status)
3038 if (creature_ptr->stat_use[status] <= 18)
3039 ind = (creature_ptr->stat_use[status] - 3);
3040 else if (creature_ptr->stat_use[status] <= 18 + 219)
3041 ind = (15 + (creature_ptr->stat_use[status] - 18) / 10);
3045 if (creature_ptr->stat_ind[status] == ind)
3048 creature_ptr->stat_ind[status] = (s16b)ind;
3049 if (status == A_CON) {
3050 set_bits(creature_ptr->update, PU_HP);
3051 } else if (status == A_INT) {
3052 if (mp_ptr->spell_stat == A_INT) {
3053 set_bits(creature_ptr->update, (PU_MANA | PU_SPELLS));
3055 } else if (status == A_WIS) {
3056 if (mp_ptr->spell_stat == A_WIS) {
3057 set_bits(creature_ptr->update, (PU_MANA | PU_SPELLS));
3059 } else if (status == A_CHR) {
3060 if (mp_ptr->spell_stat == A_CHR) {
3061 set_bits(creature_ptr->update, (PU_MANA | PU_SPELLS));
3065 set_bits(creature_ptr->window_flags, PW_PLAYER);
3068 static void update_use_status(player_type *creature_ptr, int status)
3070 int use = modify_stat_value(creature_ptr->stat_cur[status], creature_ptr->stat_add[status]);
3072 if ((status == A_CHR) && (any_bits(creature_ptr->muta3, MUT3_ILL_NORM))) {
3073 /* 10 to 18/90 charisma, guaranteed, based on level */
3074 if (use < 8 + 2 * creature_ptr->lev) {
3075 use = 8 + 2 * creature_ptr->lev;
3079 if (creature_ptr->stat_use[status] != use) {
3080 creature_ptr->stat_use[status] = (s16b)use;
3081 set_bits(creature_ptr->redraw, PR_STATS);
3082 set_bits(creature_ptr->window_flags, PW_PLAYER);
3086 static void update_top_status(player_type *creature_ptr, int status)
3088 int top = modify_stat_value(creature_ptr->stat_max[status], creature_ptr->stat_add[status]);
3090 if (creature_ptr->stat_top[status] != top) {
3091 creature_ptr->stat_top[status] = (s16b)top;
3092 set_bits(creature_ptr->redraw, PR_STATS);
3093 set_bits(creature_ptr->window_flags, PW_PLAYER);
3097 static bool is_riding_two_hands(player_type *creature_ptr)
3099 if (!creature_ptr->riding) {
3103 if (has_two_handed_weapons(creature_ptr) || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE))
3105 else if (any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
3106 switch (creature_ptr->pclass) {
3108 case CLASS_FORCETRAINER:
3109 case CLASS_BERSERKER:
3110 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_MAIN_HAND)
3111 && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND))
3119 static s16b calc_riding_bow_penalty(player_type *creature_ptr)
3121 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3122 if (!creature_ptr->riding)
3127 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
3128 if (creature_ptr->tval_ammo != TV_ARROW)
3131 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3137 if (creature_ptr->tval_ammo == TV_BOLT)
3143 void put_equipment_warning(player_type *creature_ptr)
3145 bool heavy_shoot = is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW]);
3146 if (creature_ptr->old_heavy_shoot != heavy_shoot) {
3148 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
3149 } else if (creature_ptr->inventory_list[INVEN_BOW].k_idx) {
3150 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
3152 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
3154 creature_ptr->old_heavy_shoot = heavy_shoot;
3157 for (int i = 0; i < 2; i++) {
3158 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i]) {
3159 if (creature_ptr->heavy_wield[i]) {
3160 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
3161 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
3162 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
3163 } else if (creature_ptr->heavy_wield[1 - i]) {
3164 msg_print(_("まだ武器が重い。", "You still have trouble wielding a heavy weapon."));
3166 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
3169 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
3172 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i]) {
3173 if (creature_ptr->riding_wield[i]) {
3174 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
3175 } else if (!creature_ptr->riding) {
3176 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
3177 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
3178 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
3181 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
3184 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
3187 if (creature_ptr->icky_wield[i]) {
3188 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
3189 if (current_world_ptr->is_loading_now) {
3190 chg_virtue(creature_ptr, V_FAITH, -1);
3192 } else if (has_melee_weapon(creature_ptr, INVEN_MAIN_HAND + i)) {
3193 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
3195 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
3198 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
3201 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute)) {
3202 if (creature_ptr->riding_ryoute) {
3204 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
3206 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
3210 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
3212 msg_print("You began to control the pet you're riding with one hand.");
3216 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
3219 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA))
3220 && (heavy_armor(creature_ptr) != creature_ptr->monk_notify_aux)) {
3221 if (heavy_armor(creature_ptr)) {
3222 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
3223 if (current_world_ptr->is_loading_now) {
3224 chg_virtue(creature_ptr, V_HARMONY, -1);
3227 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
3230 creature_ptr->monk_notify_aux = heavy_armor(creature_ptr);
3234 static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
3236 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3237 BIT_FLAGS flgs[TR_FLAG_SIZE];
3238 object_flags(creature_ptr, o_ptr, flgs);
3240 player_hand calc_hand = PLAYER_HAND_OTHER;
3241 if (slot == INVEN_MAIN_HAND)
3242 calc_hand = PLAYER_HAND_MAIN;
3243 if (slot == INVEN_SUB_HAND)
3244 calc_hand = PLAYER_HAND_SUB;
3247 damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3249 if (is_shero(creature_ptr)) {
3250 damage += 3 + (creature_ptr->lev / 5);
3253 if (creature_ptr->stun > 50) {
3255 } else if (creature_ptr->stun) {
3259 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3261 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3262 damage += creature_ptr->lev / 6;
3263 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3264 damage += creature_ptr->lev / 6;
3266 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3267 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3272 } else if (creature_ptr->pclass == CLASS_FORCETRAINER) {
3273 // 練気術師は格闘ダメージに (気)/5 の修正を得る。
3274 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
3275 damage += get_current_ki(creature_ptr) / 5;
3279 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3280 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
3281 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
3284 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
3287 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
3293 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3295 o_ptr = &creature_ptr->inventory_list[i];
3296 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
3297 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3300 if (!object_is_known(o_ptr) && !is_real_value)
3302 bonus_to_d = o_ptr->to_d;
3304 if (creature_ptr->pclass == CLASS_NINJA) {
3305 if (o_ptr->to_d > 0)
3306 bonus_to_d = (o_ptr->to_d + 1) / 2;
3309 switch (player_melee_type(creature_ptr)) {
3310 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
3311 case MELEE_TYPE_WEAPON_TWOHAND:
3312 if (calc_hand == main_attack_hand(creature_ptr))
3313 damage += (s16b)bonus_to_d;
3316 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
3317 case MELEE_TYPE_WEAPON_MAIN:
3318 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
3319 damage += (s16b)bonus_to_d;
3322 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
3323 case MELEE_TYPE_WEAPON_SUB:
3324 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
3325 damage += (s16b)bonus_to_d;
3328 case MELEE_TYPE_WEAPON_DOUBLE:
3329 if (calc_hand == PLAYER_HAND_MAIN) {
3330 if (i == INVEN_MAIN_RING) {
3331 damage += (s16b)bonus_to_d;
3332 } else if (i != INVEN_SUB_RING) {
3333 damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
3336 if (calc_hand == PLAYER_HAND_SUB) {
3337 if (i == INVEN_SUB_RING) {
3338 damage += (s16b)bonus_to_d;
3339 } else if (i != INVEN_MAIN_RING) {
3340 damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
3345 case MELEE_TYPE_SHIELD_DOUBLE:
3353 if (main_attack_hand(creature_ptr) == calc_hand) {
3354 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
3355 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
3357 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
3358 damage += MAX(bonus_to_d, 1);
3362 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3363 damage += (creature_ptr->lev / 6);
3366 // 朱雀の構えをとっているとき、格闘ダメージに -(レベル)/6 の修正を得る。
3367 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
3368 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
3369 damage -= (creature_ptr->lev / 6);
3377 * @brief 武器の命中修正を計算する。 / Calculate hit bonus from a wielded weapon.
3379 * 'slot' MUST be INVEN_MAIN_HAND or INVEM_SUB_HAND.
3381 static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_real_value)
3386 hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3387 hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3389 /* Temporary bonuses */
3390 if (is_blessed(creature_ptr)) {
3394 if (is_hero(creature_ptr)) {
3398 if (is_shero(creature_ptr)) {
3402 if (creature_ptr->stun > 50) {
3404 } else if (creature_ptr->stun) {
3408 player_hand calc_hand = PLAYER_HAND_OTHER;
3409 if (slot == INVEN_MAIN_HAND)
3410 calc_hand = PLAYER_HAND_MAIN;
3411 if (slot == INVEN_SUB_HAND)
3412 calc_hand = PLAYER_HAND_SUB;
3414 /* Default hand bonuses */
3415 if (main_attack_hand(creature_ptr) == calc_hand) {
3416 switch (player_melee_type(creature_ptr)) {
3417 case MELEE_TYPE_BAREHAND_MAIN:
3418 if (creature_ptr->riding)
3421 case MELEE_TYPE_BAREHAND_SUB:
3422 if (creature_ptr->riding)
3425 case MELEE_TYPE_BAREHAND_TWO:
3426 hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
3429 if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_MAIN | EMPTY_HAND_SUB))
3430 || !has_disable_two_handed_bonus(creature_ptr, calc_hand)) {
3432 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);
3433 hit += MAX(bonus_to_h, 1);
3437 /* Bonuses and penalties by weapon */
3438 if (has_melee_weapon(creature_ptr, slot)) {
3439 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3440 BIT_FLAGS flgs[TR_FLAG_SIZE];
3441 object_flags(creature_ptr, o_ptr, flgs);
3443 int tval = o_ptr->tval - TV_WEAPON_BEGIN;
3444 OBJECT_SUBTYPE_VALUE sval = o_ptr->sval;
3446 /* Traind bonuses */
3447 hit += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3449 /* Weight penalty */
3450 if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
3451 hit += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3454 /* Low melee penalty */
3455 if ((object_is_fully_known(o_ptr) || is_real_value) && any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
3456 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
3463 /* Riding bonus and penalty */
3464 if (creature_ptr->riding) {
3465 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3470 if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
3471 && !has_flag(flgs, TR_RIDING)) {
3473 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
3476 penalty = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3481 hit -= (s16b)penalty;
3484 /* Class penalties */
3485 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(has_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
3487 } else if (creature_ptr->pclass == CLASS_BERSERKER) {
3488 hit += creature_ptr->lev / 5;
3489 if (((calc_hand == PLAYER_HAND_MAIN) && !can_attack_with_sub_hand(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
3490 hit += creature_ptr->lev / 5;
3492 } else if (creature_ptr->pclass == CLASS_SORCERER) {
3493 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
3500 if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
3504 /* Hex realm bonuses */
3505 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
3506 if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
3509 if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
3512 if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
3515 if (any_bits(o_ptr->curse_flags, (TRC_TY_CURSE))) {
3521 /* Bonuses from inventory */
3522 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3523 object_type *o_ptr = &creature_ptr->inventory_list[i];
3525 /* Ignore empty hands, handed weapons, bows and capture balls */
3526 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
3527 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3530 /* Fake value does not include unknown objects' value */
3531 if (!object_is_known(o_ptr) && !is_real_value)
3534 int bonus_to_h = o_ptr->to_h;
3536 /* When wields only a weapon */
3537 if (creature_ptr->pclass == CLASS_NINJA) {
3538 if (o_ptr->to_h > 0)
3539 bonus_to_h = (o_ptr->to_h + 1) / 2;
3542 switch (player_melee_type(creature_ptr)) {
3543 case MELEE_TYPE_BAREHAND_TWO: /* fall through */
3544 case MELEE_TYPE_WEAPON_TWOHAND:
3545 if (calc_hand == main_attack_hand(creature_ptr))
3546 hit += (s16b)bonus_to_h;
3549 case MELEE_TYPE_BAREHAND_MAIN: /* fall through */
3550 case MELEE_TYPE_WEAPON_MAIN:
3551 if ((calc_hand == PLAYER_HAND_MAIN) && (i != INVEN_SUB_RING))
3552 hit += (s16b)bonus_to_h;
3555 case MELEE_TYPE_BAREHAND_SUB: /* fall through */
3556 case MELEE_TYPE_WEAPON_SUB:
3557 if ((calc_hand == PLAYER_HAND_SUB) && (i != INVEN_MAIN_RING))
3558 hit += (s16b)bonus_to_h;
3561 case MELEE_TYPE_WEAPON_DOUBLE:
3562 if (calc_hand == PLAYER_HAND_MAIN) {
3563 if (i == INVEN_MAIN_RING) {
3564 hit += (s16b)bonus_to_h;
3565 } else if (i != INVEN_SUB_RING) {
3566 hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
3569 if (calc_hand == PLAYER_HAND_SUB) {
3570 if (i == INVEN_SUB_RING) {
3571 hit += (s16b)bonus_to_h;
3572 } else if (i != INVEN_MAIN_RING) {
3573 hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
3578 case MELEE_TYPE_SHIELD_DOUBLE:
3586 /* Martial arts bonus */
3587 if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
3588 hit += (creature_ptr->lev / 3);
3591 /* Two handed combat penalty */
3592 hit -= calc_double_weapon_penalty(creature_ptr, slot);
3594 // 朱雀の構えをとっているとき、格闘命中に -(レベル)/3 の修正を得る。
3595 if (any_bits(creature_ptr->special_defense, KAMAE_SUZAKU)) {
3596 if (is_martial_arts_mode(creature_ptr) && calc_hand == PLAYER_HAND_MAIN) {
3597 hit -= (creature_ptr->lev / 3);
3604 static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
3608 pow += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3609 pow += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3613 BIT_FLAGS flgs[TR_FLAG_SIZE];
3614 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3616 object_flags(creature_ptr, o_ptr, flgs);
3618 if (any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
3619 if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
3628 if (creature_ptr->stun > 50) {
3630 } else if (creature_ptr->stun) {
3634 if (is_blessed(creature_ptr)) {
3638 if (is_hero(creature_ptr)) {
3642 if (is_shero(creature_ptr)) {
3646 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
3648 if (is_heavy_shoot(creature_ptr, o_ptr)) {
3649 pow += 2 * (calc_weapon_weight_limit(creature_ptr) - o_ptr->weight / 10);
3653 if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, &creature_ptr->inventory_list[INVEN_BOW])) {
3654 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->tval_ammo == TV_BOLT)) {
3655 pow += (10 + (creature_ptr->lev / 5));
3661 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3663 o_ptr = &creature_ptr->inventory_list[i];
3664 if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_MAIN_HAND && has_melee_weapon(creature_ptr, i))
3665 || (i == INVEN_SUB_HAND && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
3668 bonus_to_h = o_ptr->to_h;
3670 if (creature_ptr->pclass == CLASS_NINJA) {
3671 if (o_ptr->to_h > 0)
3672 bonus_to_h = (o_ptr->to_h + 1) / 2;
3675 if (is_real_value || object_is_known(o_ptr))
3676 pow += (s16b)bonus_to_h;
3679 pow -= calc_riding_bow_penalty(creature_ptr);
3684 static s16b calc_to_damage_misc(player_type *creature_ptr)
3687 BIT_FLAGS flgs[TR_FLAG_SIZE];
3691 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3692 o_ptr = &creature_ptr->inventory_list[i];
3696 object_flags(creature_ptr, o_ptr, flgs);
3698 int bonus_to_d = o_ptr->to_d;
3699 if (creature_ptr->pclass == CLASS_NINJA) {
3700 if (o_ptr->to_d > 0)
3701 bonus_to_d = (o_ptr->to_d + 1) / 2;
3703 to_dam += (s16b)bonus_to_d;
3706 if (is_shero(creature_ptr)) {
3707 to_dam += 3 + (creature_ptr->lev / 5);
3710 if (creature_ptr->stun > 50) {
3712 } else if (creature_ptr->stun) {
3716 to_dam += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
3720 static s16b calc_to_hit_misc(player_type *creature_ptr)
3723 BIT_FLAGS flgs[TR_FLAG_SIZE];
3727 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
3728 o_ptr = &creature_ptr->inventory_list[i];
3732 object_flags(creature_ptr, o_ptr, flgs);
3734 int bonus_to_h = o_ptr->to_h;
3735 if (creature_ptr->pclass == CLASS_NINJA) {
3736 if (o_ptr->to_h > 0)
3737 bonus_to_h = (o_ptr->to_h + 1) / 2;
3739 to_hit += (s16b)bonus_to_h;
3742 if (is_blessed(creature_ptr)) {
3746 if (is_hero(creature_ptr)) {
3750 if (is_shero(creature_ptr)) {
3754 if (creature_ptr->stun > 50) {
3756 } else if (creature_ptr->stun) {
3760 to_hit += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3761 to_hit += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
3766 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot)
3768 object_type *o_ptr = &creature_ptr->inventory_list[slot];
3771 if (creature_ptr->riding) {
3772 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
3780 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot)
3782 (void)creature_ptr; // unused
3783 (void)slot; // unused
3788 * @brief プレイヤーの所持重量制限を計算する /
3789 * Computes current weight limit.
3792 WEIGHT calc_weight_limit(player_type *creature_ptr)
3794 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
3795 if (creature_ptr->pclass == CLASS_BERSERKER)
3801 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3802 * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND)
3803 * @return 持っているならばTRUE
3805 bool has_melee_weapon(player_type *creature_ptr, int slot)
3807 return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot]));
3811 * @brief プレイヤーの現在開いている手の状態を返す
3812 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3813 * @return 開いている手のビットフラグ
3815 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
3817 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3818 if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx)
3819 status |= EMPTY_HAND_MAIN;
3820 if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx)
3821 status |= EMPTY_HAND_SUB;
3823 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) {
3824 if (any_bits(status, EMPTY_HAND_SUB))
3825 reset_bits(status, EMPTY_HAND_SUB);
3826 else if (any_bits(status, EMPTY_HAND_MAIN))
3827 reset_bits(status, EMPTY_HAND_MAIN);
3834 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3835 * @return ペナルティが適用されるならばTRUE。
3837 bool heavy_armor(player_type *creature_ptr)
3839 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
3842 WEIGHT monk_arm_wgt = 0;
3843 if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD)
3844 monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight;
3845 if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD)
3846 monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight;
3847 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
3848 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
3849 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
3850 monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight;
3851 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
3853 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
3857 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
3859 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3861 void update_creature(player_type *creature_ptr)
3863 if (!creature_ptr->update)
3866 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3867 if (any_bits(creature_ptr->update, (PU_AUTODESTROY))) {
3868 reset_bits(creature_ptr->update, PU_AUTODESTROY);
3869 autopick_delayed_alter(creature_ptr);
3872 if (any_bits(creature_ptr->update, (PU_COMBINE))) {
3873 reset_bits(creature_ptr->update, PU_COMBINE);
3874 combine_pack(creature_ptr);
3877 if (any_bits(creature_ptr->update, (PU_REORDER))) {
3878 reset_bits(creature_ptr->update, PU_REORDER);
3879 reorder_pack(creature_ptr);
3882 if (any_bits(creature_ptr->update, (PU_BONUS))) {
3883 reset_bits(creature_ptr->update, PU_BONUS);
3884 update_alignment(creature_ptr);
3885 update_bonuses(creature_ptr);
3888 if (any_bits(creature_ptr->update, (PU_TORCH))) {
3889 reset_bits(creature_ptr->update, PU_TORCH);
3890 update_lite_radius(creature_ptr);
3893 if (any_bits(creature_ptr->update, (PU_HP))) {
3894 reset_bits(creature_ptr->update, PU_HP);
3895 update_max_hitpoints(creature_ptr);
3898 if (any_bits(creature_ptr->update, (PU_MANA))) {
3899 reset_bits(creature_ptr->update, PU_MANA);
3900 update_max_mana(creature_ptr);
3903 if (any_bits(creature_ptr->update, (PU_SPELLS))) {
3904 reset_bits(creature_ptr->update, PU_SPELLS);
3905 update_num_of_spells(creature_ptr);
3908 if (!current_world_ptr->character_generated)
3910 if (current_world_ptr->character_icky_depth > 0)
3912 if (any_bits(creature_ptr->update, (PU_UN_LITE))) {
3913 reset_bits(creature_ptr->update, PU_UN_LITE);
3914 forget_lite(floor_ptr);
3917 if (any_bits(creature_ptr->update, (PU_UN_VIEW))) {
3918 reset_bits(creature_ptr->update, PU_UN_VIEW);
3919 forget_view(floor_ptr);
3922 if (any_bits(creature_ptr->update, (PU_VIEW))) {
3923 reset_bits(creature_ptr->update, PU_VIEW);
3924 update_view(creature_ptr);
3927 if (any_bits(creature_ptr->update, (PU_LITE))) {
3928 reset_bits(creature_ptr->update, PU_LITE);
3929 update_lite(creature_ptr);
3932 if (any_bits(creature_ptr->update, (PU_FLOW))) {
3933 reset_bits(creature_ptr->update, PU_FLOW);
3934 update_flow(creature_ptr);
3937 if (any_bits(creature_ptr->update, (PU_DISTANCE))) {
3938 reset_bits(creature_ptr->update, PU_DISTANCE);
3940 update_monsters(creature_ptr, TRUE);
3943 if (any_bits(creature_ptr->update, (PU_MON_LITE))) {
3944 reset_bits(creature_ptr->update, PU_MON_LITE);
3945 update_mon_lite(creature_ptr);
3948 if (any_bits(creature_ptr->update, (PU_DELAY_VIS))) {
3949 reset_bits(creature_ptr->update, PU_DELAY_VIS);
3950 delayed_visual_update(creature_ptr);
3953 if (any_bits(creature_ptr->update, (PU_MONSTERS))) {
3954 reset_bits(creature_ptr->update, PU_MONSTERS);
3955 update_monsters(creature_ptr, FALSE);
3960 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
3961 * @return 魔道書を一冊も持っていないならTRUEを返す
3963 bool player_has_no_spellbooks(player_type *creature_ptr)
3966 for (int i = 0; i < INVEN_PACK; i++) {
3967 o_ptr = &creature_ptr->inventory_list[i];
3968 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3972 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3973 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx) {
3974 o_ptr = &floor_ptr->o_list[i];
3975 if (o_ptr->k_idx && any_bits(o_ptr->marked, OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval))
3982 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost) { creature_ptr->energy_use = (ENERGY)need_cost; }
3984 void free_turn(player_type *creature_ptr) { creature_ptr->energy_use = 0; }
3987 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
3990 * @return 配置に成功したらTRUE
3992 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
3994 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0)
3997 /* Save player location */
3998 creature_ptr->y = y;
3999 creature_ptr->x = x;
4004 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
4007 void wreck_the_pattern(player_type *creature_ptr)
4009 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4010 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
4011 if (pattern_type == PATTERN_TILE_WRECKED)
4014 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
4015 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
4017 if (!is_invuln(creature_ptr))
4018 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
4020 int to_ruin = randint1(45) + 35;
4023 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, PROJECT_NONE);
4025 if (pattern_tile(floor_ptr, r_y, r_x) && (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
4026 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
4030 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
4034 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
4035 * Advance experience levels and print experience
4038 void check_experience(player_type *creature_ptr)
4040 if (creature_ptr->exp < 0)
4041 creature_ptr->exp = 0;
4042 if (creature_ptr->max_exp < 0)
4043 creature_ptr->max_exp = 0;
4044 if (creature_ptr->max_max_exp < 0)
4045 creature_ptr->max_max_exp = 0;
4047 if (creature_ptr->exp > PY_MAX_EXP)
4048 creature_ptr->exp = PY_MAX_EXP;
4049 if (creature_ptr->max_exp > PY_MAX_EXP)
4050 creature_ptr->max_exp = PY_MAX_EXP;
4051 if (creature_ptr->max_max_exp > PY_MAX_EXP)
4052 creature_ptr->max_max_exp = PY_MAX_EXP;
4054 if (creature_ptr->exp > creature_ptr->max_exp)
4055 creature_ptr->max_exp = creature_ptr->exp;
4056 if (creature_ptr->max_exp > creature_ptr->max_max_exp)
4057 creature_ptr->max_max_exp = creature_ptr->max_exp;
4059 set_bits(creature_ptr->redraw, PR_EXP);
4060 handle_stuff(creature_ptr);
4062 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
4063 PLAYER_LEVEL old_lev = creature_ptr->lev;
4064 while ((creature_ptr->lev > 1) && (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) {
4065 creature_ptr->lev--;
4066 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4067 set_bits(creature_ptr->redraw, PR_LEV | PR_TITLE);
4068 set_bits(creature_ptr->window_flags, PW_PLAYER);
4069 handle_stuff(creature_ptr);
4072 bool level_reward = FALSE;
4073 bool level_mutation = FALSE;
4074 bool level_inc_stat = FALSE;
4075 while ((creature_ptr->lev < PY_MAX_LEVEL)
4076 && (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) {
4077 creature_ptr->lev++;
4078 if (creature_ptr->lev > creature_ptr->max_plv) {
4079 creature_ptr->max_plv = creature_ptr->lev;
4081 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || any_bits(creature_ptr->muta2, MUT2_CHAOS_GIFT)) {
4082 level_reward = TRUE;
4084 if (creature_ptr->prace == RACE_BEASTMAN) {
4086 level_mutation = TRUE;
4088 level_inc_stat = TRUE;
4090 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
4094 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
4095 set_bits(creature_ptr->update, (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS));
4096 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE | PR_EXP));
4097 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL | PW_INVEN));
4098 creature_ptr->level_up_message = TRUE;
4099 handle_stuff(creature_ptr);
4101 creature_ptr->level_up_message = FALSE;
4102 if (level_inc_stat) {
4103 if (!(creature_ptr->max_plv % 10)) {
4110 cnv_stat(creature_ptr->stat_max[0], tmp);
4111 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
4112 cnv_stat(creature_ptr->stat_max[1], tmp);
4113 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
4114 cnv_stat(creature_ptr->stat_max[2], tmp);
4115 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
4116 cnv_stat(creature_ptr->stat_max[3], tmp);
4117 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
4118 cnv_stat(creature_ptr->stat_max[4], tmp);
4119 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
4120 cnv_stat(creature_ptr->stat_max[5], tmp);
4121 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
4124 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
4128 if ((choice >= 'a') && (choice <= 'f'))
4131 for (n = 0; n < A_MAX; n++)
4132 if (n != choice - 'a')
4134 if (get_check(_("よろしいですか?", "Are you sure? ")))
4137 do_inc_stat(creature_ptr, choice - 'a');
4139 } else if (!(creature_ptr->max_plv % 2))
4140 do_inc_stat(creature_ptr, randint0(6));
4143 if (level_mutation) {
4144 msg_print(_("あなたは変わった気がする...", "You feel different..."));
4145 (void)gain_mutation(creature_ptr, 0);
4146 level_mutation = FALSE;
4150 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
4154 gain_level_reward(creature_ptr, 0);
4155 level_reward = FALSE;
4158 set_bits(creature_ptr->update, PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4159 set_bits(creature_ptr->redraw, (PR_LEV | PR_TITLE));
4160 set_bits(creature_ptr->window_flags, (PW_PLAYER | PW_SPELL));
4161 handle_stuff(creature_ptr);
4164 if (old_lev != creature_ptr->lev)
4165 autopick_load_pref(creature_ptr, FALSE);
4169 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
4171 * @param out_val 出力先文字列ポインタ
4174 void cnv_stat(int val, char *out_val)
4177 sprintf(out_val, " %2d", val);
4181 int bonus = (val - 18);
4183 sprintf(out_val, "18/%3s", "***");
4184 } else if (bonus >= 100) {
4185 sprintf(out_val, "18/%03d", bonus);
4187 sprintf(out_val, " 18/%02d", bonus);
4192 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
4193 * Modify a stat value by a "modifier", return new value
4195 * @param amount 加減算値
4199 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
4200 * Or even: 18/13, 18/23, 18/33, ..., 18/220
4201 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
4202 * Or even: 18/13, 18/03, 18, 17, ..., 3
4205 s16b modify_stat_value(int value, int amount)
4208 for (int i = 0; i < amount; i++) {
4214 } else if (amount < 0) {
4215 for (int i = 0; i < (0 - amount); i++) {
4216 if (value >= 18 + 10)
4218 else if (value > 18)
4230 * Hack -- Calculates the total number of points earned -JWT-
4234 long calc_score(player_type *creature_ptr)
4236 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
4249 if (ironman_small_levels)
4251 if (ironman_empty_levels)
4257 if (ironman_nightmare)
4264 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
4265 if (max_dlv[i] > max_dl)
4266 max_dl = max_dlv[i];
4268 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
4269 u32b point_h = point_l / 0x10000L;
4270 point_l = point_l % 0x10000L;
4273 point_h += point_l / 0x10000L;
4274 point_l %= 0x10000L;
4276 point_l += ((point_h % 100) << 16);
4280 u32b point = (point_h << 16) + (point_l);
4281 if (creature_ptr->arena_number >= 0)
4282 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
4284 if (ironman_downward)
4286 if (creature_ptr->pclass == CLASS_BERSERKER) {
4287 if (creature_ptr->prace == RACE_SPECTRE)
4291 if ((creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) && point) {
4293 if (current_world_ptr->total_winner)
4298 point = (0 - point);
4304 * @param creature_ptr プレーヤーへの参照ポインタ
4305 * @return 祝福状態ならばTRUE
4307 bool is_blessed(player_type *creature_ptr)
4309 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
4312 bool is_tim_esp(player_type *creature_ptr)
4314 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
4317 bool is_tim_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
4319 bool is_time_limit_esp(player_type *creature_ptr)
4321 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
4324 bool is_time_limit_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); }
4326 bool can_two_hands_wielding(player_type *creature_ptr) { return !creature_ptr->riding || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS); }
4329 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
4332 void stop_singing(player_type *creature_ptr)
4334 if (creature_ptr->pclass != CLASS_BARD)
4337 /* Are there interupted song? */
4338 if (INTERUPTING_SONG_EFFECT(creature_ptr)) {
4339 /* Forget interupted song */
4340 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
4344 /* The player is singing? */
4345 if (!SINGING_SONG_EFFECT(creature_ptr))
4348 /* Hack -- if called from set_action(), avoid recursive loop */
4349 if (creature_ptr->action == ACTION_SING)
4350 set_action(creature_ptr, ACTION_NONE);
4352 /* Message text of each song or etc. */
4353 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
4355 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
4356 SINGING_SONG_ID(creature_ptr) = 0;
4357 set_bits(creature_ptr->update, PU_BONUS);
4358 set_bits(creature_ptr->redraw, PR_STATUS);
4362 * @brief 口を使う継続的な処理を中断する
4363 * @param caster_ptr プレーヤーへの参照ポインタ
4366 void stop_mouth(player_type *caster_ptr)
4368 if (music_singing_any(caster_ptr))
4369 stop_singing(caster_ptr);
4370 if (hex_spelling_any(caster_ptr))
4371 stop_hex_spell_all(caster_ptr);
4375 * @brief ペットの維持コスト計算
4378 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
4381 bool has_a_unique = FALSE;
4382 DEPTH total_friend_levels = 0;
4386 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--) {
4387 monster_type *m_ptr;
4388 monster_race *r_ptr;
4390 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
4391 if (!monster_is_valid(m_ptr))
4393 r_ptr = &r_info[m_ptr->r_idx];
4395 if (is_pet(m_ptr)) {
4397 if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
4398 if (creature_ptr->pclass == CLASS_CAVALRY) {
4399 if (creature_ptr->riding == m_idx)
4400 total_friend_levels += (r_ptr->level + 5) * 2;
4401 else if (!has_a_unique && any_bits(r_info[m_ptr->r_idx].flags7, RF7_RIDING))
4402 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
4404 total_friend_levels += (r_ptr->level + 5) * 10;
4405 has_a_unique = TRUE;
4407 total_friend_levels += (r_ptr->level + 5) * 10;
4409 total_friend_levels += r_ptr->level;
4413 if (total_friends) {
4415 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
4416 if (upkeep_factor < 0)
4418 if (upkeep_factor > 1000)
4419 upkeep_factor = 1000;
4420 return upkeep_factor;
4425 bool music_singing(player_type *caster_ptr, int music_songs) { return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs); }
4427 bool is_fast(player_type *creature_ptr) { return creature_ptr->fast || music_singing(creature_ptr, MUSIC_SPEED) || music_singing(creature_ptr, MUSIC_SHERO); }
4429 bool is_invuln(player_type *creature_ptr) { return creature_ptr->invuln || music_singing(creature_ptr, MUSIC_INVULN); }
4431 bool is_hero(player_type *creature_ptr) { return creature_ptr->hero || music_singing(creature_ptr, MUSIC_HERO) || music_singing(creature_ptr, MUSIC_SHERO); }
4433 bool is_shero(player_type *creature_ptr) { return creature_ptr->shero || creature_ptr->pclass == CLASS_BERSERKER; }
4435 bool is_echizen(player_type *creature_ptr)
4437 return (creature_ptr->pseikaku == PERSONALITY_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON);
4440 int calc_weapon_weight_limit(player_type *creature_ptr)
4442 int weight = adj_str_hold[creature_ptr->stat_ind[A_STR]];
4444 if (has_two_handed_weapons(creature_ptr))
4450 static player_hand main_attack_hand(player_type *creature_ptr)
4452 switch (player_melee_type(creature_ptr)) {
4453 case MELEE_TYPE_BAREHAND_TWO:
4454 return PLAYER_HAND_MAIN;
4455 case MELEE_TYPE_BAREHAND_MAIN:
4456 return PLAYER_HAND_MAIN;
4457 case MELEE_TYPE_BAREHAND_SUB:
4458 return PLAYER_HAND_SUB;
4459 case MELEE_TYPE_WEAPON_MAIN:
4460 return PLAYER_HAND_MAIN;
4461 case MELEE_TYPE_WEAPON_SUB:
4462 return PLAYER_HAND_SUB;
4463 case MELEE_TYPE_WEAPON_TWOHAND:
4464 return has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) ? PLAYER_HAND_MAIN : PLAYER_HAND_SUB;
4465 case MELEE_TYPE_WEAPON_DOUBLE:
4466 return PLAYER_HAND_MAIN;
4467 case MELEE_TYPE_SHIELD_DOUBLE:
4468 return PLAYER_HAND_MAIN;
4470 return PLAYER_HAND_MAIN;