4 #include "player-move.h"
5 #include "player-status.h"
6 #include "player-effects.h"
7 #include "player-skill.h"
8 #include "player-race.h"
9 #include "player-class.h"
10 #include "player-personality.h"
12 #include "floor-events.h"
17 #include "spells-status.h"
19 #include "object-hook.h"
21 #include "monster-status.h"
22 #include "monsterrace-hook.h"
25 #include "realm-hex.h"
27 #include "cmd-spell.h"
29 #include "objectkind.h"
30 #include "monsterrace.h"
38 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
40 static concptr horror_desc[MAX_SAN_HORROR] =
96 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
98 static concptr funny_desc[MAX_SAN_FUNNY] =
159 * @var funny_comments
160 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
162 static concptr funny_comments[MAX_SAN_COMMENT] =
183 * @brief 基本必要経験値テーブル /
184 * Base experience levels, may be adjusted up for race and/or class
186 const s32b player_exp[PY_MAX_LEVEL] =
242 * @brief 基本必要強化値テーブル(アンドロイド専用)
244 const s32b player_exp_a[PY_MAX_LEVEL] =
300 * Return alignment title
302 concptr your_alignment(void)
304 if (p_ptr->align > 150) return _("大善", "Lawful");
305 else if (p_ptr->align > 50) return _("中善", "Good");
306 else if (p_ptr->align > 10) return _("小善", "Neutral Good");
307 else if (p_ptr->align > -11) return _("中立", "Neutral");
308 else if (p_ptr->align > -51) return _("小悪", "Neutral Evil");
309 else if (p_ptr->align > -151) return _("中悪", "Evil");
310 else return _("大悪", "Chaotic");
315 * Return proficiency level of weapons and misc. skills (except riding)
317 int weapon_exp_level(int weapon_exp)
319 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
320 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
321 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
322 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
323 else return EXP_LEVEL_MASTER;
328 * Return proficiency level of riding
330 int riding_exp_level(int riding_exp)
332 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
333 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
334 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
335 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
336 else return EXP_LEVEL_MASTER;
341 * Return proficiency level of spells
343 int spell_exp_level(int spell_exp)
345 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
346 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
347 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
348 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
349 else return EXP_LEVEL_MASTER;
353 * @brief プレイヤーの全ステータスを更新する /
354 * Calculate the players current "state", taking into account
355 * not only race/class intrinsics, but also objects being worn
356 * and temporary spell effects.
360 * See also calc_mana() and calc_hitpoints().
362 * Take note of the new "speed code", in particular, a very strong
363 * player will start slowing down as soon as he reaches 150 pounds,
364 * but not until he reaches 450 pounds will he be half as fast as
365 * a normal kobold. This both hurts and helps the player, hurts
366 * because in the old days a player could just avoid 300 pounds,
367 * and helps because now carrying 300 pounds is not very painful.
369 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
370 * damage, since that would affect non-combat things. These values
371 * are actually added in later, at the appropriate place.
373 * This function induces various "status" messages.
376 void calc_bonuses(void)
380 int default_hand = 0;
381 int empty_hands_status = empty_hands(TRUE);
384 BIT_FLAGS flgs[TR_FLAG_SIZE];
386 bool yoiyami = FALSE;
387 bool down_saving = FALSE;
390 bool have_dd_s = FALSE, have_dd_t = FALSE;
392 bool have_sw = FALSE, have_kabe = FALSE;
393 bool easy_2weapon = FALSE;
394 bool riding_levitation = FALSE;
395 OBJECT_IDX this_o_idx, next_o_idx = 0;
396 const player_race *tmp_rp_ptr;
398 /* Save the old vision stuff */
399 bool old_telepathy = p_ptr->telepathy;
400 bool old_esp_animal = p_ptr->esp_animal;
401 bool old_esp_undead = p_ptr->esp_undead;
402 bool old_esp_demon = p_ptr->esp_demon;
403 bool old_esp_orc = p_ptr->esp_orc;
404 bool old_esp_troll = p_ptr->esp_troll;
405 bool old_esp_giant = p_ptr->esp_giant;
406 bool old_esp_dragon = p_ptr->esp_dragon;
407 bool old_esp_human = p_ptr->esp_human;
408 bool old_esp_evil = p_ptr->esp_evil;
409 bool old_esp_good = p_ptr->esp_good;
410 bool old_esp_nonliving = p_ptr->esp_nonliving;
411 bool old_esp_unique = p_ptr->esp_unique;
412 bool old_see_inv = p_ptr->see_inv;
413 bool old_mighty_throw = p_ptr->mighty_throw;
415 /* Current feature under player. */
416 feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat];
418 /* Save the old armor class */
419 ARMOUR_CLASS old_dis_ac = p_ptr->dis_ac;
420 ARMOUR_CLASS old_dis_to_a = p_ptr->dis_to_a;
423 /* Clear extra blows/shots */
424 extra_blows[0] = extra_blows[1] = 0;
426 /* Clear the stat modifiers */
427 for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0;
430 /* Clear the Displayed/Real armor class */
431 p_ptr->dis_ac = p_ptr->ac = 0;
433 /* Clear the Displayed/Real Bonuses */
434 p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
435 p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
436 p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
437 p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
438 p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
439 p_ptr->dis_to_a = p_ptr->to_a = 0;
443 p_ptr->to_m_chance = 0;
445 /* Clear the Extra Dice Bonuses */
446 p_ptr->to_dd[0] = p_ptr->to_ds[0] = 0;
447 p_ptr->to_dd[1] = p_ptr->to_ds[1] = 0;
449 /* Start with "normal" speed */
452 /* Start with a single blow per current_world_ptr->game_turn */
453 p_ptr->num_blow[0] = 1;
454 p_ptr->num_blow[1] = 1;
456 /* Start with a single shot per current_world_ptr->game_turn */
457 p_ptr->num_fire = 100;
459 /* Reset the "xtra" tval */
460 p_ptr->tval_xtra = 0;
462 /* Reset the "ammo" tval */
463 p_ptr->tval_ammo = 0;
465 /* Clear all the flags */
467 p_ptr->bless_blade = FALSE;
468 p_ptr->xtra_might = FALSE;
469 p_ptr->impact[0] = FALSE;
470 p_ptr->impact[1] = FALSE;
471 p_ptr->pass_wall = FALSE;
472 p_ptr->kill_wall = FALSE;
473 p_ptr->dec_mana = FALSE;
474 p_ptr->easy_spell = FALSE;
475 p_ptr->heavy_spell = FALSE;
476 p_ptr->see_inv = FALSE;
477 p_ptr->free_act = FALSE;
478 p_ptr->slow_digest = FALSE;
479 p_ptr->regenerate = FALSE;
480 p_ptr->can_swim = FALSE;
481 p_ptr->levitation = FALSE;
482 p_ptr->hold_exp = FALSE;
483 p_ptr->telepathy = FALSE;
484 p_ptr->esp_animal = FALSE;
485 p_ptr->esp_undead = FALSE;
486 p_ptr->esp_demon = FALSE;
487 p_ptr->esp_orc = FALSE;
488 p_ptr->esp_troll = FALSE;
489 p_ptr->esp_giant = FALSE;
490 p_ptr->esp_dragon = FALSE;
491 p_ptr->esp_human = FALSE;
492 p_ptr->esp_evil = FALSE;
493 p_ptr->esp_good = FALSE;
494 p_ptr->esp_nonliving = FALSE;
495 p_ptr->esp_unique = FALSE;
497 p_ptr->sustain_str = FALSE;
498 p_ptr->sustain_int = FALSE;
499 p_ptr->sustain_wis = FALSE;
500 p_ptr->sustain_con = FALSE;
501 p_ptr->sustain_dex = FALSE;
502 p_ptr->sustain_chr = FALSE;
503 p_ptr->resist_acid = FALSE;
504 p_ptr->resist_elec = FALSE;
505 p_ptr->resist_fire = FALSE;
506 p_ptr->resist_cold = FALSE;
507 p_ptr->resist_pois = FALSE;
508 p_ptr->resist_conf = FALSE;
509 p_ptr->resist_sound = FALSE;
510 p_ptr->resist_lite = FALSE;
511 p_ptr->resist_dark = FALSE;
512 p_ptr->resist_chaos = FALSE;
513 p_ptr->resist_disen = FALSE;
514 p_ptr->resist_shard = FALSE;
515 p_ptr->resist_nexus = FALSE;
516 p_ptr->resist_blind = FALSE;
517 p_ptr->resist_neth = FALSE;
518 p_ptr->resist_time = FALSE;
519 p_ptr->resist_water = FALSE;
520 p_ptr->resist_fear = FALSE;
521 p_ptr->reflect = FALSE;
522 p_ptr->sh_fire = FALSE;
523 p_ptr->sh_elec = FALSE;
524 p_ptr->sh_cold = FALSE;
525 p_ptr->anti_magic = FALSE;
526 p_ptr->anti_tele = FALSE;
527 p_ptr->warning = FALSE;
528 p_ptr->mighty_throw = FALSE;
529 p_ptr->see_nocto = FALSE;
531 p_ptr->immune_acid = FALSE;
532 p_ptr->immune_elec = FALSE;
533 p_ptr->immune_fire = FALSE;
534 p_ptr->immune_cold = FALSE;
536 p_ptr->ryoute = FALSE;
537 p_ptr->migite = FALSE;
538 p_ptr->hidarite = FALSE;
539 p_ptr->no_flowed = FALSE;
541 if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
542 else tmp_rp_ptr = &race_info[p_ptr->prace];
544 /* Base infravision (purely racial) */
545 p_ptr->see_infra = tmp_rp_ptr->infra;
547 /* Base skill -- disarming */
548 p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
550 /* Base skill -- magic devices */
551 p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
553 /* Base skill -- saving throw */
554 p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
556 /* Base skill -- stealth */
557 p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
559 /* Base skill -- searching ability */
560 p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
562 /* Base skill -- searching frequency */
563 p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
565 /* Base skill -- combat (normal) */
566 p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
568 /* Base skill -- combat (shooting) */
569 p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
571 /* Base skill -- combat (throwing) */
572 p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
574 /* Base skill -- digging */
575 p_ptr->skill_dig = 0;
577 if (has_melee_weapon(INVEN_RARM)) p_ptr->migite = TRUE;
578 if (has_melee_weapon(INVEN_LARM))
580 p_ptr->hidarite = TRUE;
581 if (!p_ptr->migite) default_hand = 1;
584 if (CAN_TWO_HANDS_WIELDING())
586 if (p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
587 object_allow_two_hands_wielding(&p_ptr->inventory_list[INVEN_RARM]))
589 p_ptr->ryoute = TRUE;
591 else if (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
592 object_allow_two_hands_wielding(&p_ptr->inventory_list[INVEN_LARM]))
594 p_ptr->ryoute = TRUE;
598 switch (p_ptr->pclass)
601 case CLASS_FORCETRAINER:
602 case CLASS_BERSERKER:
603 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
605 p_ptr->migite = TRUE;
606 p_ptr->ryoute = TRUE;
613 if (!p_ptr->migite && !p_ptr->hidarite)
615 if (empty_hands_status & EMPTY_HAND_RARM) p_ptr->migite = TRUE;
616 else if (empty_hands_status == EMPTY_HAND_LARM)
618 p_ptr->hidarite = TRUE;
623 if (p_ptr->special_defense & KAMAE_MASK)
625 if (!(empty_hands_status & EMPTY_HAND_RARM))
627 set_action(ACTION_NONE);
631 switch (p_ptr->pclass)
634 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
635 if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
638 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
640 case CLASS_CHAOS_WARRIOR:
641 if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
642 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
644 case CLASS_MINDCRAFTER:
645 if (p_ptr->lev > 9) p_ptr->resist_fear = TRUE;
646 if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
647 if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
648 if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
651 case CLASS_FORCETRAINER:
652 /* Unencumbered Monks become faster every 10 levels */
653 if (!(heavy_armor()))
655 if (!(prace_is_(RACE_KLACKON) ||
656 prace_is_(RACE_SPRITE) ||
657 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
658 new_speed += (p_ptr->lev) / 10;
660 /* Free action if unencumbered at level 25 */
662 p_ptr->free_act = TRUE;
667 p_ptr->dis_to_a -= 50;
670 p_ptr->resist_sound = TRUE;
673 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
675 case CLASS_BERSERKER:
677 p_ptr->sustain_str = TRUE;
678 p_ptr->sustain_dex = TRUE;
679 p_ptr->sustain_con = TRUE;
680 p_ptr->regenerate = TRUE;
681 p_ptr->free_act = TRUE;
683 if (p_ptr->lev > 29) new_speed++;
684 if (p_ptr->lev > 39) new_speed++;
685 if (p_ptr->lev > 44) new_speed++;
686 if (p_ptr->lev > 49) new_speed++;
687 p_ptr->to_a += 10 + p_ptr->lev / 2;
688 p_ptr->dis_to_a += 10 + p_ptr->lev / 2;
689 p_ptr->skill_dig += (100 + p_ptr->lev * 8);
690 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
691 p_ptr->redraw |= PR_STATUS;
693 case CLASS_MIRROR_MASTER:
694 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
697 /* Unencumbered Ninjas become faster every 10 levels */
700 new_speed -= (p_ptr->lev) / 10;
701 p_ptr->skill_stl -= (p_ptr->lev) / 10;
703 else if ((!p_ptr->inventory_list[INVEN_RARM].k_idx || p_ptr->migite) &&
704 (!p_ptr->inventory_list[INVEN_LARM].k_idx || p_ptr->hidarite))
707 if (!(prace_is_(RACE_KLACKON) ||
708 prace_is_(RACE_SPRITE) ||
709 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
710 new_speed += (p_ptr->lev) / 10;
711 p_ptr->skill_stl += (p_ptr->lev) / 10;
713 /* Free action if unencumbered at level 25 */
715 p_ptr->free_act = TRUE;
717 if ((!p_ptr->inventory_list[INVEN_RARM].k_idx || p_ptr->migite) &&
718 (!p_ptr->inventory_list[INVEN_LARM].k_idx || p_ptr->hidarite))
720 p_ptr->to_a += p_ptr->lev / 2 + 5;
721 p_ptr->dis_to_a += p_ptr->lev / 2 + 5;
723 p_ptr->slow_digest = TRUE;
724 p_ptr->resist_fear = TRUE;
725 if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
726 if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
727 if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
730 p_ptr->oppose_pois = 1;
731 p_ptr->redraw |= PR_STATUS;
733 p_ptr->see_nocto = TRUE;
738 if (p_ptr->mimic_form)
740 switch (p_ptr->mimic_form)
743 p_ptr->hold_exp = TRUE;
744 p_ptr->resist_chaos = TRUE;
745 p_ptr->resist_neth = TRUE;
746 p_ptr->resist_fire = TRUE;
747 p_ptr->oppose_fire = 1;
748 p_ptr->see_inv = TRUE;
750 p_ptr->redraw |= PR_STATUS;
752 p_ptr->dis_to_a += 10;
754 case MIMIC_DEMON_LORD:
755 p_ptr->hold_exp = TRUE;
756 p_ptr->resist_chaos = TRUE;
757 p_ptr->resist_neth = TRUE;
758 p_ptr->immune_fire = TRUE;
759 p_ptr->resist_acid = TRUE;
760 p_ptr->resist_fire = TRUE;
761 p_ptr->resist_cold = TRUE;
762 p_ptr->resist_elec = TRUE;
763 p_ptr->resist_pois = TRUE;
764 p_ptr->resist_conf = TRUE;
765 p_ptr->resist_disen = TRUE;
766 p_ptr->resist_nexus = TRUE;
767 p_ptr->resist_fear = TRUE;
768 p_ptr->sh_fire = TRUE;
769 p_ptr->see_inv = TRUE;
770 p_ptr->telepathy = TRUE;
771 p_ptr->levitation = TRUE;
772 p_ptr->kill_wall = TRUE;
775 p_ptr->dis_to_a += 20;
778 p_ptr->resist_dark = TRUE;
779 p_ptr->hold_exp = TRUE;
780 p_ptr->resist_neth = TRUE;
781 p_ptr->resist_cold = TRUE;
782 p_ptr->resist_pois = TRUE;
783 p_ptr->see_inv = TRUE;
786 p_ptr->dis_to_a += 10;
787 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
793 switch (p_ptr->prace)
796 p_ptr->resist_lite = TRUE;
799 p_ptr->hold_exp = TRUE;
802 p_ptr->free_act = TRUE;
805 p_ptr->resist_blind = TRUE;
808 p_ptr->resist_dark = TRUE;
810 case RACE_HALF_TROLL:
811 p_ptr->sustain_str = TRUE;
815 /* High level trolls heal fast... */
816 p_ptr->regenerate = TRUE;
818 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
820 p_ptr->slow_digest = TRUE;
821 /* Let's not make Regeneration
822 * a disadvantage for the poor warriors who can
823 * never learn a spell that satisfies hunger (actually
824 * neither can rogues, but half-trolls are not
825 * supposed to play rogues) */
830 p_ptr->sustain_con = TRUE;
831 p_ptr->regenerate = TRUE; /* Amberites heal fast... */
834 p_ptr->resist_lite = TRUE;
835 p_ptr->see_inv = TRUE;
838 p_ptr->resist_fear = TRUE;
841 p_ptr->resist_dark = TRUE;
842 p_ptr->sustain_str = TRUE;
844 case RACE_HALF_GIANT:
845 p_ptr->sustain_str = TRUE;
846 p_ptr->resist_shard = TRUE;
848 case RACE_HALF_TITAN:
849 p_ptr->resist_chaos = TRUE;
852 p_ptr->resist_sound = TRUE;
855 p_ptr->resist_acid = TRUE;
856 if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
859 p_ptr->resist_conf = TRUE;
860 p_ptr->resist_acid = TRUE;
862 /* Klackons become faster */
863 new_speed += (p_ptr->lev) / 10;
866 p_ptr->resist_pois = TRUE;
869 p_ptr->resist_disen = TRUE;
870 p_ptr->resist_dark = TRUE;
873 p_ptr->resist_dark = TRUE;
874 if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
877 p_ptr->levitation = TRUE;
878 if (p_ptr->lev > 4) p_ptr->resist_fire = TRUE;
879 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
880 if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
881 if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
882 if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
884 case RACE_MIND_FLAYER:
885 p_ptr->sustain_int = TRUE;
886 p_ptr->sustain_wis = TRUE;
887 if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
888 if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
891 p_ptr->resist_fire = TRUE;
892 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
895 p_ptr->slow_digest = TRUE;
896 p_ptr->free_act = TRUE;
897 p_ptr->see_inv = TRUE;
898 p_ptr->resist_pois = TRUE;
899 if (p_ptr->lev > 34) p_ptr->hold_exp = TRUE;
902 p_ptr->resist_shard = TRUE;
903 p_ptr->hold_exp = TRUE;
904 p_ptr->see_inv = TRUE;
905 p_ptr->resist_pois = TRUE;
906 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
909 p_ptr->resist_neth = TRUE;
910 p_ptr->hold_exp = TRUE;
911 p_ptr->see_inv = TRUE;
912 p_ptr->resist_pois = TRUE;
913 p_ptr->slow_digest = TRUE;
914 if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
917 p_ptr->resist_dark = TRUE;
918 p_ptr->hold_exp = TRUE;
919 p_ptr->resist_neth = TRUE;
920 p_ptr->resist_cold = TRUE;
921 p_ptr->resist_pois = TRUE;
922 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
925 p_ptr->levitation = TRUE;
926 p_ptr->free_act = TRUE;
927 p_ptr->resist_neth = TRUE;
928 p_ptr->hold_exp = TRUE;
929 p_ptr->see_inv = TRUE;
930 p_ptr->resist_pois = TRUE;
931 p_ptr->slow_digest = TRUE;
932 p_ptr->resist_cold = TRUE;
933 p_ptr->pass_wall = TRUE;
934 if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
937 p_ptr->levitation = TRUE;
938 p_ptr->resist_lite = TRUE;
940 /* Sprites become faster */
941 new_speed += (p_ptr->lev) / 10;
944 p_ptr->resist_conf = TRUE;
945 p_ptr->resist_sound = TRUE;
948 /* Ents dig like maniacs, but only with their hands. */
949 if (!p_ptr->inventory_list[INVEN_RARM].k_idx)
950 p_ptr->skill_dig += p_ptr->lev * 10;
951 /* Ents get tougher and stronger as they age, but lose dexterity. */
952 if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
953 if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
954 if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
956 if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
957 if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
958 if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
960 if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
961 if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
962 if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
965 p_ptr->levitation = TRUE;
966 p_ptr->see_inv = TRUE;
969 p_ptr->resist_fire = TRUE;
970 p_ptr->resist_neth = TRUE;
971 p_ptr->hold_exp = TRUE;
972 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
975 p_ptr->oppose_fire = 1;
976 p_ptr->redraw |= PR_STATUS;
980 p_ptr->sustain_con = TRUE;
983 p_ptr->levitation = TRUE;
986 p_ptr->resist_conf = TRUE;
989 p_ptr->slow_digest = TRUE;
990 p_ptr->free_act = TRUE;
991 p_ptr->resist_pois = TRUE;
992 p_ptr->hold_exp = TRUE;
995 p_ptr->resist_water = TRUE;
1003 if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
1005 p_ptr->see_inv = TRUE;
1006 p_ptr->free_act = TRUE;
1007 p_ptr->slow_digest = TRUE;
1008 p_ptr->regenerate = TRUE;
1009 p_ptr->levitation = TRUE;
1010 p_ptr->hold_exp = TRUE;
1011 p_ptr->telepathy = TRUE;
1013 p_ptr->sustain_str = TRUE;
1014 p_ptr->sustain_int = TRUE;
1015 p_ptr->sustain_wis = TRUE;
1016 p_ptr->sustain_con = TRUE;
1017 p_ptr->sustain_dex = TRUE;
1018 p_ptr->sustain_chr = TRUE;
1019 p_ptr->resist_acid = TRUE;
1020 p_ptr->resist_elec = TRUE;
1021 p_ptr->resist_fire = TRUE;
1022 p_ptr->resist_cold = TRUE;
1023 p_ptr->resist_pois = TRUE;
1024 p_ptr->resist_conf = TRUE;
1025 p_ptr->resist_sound = TRUE;
1026 p_ptr->resist_lite = TRUE;
1027 p_ptr->resist_dark = TRUE;
1028 p_ptr->resist_chaos = TRUE;
1029 p_ptr->resist_disen = TRUE;
1030 p_ptr->resist_shard = TRUE;
1031 p_ptr->resist_nexus = TRUE;
1032 p_ptr->resist_blind = TRUE;
1033 p_ptr->resist_neth = TRUE;
1034 p_ptr->resist_fear = TRUE;
1035 p_ptr->reflect = TRUE;
1036 p_ptr->sh_fire = TRUE;
1037 p_ptr->sh_elec = TRUE;
1038 p_ptr->sh_cold = TRUE;
1040 p_ptr->dis_to_a += 100;
1042 /* Temporary shield */
1043 else if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
1046 p_ptr->dis_to_a += 50;
1049 if (p_ptr->tim_res_nether)
1051 p_ptr->resist_neth = TRUE;
1053 if (p_ptr->tim_sh_fire)
1055 p_ptr->sh_fire = TRUE;
1057 if (p_ptr->tim_res_time)
1059 p_ptr->resist_time = TRUE;
1063 if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
1065 if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
1066 if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
1067 if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
1069 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
1071 p_ptr->to_m_chance += 5;
1072 p_ptr->resist_conf = TRUE;
1076 if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
1078 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
1080 p_ptr->resist_blind = TRUE;
1081 p_ptr->resist_conf = TRUE;
1082 p_ptr->hold_exp = TRUE;
1083 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
1085 if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
1086 /* Munchkin become faster */
1087 new_speed += (p_ptr->lev) / 10 + 5;
1090 if (music_singing(MUSIC_WALL))
1092 p_ptr->kill_wall = TRUE;
1095 /* Hack -- apply racial/class stat maxes */
1096 /* Apply the racial modifiers */
1097 for (i = 0; i < A_MAX; i++)
1099 /* Modify the stats for "race" */
1100 p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
1104 /* I'm adding the mutations here for the lack of a better place... */
1107 /* Hyper Strength */
1108 if (p_ptr->muta3 & MUT3_HYPER_STR)
1110 p_ptr->stat_add[A_STR] += 4;
1114 if (p_ptr->muta3 & MUT3_PUNY)
1116 p_ptr->stat_add[A_STR] -= 4;
1119 /* Living computer */
1120 if (p_ptr->muta3 & MUT3_HYPER_INT)
1122 p_ptr->stat_add[A_INT] += 4;
1123 p_ptr->stat_add[A_WIS] += 4;
1127 if (p_ptr->muta3 & MUT3_MORONIC)
1129 p_ptr->stat_add[A_INT] -= 4;
1130 p_ptr->stat_add[A_WIS] -= 4;
1133 if (p_ptr->muta3 & MUT3_RESILIENT)
1135 p_ptr->stat_add[A_CON] += 4;
1138 if (p_ptr->muta3 & MUT3_XTRA_FAT)
1140 p_ptr->stat_add[A_CON] += 2;
1144 if (p_ptr->muta3 & MUT3_ALBINO)
1146 p_ptr->stat_add[A_CON] -= 4;
1149 if (p_ptr->muta3 & MUT3_FLESH_ROT)
1151 p_ptr->stat_add[A_CON] -= 2;
1152 p_ptr->stat_add[A_CHR] -= 1;
1153 p_ptr->regenerate = FALSE;
1154 /* Cancel innate regeneration */
1157 if (p_ptr->muta3 & MUT3_SILLY_VOI)
1159 p_ptr->stat_add[A_CHR] -= 4;
1162 if (p_ptr->muta3 & MUT3_BLANK_FAC)
1164 p_ptr->stat_add[A_CHR] -= 1;
1167 if (p_ptr->muta3 & MUT3_XTRA_EYES)
1169 p_ptr->skill_fos += 15;
1170 p_ptr->skill_srh += 15;
1173 if (p_ptr->muta3 & MUT3_MAGIC_RES)
1175 p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
1178 if (p_ptr->muta3 & MUT3_XTRA_NOIS)
1180 p_ptr->skill_stl -= 3;
1183 if (p_ptr->muta3 & MUT3_INFRAVIS)
1185 p_ptr->see_infra += 3;
1188 if (p_ptr->muta3 & MUT3_XTRA_LEGS)
1193 if (p_ptr->muta3 & MUT3_SHORT_LEG)
1198 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
1200 p_ptr->sh_elec = TRUE;
1203 if (p_ptr->muta3 & MUT3_FIRE_BODY)
1205 p_ptr->sh_fire = TRUE;
1209 if (p_ptr->muta3 & MUT3_WART_SKIN)
1211 p_ptr->stat_add[A_CHR] -= 2;
1213 p_ptr->dis_to_a += 5;
1216 if (p_ptr->muta3 & MUT3_SCALES)
1218 p_ptr->stat_add[A_CHR] -= 1;
1220 p_ptr->dis_to_a += 10;
1223 if (p_ptr->muta3 & MUT3_IRON_SKIN)
1225 p_ptr->stat_add[A_DEX] -= 1;
1227 p_ptr->dis_to_a += 25;
1230 if (p_ptr->muta3 & MUT3_WINGS)
1232 p_ptr->levitation = TRUE;
1235 if (p_ptr->muta3 & MUT3_FEARLESS)
1237 p_ptr->resist_fear = TRUE;
1240 if (p_ptr->muta3 & MUT3_REGEN)
1242 p_ptr->regenerate = TRUE;
1245 if (p_ptr->muta3 & MUT3_ESP)
1247 p_ptr->telepathy = TRUE;
1250 if (p_ptr->muta3 & MUT3_LIMBER)
1252 p_ptr->stat_add[A_DEX] += 3;
1255 if (p_ptr->muta3 & MUT3_ARTHRITIS)
1257 p_ptr->stat_add[A_DEX] -= 3;
1260 if (p_ptr->muta3 & MUT3_MOTION)
1262 p_ptr->free_act = TRUE;
1263 p_ptr->skill_stl += 1;
1266 if (p_ptr->muta3 & MUT3_ILL_NORM)
1268 p_ptr->stat_add[A_CHR] = 0;
1272 if (p_ptr->tsuyoshi)
1274 p_ptr->stat_add[A_STR] += 4;
1275 p_ptr->stat_add[A_CON] += 4;
1278 /* Scan the usable p_ptr->inventory_list */
1279 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1281 int bonus_to_h, bonus_to_d;
1282 o_ptr = &p_ptr->inventory_list[i];
1283 if (!o_ptr->k_idx) continue;
1285 object_flags(o_ptr, flgs);
1287 p_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
1288 if (o_ptr->name1 == ART_CHAINSWORD) p_ptr->cursed |= TRC_CHAINSWORD;
1291 if (have_flag(flgs, TR_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
1292 if (have_flag(flgs, TR_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
1293 if (have_flag(flgs, TR_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
1294 if (have_flag(flgs, TR_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
1295 if (have_flag(flgs, TR_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
1296 if (have_flag(flgs, TR_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
1298 if (have_flag(flgs, TR_MAGIC_MASTERY)) p_ptr->skill_dev += 8 * o_ptr->pval;
1300 /* Affect stealth */
1301 if (have_flag(flgs, TR_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
1303 /* Affect searching ability (factor of five) */
1304 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
1306 /* Affect searching frequency (factor of five) */
1307 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
1309 /* Affect infravision */
1310 if (have_flag(flgs, TR_INFRA)) p_ptr->see_infra += o_ptr->pval;
1312 /* Affect digging (factor of 20) */
1313 if (have_flag(flgs, TR_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
1316 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
1319 if (have_flag(flgs, TR_BLOWS))
1321 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
1322 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
1323 else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
1326 /* Hack -- cause earthquakes */
1327 if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
1330 if (have_flag(flgs, TR_AGGRAVATE)) p_ptr->cursed |= TRC_AGGRAVATE;
1331 if (have_flag(flgs, TR_DRAIN_EXP)) p_ptr->cursed |= TRC_DRAIN_EXP;
1332 if (have_flag(flgs, TR_TY_CURSE)) p_ptr->cursed |= TRC_TY_CURSE;
1333 if (have_flag(flgs, TR_ADD_L_CURSE)) p_ptr->cursed |= TRC_ADD_L_CURSE;
1334 if (have_flag(flgs, TR_ADD_H_CURSE)) p_ptr->cursed |= TRC_ADD_H_CURSE;
1335 if (have_flag(flgs, TR_DRAIN_HP)) p_ptr->cursed |= TRC_DRAIN_HP;
1336 if (have_flag(flgs, TR_DRAIN_MANA)) p_ptr->cursed |= TRC_DRAIN_MANA;
1337 if (have_flag(flgs, TR_CALL_ANIMAL)) p_ptr->cursed |= TRC_CALL_ANIMAL;
1338 if (have_flag(flgs, TR_CALL_DEMON)) p_ptr->cursed |= TRC_CALL_DEMON;
1339 if (have_flag(flgs, TR_CALL_DRAGON)) p_ptr->cursed |= TRC_CALL_DRAGON;
1340 if (have_flag(flgs, TR_CALL_UNDEAD)) p_ptr->cursed |= TRC_CALL_UNDEAD;
1341 if (have_flag(flgs, TR_COWARDICE)) p_ptr->cursed |= TRC_COWARDICE;
1342 if (have_flag(flgs, TR_LOW_MELEE)) p_ptr->cursed |= TRC_LOW_MELEE;
1343 if (have_flag(flgs, TR_LOW_AC)) p_ptr->cursed |= TRC_LOW_AC;
1344 if (have_flag(flgs, TR_LOW_MAGIC)) p_ptr->cursed |= TRC_LOW_MAGIC;
1345 if (have_flag(flgs, TR_FAST_DIGEST)) p_ptr->cursed |= TRC_FAST_DIGEST;
1346 if (have_flag(flgs, TR_SLOW_REGEN)) p_ptr->cursed |= TRC_SLOW_REGEN;
1347 if (have_flag(flgs, TR_DEC_MANA)) p_ptr->dec_mana = TRUE;
1348 if (have_flag(flgs, TR_BLESSED)) p_ptr->bless_blade = TRUE;
1349 if (have_flag(flgs, TR_XTRA_MIGHT)) p_ptr->xtra_might = TRUE;
1350 if (have_flag(flgs, TR_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
1351 if (have_flag(flgs, TR_REGEN)) p_ptr->regenerate = TRUE;
1352 if (have_flag(flgs, TR_TELEPATHY)) p_ptr->telepathy = TRUE;
1353 if (have_flag(flgs, TR_ESP_ANIMAL)) p_ptr->esp_animal = TRUE;
1354 if (have_flag(flgs, TR_ESP_UNDEAD)) p_ptr->esp_undead = TRUE;
1355 if (have_flag(flgs, TR_ESP_DEMON)) p_ptr->esp_demon = TRUE;
1356 if (have_flag(flgs, TR_ESP_ORC)) p_ptr->esp_orc = TRUE;
1357 if (have_flag(flgs, TR_ESP_TROLL)) p_ptr->esp_troll = TRUE;
1358 if (have_flag(flgs, TR_ESP_GIANT)) p_ptr->esp_giant = TRUE;
1359 if (have_flag(flgs, TR_ESP_DRAGON)) p_ptr->esp_dragon = TRUE;
1360 if (have_flag(flgs, TR_ESP_HUMAN)) p_ptr->esp_human = TRUE;
1361 if (have_flag(flgs, TR_ESP_EVIL)) p_ptr->esp_evil = TRUE;
1362 if (have_flag(flgs, TR_ESP_GOOD)) p_ptr->esp_good = TRUE;
1363 if (have_flag(flgs, TR_ESP_NONLIVING)) p_ptr->esp_nonliving = TRUE;
1364 if (have_flag(flgs, TR_ESP_UNIQUE)) p_ptr->esp_unique = TRUE;
1366 if (have_flag(flgs, TR_SEE_INVIS)) p_ptr->see_inv = TRUE;
1367 if (have_flag(flgs, TR_LEVITATION)) p_ptr->levitation = TRUE;
1368 if (have_flag(flgs, TR_FREE_ACT)) p_ptr->free_act = TRUE;
1369 if (have_flag(flgs, TR_HOLD_EXP)) p_ptr->hold_exp = TRUE;
1370 if (have_flag(flgs, TR_WARNING)) {
1371 if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription), '$')))
1372 p_ptr->warning = TRUE;
1375 if (have_flag(flgs, TR_TELEPORT))
1377 if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
1380 concptr insc = quark_str(o_ptr->inscription);
1382 if (o_ptr->inscription && my_strchr(insc, '.'))
1385 * {.} will stop random teleportation.
1390 /* Controlled random teleportation */
1391 p_ptr->cursed |= TRC_TELEPORT_SELF;
1396 /* Immunity flags */
1397 if (have_flag(flgs, TR_IM_FIRE)) p_ptr->immune_fire = TRUE;
1398 if (have_flag(flgs, TR_IM_ACID)) p_ptr->immune_acid = TRUE;
1399 if (have_flag(flgs, TR_IM_COLD)) p_ptr->immune_cold = TRUE;
1400 if (have_flag(flgs, TR_IM_ELEC)) p_ptr->immune_elec = TRUE;
1402 /* Resistance flags */
1403 if (have_flag(flgs, TR_RES_ACID)) p_ptr->resist_acid = TRUE;
1404 if (have_flag(flgs, TR_RES_ELEC)) p_ptr->resist_elec = TRUE;
1405 if (have_flag(flgs, TR_RES_FIRE)) p_ptr->resist_fire = TRUE;
1406 if (have_flag(flgs, TR_RES_COLD)) p_ptr->resist_cold = TRUE;
1407 if (have_flag(flgs, TR_RES_POIS)) p_ptr->resist_pois = TRUE;
1408 if (have_flag(flgs, TR_RES_FEAR)) p_ptr->resist_fear = TRUE;
1409 if (have_flag(flgs, TR_RES_CONF)) p_ptr->resist_conf = TRUE;
1410 if (have_flag(flgs, TR_RES_SOUND)) p_ptr->resist_sound = TRUE;
1411 if (have_flag(flgs, TR_RES_LITE)) p_ptr->resist_lite = TRUE;
1412 if (have_flag(flgs, TR_RES_DARK)) p_ptr->resist_dark = TRUE;
1413 if (have_flag(flgs, TR_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
1414 if (have_flag(flgs, TR_RES_DISEN)) p_ptr->resist_disen = TRUE;
1415 if (have_flag(flgs, TR_RES_SHARDS)) p_ptr->resist_shard = TRUE;
1416 if (have_flag(flgs, TR_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
1417 if (have_flag(flgs, TR_RES_BLIND)) p_ptr->resist_blind = TRUE;
1418 if (have_flag(flgs, TR_RES_NETHER)) p_ptr->resist_neth = TRUE;
1420 if (have_flag(flgs, TR_REFLECT)) p_ptr->reflect = TRUE;
1421 if (have_flag(flgs, TR_SH_FIRE)) p_ptr->sh_fire = TRUE;
1422 if (have_flag(flgs, TR_SH_ELEC)) p_ptr->sh_elec = TRUE;
1423 if (have_flag(flgs, TR_SH_COLD)) p_ptr->sh_cold = TRUE;
1424 if (have_flag(flgs, TR_NO_MAGIC)) p_ptr->anti_magic = TRUE;
1425 if (have_flag(flgs, TR_NO_TELE)) p_ptr->anti_tele = TRUE;
1428 if (have_flag(flgs, TR_SUST_STR)) p_ptr->sustain_str = TRUE;
1429 if (have_flag(flgs, TR_SUST_INT)) p_ptr->sustain_int = TRUE;
1430 if (have_flag(flgs, TR_SUST_WIS)) p_ptr->sustain_wis = TRUE;
1431 if (have_flag(flgs, TR_SUST_DEX)) p_ptr->sustain_dex = TRUE;
1432 if (have_flag(flgs, TR_SUST_CON)) p_ptr->sustain_con = TRUE;
1433 if (have_flag(flgs, TR_SUST_CHR)) p_ptr->sustain_chr = TRUE;
1435 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
1436 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
1437 if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
1438 if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
1439 if (have_flag(flgs, TR_EASY_SPELL)) p_ptr->easy_spell = TRUE;
1440 if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
1441 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
1443 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
1445 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1447 p_ptr->to_m_chance += 10;
1451 p_ptr->to_m_chance += 3;
1455 if (o_ptr->tval == TV_CAPTURE) continue;
1457 /* Modify the base armor class */
1458 p_ptr->ac += o_ptr->ac;
1460 /* The base armor class is always known */
1461 p_ptr->dis_ac += o_ptr->ac;
1463 /* Apply the bonuses to armor class */
1464 p_ptr->to_a += o_ptr->to_a;
1466 /* Apply the mental bonuses to armor class, if known */
1467 if (object_is_known(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
1469 if (o_ptr->curse_flags & TRC_LOW_MELEE)
1471 int slot = i - INVEN_RARM;
1474 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1476 p_ptr->to_h[slot] -= 15;
1477 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 15;
1481 p_ptr->to_h[slot] -= 5;
1482 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 5;
1487 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1489 p_ptr->to_h_b -= 15;
1490 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 15;
1495 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 5;
1500 if (o_ptr->curse_flags & TRC_LOW_AC)
1502 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1505 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 30;
1510 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 10;
1514 /* Hack -- do not apply "weapon" bonuses */
1515 if (i == INVEN_RARM && has_melee_weapon(i)) continue;
1516 if (i == INVEN_LARM && has_melee_weapon(i)) continue;
1518 /* Hack -- do not apply "bow" bonuses */
1519 if (i == INVEN_BOW) continue;
1521 bonus_to_h = o_ptr->to_h;
1522 bonus_to_d = o_ptr->to_d;
1524 if (p_ptr->pclass == CLASS_NINJA)
1526 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h + 1) / 2;
1527 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
1530 /* To Bow and Natural attack */
1532 /* Apply the bonuses to hit/damage */
1533 p_ptr->to_h_b += (s16b)bonus_to_h;
1534 p_ptr->to_h_m += (s16b)bonus_to_h;
1535 p_ptr->to_d_m += (s16b)bonus_to_d;
1537 /* Apply the mental bonuses tp hit/damage, if known */
1538 if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += (s16b)bonus_to_h;
1541 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
1543 /* Apply the bonuses to hit/damage */
1544 p_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
1545 p_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
1547 /* Apply the mental bonuses tp hit/damage, if known */
1548 if (object_is_known(o_ptr))
1550 p_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
1551 p_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
1554 else if (p_ptr->migite && p_ptr->hidarite)
1556 /* Apply the bonuses to hit/damage */
1557 p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
1558 p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
1559 p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
1560 p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
1562 /* Apply the mental bonuses tp hit/damage, if known */
1563 if (object_is_known(o_ptr))
1565 p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
1566 p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
1567 p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
1568 p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
1573 /* Apply the bonuses to hit/damage */
1574 p_ptr->to_h[default_hand] += (s16b)bonus_to_h;
1575 p_ptr->to_d[default_hand] += (s16b)bonus_to_d;
1577 /* Apply the mental bonuses to hit/damage, if known */
1578 if (object_is_known(o_ptr))
1580 p_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
1581 p_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
1586 /* Shield skill bonus */
1587 if (object_is_armour(&p_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&p_ptr->inventory_list[INVEN_LARM]))
1589 p_ptr->ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
1590 p_ptr->dis_ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
1593 if (old_mighty_throw != p_ptr->mighty_throw)
1595 /* Redraw average damege display of Shuriken */
1596 p_ptr->window |= PW_INVEN;
1599 if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
1601 /* Monks get extra ac for armour _not worn_ */
1602 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
1604 if (!(p_ptr->inventory_list[INVEN_BODY].k_idx))
1606 p_ptr->to_a += (p_ptr->lev * 3) / 2;
1607 p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
1609 if (!(p_ptr->inventory_list[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
1611 p_ptr->to_a += ((p_ptr->lev - 13) / 3);
1612 p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
1614 if (!(p_ptr->inventory_list[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
1616 p_ptr->to_a += ((p_ptr->lev - 8) / 3);
1617 p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
1619 if (!(p_ptr->inventory_list[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
1621 p_ptr->to_a += (p_ptr->lev - 2) / 3;
1622 p_ptr->dis_to_a += (p_ptr->lev - 2) / 3;
1624 if (!(p_ptr->inventory_list[INVEN_HANDS].k_idx))
1626 p_ptr->to_a += (p_ptr->lev / 2);
1627 p_ptr->dis_to_a += (p_ptr->lev / 2);
1629 if (!(p_ptr->inventory_list[INVEN_FEET].k_idx))
1631 p_ptr->to_a += (p_ptr->lev / 3);
1632 p_ptr->dis_to_a += (p_ptr->lev / 3);
1634 if (p_ptr->special_defense & KAMAE_BYAKKO)
1636 p_ptr->stat_add[A_STR] += 2;
1637 p_ptr->stat_add[A_DEX] += 2;
1638 p_ptr->stat_add[A_CON] -= 3;
1640 else if (p_ptr->special_defense & KAMAE_SEIRYU)
1643 else if (p_ptr->special_defense & KAMAE_GENBU)
1645 p_ptr->stat_add[A_INT] -= 1;
1646 p_ptr->stat_add[A_WIS] -= 1;
1647 p_ptr->stat_add[A_DEX] -= 2;
1648 p_ptr->stat_add[A_CON] += 3;
1650 else if (p_ptr->special_defense & KAMAE_SUZAKU)
1652 p_ptr->stat_add[A_STR] -= 2;
1653 p_ptr->stat_add[A_INT] += 1;
1654 p_ptr->stat_add[A_WIS] += 1;
1655 p_ptr->stat_add[A_DEX] += 2;
1656 p_ptr->stat_add[A_CON] -= 2;
1660 if (p_ptr->special_defense & KATA_KOUKIJIN)
1662 for (i = 0; i < A_MAX; i++)
1663 p_ptr->stat_add[i] += 5;
1665 p_ptr->dis_to_a -= 50;
1668 /* Hack -- aura of fire also provides light */
1669 if (p_ptr->sh_fire) p_ptr->lite = TRUE;
1671 /* Golems also get an intrinsic AC bonus */
1672 if (prace_is_(RACE_GOLEM) || prace_is_(RACE_ANDROID))
1674 p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
1675 p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
1679 if (p_ptr->realm1 == REALM_HEX)
1681 if (hex_spelling_any()) p_ptr->skill_stl -= (1 + CASTING_HEX_NUM(p_ptr));
1682 if (hex_spelling(HEX_DETECT_EVIL)) p_ptr->esp_evil = TRUE;
1683 if (hex_spelling(HEX_XTRA_MIGHT)) p_ptr->stat_add[A_STR] += 4;
1684 if (hex_spelling(HEX_BUILDING))
1686 p_ptr->stat_add[A_STR] += 4;
1687 p_ptr->stat_add[A_DEX] += 4;
1688 p_ptr->stat_add[A_CON] += 4;
1690 if (hex_spelling(HEX_DEMON_AURA))
1692 p_ptr->sh_fire = TRUE;
1693 p_ptr->regenerate = TRUE;
1695 if (hex_spelling(HEX_ICE_ARMOR))
1697 p_ptr->sh_cold = TRUE;
1699 p_ptr->dis_to_a += 30;
1701 if (hex_spelling(HEX_SHOCK_CLOAK))
1703 p_ptr->sh_elec = TRUE;
1706 for (i = INVEN_RARM; i <= INVEN_FEET; i++)
1708 ARMOUR_CLASS ac = 0;
1709 o_ptr = &p_ptr->inventory_list[i];
1710 if (!o_ptr->k_idx) continue;
1711 if (!object_is_armour(o_ptr)) continue;
1712 if (!object_is_cursed(o_ptr)) continue;
1714 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
1715 if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
1716 p_ptr->to_a += (s16b)ac;
1717 p_ptr->dis_to_a += (s16b)ac;
1721 /* Calculate stats */
1722 for (i = 0; i < A_MAX; i++)
1726 /* Extract the new "stat_use" value for the stat */
1727 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
1729 /* Notice changes */
1730 if (p_ptr->stat_top[i] != top)
1732 /* Save the new value */
1733 p_ptr->stat_top[i] = (s16b)top;
1734 p_ptr->redraw |= (PR_STATS);
1735 p_ptr->window |= (PW_PLAYER);
1739 /* Extract the new "stat_use" value for the stat */
1740 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
1742 if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
1744 /* 10 to 18/90 charisma, guaranteed, based on level */
1745 if (use < 8 + 2 * p_ptr->lev)
1747 use = 8 + 2 * p_ptr->lev;
1751 /* Notice changes */
1752 if (p_ptr->stat_use[i] != use)
1754 /* Save the new value */
1755 p_ptr->stat_use[i] = (s16b)use;
1756 p_ptr->redraw |= (PR_STATS);
1757 p_ptr->window |= (PW_PLAYER);
1761 /* Values: 3, 4, ..., 17 */
1762 if (use <= 18) ind = (use - 3);
1764 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
1765 else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
1767 /* Range: 18/220+ */
1770 /* Notice changes */
1771 if (p_ptr->stat_ind[i] != ind)
1773 /* Save the new index */
1774 p_ptr->stat_ind[i] = (s16b)ind;
1776 /* Change in CON affects Hitpoints */
1779 p_ptr->update |= (PU_HP);
1782 /* Change in INT may affect Mana/Spells */
1783 else if (i == A_INT)
1785 if (mp_ptr->spell_stat == A_INT)
1787 p_ptr->update |= (PU_MANA | PU_SPELLS);
1791 /* Change in WIS may affect Mana/Spells */
1792 else if (i == A_WIS)
1794 if (mp_ptr->spell_stat == A_WIS)
1796 p_ptr->update |= (PU_MANA | PU_SPELLS);
1800 /* Change in WIS may affect Mana/Spells */
1801 else if (i == A_CHR)
1803 if (mp_ptr->spell_stat == A_CHR)
1805 p_ptr->update |= (PU_MANA | PU_SPELLS);
1809 p_ptr->window |= (PW_PLAYER);
1814 /* Apply temporary "stun" */
1815 if (p_ptr->stun > 50)
1817 p_ptr->to_h[0] -= 20;
1818 p_ptr->to_h[1] -= 20;
1819 p_ptr->to_h_b -= 20;
1820 p_ptr->to_h_m -= 20;
1821 p_ptr->dis_to_h[0] -= 20;
1822 p_ptr->dis_to_h[1] -= 20;
1823 p_ptr->dis_to_h_b -= 20;
1824 p_ptr->to_d[0] -= 20;
1825 p_ptr->to_d[1] -= 20;
1826 p_ptr->to_d_m -= 20;
1827 p_ptr->dis_to_d[0] -= 20;
1828 p_ptr->dis_to_d[1] -= 20;
1830 else if (p_ptr->stun)
1832 p_ptr->to_h[0] -= 5;
1833 p_ptr->to_h[1] -= 5;
1836 p_ptr->dis_to_h[0] -= 5;
1837 p_ptr->dis_to_h[1] -= 5;
1838 p_ptr->dis_to_h_b -= 5;
1839 p_ptr->to_d[0] -= 5;
1840 p_ptr->to_d[1] -= 5;
1842 p_ptr->dis_to_d[0] -= 5;
1843 p_ptr->dis_to_d[1] -= 5;
1847 if (p_ptr->wraith_form)
1849 p_ptr->reflect = TRUE;
1850 p_ptr->pass_wall = TRUE;
1853 if (p_ptr->kabenuke)
1855 p_ptr->pass_wall = TRUE;
1858 /* Temporary blessing */
1862 p_ptr->dis_to_a += 5;
1863 p_ptr->to_h[0] += 10;
1864 p_ptr->to_h[1] += 10;
1865 p_ptr->to_h_b += 10;
1866 p_ptr->to_h_m += 10;
1867 p_ptr->dis_to_h[0] += 10;
1868 p_ptr->dis_to_h[1] += 10;
1869 p_ptr->dis_to_h_b += 10;
1872 if (p_ptr->magicdef)
1874 p_ptr->resist_blind = TRUE;
1875 p_ptr->resist_conf = TRUE;
1876 p_ptr->reflect = TRUE;
1877 p_ptr->free_act = TRUE;
1878 p_ptr->levitation = TRUE;
1881 /* Temporary "Hero" */
1884 p_ptr->to_h[0] += 12;
1885 p_ptr->to_h[1] += 12;
1886 p_ptr->to_h_b += 12;
1887 p_ptr->to_h_m += 12;
1888 p_ptr->dis_to_h[0] += 12;
1889 p_ptr->dis_to_h[1] += 12;
1890 p_ptr->dis_to_h_b += 12;
1893 /* Temporary "Beserk" */
1896 p_ptr->to_h[0] += 12;
1897 p_ptr->to_h[1] += 12;
1898 p_ptr->to_h_b -= 12;
1899 p_ptr->to_h_m += 12;
1900 p_ptr->to_d[0] += 3 + (p_ptr->lev / 5);
1901 p_ptr->to_d[1] += 3 + (p_ptr->lev / 5);
1902 p_ptr->to_d_m += 3 + (p_ptr->lev / 5);
1903 p_ptr->dis_to_h[0] += 12;
1904 p_ptr->dis_to_h[1] += 12;
1905 p_ptr->dis_to_h_b -= 12;
1906 p_ptr->dis_to_d[0] += 3 + (p_ptr->lev / 5);
1907 p_ptr->dis_to_d[1] += 3 + (p_ptr->lev / 5);
1909 p_ptr->dis_to_a -= 10;
1910 p_ptr->skill_stl -= 7;
1911 p_ptr->skill_dev -= 20;
1912 p_ptr->skill_sav -= 30;
1913 p_ptr->skill_srh -= 15;
1914 p_ptr->skill_fos -= 15;
1915 p_ptr->skill_tht -= 20;
1916 p_ptr->skill_dig += 30;
1919 /* Temporary "fast" */
1925 /* Temporary "slow" */
1931 /* Temporary "telepathy" */
1934 p_ptr->telepathy = TRUE;
1937 if (p_ptr->ele_immune)
1939 if (p_ptr->special_defense & DEFENSE_ACID)
1940 p_ptr->immune_acid = TRUE;
1941 else if (p_ptr->special_defense & DEFENSE_ELEC)
1942 p_ptr->immune_elec = TRUE;
1943 else if (p_ptr->special_defense & DEFENSE_FIRE)
1944 p_ptr->immune_fire = TRUE;
1945 else if (p_ptr->special_defense & DEFENSE_COLD)
1946 p_ptr->immune_cold = TRUE;
1949 /* Temporary see invisible */
1950 if (p_ptr->tim_invis)
1952 p_ptr->see_inv = TRUE;
1955 /* Temporary infravision boost */
1956 if (p_ptr->tim_infra)
1958 p_ptr->see_infra += 3;
1961 /* Temporary regeneration boost */
1962 if (p_ptr->tim_regen)
1964 p_ptr->regenerate = TRUE;
1967 /* Temporary levitation */
1968 if (p_ptr->tim_levitation)
1970 p_ptr->levitation = TRUE;
1973 /* Temporary reflection */
1974 if (p_ptr->tim_reflect)
1976 p_ptr->reflect = TRUE;
1979 /* Hack -- Hero/Shero -> Res fear */
1980 if (IS_HERO() || p_ptr->shero)
1982 p_ptr->resist_fear = TRUE;
1986 /* Hack -- Telepathy Change */
1987 if (p_ptr->telepathy != old_telepathy)
1989 p_ptr->update |= (PU_MONSTERS);
1992 if ((p_ptr->esp_animal != old_esp_animal) ||
1993 (p_ptr->esp_undead != old_esp_undead) ||
1994 (p_ptr->esp_demon != old_esp_demon) ||
1995 (p_ptr->esp_orc != old_esp_orc) ||
1996 (p_ptr->esp_troll != old_esp_troll) ||
1997 (p_ptr->esp_giant != old_esp_giant) ||
1998 (p_ptr->esp_dragon != old_esp_dragon) ||
1999 (p_ptr->esp_human != old_esp_human) ||
2000 (p_ptr->esp_evil != old_esp_evil) ||
2001 (p_ptr->esp_good != old_esp_good) ||
2002 (p_ptr->esp_nonliving != old_esp_nonliving) ||
2003 (p_ptr->esp_unique != old_esp_unique))
2005 p_ptr->update |= (PU_MONSTERS);
2008 /* Hack -- See Invis Change */
2009 if (p_ptr->see_inv != old_see_inv)
2011 p_ptr->update |= (PU_MONSTERS);
2014 /* Bloating slows the player down (a little) */
2015 if (p_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
2017 if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
2019 if ((p_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
2020 (p_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
2022 p_ptr->to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2023 p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2026 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2028 int penalty1, penalty2;
2029 penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - p_ptr->inventory_list[INVEN_RARM].weight) / 8);
2030 penalty2 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - p_ptr->inventory_list[INVEN_LARM].weight) / 8);
2031 if ((p_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (p_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN))
2033 penalty1 = penalty1 / 2 - 5;
2034 penalty2 = penalty2 / 2 - 5;
2037 p_ptr->dis_to_a += 10;
2041 if (penalty1 > 0) penalty1 /= 2;
2042 if (penalty2 > 0) penalty2 /= 2;
2044 else if ((p_ptr->inventory_list[INVEN_LARM].tval == TV_SWORD) && ((p_ptr->inventory_list[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (p_ptr->inventory_list[INVEN_LARM].sval == SV_WAKIZASHI)))
2046 penalty1 = MAX(0, penalty1 - 10);
2047 penalty2 = MAX(0, penalty2 - 10);
2049 if ((p_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (p_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
2051 penalty1 = MIN(0, penalty1);
2052 penalty2 = MIN(0, penalty2);
2054 p_ptr->dis_to_a += 10;
2058 if ((p_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
2060 if ((p_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
2063 if (p_ptr->inventory_list[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
2064 if (p_ptr->inventory_list[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
2065 p_ptr->to_h[0] -= (s16b)penalty1;
2066 p_ptr->to_h[1] -= (s16b)penalty2;
2067 p_ptr->dis_to_h[0] -= (s16b)penalty1;
2068 p_ptr->dis_to_h[1] -= (s16b)penalty2;
2071 /* Extract the current weight (in tenth pounds) */
2072 j = p_ptr->total_weight;
2076 /* Extract the "weight limit" (in tenth pounds) */
2077 i = (int)weight_limit();
2081 monster_type *riding_m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
2082 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2083 SPEED speed = riding_m_ptr->mspeed;
2085 if (riding_m_ptr->mspeed > 110)
2087 new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
2088 if (new_speed < 110) new_speed = 110;
2094 new_speed += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev * 160L) / 3200;
2095 if (MON_FAST(riding_m_ptr)) new_speed += 10;
2096 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
2097 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
2098 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
2100 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) p_ptr->pass_wall = FALSE;
2101 if (riding_r_ptr->flags2 & RF2_KILL_WALL) p_ptr->kill_wall = TRUE;
2103 if (p_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) j += (p_ptr->wt * 3 * (RIDING_EXP_SKILLED - p_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2105 /* Extract the "weight limit" */
2106 i = 1500 + riding_r_ptr->level * 25;
2109 /* Apply "encumbrance" from weight */
2110 if (j > i) new_speed -= ((j - i) / (i / 5));
2112 /* Searching slows the player down */
2113 if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
2116 if (p_ptr->prace == RACE_MERFOLK)
2118 if (have_flag(f_ptr->flags, FF_WATER))
2120 new_speed += (2 + p_ptr->lev / 10);
2122 else if (!p_ptr->levitation)
2129 /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
2130 p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
2131 p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2132 p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2133 p_ptr->to_d_m += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2134 p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2135 p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2136 p_ptr->to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2137 p_ptr->to_h_m += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2138 p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2139 p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2140 p_ptr->to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2141 p_ptr->to_h_m += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2143 /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
2144 p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
2145 p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2146 p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2147 p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2148 p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2149 p_ptr->dis_to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2150 p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2151 p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2152 p_ptr->dis_to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
2155 /* Obtain the "hold" value */
2156 hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
2159 /* Examine the "current bow" */
2160 o_ptr = &p_ptr->inventory_list[INVEN_BOW];
2162 /* It is hard to carholdry a heavy bow */
2163 p_ptr->heavy_shoot = is_heavy_shoot(o_ptr);
2164 if (p_ptr->heavy_shoot)
2166 /* Hard to wield a heavy bow */
2167 p_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
2168 p_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
2171 /* Compute "extra shots" if needed */
2174 p_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
2176 /* Apply special flags */
2177 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
2180 p_ptr->num_fire = calc_num_fire(o_ptr);
2182 /* Snipers love Cross bows */
2183 if ((p_ptr->pclass == CLASS_SNIPER) &&
2184 (p_ptr->tval_ammo == TV_BOLT))
2186 p_ptr->to_h_b += (10 + (p_ptr->lev / 5));
2187 p_ptr->dis_to_h_b += (10 + (p_ptr->lev / 5));
2192 if (p_ptr->ryoute) hold *= 2;
2194 for (i = 0; i < 2; i++)
2196 /* Examine the "main weapon" */
2197 o_ptr = &p_ptr->inventory_list[INVEN_RARM + i];
2199 object_flags(o_ptr, flgs);
2201 /* Assume not heavy */
2202 p_ptr->heavy_wield[i] = FALSE;
2203 p_ptr->icky_wield[i] = FALSE;
2204 p_ptr->riding_wield[i] = FALSE;
2206 if (!has_melee_weapon(INVEN_RARM + i))
2208 p_ptr->num_blow[i] = 1;
2211 /* It is hard to hold a heavy weapon */
2212 if (hold < o_ptr->weight / 10)
2214 /* Hard to wield a heavy weapon */
2215 p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
2216 p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
2219 p_ptr->heavy_wield[i] = TRUE;
2221 else if (p_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
2223 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
2226 p_ptr->dis_to_a += 5;
2229 /* Normal weapons */
2230 if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
2232 int str_index, dex_index;
2234 int num = 0, wgt = 0, mul = 0, div = 0;
2236 /* Analyze the class */
2237 switch (p_ptr->pclass)
2240 num = 6; wgt = 70; mul = 5; break;
2242 case CLASS_BERSERKER:
2243 num = 6; wgt = 70; mul = 7; break;
2246 case CLASS_HIGH_MAGE:
2247 case CLASS_BLUE_MAGE:
2248 num = 3; wgt = 100; mul = 2; break;
2251 case CLASS_MAGIC_EATER:
2252 case CLASS_MINDCRAFTER:
2253 num = 5; wgt = 100; mul = 3; break;
2256 num = 5; wgt = 40; mul = 3; break;
2259 num = 5; wgt = 70; mul = 4; break;
2263 num = 5; wgt = 70; mul = 4; break;
2266 num = 5; wgt = 150; mul = 5; break;
2268 case CLASS_WARRIOR_MAGE:
2269 case CLASS_RED_MAGE:
2270 num = 5; wgt = 70; mul = 3; break;
2272 case CLASS_CHAOS_WARRIOR:
2273 num = 5; wgt = 70; mul = 4; break;
2276 num = 5; wgt = 60; mul = 3; break;
2279 num = 4; wgt = 100; mul = 3; break;
2281 case CLASS_IMITATOR:
2282 num = 5; wgt = 70; mul = 4; break;
2284 case CLASS_BEASTMASTER:
2285 num = 5; wgt = 70; mul = 3; break;
2288 if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
2289 else { num = 5; wgt = 100; mul = 3; }
2292 case CLASS_SORCERER:
2293 num = 1; wgt = 1; mul = 1; break;
2298 num = 4; wgt = 70; mul = 2; break;
2300 case CLASS_FORCETRAINER:
2301 num = 4; wgt = 60; mul = 2; break;
2303 case CLASS_MIRROR_MASTER:
2304 num = 3; wgt = 100; mul = 3; break;
2307 num = 4; wgt = 20; mul = 1; break;
2310 /* Hex - extra mights gives +1 bonus to max blows */
2311 if (hex_spelling(HEX_XTRA_MIGHT) || hex_spelling(HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
2313 /* Enforce a minimum "weight" (tenth pounds) */
2314 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
2316 /* Access the strength vs weight */
2317 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
2319 if (p_ptr->ryoute && !omoi) str_index++;
2320 if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
2323 if (str_index > 11) str_index = 11;
2325 /* Index by dexterity */
2326 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
2329 if (dex_index > 11) dex_index = 11;
2331 /* Use the blows table */
2332 p_ptr->num_blow[i] = blows_table[str_index][dex_index];
2335 if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = (s16b)num;
2337 /* Add in the "bonus blows" */
2338 p_ptr->num_blow[i] += (s16b)extra_blows[i];
2341 if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
2342 else if (p_ptr->pclass == CLASS_BERSERKER)
2344 p_ptr->num_blow[i] += (p_ptr->lev / 23);
2346 else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
2348 if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
2350 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
2353 /* Require at least one blow */
2354 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
2356 /* Boost digging skill by weapon weight */
2357 p_ptr->skill_dig += (o_ptr->weight / 10);
2361 /* Priest weapon penalty for non-blessed edged weapons */
2362 if ((p_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
2363 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
2365 /* Reduce the real bonuses */
2366 p_ptr->to_h[i] -= 2;
2367 p_ptr->to_d[i] -= 2;
2369 /* Reduce the mental bonuses */
2370 p_ptr->dis_to_h[i] -= 2;
2371 p_ptr->dis_to_d[i] -= 2;
2374 p_ptr->icky_wield[i] = TRUE;
2376 else if (p_ptr->pclass == CLASS_BERSERKER)
2378 p_ptr->to_h[i] += p_ptr->lev / 5;
2379 p_ptr->to_d[i] += p_ptr->lev / 6;
2380 p_ptr->dis_to_h[i] += p_ptr->lev / 5;
2381 p_ptr->dis_to_d[i] += p_ptr->lev / 6;
2382 if (((i == 0) && !p_ptr->hidarite) || p_ptr->ryoute)
2384 p_ptr->to_h[i] += p_ptr->lev / 5;
2385 p_ptr->to_d[i] += p_ptr->lev / 6;
2386 p_ptr->dis_to_h[i] += p_ptr->lev / 5;
2387 p_ptr->dis_to_d[i] += p_ptr->lev / 6;
2390 else if (p_ptr->pclass == CLASS_SORCERER)
2392 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
2394 /* Reduce the real bonuses */
2395 p_ptr->to_h[i] -= 200;
2396 p_ptr->to_d[i] -= 200;
2398 /* Reduce the mental bonuses */
2399 p_ptr->dis_to_h[i] -= 200;
2400 p_ptr->dis_to_d[i] -= 200;
2403 p_ptr->icky_wield[i] = TRUE;
2407 /* Reduce the real bonuses */
2408 p_ptr->to_h[i] -= 30;
2409 p_ptr->to_d[i] -= 10;
2411 /* Reduce the mental bonuses */
2412 p_ptr->dis_to_h[i] -= 30;
2413 p_ptr->dis_to_d[i] -= 10;
2417 if (p_ptr->realm1 == REALM_HEX)
2419 if (object_is_cursed(o_ptr))
2421 if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
2422 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_h[i] += 7; p_ptr->dis_to_h[i] += 7; }
2423 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_h[i] += 13; p_ptr->dis_to_h[i] += 13; }
2424 if (o_ptr->curse_flags & (TRC_TY_CURSE)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
2425 if (hex_spelling(HEX_RUNESWORD))
2427 if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_d[i] += 5; p_ptr->dis_to_d[i] += 5; }
2428 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_d[i] += 7; p_ptr->dis_to_d[i] += 7; }
2429 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_d[i] += 13; p_ptr->dis_to_d[i] += 13; }
2435 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2437 p_ptr->to_h[i] += 15;
2438 p_ptr->dis_to_h[i] += 15;
2439 p_ptr->to_dd[i] += 2;
2441 else if (!(have_flag(flgs, TR_RIDING)))
2444 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
2450 penalty = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
2452 if (penalty < 30) penalty = 30;
2454 p_ptr->to_h[i] -= (s16b)penalty;
2455 p_ptr->dis_to_h[i] -= (s16b)penalty;
2458 p_ptr->riding_wield[i] = TRUE;
2467 p_ptr->riding_ryoute = FALSE;
2469 if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
2470 else if (p_ptr->pet_extra_flags & PF_RYOUTE)
2472 switch (p_ptr->pclass)
2475 case CLASS_FORCETRAINER:
2476 case CLASS_BERSERKER:
2477 if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
2478 p_ptr->riding_ryoute = TRUE;
2483 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
2485 if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
2489 penalty = r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
2491 if (penalty < 30) penalty = 30;
2493 if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
2494 p_ptr->to_h_b -= (s16b)penalty;
2495 p_ptr->dis_to_h_b -= (s16b)penalty;
2498 /* Different calculation for monks with empty hands */
2499 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) &&
2500 (empty_hands_status & EMPTY_HAND_RARM) && !p_ptr->hidarite)
2502 int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
2503 p_ptr->num_blow[0] = 0;
2505 if (p_ptr->pclass == CLASS_FORCETRAINER)
2507 if (blow_base > 18) p_ptr->num_blow[0]++;
2508 if (blow_base > 31) p_ptr->num_blow[0]++;
2509 if (blow_base > 44) p_ptr->num_blow[0]++;
2510 if (blow_base > 58) p_ptr->num_blow[0]++;
2513 p_ptr->to_d[0] += P_PTR_KI / 5;
2514 p_ptr->dis_to_d[0] += P_PTR_KI / 5;
2519 if (blow_base > 12) p_ptr->num_blow[0]++;
2520 if (blow_base > 22) p_ptr->num_blow[0]++;
2521 if (blow_base > 31) p_ptr->num_blow[0]++;
2522 if (blow_base > 39) p_ptr->num_blow[0]++;
2523 if (blow_base > 46) p_ptr->num_blow[0]++;
2524 if (blow_base > 53) p_ptr->num_blow[0]++;
2525 if (blow_base > 59) p_ptr->num_blow[0]++;
2528 if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
2529 p_ptr->num_blow[0] /= 2;
2532 p_ptr->to_h[0] += (p_ptr->lev / 3);
2533 p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
2535 p_ptr->to_d[0] += (p_ptr->lev / 6);
2536 p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
2539 if (p_ptr->special_defense & KAMAE_BYAKKO)
2542 p_ptr->dis_to_a -= 40;
2545 else if (p_ptr->special_defense & KAMAE_SEIRYU)
2548 p_ptr->dis_to_a -= 50;
2549 p_ptr->resist_acid = TRUE;
2550 p_ptr->resist_fire = TRUE;
2551 p_ptr->resist_elec = TRUE;
2552 p_ptr->resist_cold = TRUE;
2553 p_ptr->resist_pois = TRUE;
2554 p_ptr->sh_fire = TRUE;
2555 p_ptr->sh_elec = TRUE;
2556 p_ptr->sh_cold = TRUE;
2557 p_ptr->levitation = TRUE;
2559 else if (p_ptr->special_defense & KAMAE_GENBU)
2561 p_ptr->to_a += (p_ptr->lev*p_ptr->lev) / 50;
2562 p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev) / 50;
2563 p_ptr->reflect = TRUE;
2564 p_ptr->num_blow[0] -= 2;
2565 if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
2566 if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
2568 else if (p_ptr->special_defense & KAMAE_SUZAKU)
2570 p_ptr->to_h[0] -= (p_ptr->lev / 3);
2571 p_ptr->to_d[0] -= (p_ptr->lev / 6);
2573 p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
2574 p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
2575 p_ptr->num_blow[0] /= 2;
2576 p_ptr->levitation = TRUE;
2579 p_ptr->num_blow[0] += 1 + extra_blows[0];
2582 if (p_ptr->riding) p_ptr->levitation = riding_levitation;
2584 p_ptr->monk_armour_aux = FALSE;
2588 p_ptr->monk_armour_aux = TRUE;
2591 for (i = 0; i < 2; i++)
2593 if (has_melee_weapon(INVEN_RARM + i))
2595 OBJECT_TYPE_VALUE tval = p_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
2596 OBJECT_SUBTYPE_VALUE sval = p_ptr->inventory_list[INVEN_RARM + i].sval;
2598 p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2599 p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2600 if ((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER))
2602 if (!s_info[p_ptr->pclass].w_max[tval][sval])
2604 p_ptr->to_h[i] -= 40;
2605 p_ptr->dis_to_h[i] -= 40;
2606 p_ptr->icky_wield[i] = TRUE;
2609 else if (p_ptr->pclass == CLASS_NINJA)
2611 if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (p_ptr->inventory_list[INVEN_LARM - i].tval == TV_SHIELD))
2613 p_ptr->to_h[i] -= 40;
2614 p_ptr->dis_to_h[i] -= 40;
2615 p_ptr->icky_wield[i] = TRUE;
2616 p_ptr->num_blow[i] /= 2;
2617 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
2623 /* Maximum speed is (+99). (internally it's 110 + 99) */
2624 /* Temporary lightspeed forces to be maximum speed */
2625 if ((p_ptr->lightspeed && !p_ptr->riding) || (new_speed > 209))
2630 /* Minimum speed is (-99). (internally it's 110 - 99) */
2631 if (new_speed < 11) new_speed = 11;
2633 /* Display the speed (if needed) */
2634 if (p_ptr->pspeed != (byte)new_speed)
2636 p_ptr->pspeed = (byte)new_speed;
2637 p_ptr->redraw |= (PR_SPEED);
2642 if (p_ptr->to_a > (0 - p_ptr->ac))
2643 p_ptr->to_a = 0 - p_ptr->ac;
2644 if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
2645 p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
2648 /* Redraw armor (if needed) */
2649 if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
2651 p_ptr->redraw |= (PR_ARMOR);
2652 p_ptr->window |= (PW_PLAYER);
2655 if (p_ptr->ryoute && !omoi)
2657 int bonus_to_h = 0, bonus_to_d = 0;
2658 bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128) / 2;
2659 bonus_to_h = ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2661 p_ptr->to_h[default_hand] += MAX(bonus_to_h, 1);
2662 p_ptr->dis_to_h[default_hand] += MAX(bonus_to_h, 1);
2663 p_ptr->to_d[default_hand] += MAX(bonus_to_d, 1);
2664 p_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
2667 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) p_ptr->ryoute = FALSE;
2669 /* Affect Skill -- stealth (bonus one) */
2670 p_ptr->skill_stl += 1;
2672 if (IS_TIM_STEALTH()) p_ptr->skill_stl += 99;
2674 /* Affect Skill -- disarming (DEX and INT) */
2675 p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
2676 p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
2678 /* Affect Skill -- magic devices (INT) */
2679 p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
2681 /* Affect Skill -- saving throw (WIS) */
2682 p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
2684 /* Affect Skill -- digging (STR) */
2685 p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
2687 /* Affect Skill -- disarming (Level, by Class) */
2688 p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
2690 /* Affect Skill -- magic devices (Level, by Class) */
2691 p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
2693 /* Affect Skill -- saving throw (Level, by Class) */
2694 p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
2696 /* Affect Skill -- stealth (Level, by Class) */
2697 p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
2699 /* Affect Skill -- search ability (Level, by Class) */
2700 p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
2702 /* Affect Skill -- search frequency (Level, by Class) */
2703 p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
2705 /* Affect Skill -- combat (normal) (Level, by Class) */
2706 p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
2708 /* Affect Skill -- combat (shooting) (Level, by Class) */
2709 p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
2711 /* Affect Skill -- combat (throwing) (Level, by Class) */
2712 p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
2715 if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && (p_ptr->cursed & TRC_AGGRAVATE))
2717 p_ptr->cursed &= ~(TRC_AGGRAVATE);
2718 p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
2721 /* Limit Skill -- stealth from 0 to 30 */
2722 if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
2723 if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
2725 /* Limit Skill -- digging from 1 up */
2726 if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
2728 if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
2730 if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
2732 if ((p_ptr->ult_res || p_ptr->resist_magic || p_ptr->magicdef) && (p_ptr->skill_sav < (95 + p_ptr->lev))) p_ptr->skill_sav = 95 + p_ptr->lev;
2734 if (down_saving) p_ptr->skill_sav /= 2;
2736 /* Hack -- Each elemental immunity includes resistance */
2737 if (p_ptr->immune_acid) p_ptr->resist_acid = TRUE;
2738 if (p_ptr->immune_elec) p_ptr->resist_elec = TRUE;
2739 if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
2740 if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
2743 /* Hack -- handle "xtra" mode */
2744 if (character_xtra) return;
2746 /* Take note when "heavy bow" changes */
2747 if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
2749 if (p_ptr->heavy_shoot)
2751 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2753 else if (p_ptr->inventory_list[INVEN_BOW].k_idx)
2755 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2759 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2763 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
2766 for (i = 0; i < 2; i++)
2768 /* Take note when "heavy weapon" changes */
2769 if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
2771 if (p_ptr->heavy_wield[i])
2773 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2775 else if (has_melee_weapon(INVEN_RARM + i))
2777 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2779 else if (p_ptr->heavy_wield[1 - i])
2781 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
2785 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2789 p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
2792 /* Take note when "heavy weapon" changes */
2793 if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
2795 if (p_ptr->riding_wield[i])
2797 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2799 else if (!p_ptr->riding)
2801 msg_print(_("この武器は徒歩で使いやすい。", "This weapon was not suitable for use while riding."));
2803 else if (has_melee_weapon(INVEN_RARM + i))
2805 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2808 p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
2811 /* Take note when "illegal weapon" changes */
2812 if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
2814 if (p_ptr->icky_wield[i])
2816 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2817 if (current_world_ptr->is_loading_now)
2819 chg_virtue(V_FAITH, -1);
2822 else if (has_melee_weapon(INVEN_RARM + i))
2824 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2828 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2832 p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
2836 if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
2838 if (p_ptr->riding_ryoute)
2841 msg_format("%s馬を操れない。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2843 msg_print("You are using both hand for fighting, and you can't control a riding pet.");
2849 msg_format("%s馬を操れるようになった。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2851 msg_print("You began to control riding pet with one hand.");
2855 p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
2858 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (p_ptr->monk_armour_aux != p_ptr->monk_notify_aux))
2862 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2863 if (current_world_ptr->is_loading_now)
2865 chg_virtue(V_HARMONY, -1);
2870 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2873 p_ptr->monk_notify_aux = p_ptr->monk_armour_aux;
2876 for (i = 0; i < INVEN_PACK; i++)
2879 if ((p_ptr->inventory_list[i].tval == TV_SORCERY_BOOK) && (p_ptr->inventory_list[i].sval == 2)) have_dd_s = TRUE;
2880 if ((p_ptr->inventory_list[i].tval == TV_TRUMP_BOOK) && (p_ptr->inventory_list[i].sval == 1)) have_dd_t = TRUE;
2882 if ((p_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (p_ptr->inventory_list[i].sval == 2)) have_sw = TRUE;
2883 if ((p_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (p_ptr->inventory_list[i].sval == 2)) have_kabe = TRUE;
2886 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2888 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
2889 next_o_idx = o_ptr->next_o_idx;
2892 if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
2893 if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
2895 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
2896 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
2899 if (p_ptr->pass_wall && !p_ptr->kill_wall) p_ptr->no_flowed = TRUE;
2901 if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
2903 const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY - 1][SPELL_DD_S];
2904 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2907 if (have_dd_t && ((p_ptr->realm1 == REALM_TRUMP) || (p_ptr->realm2 == REALM_TRUMP) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)))
2909 const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP - 1][SPELL_DD_T];
2910 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2913 if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
2915 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
2916 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2919 if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER)))
2921 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_KABE];
2922 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2927 static void calc_alignment(void)
2931 int i, j, neutral[2];
2933 for (m_idx = current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
2935 monster_type *m_ptr;
2936 monster_race *r_ptr;
2937 m_ptr = ¤t_floor_ptr->m_list[m_idx];
2938 if (!monster_is_valid(m_ptr)) continue;
2939 r_ptr = &r_info[m_ptr->r_idx];
2943 if (r_ptr->flags3 & RF3_GOOD) p_ptr->align += r_ptr->level;
2944 if (r_ptr->flags3 & RF3_EVIL) p_ptr->align -= r_ptr->level;
2948 if (p_ptr->mimic_form)
2950 switch (p_ptr->mimic_form)
2953 p_ptr->align -= 200;
2955 case MIMIC_DEMON_LORD:
2956 p_ptr->align -= 200;
2962 switch (p_ptr->prace)
2965 p_ptr->align += 200;
2968 p_ptr->align -= 200;
2973 for (i = 0; i < 2; i++)
2975 if (has_melee_weapon(INVEN_RARM + i))
2977 if (p_ptr->inventory_list[INVEN_RARM + i].name1 == ART_IRON_BALL) p_ptr->align -= 1000;
2981 /* Determine player alignment */
2982 for (i = 0, j = 0; i < 8; i++)
2984 switch (p_ptr->vir_types[i])
2987 p_ptr->align += p_ptr->virtues[i] * 2;
2997 p_ptr->align -= p_ptr->virtues[i];
3000 p_ptr->align += p_ptr->virtues[i];
3005 for (i = 0; i < j; i++)
3007 if (p_ptr->align > 0)
3009 p_ptr->align -= p_ptr->virtues[neutral[i]] / 2;
3010 if (p_ptr->align < 0) p_ptr->align = 0;
3012 else if (p_ptr->align < 0)
3014 p_ptr->align += p_ptr->virtues[neutral[i]] / 2;
3015 if (p_ptr->align > 0) p_ptr->align = 0;
3021 * @brief プレイヤーの最大HPを計算する /
3022 * Calculate the players (maximal) hit points
3023 * Adjust current hitpoints if necessary
3027 static void calc_hitpoints(void)
3032 /* Un-inflate "half-hitpoint bonus per level" value */
3033 bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
3035 /* Calculate hitpoints */
3036 mhp = p_ptr->player_hp[p_ptr->lev - 1];
3038 if (p_ptr->mimic_form)
3040 if (p_ptr->pclass == CLASS_SORCERER)
3041 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
3043 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3044 mhp = mhp * tmp_hitdie / p_ptr->hitdie;
3047 if (p_ptr->pclass == CLASS_SORCERER)
3049 if (p_ptr->lev < 30)
3050 mhp = (mhp * (45 + p_ptr->lev) / 100);
3052 mhp = (mhp * 75 / 100);
3053 bonus = (bonus * 65 / 100);
3058 if (p_ptr->pclass == CLASS_BERSERKER)
3060 mhp = mhp * (110 + (((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110)) / 100;
3063 /* Always have at least one hitpoint per level */
3064 if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
3066 /* Factor in the hero / superhero settings */
3067 if (IS_HERO()) mhp += 10;
3068 if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
3069 if (p_ptr->tsuyoshi) mhp += 50;
3071 /* Factor in the hex spell settings */
3072 if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
3073 if (hex_spelling(HEX_BUILDING)) mhp += 60;
3075 /* New maximum hitpoints */
3076 if (p_ptr->mhp != mhp)
3078 /* Enforce maximum */
3079 if (p_ptr->chp >= mhp)
3082 p_ptr->chp_frac = 0;
3086 /* レベルアップの時は上昇量を表示する */
3087 if ((level_up == 1) && (mhp > p_ptr->mhp))
3089 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - p_ptr->mhp));
3092 /* Save the new max-hitpoints */
3095 /* Display hitpoints (later) */
3096 p_ptr->redraw |= (PR_HP);
3097 p_ptr->window |= (PW_PLAYER);
3102 * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
3105 * SWD: Experimental modification: multiple light sources have additive effect.
3107 static void calc_torch(void)
3112 BIT_FLAGS flgs[TR_FLAG_SIZE];
3114 /* Assume no light */
3115 p_ptr->cur_lite = 0;
3117 /* Loop through all wielded items */
3118 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3120 o_ptr = &p_ptr->inventory_list[i];
3121 /* Skip empty slots */
3122 if (!o_ptr->k_idx) continue;
3124 if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
3127 if (o_ptr->name2 != EGO_LITE_DARKNESS)
3129 if (o_ptr->tval == TV_LITE)
3131 if ((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
3132 if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
3135 object_flags(o_ptr, flgs);
3137 /* calc the lite_radius */
3140 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 1;
3141 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 2;
3142 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 3;
3143 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
3144 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
3145 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
3146 p_ptr->cur_lite += rad;
3149 /* max radius is 14 (was 5) without rewriting other code -- */
3150 /* see current_floor_ptr->grid_array.c:update_lite() and defines.h:LITE_MAX */
3151 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
3152 p_ptr->cur_lite = 1;
3155 * check if the player doesn't have light radius,
3156 * but does weakly glow as an intrinsic.
3158 if (p_ptr->cur_lite <= 0 && p_ptr->lite) p_ptr->cur_lite++;
3160 if (p_ptr->cur_lite > 14) p_ptr->cur_lite = 14;
3161 if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
3163 /* end experimental mods */
3165 /* Notice changes in the "lite radius" */
3166 if (p_ptr->old_lite != p_ptr->cur_lite)
3168 /* Hack -- PU_MON_LITE for monsters' darkness */
3169 p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
3171 /* Remember the old lite */
3172 p_ptr->old_lite = p_ptr->cur_lite;
3174 if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
3175 set_superstealth(FALSE);
3180 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
3181 * Calculate number of spells player should have, and forget,
3182 * or remember, spells until that number is properly reflected.
3185 * Note that this function induces various "status" messages,
3186 * which must be bypasses until the character is created.
3188 static void calc_spells(void)
3190 int i, j, k, levels;
3192 int num_boukyaku = 0;
3194 const magic_type *s_ptr;
3200 /* Hack -- must be literate */
3201 if (!mp_ptr->spell_book) return;
3203 /* Hack -- wait for creation */
3204 if (!character_generated) return;
3206 /* Hack -- handle "xtra" mode */
3207 if (character_xtra) return;
3209 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3211 p_ptr->new_spells = 0;
3215 p = spell_category_name(mp_ptr->spell_book);
3217 /* Determine the number of spells allowed */
3218 levels = p_ptr->lev - mp_ptr->spell_first + 1;
3220 /* Hack -- no negative spells */
3221 if (levels < 0) levels = 0;
3223 /* Extract total allowed spells */
3224 num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
3226 if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
3230 if (p_ptr->pclass == CLASS_SAMURAI)
3234 else if (p_ptr->realm2 == REALM_NONE)
3236 num_allowed = (num_allowed + 1) / 2;
3237 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
3239 else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
3241 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
3245 if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
3248 /* Count the number of spells we know */
3249 for (j = 0; j < 64; j++)
3251 /* Count known spells */
3253 (p_ptr->spell_forgotten1 & (1L << j)) :
3254 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
3260 /* See how many spells we must forget or may learn */
3261 p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
3263 /* Forget spells which are too hard */
3264 for (i = 63; i >= 0; i--)
3266 /* Efficiency -- all done */
3267 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
3269 /* Access the spell */
3270 j = p_ptr->spell_order[i];
3272 /* Skip non-spells */
3273 if (j >= 99) continue;
3277 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
3280 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3282 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
3285 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3287 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
3289 /* Skip spells we are allowed to know */
3290 if (s_ptr->slevel <= p_ptr->lev) continue;
3294 (p_ptr->spell_learned1 & (1L << j)) :
3295 (p_ptr->spell_learned2 & (1L << (j - 32))))
3297 /* Mark as forgotten */
3300 p_ptr->spell_forgotten1 |= (1L << j);
3301 which = p_ptr->realm1;
3305 p_ptr->spell_forgotten2 |= (1L << (j - 32));
3306 which = p_ptr->realm2;
3309 /* No longer known */
3312 p_ptr->spell_learned1 &= ~(1L << j);
3313 which = p_ptr->realm1;
3317 p_ptr->spell_learned2 &= ~(1L << (j - 32));
3318 which = p_ptr->realm2;
3322 msg_format("%sの%sを忘れてしまった。", do_spell(which, j % 32, SPELL_NAME), p);
3324 msg_format("You have forgotten the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
3328 /* One more can be learned */
3329 p_ptr->new_spells++;
3334 /* Forget spells if we know too many spells */
3335 for (i = 63; i >= 0; i--)
3337 /* Stop when possible */
3338 if (p_ptr->new_spells >= 0) break;
3340 /* Efficiency -- all done */
3341 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
3343 /* Get the (i+1)th spell learned */
3344 j = p_ptr->spell_order[i];
3346 /* Skip unknown spells */
3347 if (j >= 99) continue;
3349 /* Forget it (if learned) */
3351 (p_ptr->spell_learned1 & (1L << j)) :
3352 (p_ptr->spell_learned2 & (1L << (j - 32))))
3354 /* Mark as forgotten */
3357 p_ptr->spell_forgotten1 |= (1L << j);
3358 which = p_ptr->realm1;
3362 p_ptr->spell_forgotten2 |= (1L << (j - 32));
3363 which = p_ptr->realm2;
3366 /* No longer known */
3369 p_ptr->spell_learned1 &= ~(1L << j);
3370 which = p_ptr->realm1;
3374 p_ptr->spell_learned2 &= ~(1L << (j - 32));
3375 which = p_ptr->realm2;
3379 msg_format("%sの%sを忘れてしまった。", do_spell(which, j % 32, SPELL_NAME), p);
3381 msg_format("You have forgotten the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
3385 /* One more can be learned */
3386 p_ptr->new_spells++;
3391 /* Check for spells to remember */
3392 for (i = 0; i < 64; i++)
3394 /* None left to remember */
3395 if (p_ptr->new_spells <= 0) break;
3397 /* Efficiency -- all done */
3398 if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
3400 /* Get the next spell we learned */
3401 j = p_ptr->spell_order[i];
3403 /* Skip unknown spells */
3406 /* Access the spell */
3407 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
3410 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3412 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
3415 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3417 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
3419 /* Skip spells we cannot remember */
3420 if (s_ptr->slevel > p_ptr->lev) continue;
3422 /* First set of spells */
3424 (p_ptr->spell_forgotten1 & (1L << j)) :
3425 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
3427 /* No longer forgotten */
3430 p_ptr->spell_forgotten1 &= ~(1L << j);
3431 which = p_ptr->realm1;
3435 p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
3436 which = p_ptr->realm2;
3439 /* Known once more */
3442 p_ptr->spell_learned1 |= (1L << j);
3443 which = p_ptr->realm1;
3447 p_ptr->spell_learned2 |= (1L << (j - 32));
3448 which = p_ptr->realm2;
3452 msg_format("%sの%sを思い出した。", do_spell(which, j % 32, SPELL_NAME), p);
3454 msg_format("You have remembered the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
3458 /* One less can be learned */
3459 p_ptr->new_spells--;
3465 if (p_ptr->realm2 == REALM_NONE)
3467 /* Count spells that can be learned */
3468 for (j = 0; j < 32; j++)
3470 if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3471 else s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3473 /* Skip spells we cannot remember */
3474 if (s_ptr->slevel > p_ptr->lev) continue;
3476 /* Skip spells we already know */
3477 if (p_ptr->spell_learned1 & (1L << j))
3486 if ((p_ptr->new_spells > k) &&
3487 ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
3489 p_ptr->new_spells = (s16b)k;
3493 if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
3495 /* Spell count changed */
3496 if (p_ptr->old_spells != p_ptr->new_spells)
3498 /* Message if needed */
3499 if (p_ptr->new_spells)
3502 if (p_ptr->new_spells < 10) {
3503 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
3506 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
3509 msg_format("You can learn %d more %s%s.",
3510 p_ptr->new_spells, p,
3511 (p_ptr->new_spells != 1) ? "s" : "");
3516 /* Save the new_spells value */
3517 p_ptr->old_spells = p_ptr->new_spells;
3519 /* Redraw Study Status */
3520 p_ptr->redraw |= (PR_STUDY);
3522 /* Redraw object recall */
3523 p_ptr->window |= (PW_OBJECT);
3528 * @brief プレイヤーの最大MPを計算する /
3529 * Calculate maximum mana. You do not need to know any spells.
3530 * Note that mana is lowered by heavy (or inappropriate) armor.
3533 * This function induces status messages.
3535 static void calc_mana(void)
3537 int msp, levels, cur_wgt, max_wgt;
3542 /* Hack -- Must be literate */
3543 if (!mp_ptr->spell_book) return;
3545 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3546 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3547 (p_ptr->pclass == CLASS_BLUE_MAGE))
3549 levels = p_ptr->lev;
3553 if (mp_ptr->spell_first > p_ptr->lev)
3558 /* Display mana later */
3559 p_ptr->redraw |= (PR_MANA);
3563 /* Extract "effective" player level */
3564 levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
3567 if (p_ptr->pclass == CLASS_SAMURAI)
3569 msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
3570 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3574 /* Extract total mana */
3575 msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
3577 /* Hack -- usually add one mana */
3580 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3582 if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
3584 /* Hack: High mages have a 25% mana bonus */
3585 if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
3587 if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + p_ptr->lev) / 100;
3590 /* Only mages are affected */
3591 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
3593 BIT_FLAGS flgs[TR_FLAG_SIZE];
3595 /* Assume player is not encumbered by gloves */
3596 p_ptr->cumber_glove = FALSE;
3598 /* Get the gloves */
3599 o_ptr = &p_ptr->inventory_list[INVEN_HANDS];
3601 /* Examine the gloves */
3602 object_flags(o_ptr, flgs);
3604 /* Normal gloves hurt mage-type spells */
3606 !(have_flag(flgs, TR_FREE_ACT)) &&
3607 !(have_flag(flgs, TR_DEC_MANA)) &&
3608 !(have_flag(flgs, TR_EASY_SPELL)) &&
3609 !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
3610 !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
3613 p_ptr->cumber_glove = TRUE;
3616 msp = (3 * msp) / 4;
3621 /* Assume player not encumbered by armor */
3622 p_ptr->cumber_armor = FALSE;
3624 /* Weigh the armor */
3626 if (p_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_RARM].weight;
3627 if (p_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_LARM].weight;
3628 cur_wgt += p_ptr->inventory_list[INVEN_BODY].weight;
3629 cur_wgt += p_ptr->inventory_list[INVEN_HEAD].weight;
3630 cur_wgt += p_ptr->inventory_list[INVEN_OUTER].weight;
3631 cur_wgt += p_ptr->inventory_list[INVEN_HANDS].weight;
3632 cur_wgt += p_ptr->inventory_list[INVEN_FEET].weight;
3634 /* Subtract a percentage of maximum mana. */
3635 switch (p_ptr->pclass)
3637 /* For these classes, mana is halved if armour
3638 * is 30 pounds over their weight limit. */
3640 case CLASS_HIGH_MAGE:
3641 case CLASS_BLUE_MAGE:
3643 case CLASS_FORCETRAINER:
3644 case CLASS_SORCERER:
3646 if (p_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_RARM].weight;
3647 if (p_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_LARM].weight;
3651 /* Mana halved if armour is 40 pounds over weight limit. */
3656 if (p_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
3657 if (p_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
3661 case CLASS_MINDCRAFTER:
3662 case CLASS_BEASTMASTER:
3663 case CLASS_MIRROR_MASTER:
3665 if (p_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_RARM].weight / 2;
3666 if (p_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_LARM].weight / 2;
3670 /* Mana halved if armour is 50 pounds over weight limit. */
3673 case CLASS_RED_MAGE:
3674 case CLASS_WARRIOR_MAGE:
3676 if (p_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_RARM].weight / 3;
3677 if (p_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_LARM].weight / 3;
3681 /* Mana halved if armour is 60 pounds over weight limit. */
3683 case CLASS_CHAOS_WARRIOR:
3685 if (p_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_RARM].weight / 5;
3686 if (p_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += p_ptr->inventory_list[INVEN_LARM].weight / 5;
3690 /* For new classes created, but not yet added to this formula. */
3697 /* Determine the weight allowance */
3698 max_wgt = mp_ptr->spell_weight;
3700 /* Heavy armor penalizes mana by a percentage. -LM- */
3701 if ((cur_wgt - max_wgt) > 0)
3704 p_ptr->cumber_armor = TRUE;
3706 /* Subtract a percentage of maximum mana. */
3707 switch (p_ptr->pclass)
3709 /* For these classes, mana is halved if armour
3710 * is 30 pounds over their weight limit. */
3712 case CLASS_HIGH_MAGE:
3713 case CLASS_BLUE_MAGE:
3715 msp -= msp * (cur_wgt - max_wgt) / 600;
3719 /* Mana halved if armour is 40 pounds over weight limit. */
3721 case CLASS_MINDCRAFTER:
3722 case CLASS_BEASTMASTER:
3724 case CLASS_FORCETRAINER:
3726 case CLASS_MIRROR_MASTER:
3728 msp -= msp * (cur_wgt - max_wgt) / 800;
3732 case CLASS_SORCERER:
3734 msp -= msp * (cur_wgt - max_wgt) / 900;
3738 /* Mana halved if armour is 50 pounds over weight limit. */
3742 case CLASS_RED_MAGE:
3744 msp -= msp * (cur_wgt - max_wgt) / 1000;
3748 /* Mana halved if armour is 60 pounds over weight limit. */
3750 case CLASS_CHAOS_WARRIOR:
3751 case CLASS_WARRIOR_MAGE:
3753 msp -= msp * (cur_wgt - max_wgt) / 1200;
3759 p_ptr->cumber_armor = FALSE;
3763 /* For new classes created, but not yet added to this formula. */
3766 msp -= msp * (cur_wgt - max_wgt) / 800;
3772 /* Mana can never be negative */
3773 if (msp < 0) msp = 0;
3776 /* Maximum mana has changed */
3777 if (p_ptr->msp != msp)
3779 /* Enforce maximum */
3780 if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
3783 p_ptr->csp_frac = 0;
3787 /* レベルアップの時は上昇量を表示する */
3788 if ((level_up == 1) && (msp > p_ptr->msp))
3790 msg_format("最大マジック・ポイントが %d 増加した!", (msp - p_ptr->msp));
3796 /* Display mana later */
3797 p_ptr->redraw |= (PR_MANA);
3798 p_ptr->window |= (PW_PLAYER | PW_SPELL);
3802 /* Hack -- handle "xtra" mode */
3803 if (character_xtra) return;
3805 /* Take note when "glove state" changes */
3806 if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
3808 if (p_ptr->cumber_glove)
3810 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
3814 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
3818 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
3822 /* Take note when "armor state" changes */
3823 if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
3825 if (p_ptr->cumber_armor)
3827 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
3831 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
3835 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
3840 * @brief 装備中の射撃武器の威力倍率を返す /
3841 * calcurate the fire rate of target object
3842 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
3843 * @return 射撃倍率の値(100で1.00倍)
3845 s16b calc_num_fire(object_type *o_ptr)
3847 int extra_shots = 0;
3850 OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
3852 BIT_FLAGS flgs[TR_FLAG_SIZE];
3854 /* Scan the usable p_ptr->inventory_list */
3855 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3857 q_ptr = &p_ptr->inventory_list[i];
3858 if (!q_ptr->k_idx) continue;
3860 /* Do not apply current equip */
3861 if (i == INVEN_BOW) continue;
3863 object_flags(q_ptr, flgs);
3866 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3869 object_flags(o_ptr, flgs);
3870 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3872 if (o_ptr->k_idx && !is_heavy_shoot(o_ptr))
3876 num += (extra_shots * 100);
3878 /* Hack -- Rangers love Bows */
3879 if ((p_ptr->pclass == CLASS_RANGER) &&
3880 (tval_ammo == TV_ARROW))
3882 num += (p_ptr->lev * 4);
3885 if ((p_ptr->pclass == CLASS_CAVALRY) &&
3886 (tval_ammo == TV_ARROW))
3888 num += (p_ptr->lev * 3);
3891 if (p_ptr->pclass == CLASS_ARCHER)
3893 if (tval_ammo == TV_ARROW)
3894 num += ((p_ptr->lev * 5) + 50);
3895 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
3896 num += (p_ptr->lev * 4);
3900 * Addendum -- also "Reward" high level warriors,
3901 * with _any_ missile weapon -- TY
3903 if (p_ptr->pclass == CLASS_WARRIOR &&
3904 (tval_ammo <= TV_BOLT) &&
3905 (tval_ammo >= TV_SHOT))
3907 num += (p_ptr->lev * 2);
3909 if ((p_ptr->pclass == CLASS_ROGUE) &&
3910 (tval_ammo == TV_SHOT))
3912 num += (p_ptr->lev * 4);
3919 * @brief プレイヤーの所持重量制限を計算する /
3920 * Computes current weight limit.
3923 WEIGHT weight_limit(void)
3927 /* Weight limit based only on strength */
3928 i = (WEIGHT)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
3929 if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
3931 /* Return the result */
3936 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3937 * @param i 判定する手のID(右手:0 左手:1)
3938 * @return 持っているならばTRUE
3940 bool has_melee_weapon(int i)
3942 return ((p_ptr->inventory_list[i].k_idx && object_is_melee_weapon(&p_ptr->inventory_list[i])) ? TRUE : FALSE);
3946 * @brief プレイヤーの現在開いている手の状態を返す
3947 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3948 * @return 開いている手のビットフラグ
3950 BIT_FLAGS16 empty_hands(bool riding_control)
3952 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3954 if (!p_ptr->inventory_list[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
3955 if (!p_ptr->inventory_list[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
3957 if (riding_control && (status != EMPTY_HAND_NONE) && p_ptr->riding && !(p_ptr->pet_extra_flags & PF_RYOUTE))
3959 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
3960 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
3968 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3969 * @return ペナルティが適用されるならばTRUE。
3971 bool heavy_armor(void)
3973 WEIGHT monk_arm_wgt = 0;
3975 if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
3977 /* Weight the armor */
3978 if (p_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += p_ptr->inventory_list[INVEN_RARM].weight;
3979 if (p_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += p_ptr->inventory_list[INVEN_LARM].weight;
3980 monk_arm_wgt += p_ptr->inventory_list[INVEN_BODY].weight;
3981 monk_arm_wgt += p_ptr->inventory_list[INVEN_HEAD].weight;
3982 monk_arm_wgt += p_ptr->inventory_list[INVEN_OUTER].weight;
3983 monk_arm_wgt += p_ptr->inventory_list[INVEN_HANDS].weight;
3984 monk_arm_wgt += p_ptr->inventory_list[INVEN_FEET].weight;
3986 return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
3990 * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update"
3992 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3994 void update_creature(player_type *creature_ptr)
3996 if (!creature_ptr->update) return;
3998 /* Actually do auto-destroy */
3999 if (creature_ptr->update & (PU_AUTODESTROY))
4001 creature_ptr->update &= ~(PU_AUTODESTROY);
4002 autopick_delayed_alter();
4004 if (creature_ptr->update & (PU_COMBINE))
4006 creature_ptr->update &= ~(PU_COMBINE);
4010 /* Reorder the pack */
4011 if (creature_ptr->update & (PU_REORDER))
4013 creature_ptr->update &= ~(PU_REORDER);
4017 if (creature_ptr->update & (PU_BONUS))
4019 creature_ptr->update &= ~(PU_BONUS);
4024 if (creature_ptr->update & (PU_TORCH))
4026 creature_ptr->update &= ~(PU_TORCH);
4030 if (creature_ptr->update & (PU_HP))
4032 creature_ptr->update &= ~(PU_HP);
4036 if (creature_ptr->update & (PU_MANA))
4038 creature_ptr->update &= ~(PU_MANA);
4042 if (creature_ptr->update & (PU_SPELLS))
4044 creature_ptr->update &= ~(PU_SPELLS);
4048 /* Character is not ready yet, no screen updates */
4049 if (!character_generated) return;
4051 /* Character is in "icky" mode, no screen updates */
4052 if (character_icky) return;
4054 if (creature_ptr->update & (PU_UN_LITE))
4056 creature_ptr->update &= ~(PU_UN_LITE);
4060 if (creature_ptr->update & (PU_UN_VIEW))
4062 creature_ptr->update &= ~(PU_UN_VIEW);
4066 if (creature_ptr->update & (PU_VIEW))
4068 creature_ptr->update &= ~(PU_VIEW);
4072 if (creature_ptr->update & (PU_LITE))
4074 creature_ptr->update &= ~(PU_LITE);
4079 if (creature_ptr->update & (PU_FLOW))
4081 creature_ptr->update &= ~(PU_FLOW);
4085 if (creature_ptr->update & (PU_DISTANCE))
4087 creature_ptr->update &= ~(PU_DISTANCE);
4089 /* Still need to call update_monsters(FALSE) after update_mon_lite() */
4090 /* creature_ptr->update &= ~(PU_MONSTERS); */
4092 update_monsters(TRUE);
4095 if (creature_ptr->update & (PU_MON_LITE))
4097 creature_ptr->update &= ~(PU_MON_LITE);
4102 * Mega-Hack -- Delayed visual update
4103 * Only used if update_view(), update_lite() or update_mon_lite() was called
4105 if (creature_ptr->update & (PU_DELAY_VIS))
4107 creature_ptr->update &= ~(PU_DELAY_VIS);
4108 delayed_visual_update();
4111 if (creature_ptr->update & (PU_MONSTERS))
4113 creature_ptr->update &= ~(PU_MONSTERS);
4114 update_monsters(FALSE);
4119 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
4120 * @return 魔道書を一冊も持っていないならTRUEを返す
4122 bool player_has_no_spellbooks(void)
4127 for (i = 0; i < INVEN_PACK; i++)
4129 o_ptr = &p_ptr->inventory_list[i];
4130 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
4133 for (i = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
4135 o_ptr = ¤t_floor_ptr->o_list[i];
4136 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
4142 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
4144 creature_ptr->energy_use = (ENERGY)need_cost;
4147 void free_turn(player_type *creature_ptr)
4149 creature_ptr->energy_use = 0;
4153 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4156 * @return 配置に成功したらTRUE
4158 bool player_place(POSITION y, POSITION x)
4160 /* Paranoia XXX XXX */
4161 if (current_floor_ptr->grid_array[y][x].m_idx != 0) return FALSE;
4163 /* Save player location */
4172 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
4175 void wreck_the_pattern(void)
4179 int pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
4181 if (pattern_type == PATTERN_TILE_WRECKED)
4183 /* Ruined already */
4187 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
4188 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
4190 if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
4191 to_ruin = randint1(45) + 35;
4195 scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
4197 if (pattern_tile(r_y, r_x) &&
4198 (f_info[current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
4200 cave_set_feat(r_y, r_x, feat_pattern_corrupted);
4204 cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
4209 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
4210 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
4211 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
4214 void sanity_blast(monster_type *m_ptr, bool necro)
4218 if (p_ptr->inside_battle || !character_dungeon) return;
4220 if (!necro && m_ptr)
4222 GAME_TEXT m_name[MAX_NLEN];
4223 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
4225 power = r_ptr->level / 2;
4227 monster_desc(m_name, m_ptr, 0);
4229 if (!(r_ptr->flags1 & RF1_UNIQUE))
4231 if (r_ptr->flags1 & RF1_FRIENDS)
4236 if (!current_world_ptr->is_loading_now)
4237 return; /* No effect yet, just loaded... */
4240 return; /* Cannot see it for some reason */
4242 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
4246 return; /* Pet eldritch horrors are safe most of the time */
4248 if (randint1(100) > power) return;
4250 if (saving_throw(p_ptr->skill_sav - power))
4252 return; /* Save, no adverse effects */
4257 /* Something silly happens... */
4258 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4259 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4263 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4264 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
4267 return; /* Never mind; we can't see it clearly enough */
4270 /* Something frightening happens... */
4271 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4272 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
4274 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4276 /* Demon characters are unaffected */
4277 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
4278 if (p_ptr->wizard) return;
4280 /* Undead characters are 50% likely to be unaffected */
4281 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
4282 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
4283 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
4285 if (saving_throw(25 + p_ptr->lev)) return;
4290 monster_race *r_ptr;
4291 GAME_TEXT m_name[MAX_NLEN];
4294 get_mon_num_prep(get_nightmare, NULL);
4296 r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
4297 power = r_ptr->level + 10;
4298 desc = r_name + r_ptr->name;
4300 get_mon_num_prep(NULL, NULL);
4303 if (!(r_ptr->flags1 & RF1_UNIQUE))
4304 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
4307 sprintf(m_name, "%s", desc);
4309 if (!(r_ptr->flags1 & RF1_UNIQUE))
4311 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
4315 if (saving_throw(p_ptr->skill_sav * 100 / power))
4317 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
4324 /* Something silly happens... */
4325 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4326 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4330 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4331 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
4334 /* Never mind; we can't see it clearly enough */
4338 /* Something frightening happens... */
4339 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4340 horror_desc[randint0(MAX_SAN_HORROR)], desc);
4342 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4344 if (!p_ptr->mimic_form)
4346 switch (p_ptr->prace)
4348 /* Demons may make a saving throw */
4351 if (saving_throw(20 + p_ptr->lev)) return;
4353 /* Undead may make a saving throw */
4358 if (saving_throw(10 + p_ptr->lev)) return;
4364 /* Demons may make a saving throw */
4365 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
4367 if (saving_throw(20 + p_ptr->lev)) return;
4369 /* Undead may make a saving throw */
4370 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
4372 if (saving_throw(10 + p_ptr->lev)) return;
4378 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
4381 if (saving_throw(p_ptr->skill_sav - power))
4387 (void)do_dec_stat(A_INT);
4388 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
4391 (void)do_dec_stat(A_WIS);
4392 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
4394 switch (randint1(21))
4397 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
4399 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
4401 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You current_world_ptr->game_turn into an utter moron!"));
4405 msg_print(_("あなたは完璧な馬鹿になった!", "You current_world_ptr->game_turn into an utter moron!"));
4408 if (p_ptr->muta3 & MUT3_HYPER_INT)
4410 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
4411 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
4413 p_ptr->muta3 |= MUT3_MORONIC;
4419 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
4421 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
4423 /* Duh, the following should never happen, but anyway... */
4424 if (p_ptr->muta3 & MUT3_FEARLESS)
4426 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
4427 p_ptr->muta3 &= ~(MUT3_FEARLESS);
4430 p_ptr->muta2 |= MUT2_COWARDICE;
4436 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
4438 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
4439 p_ptr->muta2 |= MUT2_HALLU;
4445 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
4447 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
4448 p_ptr->muta2 |= MUT2_BERS_RAGE;
4458 if (!p_ptr->resist_conf)
4460 (void)set_confused(p_ptr->confused + randint0(4) + 4);
4462 if (!p_ptr->free_act)
4464 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
4466 if (!p_ptr->resist_chaos)
4468 (void)set_image(p_ptr->image + randint0(250) + 150);
4477 if (lose_all_info())
4478 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
4482 p_ptr->update |= PU_BONUS;
4488 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
4489 * Advance experience levels and print experience
4492 void check_experience(void)
4494 bool level_reward = FALSE;
4495 bool level_mutation = FALSE;
4496 bool level_inc_stat = FALSE;
4497 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
4498 PLAYER_LEVEL old_lev = p_ptr->lev;
4500 /* Hack -- lower limit */
4501 if (p_ptr->exp < 0) p_ptr->exp = 0;
4502 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
4503 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
4505 /* Hack -- upper limit */
4506 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
4507 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
4508 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
4510 /* Hack -- maintain "max" experience */
4511 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
4513 /* Hack -- maintain "max max" experience */
4514 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
4516 /* Redraw experience */
4517 p_ptr->redraw |= (PR_EXP);
4521 /* Lose levels while possible */
4522 while ((p_ptr->lev > 1) &&
4523 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
4527 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4528 p_ptr->redraw |= (PR_LEV | PR_TITLE);
4529 p_ptr->window |= (PW_PLAYER);
4534 /* Gain levels while possible */
4535 while ((p_ptr->lev < PY_MAX_LEVEL) &&
4536 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev - 1] * p_ptr->expfact / 100L)))
4541 /* Save the highest level */
4542 if (p_ptr->lev > p_ptr->max_plv)
4544 p_ptr->max_plv = p_ptr->lev;
4546 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
4547 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
4549 level_reward = TRUE;
4551 if (p_ptr->prace == RACE_BEASTMAN)
4553 if (one_in_(5)) level_mutation = TRUE;
4555 level_inc_stat = TRUE;
4557 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
4562 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
4564 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4565 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
4566 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
4576 if (!(p_ptr->max_plv % 10))
4585 cnv_stat(p_ptr->stat_max[0], tmp);
4586 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
4587 cnv_stat(p_ptr->stat_max[1], tmp);
4588 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
4589 cnv_stat(p_ptr->stat_max[2], tmp);
4590 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
4591 cnv_stat(p_ptr->stat_max[3], tmp);
4592 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
4593 cnv_stat(p_ptr->stat_max[4], tmp);
4594 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
4595 cnv_stat(p_ptr->stat_max[5], tmp);
4596 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
4599 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
4604 if ((choice >= 'a') && (choice <= 'f')) break;
4606 for (n = 0; n < A_MAX; n++)
4607 if (n != choice - 'a')
4609 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
4611 do_inc_stat(choice - 'a');
4614 else if (!(p_ptr->max_plv % 2))
4615 do_inc_stat(randint0(6));
4620 msg_print(_("あなたは変わった気がする...", "You feel different..."));
4621 (void)gain_mutation(p_ptr, 0);
4622 level_mutation = FALSE;
4626 * 報酬でレベルが上ると再帰的に check_experience() が
4631 gain_level_reward(0);
4632 level_reward = FALSE;
4635 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4636 p_ptr->redraw |= (PR_LEV | PR_TITLE);
4637 p_ptr->window |= (PW_PLAYER | PW_SPELL);
4641 /* Load an autopick preference file */
4642 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
4646 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
4648 * @param out_val 出力先文字列ポインタ
4651 void cnv_stat(int val, char *out_val)
4656 int bonus = (val - 18);
4660 sprintf(out_val, "18/%3s", "***");
4662 else if (bonus >= 100)
4664 sprintf(out_val, "18/%03d", bonus);
4668 sprintf(out_val, " 18/%02d", bonus);
4675 sprintf(out_val, " %2d", val);
4680 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
4681 * Modify a stat value by a "modifier", return new value
4683 * @param amount 加減算値
4687 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
4688 * Or even: 18/13, 18/23, 18/33, ..., 18/220
4689 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
4690 * Or even: 18/13, 18/03, 18, 17, ..., 3
4693 s16b modify_stat_value(int value, int amount)
4700 /* Apply each point */
4701 for (i = 0; i < amount; i++)
4703 /* One point at a time */
4704 if (value < 18) value++;
4706 /* Ten "points" at a time */
4712 else if (amount < 0)
4714 /* Apply each point */
4715 for (i = 0; i < (0 - amount); i++)
4717 /* Ten points at a time */
4718 if (value >= 18 + 10) value -= 10;
4720 /* Hack -- prevent weirdness */
4721 else if (value > 18) value = 18;
4723 /* One point at a time */
4724 else if (value > 3) value--;
4728 /* Return new value */
4729 return (s16b)(value);
4735 * Hack -- Calculates the total number of points earned -JWT-
4739 long calc_score(void)
4743 u32b point, point_h, point_l;
4744 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
4746 if (!preserve_mode) mult += 10;
4747 if (!autoroller) mult += 10;
4748 if (!smart_learn) mult -= 20;
4749 if (smart_cheat) mult += 30;
4750 if (ironman_shops) mult += 50;
4751 if (ironman_small_levels) mult += 10;
4752 if (ironman_empty_levels) mult += 20;
4753 if (!powerup_home) mult += 50;
4754 if (ironman_rooms) mult += 100;
4755 if (ironman_nightmare) mult += 100;
4757 if (mult < 5) mult = 5;
4759 for (i = 0; i < max_d_idx; i++)
4760 if (max_dlv[i] > max_dl)
4761 max_dl = max_dlv[i];
4763 point_l = (p_ptr->max_max_exp + (100 * max_dl));
4764 point_h = point_l / 0x10000L;
4765 point_l = point_l % 0x10000L;
4768 point_h += point_l / 0x10000L;
4769 point_l %= 0x10000L;
4771 point_l += ((point_h % 100) << 16);
4775 point = (point_h << 16) + (point_l);
4776 if (p_ptr->arena_number >= 0)
4777 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
4779 if (ironman_downward) point *= 2;
4780 if (p_ptr->pclass == CLASS_BERSERKER)
4782 if (p_ptr->prace == RACE_SPECTRE)
4786 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
4789 if (p_ptr->total_winner) point = 2;
4791 if (easy_band) point = (0 - point);
4797 void cheat_death(player_type *creature_ptr)
4799 /* Mark social class, reset age, if needed */
4800 if (creature_ptr->sc) creature_ptr->sc = creature_ptr->age = 0;
4803 creature_ptr->age++;
4806 creature_ptr->noscore |= 0x0001;
4808 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
4811 (void)life_stream(FALSE, FALSE);
4813 if (creature_ptr->pclass == CLASS_MAGIC_EATER)
4816 for (magic_idx = 0; magic_idx < EATER_EXT * 2; magic_idx++)
4818 creature_ptr->magic_num1[magic_idx] = creature_ptr->magic_num2[magic_idx] * EATER_CHARGE;
4820 for (; magic_idx < EATER_EXT * 3; magic_idx++)
4822 creature_ptr->magic_num1[magic_idx] = 0;
4826 /* Restore spell points */
4827 creature_ptr->csp = creature_ptr->msp;
4828 creature_ptr->csp_frac = 0;
4830 /* Hack -- cancel recall */
4831 if (creature_ptr->word_recall)
4833 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
4836 /* Hack -- Prevent recall */
4837 creature_ptr->word_recall = 0;
4838 creature_ptr->redraw |= (PR_STATUS);
4841 /* Hack -- cancel alter */
4842 if (creature_ptr->alter_reality)
4844 /* Hack -- Prevent alter */
4845 creature_ptr->alter_reality = 0;
4846 creature_ptr->redraw |= (PR_STATUS);
4849 /* Note cause of death */
4850 (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
4853 creature_ptr->is_dead = FALSE;
4855 /* Hack -- Prevent starvation */
4856 (void)set_food(PY_FOOD_MAX - 1);
4858 current_floor_ptr->dun_level = 0;
4859 creature_ptr->inside_arena = FALSE;
4860 creature_ptr->inside_battle = FALSE;
4862 creature_ptr->inside_quest = 0;
4863 if (p_ptr->dungeon_idx) creature_ptr->recall_dungeon = p_ptr->dungeon_idx;
4864 p_ptr->dungeon_idx = 0;
4865 if (lite_town || vanilla_town)
4867 creature_ptr->wilderness_y = 1;
4868 creature_ptr->wilderness_x = 1;
4871 creature_ptr->oldpy = 10;
4872 creature_ptr->oldpx = 34;
4876 creature_ptr->oldpy = 33;
4877 creature_ptr->oldpx = 131;
4882 creature_ptr->wilderness_y = 48;
4883 creature_ptr->wilderness_x = 5;
4884 creature_ptr->oldpy = 33;
4885 creature_ptr->oldpx = 131;
4887 creature_ptr->wild_mode = FALSE;
4888 creature_ptr->leaving = TRUE;
4890 do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
4894 /* Prepare next floor */