7 #include "player-move.h"
8 #include "player-status.h"
9 #include "player-effects.h"
10 #include "player-skill.h"
11 #include "player-race.h"
12 #include "player-class.h"
13 #include "player-personality.h"
14 #include "player-damage.h"
16 #include "floor-events.h"
21 #include "spells-status.h"
23 #include "object-hook.h"
24 #include "object-ego.h"
26 #include "monster-status.h"
27 #include "monsterrace-hook.h"
30 #include "realm-hex.h"
31 #include "realm-song.h"
33 #include "cmd-spell.h"
35 #include "objectkind.h"
36 #include "monsterrace.h"
41 #include "view-mainwindow.h"
43 #include "cmd-magiceat.h"
46 * @brief 能力値テーブル / Abbreviations of healthy stats
48 const concptr stat_names[6] =
51 "腕力 :", "知能 :", "賢さ :", "器用 :", "耐久 :", "魅力 :"
53 "STR : ", "INT : ", "WIS : ", "DEX : ", "CON : ", "CHR : "
58 * @brief 能力値テーブル(能力低下時) / Abbreviations of damaged stats
60 const concptr stat_names_reduced[6] =
63 "腕力x:", "知能x:", "賢さx:", "器用x:", "耐久x:", "魅力x:"
65 "Str : ", "Int : ", "Wis : ", "Dex : ", "Con : ", "Chr : "
69 /* ELDRITCH_HORRORによるsanity blast処理に関するメッセージの最大数 / Number of entries in the sanity-blast descriptions */
70 #define MAX_SAN_HORROR 20 /*!< 恐ろしい対象の形容数(正常時) */
71 #define MAX_SAN_FUNNY 22 /*!< 恐ろしい対象の形容数(幻覚時) */
72 #define MAX_SAN_COMMENT 5 /*!< 恐ろしい対象を見たときの絶叫メッセージ数(幻覚時) */
76 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
78 static concptr horror_desc[MAX_SAN_HORROR] =
133 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
135 static concptr funny_desc[MAX_SAN_FUNNY] =
195 * @var funny_comments
196 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
198 static concptr funny_comments[MAX_SAN_COMMENT] =
216 * @brief 基本必要経験値テーブル /
217 * Base experience levels, may be adjusted up for race and/or class
219 const s32b player_exp[PY_MAX_LEVEL] =
274 * @brief 基本必要強化値テーブル(アンドロイド専用)
276 const s32b player_exp_a[PY_MAX_LEVEL] =
331 * 知力/賢さによるレベル毎の習得可能魔法数テーブル
332 * Stat Table (INT/WIS) -- Number of half-spells per level
334 const byte adj_mag_study[] =
361 4 /* 18/100-18/109 */,
362 4 /* 18/110-18/119 */,
363 5 /* 18/120-18/129 */,
364 5 /* 18/130-18/139 */,
365 5 /* 18/140-18/149 */,
366 5 /* 18/150-18/159 */,
367 5 /* 18/160-18/169 */,
368 5 /* 18/170-18/179 */,
369 5 /* 18/180-18/189 */,
370 5 /* 18/190-18/199 */,
371 5 /* 18/200-18/209 */,
372 6 /* 18/210-18/219 */,
378 * Stat Table (INT/WIS) -- extra 1/4-mana-points per level
380 const byte adj_mag_mana[] =
397 10 /* 18/00-18/09 */,
398 11 /* 18/10-18/19 */,
399 11 /* 18/20-18/29 */,
400 12 /* 18/30-18/39 */,
401 12 /* 18/40-18/49 */,
402 13 /* 18/50-18/59 */,
403 14 /* 18/60-18/69 */,
404 15 /* 18/70-18/79 */,
405 16 /* 18/80-18/89 */,
406 17 /* 18/90-18/99 */,
407 18 /* 18/100-18/109 */,
408 19 /* 18/110-18/119 */,
409 20 /* 18/120-18/129 */,
410 21 /* 18/130-18/139 */,
411 22 /* 18/140-18/149 */,
412 23 /* 18/150-18/159 */,
413 24 /* 18/160-18/169 */,
414 25 /* 18/170-18/179 */,
415 26 /* 18/180-18/189 */,
416 27 /* 18/190-18/199 */,
417 28 /* 18/200-18/209 */,
418 29 /* 18/210-18/219 */,
423 * 知力/賢さによる最低魔法失敗率テーブル
424 * Stat Table (INT/WIS) -- Minimum failure rate (percentage)
426 const byte adj_mag_fail[] =
453 3 /* 18/100-18/109 */,
454 2 /* 18/110-18/119 */,
455 2 /* 18/120-18/129 */,
456 2 /* 18/130-18/139 */,
457 2 /* 18/140-18/149 */,
458 1 /* 18/150-18/159 */,
459 1 /* 18/160-18/169 */,
460 1 /* 18/170-18/179 */,
461 1 /* 18/180-18/189 */,
462 1 /* 18/190-18/199 */,
463 0 /* 18/200-18/209 */,
464 0 /* 18/210-18/219 */,
469 * 知力/賢さによる魔法失敗率修正テーブル
470 * Stat Table (INT/WIS) -- Various things
472 const byte adj_mag_stat[] =
499 8 /* 18/100-18/109 */,
500 9 /* 18/110-18/119 */,
501 10 /* 18/120-18/129 */,
502 11 /* 18/130-18/139 */,
503 12 /* 18/140-18/149 */,
504 13 /* 18/150-18/159 */,
505 14 /* 18/160-18/169 */,
506 15 /* 18/170-18/179 */,
507 16 /* 18/180-18/189 */,
508 17 /* 18/190-18/199 */,
509 18 /* 18/200-18/209 */,
510 19 /* 18/210-18/219 */,
516 * Stat Table (CHR) -- payment percentages
518 const byte adj_chr_gold[] =
535 100 /* 18/00-18/09 */,
536 99 /* 18/10-18/19 */,
537 98 /* 18/20-18/29 */,
538 97 /* 18/30-18/39 */,
539 96 /* 18/40-18/49 */,
540 95 /* 18/50-18/59 */,
541 94 /* 18/60-18/69 */,
542 93 /* 18/70-18/79 */,
543 92 /* 18/80-18/89 */,
544 91 /* 18/90-18/99 */,
545 90 /* 18/100-18/109 */,
546 89 /* 18/110-18/119 */,
547 88 /* 18/120-18/129 */,
548 87 /* 18/130-18/139 */,
549 86 /* 18/140-18/149 */,
550 85 /* 18/150-18/159 */,
551 84 /* 18/160-18/169 */,
552 83 /* 18/170-18/179 */,
553 82 /* 18/180-18/189 */,
554 81 /* 18/190-18/199 */,
555 80 /* 18/200-18/209 */,
556 79 /* 18/210-18/219 */,
562 * Stat Table (INT) -- Magic devices
564 const byte adj_int_dev[] =
591 8 /* 18/100-18/109 */,
592 9 /* 18/110-18/119 */,
593 10 /* 18/120-18/129 */,
594 11 /* 18/130-18/139 */,
595 12 /* 18/140-18/149 */,
596 13 /* 18/150-18/159 */,
597 14 /* 18/160-18/169 */,
598 15 /* 18/170-18/179 */,
599 16 /* 18/180-18/189 */,
600 17 /* 18/190-18/199 */,
601 18 /* 18/200-18/209 */,
602 19 /* 18/210-18/219 */,
608 * Stat Table (WIS) -- Saving throw
610 const byte adj_wis_sav[] =
637 7 /* 18/100-18/109 */,
638 8 /* 18/110-18/119 */,
639 9 /* 18/120-18/129 */,
640 10 /* 18/130-18/139 */,
641 11 /* 18/140-18/149 */,
642 12 /* 18/150-18/159 */,
643 13 /* 18/160-18/169 */,
644 14 /* 18/170-18/179 */,
645 15 /* 18/180-18/189 */,
646 16 /* 18/190-18/199 */,
647 17 /* 18/200-18/209 */,
648 18 /* 18/210-18/219 */,
654 * Stat Table (DEX) -- disarming
656 const byte adj_dex_dis[] =
683 8 /* 18/100-18/109 */,
684 8 /* 18/110-18/119 */,
685 8 /* 18/120-18/129 */,
686 8 /* 18/130-18/139 */,
687 8 /* 18/140-18/149 */,
688 9 /* 18/150-18/159 */,
689 9 /* 18/160-18/169 */,
690 9 /* 18/170-18/179 */,
691 9 /* 18/180-18/189 */,
692 9 /* 18/190-18/199 */,
693 10 /* 18/200-18/209 */,
694 10 /* 18/210-18/219 */,
700 * Stat Table (INT) -- disarming
702 const byte adj_int_dis[] =
729 10 /* 18/100-18/109 */,
730 10 /* 18/110-18/119 */,
731 11 /* 18/120-18/129 */,
732 12 /* 18/130-18/139 */,
733 13 /* 18/140-18/149 */,
734 14 /* 18/150-18/159 */,
735 15 /* 18/160-18/169 */,
736 16 /* 18/170-18/179 */,
737 17 /* 18/180-18/189 */,
738 18 /* 18/190-18/199 */,
739 19 /* 18/200-18/209 */,
740 19 /* 18/210-18/219 */,
746 * Stat Table (DEX) -- bonus to ac (plus 128)
748 const byte adj_dex_ta[] =
765 128 + 2 /* 18/00-18/09 */,
766 128 + 2 /* 18/10-18/19 */,
767 128 + 2 /* 18/20-18/29 */,
768 128 + 2 /* 18/30-18/39 */,
769 128 + 2 /* 18/40-18/49 */,
770 128 + 3 /* 18/50-18/59 */,
771 128 + 3 /* 18/60-18/69 */,
772 128 + 3 /* 18/70-18/79 */,
773 128 + 4 /* 18/80-18/89 */,
774 128 + 5 /* 18/90-18/99 */,
775 128 + 6 /* 18/100-18/109 */,
776 128 + 7 /* 18/110-18/119 */,
777 128 + 8 /* 18/120-18/129 */,
778 128 + 9 /* 18/130-18/139 */,
779 128 + 9 /* 18/140-18/149 */,
780 128 + 10 /* 18/150-18/159 */,
781 128 + 11 /* 18/160-18/169 */,
782 128 + 12 /* 18/170-18/179 */,
783 128 + 13 /* 18/180-18/189 */,
784 128 + 14 /* 18/190-18/199 */,
785 128 + 15 /* 18/200-18/209 */,
786 128 + 15 /* 18/210-18/219 */,
787 128 + 16 /* 18/220+ */
792 * Stat Table (STR) -- bonus to dam (plus 128)
794 const byte adj_str_td[] =
811 128 + 2 /* 18/00-18/09 */,
812 128 + 2 /* 18/10-18/19 */,
813 128 + 3 /* 18/20-18/29 */,
814 128 + 3 /* 18/30-18/39 */,
815 128 + 3 /* 18/40-18/49 */,
816 128 + 3 /* 18/50-18/59 */,
817 128 + 3 /* 18/60-18/69 */,
818 128 + 4 /* 18/70-18/79 */,
819 128 + 5 /* 18/80-18/89 */,
820 128 + 5 /* 18/90-18/99 */,
821 128 + 6 /* 18/100-18/109 */,
822 128 + 7 /* 18/110-18/119 */,
823 128 + 8 /* 18/120-18/129 */,
824 128 + 9 /* 18/130-18/139 */,
825 128 + 10 /* 18/140-18/149 */,
826 128 + 11 /* 18/150-18/159 */,
827 128 + 12 /* 18/160-18/169 */,
828 128 + 13 /* 18/170-18/179 */,
829 128 + 14 /* 18/180-18/189 */,
830 128 + 15 /* 18/190-18/199 */,
831 128 + 16 /* 18/200-18/209 */,
832 128 + 18 /* 18/210-18/219 */,
833 128 + 20 /* 18/220+ */
838 * Stat Table (DEX) -- bonus to hit (plus 128)
840 const byte adj_dex_th[] =
857 128 + 3 /* 18/00-18/09 */,
858 128 + 3 /* 18/10-18/19 */,
859 128 + 3 /* 18/20-18/29 */,
860 128 + 3 /* 18/30-18/39 */,
861 128 + 3 /* 18/40-18/49 */,
862 128 + 4 /* 18/50-18/59 */,
863 128 + 4 /* 18/60-18/69 */,
864 128 + 4 /* 18/70-18/79 */,
865 128 + 4 /* 18/80-18/89 */,
866 128 + 5 /* 18/90-18/99 */,
867 128 + 6 /* 18/100-18/109 */,
868 128 + 7 /* 18/110-18/119 */,
869 128 + 8 /* 18/120-18/129 */,
870 128 + 9 /* 18/130-18/139 */,
871 128 + 9 /* 18/140-18/149 */,
872 128 + 10 /* 18/150-18/159 */,
873 128 + 11 /* 18/160-18/169 */,
874 128 + 12 /* 18/170-18/179 */,
875 128 + 13 /* 18/180-18/189 */,
876 128 + 14 /* 18/190-18/199 */,
877 128 + 15 /* 18/200-18/209 */,
878 128 + 15 /* 18/210-18/219 */,
879 128 + 16 /* 18/220+ */
884 * Stat Table (STR) -- bonus to hit (plus 128)
886 const byte adj_str_th[] =
903 128 + 1 /* 18/00-18/09 */,
904 128 + 1 /* 18/10-18/19 */,
905 128 + 1 /* 18/20-18/29 */,
906 128 + 1 /* 18/30-18/39 */,
907 128 + 1 /* 18/40-18/49 */,
908 128 + 1 /* 18/50-18/59 */,
909 128 + 1 /* 18/60-18/69 */,
910 128 + 2 /* 18/70-18/79 */,
911 128 + 3 /* 18/80-18/89 */,
912 128 + 4 /* 18/90-18/99 */,
913 128 + 5 /* 18/100-18/109 */,
914 128 + 6 /* 18/110-18/119 */,
915 128 + 7 /* 18/120-18/129 */,
916 128 + 8 /* 18/130-18/139 */,
917 128 + 9 /* 18/140-18/149 */,
918 128 + 10 /* 18/150-18/159 */,
919 128 + 11 /* 18/160-18/169 */,
920 128 + 12 /* 18/170-18/179 */,
921 128 + 13 /* 18/180-18/189 */,
922 128 + 14 /* 18/190-18/199 */,
923 128 + 15 /* 18/200-18/209 */,
924 128 + 15 /* 18/210-18/219 */,
925 128 + 16 /* 18/220+ */
930 * Stat Table (STR) -- weight limit in deca-pounds
932 const byte adj_str_wgt[] =
949 25 /* 18/00-18/09 */,
950 26 /* 18/10-18/19 */,
951 27 /* 18/20-18/29 */,
952 28 /* 18/30-18/39 */,
953 29 /* 18/40-18/49 */,
954 30 /* 18/50-18/59 */,
955 31 /* 18/60-18/69 */,
956 31 /* 18/70-18/79 */,
957 32 /* 18/80-18/89 */,
958 32 /* 18/90-18/99 */,
959 33 /* 18/100-18/109 */,
960 33 /* 18/110-18/119 */,
961 34 /* 18/120-18/129 */,
962 34 /* 18/130-18/139 */,
963 35 /* 18/140-18/149 */,
964 35 /* 18/150-18/159 */,
965 36 /* 18/160-18/169 */,
966 36 /* 18/170-18/179 */,
967 37 /* 18/180-18/189 */,
968 37 /* 18/190-18/199 */,
969 38 /* 18/200-18/209 */,
970 38 /* 18/210-18/219 */,
976 * Stat Table (STR) -- weapon weight limit in pounds
978 const byte adj_str_hold[] =
995 19 /* 18/00-18/09 */,
996 20 /* 18/10-18/19 */,
997 21 /* 18/20-18/29 */,
998 22 /* 18/30-18/39 */,
999 23 /* 18/40-18/49 */,
1000 24 /* 18/50-18/59 */,
1001 25 /* 18/60-18/69 */,
1002 26 /* 18/70-18/79 */,
1003 27 /* 18/80-18/89 */,
1004 28 /* 18/90-18/99 */,
1005 30 /* 18/100-18/109 */,
1006 31 /* 18/110-18/119 */,
1007 32 /* 18/120-18/129 */,
1008 33 /* 18/130-18/139 */,
1009 34 /* 18/140-18/149 */,
1010 35 /* 18/150-18/159 */,
1011 37 /* 18/160-18/169 */,
1012 40 /* 18/170-18/179 */,
1013 44 /* 18/180-18/189 */,
1014 48 /* 18/190-18/199 */,
1015 50 /* 18/200-18/209 */,
1016 50 /* 18/210-18/219 */,
1022 * Stat Table (STR) -- digging value
1024 const byte adj_str_dig[] =
1041 9 /* 18/00-18/09 */,
1042 10 /* 18/10-18/19 */,
1043 12 /* 18/20-18/29 */,
1044 15 /* 18/30-18/39 */,
1045 20 /* 18/40-18/49 */,
1046 25 /* 18/50-18/59 */,
1047 30 /* 18/60-18/69 */,
1048 35 /* 18/70-18/79 */,
1049 40 /* 18/80-18/89 */,
1050 45 /* 18/90-18/99 */,
1051 50 /* 18/100-18/109 */,
1052 55 /* 18/110-18/119 */,
1053 60 /* 18/120-18/129 */,
1054 65 /* 18/130-18/139 */,
1055 70 /* 18/140-18/149 */,
1056 75 /* 18/150-18/159 */,
1057 80 /* 18/160-18/169 */,
1058 85 /* 18/170-18/179 */,
1059 90 /* 18/180-18/189 */,
1060 95 /* 18/190-18/199 */,
1061 100 /* 18/200-18/209 */,
1062 100 /* 18/210-18/219 */,
1067 * 器用さによる盗難防止&体当たり成功判定修正テーブル
1068 * Stat Table (DEX) -- chance of avoiding "theft" and "falling"
1070 const byte adj_dex_safe[] =
1087 10 /* 18/00-18/09 */,
1088 10 /* 18/10-18/19 */,
1089 15 /* 18/20-18/29 */,
1090 15 /* 18/30-18/39 */,
1091 20 /* 18/40-18/49 */,
1092 25 /* 18/50-18/59 */,
1093 30 /* 18/60-18/69 */,
1094 35 /* 18/70-18/79 */,
1095 40 /* 18/80-18/89 */,
1096 45 /* 18/90-18/99 */,
1097 50 /* 18/100-18/109 */,
1098 60 /* 18/110-18/119 */,
1099 70 /* 18/120-18/129 */,
1100 80 /* 18/130-18/139 */,
1101 90 /* 18/140-18/149 */,
1102 100 /* 18/150-18/159 */,
1103 100 /* 18/160-18/169 */,
1104 100 /* 18/170-18/179 */,
1105 100 /* 18/180-18/189 */,
1106 100 /* 18/190-18/199 */,
1107 100 /* 18/200-18/209 */,
1108 100 /* 18/210-18/219 */,
1113 * 耐久による基本HP自然治癒値テーブル /
1114 * Stat Table (CON) -- base regeneration rate
1116 const byte adj_con_fix[] =
1133 2 /* 18/00-18/09 */,
1134 2 /* 18/10-18/19 */,
1135 2 /* 18/20-18/29 */,
1136 2 /* 18/30-18/39 */,
1137 2 /* 18/40-18/49 */,
1138 3 /* 18/50-18/59 */,
1139 3 /* 18/60-18/69 */,
1140 3 /* 18/70-18/79 */,
1141 3 /* 18/80-18/89 */,
1142 3 /* 18/90-18/99 */,
1143 4 /* 18/100-18/109 */,
1144 4 /* 18/110-18/119 */,
1145 5 /* 18/120-18/129 */,
1146 6 /* 18/130-18/139 */,
1147 6 /* 18/140-18/149 */,
1148 7 /* 18/150-18/159 */,
1149 7 /* 18/160-18/169 */,
1150 8 /* 18/170-18/179 */,
1151 8 /* 18/180-18/189 */,
1152 8 /* 18/190-18/199 */,
1153 9 /* 18/200-18/209 */,
1154 9 /* 18/210-18/219 */,
1159 * 耐久による基本HP自然治癒値テーブル /
1160 * Stat Table (CON) -- extra 1/4-hitpoints per level (plus 128)
1162 const byte adj_con_mhp[] =
1179 128 + 4 /* 18/00-18/09 */,
1180 128 + 5 /* 18/10-18/19 */,
1181 128 + 6 /* 18/20-18/29 */,
1182 128 + 7 /* 18/30-18/39 */,
1183 128 + 8 /* 18/40-18/49 */,
1184 128 + 9 /* 18/50-18/59 */,
1185 128 + 10 /* 18/60-18/69 */,
1186 128 + 11 /* 18/70-18/79 */,
1187 128 + 12 /* 18/80-18/89 */,
1188 128 + 14 /* 18/90-18/99 */,
1189 128 + 17 /* 18/100-18/109 */,
1190 128 + 20 /* 18/110-18/119 */,
1191 128 + 23 /* 18/120-18/129 */,
1192 128 + 26 /* 18/130-18/139 */,
1193 128 + 29 /* 18/140-18/149 */,
1194 128 + 32 /* 18/150-18/159 */,
1195 128 + 35 /* 18/160-18/169 */,
1196 128 + 38 /* 18/170-18/179 */,
1197 128 + 40 /* 18/180-18/189 */,
1198 128 + 42 /* 18/190-18/199 */,
1199 128 + 44 /* 18/200-18/209 */,
1200 128 + 46 /* 18/210-18/219 */,
1201 128 + 48 /* 18/220+ */
1206 * Stat Table (CHR) -- charm
1208 const byte adj_chr_chm[] =
1225 9 /* 18/00-18/09 */,
1226 10 /* 18/10-18/19 */,
1227 12 /* 18/20-18/29 */,
1228 15 /* 18/30-18/39 */,
1229 18 /* 18/40-18/49 */,
1230 21 /* 18/50-18/59 */,
1231 24 /* 18/60-18/69 */,
1232 28 /* 18/70-18/79 */,
1233 32 /* 18/80-18/89 */,
1234 36 /* 18/90-18/99 */,
1235 39 /* 18/100-18/109 */,
1236 42 /* 18/110-18/119 */,
1237 45 /* 18/120-18/129 */,
1238 49 /* 18/130-18/139 */,
1239 53 /* 18/140-18/149 */,
1240 57 /* 18/150-18/159 */,
1241 61 /* 18/160-18/169 */,
1242 65 /* 18/170-18/179 */,
1243 69 /* 18/180-18/189 */,
1244 73 /* 18/190-18/199 */,
1245 77 /* 18/200-18/209 */,
1246 81 /* 18/210-18/219 */,
1250 /*** Player information ***/
1253 * Static player info record
1258 * Pointer to the player info
1260 player_type *p_ptr = &p_body;
1263 * Return alignment title
1265 concptr your_alignment(player_type *creature_ptr)
1267 if (creature_ptr->align > 150) return _("大善", "Lawful");
1268 else if (creature_ptr->align > 50) return _("中善", "Good");
1269 else if (creature_ptr->align > 10) return _("小善", "Neutral Good");
1270 else if (creature_ptr->align > -11) return _("中立", "Neutral");
1271 else if (creature_ptr->align > -51) return _("小悪", "Neutral Evil");
1272 else if (creature_ptr->align > -151) return _("中悪", "Evil");
1273 else return _("大悪", "Chaotic");
1278 * Return proficiency level of weapons and misc. skills (except riding)
1280 int weapon_exp_level(int weapon_exp)
1282 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1283 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1284 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1285 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
1286 else return EXP_LEVEL_MASTER;
1291 * Return proficiency level of riding
1293 int riding_exp_level(int riding_exp)
1295 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1296 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1297 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1298 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
1299 else return EXP_LEVEL_MASTER;
1304 * Return proficiency level of spells
1306 int spell_exp_level(int spell_exp)
1308 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1309 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1310 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1311 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
1312 else return EXP_LEVEL_MASTER;
1317 * @brief プレイヤーの全ステータスを更新する /
1318 * Calculate the players current "state", taking into account
1319 * not only race/class intrinsics, but also objects being worn
1320 * and temporary spell effects.
1324 * See also calc_mana() and calc_hitpoints().
1326 * Take note of the new "speed code", in particular, a very strong
1327 * player will start slowing down as soon as he reaches 150 pounds,
1328 * but not until he reaches 450 pounds will he be half as fast as
1329 * a normal kobold. This both hurts and helps the player, hurts
1330 * because in the old days a player could just avoid 300 pounds,
1331 * and helps because now carrying 300 pounds is not very painful.
1333 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
1334 * damage, since that would affect non-combat things. These values
1335 * are actually added in later, at the appropriate place.
1337 * This function induces various "status" messages.
1340 void calc_bonuses(player_type *creature_ptr)
1344 int default_hand = 0;
1345 int empty_hands_status = empty_hands(creature_ptr, TRUE);
1348 BIT_FLAGS flgs[TR_FLAG_SIZE];
1350 bool yoiyami = FALSE;
1351 bool down_saving = FALSE;
1353 bool have_sw = FALSE, have_kabe = FALSE;
1354 bool easy_2weapon = FALSE;
1355 bool riding_levitation = FALSE;
1356 OBJECT_IDX this_o_idx, next_o_idx = 0;
1357 const player_race *tmp_rp_ptr;
1359 /* Save the old vision stuff */
1360 bool old_telepathy = creature_ptr->telepathy;
1361 bool old_esp_animal = creature_ptr->esp_animal;
1362 bool old_esp_undead = creature_ptr->esp_undead;
1363 bool old_esp_demon = creature_ptr->esp_demon;
1364 bool old_esp_orc = creature_ptr->esp_orc;
1365 bool old_esp_troll = creature_ptr->esp_troll;
1366 bool old_esp_giant = creature_ptr->esp_giant;
1367 bool old_esp_dragon = creature_ptr->esp_dragon;
1368 bool old_esp_human = creature_ptr->esp_human;
1369 bool old_esp_evil = creature_ptr->esp_evil;
1370 bool old_esp_good = creature_ptr->esp_good;
1371 bool old_esp_nonliving = creature_ptr->esp_nonliving;
1372 bool old_esp_unique = creature_ptr->esp_unique;
1373 bool old_see_inv = creature_ptr->see_inv;
1374 bool old_mighty_throw = creature_ptr->mighty_throw;
1376 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1377 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
1379 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
1380 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
1382 extra_blows[0] = extra_blows[1] = 0;
1384 for (int i = 0; i < A_MAX; i++) creature_ptr->stat_add[i] = 0;
1386 creature_ptr->dis_ac = creature_ptr->ac = 0;
1387 creature_ptr->dis_to_h[0] = creature_ptr->to_h[0] = 0;
1388 creature_ptr->dis_to_h[1] = creature_ptr->to_h[1] = 0;
1389 creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0;
1390 creature_ptr->dis_to_d[1] = creature_ptr->to_d[1] = 0;
1391 creature_ptr->dis_to_h_b = creature_ptr->to_h_b = 0;
1392 creature_ptr->dis_to_a = creature_ptr->to_a = 0;
1393 creature_ptr->to_h_m = 0;
1394 creature_ptr->to_d_m = 0;
1395 creature_ptr->to_m_chance = 0;
1396 creature_ptr->to_dd[0] = creature_ptr->to_ds[0] = 0;
1397 creature_ptr->to_dd[1] = creature_ptr->to_ds[1] = 0;
1400 creature_ptr->num_blow[0] = 1;
1401 creature_ptr->num_blow[1] = 1;
1402 creature_ptr->num_fire = 100;
1403 creature_ptr->tval_xtra = 0;
1404 creature_ptr->tval_ammo = 0;
1405 creature_ptr->cursed = 0L;
1406 creature_ptr->bless_blade = FALSE;
1407 creature_ptr->xtra_might = FALSE;
1408 creature_ptr->impact[0] = FALSE;
1409 creature_ptr->impact[1] = FALSE;
1410 creature_ptr->pass_wall = FALSE;
1411 creature_ptr->kill_wall = FALSE;
1412 creature_ptr->dec_mana = FALSE;
1413 creature_ptr->easy_spell = FALSE;
1414 creature_ptr->heavy_spell = FALSE;
1415 creature_ptr->see_inv = FALSE;
1416 creature_ptr->free_act = FALSE;
1417 creature_ptr->slow_digest = FALSE;
1418 creature_ptr->regenerate = FALSE;
1419 creature_ptr->can_swim = FALSE;
1420 creature_ptr->levitation = FALSE;
1421 creature_ptr->hold_exp = FALSE;
1422 creature_ptr->telepathy = FALSE;
1423 creature_ptr->esp_animal = FALSE;
1424 creature_ptr->esp_undead = FALSE;
1425 creature_ptr->esp_demon = FALSE;
1426 creature_ptr->esp_orc = FALSE;
1427 creature_ptr->esp_troll = FALSE;
1428 creature_ptr->esp_giant = FALSE;
1429 creature_ptr->esp_dragon = FALSE;
1430 creature_ptr->esp_human = FALSE;
1431 creature_ptr->esp_evil = FALSE;
1432 creature_ptr->esp_good = FALSE;
1433 creature_ptr->esp_nonliving = FALSE;
1434 creature_ptr->esp_unique = FALSE;
1435 creature_ptr->lite = FALSE;
1436 creature_ptr->sustain_str = FALSE;
1437 creature_ptr->sustain_int = FALSE;
1438 creature_ptr->sustain_wis = FALSE;
1439 creature_ptr->sustain_con = FALSE;
1440 creature_ptr->sustain_dex = FALSE;
1441 creature_ptr->sustain_chr = FALSE;
1442 creature_ptr->resist_acid = FALSE;
1443 creature_ptr->resist_elec = FALSE;
1444 creature_ptr->resist_fire = FALSE;
1445 creature_ptr->resist_cold = FALSE;
1446 creature_ptr->resist_pois = FALSE;
1447 creature_ptr->resist_conf = FALSE;
1448 creature_ptr->resist_sound = FALSE;
1449 creature_ptr->resist_lite = FALSE;
1450 creature_ptr->resist_dark = FALSE;
1451 creature_ptr->resist_chaos = FALSE;
1452 creature_ptr->resist_disen = FALSE;
1453 creature_ptr->resist_shard = FALSE;
1454 creature_ptr->resist_nexus = FALSE;
1455 creature_ptr->resist_blind = FALSE;
1456 creature_ptr->resist_neth = FALSE;
1457 creature_ptr->resist_time = FALSE;
1458 creature_ptr->resist_water = FALSE;
1459 creature_ptr->resist_fear = FALSE;
1460 creature_ptr->reflect = FALSE;
1461 creature_ptr->sh_fire = FALSE;
1462 creature_ptr->sh_elec = FALSE;
1463 creature_ptr->sh_cold = FALSE;
1464 creature_ptr->anti_magic = FALSE;
1465 creature_ptr->anti_tele = FALSE;
1466 creature_ptr->warning = FALSE;
1467 creature_ptr->mighty_throw = FALSE;
1468 creature_ptr->see_nocto = FALSE;
1469 creature_ptr->immune_acid = FALSE;
1470 creature_ptr->immune_elec = FALSE;
1471 creature_ptr->immune_fire = FALSE;
1472 creature_ptr->immune_cold = FALSE;
1473 creature_ptr->ryoute = FALSE;
1474 creature_ptr->migite = FALSE;
1475 creature_ptr->hidarite = FALSE;
1476 creature_ptr->no_flowed = FALSE;
1478 if (creature_ptr->mimic_form) tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1479 else tmp_rp_ptr = &race_info[creature_ptr->prace];
1481 creature_ptr->see_infra = tmp_rp_ptr->infra;
1482 creature_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
1483 creature_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
1484 creature_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
1485 creature_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
1486 creature_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
1487 creature_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
1488 creature_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
1489 creature_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
1490 creature_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
1491 creature_ptr->skill_dig = 0;
1493 if (has_melee_weapon(creature_ptr, INVEN_RARM)) creature_ptr->migite = TRUE;
1494 if (has_melee_weapon(creature_ptr, INVEN_LARM))
1496 creature_ptr->hidarite = TRUE;
1497 if (!creature_ptr->migite) default_hand = 1;
1500 if (can_two_hands_wielding(creature_ptr))
1502 if (creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) &&
1503 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM]))
1505 creature_ptr->ryoute = TRUE;
1507 else if (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) &&
1508 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM]))
1510 creature_ptr->ryoute = TRUE;
1514 switch (creature_ptr->pclass)
1517 case CLASS_FORCETRAINER:
1518 case CLASS_BERSERKER:
1519 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
1521 creature_ptr->migite = TRUE;
1522 creature_ptr->ryoute = TRUE;
1529 if (!creature_ptr->migite && !creature_ptr->hidarite)
1531 if (empty_hands_status & EMPTY_HAND_RARM) creature_ptr->migite = TRUE;
1532 else if (empty_hands_status == EMPTY_HAND_LARM)
1534 creature_ptr->hidarite = TRUE;
1539 if (creature_ptr->special_defense & KAMAE_MASK)
1541 if (!(empty_hands_status & EMPTY_HAND_RARM))
1543 set_action(creature_ptr, ACTION_NONE);
1547 switch (creature_ptr->pclass)
1550 if (creature_ptr->lev > 29) creature_ptr->resist_fear = TRUE;
1551 if (creature_ptr->lev > 44) creature_ptr->regenerate = TRUE;
1554 if (creature_ptr->lev > 39) creature_ptr->resist_fear = TRUE;
1556 case CLASS_CHAOS_WARRIOR:
1557 if (creature_ptr->lev > 29) creature_ptr->resist_chaos = TRUE;
1558 if (creature_ptr->lev > 39) creature_ptr->resist_fear = TRUE;
1560 case CLASS_MINDCRAFTER:
1561 if (creature_ptr->lev > 9) creature_ptr->resist_fear = TRUE;
1562 if (creature_ptr->lev > 19) creature_ptr->sustain_wis = TRUE;
1563 if (creature_ptr->lev > 29) creature_ptr->resist_conf = TRUE;
1564 if (creature_ptr->lev > 39) creature_ptr->telepathy = TRUE;
1567 case CLASS_FORCETRAINER:
1568 if (!(heavy_armor(creature_ptr)))
1570 if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
1571 PRACE_IS_(creature_ptr, RACE_SPRITE) ||
1572 (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
1573 new_speed += (creature_ptr->lev) / 10;
1575 if (creature_ptr->lev > 24)
1576 creature_ptr->free_act = TRUE;
1580 case CLASS_SORCERER:
1581 creature_ptr->to_a -= 50;
1582 creature_ptr->dis_to_a -= 50;
1585 creature_ptr->resist_sound = TRUE;
1588 if (creature_ptr->lev > 29) creature_ptr->resist_fear = TRUE;
1590 case CLASS_BERSERKER:
1591 creature_ptr->shero = 1;
1592 creature_ptr->sustain_str = TRUE;
1593 creature_ptr->sustain_dex = TRUE;
1594 creature_ptr->sustain_con = TRUE;
1595 creature_ptr->regenerate = TRUE;
1596 creature_ptr->free_act = TRUE;
1598 if (creature_ptr->lev > 29) new_speed++;
1599 if (creature_ptr->lev > 39) new_speed++;
1600 if (creature_ptr->lev > 44) new_speed++;
1601 if (creature_ptr->lev > 49) new_speed++;
1602 creature_ptr->to_a += 10 + creature_ptr->lev / 2;
1603 creature_ptr->dis_to_a += 10 + creature_ptr->lev / 2;
1604 creature_ptr->skill_dig += (100 + creature_ptr->lev * 8);
1605 if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
1606 creature_ptr->redraw |= PR_STATUS;
1608 case CLASS_MIRROR_MASTER:
1609 if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
1612 if (heavy_armor(creature_ptr))
1614 new_speed -= (creature_ptr->lev) / 10;
1615 creature_ptr->skill_stl -= (creature_ptr->lev) / 10;
1617 else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
1618 (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
1621 if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
1622 PRACE_IS_(creature_ptr, RACE_SPRITE) ||
1623 (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
1624 new_speed += (creature_ptr->lev) / 10;
1625 creature_ptr->skill_stl += (creature_ptr->lev) / 10;
1626 if (creature_ptr->lev > 24)
1627 creature_ptr->free_act = TRUE;
1630 if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
1631 (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
1633 creature_ptr->to_a += creature_ptr->lev / 2 + 5;
1634 creature_ptr->dis_to_a += creature_ptr->lev / 2 + 5;
1637 creature_ptr->slow_digest = TRUE;
1638 creature_ptr->resist_fear = TRUE;
1639 if (creature_ptr->lev > 19) creature_ptr->resist_pois = TRUE;
1640 if (creature_ptr->lev > 24) creature_ptr->sustain_dex = TRUE;
1641 if (creature_ptr->lev > 29) creature_ptr->see_inv = TRUE;
1642 if (creature_ptr->lev > 44)
1644 creature_ptr->oppose_pois = 1;
1645 creature_ptr->redraw |= PR_STATUS;
1648 creature_ptr->see_nocto = TRUE;
1652 if (creature_ptr->mimic_form)
1654 switch (creature_ptr->mimic_form)
1657 creature_ptr->hold_exp = TRUE;
1658 creature_ptr->resist_chaos = TRUE;
1659 creature_ptr->resist_neth = TRUE;
1660 creature_ptr->resist_fire = TRUE;
1661 creature_ptr->oppose_fire = 1;
1662 creature_ptr->see_inv = TRUE;
1664 creature_ptr->redraw |= PR_STATUS;
1665 creature_ptr->to_a += 10;
1666 creature_ptr->dis_to_a += 10;
1668 case MIMIC_DEMON_LORD:
1669 creature_ptr->hold_exp = TRUE;
1670 creature_ptr->resist_chaos = TRUE;
1671 creature_ptr->resist_neth = TRUE;
1672 creature_ptr->immune_fire = TRUE;
1673 creature_ptr->resist_acid = TRUE;
1674 creature_ptr->resist_fire = TRUE;
1675 creature_ptr->resist_cold = TRUE;
1676 creature_ptr->resist_elec = TRUE;
1677 creature_ptr->resist_pois = TRUE;
1678 creature_ptr->resist_conf = TRUE;
1679 creature_ptr->resist_disen = TRUE;
1680 creature_ptr->resist_nexus = TRUE;
1681 creature_ptr->resist_fear = TRUE;
1682 creature_ptr->sh_fire = TRUE;
1683 creature_ptr->see_inv = TRUE;
1684 creature_ptr->telepathy = TRUE;
1685 creature_ptr->levitation = TRUE;
1686 creature_ptr->kill_wall = TRUE;
1688 creature_ptr->to_a += 20;
1689 creature_ptr->dis_to_a += 20;
1692 creature_ptr->resist_dark = TRUE;
1693 creature_ptr->hold_exp = TRUE;
1694 creature_ptr->resist_neth = TRUE;
1695 creature_ptr->resist_cold = TRUE;
1696 creature_ptr->resist_pois = TRUE;
1697 creature_ptr->see_inv = TRUE;
1699 creature_ptr->to_a += 10;
1700 creature_ptr->dis_to_a += 10;
1701 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1707 switch (creature_ptr->prace)
1710 creature_ptr->resist_lite = TRUE;
1713 creature_ptr->hold_exp = TRUE;
1716 creature_ptr->free_act = TRUE;
1719 creature_ptr->resist_blind = TRUE;
1722 creature_ptr->resist_dark = TRUE;
1724 case RACE_HALF_TROLL:
1725 creature_ptr->sustain_str = TRUE;
1727 if (creature_ptr->lev > 14)
1729 creature_ptr->regenerate = TRUE;
1730 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER)
1732 creature_ptr->slow_digest = TRUE;
1733 /* Let's not make Regeneration
1734 * a disadvantage for the poor warriors who can
1735 * never learn a spell that satisfies hunger (actually
1736 * neither can rogues, but half-trolls are not
1737 * supposed to play rogues) */
1742 creature_ptr->sustain_con = TRUE;
1743 creature_ptr->regenerate = TRUE;
1746 creature_ptr->resist_lite = TRUE;
1747 creature_ptr->see_inv = TRUE;
1749 case RACE_BARBARIAN:
1750 creature_ptr->resist_fear = TRUE;
1752 case RACE_HALF_OGRE:
1753 creature_ptr->resist_dark = TRUE;
1754 creature_ptr->sustain_str = TRUE;
1756 case RACE_HALF_GIANT:
1757 creature_ptr->sustain_str = TRUE;
1758 creature_ptr->resist_shard = TRUE;
1760 case RACE_HALF_TITAN:
1761 creature_ptr->resist_chaos = TRUE;
1764 creature_ptr->resist_sound = TRUE;
1767 creature_ptr->resist_acid = TRUE;
1768 if (creature_ptr->lev > 19) creature_ptr->immune_acid = TRUE;
1771 creature_ptr->resist_conf = TRUE;
1772 creature_ptr->resist_acid = TRUE;
1773 new_speed += (creature_ptr->lev) / 10;
1776 creature_ptr->resist_pois = TRUE;
1779 creature_ptr->resist_disen = TRUE;
1780 creature_ptr->resist_dark = TRUE;
1783 creature_ptr->resist_dark = TRUE;
1784 if (creature_ptr->lev > 19) creature_ptr->see_inv = TRUE;
1786 case RACE_DRACONIAN:
1787 creature_ptr->levitation = TRUE;
1788 if (creature_ptr->lev > 4) creature_ptr->resist_fire = TRUE;
1789 if (creature_ptr->lev > 9) creature_ptr->resist_cold = TRUE;
1790 if (creature_ptr->lev > 14) creature_ptr->resist_acid = TRUE;
1791 if (creature_ptr->lev > 19) creature_ptr->resist_elec = TRUE;
1792 if (creature_ptr->lev > 34) creature_ptr->resist_pois = TRUE;
1794 case RACE_MIND_FLAYER:
1795 creature_ptr->sustain_int = TRUE;
1796 creature_ptr->sustain_wis = TRUE;
1797 if (creature_ptr->lev > 14) creature_ptr->see_inv = TRUE;
1798 if (creature_ptr->lev > 29) creature_ptr->telepathy = TRUE;
1801 creature_ptr->resist_fire = TRUE;
1802 if (creature_ptr->lev > 9) creature_ptr->see_inv = TRUE;
1805 creature_ptr->slow_digest = TRUE;
1806 creature_ptr->free_act = TRUE;
1807 creature_ptr->see_inv = TRUE;
1808 creature_ptr->resist_pois = TRUE;
1809 if (creature_ptr->lev > 34) creature_ptr->hold_exp = TRUE;
1812 creature_ptr->resist_shard = TRUE;
1813 creature_ptr->hold_exp = TRUE;
1814 creature_ptr->see_inv = TRUE;
1815 creature_ptr->resist_pois = TRUE;
1816 if (creature_ptr->lev > 9) creature_ptr->resist_cold = TRUE;
1819 creature_ptr->resist_neth = TRUE;
1820 creature_ptr->hold_exp = TRUE;
1821 creature_ptr->see_inv = TRUE;
1822 creature_ptr->resist_pois = TRUE;
1823 creature_ptr->slow_digest = TRUE;
1824 if (creature_ptr->lev > 4) creature_ptr->resist_cold = TRUE;
1827 creature_ptr->resist_dark = TRUE;
1828 creature_ptr->hold_exp = TRUE;
1829 creature_ptr->resist_neth = TRUE;
1830 creature_ptr->resist_cold = TRUE;
1831 creature_ptr->resist_pois = TRUE;
1832 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1835 creature_ptr->levitation = TRUE;
1836 creature_ptr->free_act = TRUE;
1837 creature_ptr->resist_neth = TRUE;
1838 creature_ptr->hold_exp = TRUE;
1839 creature_ptr->see_inv = TRUE;
1840 creature_ptr->resist_pois = TRUE;
1841 creature_ptr->slow_digest = TRUE;
1842 creature_ptr->resist_cold = TRUE;
1843 creature_ptr->pass_wall = TRUE;
1844 if (creature_ptr->lev > 34) creature_ptr->telepathy = TRUE;
1847 creature_ptr->levitation = TRUE;
1848 creature_ptr->resist_lite = TRUE;
1850 new_speed += (creature_ptr->lev) / 10;
1853 creature_ptr->resist_conf = TRUE;
1854 creature_ptr->resist_sound = TRUE;
1857 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
1858 creature_ptr->skill_dig += creature_ptr->lev * 10;
1860 if (creature_ptr->lev > 25) creature_ptr->stat_add[A_STR]++;
1861 if (creature_ptr->lev > 40) creature_ptr->stat_add[A_STR]++;
1862 if (creature_ptr->lev > 45) creature_ptr->stat_add[A_STR]++;
1864 if (creature_ptr->lev > 25) creature_ptr->stat_add[A_DEX]--;
1865 if (creature_ptr->lev > 40) creature_ptr->stat_add[A_DEX]--;
1866 if (creature_ptr->lev > 45) creature_ptr->stat_add[A_DEX]--;
1868 if (creature_ptr->lev > 25) creature_ptr->stat_add[A_CON]++;
1869 if (creature_ptr->lev > 40) creature_ptr->stat_add[A_CON]++;
1870 if (creature_ptr->lev > 45) creature_ptr->stat_add[A_CON]++;
1873 creature_ptr->levitation = TRUE;
1874 creature_ptr->see_inv = TRUE;
1877 creature_ptr->resist_fire = TRUE;
1878 creature_ptr->resist_neth = TRUE;
1879 creature_ptr->hold_exp = TRUE;
1880 if (creature_ptr->lev > 9) creature_ptr->see_inv = TRUE;
1881 if (creature_ptr->lev > 44)
1883 creature_ptr->oppose_fire = 1;
1884 creature_ptr->redraw |= PR_STATUS;
1889 creature_ptr->sustain_con = TRUE;
1892 creature_ptr->levitation = TRUE;
1895 creature_ptr->resist_conf = TRUE;
1898 creature_ptr->slow_digest = TRUE;
1899 creature_ptr->free_act = TRUE;
1900 creature_ptr->resist_pois = TRUE;
1901 creature_ptr->hold_exp = TRUE;
1904 creature_ptr->resist_water = TRUE;
1911 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU))
1913 creature_ptr->see_inv = TRUE;
1914 creature_ptr->free_act = TRUE;
1915 creature_ptr->slow_digest = TRUE;
1916 creature_ptr->regenerate = TRUE;
1917 creature_ptr->levitation = TRUE;
1918 creature_ptr->hold_exp = TRUE;
1919 creature_ptr->telepathy = TRUE;
1920 creature_ptr->lite = TRUE;
1921 creature_ptr->sustain_str = TRUE;
1922 creature_ptr->sustain_int = TRUE;
1923 creature_ptr->sustain_wis = TRUE;
1924 creature_ptr->sustain_con = TRUE;
1925 creature_ptr->sustain_dex = TRUE;
1926 creature_ptr->sustain_chr = TRUE;
1927 creature_ptr->resist_acid = TRUE;
1928 creature_ptr->resist_elec = TRUE;
1929 creature_ptr->resist_fire = TRUE;
1930 creature_ptr->resist_cold = TRUE;
1931 creature_ptr->resist_pois = TRUE;
1932 creature_ptr->resist_conf = TRUE;
1933 creature_ptr->resist_sound = TRUE;
1934 creature_ptr->resist_lite = TRUE;
1935 creature_ptr->resist_dark = TRUE;
1936 creature_ptr->resist_chaos = TRUE;
1937 creature_ptr->resist_disen = TRUE;
1938 creature_ptr->resist_shard = TRUE;
1939 creature_ptr->resist_nexus = TRUE;
1940 creature_ptr->resist_blind = TRUE;
1941 creature_ptr->resist_neth = TRUE;
1942 creature_ptr->resist_fear = TRUE;
1943 creature_ptr->reflect = TRUE;
1944 creature_ptr->sh_fire = TRUE;
1945 creature_ptr->sh_elec = TRUE;
1946 creature_ptr->sh_cold = TRUE;
1947 creature_ptr->to_a += 100;
1948 creature_ptr->dis_to_a += 100;
1950 else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef)
1952 creature_ptr->to_a += 50;
1953 creature_ptr->dis_to_a += 50;
1956 if (creature_ptr->tim_res_nether)
1958 creature_ptr->resist_neth = TRUE;
1961 if (creature_ptr->tim_sh_fire)
1963 creature_ptr->sh_fire = TRUE;
1966 if (creature_ptr->tim_res_time)
1968 creature_ptr->resist_time = TRUE;
1971 if (creature_ptr->pseikaku == SEIKAKU_SEXY) creature_ptr->cursed |= (TRC_AGGRAVATE);
1972 if (creature_ptr->pseikaku == SEIKAKU_NAMAKE) creature_ptr->to_m_chance += 10;
1973 if (creature_ptr->pseikaku == SEIKAKU_KIREMONO) creature_ptr->to_m_chance -= 3;
1974 if ((creature_ptr->pseikaku == SEIKAKU_GAMAN) || (creature_ptr->pseikaku == SEIKAKU_CHIKARA)) creature_ptr->to_m_chance++;
1975 if (creature_ptr->pseikaku == SEIKAKU_CHARGEMAN)
1977 creature_ptr->to_m_chance += 5;
1978 creature_ptr->resist_conf = TRUE;
1981 if (creature_ptr->pseikaku == SEIKAKU_LUCKY) creature_ptr->muta3 |= MUT3_GOOD_LUCK;
1982 if (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)
1984 creature_ptr->resist_blind = TRUE;
1985 creature_ptr->resist_conf = TRUE;
1986 creature_ptr->hold_exp = TRUE;
1987 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1989 if ((creature_ptr->prace != RACE_KLACKON) && (creature_ptr->prace != RACE_SPRITE))
1990 new_speed += (creature_ptr->lev) / 10 + 5;
1993 if (music_singing(creature_ptr, MUSIC_WALL))
1995 creature_ptr->kill_wall = TRUE;
1998 for (int i = 0; i < A_MAX; i++)
2000 creature_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
2003 if (creature_ptr->muta3)
2005 if (creature_ptr->muta3 & MUT3_HYPER_STR)
2007 creature_ptr->stat_add[A_STR] += 4;
2010 if (creature_ptr->muta3 & MUT3_PUNY)
2012 creature_ptr->stat_add[A_STR] -= 4;
2015 if (creature_ptr->muta3 & MUT3_HYPER_INT)
2017 creature_ptr->stat_add[A_INT] += 4;
2018 creature_ptr->stat_add[A_WIS] += 4;
2021 if (creature_ptr->muta3 & MUT3_MORONIC)
2023 creature_ptr->stat_add[A_INT] -= 4;
2024 creature_ptr->stat_add[A_WIS] -= 4;
2027 if (creature_ptr->muta3 & MUT3_RESILIENT)
2029 creature_ptr->stat_add[A_CON] += 4;
2032 if (creature_ptr->muta3 & MUT3_XTRA_FAT)
2034 creature_ptr->stat_add[A_CON] += 2;
2038 if (creature_ptr->muta3 & MUT3_ALBINO)
2040 creature_ptr->stat_add[A_CON] -= 4;
2043 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
2045 creature_ptr->stat_add[A_CON] -= 2;
2046 creature_ptr->stat_add[A_CHR] -= 1;
2047 creature_ptr->regenerate = FALSE;
2050 if (creature_ptr->muta3 & MUT3_SILLY_VOI)
2052 creature_ptr->stat_add[A_CHR] -= 4;
2055 if (creature_ptr->muta3 & MUT3_BLANK_FAC)
2057 creature_ptr->stat_add[A_CHR] -= 1;
2060 if (creature_ptr->muta3 & MUT3_XTRA_EYES)
2062 creature_ptr->skill_fos += 15;
2063 creature_ptr->skill_srh += 15;
2066 if (creature_ptr->muta3 & MUT3_MAGIC_RES)
2068 creature_ptr->skill_sav += (15 + (creature_ptr->lev / 5));
2071 if (creature_ptr->muta3 & MUT3_XTRA_NOIS)
2073 creature_ptr->skill_stl -= 3;
2076 if (creature_ptr->muta3 & MUT3_INFRAVIS)
2078 creature_ptr->see_infra += 3;
2081 if (creature_ptr->muta3 & MUT3_XTRA_LEGS)
2086 if (creature_ptr->muta3 & MUT3_SHORT_LEG)
2091 if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
2093 creature_ptr->sh_elec = TRUE;
2096 if (creature_ptr->muta3 & MUT3_FIRE_BODY)
2098 creature_ptr->sh_fire = TRUE;
2099 creature_ptr->lite = TRUE;
2102 if (creature_ptr->muta3 & MUT3_WART_SKIN)
2104 creature_ptr->stat_add[A_CHR] -= 2;
2105 creature_ptr->to_a += 5;
2106 creature_ptr->dis_to_a += 5;
2109 if (creature_ptr->muta3 & MUT3_SCALES)
2111 creature_ptr->stat_add[A_CHR] -= 1;
2112 creature_ptr->to_a += 10;
2113 creature_ptr->dis_to_a += 10;
2116 if (creature_ptr->muta3 & MUT3_IRON_SKIN)
2118 creature_ptr->stat_add[A_DEX] -= 1;
2119 creature_ptr->to_a += 25;
2120 creature_ptr->dis_to_a += 25;
2123 if (creature_ptr->muta3 & MUT3_WINGS)
2125 creature_ptr->levitation = TRUE;
2128 if (creature_ptr->muta3 & MUT3_FEARLESS)
2130 creature_ptr->resist_fear = TRUE;
2133 if (creature_ptr->muta3 & MUT3_REGEN)
2135 creature_ptr->regenerate = TRUE;
2138 if (creature_ptr->muta3 & MUT3_ESP)
2140 creature_ptr->telepathy = TRUE;
2143 if (creature_ptr->muta3 & MUT3_LIMBER)
2145 creature_ptr->stat_add[A_DEX] += 3;
2148 if (creature_ptr->muta3 & MUT3_ARTHRITIS)
2150 creature_ptr->stat_add[A_DEX] -= 3;
2153 if (creature_ptr->muta3 & MUT3_MOTION)
2155 creature_ptr->free_act = TRUE;
2156 creature_ptr->skill_stl += 1;
2159 if (creature_ptr->muta3 & MUT3_ILL_NORM)
2161 creature_ptr->stat_add[A_CHR] = 0;
2165 if (creature_ptr->tsuyoshi)
2167 creature_ptr->stat_add[A_STR] += 4;
2168 creature_ptr->stat_add[A_CON] += 4;
2171 for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
2173 int bonus_to_h, bonus_to_d;
2174 o_ptr = &creature_ptr->inventory_list[i];
2175 if (!o_ptr->k_idx) continue;
2177 object_flags(o_ptr, flgs);
2179 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
2180 if (o_ptr->name1 == ART_CHAINSWORD) creature_ptr->cursed |= TRC_CHAINSWORD;
2182 if (have_flag(flgs, TR_STR)) creature_ptr->stat_add[A_STR] += o_ptr->pval;
2183 if (have_flag(flgs, TR_INT)) creature_ptr->stat_add[A_INT] += o_ptr->pval;
2184 if (have_flag(flgs, TR_WIS)) creature_ptr->stat_add[A_WIS] += o_ptr->pval;
2185 if (have_flag(flgs, TR_DEX)) creature_ptr->stat_add[A_DEX] += o_ptr->pval;
2186 if (have_flag(flgs, TR_CON)) creature_ptr->stat_add[A_CON] += o_ptr->pval;
2187 if (have_flag(flgs, TR_CHR)) creature_ptr->stat_add[A_CHR] += o_ptr->pval;
2188 if (have_flag(flgs, TR_MAGIC_MASTERY)) creature_ptr->skill_dev += 8 * o_ptr->pval;
2189 if (have_flag(flgs, TR_STEALTH)) creature_ptr->skill_stl += o_ptr->pval;
2190 if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_srh += (o_ptr->pval * 5);
2191 if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_fos += (o_ptr->pval * 5);
2192 if (have_flag(flgs, TR_INFRA)) creature_ptr->see_infra += o_ptr->pval;
2193 if (have_flag(flgs, TR_TUNNEL)) creature_ptr->skill_dig += (o_ptr->pval * 20);
2194 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
2195 if (have_flag(flgs, TR_BLOWS))
2197 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !creature_ptr->ryoute) extra_blows[0] += o_ptr->pval;
2198 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !creature_ptr->ryoute) extra_blows[1] += o_ptr->pval;
2199 else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
2202 if (have_flag(flgs, TR_IMPACT)) creature_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
2203 if (have_flag(flgs, TR_AGGRAVATE)) creature_ptr->cursed |= TRC_AGGRAVATE;
2204 if (have_flag(flgs, TR_DRAIN_EXP)) creature_ptr->cursed |= TRC_DRAIN_EXP;
2205 if (have_flag(flgs, TR_TY_CURSE)) creature_ptr->cursed |= TRC_TY_CURSE;
2206 if (have_flag(flgs, TR_ADD_L_CURSE)) creature_ptr->cursed |= TRC_ADD_L_CURSE;
2207 if (have_flag(flgs, TR_ADD_H_CURSE)) creature_ptr->cursed |= TRC_ADD_H_CURSE;
2208 if (have_flag(flgs, TR_DRAIN_HP)) creature_ptr->cursed |= TRC_DRAIN_HP;
2209 if (have_flag(flgs, TR_DRAIN_MANA)) creature_ptr->cursed |= TRC_DRAIN_MANA;
2210 if (have_flag(flgs, TR_CALL_ANIMAL)) creature_ptr->cursed |= TRC_CALL_ANIMAL;
2211 if (have_flag(flgs, TR_CALL_DEMON)) creature_ptr->cursed |= TRC_CALL_DEMON;
2212 if (have_flag(flgs, TR_CALL_DRAGON)) creature_ptr->cursed |= TRC_CALL_DRAGON;
2213 if (have_flag(flgs, TR_CALL_UNDEAD)) creature_ptr->cursed |= TRC_CALL_UNDEAD;
2214 if (have_flag(flgs, TR_COWARDICE)) creature_ptr->cursed |= TRC_COWARDICE;
2215 if (have_flag(flgs, TR_LOW_MELEE)) creature_ptr->cursed |= TRC_LOW_MELEE;
2216 if (have_flag(flgs, TR_LOW_AC)) creature_ptr->cursed |= TRC_LOW_AC;
2217 if (have_flag(flgs, TR_LOW_MAGIC)) creature_ptr->cursed |= TRC_LOW_MAGIC;
2218 if (have_flag(flgs, TR_FAST_DIGEST)) creature_ptr->cursed |= TRC_FAST_DIGEST;
2219 if (have_flag(flgs, TR_SLOW_REGEN)) creature_ptr->cursed |= TRC_SLOW_REGEN;
2220 if (have_flag(flgs, TR_DEC_MANA)) creature_ptr->dec_mana = TRUE;
2221 if (have_flag(flgs, TR_BLESSED)) creature_ptr->bless_blade = TRUE;
2222 if (have_flag(flgs, TR_XTRA_MIGHT)) creature_ptr->xtra_might = TRUE;
2223 if (have_flag(flgs, TR_SLOW_DIGEST)) creature_ptr->slow_digest = TRUE;
2224 if (have_flag(flgs, TR_REGEN)) creature_ptr->regenerate = TRUE;
2225 if (have_flag(flgs, TR_TELEPATHY)) creature_ptr->telepathy = TRUE;
2226 if (have_flag(flgs, TR_ESP_ANIMAL)) creature_ptr->esp_animal = TRUE;
2227 if (have_flag(flgs, TR_ESP_UNDEAD)) creature_ptr->esp_undead = TRUE;
2228 if (have_flag(flgs, TR_ESP_DEMON)) creature_ptr->esp_demon = TRUE;
2229 if (have_flag(flgs, TR_ESP_ORC)) creature_ptr->esp_orc = TRUE;
2230 if (have_flag(flgs, TR_ESP_TROLL)) creature_ptr->esp_troll = TRUE;
2231 if (have_flag(flgs, TR_ESP_GIANT)) creature_ptr->esp_giant = TRUE;
2232 if (have_flag(flgs, TR_ESP_DRAGON)) creature_ptr->esp_dragon = TRUE;
2233 if (have_flag(flgs, TR_ESP_HUMAN)) creature_ptr->esp_human = TRUE;
2234 if (have_flag(flgs, TR_ESP_EVIL)) creature_ptr->esp_evil = TRUE;
2235 if (have_flag(flgs, TR_ESP_GOOD)) creature_ptr->esp_good = TRUE;
2236 if (have_flag(flgs, TR_ESP_NONLIVING)) creature_ptr->esp_nonliving = TRUE;
2237 if (have_flag(flgs, TR_ESP_UNIQUE)) creature_ptr->esp_unique = TRUE;
2239 if (have_flag(flgs, TR_SEE_INVIS)) creature_ptr->see_inv = TRUE;
2240 if (have_flag(flgs, TR_LEVITATION)) creature_ptr->levitation = TRUE;
2241 if (have_flag(flgs, TR_FREE_ACT)) creature_ptr->free_act = TRUE;
2242 if (have_flag(flgs, TR_HOLD_EXP)) creature_ptr->hold_exp = TRUE;
2243 if (have_flag(flgs, TR_WARNING)) {
2244 if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription), '$')))
2245 creature_ptr->warning = TRUE;
2248 if (have_flag(flgs, TR_TELEPORT))
2250 if (object_is_cursed(o_ptr)) creature_ptr->cursed |= TRC_TELEPORT;
2253 concptr insc = quark_str(o_ptr->inscription);
2255 /* {.} will stop random teleportation. */
2256 if (o_ptr->inscription && my_strchr(insc, '.'))
2261 creature_ptr->cursed |= TRC_TELEPORT_SELF;
2266 if (have_flag(flgs, TR_IM_FIRE)) creature_ptr->immune_fire = TRUE;
2267 if (have_flag(flgs, TR_IM_ACID)) creature_ptr->immune_acid = TRUE;
2268 if (have_flag(flgs, TR_IM_COLD)) creature_ptr->immune_cold = TRUE;
2269 if (have_flag(flgs, TR_IM_ELEC)) creature_ptr->immune_elec = TRUE;
2271 if (have_flag(flgs, TR_RES_ACID)) creature_ptr->resist_acid = TRUE;
2272 if (have_flag(flgs, TR_RES_ELEC)) creature_ptr->resist_elec = TRUE;
2273 if (have_flag(flgs, TR_RES_FIRE)) creature_ptr->resist_fire = TRUE;
2274 if (have_flag(flgs, TR_RES_COLD)) creature_ptr->resist_cold = TRUE;
2275 if (have_flag(flgs, TR_RES_POIS)) creature_ptr->resist_pois = TRUE;
2276 if (have_flag(flgs, TR_RES_FEAR)) creature_ptr->resist_fear = TRUE;
2277 if (have_flag(flgs, TR_RES_CONF)) creature_ptr->resist_conf = TRUE;
2278 if (have_flag(flgs, TR_RES_SOUND)) creature_ptr->resist_sound = TRUE;
2279 if (have_flag(flgs, TR_RES_LITE)) creature_ptr->resist_lite = TRUE;
2280 if (have_flag(flgs, TR_RES_DARK)) creature_ptr->resist_dark = TRUE;
2281 if (have_flag(flgs, TR_RES_CHAOS)) creature_ptr->resist_chaos = TRUE;
2282 if (have_flag(flgs, TR_RES_DISEN)) creature_ptr->resist_disen = TRUE;
2283 if (have_flag(flgs, TR_RES_SHARDS)) creature_ptr->resist_shard = TRUE;
2284 if (have_flag(flgs, TR_RES_NEXUS)) creature_ptr->resist_nexus = TRUE;
2285 if (have_flag(flgs, TR_RES_BLIND)) creature_ptr->resist_blind = TRUE;
2286 if (have_flag(flgs, TR_RES_NETHER)) creature_ptr->resist_neth = TRUE;
2288 if (have_flag(flgs, TR_REFLECT)) creature_ptr->reflect = TRUE;
2289 if (have_flag(flgs, TR_SH_FIRE)) creature_ptr->sh_fire = TRUE;
2290 if (have_flag(flgs, TR_SH_ELEC)) creature_ptr->sh_elec = TRUE;
2291 if (have_flag(flgs, TR_SH_COLD)) creature_ptr->sh_cold = TRUE;
2292 if (have_flag(flgs, TR_NO_MAGIC)) creature_ptr->anti_magic = TRUE;
2293 if (have_flag(flgs, TR_NO_TELE)) creature_ptr->anti_tele = TRUE;
2295 if (have_flag(flgs, TR_SUST_STR)) creature_ptr->sustain_str = TRUE;
2296 if (have_flag(flgs, TR_SUST_INT)) creature_ptr->sustain_int = TRUE;
2297 if (have_flag(flgs, TR_SUST_WIS)) creature_ptr->sustain_wis = TRUE;
2298 if (have_flag(flgs, TR_SUST_DEX)) creature_ptr->sustain_dex = TRUE;
2299 if (have_flag(flgs, TR_SUST_CON)) creature_ptr->sustain_con = TRUE;
2300 if (have_flag(flgs, TR_SUST_CHR)) creature_ptr->sustain_chr = TRUE;
2302 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
2303 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
2304 if (o_ptr->name2 == EGO_RING_RES_TIME) creature_ptr->resist_time = TRUE;
2305 if (o_ptr->name2 == EGO_RING_THROW) creature_ptr->mighty_throw = TRUE;
2306 if (have_flag(flgs, TR_EASY_SPELL)) creature_ptr->easy_spell = TRUE;
2307 if (o_ptr->name2 == EGO_AMU_FOOL) creature_ptr->heavy_spell = TRUE;
2308 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
2310 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
2312 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2314 creature_ptr->to_m_chance += 10;
2318 creature_ptr->to_m_chance += 3;
2322 if (o_ptr->tval == TV_CAPTURE) continue;
2324 creature_ptr->ac += o_ptr->ac;
2325 creature_ptr->dis_ac += o_ptr->ac;
2326 creature_ptr->to_a += o_ptr->to_a;
2327 if (object_is_known(o_ptr)) creature_ptr->dis_to_a += o_ptr->to_a;
2329 if (o_ptr->curse_flags & TRC_LOW_MELEE)
2331 int slot = i - INVEN_RARM;
2334 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2336 creature_ptr->to_h[slot] -= 15;
2337 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h[slot] -= 15;
2341 creature_ptr->to_h[slot] -= 5;
2342 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h[slot] -= 5;
2347 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2349 creature_ptr->to_h_b -= 15;
2350 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h_b -= 15;
2354 creature_ptr->to_h_b -= 5;
2355 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h_b -= 5;
2360 if (o_ptr->curse_flags & TRC_LOW_AC)
2362 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2364 creature_ptr->to_a -= 30;
2365 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_a -= 30;
2369 creature_ptr->to_a -= 10;
2370 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_a -= 10;
2374 if (i == INVEN_RARM && has_melee_weapon(creature_ptr, i)) continue;
2375 if (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) continue;
2376 if (i == INVEN_BOW) continue;
2378 bonus_to_h = o_ptr->to_h;
2379 bonus_to_d = o_ptr->to_d;
2381 if (creature_ptr->pclass == CLASS_NINJA)
2383 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h + 1) / 2;
2384 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
2387 creature_ptr->to_h_b += (s16b)bonus_to_h;
2388 creature_ptr->to_h_m += (s16b)bonus_to_h;
2389 creature_ptr->to_d_m += (s16b)bonus_to_d;
2391 if (object_is_known(o_ptr)) creature_ptr->dis_to_h_b += (s16b)bonus_to_h;
2393 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !creature_ptr->ryoute)
2395 creature_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
2396 creature_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
2397 if (object_is_known(o_ptr))
2399 creature_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
2400 creature_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
2406 if (creature_ptr->migite && creature_ptr->hidarite)
2408 creature_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2409 creature_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2410 creature_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2411 creature_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2412 if (!object_is_known(o_ptr)) continue;
2414 creature_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2415 creature_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2416 creature_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2417 creature_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2421 creature_ptr->to_h[default_hand] += (s16b)bonus_to_h;
2422 creature_ptr->to_d[default_hand] += (s16b)bonus_to_d;
2424 if (!object_is_known(o_ptr)) continue;
2426 creature_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
2427 creature_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
2430 if (object_is_armour(&creature_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&creature_ptr->inventory_list[INVEN_LARM]))
2432 creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2433 creature_ptr->dis_ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2436 if (old_mighty_throw != creature_ptr->mighty_throw)
2438 creature_ptr->window |= PW_INVEN;
2441 if (creature_ptr->cursed & TRC_TELEPORT) creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
2443 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr))
2445 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx))
2447 creature_ptr->to_a += (creature_ptr->lev * 3) / 2;
2448 creature_ptr->dis_to_a += (creature_ptr->lev * 3) / 2;
2450 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15))
2452 creature_ptr->to_a += ((creature_ptr->lev - 13) / 3);
2453 creature_ptr->dis_to_a += ((creature_ptr->lev - 13) / 3);
2455 if (!(creature_ptr->inventory_list[INVEN_LARM].k_idx) && (creature_ptr->lev > 10))
2457 creature_ptr->to_a += ((creature_ptr->lev - 8) / 3);
2458 creature_ptr->dis_to_a += ((creature_ptr->lev - 8) / 3);
2460 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4))
2462 creature_ptr->to_a += (creature_ptr->lev - 2) / 3;
2463 creature_ptr->dis_to_a += (creature_ptr->lev - 2) / 3;
2465 if (!(creature_ptr->inventory_list[INVEN_HANDS].k_idx))
2467 creature_ptr->to_a += (creature_ptr->lev / 2);
2468 creature_ptr->dis_to_a += (creature_ptr->lev / 2);
2470 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx))
2472 creature_ptr->to_a += (creature_ptr->lev / 3);
2473 creature_ptr->dis_to_a += (creature_ptr->lev / 3);
2475 if (creature_ptr->special_defense & KAMAE_BYAKKO)
2477 creature_ptr->stat_add[A_STR] += 2;
2478 creature_ptr->stat_add[A_DEX] += 2;
2479 creature_ptr->stat_add[A_CON] -= 3;
2481 else if (creature_ptr->special_defense & KAMAE_SEIRYU)
2484 else if (creature_ptr->special_defense & KAMAE_GENBU)
2486 creature_ptr->stat_add[A_INT] -= 1;
2487 creature_ptr->stat_add[A_WIS] -= 1;
2488 creature_ptr->stat_add[A_DEX] -= 2;
2489 creature_ptr->stat_add[A_CON] += 3;
2491 else if (creature_ptr->special_defense & KAMAE_SUZAKU)
2493 creature_ptr->stat_add[A_STR] -= 2;
2494 creature_ptr->stat_add[A_INT] += 1;
2495 creature_ptr->stat_add[A_WIS] += 1;
2496 creature_ptr->stat_add[A_DEX] += 2;
2497 creature_ptr->stat_add[A_CON] -= 2;
2501 if (creature_ptr->special_defense & KATA_KOUKIJIN)
2503 for (int i = 0; i < A_MAX; i++)
2504 creature_ptr->stat_add[i] += 5;
2505 creature_ptr->to_a -= 50;
2506 creature_ptr->dis_to_a -= 50;
2509 if (creature_ptr->sh_fire) creature_ptr->lite = TRUE;
2511 if (PRACE_IS_(creature_ptr, RACE_GOLEM) || PRACE_IS_(creature_ptr, RACE_ANDROID))
2513 creature_ptr->to_a += 10 + (creature_ptr->lev * 2 / 5);
2514 creature_ptr->dis_to_a += 10 + (creature_ptr->lev * 2 / 5);
2517 if (creature_ptr->realm1 == REALM_HEX)
2519 if (hex_spelling_any(creature_ptr)) creature_ptr->skill_stl -= (1 + CASTING_HEX_NUM(creature_ptr));
2520 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
2521 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
2522 if (hex_spelling(creature_ptr, HEX_BUILDING))
2524 creature_ptr->stat_add[A_STR] += 4;
2525 creature_ptr->stat_add[A_DEX] += 4;
2526 creature_ptr->stat_add[A_CON] += 4;
2529 if (hex_spelling(creature_ptr, HEX_DEMON_AURA))
2531 creature_ptr->sh_fire = TRUE;
2532 creature_ptr->regenerate = TRUE;
2535 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR))
2537 creature_ptr->sh_cold = TRUE;
2538 creature_ptr->to_a += 30;
2539 creature_ptr->dis_to_a += 30;
2542 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK))
2544 creature_ptr->sh_elec = TRUE;
2548 for (int i = INVEN_RARM; i <= INVEN_FEET; i++)
2550 ARMOUR_CLASS ac = 0;
2551 o_ptr = &creature_ptr->inventory_list[i];
2552 if (!o_ptr->k_idx) continue;
2553 if (!object_is_armour(o_ptr)) continue;
2554 if (!object_is_cursed(o_ptr)) continue;
2556 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
2557 if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
2558 creature_ptr->to_a += (s16b)ac;
2559 creature_ptr->dis_to_a += (s16b)ac;
2564 for (int i = 0; i < A_MAX; i++)
2567 int top = modify_stat_value(creature_ptr->stat_max[i], creature_ptr->stat_add[i]);
2569 if (creature_ptr->stat_top[i] != top)
2571 creature_ptr->stat_top[i] = (s16b)top;
2572 creature_ptr->redraw |= (PR_STATS);
2573 creature_ptr->window |= (PW_PLAYER);
2576 int use = modify_stat_value(creature_ptr->stat_cur[i], creature_ptr->stat_add[i]);
2578 if ((i == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM))
2580 /* 10 to 18/90 charisma, guaranteed, based on level */
2581 if (use < 8 + 2 * creature_ptr->lev)
2583 use = 8 + 2 * creature_ptr->lev;
2587 if (creature_ptr->stat_use[i] != use)
2589 creature_ptr->stat_use[i] = (s16b)use;
2590 creature_ptr->redraw |= (PR_STATS);
2591 creature_ptr->window |= (PW_PLAYER);
2594 if (use <= 18) ind = (use - 3);
2595 else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
2598 if (creature_ptr->stat_ind[i] == ind) continue;
2599 creature_ptr->stat_ind[i] = (s16b)ind;
2602 creature_ptr->update |= (PU_HP);
2604 else if (i == A_INT)
2606 if (mp_ptr->spell_stat == A_INT)
2608 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2611 else if (i == A_WIS)
2613 if (mp_ptr->spell_stat == A_WIS)
2615 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2618 else if (i == A_CHR)
2620 if (mp_ptr->spell_stat == A_CHR)
2622 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2626 creature_ptr->window |= (PW_PLAYER);
2630 if (creature_ptr->stun > 50)
2632 creature_ptr->to_h[0] -= 20;
2633 creature_ptr->to_h[1] -= 20;
2634 creature_ptr->to_h_b -= 20;
2635 creature_ptr->to_h_m -= 20;
2636 creature_ptr->dis_to_h[0] -= 20;
2637 creature_ptr->dis_to_h[1] -= 20;
2638 creature_ptr->dis_to_h_b -= 20;
2639 creature_ptr->to_d[0] -= 20;
2640 creature_ptr->to_d[1] -= 20;
2641 creature_ptr->to_d_m -= 20;
2642 creature_ptr->dis_to_d[0] -= 20;
2643 creature_ptr->dis_to_d[1] -= 20;
2645 else if (creature_ptr->stun)
2647 creature_ptr->to_h[0] -= 5;
2648 creature_ptr->to_h[1] -= 5;
2649 creature_ptr->to_h_b -= 5;
2650 creature_ptr->to_h_m -= 5;
2651 creature_ptr->dis_to_h[0] -= 5;
2652 creature_ptr->dis_to_h[1] -= 5;
2653 creature_ptr->dis_to_h_b -= 5;
2654 creature_ptr->to_d[0] -= 5;
2655 creature_ptr->to_d[1] -= 5;
2656 creature_ptr->to_d_m -= 5;
2657 creature_ptr->dis_to_d[0] -= 5;
2658 creature_ptr->dis_to_d[1] -= 5;
2661 if (creature_ptr->wraith_form)
2663 creature_ptr->reflect = TRUE;
2664 creature_ptr->pass_wall = TRUE;
2667 if (creature_ptr->kabenuke)
2669 creature_ptr->pass_wall = TRUE;
2672 if (is_blessed(creature_ptr))
2674 creature_ptr->to_a += 5;
2675 creature_ptr->dis_to_a += 5;
2676 creature_ptr->to_h[0] += 10;
2677 creature_ptr->to_h[1] += 10;
2678 creature_ptr->to_h_b += 10;
2679 creature_ptr->to_h_m += 10;
2680 creature_ptr->dis_to_h[0] += 10;
2681 creature_ptr->dis_to_h[1] += 10;
2682 creature_ptr->dis_to_h_b += 10;
2685 if (creature_ptr->magicdef)
2687 creature_ptr->resist_blind = TRUE;
2688 creature_ptr->resist_conf = TRUE;
2689 creature_ptr->reflect = TRUE;
2690 creature_ptr->free_act = TRUE;
2691 creature_ptr->levitation = TRUE;
2694 if (IS_HERO(creature_ptr))
2696 creature_ptr->to_h[0] += 12;
2697 creature_ptr->to_h[1] += 12;
2698 creature_ptr->to_h_b += 12;
2699 creature_ptr->to_h_m += 12;
2700 creature_ptr->dis_to_h[0] += 12;
2701 creature_ptr->dis_to_h[1] += 12;
2702 creature_ptr->dis_to_h_b += 12;
2705 if (creature_ptr->shero)
2707 creature_ptr->to_h[0] += 12;
2708 creature_ptr->to_h[1] += 12;
2709 creature_ptr->to_h_b -= 12;
2710 creature_ptr->to_h_m += 12;
2711 creature_ptr->to_d[0] += 3 + (creature_ptr->lev / 5);
2712 creature_ptr->to_d[1] += 3 + (creature_ptr->lev / 5);
2713 creature_ptr->to_d_m += 3 + (creature_ptr->lev / 5);
2714 creature_ptr->dis_to_h[0] += 12;
2715 creature_ptr->dis_to_h[1] += 12;
2716 creature_ptr->dis_to_h_b -= 12;
2717 creature_ptr->dis_to_d[0] += 3 + (creature_ptr->lev / 5);
2718 creature_ptr->dis_to_d[1] += 3 + (creature_ptr->lev / 5);
2719 creature_ptr->to_a -= 10;
2720 creature_ptr->dis_to_a -= 10;
2721 creature_ptr->skill_stl -= 7;
2722 creature_ptr->skill_dev -= 20;
2723 creature_ptr->skill_sav -= 30;
2724 creature_ptr->skill_srh -= 15;
2725 creature_ptr->skill_fos -= 15;
2726 creature_ptr->skill_tht -= 20;
2727 creature_ptr->skill_dig += 30;
2730 if (IS_FAST(creature_ptr))
2735 if (creature_ptr->slow)
2740 if (is_time_limit_esp(creature_ptr))
2742 creature_ptr->telepathy = TRUE;
2745 if (creature_ptr->ele_immune)
2747 if (creature_ptr->special_defense & DEFENSE_ACID)
2748 creature_ptr->immune_acid = TRUE;
2749 else if (creature_ptr->special_defense & DEFENSE_ELEC)
2750 creature_ptr->immune_elec = TRUE;
2751 else if (creature_ptr->special_defense & DEFENSE_FIRE)
2752 creature_ptr->immune_fire = TRUE;
2753 else if (creature_ptr->special_defense & DEFENSE_COLD)
2754 creature_ptr->immune_cold = TRUE;
2757 if (creature_ptr->tim_invis)
2759 creature_ptr->see_inv = TRUE;
2762 if (creature_ptr->tim_infra)
2764 creature_ptr->see_infra += 3;
2767 if (creature_ptr->tim_regen)
2769 creature_ptr->regenerate = TRUE;
2772 if (creature_ptr->tim_levitation)
2774 creature_ptr->levitation = TRUE;
2777 if (creature_ptr->tim_reflect)
2779 creature_ptr->reflect = TRUE;
2782 if (IS_HERO(creature_ptr) || creature_ptr->shero)
2784 creature_ptr->resist_fear = TRUE;
2787 if (creature_ptr->telepathy != old_telepathy)
2789 creature_ptr->update |= (PU_MONSTERS);
2792 if ((creature_ptr->esp_animal != old_esp_animal) ||
2793 (creature_ptr->esp_undead != old_esp_undead) ||
2794 (creature_ptr->esp_demon != old_esp_demon) ||
2795 (creature_ptr->esp_orc != old_esp_orc) ||
2796 (creature_ptr->esp_troll != old_esp_troll) ||
2797 (creature_ptr->esp_giant != old_esp_giant) ||
2798 (creature_ptr->esp_dragon != old_esp_dragon) ||
2799 (creature_ptr->esp_human != old_esp_human) ||
2800 (creature_ptr->esp_evil != old_esp_evil) ||
2801 (creature_ptr->esp_good != old_esp_good) ||
2802 (creature_ptr->esp_nonliving != old_esp_nonliving) ||
2803 (creature_ptr->esp_unique != old_esp_unique))
2805 creature_ptr->update |= (PU_MONSTERS);
2808 if (creature_ptr->see_inv != old_see_inv)
2810 creature_ptr->update |= (PU_MONSTERS);
2813 if (creature_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
2815 if (creature_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
2817 if ((creature_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
2818 (creature_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
2820 creature_ptr->to_h[default_hand] += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2821 creature_ptr->dis_to_h[default_hand] += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2824 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2826 int penalty1, penalty2;
2827 penalty1 = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[INVEN_RARM].weight) / 8);
2828 penalty2 = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[INVEN_LARM].weight) / 8);
2829 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN))
2831 penalty1 = penalty1 / 2 - 5;
2832 penalty2 = penalty2 / 2 - 5;
2834 creature_ptr->to_a += 10;
2835 creature_ptr->dis_to_a += 10;
2839 if (penalty1 > 0) penalty1 /= 2;
2840 if (penalty2 > 0) penalty2 /= 2;
2842 else if ((creature_ptr->inventory_list[INVEN_LARM].tval == TV_SWORD) && ((creature_ptr->inventory_list[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (creature_ptr->inventory_list[INVEN_LARM].sval == SV_WAKIZASHI)))
2844 penalty1 = MAX(0, penalty1 - 10);
2845 penalty2 = MAX(0, penalty2 - 10);
2847 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
2849 penalty1 = MIN(0, penalty1);
2850 penalty2 = MIN(0, penalty2);
2851 creature_ptr->to_a += 10;
2852 creature_ptr->dis_to_a += 10;
2856 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
2858 if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
2862 if (creature_ptr->inventory_list[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
2863 if (creature_ptr->inventory_list[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
2864 creature_ptr->to_h[0] -= (s16b)penalty1;
2865 creature_ptr->to_h[1] -= (s16b)penalty2;
2866 creature_ptr->dis_to_h[0] -= (s16b)penalty1;
2867 creature_ptr->dis_to_h[1] -= (s16b)penalty2;
2870 int j = creature_ptr->total_weight;
2871 if (!creature_ptr->riding)
2873 count = (int)weight_limit(creature_ptr);
2877 monster_type *riding_m_ptr = &floor_ptr->m_list[creature_ptr->riding];
2878 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2879 SPEED speed = riding_m_ptr->mspeed;
2881 if (riding_m_ptr->mspeed > 110)
2883 new_speed = 110 + (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2884 if (new_speed < 110) new_speed = 110;
2891 new_speed += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2892 if (MON_FAST(riding_m_ptr)) new_speed += 10;
2893 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
2894 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
2895 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) creature_ptr->can_swim = TRUE;
2897 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) creature_ptr->pass_wall = FALSE;
2898 if (riding_r_ptr->flags2 & RF2_KILL_WALL) creature_ptr->kill_wall = TRUE;
2900 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED)
2901 j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2903 count = 1500 + riding_r_ptr->level * 25;
2906 if (j > count) new_speed -= ((j - count) / (count / 5));
2907 if (creature_ptr->action == ACTION_SEARCH) new_speed -= 10;
2908 if (creature_ptr->prace == RACE_MERFOLK)
2910 if (have_flag(f_ptr->flags, FF_WATER))
2912 new_speed += (2 + creature_ptr->lev / 10);
2914 else if (!creature_ptr->levitation)
2920 creature_ptr->to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2921 creature_ptr->to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2922 creature_ptr->to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2923 creature_ptr->to_d_m += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2924 creature_ptr->to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2925 creature_ptr->to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2926 creature_ptr->to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2927 creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2928 creature_ptr->to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2929 creature_ptr->to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2930 creature_ptr->to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2931 creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2932 creature_ptr->dis_to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2933 creature_ptr->dis_to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2934 creature_ptr->dis_to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2935 creature_ptr->dis_to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2936 creature_ptr->dis_to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2937 creature_ptr->dis_to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2938 creature_ptr->dis_to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2939 creature_ptr->dis_to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2940 creature_ptr->dis_to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2942 hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
2943 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2944 creature_ptr->heavy_shoot = is_heavy_shoot(creature_ptr, o_ptr);
2945 if (creature_ptr->heavy_shoot)
2947 creature_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
2948 creature_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
2953 creature_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
2954 if (o_ptr->k_idx && !creature_ptr->heavy_shoot)
2956 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
2957 if ((creature_ptr->pclass == CLASS_SNIPER) &&
2958 (creature_ptr->tval_ammo == TV_BOLT))
2960 creature_ptr->to_h_b += (10 + (creature_ptr->lev / 5));
2961 creature_ptr->dis_to_h_b += (10 + (creature_ptr->lev / 5));
2966 if (creature_ptr->ryoute) hold *= 2;
2967 for (int i = 0; i < 2; i++)
2969 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
2970 object_flags(o_ptr, flgs);
2971 creature_ptr->heavy_wield[i] = FALSE;
2972 creature_ptr->icky_wield[i] = FALSE;
2973 creature_ptr->riding_wield[i] = FALSE;
2974 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
2976 creature_ptr->num_blow[i] = 1;
2980 if (hold < o_ptr->weight / 10)
2982 creature_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
2983 creature_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
2984 creature_ptr->heavy_wield[i] = TRUE;
2986 else if (creature_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
2988 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
2990 creature_ptr->to_a += 5;
2991 creature_ptr->dis_to_a += 5;
2994 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i])
2996 int str_index, dex_index;
2997 int num = 0, wgt = 0, mul = 0, div = 0;
2998 switch (creature_ptr->pclass)
3001 num = 6; wgt = 70; mul = 5; break;
3003 case CLASS_BERSERKER:
3004 num = 6; wgt = 70; mul = 7; break;
3007 case CLASS_HIGH_MAGE:
3008 case CLASS_BLUE_MAGE:
3009 num = 3; wgt = 100; mul = 2; break;
3012 case CLASS_MAGIC_EATER:
3013 case CLASS_MINDCRAFTER:
3014 num = 5; wgt = 100; mul = 3; break;
3017 num = 5; wgt = 40; mul = 3; break;
3020 num = 5; wgt = 70; mul = 4; break;
3024 num = 5; wgt = 70; mul = 4; break;
3027 num = 5; wgt = 150; mul = 5; break;
3029 case CLASS_WARRIOR_MAGE:
3030 case CLASS_RED_MAGE:
3031 num = 5; wgt = 70; mul = 3; break;
3033 case CLASS_CHAOS_WARRIOR:
3034 num = 5; wgt = 70; mul = 4; break;
3037 num = 5; wgt = 60; mul = 3; break;
3040 num = 4; wgt = 100; mul = 3; break;
3042 case CLASS_IMITATOR:
3043 num = 5; wgt = 70; mul = 4; break;
3045 case CLASS_BEASTMASTER:
3046 num = 5; wgt = 70; mul = 3; break;
3049 if ((creature_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
3050 else { num = 5; wgt = 100; mul = 3; }
3053 case CLASS_SORCERER:
3054 num = 1; wgt = 1; mul = 1; break;
3059 num = 4; wgt = 70; mul = 2; break;
3061 case CLASS_FORCETRAINER:
3062 num = 4; wgt = 60; mul = 2; break;
3064 case CLASS_MIRROR_MASTER:
3065 num = 3; wgt = 100; mul = 3; break;
3068 num = 4; wgt = 20; mul = 1; break;
3071 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING))
3078 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
3079 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
3081 if (creature_ptr->ryoute && !omoi) str_index++;
3082 if (creature_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
3083 if (str_index > 11) str_index = 11;
3085 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
3086 if (dex_index > 11) dex_index = 11;
3088 creature_ptr->num_blow[i] = blows_table[str_index][dex_index];
3089 if (creature_ptr->num_blow[i] > num) creature_ptr->num_blow[i] = (s16b)num;
3091 creature_ptr->num_blow[i] += (s16b)extra_blows[i];
3092 if (creature_ptr->pclass == CLASS_WARRIOR) creature_ptr->num_blow[i] += (creature_ptr->lev / 40);
3093 else if (creature_ptr->pclass == CLASS_BERSERKER)
3094 creature_ptr->num_blow[i] += (creature_ptr->lev / 23);
3095 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
3096 creature_ptr->num_blow[i] ++;
3098 if (creature_ptr->special_defense & KATA_FUUJIN)
3099 creature_ptr->num_blow[i] -= 1;
3101 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
3102 creature_ptr->num_blow[i] = 1;
3104 if (creature_ptr->num_blow[i] < 1)
3105 creature_ptr->num_blow[i] = 1;
3107 creature_ptr->skill_dig += (o_ptr->weight / 10);
3110 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
3111 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
3113 creature_ptr->to_h[i] -= 2;
3114 creature_ptr->to_d[i] -= 2;
3115 creature_ptr->dis_to_h[i] -= 2;
3116 creature_ptr->dis_to_d[i] -= 2;
3117 creature_ptr->icky_wield[i] = TRUE;
3119 else if (creature_ptr->pclass == CLASS_BERSERKER)
3121 creature_ptr->to_h[i] += creature_ptr->lev / 5;
3122 creature_ptr->to_d[i] += creature_ptr->lev / 6;
3123 creature_ptr->dis_to_h[i] += creature_ptr->lev / 5;
3124 creature_ptr->dis_to_d[i] += creature_ptr->lev / 6;
3125 if (((i == 0) && !creature_ptr->hidarite) || creature_ptr->ryoute)
3127 creature_ptr->to_h[i] += creature_ptr->lev / 5;
3128 creature_ptr->to_d[i] += creature_ptr->lev / 6;
3129 creature_ptr->dis_to_h[i] += creature_ptr->lev / 5;
3130 creature_ptr->dis_to_d[i] += creature_ptr->lev / 6;
3133 else if (creature_ptr->pclass == CLASS_SORCERER)
3135 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
3137 creature_ptr->to_h[i] -= 200;
3138 creature_ptr->to_d[i] -= 200;
3139 creature_ptr->dis_to_h[i] -= 200;
3140 creature_ptr->dis_to_d[i] -= 200;
3141 creature_ptr->icky_wield[i] = TRUE;
3145 creature_ptr->to_h[i] -= 30;
3146 creature_ptr->to_d[i] -= 10;
3147 creature_ptr->dis_to_h[i] -= 30;
3148 creature_ptr->dis_to_d[i] -= 10;
3152 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr))
3154 if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
3155 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_h[i] += 7; creature_ptr->dis_to_h[i] += 7; }
3156 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_h[i] += 13; creature_ptr->dis_to_h[i] += 13; }
3157 if (o_ptr->curse_flags & (TRC_TY_CURSE)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
3158 if (hex_spelling(creature_ptr, HEX_RUNESWORD))
3160 if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_d[i] += 5; creature_ptr->dis_to_d[i] += 5; }
3161 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_d[i] += 7; creature_ptr->dis_to_d[i] += 7; }
3162 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_d[i] += 13; creature_ptr->dis_to_d[i] += 13; }
3166 if (creature_ptr->riding == 0) continue;
3168 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
3170 creature_ptr->to_h[i] += 15;
3171 creature_ptr->dis_to_h[i] += 15;
3172 creature_ptr->to_dd[i] += 2;
3176 if (have_flag(flgs, TR_RIDING)) continue;
3179 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
3185 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3187 if (penalty < 30) penalty = 30;
3190 creature_ptr->to_h[i] -= (s16b)penalty;
3191 creature_ptr->dis_to_h[i] -= (s16b)penalty;
3192 creature_ptr->riding_wield[i] = TRUE;
3195 if (creature_ptr->riding)
3199 creature_ptr->riding_ryoute = FALSE;
3201 if (creature_ptr->ryoute || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE)) creature_ptr->riding_ryoute = TRUE;
3202 else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
3204 switch (creature_ptr->pclass)
3207 case CLASS_FORCETRAINER:
3208 case CLASS_BERSERKER:
3209 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
3210 creature_ptr->riding_ryoute = TRUE;
3215 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
3217 if (creature_ptr->tval_ammo != TV_ARROW) penalty = 5;
3221 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3223 if (penalty < 30) penalty = 30;
3226 if (creature_ptr->tval_ammo == TV_BOLT) penalty *= 2;
3227 creature_ptr->to_h_b -= (s16b)penalty;
3228 creature_ptr->dis_to_h_b -= (s16b)penalty;
3231 /* Different calculation for monks with empty hands */
3232 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER)) &&
3233 (empty_hands_status & EMPTY_HAND_RARM) && !creature_ptr->hidarite)
3235 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
3236 creature_ptr->num_blow[0] = 0;
3238 if (creature_ptr->pclass == CLASS_FORCETRAINER)
3240 if (blow_base > 18) creature_ptr->num_blow[0]++;
3241 if (blow_base > 31) creature_ptr->num_blow[0]++;
3242 if (blow_base > 44) creature_ptr->num_blow[0]++;
3243 if (blow_base > 58) creature_ptr->num_blow[0]++;
3246 creature_ptr->to_d[0] += P_PTR_KI / 5;
3247 creature_ptr->dis_to_d[0] += P_PTR_KI / 5;
3252 if (blow_base > 12) creature_ptr->num_blow[0]++;
3253 if (blow_base > 22) creature_ptr->num_blow[0]++;
3254 if (blow_base > 31) creature_ptr->num_blow[0]++;
3255 if (blow_base > 39) creature_ptr->num_blow[0]++;
3256 if (blow_base > 46) creature_ptr->num_blow[0]++;
3257 if (blow_base > 53) creature_ptr->num_blow[0]++;
3258 if (blow_base > 59) creature_ptr->num_blow[0]++;
3261 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
3262 creature_ptr->num_blow[0] /= 2;
3265 creature_ptr->to_h[0] += (creature_ptr->lev / 3);
3266 creature_ptr->dis_to_h[0] += (creature_ptr->lev / 3);
3268 creature_ptr->to_d[0] += (creature_ptr->lev / 6);
3269 creature_ptr->dis_to_d[0] += (creature_ptr->lev / 6);
3272 if (creature_ptr->special_defense & KAMAE_BYAKKO)
3274 creature_ptr->to_a -= 40;
3275 creature_ptr->dis_to_a -= 40;
3278 else if (creature_ptr->special_defense & KAMAE_SEIRYU)
3280 creature_ptr->to_a -= 50;
3281 creature_ptr->dis_to_a -= 50;
3282 creature_ptr->resist_acid = TRUE;
3283 creature_ptr->resist_fire = TRUE;
3284 creature_ptr->resist_elec = TRUE;
3285 creature_ptr->resist_cold = TRUE;
3286 creature_ptr->resist_pois = TRUE;
3287 creature_ptr->sh_fire = TRUE;
3288 creature_ptr->sh_elec = TRUE;
3289 creature_ptr->sh_cold = TRUE;
3290 creature_ptr->levitation = TRUE;
3292 else if (creature_ptr->special_defense & KAMAE_GENBU)
3294 creature_ptr->to_a += (creature_ptr->lev*creature_ptr->lev) / 50;
3295 creature_ptr->dis_to_a += (creature_ptr->lev*creature_ptr->lev) / 50;
3296 creature_ptr->reflect = TRUE;
3297 creature_ptr->num_blow[0] -= 2;
3298 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42)) creature_ptr->num_blow[0]--;
3299 if (creature_ptr->num_blow[0] < 0) creature_ptr->num_blow[0] = 0;
3301 else if (creature_ptr->special_defense & KAMAE_SUZAKU)
3303 creature_ptr->to_h[0] -= (creature_ptr->lev / 3);
3304 creature_ptr->to_d[0] -= (creature_ptr->lev / 6);
3306 creature_ptr->dis_to_h[0] -= (creature_ptr->lev / 3);
3307 creature_ptr->dis_to_d[0] -= (creature_ptr->lev / 6);
3308 creature_ptr->num_blow[0] /= 2;
3309 creature_ptr->levitation = TRUE;
3312 creature_ptr->num_blow[0] += 1 + extra_blows[0];
3315 if (creature_ptr->riding) creature_ptr->levitation = riding_levitation;
3317 creature_ptr->monk_armour_aux = FALSE;
3319 if (heavy_armor(creature_ptr))
3321 creature_ptr->monk_armour_aux = TRUE;
3324 for (int i = 0; i < 2; i++)
3326 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
3328 OBJECT_TYPE_VALUE tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
3329 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
3331 creature_ptr->to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3332 creature_ptr->dis_to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3333 if ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER))
3335 if (!s_info[creature_ptr->pclass].w_max[tval][sval])
3337 creature_ptr->to_h[i] -= 40;
3338 creature_ptr->dis_to_h[i] -= 40;
3339 creature_ptr->icky_wield[i] = TRUE;
3345 if (creature_ptr->pclass != CLASS_NINJA) continue;
3347 if ((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD))
3350 creature_ptr->to_h[i] -= 40;
3351 creature_ptr->dis_to_h[i] -= 40;
3352 creature_ptr->icky_wield[i] = TRUE;
3353 creature_ptr->num_blow[i] /= 2;
3354 if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1;
3357 /* Maximum speed is (+99). (internally it's 110 + 99) */
3358 /* Temporary lightspeed forces to be maximum speed */
3359 if ((creature_ptr->lightspeed && !creature_ptr->riding) || (new_speed > 209))
3364 /* Minimum speed is (-99). (internally it's 110 - 99) */
3365 if (new_speed < 11) new_speed = 11;
3367 if (creature_ptr->pspeed != (byte)new_speed)
3369 creature_ptr->pspeed = (byte)new_speed;
3370 creature_ptr->redraw |= (PR_SPEED);
3375 if (creature_ptr->to_a > (0 - creature_ptr->ac))
3376 creature_ptr->to_a = 0 - creature_ptr->ac;
3377 if (creature_ptr->dis_to_a > (0 - creature_ptr->dis_ac))
3378 creature_ptr->dis_to_a = 0 - creature_ptr->dis_ac;
3381 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a))
3383 creature_ptr->redraw |= (PR_ARMOR);
3384 creature_ptr->window |= (PW_PLAYER);
3387 if (creature_ptr->ryoute && !omoi)
3389 int bonus_to_h = 0, bonus_to_d = 0;
3390 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
3391 bonus_to_h = ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3393 creature_ptr->to_h[default_hand] += MAX(bonus_to_h, 1);
3394 creature_ptr->dis_to_h[default_hand] += MAX(bonus_to_h, 1);
3395 creature_ptr->to_d[default_hand] += MAX(bonus_to_d, 1);
3396 creature_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
3399 bool is_special_class = creature_ptr->pclass == CLASS_MONK;
3400 is_special_class |= creature_ptr->pclass == CLASS_FORCETRAINER;
3401 is_special_class |= creature_ptr->pclass == CLASS_BERSERKER;
3402 if (is_special_class && (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)))
3403 creature_ptr->ryoute = FALSE;
3405 creature_ptr->skill_stl += 1;
3407 if (is_time_limit_stealth(creature_ptr))
3408 creature_ptr->skill_stl += 99;
3410 creature_ptr->skill_dis += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
3411 creature_ptr->skill_dis += adj_int_dis[creature_ptr->stat_ind[A_INT]];
3412 creature_ptr->skill_dev += adj_int_dev[creature_ptr->stat_ind[A_INT]];
3413 creature_ptr->skill_sav += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
3414 creature_ptr->skill_dig += adj_str_dig[creature_ptr->stat_ind[A_STR]];
3415 creature_ptr->skill_dis += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
3416 creature_ptr->skill_dev += ((cp_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
3417 creature_ptr->skill_sav += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
3418 creature_ptr->skill_stl += (cp_ptr->x_stl * creature_ptr->lev / 10);
3419 creature_ptr->skill_srh += (cp_ptr->x_srh * creature_ptr->lev / 10);
3420 creature_ptr->skill_fos += (cp_ptr->x_fos * creature_ptr->lev / 10);
3421 creature_ptr->skill_thn += ((cp_ptr->x_thn * creature_ptr->lev / 10) + (ap_ptr->a_thn * creature_ptr->lev / 50));
3422 creature_ptr->skill_thb += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
3423 creature_ptr->skill_tht += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
3425 if ((PRACE_IS_(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != SEIKAKU_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE))
3427 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
3428 creature_ptr->skill_stl = MIN(creature_ptr->skill_stl - 3, (creature_ptr->skill_stl + 2) / 2);
3431 if (creature_ptr->skill_stl > 30) creature_ptr->skill_stl = 30;
3432 if (creature_ptr->skill_stl < 0) creature_ptr->skill_stl = 0;
3433 if (creature_ptr->skill_dig < 1) creature_ptr->skill_dig = 1;
3434 if (creature_ptr->anti_magic && (creature_ptr->skill_sav < (90 + creature_ptr->lev)))
3435 creature_ptr->skill_sav = 90 + creature_ptr->lev;
3436 if (creature_ptr->tsubureru) creature_ptr->skill_sav = 10;
3437 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (creature_ptr->skill_sav < (95 + creature_ptr->lev)))
3438 creature_ptr->skill_sav = 95 + creature_ptr->lev;
3440 if (down_saving) creature_ptr->skill_sav /= 2;
3442 if (creature_ptr->immune_acid) creature_ptr->resist_acid = TRUE;
3443 if (creature_ptr->immune_elec) creature_ptr->resist_elec = TRUE;
3444 if (creature_ptr->immune_fire) creature_ptr->resist_fire = TRUE;
3445 if (creature_ptr->immune_cold) creature_ptr->resist_cold = TRUE;
3447 if (current_world_ptr->character_xtra) return;
3449 if (creature_ptr->old_heavy_shoot != creature_ptr->heavy_shoot)
3451 if (creature_ptr->heavy_shoot)
3453 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
3455 else if (creature_ptr->inventory_list[INVEN_BOW].k_idx)
3457 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
3461 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
3464 creature_ptr->old_heavy_shoot = creature_ptr->heavy_shoot;
3467 for (int i = 0; i < 2; i++)
3469 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i])
3471 if (creature_ptr->heavy_wield[i])
3473 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
3475 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3477 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
3479 else if (creature_ptr->heavy_wield[1 - i])
3481 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
3485 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
3488 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
3491 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i])
3493 if (creature_ptr->riding_wield[i])
3495 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
3497 else if (!creature_ptr->riding)
3499 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
3501 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3503 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
3506 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
3509 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
3512 if (creature_ptr->icky_wield[i])
3514 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
3515 if (current_world_ptr->is_loading_now)
3517 chg_virtue(creature_ptr, V_FAITH, -1);
3520 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3522 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
3526 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
3529 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
3532 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute))
3534 if (creature_ptr->riding_ryoute)
3537 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
3539 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
3545 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
3547 msg_print("You began to control the pet you're riding with one hand.");
3551 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
3554 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA)) && (creature_ptr->monk_armour_aux != creature_ptr->monk_notify_aux))
3556 if (heavy_armor(creature_ptr))
3558 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
3559 if (current_world_ptr->is_loading_now)
3561 chg_virtue(creature_ptr, V_HARMONY, -1);
3566 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
3569 creature_ptr->monk_notify_aux = creature_ptr->monk_armour_aux;
3572 for (int i = 0; i < INVEN_PACK; i++)
3574 if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_sw = TRUE;
3575 if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_kabe = TRUE;
3578 for (this_o_idx = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3580 o_ptr = &floor_ptr->o_list[this_o_idx];
3581 next_o_idx = o_ptr->next_o_idx;
3583 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
3584 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
3587 if (creature_ptr->pass_wall && !creature_ptr->kill_wall) creature_ptr->no_flowed = TRUE;
3589 if (have_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER)))
3591 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
3592 if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
3595 if (have_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER)))
3597 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_KABE];
3598 if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
3603 static void calc_alignment(player_type *creature_ptr)
3605 creature_ptr->align = 0;
3606 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3607 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
3609 monster_type *m_ptr;
3610 monster_race *r_ptr;
3611 m_ptr = &floor_ptr->m_list[m_idx];
3612 if (!monster_is_valid(m_ptr)) continue;
3613 r_ptr = &r_info[m_ptr->r_idx];
3615 if (!is_pet(m_ptr)) continue;
3617 if (r_ptr->flags3 & RF3_GOOD) creature_ptr->align += r_ptr->level;
3618 if (r_ptr->flags3 & RF3_EVIL) creature_ptr->align -= r_ptr->level;
3621 if (creature_ptr->mimic_form)
3623 switch (creature_ptr->mimic_form)
3626 creature_ptr->align -= 200;
3628 case MIMIC_DEMON_LORD:
3629 creature_ptr->align -= 200;
3635 switch (creature_ptr->prace)
3638 creature_ptr->align += 200;
3641 creature_ptr->align -= 200;
3646 for (int i = 0; i < 2; i++)
3648 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
3649 if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL) continue;
3650 creature_ptr->align -= 1000;
3655 for (int i = 0; i < 8; i++)
3657 switch (creature_ptr->vir_types[i])
3660 creature_ptr->align += creature_ptr->virtues[i] * 2;
3669 creature_ptr->align -= creature_ptr->virtues[i];
3672 creature_ptr->align += creature_ptr->virtues[i];
3677 for (int i = 0; i < j; i++)
3679 if (creature_ptr->align > 0)
3681 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
3682 if (creature_ptr->align < 0) creature_ptr->align = 0;
3684 else if (creature_ptr->align < 0)
3686 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
3687 if (creature_ptr->align > 0) creature_ptr->align = 0;
3694 * @brief プレイヤーの最大HPを計算する /
3695 * Calculate the players (maximal) hit points
3696 * Adjust current hitpoints if necessary
3700 static void calc_hitpoints(player_type *creature_ptr)
3702 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
3703 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
3706 if (creature_ptr->mimic_form)
3708 if (creature_ptr->pclass == CLASS_SORCERER)
3709 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
3711 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3712 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
3715 if (creature_ptr->pclass == CLASS_SORCERER)
3717 if (creature_ptr->lev < 30)
3718 mhp = (mhp * (45 + creature_ptr->lev) / 100);
3720 mhp = (mhp * 75 / 100);
3721 bonus = (bonus * 65 / 100);
3726 if (creature_ptr->pclass == CLASS_BERSERKER)
3728 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
3731 if (mhp < creature_ptr->lev + 1) mhp = creature_ptr->lev + 1;
3732 if (IS_HERO(creature_ptr)) mhp += 10;
3733 if (creature_ptr->shero && (creature_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
3734 if (creature_ptr->tsuyoshi) mhp += 50;
3735 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) mhp += 15;
3736 if (hex_spelling(creature_ptr, HEX_BUILDING)) mhp += 60;
3737 if (creature_ptr->mhp == mhp) return;
3739 if (creature_ptr->chp >= mhp)
3741 creature_ptr->chp = mhp;
3742 creature_ptr->chp_frac = 0;
3746 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp))
3748 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
3751 creature_ptr->mhp = mhp;
3753 creature_ptr->redraw |= PR_HP;
3754 creature_ptr->window |= PW_PLAYER;
3759 * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
3762 * SWD: Experimental modification: multiple light sources have additive effect.
3764 static void calc_torch(player_type *creature_ptr)
3766 creature_ptr->cur_lite = 0;
3767 for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
3770 o_ptr = &creature_ptr->inventory_list[i];
3771 if (!o_ptr->k_idx) continue;
3773 if (o_ptr->name2 == EGO_LITE_SHINE) creature_ptr->cur_lite++;
3774 if (o_ptr->name2 != EGO_LITE_DARKNESS)
3776 if (o_ptr->tval == TV_LITE)
3778 if ((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
3779 if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
3783 BIT_FLAGS flgs[TR_FLAG_SIZE];
3784 object_flags(o_ptr, flgs);
3787 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 1;
3788 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 2;
3789 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 3;
3790 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
3791 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
3792 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
3793 creature_ptr->cur_lite += rad;
3796 if (d_info[creature_ptr->dungeon_idx].flags1 & DF1_DARKNESS && creature_ptr->cur_lite > 1)
3797 creature_ptr->cur_lite = 1;
3799 if (creature_ptr->cur_lite <= 0 && creature_ptr->lite)
3800 creature_ptr->cur_lite++;
3802 if (creature_ptr->cur_lite > 14)
3803 creature_ptr->cur_lite = 14;
3805 if (creature_ptr->cur_lite < 0)
3806 creature_ptr->cur_lite = 0;
3808 if (creature_ptr->old_lite == creature_ptr->cur_lite)
3811 creature_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
3812 creature_ptr->old_lite = creature_ptr->cur_lite;
3814 if ((creature_ptr->cur_lite > 0) && (creature_ptr->special_defense & NINJA_S_STEALTH))
3815 set_superstealth(creature_ptr, FALSE);
3820 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
3821 * Calculate number of spells player should have, and forget,
3822 * or remember, spells until that number is properly reflected.
3825 * Note that this function induces various "status" messages,
3826 * which must be bypasses until the character is created.
3828 static void calc_spells(player_type *creature_ptr)
3830 if (!mp_ptr->spell_book) return;
3831 if (!current_world_ptr->character_generated) return;
3832 if (current_world_ptr->character_xtra) return;
3833 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE))
3835 creature_ptr->new_spells = 0;
3839 concptr p = spell_category_name(mp_ptr->spell_book);
3840 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
3841 if (levels < 0) levels = 0;
3843 int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
3845 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
3850 if (creature_ptr->pclass == CLASS_SAMURAI)
3854 else if (creature_ptr->realm2 == REALM_NONE)
3856 num_allowed = (num_allowed + 1) / 2;
3857 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
3859 else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST))
3861 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
3865 if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
3868 int num_boukyaku = 0;
3869 for (int j = 0; j < 64; j++)
3872 (creature_ptr->spell_forgotten1 & (1L << j)) :
3873 (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
3879 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
3880 for (int i = 63; i >= 0; i--)
3882 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
3884 int j = creature_ptr->spell_order[i];
3885 if (j >= 99) continue;
3887 const magic_type *s_ptr;
3888 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
3891 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3893 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
3896 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
3898 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
3900 if (s_ptr->slevel <= creature_ptr->lev) continue;
3902 bool is_spell_learned = (j < 32) ?
3903 (creature_ptr->spell_learned1 & (1L << j)) :
3904 (creature_ptr->spell_learned2 & (1L << (j - 32)));
3905 if (!is_spell_learned) continue;
3910 creature_ptr->spell_forgotten1 |= (1L << j);
3911 which = creature_ptr->realm1;
3915 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
3916 which = creature_ptr->realm2;
3921 creature_ptr->spell_learned1 &= ~(1L << j);
3922 which = creature_ptr->realm1;
3926 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
3927 which = creature_ptr->realm2;
3931 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3933 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3935 creature_ptr->new_spells++;
3938 /* Forget spells if we know too many spells */
3939 for (int i = 63; i >= 0; i--)
3941 if (creature_ptr->new_spells >= 0) break;
3942 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
3944 int j = creature_ptr->spell_order[i];
3945 if (j >= 99) continue;
3947 bool is_spell_learned = (j < 32) ?
3948 (creature_ptr->spell_learned1 & (1L << j)) :
3949 (creature_ptr->spell_learned2 & (1L << (j - 32)));
3950 if (!is_spell_learned) continue;
3955 creature_ptr->spell_forgotten1 |= (1L << j);
3956 which = creature_ptr->realm1;
3960 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
3961 which = creature_ptr->realm2;
3966 creature_ptr->spell_learned1 &= ~(1L << j);
3967 which = creature_ptr->realm1;
3971 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
3972 which = creature_ptr->realm2;
3976 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3978 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3980 creature_ptr->new_spells++;
3983 /* Check for spells to remember */
3984 for (int i = 0; i < 64; i++)
3986 if (creature_ptr->new_spells <= 0) break;
3987 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2) break;
3988 int j = creature_ptr->spell_order[i];
3991 const magic_type *s_ptr;
3992 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
3995 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3997 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
4000 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
4002 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
4004 if (s_ptr->slevel > creature_ptr->lev) continue;
4006 bool is_spell_learned = (j < 32) ?
4007 (creature_ptr->spell_forgotten1 & (1L << j)) :
4008 (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
4009 if (!is_spell_learned) continue;
4014 creature_ptr->spell_forgotten1 &= ~(1L << j);
4015 which = creature_ptr->realm1;
4019 creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
4020 which = creature_ptr->realm2;
4025 creature_ptr->spell_learned1 |= (1L << j);
4026 which = creature_ptr->realm1;
4030 creature_ptr->spell_learned2 |= (1L << (j - 32));
4031 which = creature_ptr->realm2;
4035 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
4037 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
4039 creature_ptr->new_spells--;
4042 if (creature_ptr->realm2 == REALM_NONE)
4045 for (int j = 0; j < 32; j++)
4047 const magic_type *s_ptr;
4048 if (!is_magic(creature_ptr->realm1)) s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
4049 else s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
4051 if (s_ptr->slevel > creature_ptr->lev) continue;
4053 if (creature_ptr->spell_learned1 & (1L << j))
4062 if ((creature_ptr->new_spells > k) &&
4063 ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
4065 creature_ptr->new_spells = (s16b)k;
4069 if (creature_ptr->new_spells < 0) creature_ptr->new_spells = 0;
4071 if (creature_ptr->old_spells == creature_ptr->new_spells) return;
4073 if (creature_ptr->new_spells)
4076 if (creature_ptr->new_spells < 10) {
4077 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
4080 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
4083 msg_format("You can learn %d more %s%s.",
4084 creature_ptr->new_spells, p,
4085 (creature_ptr->new_spells != 1) ? "s" : "");
4089 creature_ptr->old_spells = creature_ptr->new_spells;
4090 creature_ptr->redraw |= PR_STUDY;
4091 creature_ptr->window |= PW_OBJECT;
4096 * @brief プレイヤーの最大MPを計算する /
4097 * Calculate maximum mana. You do not need to know any spells.
4098 * Note that mana is lowered by heavy (or inappropriate) armor.
4101 * This function induces status messages.
4103 static void calc_mana(player_type *creature_ptr)
4105 if (!mp_ptr->spell_book) return;
4108 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) ||
4109 (creature_ptr->pclass == CLASS_MIRROR_MASTER) ||
4110 (creature_ptr->pclass == CLASS_BLUE_MAGE))
4112 levels = creature_ptr->lev;
4116 if (mp_ptr->spell_first > creature_ptr->lev)
4118 creature_ptr->msp = 0;
4119 creature_ptr->redraw |= (PR_MANA);
4123 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
4127 if (creature_ptr->pclass == CLASS_SAMURAI)
4129 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
4130 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
4134 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
4136 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
4137 if (msp && (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
4138 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
4139 if (msp && (creature_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + creature_ptr->lev) / 100;
4142 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
4144 BIT_FLAGS flgs[TR_FLAG_SIZE];
4145 creature_ptr->cumber_glove = FALSE;
4147 o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
4148 object_flags(o_ptr, flgs);
4150 !(have_flag(flgs, TR_FREE_ACT)) &&
4151 !(have_flag(flgs, TR_DEC_MANA)) &&
4152 !(have_flag(flgs, TR_EASY_SPELL)) &&
4153 !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
4154 !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
4156 creature_ptr->cumber_glove = TRUE;
4157 msp = (3 * msp) / 4;
4161 creature_ptr->cumber_armor = FALSE;
4164 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4165 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4166 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
4167 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
4168 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
4169 cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
4170 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
4172 switch (creature_ptr->pclass)
4175 case CLASS_HIGH_MAGE:
4176 case CLASS_BLUE_MAGE:
4178 case CLASS_FORCETRAINER:
4179 case CLASS_SORCERER:
4181 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4182 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4189 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
4190 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
4193 case CLASS_MINDCRAFTER:
4194 case CLASS_BEASTMASTER:
4195 case CLASS_MIRROR_MASTER:
4197 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 2;
4198 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
4203 case CLASS_RED_MAGE:
4204 case CLASS_WARRIOR_MAGE:
4206 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 3;
4207 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
4211 case CLASS_CHAOS_WARRIOR:
4213 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 5;
4214 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
4223 int max_wgt = mp_ptr->spell_weight;
4224 if ((cur_wgt - max_wgt) > 0)
4226 creature_ptr->cumber_armor = TRUE;
4227 switch (creature_ptr->pclass)
4230 case CLASS_HIGH_MAGE:
4231 case CLASS_BLUE_MAGE:
4233 msp -= msp * (cur_wgt - max_wgt) / 600;
4237 case CLASS_MINDCRAFTER:
4238 case CLASS_BEASTMASTER:
4240 case CLASS_FORCETRAINER:
4242 case CLASS_MIRROR_MASTER:
4244 msp -= msp * (cur_wgt - max_wgt) / 800;
4247 case CLASS_SORCERER:
4249 msp -= msp * (cur_wgt - max_wgt) / 900;
4255 case CLASS_RED_MAGE:
4257 msp -= msp * (cur_wgt - max_wgt) / 1000;
4261 case CLASS_CHAOS_WARRIOR:
4262 case CLASS_WARRIOR_MAGE:
4264 msp -= msp * (cur_wgt - max_wgt) / 1200;
4269 creature_ptr->cumber_armor = FALSE;
4274 msp -= msp * (cur_wgt - max_wgt) / 800;
4280 if (msp < 0) msp = 0;
4282 if (creature_ptr->msp != msp)
4284 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI))
4286 creature_ptr->csp = msp;
4287 creature_ptr->csp_frac = 0;
4291 if (creature_ptr->level_up_message && (msp > creature_ptr->msp))
4293 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
4296 creature_ptr->msp = msp;
4297 creature_ptr->redraw |= (PR_MANA);
4298 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
4301 if (current_world_ptr->character_xtra) return;
4303 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove)
4305 if (creature_ptr->cumber_glove)
4306 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
4308 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
4310 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
4313 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor) return;
4315 if (creature_ptr->cumber_armor)
4316 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
4318 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
4320 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
4325 * @brief 装備中の射撃武器の威力倍率を返す /
4326 * calcurate the fire rate of target object
4327 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
4328 * @return 射撃倍率の値(100で1.00倍)
4330 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
4332 int extra_shots = 0;
4333 BIT_FLAGS flgs[TR_FLAG_SIZE];
4334 for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
4337 q_ptr = &creature_ptr->inventory_list[i];
4338 if (!q_ptr->k_idx) continue;
4340 if (i == INVEN_BOW) continue;
4342 object_flags(q_ptr, flgs);
4343 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
4346 object_flags(o_ptr, flgs);
4347 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
4350 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
4354 num += (extra_shots * 100);
4356 OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
4357 if ((creature_ptr->pclass == CLASS_RANGER) &&
4358 (tval_ammo == TV_ARROW))
4360 num += (creature_ptr->lev * 4);
4363 if ((creature_ptr->pclass == CLASS_CAVALRY) &&
4364 (tval_ammo == TV_ARROW))
4366 num += (creature_ptr->lev * 3);
4369 if (creature_ptr->pclass == CLASS_ARCHER)
4371 if (tval_ammo == TV_ARROW)
4372 num += ((creature_ptr->lev * 5) + 50);
4373 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
4374 num += (creature_ptr->lev * 4);
4377 if (creature_ptr->pclass == CLASS_WARRIOR &&
4378 (tval_ammo <= TV_BOLT) &&
4379 (tval_ammo >= TV_SHOT))
4381 num += (creature_ptr->lev * 2);
4384 if ((creature_ptr->pclass == CLASS_ROGUE) &&
4385 (tval_ammo == TV_SHOT))
4387 num += (creature_ptr->lev * 4);
4395 * @brief プレイヤーの所持重量制限を計算する /
4396 * Computes current weight limit.
4399 WEIGHT weight_limit(player_type *creature_ptr)
4401 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
4402 if (creature_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
4408 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
4409 * @param i 判定する手のID(右手:0 左手:1)
4410 * @return 持っているならばTRUE
4412 bool has_melee_weapon(player_type *creature_ptr, int i)
4414 return ((creature_ptr->inventory_list[i].k_idx && object_is_melee_weapon(&creature_ptr->inventory_list[i])) ? TRUE : FALSE);
4419 * @brief プレイヤーの現在開いている手の状態を返す
4420 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
4421 * @return 開いている手のビットフラグ
4423 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
4425 BIT_FLAGS16 status = EMPTY_HAND_NONE;
4426 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
4427 if (!creature_ptr->inventory_list[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
4429 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS))
4431 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
4432 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
4440 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
4441 * @return ペナルティが適用されるならばTRUE。
4443 bool heavy_armor(player_type *creature_ptr)
4445 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
4448 WEIGHT monk_arm_wgt = 0;
4449 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4450 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4451 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
4452 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
4453 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
4454 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
4455 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
4457 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
4462 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
4464 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
4466 void update_creature(player_type *creature_ptr)
4468 if (!creature_ptr->update) return;
4470 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4471 if (creature_ptr->update & (PU_AUTODESTROY))
4473 creature_ptr->update &= ~(PU_AUTODESTROY);
4474 autopick_delayed_alter(creature_ptr);
4477 if (creature_ptr->update & (PU_COMBINE))
4479 creature_ptr->update &= ~(PU_COMBINE);
4480 combine_pack(creature_ptr);
4483 if (creature_ptr->update & (PU_REORDER))
4485 creature_ptr->update &= ~(PU_REORDER);
4486 reorder_pack(creature_ptr);
4489 if (creature_ptr->update & (PU_BONUS))
4491 creature_ptr->update &= ~(PU_BONUS);
4492 calc_alignment(creature_ptr);
4493 calc_bonuses(creature_ptr);
4496 if (creature_ptr->update & (PU_TORCH))
4498 creature_ptr->update &= ~(PU_TORCH);
4499 calc_torch(creature_ptr);
4502 if (creature_ptr->update & (PU_HP))
4504 creature_ptr->update &= ~(PU_HP);
4505 calc_hitpoints(creature_ptr);
4508 if (creature_ptr->update & (PU_MANA))
4510 creature_ptr->update &= ~(PU_MANA);
4511 calc_mana(creature_ptr);
4514 if (creature_ptr->update & (PU_SPELLS))
4516 creature_ptr->update &= ~(PU_SPELLS);
4517 calc_spells(creature_ptr);
4520 if (!current_world_ptr->character_generated) return;
4521 if (current_world_ptr->character_icky) return;
4522 if (creature_ptr->update & (PU_UN_LITE))
4524 creature_ptr->update &= ~(PU_UN_LITE);
4525 forget_lite(floor_ptr);
4528 if (creature_ptr->update & (PU_UN_VIEW))
4530 creature_ptr->update &= ~(PU_UN_VIEW);
4531 forget_view(floor_ptr);
4534 if (creature_ptr->update & (PU_VIEW))
4536 creature_ptr->update &= ~(PU_VIEW);
4537 update_view(creature_ptr);
4540 if (creature_ptr->update & (PU_LITE))
4542 creature_ptr->update &= ~(PU_LITE);
4543 update_lite(creature_ptr);
4546 if (creature_ptr->update & (PU_FLOW))
4548 creature_ptr->update &= ~(PU_FLOW);
4549 update_flow(creature_ptr);
4552 if (creature_ptr->update & (PU_DISTANCE))
4554 creature_ptr->update &= ~(PU_DISTANCE);
4556 update_monsters(creature_ptr, TRUE);
4559 if (creature_ptr->update & (PU_MON_LITE))
4561 creature_ptr->update &= ~(PU_MON_LITE);
4562 update_mon_lite(creature_ptr);
4565 if (creature_ptr->update & (PU_DELAY_VIS))
4567 creature_ptr->update &= ~(PU_DELAY_VIS);
4568 delayed_visual_update(creature_ptr);
4571 if (creature_ptr->update & (PU_MONSTERS))
4573 creature_ptr->update &= ~(PU_MONSTERS);
4574 update_monsters(creature_ptr, FALSE);
4580 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
4581 * @return 魔道書を一冊も持っていないならTRUEを返す
4583 bool player_has_no_spellbooks(player_type *creature_ptr)
4586 for (int i = 0; i < INVEN_PACK; i++)
4588 o_ptr = &creature_ptr->inventory_list[i];
4589 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
4592 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4593 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
4595 o_ptr = &floor_ptr->o_list[i];
4596 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
4603 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
4605 creature_ptr->energy_use = (ENERGY)need_cost;
4609 void free_turn(player_type *creature_ptr)
4611 creature_ptr->energy_use = 0;
4616 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4619 * @return 配置に成功したらTRUE
4621 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
4623 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0) return FALSE;
4625 /* Save player location */
4626 creature_ptr->y = y;
4627 creature_ptr->x = x;
4633 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
4636 void wreck_the_pattern(player_type *creature_ptr)
4638 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4639 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
4640 if (pattern_type == PATTERN_TILE_WRECKED) return;
4642 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
4643 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
4645 if (!IS_INVULN(creature_ptr))
4646 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
4648 int to_ruin = randint1(45) + 35;
4652 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
4654 if (pattern_tile(floor_ptr, r_y, r_x) &&
4655 (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
4657 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
4661 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
4666 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
4667 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
4668 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
4671 void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
4673 if (creature_ptr->phase_out || !current_world_ptr->character_dungeon) return;
4676 if (!necro && m_ptr)
4678 GAME_TEXT m_name[MAX_NLEN];
4679 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
4680 power = r_ptr->level / 2;
4681 monster_desc(creature_ptr, m_name, m_ptr, 0);
4682 if (!(r_ptr->flags1 & RF1_UNIQUE))
4684 if (r_ptr->flags1 & RF1_FRIENDS)
4689 if (!current_world_ptr->is_loading_now)
4695 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
4701 if (randint1(100) > power) return;
4703 if (saving_throw(creature_ptr->skill_sav - power))
4706 if (creature_ptr->image)
4708 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4709 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4713 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4714 creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
4720 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4721 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
4722 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4723 if (PRACE_IS_(creature_ptr, RACE_IMP) ||
4724 PRACE_IS_(creature_ptr, RACE_DEMON) ||
4725 (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) ||
4726 current_world_ptr->wizard)
4729 if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_ZOMBIE)
4730 || PRACE_IS_(creature_ptr, RACE_VAMPIRE) || PRACE_IS_(creature_ptr, RACE_SPECTRE) ||
4731 (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
4733 if (saving_throw(25 + creature_ptr->lev)) return;
4738 monster_race *r_ptr;
4739 GAME_TEXT m_name[MAX_NLEN];
4741 get_mon_num_prep(creature_ptr, get_nightmare, NULL);
4742 r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH)];
4743 power = r_ptr->level + 10;
4744 desc = r_name + r_ptr->name;
4745 get_mon_num_prep(creature_ptr, NULL, NULL);
4749 if (!(r_ptr->flags1 & RF1_UNIQUE))
4750 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
4753 sprintf(m_name, "%s", desc);
4755 if (!(r_ptr->flags1 & RF1_UNIQUE))
4757 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
4761 if (saving_throw(creature_ptr->skill_sav * 100 / power))
4763 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
4767 if (creature_ptr->image)
4769 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4770 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4774 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4775 creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
4781 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4782 horror_desc[randint0(MAX_SAN_HORROR)], desc);
4784 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4786 if (!creature_ptr->mimic_form)
4788 switch (creature_ptr->prace)
4792 if (saving_throw(20 + creature_ptr->lev)) return;
4798 if (saving_throw(10 + creature_ptr->lev)) return;
4804 if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
4806 if (saving_throw(20 + creature_ptr->lev)) return;
4808 else if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
4810 if (saving_throw(10 + creature_ptr->lev)) return;
4816 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
4819 /* 過去の効果無効率再現のため5回saving_throw 実行 */
4820 if (saving_throw(creature_ptr->skill_sav - power)
4821 && saving_throw(creature_ptr->skill_sav - power)
4822 && saving_throw(creature_ptr->skill_sav - power)
4823 && saving_throw(creature_ptr->skill_sav - power)
4824 && saving_throw(creature_ptr->skill_sav - power)
4830 switch (randint1(22))
4833 if (!(creature_ptr->muta3 & MUT3_MORONIC))
4835 if ((creature_ptr->stat_use[A_INT] < 4) && (creature_ptr->stat_use[A_WIS] < 4))
4837 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
4841 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
4844 if (creature_ptr->muta3 & MUT3_HYPER_INT)
4846 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
4847 creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
4849 creature_ptr->muta3 |= MUT3_MORONIC;
4853 if (!(creature_ptr->muta2 & MUT2_COWARDICE) && !creature_ptr->resist_fear)
4855 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
4856 if (creature_ptr->muta3 & MUT3_FEARLESS)
4858 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
4859 creature_ptr->muta3 &= ~(MUT3_FEARLESS);
4862 creature_ptr->muta2 |= MUT2_COWARDICE;
4866 if (!(creature_ptr->muta2 & MUT2_HALLU) && !creature_ptr->resist_chaos)
4868 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
4869 creature_ptr->muta2 |= MUT2_HALLU;
4873 if (!(creature_ptr->muta2 & MUT2_BERS_RAGE) && !creature_ptr->resist_conf)
4875 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
4876 creature_ptr->muta2 |= MUT2_BERS_RAGE;
4887 if (!creature_ptr->resist_conf)
4889 (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
4892 if (!creature_ptr->resist_chaos && one_in_(3))
4894 (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
4897 /* todo いつからかは不明だがreturnとbreakが同時に存在している。どちらがデッドコードか不明瞭なので保留 */
4903 if (!creature_ptr->resist_conf)
4905 (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
4907 if (!creature_ptr->free_act)
4909 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + randint0(4) + 4);
4911 if (!creature_ptr->resist_chaos)
4913 (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
4918 (void)do_dec_stat(creature_ptr, A_INT);
4919 } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
4923 (void)do_dec_stat(creature_ptr, A_WIS);
4924 } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
4929 if (lose_all_info(creature_ptr))
4930 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
4937 do_dec_stat(creature_ptr, A_INT);
4938 do_dec_stat(creature_ptr, A_WIS);
4944 creature_ptr->update |= PU_BONUS;
4945 handle_stuff(creature_ptr);
4950 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
4951 * Advance experience levels and print experience
4954 void check_experience(player_type *creature_ptr)
4956 if (creature_ptr->exp < 0) creature_ptr->exp = 0;
4957 if (creature_ptr->max_exp < 0) creature_ptr->max_exp = 0;
4958 if (creature_ptr->max_max_exp < 0) creature_ptr->max_max_exp = 0;
4960 if (creature_ptr->exp > PY_MAX_EXP) creature_ptr->exp = PY_MAX_EXP;
4961 if (creature_ptr->max_exp > PY_MAX_EXP) creature_ptr->max_exp = PY_MAX_EXP;
4962 if (creature_ptr->max_max_exp > PY_MAX_EXP) creature_ptr->max_max_exp = PY_MAX_EXP;
4964 if (creature_ptr->exp > creature_ptr->max_exp) creature_ptr->max_exp = creature_ptr->exp;
4965 if (creature_ptr->max_exp > creature_ptr->max_max_exp) creature_ptr->max_max_exp = creature_ptr->max_exp;
4967 creature_ptr->redraw |= (PR_EXP);
4968 handle_stuff(creature_ptr);
4970 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
4971 PLAYER_LEVEL old_lev = creature_ptr->lev;
4972 while ((creature_ptr->lev > 1) &&
4973 (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L)))
4975 creature_ptr->lev--;
4976 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4977 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
4978 creature_ptr->window |= (PW_PLAYER);
4979 handle_stuff(creature_ptr);
4982 bool level_reward = FALSE;
4983 bool level_mutation = FALSE;
4984 bool level_inc_stat = FALSE;
4985 while ((creature_ptr->lev < PY_MAX_LEVEL) &&
4986 (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L)))
4988 creature_ptr->lev++;
4989 if (creature_ptr->lev > creature_ptr->max_plv)
4991 creature_ptr->max_plv = creature_ptr->lev;
4993 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
4994 (creature_ptr->muta2 & MUT2_CHAOS_GIFT))
4996 level_reward = TRUE;
4998 if (creature_ptr->prace == RACE_BEASTMAN)
5000 if (one_in_(5)) level_mutation = TRUE;
5002 level_inc_stat = TRUE;
5004 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
5008 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
5009 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5010 creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
5011 creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
5012 creature_ptr->level_up_message = TRUE;
5013 handle_stuff(creature_ptr);
5015 creature_ptr->level_up_message = FALSE;
5018 if (!(creature_ptr->max_plv % 10))
5027 cnv_stat(creature_ptr->stat_max[0], tmp);
5028 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
5029 cnv_stat(creature_ptr->stat_max[1], tmp);
5030 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
5031 cnv_stat(creature_ptr->stat_max[2], tmp);
5032 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
5033 cnv_stat(creature_ptr->stat_max[3], tmp);
5034 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
5035 cnv_stat(creature_ptr->stat_max[4], tmp);
5036 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
5037 cnv_stat(creature_ptr->stat_max[5], tmp);
5038 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
5041 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
5046 if ((choice >= 'a') && (choice <= 'f')) break;
5048 for (n = 0; n < A_MAX; n++)
5049 if (n != choice - 'a')
5051 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
5053 do_inc_stat(creature_ptr, choice - 'a');
5056 else if (!(creature_ptr->max_plv % 2))
5057 do_inc_stat(creature_ptr, randint0(6));
5062 msg_print(_("あなたは変わった気がする...", "You feel different..."));
5063 (void)gain_mutation(creature_ptr, 0);
5064 level_mutation = FALSE;
5068 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
5073 gain_level_reward(creature_ptr, 0);
5074 level_reward = FALSE;
5077 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5078 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
5079 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
5080 handle_stuff(creature_ptr);
5083 if (old_lev != creature_ptr->lev)
5084 autopick_load_pref(creature_ptr, FALSE);
5089 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
5091 * @param out_val 出力先文字列ポインタ
5094 void cnv_stat(int val, char *out_val)
5098 sprintf(out_val, " %2d", val);
5102 int bonus = (val - 18);
5105 sprintf(out_val, "18/%3s", "***");
5107 else if (bonus >= 100)
5109 sprintf(out_val, "18/%03d", bonus);
5113 sprintf(out_val, " 18/%02d", bonus);
5119 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
5120 * Modify a stat value by a "modifier", return new value
5122 * @param amount 加減算値
5126 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
5127 * Or even: 18/13, 18/23, 18/33, ..., 18/220
5128 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
5129 * Or even: 18/13, 18/03, 18, 17, ..., 3
5132 s16b modify_stat_value(int value, int amount)
5136 for (int i = 0; i < amount; i++)
5138 if (value < 18) value++;
5142 else if (amount < 0)
5144 for (int i = 0; i < (0 - amount); i++)
5146 if (value >= 18 + 10) value -= 10;
5147 else if (value > 18) value = 18;
5148 else if (value > 3) value--;
5158 * Hack -- Calculates the total number of points earned -JWT-
5162 long calc_score(player_type *creature_ptr)
5164 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
5167 if (!preserve_mode) mult += 10;
5168 if (!autoroller) mult += 10;
5169 if (!smart_learn) mult -= 20;
5170 if (smart_cheat) mult += 30;
5171 if (ironman_shops) mult += 50;
5172 if (ironman_small_levels) mult += 10;
5173 if (ironman_empty_levels) mult += 20;
5174 if (!powerup_home) mult += 50;
5175 if (ironman_rooms) mult += 100;
5176 if (ironman_nightmare) mult += 100;
5178 if (mult < 5) mult = 5;
5181 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
5182 if (max_dlv[i] > max_dl)
5183 max_dl = max_dlv[i];
5185 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
5186 u32b point_h = point_l / 0x10000L;
5187 point_l = point_l % 0x10000L;
5190 point_h += point_l / 0x10000L;
5191 point_l %= 0x10000L;
5193 point_l += ((point_h % 100) << 16);
5197 u32b point = (point_h << 16) + (point_l);
5198 if (creature_ptr->arena_number >= 0)
5199 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
5201 if (ironman_downward) point *= 2;
5202 if (creature_ptr->pclass == CLASS_BERSERKER)
5204 if (creature_ptr->prace == RACE_SPECTRE)
5208 if ((creature_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
5211 if (current_world_ptr->total_winner) point = 2;
5214 if (easy_band) point = (0 - point);
5220 void cheat_death(player_type *creature_ptr)
5222 if (creature_ptr->sc)
5223 creature_ptr->sc = creature_ptr->age = 0;
5224 creature_ptr->age++;
5226 current_world_ptr->noscore |= 0x0001;
5227 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
5230 (void)life_stream(creature_ptr, FALSE, FALSE);
5231 if (creature_ptr->pclass == CLASS_MAGIC_EATER)
5234 for (magic_idx = 0; magic_idx < EATER_EXT * 2; magic_idx++)
5236 creature_ptr->magic_num1[magic_idx] = creature_ptr->magic_num2[magic_idx] * EATER_CHARGE;
5238 for (; magic_idx < EATER_EXT * 3; magic_idx++)
5240 creature_ptr->magic_num1[magic_idx] = 0;
5244 creature_ptr->csp = creature_ptr->msp;
5245 creature_ptr->csp_frac = 0;
5246 if (creature_ptr->word_recall)
5248 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
5250 creature_ptr->word_recall = 0;
5251 creature_ptr->redraw |= (PR_STATUS);
5254 if (creature_ptr->alter_reality)
5256 creature_ptr->alter_reality = 0;
5257 creature_ptr->redraw |= (PR_STATUS);
5260 (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
5261 creature_ptr->is_dead = FALSE;
5262 (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
5264 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
5265 floor_ptr->dun_level = 0;
5266 floor_ptr->inside_arena = FALSE;
5267 creature_ptr->phase_out = FALSE;
5269 floor_ptr->inside_quest = 0;
5270 if (creature_ptr->dungeon_idx) creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
5271 creature_ptr->dungeon_idx = 0;
5272 if (lite_town || vanilla_town)
5274 creature_ptr->wilderness_y = 1;
5275 creature_ptr->wilderness_x = 1;
5278 creature_ptr->oldpy = 10;
5279 creature_ptr->oldpx = 34;
5283 creature_ptr->oldpy = 33;
5284 creature_ptr->oldpx = 131;
5289 creature_ptr->wilderness_y = 48;
5290 creature_ptr->wilderness_x = 5;
5291 creature_ptr->oldpy = 33;
5292 creature_ptr->oldpx = 131;
5295 creature_ptr->wild_mode = FALSE;
5296 creature_ptr->leaving = TRUE;
5298 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1,
5302 leave_floor(creature_ptr);
5303 wipe_monsters_list(creature_ptr);
5308 * @param creature_ptr プレーヤーへの参照ポインタ
5309 * @return 祝福状態ならばTRUE
5311 bool is_blessed(player_type *creature_ptr)
5313 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
5317 bool is_oppose_acid(player_type *creature_ptr)
5319 return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5323 bool is_oppose_elec(player_type *creature_ptr)
5325 return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5329 bool is_oppose_fire(player_type *creature_ptr)
5331 return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5335 bool is_oppose_cold(player_type *creature_ptr)
5337 return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5341 bool is_oppose_pois(player_type *creature_ptr)
5343 return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5347 bool is_tim_esp(player_type *creature_ptr)
5349 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
5353 bool is_tim_stealth(player_type *creature_ptr)
5355 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
5359 bool is_time_limit_esp(player_type *creature_ptr)
5361 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
5365 bool is_time_limit_stealth(player_type *creature_ptr)
5367 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
5371 bool can_two_hands_wielding(player_type *creature_ptr)
5373 return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS);
5379 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
5382 void stop_singing(player_type *creature_ptr)
5384 if (creature_ptr->pclass != CLASS_BARD) return;
5386 /* Are there interupted song? */
5387 if (INTERUPTING_SONG_EFFECT(creature_ptr))
5389 /* Forget interupted song */
5390 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
5394 /* The player is singing? */
5395 if (!SINGING_SONG_EFFECT(creature_ptr)) return;
5397 /* Hack -- if called from set_action(), avoid recursive loop */
5398 if (creature_ptr->action == ACTION_SING) set_action(creature_ptr, ACTION_NONE);
5400 /* Message text of each song or etc. */
5401 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
5403 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
5404 SINGING_SONG_ID(creature_ptr) = 0;
5405 creature_ptr->update |= (PU_BONUS);
5406 creature_ptr->redraw |= (PR_STATUS);
5410 * @brief 口を使う継続的な処理を中断する
5411 * @param caster_ptr プレーヤーへの参照ポインタ
5414 void stop_mouth(player_type *caster_ptr)
5416 if (music_singing_any(caster_ptr)) stop_singing(caster_ptr);
5417 if (hex_spelling_any(caster_ptr)) stop_hex_spell_all(caster_ptr);
5422 * @brief ペットの維持コスト計算
5425 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
5428 bool have_a_unique = FALSE;
5429 DEPTH total_friend_levels = 0;
5433 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
5435 monster_type *m_ptr;
5436 monster_race *r_ptr;
5438 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
5439 if (!monster_is_valid(m_ptr)) continue;
5440 r_ptr = &r_info[m_ptr->r_idx];
5445 if (r_ptr->flags1 & RF1_UNIQUE)
5447 if (creature_ptr->pclass == CLASS_CAVALRY)
5449 if (creature_ptr->riding == m_idx)
5450 total_friend_levels += (r_ptr->level + 5) * 2;
5451 else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
5452 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
5454 total_friend_levels += (r_ptr->level + 5) * 10;
5455 have_a_unique = TRUE;
5458 total_friend_levels += (r_ptr->level + 5) * 10;
5461 total_friend_levels += r_ptr->level;
5469 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
5470 if (upkeep_factor < 0) upkeep_factor = 0;
5471 if (upkeep_factor > 1000) upkeep_factor = 1000;
5472 return upkeep_factor;
5478 bool music_singing(player_type *caster_ptr, int music_songs)
5480 return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);