4 #include "main/sound-definitions-table.h"
6 #include "market/building.h"
8 #include "player-move.h"
9 #include "player-status.h"
10 #include "player-effects.h"
11 #include "player-skill.h"
12 #include "player/race-info-table.h"
13 #include "player/mimic-info-table.h"
14 #include "player-class.h"
15 #include "player-personality.h"
16 #include "player-damage.h"
18 #include "floor-events.h"
22 #include "spell/technic-info-table.h"
23 #include "spells-status.h"
25 #include "object-hook.h"
26 #include "object-ego.h"
28 #include "monster-status.h"
29 #include "monsterrace-hook.h"
32 #include "realm/realm-hex.h"
33 #include "realm/realm-song.h"
34 #include "cmd/cmd-pet.h"
35 #include "cmd/cmd-spell.h"
37 #include "object/object-kind.h"
38 #include "monsterrace.h"
39 #include "autopick/autopick.h"
40 #include "autopick/autopick-reader-writer.h"
41 #include "io/write-diary.h"
42 #include "cmd/cmd-dump.h"
45 #include "view/display-main-window.h"
47 #include "cmd-magiceat.h"
49 #include "horror-descriptions.h"
50 #include "market/arena-info-table.h"
53 * @brief 能力値テーブル / Abbreviations of healthy stats
55 const concptr stat_names[6] =
58 "腕力 :", "知能 :", "賢さ :", "器用 :", "耐久 :", "魅力 :"
60 "STR : ", "INT : ", "WIS : ", "DEX : ", "CON : ", "CHR : "
65 * @brief 能力値テーブル(能力低下時) / Abbreviations of damaged stats
67 const concptr stat_names_reduced[6] =
70 "腕力x:", "知能x:", "賢さx:", "器用x:", "耐久x:", "魅力x:"
72 "Str : ", "Int : ", "Wis : ", "Dex : ", "Con : ", "Chr : "
77 * @brief 基本必要経験値テーブル /
78 * Base experience levels, may be adjusted up for race and/or class
80 const s32b player_exp[PY_MAX_LEVEL] =
135 * @brief 基本必要強化値テーブル(アンドロイド専用)
137 const s32b player_exp_a[PY_MAX_LEVEL] =
192 * 知力/賢さによるレベル毎の習得可能魔法数テーブル
193 * Stat Table (INT/WIS) -- Number of half-spells per level
195 const byte adj_mag_study[] =
222 4 /* 18/100-18/109 */,
223 4 /* 18/110-18/119 */,
224 5 /* 18/120-18/129 */,
225 5 /* 18/130-18/139 */,
226 5 /* 18/140-18/149 */,
227 5 /* 18/150-18/159 */,
228 5 /* 18/160-18/169 */,
229 5 /* 18/170-18/179 */,
230 5 /* 18/180-18/189 */,
231 5 /* 18/190-18/199 */,
232 5 /* 18/200-18/209 */,
233 6 /* 18/210-18/219 */,
239 * Stat Table (INT/WIS) -- extra 1/4-mana-points per level
241 const byte adj_mag_mana[] =
258 10 /* 18/00-18/09 */,
259 11 /* 18/10-18/19 */,
260 11 /* 18/20-18/29 */,
261 12 /* 18/30-18/39 */,
262 12 /* 18/40-18/49 */,
263 13 /* 18/50-18/59 */,
264 14 /* 18/60-18/69 */,
265 15 /* 18/70-18/79 */,
266 16 /* 18/80-18/89 */,
267 17 /* 18/90-18/99 */,
268 18 /* 18/100-18/109 */,
269 19 /* 18/110-18/119 */,
270 20 /* 18/120-18/129 */,
271 21 /* 18/130-18/139 */,
272 22 /* 18/140-18/149 */,
273 23 /* 18/150-18/159 */,
274 24 /* 18/160-18/169 */,
275 25 /* 18/170-18/179 */,
276 26 /* 18/180-18/189 */,
277 27 /* 18/190-18/199 */,
278 28 /* 18/200-18/209 */,
279 29 /* 18/210-18/219 */,
284 * 知力/賢さによる最低魔法失敗率テーブル
285 * Stat Table (INT/WIS) -- Minimum failure rate (percentage)
287 const byte adj_mag_fail[] =
314 3 /* 18/100-18/109 */,
315 2 /* 18/110-18/119 */,
316 2 /* 18/120-18/129 */,
317 2 /* 18/130-18/139 */,
318 2 /* 18/140-18/149 */,
319 1 /* 18/150-18/159 */,
320 1 /* 18/160-18/169 */,
321 1 /* 18/170-18/179 */,
322 1 /* 18/180-18/189 */,
323 1 /* 18/190-18/199 */,
324 0 /* 18/200-18/209 */,
325 0 /* 18/210-18/219 */,
330 * 知力/賢さによる魔法失敗率修正テーブル
331 * Stat Table (INT/WIS) -- Various things
333 const byte adj_mag_stat[] =
360 8 /* 18/100-18/109 */,
361 9 /* 18/110-18/119 */,
362 10 /* 18/120-18/129 */,
363 11 /* 18/130-18/139 */,
364 12 /* 18/140-18/149 */,
365 13 /* 18/150-18/159 */,
366 14 /* 18/160-18/169 */,
367 15 /* 18/170-18/179 */,
368 16 /* 18/180-18/189 */,
369 17 /* 18/190-18/199 */,
370 18 /* 18/200-18/209 */,
371 19 /* 18/210-18/219 */,
377 * Stat Table (CHR) -- payment percentages
379 const byte adj_chr_gold[] =
396 100 /* 18/00-18/09 */,
397 99 /* 18/10-18/19 */,
398 98 /* 18/20-18/29 */,
399 97 /* 18/30-18/39 */,
400 96 /* 18/40-18/49 */,
401 95 /* 18/50-18/59 */,
402 94 /* 18/60-18/69 */,
403 93 /* 18/70-18/79 */,
404 92 /* 18/80-18/89 */,
405 91 /* 18/90-18/99 */,
406 90 /* 18/100-18/109 */,
407 89 /* 18/110-18/119 */,
408 88 /* 18/120-18/129 */,
409 87 /* 18/130-18/139 */,
410 86 /* 18/140-18/149 */,
411 85 /* 18/150-18/159 */,
412 84 /* 18/160-18/169 */,
413 83 /* 18/170-18/179 */,
414 82 /* 18/180-18/189 */,
415 81 /* 18/190-18/199 */,
416 80 /* 18/200-18/209 */,
417 79 /* 18/210-18/219 */,
423 * Stat Table (INT) -- Magic devices
425 const byte adj_int_dev[] =
452 8 /* 18/100-18/109 */,
453 9 /* 18/110-18/119 */,
454 10 /* 18/120-18/129 */,
455 11 /* 18/130-18/139 */,
456 12 /* 18/140-18/149 */,
457 13 /* 18/150-18/159 */,
458 14 /* 18/160-18/169 */,
459 15 /* 18/170-18/179 */,
460 16 /* 18/180-18/189 */,
461 17 /* 18/190-18/199 */,
462 18 /* 18/200-18/209 */,
463 19 /* 18/210-18/219 */,
469 * Stat Table (WIS) -- Saving throw
471 const byte adj_wis_sav[] =
498 7 /* 18/100-18/109 */,
499 8 /* 18/110-18/119 */,
500 9 /* 18/120-18/129 */,
501 10 /* 18/130-18/139 */,
502 11 /* 18/140-18/149 */,
503 12 /* 18/150-18/159 */,
504 13 /* 18/160-18/169 */,
505 14 /* 18/170-18/179 */,
506 15 /* 18/180-18/189 */,
507 16 /* 18/190-18/199 */,
508 17 /* 18/200-18/209 */,
509 18 /* 18/210-18/219 */,
515 * Stat Table (DEX) -- disarming
517 const byte adj_dex_dis[] =
544 8 /* 18/100-18/109 */,
545 8 /* 18/110-18/119 */,
546 8 /* 18/120-18/129 */,
547 8 /* 18/130-18/139 */,
548 8 /* 18/140-18/149 */,
549 9 /* 18/150-18/159 */,
550 9 /* 18/160-18/169 */,
551 9 /* 18/170-18/179 */,
552 9 /* 18/180-18/189 */,
553 9 /* 18/190-18/199 */,
554 10 /* 18/200-18/209 */,
555 10 /* 18/210-18/219 */,
561 * Stat Table (INT) -- disarming
563 const byte adj_int_dis[] =
590 10 /* 18/100-18/109 */,
591 10 /* 18/110-18/119 */,
592 11 /* 18/120-18/129 */,
593 12 /* 18/130-18/139 */,
594 13 /* 18/140-18/149 */,
595 14 /* 18/150-18/159 */,
596 15 /* 18/160-18/169 */,
597 16 /* 18/170-18/179 */,
598 17 /* 18/180-18/189 */,
599 18 /* 18/190-18/199 */,
600 19 /* 18/200-18/209 */,
601 19 /* 18/210-18/219 */,
607 * Stat Table (DEX) -- bonus to ac (plus 128)
609 const byte adj_dex_ta[] =
626 128 + 2 /* 18/00-18/09 */,
627 128 + 2 /* 18/10-18/19 */,
628 128 + 2 /* 18/20-18/29 */,
629 128 + 2 /* 18/30-18/39 */,
630 128 + 2 /* 18/40-18/49 */,
631 128 + 3 /* 18/50-18/59 */,
632 128 + 3 /* 18/60-18/69 */,
633 128 + 3 /* 18/70-18/79 */,
634 128 + 4 /* 18/80-18/89 */,
635 128 + 5 /* 18/90-18/99 */,
636 128 + 6 /* 18/100-18/109 */,
637 128 + 7 /* 18/110-18/119 */,
638 128 + 8 /* 18/120-18/129 */,
639 128 + 9 /* 18/130-18/139 */,
640 128 + 9 /* 18/140-18/149 */,
641 128 + 10 /* 18/150-18/159 */,
642 128 + 11 /* 18/160-18/169 */,
643 128 + 12 /* 18/170-18/179 */,
644 128 + 13 /* 18/180-18/189 */,
645 128 + 14 /* 18/190-18/199 */,
646 128 + 15 /* 18/200-18/209 */,
647 128 + 15 /* 18/210-18/219 */,
648 128 + 16 /* 18/220+ */
653 * Stat Table (STR) -- bonus to dam (plus 128)
655 const byte adj_str_td[] =
672 128 + 2 /* 18/00-18/09 */,
673 128 + 2 /* 18/10-18/19 */,
674 128 + 3 /* 18/20-18/29 */,
675 128 + 3 /* 18/30-18/39 */,
676 128 + 3 /* 18/40-18/49 */,
677 128 + 3 /* 18/50-18/59 */,
678 128 + 3 /* 18/60-18/69 */,
679 128 + 4 /* 18/70-18/79 */,
680 128 + 5 /* 18/80-18/89 */,
681 128 + 5 /* 18/90-18/99 */,
682 128 + 6 /* 18/100-18/109 */,
683 128 + 7 /* 18/110-18/119 */,
684 128 + 8 /* 18/120-18/129 */,
685 128 + 9 /* 18/130-18/139 */,
686 128 + 10 /* 18/140-18/149 */,
687 128 + 11 /* 18/150-18/159 */,
688 128 + 12 /* 18/160-18/169 */,
689 128 + 13 /* 18/170-18/179 */,
690 128 + 14 /* 18/180-18/189 */,
691 128 + 15 /* 18/190-18/199 */,
692 128 + 16 /* 18/200-18/209 */,
693 128 + 18 /* 18/210-18/219 */,
694 128 + 20 /* 18/220+ */
699 * Stat Table (DEX) -- bonus to hit (plus 128)
701 const byte adj_dex_th[] =
718 128 + 3 /* 18/00-18/09 */,
719 128 + 3 /* 18/10-18/19 */,
720 128 + 3 /* 18/20-18/29 */,
721 128 + 3 /* 18/30-18/39 */,
722 128 + 3 /* 18/40-18/49 */,
723 128 + 4 /* 18/50-18/59 */,
724 128 + 4 /* 18/60-18/69 */,
725 128 + 4 /* 18/70-18/79 */,
726 128 + 4 /* 18/80-18/89 */,
727 128 + 5 /* 18/90-18/99 */,
728 128 + 6 /* 18/100-18/109 */,
729 128 + 7 /* 18/110-18/119 */,
730 128 + 8 /* 18/120-18/129 */,
731 128 + 9 /* 18/130-18/139 */,
732 128 + 9 /* 18/140-18/149 */,
733 128 + 10 /* 18/150-18/159 */,
734 128 + 11 /* 18/160-18/169 */,
735 128 + 12 /* 18/170-18/179 */,
736 128 + 13 /* 18/180-18/189 */,
737 128 + 14 /* 18/190-18/199 */,
738 128 + 15 /* 18/200-18/209 */,
739 128 + 15 /* 18/210-18/219 */,
740 128 + 16 /* 18/220+ */
745 * Stat Table (STR) -- bonus to hit (plus 128)
747 const byte adj_str_th[] =
764 128 + 1 /* 18/00-18/09 */,
765 128 + 1 /* 18/10-18/19 */,
766 128 + 1 /* 18/20-18/29 */,
767 128 + 1 /* 18/30-18/39 */,
768 128 + 1 /* 18/40-18/49 */,
769 128 + 1 /* 18/50-18/59 */,
770 128 + 1 /* 18/60-18/69 */,
771 128 + 2 /* 18/70-18/79 */,
772 128 + 3 /* 18/80-18/89 */,
773 128 + 4 /* 18/90-18/99 */,
774 128 + 5 /* 18/100-18/109 */,
775 128 + 6 /* 18/110-18/119 */,
776 128 + 7 /* 18/120-18/129 */,
777 128 + 8 /* 18/130-18/139 */,
778 128 + 9 /* 18/140-18/149 */,
779 128 + 10 /* 18/150-18/159 */,
780 128 + 11 /* 18/160-18/169 */,
781 128 + 12 /* 18/170-18/179 */,
782 128 + 13 /* 18/180-18/189 */,
783 128 + 14 /* 18/190-18/199 */,
784 128 + 15 /* 18/200-18/209 */,
785 128 + 15 /* 18/210-18/219 */,
786 128 + 16 /* 18/220+ */
791 * Stat Table (STR) -- weight limit in deca-pounds
793 const byte adj_str_wgt[] =
810 25 /* 18/00-18/09 */,
811 26 /* 18/10-18/19 */,
812 27 /* 18/20-18/29 */,
813 28 /* 18/30-18/39 */,
814 29 /* 18/40-18/49 */,
815 30 /* 18/50-18/59 */,
816 31 /* 18/60-18/69 */,
817 31 /* 18/70-18/79 */,
818 32 /* 18/80-18/89 */,
819 32 /* 18/90-18/99 */,
820 33 /* 18/100-18/109 */,
821 33 /* 18/110-18/119 */,
822 34 /* 18/120-18/129 */,
823 34 /* 18/130-18/139 */,
824 35 /* 18/140-18/149 */,
825 35 /* 18/150-18/159 */,
826 36 /* 18/160-18/169 */,
827 36 /* 18/170-18/179 */,
828 37 /* 18/180-18/189 */,
829 37 /* 18/190-18/199 */,
830 38 /* 18/200-18/209 */,
831 38 /* 18/210-18/219 */,
837 * Stat Table (STR) -- weapon weight limit in pounds
839 const byte adj_str_hold[] =
856 19 /* 18/00-18/09 */,
857 20 /* 18/10-18/19 */,
858 21 /* 18/20-18/29 */,
859 22 /* 18/30-18/39 */,
860 23 /* 18/40-18/49 */,
861 24 /* 18/50-18/59 */,
862 25 /* 18/60-18/69 */,
863 26 /* 18/70-18/79 */,
864 27 /* 18/80-18/89 */,
865 28 /* 18/90-18/99 */,
866 30 /* 18/100-18/109 */,
867 31 /* 18/110-18/119 */,
868 32 /* 18/120-18/129 */,
869 33 /* 18/130-18/139 */,
870 34 /* 18/140-18/149 */,
871 35 /* 18/150-18/159 */,
872 37 /* 18/160-18/169 */,
873 40 /* 18/170-18/179 */,
874 44 /* 18/180-18/189 */,
875 48 /* 18/190-18/199 */,
876 50 /* 18/200-18/209 */,
877 50 /* 18/210-18/219 */,
883 * Stat Table (STR) -- digging value
885 const byte adj_str_dig[] =
903 10 /* 18/10-18/19 */,
904 12 /* 18/20-18/29 */,
905 15 /* 18/30-18/39 */,
906 20 /* 18/40-18/49 */,
907 25 /* 18/50-18/59 */,
908 30 /* 18/60-18/69 */,
909 35 /* 18/70-18/79 */,
910 40 /* 18/80-18/89 */,
911 45 /* 18/90-18/99 */,
912 50 /* 18/100-18/109 */,
913 55 /* 18/110-18/119 */,
914 60 /* 18/120-18/129 */,
915 65 /* 18/130-18/139 */,
916 70 /* 18/140-18/149 */,
917 75 /* 18/150-18/159 */,
918 80 /* 18/160-18/169 */,
919 85 /* 18/170-18/179 */,
920 90 /* 18/180-18/189 */,
921 95 /* 18/190-18/199 */,
922 100 /* 18/200-18/209 */,
923 100 /* 18/210-18/219 */,
928 * 器用さによる盗難防止&体当たり成功判定修正テーブル
929 * Stat Table (DEX) -- chance of avoiding "theft" and "falling"
931 const byte adj_dex_safe[] =
948 10 /* 18/00-18/09 */,
949 10 /* 18/10-18/19 */,
950 15 /* 18/20-18/29 */,
951 15 /* 18/30-18/39 */,
952 20 /* 18/40-18/49 */,
953 25 /* 18/50-18/59 */,
954 30 /* 18/60-18/69 */,
955 35 /* 18/70-18/79 */,
956 40 /* 18/80-18/89 */,
957 45 /* 18/90-18/99 */,
958 50 /* 18/100-18/109 */,
959 60 /* 18/110-18/119 */,
960 70 /* 18/120-18/129 */,
961 80 /* 18/130-18/139 */,
962 90 /* 18/140-18/149 */,
963 100 /* 18/150-18/159 */,
964 100 /* 18/160-18/169 */,
965 100 /* 18/170-18/179 */,
966 100 /* 18/180-18/189 */,
967 100 /* 18/190-18/199 */,
968 100 /* 18/200-18/209 */,
969 100 /* 18/210-18/219 */,
974 * 耐久による基本HP自然治癒値テーブル /
975 * Stat Table (CON) -- base regeneration rate
977 const byte adj_con_fix[] =
1000 3 /* 18/60-18/69 */,
1001 3 /* 18/70-18/79 */,
1002 3 /* 18/80-18/89 */,
1003 3 /* 18/90-18/99 */,
1004 4 /* 18/100-18/109 */,
1005 4 /* 18/110-18/119 */,
1006 5 /* 18/120-18/129 */,
1007 6 /* 18/130-18/139 */,
1008 6 /* 18/140-18/149 */,
1009 7 /* 18/150-18/159 */,
1010 7 /* 18/160-18/169 */,
1011 8 /* 18/170-18/179 */,
1012 8 /* 18/180-18/189 */,
1013 8 /* 18/190-18/199 */,
1014 9 /* 18/200-18/209 */,
1015 9 /* 18/210-18/219 */,
1020 * 耐久による基本HP自然治癒値テーブル /
1021 * Stat Table (CON) -- extra 1/4-hitpoints per level (plus 128)
1023 const byte adj_con_mhp[] =
1040 128 + 4 /* 18/00-18/09 */,
1041 128 + 5 /* 18/10-18/19 */,
1042 128 + 6 /* 18/20-18/29 */,
1043 128 + 7 /* 18/30-18/39 */,
1044 128 + 8 /* 18/40-18/49 */,
1045 128 + 9 /* 18/50-18/59 */,
1046 128 + 10 /* 18/60-18/69 */,
1047 128 + 11 /* 18/70-18/79 */,
1048 128 + 12 /* 18/80-18/89 */,
1049 128 + 14 /* 18/90-18/99 */,
1050 128 + 17 /* 18/100-18/109 */,
1051 128 + 20 /* 18/110-18/119 */,
1052 128 + 23 /* 18/120-18/129 */,
1053 128 + 26 /* 18/130-18/139 */,
1054 128 + 29 /* 18/140-18/149 */,
1055 128 + 32 /* 18/150-18/159 */,
1056 128 + 35 /* 18/160-18/169 */,
1057 128 + 38 /* 18/170-18/179 */,
1058 128 + 40 /* 18/180-18/189 */,
1059 128 + 42 /* 18/190-18/199 */,
1060 128 + 44 /* 18/200-18/209 */,
1061 128 + 46 /* 18/210-18/219 */,
1062 128 + 48 /* 18/220+ */
1067 * Stat Table (CHR) -- charm
1069 const byte adj_chr_chm[] =
1086 9 /* 18/00-18/09 */,
1087 10 /* 18/10-18/19 */,
1088 12 /* 18/20-18/29 */,
1089 15 /* 18/30-18/39 */,
1090 18 /* 18/40-18/49 */,
1091 21 /* 18/50-18/59 */,
1092 24 /* 18/60-18/69 */,
1093 28 /* 18/70-18/79 */,
1094 32 /* 18/80-18/89 */,
1095 36 /* 18/90-18/99 */,
1096 39 /* 18/100-18/109 */,
1097 42 /* 18/110-18/119 */,
1098 45 /* 18/120-18/129 */,
1099 49 /* 18/130-18/139 */,
1100 53 /* 18/140-18/149 */,
1101 57 /* 18/150-18/159 */,
1102 61 /* 18/160-18/169 */,
1103 65 /* 18/170-18/179 */,
1104 69 /* 18/180-18/189 */,
1105 73 /* 18/190-18/199 */,
1106 77 /* 18/200-18/209 */,
1107 81 /* 18/210-18/219 */,
1111 /*** Player information ***/
1114 * Static player info record
1119 * Pointer to the player info
1121 player_type *p_ptr = &p_body;
1124 * Return alignment title
1126 concptr your_alignment(player_type *creature_ptr)
1128 if (creature_ptr->align > 150) return _("大善", "Lawful");
1129 else if (creature_ptr->align > 50) return _("中善", "Good");
1130 else if (creature_ptr->align > 10) return _("小善", "Neutral Good");
1131 else if (creature_ptr->align > -11) return _("中立", "Neutral");
1132 else if (creature_ptr->align > -51) return _("小悪", "Neutral Evil");
1133 else if (creature_ptr->align > -151) return _("中悪", "Evil");
1134 else return _("大悪", "Chaotic");
1139 * Return proficiency level of weapons and misc. skills (except riding)
1141 int weapon_exp_level(int weapon_exp)
1143 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1144 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1145 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1146 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
1147 else return EXP_LEVEL_MASTER;
1152 * Return proficiency level of riding
1154 int riding_exp_level(int riding_exp)
1156 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1157 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1158 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1159 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
1160 else return EXP_LEVEL_MASTER;
1165 * Return proficiency level of spells
1167 int spell_exp_level(int spell_exp)
1169 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1170 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1171 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1172 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
1173 else return EXP_LEVEL_MASTER;
1178 * @brief プレイヤーの全ステータスを更新する /
1179 * Calculate the players current "state", taking into account
1180 * not only race/class intrinsics, but also objects being worn
1181 * and temporary spell effects.
1185 * See also calc_mana() and calc_hitpoints().
1187 * Take note of the new "speed code", in particular, a very strong
1188 * player will start slowing down as soon as he reaches 150 pounds,
1189 * but not until he reaches 450 pounds will he be half as fast as
1190 * a normal kobold. This both hurts and helps the player, hurts
1191 * because in the old days a player could just avoid 300 pounds,
1192 * and helps because now carrying 300 pounds is not very painful.
1194 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
1195 * damage, since that would affect non-combat things. These values
1196 * are actually added in later, at the appropriate place.
1198 * This function induces various "status" messages.
1201 void calc_bonuses(player_type *creature_ptr)
1205 int default_hand = 0;
1206 int empty_hands_status = empty_hands(creature_ptr, TRUE);
1209 BIT_FLAGS flgs[TR_FLAG_SIZE];
1211 bool yoiyami = FALSE;
1212 bool down_saving = FALSE;
1214 bool have_sw = FALSE, have_kabe = FALSE;
1215 bool easy_2weapon = FALSE;
1216 bool riding_levitation = FALSE;
1217 OBJECT_IDX this_o_idx, next_o_idx = 0;
1218 const player_race *tmp_rp_ptr;
1220 /* Save the old vision stuff */
1221 bool old_telepathy = creature_ptr->telepathy;
1222 bool old_esp_animal = creature_ptr->esp_animal;
1223 bool old_esp_undead = creature_ptr->esp_undead;
1224 bool old_esp_demon = creature_ptr->esp_demon;
1225 bool old_esp_orc = creature_ptr->esp_orc;
1226 bool old_esp_troll = creature_ptr->esp_troll;
1227 bool old_esp_giant = creature_ptr->esp_giant;
1228 bool old_esp_dragon = creature_ptr->esp_dragon;
1229 bool old_esp_human = creature_ptr->esp_human;
1230 bool old_esp_evil = creature_ptr->esp_evil;
1231 bool old_esp_good = creature_ptr->esp_good;
1232 bool old_esp_nonliving = creature_ptr->esp_nonliving;
1233 bool old_esp_unique = creature_ptr->esp_unique;
1234 bool old_see_inv = creature_ptr->see_inv;
1235 bool old_mighty_throw = creature_ptr->mighty_throw;
1237 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1238 feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
1240 ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
1241 ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
1243 extra_blows[0] = extra_blows[1] = 0;
1245 for (int i = 0; i < A_MAX; i++) creature_ptr->stat_add[i] = 0;
1247 creature_ptr->dis_ac = creature_ptr->ac = 0;
1248 creature_ptr->dis_to_h[0] = creature_ptr->to_h[0] = 0;
1249 creature_ptr->dis_to_h[1] = creature_ptr->to_h[1] = 0;
1250 creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0;
1251 creature_ptr->dis_to_d[1] = creature_ptr->to_d[1] = 0;
1252 creature_ptr->dis_to_h_b = creature_ptr->to_h_b = 0;
1253 creature_ptr->dis_to_a = creature_ptr->to_a = 0;
1254 creature_ptr->to_h_m = 0;
1255 creature_ptr->to_d_m = 0;
1256 creature_ptr->to_m_chance = 0;
1257 creature_ptr->to_dd[0] = creature_ptr->to_ds[0] = 0;
1258 creature_ptr->to_dd[1] = creature_ptr->to_ds[1] = 0;
1261 creature_ptr->num_blow[0] = 1;
1262 creature_ptr->num_blow[1] = 1;
1263 creature_ptr->num_fire = 100;
1264 creature_ptr->tval_xtra = 0;
1265 creature_ptr->tval_ammo = 0;
1266 creature_ptr->cursed = 0L;
1267 creature_ptr->bless_blade = FALSE;
1268 creature_ptr->xtra_might = FALSE;
1269 creature_ptr->impact[0] = FALSE;
1270 creature_ptr->impact[1] = FALSE;
1271 creature_ptr->pass_wall = FALSE;
1272 creature_ptr->kill_wall = FALSE;
1273 creature_ptr->dec_mana = FALSE;
1274 creature_ptr->easy_spell = FALSE;
1275 creature_ptr->heavy_spell = FALSE;
1276 creature_ptr->see_inv = FALSE;
1277 creature_ptr->free_act = FALSE;
1278 creature_ptr->slow_digest = FALSE;
1279 creature_ptr->regenerate = FALSE;
1280 creature_ptr->can_swim = FALSE;
1281 creature_ptr->levitation = FALSE;
1282 creature_ptr->hold_exp = FALSE;
1283 creature_ptr->telepathy = FALSE;
1284 creature_ptr->esp_animal = FALSE;
1285 creature_ptr->esp_undead = FALSE;
1286 creature_ptr->esp_demon = FALSE;
1287 creature_ptr->esp_orc = FALSE;
1288 creature_ptr->esp_troll = FALSE;
1289 creature_ptr->esp_giant = FALSE;
1290 creature_ptr->esp_dragon = FALSE;
1291 creature_ptr->esp_human = FALSE;
1292 creature_ptr->esp_evil = FALSE;
1293 creature_ptr->esp_good = FALSE;
1294 creature_ptr->esp_nonliving = FALSE;
1295 creature_ptr->esp_unique = FALSE;
1296 creature_ptr->lite = FALSE;
1297 creature_ptr->sustain_str = FALSE;
1298 creature_ptr->sustain_int = FALSE;
1299 creature_ptr->sustain_wis = FALSE;
1300 creature_ptr->sustain_con = FALSE;
1301 creature_ptr->sustain_dex = FALSE;
1302 creature_ptr->sustain_chr = FALSE;
1303 creature_ptr->resist_acid = FALSE;
1304 creature_ptr->resist_elec = FALSE;
1305 creature_ptr->resist_fire = FALSE;
1306 creature_ptr->resist_cold = FALSE;
1307 creature_ptr->resist_pois = FALSE;
1308 creature_ptr->resist_conf = FALSE;
1309 creature_ptr->resist_sound = FALSE;
1310 creature_ptr->resist_lite = FALSE;
1311 creature_ptr->resist_dark = FALSE;
1312 creature_ptr->resist_chaos = FALSE;
1313 creature_ptr->resist_disen = FALSE;
1314 creature_ptr->resist_shard = FALSE;
1315 creature_ptr->resist_nexus = FALSE;
1316 creature_ptr->resist_blind = FALSE;
1317 creature_ptr->resist_neth = FALSE;
1318 creature_ptr->resist_time = FALSE;
1319 creature_ptr->resist_water = FALSE;
1320 creature_ptr->resist_fear = FALSE;
1321 creature_ptr->reflect = FALSE;
1322 creature_ptr->sh_fire = FALSE;
1323 creature_ptr->sh_elec = FALSE;
1324 creature_ptr->sh_cold = FALSE;
1325 creature_ptr->anti_magic = FALSE;
1326 creature_ptr->anti_tele = FALSE;
1327 creature_ptr->warning = FALSE;
1328 creature_ptr->mighty_throw = FALSE;
1329 creature_ptr->see_nocto = FALSE;
1330 creature_ptr->immune_acid = FALSE;
1331 creature_ptr->immune_elec = FALSE;
1332 creature_ptr->immune_fire = FALSE;
1333 creature_ptr->immune_cold = FALSE;
1334 creature_ptr->ryoute = FALSE;
1335 creature_ptr->migite = FALSE;
1336 creature_ptr->hidarite = FALSE;
1337 creature_ptr->no_flowed = FALSE;
1339 if (creature_ptr->mimic_form) tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1340 else tmp_rp_ptr = &race_info[creature_ptr->prace];
1342 creature_ptr->see_infra = tmp_rp_ptr->infra;
1343 creature_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
1344 creature_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
1345 creature_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
1346 creature_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
1347 creature_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
1348 creature_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
1349 creature_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
1350 creature_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
1351 creature_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
1352 creature_ptr->skill_dig = 0;
1354 if (has_melee_weapon(creature_ptr, INVEN_RARM)) creature_ptr->migite = TRUE;
1355 if (has_melee_weapon(creature_ptr, INVEN_LARM))
1357 creature_ptr->hidarite = TRUE;
1358 if (!creature_ptr->migite) default_hand = 1;
1361 if (can_two_hands_wielding(creature_ptr))
1363 if (creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) &&
1364 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM]))
1366 creature_ptr->ryoute = TRUE;
1368 else if (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) &&
1369 object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM]))
1371 creature_ptr->ryoute = TRUE;
1375 switch (creature_ptr->pclass)
1378 case CLASS_FORCETRAINER:
1379 case CLASS_BERSERKER:
1380 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
1382 creature_ptr->migite = TRUE;
1383 creature_ptr->ryoute = TRUE;
1390 if (!creature_ptr->migite && !creature_ptr->hidarite)
1392 if (empty_hands_status & EMPTY_HAND_RARM) creature_ptr->migite = TRUE;
1393 else if (empty_hands_status == EMPTY_HAND_LARM)
1395 creature_ptr->hidarite = TRUE;
1400 if (creature_ptr->special_defense & KAMAE_MASK)
1402 if (!(empty_hands_status & EMPTY_HAND_RARM))
1404 set_action(creature_ptr, ACTION_NONE);
1408 switch (creature_ptr->pclass)
1411 if (creature_ptr->lev > 29) creature_ptr->resist_fear = TRUE;
1412 if (creature_ptr->lev > 44) creature_ptr->regenerate = TRUE;
1415 if (creature_ptr->lev > 39) creature_ptr->resist_fear = TRUE;
1417 case CLASS_CHAOS_WARRIOR:
1418 if (creature_ptr->lev > 29) creature_ptr->resist_chaos = TRUE;
1419 if (creature_ptr->lev > 39) creature_ptr->resist_fear = TRUE;
1421 case CLASS_MINDCRAFTER:
1422 if (creature_ptr->lev > 9) creature_ptr->resist_fear = TRUE;
1423 if (creature_ptr->lev > 19) creature_ptr->sustain_wis = TRUE;
1424 if (creature_ptr->lev > 29) creature_ptr->resist_conf = TRUE;
1425 if (creature_ptr->lev > 39) creature_ptr->telepathy = TRUE;
1428 case CLASS_FORCETRAINER:
1429 if (!(heavy_armor(creature_ptr)))
1431 if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
1432 PRACE_IS_(creature_ptr, RACE_SPRITE) ||
1433 (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
1434 new_speed += (creature_ptr->lev) / 10;
1436 if (creature_ptr->lev > 24)
1437 creature_ptr->free_act = TRUE;
1441 case CLASS_SORCERER:
1442 creature_ptr->to_a -= 50;
1443 creature_ptr->dis_to_a -= 50;
1446 creature_ptr->resist_sound = TRUE;
1449 if (creature_ptr->lev > 29) creature_ptr->resist_fear = TRUE;
1451 case CLASS_BERSERKER:
1452 creature_ptr->shero = 1;
1453 creature_ptr->sustain_str = TRUE;
1454 creature_ptr->sustain_dex = TRUE;
1455 creature_ptr->sustain_con = TRUE;
1456 creature_ptr->regenerate = TRUE;
1457 creature_ptr->free_act = TRUE;
1459 if (creature_ptr->lev > 29) new_speed++;
1460 if (creature_ptr->lev > 39) new_speed++;
1461 if (creature_ptr->lev > 44) new_speed++;
1462 if (creature_ptr->lev > 49) new_speed++;
1463 creature_ptr->to_a += 10 + creature_ptr->lev / 2;
1464 creature_ptr->dis_to_a += 10 + creature_ptr->lev / 2;
1465 creature_ptr->skill_dig += (100 + creature_ptr->lev * 8);
1466 if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
1467 creature_ptr->redraw |= PR_STATUS;
1469 case CLASS_MIRROR_MASTER:
1470 if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
1473 if (heavy_armor(creature_ptr))
1475 new_speed -= (creature_ptr->lev) / 10;
1476 creature_ptr->skill_stl -= (creature_ptr->lev) / 10;
1478 else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
1479 (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
1482 if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
1483 PRACE_IS_(creature_ptr, RACE_SPRITE) ||
1484 (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
1485 new_speed += (creature_ptr->lev) / 10;
1486 creature_ptr->skill_stl += (creature_ptr->lev) / 10;
1487 if (creature_ptr->lev > 24)
1488 creature_ptr->free_act = TRUE;
1491 if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
1492 (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
1494 creature_ptr->to_a += creature_ptr->lev / 2 + 5;
1495 creature_ptr->dis_to_a += creature_ptr->lev / 2 + 5;
1498 creature_ptr->slow_digest = TRUE;
1499 creature_ptr->resist_fear = TRUE;
1500 if (creature_ptr->lev > 19) creature_ptr->resist_pois = TRUE;
1501 if (creature_ptr->lev > 24) creature_ptr->sustain_dex = TRUE;
1502 if (creature_ptr->lev > 29) creature_ptr->see_inv = TRUE;
1503 if (creature_ptr->lev > 44)
1505 creature_ptr->oppose_pois = 1;
1506 creature_ptr->redraw |= PR_STATUS;
1509 creature_ptr->see_nocto = TRUE;
1513 if (creature_ptr->mimic_form)
1515 switch (creature_ptr->mimic_form)
1518 creature_ptr->hold_exp = TRUE;
1519 creature_ptr->resist_chaos = TRUE;
1520 creature_ptr->resist_neth = TRUE;
1521 creature_ptr->resist_fire = TRUE;
1522 creature_ptr->oppose_fire = 1;
1523 creature_ptr->see_inv = TRUE;
1525 creature_ptr->redraw |= PR_STATUS;
1526 creature_ptr->to_a += 10;
1527 creature_ptr->dis_to_a += 10;
1529 case MIMIC_DEMON_LORD:
1530 creature_ptr->hold_exp = TRUE;
1531 creature_ptr->resist_chaos = TRUE;
1532 creature_ptr->resist_neth = TRUE;
1533 creature_ptr->immune_fire = TRUE;
1534 creature_ptr->resist_acid = TRUE;
1535 creature_ptr->resist_fire = TRUE;
1536 creature_ptr->resist_cold = TRUE;
1537 creature_ptr->resist_elec = TRUE;
1538 creature_ptr->resist_pois = TRUE;
1539 creature_ptr->resist_conf = TRUE;
1540 creature_ptr->resist_disen = TRUE;
1541 creature_ptr->resist_nexus = TRUE;
1542 creature_ptr->resist_fear = TRUE;
1543 creature_ptr->sh_fire = TRUE;
1544 creature_ptr->see_inv = TRUE;
1545 creature_ptr->telepathy = TRUE;
1546 creature_ptr->levitation = TRUE;
1547 creature_ptr->kill_wall = TRUE;
1549 creature_ptr->to_a += 20;
1550 creature_ptr->dis_to_a += 20;
1553 creature_ptr->resist_dark = TRUE;
1554 creature_ptr->hold_exp = TRUE;
1555 creature_ptr->resist_neth = TRUE;
1556 creature_ptr->resist_cold = TRUE;
1557 creature_ptr->resist_pois = TRUE;
1558 creature_ptr->see_inv = TRUE;
1560 creature_ptr->to_a += 10;
1561 creature_ptr->dis_to_a += 10;
1562 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1568 switch (creature_ptr->prace)
1571 creature_ptr->resist_lite = TRUE;
1574 creature_ptr->hold_exp = TRUE;
1577 creature_ptr->free_act = TRUE;
1580 creature_ptr->resist_blind = TRUE;
1583 creature_ptr->resist_dark = TRUE;
1585 case RACE_HALF_TROLL:
1586 creature_ptr->sustain_str = TRUE;
1588 if (creature_ptr->lev > 14)
1590 creature_ptr->regenerate = TRUE;
1591 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER)
1593 creature_ptr->slow_digest = TRUE;
1594 /* Let's not make Regeneration
1595 * a disadvantage for the poor warriors who can
1596 * never learn a spell that satisfies hunger (actually
1597 * neither can rogues, but half-trolls are not
1598 * supposed to play rogues) */
1603 creature_ptr->sustain_con = TRUE;
1604 creature_ptr->regenerate = TRUE;
1607 creature_ptr->resist_lite = TRUE;
1608 creature_ptr->see_inv = TRUE;
1610 case RACE_BARBARIAN:
1611 creature_ptr->resist_fear = TRUE;
1613 case RACE_HALF_OGRE:
1614 creature_ptr->resist_dark = TRUE;
1615 creature_ptr->sustain_str = TRUE;
1617 case RACE_HALF_GIANT:
1618 creature_ptr->sustain_str = TRUE;
1619 creature_ptr->resist_shard = TRUE;
1621 case RACE_HALF_TITAN:
1622 creature_ptr->resist_chaos = TRUE;
1625 creature_ptr->resist_sound = TRUE;
1628 creature_ptr->resist_acid = TRUE;
1629 if (creature_ptr->lev > 19) creature_ptr->immune_acid = TRUE;
1632 creature_ptr->resist_conf = TRUE;
1633 creature_ptr->resist_acid = TRUE;
1634 new_speed += (creature_ptr->lev) / 10;
1637 creature_ptr->resist_pois = TRUE;
1640 creature_ptr->resist_disen = TRUE;
1641 creature_ptr->resist_dark = TRUE;
1644 creature_ptr->resist_dark = TRUE;
1645 if (creature_ptr->lev > 19) creature_ptr->see_inv = TRUE;
1647 case RACE_DRACONIAN:
1648 creature_ptr->levitation = TRUE;
1649 if (creature_ptr->lev > 4) creature_ptr->resist_fire = TRUE;
1650 if (creature_ptr->lev > 9) creature_ptr->resist_cold = TRUE;
1651 if (creature_ptr->lev > 14) creature_ptr->resist_acid = TRUE;
1652 if (creature_ptr->lev > 19) creature_ptr->resist_elec = TRUE;
1653 if (creature_ptr->lev > 34) creature_ptr->resist_pois = TRUE;
1655 case RACE_MIND_FLAYER:
1656 creature_ptr->sustain_int = TRUE;
1657 creature_ptr->sustain_wis = TRUE;
1658 if (creature_ptr->lev > 14) creature_ptr->see_inv = TRUE;
1659 if (creature_ptr->lev > 29) creature_ptr->telepathy = TRUE;
1662 creature_ptr->resist_fire = TRUE;
1663 if (creature_ptr->lev > 9) creature_ptr->see_inv = TRUE;
1666 creature_ptr->slow_digest = TRUE;
1667 creature_ptr->free_act = TRUE;
1668 creature_ptr->see_inv = TRUE;
1669 creature_ptr->resist_pois = TRUE;
1670 if (creature_ptr->lev > 34) creature_ptr->hold_exp = TRUE;
1673 creature_ptr->resist_shard = TRUE;
1674 creature_ptr->hold_exp = TRUE;
1675 creature_ptr->see_inv = TRUE;
1676 creature_ptr->resist_pois = TRUE;
1677 if (creature_ptr->lev > 9) creature_ptr->resist_cold = TRUE;
1680 creature_ptr->resist_neth = TRUE;
1681 creature_ptr->hold_exp = TRUE;
1682 creature_ptr->see_inv = TRUE;
1683 creature_ptr->resist_pois = TRUE;
1684 creature_ptr->slow_digest = TRUE;
1685 if (creature_ptr->lev > 4) creature_ptr->resist_cold = TRUE;
1688 creature_ptr->resist_dark = TRUE;
1689 creature_ptr->hold_exp = TRUE;
1690 creature_ptr->resist_neth = TRUE;
1691 creature_ptr->resist_cold = TRUE;
1692 creature_ptr->resist_pois = TRUE;
1693 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1696 creature_ptr->levitation = TRUE;
1697 creature_ptr->free_act = TRUE;
1698 creature_ptr->resist_neth = TRUE;
1699 creature_ptr->hold_exp = TRUE;
1700 creature_ptr->see_inv = TRUE;
1701 creature_ptr->resist_pois = TRUE;
1702 creature_ptr->slow_digest = TRUE;
1703 creature_ptr->resist_cold = TRUE;
1704 creature_ptr->pass_wall = TRUE;
1705 if (creature_ptr->lev > 34) creature_ptr->telepathy = TRUE;
1708 creature_ptr->levitation = TRUE;
1709 creature_ptr->resist_lite = TRUE;
1711 new_speed += (creature_ptr->lev) / 10;
1714 creature_ptr->resist_conf = TRUE;
1715 creature_ptr->resist_sound = TRUE;
1718 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
1719 creature_ptr->skill_dig += creature_ptr->lev * 10;
1721 if (creature_ptr->lev > 25) creature_ptr->stat_add[A_STR]++;
1722 if (creature_ptr->lev > 40) creature_ptr->stat_add[A_STR]++;
1723 if (creature_ptr->lev > 45) creature_ptr->stat_add[A_STR]++;
1725 if (creature_ptr->lev > 25) creature_ptr->stat_add[A_DEX]--;
1726 if (creature_ptr->lev > 40) creature_ptr->stat_add[A_DEX]--;
1727 if (creature_ptr->lev > 45) creature_ptr->stat_add[A_DEX]--;
1729 if (creature_ptr->lev > 25) creature_ptr->stat_add[A_CON]++;
1730 if (creature_ptr->lev > 40) creature_ptr->stat_add[A_CON]++;
1731 if (creature_ptr->lev > 45) creature_ptr->stat_add[A_CON]++;
1734 creature_ptr->levitation = TRUE;
1735 creature_ptr->see_inv = TRUE;
1738 creature_ptr->resist_fire = TRUE;
1739 creature_ptr->resist_neth = TRUE;
1740 creature_ptr->hold_exp = TRUE;
1741 if (creature_ptr->lev > 9) creature_ptr->see_inv = TRUE;
1742 if (creature_ptr->lev > 44)
1744 creature_ptr->oppose_fire = 1;
1745 creature_ptr->redraw |= PR_STATUS;
1750 creature_ptr->sustain_con = TRUE;
1753 creature_ptr->levitation = TRUE;
1756 creature_ptr->resist_conf = TRUE;
1759 creature_ptr->slow_digest = TRUE;
1760 creature_ptr->free_act = TRUE;
1761 creature_ptr->resist_pois = TRUE;
1762 creature_ptr->hold_exp = TRUE;
1765 creature_ptr->resist_water = TRUE;
1772 if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU))
1774 creature_ptr->see_inv = TRUE;
1775 creature_ptr->free_act = TRUE;
1776 creature_ptr->slow_digest = TRUE;
1777 creature_ptr->regenerate = TRUE;
1778 creature_ptr->levitation = TRUE;
1779 creature_ptr->hold_exp = TRUE;
1780 creature_ptr->telepathy = TRUE;
1781 creature_ptr->lite = TRUE;
1782 creature_ptr->sustain_str = TRUE;
1783 creature_ptr->sustain_int = TRUE;
1784 creature_ptr->sustain_wis = TRUE;
1785 creature_ptr->sustain_con = TRUE;
1786 creature_ptr->sustain_dex = TRUE;
1787 creature_ptr->sustain_chr = TRUE;
1788 creature_ptr->resist_acid = TRUE;
1789 creature_ptr->resist_elec = TRUE;
1790 creature_ptr->resist_fire = TRUE;
1791 creature_ptr->resist_cold = TRUE;
1792 creature_ptr->resist_pois = TRUE;
1793 creature_ptr->resist_conf = TRUE;
1794 creature_ptr->resist_sound = TRUE;
1795 creature_ptr->resist_lite = TRUE;
1796 creature_ptr->resist_dark = TRUE;
1797 creature_ptr->resist_chaos = TRUE;
1798 creature_ptr->resist_disen = TRUE;
1799 creature_ptr->resist_shard = TRUE;
1800 creature_ptr->resist_nexus = TRUE;
1801 creature_ptr->resist_blind = TRUE;
1802 creature_ptr->resist_neth = TRUE;
1803 creature_ptr->resist_fear = TRUE;
1804 creature_ptr->reflect = TRUE;
1805 creature_ptr->sh_fire = TRUE;
1806 creature_ptr->sh_elec = TRUE;
1807 creature_ptr->sh_cold = TRUE;
1808 creature_ptr->to_a += 100;
1809 creature_ptr->dis_to_a += 100;
1811 else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef)
1813 creature_ptr->to_a += 50;
1814 creature_ptr->dis_to_a += 50;
1817 if (creature_ptr->tim_res_nether)
1819 creature_ptr->resist_neth = TRUE;
1822 if (creature_ptr->tim_sh_fire)
1824 creature_ptr->sh_fire = TRUE;
1827 if (creature_ptr->tim_res_time)
1829 creature_ptr->resist_time = TRUE;
1832 if (creature_ptr->pseikaku == SEIKAKU_SEXY) creature_ptr->cursed |= (TRC_AGGRAVATE);
1833 if (creature_ptr->pseikaku == SEIKAKU_NAMAKE) creature_ptr->to_m_chance += 10;
1834 if (creature_ptr->pseikaku == SEIKAKU_KIREMONO) creature_ptr->to_m_chance -= 3;
1835 if ((creature_ptr->pseikaku == SEIKAKU_GAMAN) || (creature_ptr->pseikaku == SEIKAKU_CHIKARA)) creature_ptr->to_m_chance++;
1836 if (creature_ptr->pseikaku == SEIKAKU_CHARGEMAN)
1838 creature_ptr->to_m_chance += 5;
1839 creature_ptr->resist_conf = TRUE;
1842 if (creature_ptr->pseikaku == SEIKAKU_LUCKY) creature_ptr->muta3 |= MUT3_GOOD_LUCK;
1843 if (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)
1845 creature_ptr->resist_blind = TRUE;
1846 creature_ptr->resist_conf = TRUE;
1847 creature_ptr->hold_exp = TRUE;
1848 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1850 if ((creature_ptr->prace != RACE_KLACKON) && (creature_ptr->prace != RACE_SPRITE))
1851 new_speed += (creature_ptr->lev) / 10 + 5;
1854 if (music_singing(creature_ptr, MUSIC_WALL))
1856 creature_ptr->kill_wall = TRUE;
1859 for (int i = 0; i < A_MAX; i++)
1861 creature_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
1864 if (creature_ptr->muta3)
1866 if (creature_ptr->muta3 & MUT3_HYPER_STR)
1868 creature_ptr->stat_add[A_STR] += 4;
1871 if (creature_ptr->muta3 & MUT3_PUNY)
1873 creature_ptr->stat_add[A_STR] -= 4;
1876 if (creature_ptr->muta3 & MUT3_HYPER_INT)
1878 creature_ptr->stat_add[A_INT] += 4;
1879 creature_ptr->stat_add[A_WIS] += 4;
1882 if (creature_ptr->muta3 & MUT3_MORONIC)
1884 creature_ptr->stat_add[A_INT] -= 4;
1885 creature_ptr->stat_add[A_WIS] -= 4;
1888 if (creature_ptr->muta3 & MUT3_RESILIENT)
1890 creature_ptr->stat_add[A_CON] += 4;
1893 if (creature_ptr->muta3 & MUT3_XTRA_FAT)
1895 creature_ptr->stat_add[A_CON] += 2;
1899 if (creature_ptr->muta3 & MUT3_ALBINO)
1901 creature_ptr->stat_add[A_CON] -= 4;
1904 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
1906 creature_ptr->stat_add[A_CON] -= 2;
1907 creature_ptr->stat_add[A_CHR] -= 1;
1908 creature_ptr->regenerate = FALSE;
1911 if (creature_ptr->muta3 & MUT3_SILLY_VOI)
1913 creature_ptr->stat_add[A_CHR] -= 4;
1916 if (creature_ptr->muta3 & MUT3_BLANK_FAC)
1918 creature_ptr->stat_add[A_CHR] -= 1;
1921 if (creature_ptr->muta3 & MUT3_XTRA_EYES)
1923 creature_ptr->skill_fos += 15;
1924 creature_ptr->skill_srh += 15;
1927 if (creature_ptr->muta3 & MUT3_MAGIC_RES)
1929 creature_ptr->skill_sav += (15 + (creature_ptr->lev / 5));
1932 if (creature_ptr->muta3 & MUT3_XTRA_NOIS)
1934 creature_ptr->skill_stl -= 3;
1937 if (creature_ptr->muta3 & MUT3_INFRAVIS)
1939 creature_ptr->see_infra += 3;
1942 if (creature_ptr->muta3 & MUT3_XTRA_LEGS)
1947 if (creature_ptr->muta3 & MUT3_SHORT_LEG)
1952 if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
1954 creature_ptr->sh_elec = TRUE;
1957 if (creature_ptr->muta3 & MUT3_FIRE_BODY)
1959 creature_ptr->sh_fire = TRUE;
1960 creature_ptr->lite = TRUE;
1963 if (creature_ptr->muta3 & MUT3_WART_SKIN)
1965 creature_ptr->stat_add[A_CHR] -= 2;
1966 creature_ptr->to_a += 5;
1967 creature_ptr->dis_to_a += 5;
1970 if (creature_ptr->muta3 & MUT3_SCALES)
1972 creature_ptr->stat_add[A_CHR] -= 1;
1973 creature_ptr->to_a += 10;
1974 creature_ptr->dis_to_a += 10;
1977 if (creature_ptr->muta3 & MUT3_IRON_SKIN)
1979 creature_ptr->stat_add[A_DEX] -= 1;
1980 creature_ptr->to_a += 25;
1981 creature_ptr->dis_to_a += 25;
1984 if (creature_ptr->muta3 & MUT3_WINGS)
1986 creature_ptr->levitation = TRUE;
1989 if (creature_ptr->muta3 & MUT3_FEARLESS)
1991 creature_ptr->resist_fear = TRUE;
1994 if (creature_ptr->muta3 & MUT3_REGEN)
1996 creature_ptr->regenerate = TRUE;
1999 if (creature_ptr->muta3 & MUT3_ESP)
2001 creature_ptr->telepathy = TRUE;
2004 if (creature_ptr->muta3 & MUT3_LIMBER)
2006 creature_ptr->stat_add[A_DEX] += 3;
2009 if (creature_ptr->muta3 & MUT3_ARTHRITIS)
2011 creature_ptr->stat_add[A_DEX] -= 3;
2014 if (creature_ptr->muta3 & MUT3_MOTION)
2016 creature_ptr->free_act = TRUE;
2017 creature_ptr->skill_stl += 1;
2020 if (creature_ptr->muta3 & MUT3_ILL_NORM)
2022 creature_ptr->stat_add[A_CHR] = 0;
2026 if (creature_ptr->tsuyoshi)
2028 creature_ptr->stat_add[A_STR] += 4;
2029 creature_ptr->stat_add[A_CON] += 4;
2032 for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
2034 int bonus_to_h, bonus_to_d;
2035 o_ptr = &creature_ptr->inventory_list[i];
2036 if (!o_ptr->k_idx) continue;
2038 object_flags(o_ptr, flgs);
2040 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
2041 if (o_ptr->name1 == ART_CHAINSWORD) creature_ptr->cursed |= TRC_CHAINSWORD;
2043 if (have_flag(flgs, TR_STR)) creature_ptr->stat_add[A_STR] += o_ptr->pval;
2044 if (have_flag(flgs, TR_INT)) creature_ptr->stat_add[A_INT] += o_ptr->pval;
2045 if (have_flag(flgs, TR_WIS)) creature_ptr->stat_add[A_WIS] += o_ptr->pval;
2046 if (have_flag(flgs, TR_DEX)) creature_ptr->stat_add[A_DEX] += o_ptr->pval;
2047 if (have_flag(flgs, TR_CON)) creature_ptr->stat_add[A_CON] += o_ptr->pval;
2048 if (have_flag(flgs, TR_CHR)) creature_ptr->stat_add[A_CHR] += o_ptr->pval;
2049 if (have_flag(flgs, TR_MAGIC_MASTERY)) creature_ptr->skill_dev += 8 * o_ptr->pval;
2050 if (have_flag(flgs, TR_STEALTH)) creature_ptr->skill_stl += o_ptr->pval;
2051 if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_srh += (o_ptr->pval * 5);
2052 if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_fos += (o_ptr->pval * 5);
2053 if (have_flag(flgs, TR_INFRA)) creature_ptr->see_infra += o_ptr->pval;
2054 if (have_flag(flgs, TR_TUNNEL)) creature_ptr->skill_dig += (o_ptr->pval * 20);
2055 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
2056 if (have_flag(flgs, TR_BLOWS))
2058 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !creature_ptr->ryoute) extra_blows[0] += o_ptr->pval;
2059 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !creature_ptr->ryoute) extra_blows[1] += o_ptr->pval;
2060 else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
2063 if (have_flag(flgs, TR_IMPACT)) creature_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
2064 if (have_flag(flgs, TR_AGGRAVATE)) creature_ptr->cursed |= TRC_AGGRAVATE;
2065 if (have_flag(flgs, TR_DRAIN_EXP)) creature_ptr->cursed |= TRC_DRAIN_EXP;
2066 if (have_flag(flgs, TR_TY_CURSE)) creature_ptr->cursed |= TRC_TY_CURSE;
2067 if (have_flag(flgs, TR_ADD_L_CURSE)) creature_ptr->cursed |= TRC_ADD_L_CURSE;
2068 if (have_flag(flgs, TR_ADD_H_CURSE)) creature_ptr->cursed |= TRC_ADD_H_CURSE;
2069 if (have_flag(flgs, TR_DRAIN_HP)) creature_ptr->cursed |= TRC_DRAIN_HP;
2070 if (have_flag(flgs, TR_DRAIN_MANA)) creature_ptr->cursed |= TRC_DRAIN_MANA;
2071 if (have_flag(flgs, TR_CALL_ANIMAL)) creature_ptr->cursed |= TRC_CALL_ANIMAL;
2072 if (have_flag(flgs, TR_CALL_DEMON)) creature_ptr->cursed |= TRC_CALL_DEMON;
2073 if (have_flag(flgs, TR_CALL_DRAGON)) creature_ptr->cursed |= TRC_CALL_DRAGON;
2074 if (have_flag(flgs, TR_CALL_UNDEAD)) creature_ptr->cursed |= TRC_CALL_UNDEAD;
2075 if (have_flag(flgs, TR_COWARDICE)) creature_ptr->cursed |= TRC_COWARDICE;
2076 if (have_flag(flgs, TR_LOW_MELEE)) creature_ptr->cursed |= TRC_LOW_MELEE;
2077 if (have_flag(flgs, TR_LOW_AC)) creature_ptr->cursed |= TRC_LOW_AC;
2078 if (have_flag(flgs, TR_LOW_MAGIC)) creature_ptr->cursed |= TRC_LOW_MAGIC;
2079 if (have_flag(flgs, TR_FAST_DIGEST)) creature_ptr->cursed |= TRC_FAST_DIGEST;
2080 if (have_flag(flgs, TR_SLOW_REGEN)) creature_ptr->cursed |= TRC_SLOW_REGEN;
2081 if (have_flag(flgs, TR_DEC_MANA)) creature_ptr->dec_mana = TRUE;
2082 if (have_flag(flgs, TR_BLESSED)) creature_ptr->bless_blade = TRUE;
2083 if (have_flag(flgs, TR_XTRA_MIGHT)) creature_ptr->xtra_might = TRUE;
2084 if (have_flag(flgs, TR_SLOW_DIGEST)) creature_ptr->slow_digest = TRUE;
2085 if (have_flag(flgs, TR_REGEN)) creature_ptr->regenerate = TRUE;
2086 if (have_flag(flgs, TR_TELEPATHY)) creature_ptr->telepathy = TRUE;
2087 if (have_flag(flgs, TR_ESP_ANIMAL)) creature_ptr->esp_animal = TRUE;
2088 if (have_flag(flgs, TR_ESP_UNDEAD)) creature_ptr->esp_undead = TRUE;
2089 if (have_flag(flgs, TR_ESP_DEMON)) creature_ptr->esp_demon = TRUE;
2090 if (have_flag(flgs, TR_ESP_ORC)) creature_ptr->esp_orc = TRUE;
2091 if (have_flag(flgs, TR_ESP_TROLL)) creature_ptr->esp_troll = TRUE;
2092 if (have_flag(flgs, TR_ESP_GIANT)) creature_ptr->esp_giant = TRUE;
2093 if (have_flag(flgs, TR_ESP_DRAGON)) creature_ptr->esp_dragon = TRUE;
2094 if (have_flag(flgs, TR_ESP_HUMAN)) creature_ptr->esp_human = TRUE;
2095 if (have_flag(flgs, TR_ESP_EVIL)) creature_ptr->esp_evil = TRUE;
2096 if (have_flag(flgs, TR_ESP_GOOD)) creature_ptr->esp_good = TRUE;
2097 if (have_flag(flgs, TR_ESP_NONLIVING)) creature_ptr->esp_nonliving = TRUE;
2098 if (have_flag(flgs, TR_ESP_UNIQUE)) creature_ptr->esp_unique = TRUE;
2100 if (have_flag(flgs, TR_SEE_INVIS)) creature_ptr->see_inv = TRUE;
2101 if (have_flag(flgs, TR_LEVITATION)) creature_ptr->levitation = TRUE;
2102 if (have_flag(flgs, TR_FREE_ACT)) creature_ptr->free_act = TRUE;
2103 if (have_flag(flgs, TR_HOLD_EXP)) creature_ptr->hold_exp = TRUE;
2104 if (have_flag(flgs, TR_WARNING)) {
2105 if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription), '$')))
2106 creature_ptr->warning = TRUE;
2109 if (have_flag(flgs, TR_TELEPORT))
2111 if (object_is_cursed(o_ptr)) creature_ptr->cursed |= TRC_TELEPORT;
2114 concptr insc = quark_str(o_ptr->inscription);
2116 /* {.} will stop random teleportation. */
2117 if (o_ptr->inscription && my_strchr(insc, '.'))
2122 creature_ptr->cursed |= TRC_TELEPORT_SELF;
2127 if (have_flag(flgs, TR_IM_FIRE)) creature_ptr->immune_fire = TRUE;
2128 if (have_flag(flgs, TR_IM_ACID)) creature_ptr->immune_acid = TRUE;
2129 if (have_flag(flgs, TR_IM_COLD)) creature_ptr->immune_cold = TRUE;
2130 if (have_flag(flgs, TR_IM_ELEC)) creature_ptr->immune_elec = TRUE;
2132 if (have_flag(flgs, TR_RES_ACID)) creature_ptr->resist_acid = TRUE;
2133 if (have_flag(flgs, TR_RES_ELEC)) creature_ptr->resist_elec = TRUE;
2134 if (have_flag(flgs, TR_RES_FIRE)) creature_ptr->resist_fire = TRUE;
2135 if (have_flag(flgs, TR_RES_COLD)) creature_ptr->resist_cold = TRUE;
2136 if (have_flag(flgs, TR_RES_POIS)) creature_ptr->resist_pois = TRUE;
2137 if (have_flag(flgs, TR_RES_FEAR)) creature_ptr->resist_fear = TRUE;
2138 if (have_flag(flgs, TR_RES_CONF)) creature_ptr->resist_conf = TRUE;
2139 if (have_flag(flgs, TR_RES_SOUND)) creature_ptr->resist_sound = TRUE;
2140 if (have_flag(flgs, TR_RES_LITE)) creature_ptr->resist_lite = TRUE;
2141 if (have_flag(flgs, TR_RES_DARK)) creature_ptr->resist_dark = TRUE;
2142 if (have_flag(flgs, TR_RES_CHAOS)) creature_ptr->resist_chaos = TRUE;
2143 if (have_flag(flgs, TR_RES_DISEN)) creature_ptr->resist_disen = TRUE;
2144 if (have_flag(flgs, TR_RES_SHARDS)) creature_ptr->resist_shard = TRUE;
2145 if (have_flag(flgs, TR_RES_NEXUS)) creature_ptr->resist_nexus = TRUE;
2146 if (have_flag(flgs, TR_RES_BLIND)) creature_ptr->resist_blind = TRUE;
2147 if (have_flag(flgs, TR_RES_NETHER)) creature_ptr->resist_neth = TRUE;
2149 if (have_flag(flgs, TR_REFLECT)) creature_ptr->reflect = TRUE;
2150 if (have_flag(flgs, TR_SH_FIRE)) creature_ptr->sh_fire = TRUE;
2151 if (have_flag(flgs, TR_SH_ELEC)) creature_ptr->sh_elec = TRUE;
2152 if (have_flag(flgs, TR_SH_COLD)) creature_ptr->sh_cold = TRUE;
2153 if (have_flag(flgs, TR_NO_MAGIC)) creature_ptr->anti_magic = TRUE;
2154 if (have_flag(flgs, TR_NO_TELE)) creature_ptr->anti_tele = TRUE;
2156 if (have_flag(flgs, TR_SUST_STR)) creature_ptr->sustain_str = TRUE;
2157 if (have_flag(flgs, TR_SUST_INT)) creature_ptr->sustain_int = TRUE;
2158 if (have_flag(flgs, TR_SUST_WIS)) creature_ptr->sustain_wis = TRUE;
2159 if (have_flag(flgs, TR_SUST_DEX)) creature_ptr->sustain_dex = TRUE;
2160 if (have_flag(flgs, TR_SUST_CON)) creature_ptr->sustain_con = TRUE;
2161 if (have_flag(flgs, TR_SUST_CHR)) creature_ptr->sustain_chr = TRUE;
2163 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
2164 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
2165 if (o_ptr->name2 == EGO_RING_RES_TIME) creature_ptr->resist_time = TRUE;
2166 if (o_ptr->name2 == EGO_RING_THROW) creature_ptr->mighty_throw = TRUE;
2167 if (have_flag(flgs, TR_EASY_SPELL)) creature_ptr->easy_spell = TRUE;
2168 if (o_ptr->name2 == EGO_AMU_FOOL) creature_ptr->heavy_spell = TRUE;
2169 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
2171 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
2173 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2175 creature_ptr->to_m_chance += 10;
2179 creature_ptr->to_m_chance += 3;
2183 if (o_ptr->tval == TV_CAPTURE) continue;
2185 creature_ptr->ac += o_ptr->ac;
2186 creature_ptr->dis_ac += o_ptr->ac;
2187 creature_ptr->to_a += o_ptr->to_a;
2188 if (object_is_known(o_ptr)) creature_ptr->dis_to_a += o_ptr->to_a;
2190 if (o_ptr->curse_flags & TRC_LOW_MELEE)
2192 int slot = i - INVEN_RARM;
2195 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2197 creature_ptr->to_h[slot] -= 15;
2198 if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h[slot] -= 15;
2202 creature_ptr->to_h[slot] -= 5;
2203 if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h[slot] -= 5;
2208 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2210 creature_ptr->to_h_b -= 15;
2211 if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h_b -= 15;
2215 creature_ptr->to_h_b -= 5;
2216 if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h_b -= 5;
2221 if (o_ptr->curse_flags & TRC_LOW_AC)
2223 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2225 creature_ptr->to_a -= 30;
2226 if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_a -= 30;
2230 creature_ptr->to_a -= 10;
2231 if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_a -= 10;
2235 if (i == INVEN_RARM && has_melee_weapon(creature_ptr, i)) continue;
2236 if (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) continue;
2237 if (i == INVEN_BOW) continue;
2239 bonus_to_h = o_ptr->to_h;
2240 bonus_to_d = o_ptr->to_d;
2242 if (creature_ptr->pclass == CLASS_NINJA)
2244 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h + 1) / 2;
2245 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
2248 creature_ptr->to_h_b += (s16b)bonus_to_h;
2249 creature_ptr->to_h_m += (s16b)bonus_to_h;
2250 creature_ptr->to_d_m += (s16b)bonus_to_d;
2252 if (object_is_known(o_ptr)) creature_ptr->dis_to_h_b += (s16b)bonus_to_h;
2254 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !creature_ptr->ryoute)
2256 creature_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
2257 creature_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
2258 if (object_is_known(o_ptr))
2260 creature_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
2261 creature_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
2267 if (creature_ptr->migite && creature_ptr->hidarite)
2269 creature_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2270 creature_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2271 creature_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2272 creature_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2273 if (!object_is_known(o_ptr)) continue;
2275 creature_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2276 creature_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2277 creature_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2278 creature_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2282 creature_ptr->to_h[default_hand] += (s16b)bonus_to_h;
2283 creature_ptr->to_d[default_hand] += (s16b)bonus_to_d;
2285 if (!object_is_known(o_ptr)) continue;
2287 creature_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
2288 creature_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
2291 if (object_is_armour(&creature_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&creature_ptr->inventory_list[INVEN_LARM]))
2293 creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2294 creature_ptr->dis_ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2297 if (old_mighty_throw != creature_ptr->mighty_throw)
2299 creature_ptr->window |= PW_INVEN;
2302 if (creature_ptr->cursed & TRC_TELEPORT) creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
2304 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr))
2306 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx))
2308 creature_ptr->to_a += (creature_ptr->lev * 3) / 2;
2309 creature_ptr->dis_to_a += (creature_ptr->lev * 3) / 2;
2311 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15))
2313 creature_ptr->to_a += ((creature_ptr->lev - 13) / 3);
2314 creature_ptr->dis_to_a += ((creature_ptr->lev - 13) / 3);
2316 if (!(creature_ptr->inventory_list[INVEN_LARM].k_idx) && (creature_ptr->lev > 10))
2318 creature_ptr->to_a += ((creature_ptr->lev - 8) / 3);
2319 creature_ptr->dis_to_a += ((creature_ptr->lev - 8) / 3);
2321 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4))
2323 creature_ptr->to_a += (creature_ptr->lev - 2) / 3;
2324 creature_ptr->dis_to_a += (creature_ptr->lev - 2) / 3;
2326 if (!(creature_ptr->inventory_list[INVEN_HANDS].k_idx))
2328 creature_ptr->to_a += (creature_ptr->lev / 2);
2329 creature_ptr->dis_to_a += (creature_ptr->lev / 2);
2331 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx))
2333 creature_ptr->to_a += (creature_ptr->lev / 3);
2334 creature_ptr->dis_to_a += (creature_ptr->lev / 3);
2336 if (creature_ptr->special_defense & KAMAE_BYAKKO)
2338 creature_ptr->stat_add[A_STR] += 2;
2339 creature_ptr->stat_add[A_DEX] += 2;
2340 creature_ptr->stat_add[A_CON] -= 3;
2342 else if (creature_ptr->special_defense & KAMAE_SEIRYU)
2345 else if (creature_ptr->special_defense & KAMAE_GENBU)
2347 creature_ptr->stat_add[A_INT] -= 1;
2348 creature_ptr->stat_add[A_WIS] -= 1;
2349 creature_ptr->stat_add[A_DEX] -= 2;
2350 creature_ptr->stat_add[A_CON] += 3;
2352 else if (creature_ptr->special_defense & KAMAE_SUZAKU)
2354 creature_ptr->stat_add[A_STR] -= 2;
2355 creature_ptr->stat_add[A_INT] += 1;
2356 creature_ptr->stat_add[A_WIS] += 1;
2357 creature_ptr->stat_add[A_DEX] += 2;
2358 creature_ptr->stat_add[A_CON] -= 2;
2362 if (creature_ptr->special_defense & KATA_KOUKIJIN)
2364 for (int i = 0; i < A_MAX; i++)
2365 creature_ptr->stat_add[i] += 5;
2366 creature_ptr->to_a -= 50;
2367 creature_ptr->dis_to_a -= 50;
2370 if (creature_ptr->sh_fire) creature_ptr->lite = TRUE;
2372 if (PRACE_IS_(creature_ptr, RACE_GOLEM) || PRACE_IS_(creature_ptr, RACE_ANDROID))
2374 creature_ptr->to_a += 10 + (creature_ptr->lev * 2 / 5);
2375 creature_ptr->dis_to_a += 10 + (creature_ptr->lev * 2 / 5);
2378 if (creature_ptr->realm1 == REALM_HEX)
2380 if (hex_spelling_any(creature_ptr)) creature_ptr->skill_stl -= (1 + CASTING_HEX_NUM(creature_ptr));
2381 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
2382 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
2383 if (hex_spelling(creature_ptr, HEX_BUILDING))
2385 creature_ptr->stat_add[A_STR] += 4;
2386 creature_ptr->stat_add[A_DEX] += 4;
2387 creature_ptr->stat_add[A_CON] += 4;
2390 if (hex_spelling(creature_ptr, HEX_DEMON_AURA))
2392 creature_ptr->sh_fire = TRUE;
2393 creature_ptr->regenerate = TRUE;
2396 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR))
2398 creature_ptr->sh_cold = TRUE;
2399 creature_ptr->to_a += 30;
2400 creature_ptr->dis_to_a += 30;
2403 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK))
2405 creature_ptr->sh_elec = TRUE;
2409 for (int i = INVEN_RARM; i <= INVEN_FEET; i++)
2411 ARMOUR_CLASS ac = 0;
2412 o_ptr = &creature_ptr->inventory_list[i];
2413 if (!o_ptr->k_idx) continue;
2414 if (!object_is_armour(o_ptr)) continue;
2415 if (!object_is_cursed(o_ptr)) continue;
2417 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
2418 if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
2419 creature_ptr->to_a += (s16b)ac;
2420 creature_ptr->dis_to_a += (s16b)ac;
2425 for (int i = 0; i < A_MAX; i++)
2428 int top = modify_stat_value(creature_ptr->stat_max[i], creature_ptr->stat_add[i]);
2430 if (creature_ptr->stat_top[i] != top)
2432 creature_ptr->stat_top[i] = (s16b)top;
2433 creature_ptr->redraw |= (PR_STATS);
2434 creature_ptr->window |= (PW_PLAYER);
2437 int use = modify_stat_value(creature_ptr->stat_cur[i], creature_ptr->stat_add[i]);
2439 if ((i == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM))
2441 /* 10 to 18/90 charisma, guaranteed, based on level */
2442 if (use < 8 + 2 * creature_ptr->lev)
2444 use = 8 + 2 * creature_ptr->lev;
2448 if (creature_ptr->stat_use[i] != use)
2450 creature_ptr->stat_use[i] = (s16b)use;
2451 creature_ptr->redraw |= (PR_STATS);
2452 creature_ptr->window |= (PW_PLAYER);
2455 if (use <= 18) ind = (use - 3);
2456 else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
2459 if (creature_ptr->stat_ind[i] == ind) continue;
2460 creature_ptr->stat_ind[i] = (s16b)ind;
2463 creature_ptr->update |= (PU_HP);
2465 else if (i == A_INT)
2467 if (mp_ptr->spell_stat == A_INT)
2469 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2472 else if (i == A_WIS)
2474 if (mp_ptr->spell_stat == A_WIS)
2476 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2479 else if (i == A_CHR)
2481 if (mp_ptr->spell_stat == A_CHR)
2483 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2487 creature_ptr->window |= (PW_PLAYER);
2491 if (creature_ptr->stun > 50)
2493 creature_ptr->to_h[0] -= 20;
2494 creature_ptr->to_h[1] -= 20;
2495 creature_ptr->to_h_b -= 20;
2496 creature_ptr->to_h_m -= 20;
2497 creature_ptr->dis_to_h[0] -= 20;
2498 creature_ptr->dis_to_h[1] -= 20;
2499 creature_ptr->dis_to_h_b -= 20;
2500 creature_ptr->to_d[0] -= 20;
2501 creature_ptr->to_d[1] -= 20;
2502 creature_ptr->to_d_m -= 20;
2503 creature_ptr->dis_to_d[0] -= 20;
2504 creature_ptr->dis_to_d[1] -= 20;
2506 else if (creature_ptr->stun)
2508 creature_ptr->to_h[0] -= 5;
2509 creature_ptr->to_h[1] -= 5;
2510 creature_ptr->to_h_b -= 5;
2511 creature_ptr->to_h_m -= 5;
2512 creature_ptr->dis_to_h[0] -= 5;
2513 creature_ptr->dis_to_h[1] -= 5;
2514 creature_ptr->dis_to_h_b -= 5;
2515 creature_ptr->to_d[0] -= 5;
2516 creature_ptr->to_d[1] -= 5;
2517 creature_ptr->to_d_m -= 5;
2518 creature_ptr->dis_to_d[0] -= 5;
2519 creature_ptr->dis_to_d[1] -= 5;
2522 if (creature_ptr->wraith_form)
2524 creature_ptr->reflect = TRUE;
2525 creature_ptr->pass_wall = TRUE;
2528 if (creature_ptr->kabenuke)
2530 creature_ptr->pass_wall = TRUE;
2533 if (is_blessed(creature_ptr))
2535 creature_ptr->to_a += 5;
2536 creature_ptr->dis_to_a += 5;
2537 creature_ptr->to_h[0] += 10;
2538 creature_ptr->to_h[1] += 10;
2539 creature_ptr->to_h_b += 10;
2540 creature_ptr->to_h_m += 10;
2541 creature_ptr->dis_to_h[0] += 10;
2542 creature_ptr->dis_to_h[1] += 10;
2543 creature_ptr->dis_to_h_b += 10;
2546 if (creature_ptr->magicdef)
2548 creature_ptr->resist_blind = TRUE;
2549 creature_ptr->resist_conf = TRUE;
2550 creature_ptr->reflect = TRUE;
2551 creature_ptr->free_act = TRUE;
2552 creature_ptr->levitation = TRUE;
2555 if (IS_HERO(creature_ptr))
2557 creature_ptr->to_h[0] += 12;
2558 creature_ptr->to_h[1] += 12;
2559 creature_ptr->to_h_b += 12;
2560 creature_ptr->to_h_m += 12;
2561 creature_ptr->dis_to_h[0] += 12;
2562 creature_ptr->dis_to_h[1] += 12;
2563 creature_ptr->dis_to_h_b += 12;
2566 if (creature_ptr->shero)
2568 creature_ptr->to_h[0] += 12;
2569 creature_ptr->to_h[1] += 12;
2570 creature_ptr->to_h_b -= 12;
2571 creature_ptr->to_h_m += 12;
2572 creature_ptr->to_d[0] += 3 + (creature_ptr->lev / 5);
2573 creature_ptr->to_d[1] += 3 + (creature_ptr->lev / 5);
2574 creature_ptr->to_d_m += 3 + (creature_ptr->lev / 5);
2575 creature_ptr->dis_to_h[0] += 12;
2576 creature_ptr->dis_to_h[1] += 12;
2577 creature_ptr->dis_to_h_b -= 12;
2578 creature_ptr->dis_to_d[0] += 3 + (creature_ptr->lev / 5);
2579 creature_ptr->dis_to_d[1] += 3 + (creature_ptr->lev / 5);
2580 creature_ptr->to_a -= 10;
2581 creature_ptr->dis_to_a -= 10;
2582 creature_ptr->skill_stl -= 7;
2583 creature_ptr->skill_dev -= 20;
2584 creature_ptr->skill_sav -= 30;
2585 creature_ptr->skill_srh -= 15;
2586 creature_ptr->skill_fos -= 15;
2587 creature_ptr->skill_tht -= 20;
2588 creature_ptr->skill_dig += 30;
2591 if (IS_FAST(creature_ptr))
2596 if (creature_ptr->slow)
2601 if (is_time_limit_esp(creature_ptr))
2603 creature_ptr->telepathy = TRUE;
2606 if (creature_ptr->ele_immune)
2608 if (creature_ptr->special_defense & DEFENSE_ACID)
2609 creature_ptr->immune_acid = TRUE;
2610 else if (creature_ptr->special_defense & DEFENSE_ELEC)
2611 creature_ptr->immune_elec = TRUE;
2612 else if (creature_ptr->special_defense & DEFENSE_FIRE)
2613 creature_ptr->immune_fire = TRUE;
2614 else if (creature_ptr->special_defense & DEFENSE_COLD)
2615 creature_ptr->immune_cold = TRUE;
2618 if (creature_ptr->tim_invis)
2620 creature_ptr->see_inv = TRUE;
2623 if (creature_ptr->tim_infra)
2625 creature_ptr->see_infra += 3;
2628 if (creature_ptr->tim_regen)
2630 creature_ptr->regenerate = TRUE;
2633 if (creature_ptr->tim_levitation)
2635 creature_ptr->levitation = TRUE;
2638 if (creature_ptr->tim_reflect)
2640 creature_ptr->reflect = TRUE;
2643 if (IS_HERO(creature_ptr) || creature_ptr->shero)
2645 creature_ptr->resist_fear = TRUE;
2648 if (creature_ptr->telepathy != old_telepathy)
2650 creature_ptr->update |= (PU_MONSTERS);
2653 if ((creature_ptr->esp_animal != old_esp_animal) ||
2654 (creature_ptr->esp_undead != old_esp_undead) ||
2655 (creature_ptr->esp_demon != old_esp_demon) ||
2656 (creature_ptr->esp_orc != old_esp_orc) ||
2657 (creature_ptr->esp_troll != old_esp_troll) ||
2658 (creature_ptr->esp_giant != old_esp_giant) ||
2659 (creature_ptr->esp_dragon != old_esp_dragon) ||
2660 (creature_ptr->esp_human != old_esp_human) ||
2661 (creature_ptr->esp_evil != old_esp_evil) ||
2662 (creature_ptr->esp_good != old_esp_good) ||
2663 (creature_ptr->esp_nonliving != old_esp_nonliving) ||
2664 (creature_ptr->esp_unique != old_esp_unique))
2666 creature_ptr->update |= (PU_MONSTERS);
2669 if (creature_ptr->see_inv != old_see_inv)
2671 creature_ptr->update |= (PU_MONSTERS);
2674 if (creature_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
2676 if (creature_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
2678 if ((creature_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
2679 (creature_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
2681 creature_ptr->to_h[default_hand] += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2682 creature_ptr->dis_to_h[default_hand] += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2685 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2687 int penalty1, penalty2;
2688 penalty1 = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[INVEN_RARM].weight) / 8);
2689 penalty2 = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[INVEN_LARM].weight) / 8);
2690 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN))
2692 penalty1 = penalty1 / 2 - 5;
2693 penalty2 = penalty2 / 2 - 5;
2695 creature_ptr->to_a += 10;
2696 creature_ptr->dis_to_a += 10;
2700 if (penalty1 > 0) penalty1 /= 2;
2701 if (penalty2 > 0) penalty2 /= 2;
2703 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)))
2705 penalty1 = MAX(0, penalty1 - 10);
2706 penalty2 = MAX(0, penalty2 - 10);
2708 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
2710 penalty1 = MIN(0, penalty1);
2711 penalty2 = MIN(0, penalty2);
2712 creature_ptr->to_a += 10;
2713 creature_ptr->dis_to_a += 10;
2717 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
2719 if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
2723 if (creature_ptr->inventory_list[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
2724 if (creature_ptr->inventory_list[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
2725 creature_ptr->to_h[0] -= (s16b)penalty1;
2726 creature_ptr->to_h[1] -= (s16b)penalty2;
2727 creature_ptr->dis_to_h[0] -= (s16b)penalty1;
2728 creature_ptr->dis_to_h[1] -= (s16b)penalty2;
2731 int j = creature_ptr->total_weight;
2732 if (!creature_ptr->riding)
2734 count = (int)weight_limit(creature_ptr);
2738 monster_type *riding_m_ptr = &floor_ptr->m_list[creature_ptr->riding];
2739 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2740 SPEED speed = riding_m_ptr->mspeed;
2742 if (riding_m_ptr->mspeed > 110)
2744 new_speed = 110 + (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2745 if (new_speed < 110) new_speed = 110;
2752 new_speed += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2753 if (MON_FAST(riding_m_ptr)) new_speed += 10;
2754 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
2755 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
2756 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) creature_ptr->can_swim = TRUE;
2758 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) creature_ptr->pass_wall = FALSE;
2759 if (riding_r_ptr->flags2 & RF2_KILL_WALL) creature_ptr->kill_wall = TRUE;
2761 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED)
2762 j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2764 count = 1500 + riding_r_ptr->level * 25;
2767 if (j > count) new_speed -= ((j - count) / (count / 5));
2768 if (creature_ptr->action == ACTION_SEARCH) new_speed -= 10;
2769 if (creature_ptr->prace == RACE_MERFOLK)
2771 if (have_flag(f_ptr->flags, FF_WATER))
2773 new_speed += (2 + creature_ptr->lev / 10);
2775 else if (!creature_ptr->levitation)
2781 creature_ptr->to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2782 creature_ptr->to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2783 creature_ptr->to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2784 creature_ptr->to_d_m += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2785 creature_ptr->to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2786 creature_ptr->to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2787 creature_ptr->to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2788 creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2789 creature_ptr->to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2790 creature_ptr->to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2791 creature_ptr->to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2792 creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2793 creature_ptr->dis_to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2794 creature_ptr->dis_to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2795 creature_ptr->dis_to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2796 creature_ptr->dis_to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2797 creature_ptr->dis_to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2798 creature_ptr->dis_to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2799 creature_ptr->dis_to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2800 creature_ptr->dis_to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2801 creature_ptr->dis_to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2803 hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
2804 o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2805 creature_ptr->heavy_shoot = is_heavy_shoot(creature_ptr, o_ptr);
2806 if (creature_ptr->heavy_shoot)
2808 creature_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
2809 creature_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
2814 creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
2815 if (o_ptr->k_idx && !creature_ptr->heavy_shoot)
2817 creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
2818 if ((creature_ptr->pclass == CLASS_SNIPER) &&
2819 (creature_ptr->tval_ammo == TV_BOLT))
2821 creature_ptr->to_h_b += (10 + (creature_ptr->lev / 5));
2822 creature_ptr->dis_to_h_b += (10 + (creature_ptr->lev / 5));
2827 if (creature_ptr->ryoute) hold *= 2;
2828 for (int i = 0; i < 2; i++)
2830 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
2831 object_flags(o_ptr, flgs);
2832 creature_ptr->heavy_wield[i] = FALSE;
2833 creature_ptr->icky_wield[i] = FALSE;
2834 creature_ptr->riding_wield[i] = FALSE;
2835 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
2837 creature_ptr->num_blow[i] = 1;
2841 if (hold < o_ptr->weight / 10)
2843 creature_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
2844 creature_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
2845 creature_ptr->heavy_wield[i] = TRUE;
2847 else if (creature_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
2849 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
2851 creature_ptr->to_a += 5;
2852 creature_ptr->dis_to_a += 5;
2855 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i])
2857 int str_index, dex_index;
2858 int num = 0, wgt = 0, mul = 0, div = 0;
2859 switch (creature_ptr->pclass)
2862 num = 6; wgt = 70; mul = 5; break;
2864 case CLASS_BERSERKER:
2865 num = 6; wgt = 70; mul = 7; break;
2868 case CLASS_HIGH_MAGE:
2869 case CLASS_BLUE_MAGE:
2870 num = 3; wgt = 100; mul = 2; break;
2873 case CLASS_MAGIC_EATER:
2874 case CLASS_MINDCRAFTER:
2875 num = 5; wgt = 100; mul = 3; break;
2878 num = 5; wgt = 40; mul = 3; break;
2881 num = 5; wgt = 70; mul = 4; break;
2885 num = 5; wgt = 70; mul = 4; break;
2888 num = 5; wgt = 150; mul = 5; break;
2890 case CLASS_WARRIOR_MAGE:
2891 case CLASS_RED_MAGE:
2892 num = 5; wgt = 70; mul = 3; break;
2894 case CLASS_CHAOS_WARRIOR:
2895 num = 5; wgt = 70; mul = 4; break;
2898 num = 5; wgt = 60; mul = 3; break;
2901 num = 4; wgt = 100; mul = 3; break;
2903 case CLASS_IMITATOR:
2904 num = 5; wgt = 70; mul = 4; break;
2906 case CLASS_BEASTMASTER:
2907 num = 5; wgt = 70; mul = 3; break;
2910 if ((creature_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
2911 else { num = 5; wgt = 100; mul = 3; }
2914 case CLASS_SORCERER:
2915 num = 1; wgt = 1; mul = 1; break;
2920 num = 4; wgt = 70; mul = 2; break;
2922 case CLASS_FORCETRAINER:
2923 num = 4; wgt = 60; mul = 2; break;
2925 case CLASS_MIRROR_MASTER:
2926 num = 3; wgt = 100; mul = 3; break;
2929 num = 4; wgt = 20; mul = 1; break;
2932 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING))
2939 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
2940 str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
2942 if (creature_ptr->ryoute && !omoi) str_index++;
2943 if (creature_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
2944 if (str_index > 11) str_index = 11;
2946 dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
2947 if (dex_index > 11) dex_index = 11;
2949 creature_ptr->num_blow[i] = blows_table[str_index][dex_index];
2950 if (creature_ptr->num_blow[i] > num) creature_ptr->num_blow[i] = (s16b)num;
2952 creature_ptr->num_blow[i] += (s16b)extra_blows[i];
2953 if (creature_ptr->pclass == CLASS_WARRIOR) creature_ptr->num_blow[i] += (creature_ptr->lev / 40);
2954 else if (creature_ptr->pclass == CLASS_BERSERKER)
2955 creature_ptr->num_blow[i] += (creature_ptr->lev / 23);
2956 else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
2957 creature_ptr->num_blow[i] ++;
2959 if (creature_ptr->special_defense & KATA_FUUJIN)
2960 creature_ptr->num_blow[i] -= 1;
2962 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
2963 creature_ptr->num_blow[i] = 1;
2965 if (creature_ptr->num_blow[i] < 1)
2966 creature_ptr->num_blow[i] = 1;
2968 creature_ptr->skill_dig += (o_ptr->weight / 10);
2971 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
2972 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
2974 creature_ptr->to_h[i] -= 2;
2975 creature_ptr->to_d[i] -= 2;
2976 creature_ptr->dis_to_h[i] -= 2;
2977 creature_ptr->dis_to_d[i] -= 2;
2978 creature_ptr->icky_wield[i] = TRUE;
2980 else if (creature_ptr->pclass == CLASS_BERSERKER)
2982 creature_ptr->to_h[i] += creature_ptr->lev / 5;
2983 creature_ptr->to_d[i] += creature_ptr->lev / 6;
2984 creature_ptr->dis_to_h[i] += creature_ptr->lev / 5;
2985 creature_ptr->dis_to_d[i] += creature_ptr->lev / 6;
2986 if (((i == 0) && !creature_ptr->hidarite) || creature_ptr->ryoute)
2988 creature_ptr->to_h[i] += creature_ptr->lev / 5;
2989 creature_ptr->to_d[i] += creature_ptr->lev / 6;
2990 creature_ptr->dis_to_h[i] += creature_ptr->lev / 5;
2991 creature_ptr->dis_to_d[i] += creature_ptr->lev / 6;
2994 else if (creature_ptr->pclass == CLASS_SORCERER)
2996 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
2998 creature_ptr->to_h[i] -= 200;
2999 creature_ptr->to_d[i] -= 200;
3000 creature_ptr->dis_to_h[i] -= 200;
3001 creature_ptr->dis_to_d[i] -= 200;
3002 creature_ptr->icky_wield[i] = TRUE;
3006 creature_ptr->to_h[i] -= 30;
3007 creature_ptr->to_d[i] -= 10;
3008 creature_ptr->dis_to_h[i] -= 30;
3009 creature_ptr->dis_to_d[i] -= 10;
3013 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr))
3015 if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
3016 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_h[i] += 7; creature_ptr->dis_to_h[i] += 7; }
3017 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_h[i] += 13; creature_ptr->dis_to_h[i] += 13; }
3018 if (o_ptr->curse_flags & (TRC_TY_CURSE)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
3019 if (hex_spelling(creature_ptr, HEX_RUNESWORD))
3021 if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_d[i] += 5; creature_ptr->dis_to_d[i] += 5; }
3022 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_d[i] += 7; creature_ptr->dis_to_d[i] += 7; }
3023 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_d[i] += 13; creature_ptr->dis_to_d[i] += 13; }
3027 if (creature_ptr->riding == 0) continue;
3029 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
3031 creature_ptr->to_h[i] += 15;
3032 creature_ptr->dis_to_h[i] += 15;
3033 creature_ptr->to_dd[i] += 2;
3037 if (have_flag(flgs, TR_RIDING)) continue;
3040 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
3046 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3048 if (penalty < 30) penalty = 30;
3051 creature_ptr->to_h[i] -= (s16b)penalty;
3052 creature_ptr->dis_to_h[i] -= (s16b)penalty;
3053 creature_ptr->riding_wield[i] = TRUE;
3056 if (creature_ptr->riding)
3060 creature_ptr->riding_ryoute = FALSE;
3062 if (creature_ptr->ryoute || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE)) creature_ptr->riding_ryoute = TRUE;
3063 else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
3065 switch (creature_ptr->pclass)
3068 case CLASS_FORCETRAINER:
3069 case CLASS_BERSERKER:
3070 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
3071 creature_ptr->riding_ryoute = TRUE;
3076 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
3078 if (creature_ptr->tval_ammo != TV_ARROW) penalty = 5;
3082 penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3084 if (penalty < 30) penalty = 30;
3087 if (creature_ptr->tval_ammo == TV_BOLT) penalty *= 2;
3088 creature_ptr->to_h_b -= (s16b)penalty;
3089 creature_ptr->dis_to_h_b -= (s16b)penalty;
3092 /* Different calculation for monks with empty hands */
3093 if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER)) &&
3094 (empty_hands_status & EMPTY_HAND_RARM) && !creature_ptr->hidarite)
3096 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
3097 creature_ptr->num_blow[0] = 0;
3099 if (creature_ptr->pclass == CLASS_FORCETRAINER)
3101 if (blow_base > 18) creature_ptr->num_blow[0]++;
3102 if (blow_base > 31) creature_ptr->num_blow[0]++;
3103 if (blow_base > 44) creature_ptr->num_blow[0]++;
3104 if (blow_base > 58) creature_ptr->num_blow[0]++;
3107 creature_ptr->to_d[0] += P_PTR_KI / 5;
3108 creature_ptr->dis_to_d[0] += P_PTR_KI / 5;
3113 if (blow_base > 12) creature_ptr->num_blow[0]++;
3114 if (blow_base > 22) creature_ptr->num_blow[0]++;
3115 if (blow_base > 31) creature_ptr->num_blow[0]++;
3116 if (blow_base > 39) creature_ptr->num_blow[0]++;
3117 if (blow_base > 46) creature_ptr->num_blow[0]++;
3118 if (blow_base > 53) creature_ptr->num_blow[0]++;
3119 if (blow_base > 59) creature_ptr->num_blow[0]++;
3122 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
3123 creature_ptr->num_blow[0] /= 2;
3126 creature_ptr->to_h[0] += (creature_ptr->lev / 3);
3127 creature_ptr->dis_to_h[0] += (creature_ptr->lev / 3);
3129 creature_ptr->to_d[0] += (creature_ptr->lev / 6);
3130 creature_ptr->dis_to_d[0] += (creature_ptr->lev / 6);
3133 if (creature_ptr->special_defense & KAMAE_BYAKKO)
3135 creature_ptr->to_a -= 40;
3136 creature_ptr->dis_to_a -= 40;
3139 else if (creature_ptr->special_defense & KAMAE_SEIRYU)
3141 creature_ptr->to_a -= 50;
3142 creature_ptr->dis_to_a -= 50;
3143 creature_ptr->resist_acid = TRUE;
3144 creature_ptr->resist_fire = TRUE;
3145 creature_ptr->resist_elec = TRUE;
3146 creature_ptr->resist_cold = TRUE;
3147 creature_ptr->resist_pois = TRUE;
3148 creature_ptr->sh_fire = TRUE;
3149 creature_ptr->sh_elec = TRUE;
3150 creature_ptr->sh_cold = TRUE;
3151 creature_ptr->levitation = TRUE;
3153 else if (creature_ptr->special_defense & KAMAE_GENBU)
3155 creature_ptr->to_a += (creature_ptr->lev*creature_ptr->lev) / 50;
3156 creature_ptr->dis_to_a += (creature_ptr->lev*creature_ptr->lev) / 50;
3157 creature_ptr->reflect = TRUE;
3158 creature_ptr->num_blow[0] -= 2;
3159 if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42)) creature_ptr->num_blow[0]--;
3160 if (creature_ptr->num_blow[0] < 0) creature_ptr->num_blow[0] = 0;
3162 else if (creature_ptr->special_defense & KAMAE_SUZAKU)
3164 creature_ptr->to_h[0] -= (creature_ptr->lev / 3);
3165 creature_ptr->to_d[0] -= (creature_ptr->lev / 6);
3167 creature_ptr->dis_to_h[0] -= (creature_ptr->lev / 3);
3168 creature_ptr->dis_to_d[0] -= (creature_ptr->lev / 6);
3169 creature_ptr->num_blow[0] /= 2;
3170 creature_ptr->levitation = TRUE;
3173 creature_ptr->num_blow[0] += 1 + extra_blows[0];
3176 if (creature_ptr->riding) creature_ptr->levitation = riding_levitation;
3178 creature_ptr->monk_armour_aux = FALSE;
3180 if (heavy_armor(creature_ptr))
3182 creature_ptr->monk_armour_aux = TRUE;
3185 for (int i = 0; i < 2; i++)
3187 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
3189 OBJECT_TYPE_VALUE tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
3190 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
3192 creature_ptr->to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3193 creature_ptr->dis_to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3194 if ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER))
3196 if (!s_info[creature_ptr->pclass].w_max[tval][sval])
3198 creature_ptr->to_h[i] -= 40;
3199 creature_ptr->dis_to_h[i] -= 40;
3200 creature_ptr->icky_wield[i] = TRUE;
3206 if (creature_ptr->pclass != CLASS_NINJA) continue;
3208 if ((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD))
3211 creature_ptr->to_h[i] -= 40;
3212 creature_ptr->dis_to_h[i] -= 40;
3213 creature_ptr->icky_wield[i] = TRUE;
3214 creature_ptr->num_blow[i] /= 2;
3215 if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1;
3218 /* Maximum speed is (+99). (internally it's 110 + 99) */
3219 /* Temporary lightspeed forces to be maximum speed */
3220 if ((creature_ptr->lightspeed && !creature_ptr->riding) || (new_speed > 209))
3225 /* Minimum speed is (-99). (internally it's 110 - 99) */
3226 if (new_speed < 11) new_speed = 11;
3228 if (creature_ptr->pspeed != (byte)new_speed)
3230 creature_ptr->pspeed = (byte)new_speed;
3231 creature_ptr->redraw |= (PR_SPEED);
3236 if (creature_ptr->to_a > (0 - creature_ptr->ac))
3237 creature_ptr->to_a = 0 - creature_ptr->ac;
3238 if (creature_ptr->dis_to_a > (0 - creature_ptr->dis_ac))
3239 creature_ptr->dis_to_a = 0 - creature_ptr->dis_ac;
3242 if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a))
3244 creature_ptr->redraw |= (PR_ARMOR);
3245 creature_ptr->window |= (PW_PLAYER);
3248 if (creature_ptr->ryoute && !omoi)
3250 int bonus_to_h = 0, bonus_to_d = 0;
3251 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
3252 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);
3254 creature_ptr->to_h[default_hand] += MAX(bonus_to_h, 1);
3255 creature_ptr->dis_to_h[default_hand] += MAX(bonus_to_h, 1);
3256 creature_ptr->to_d[default_hand] += MAX(bonus_to_d, 1);
3257 creature_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
3260 bool is_special_class = creature_ptr->pclass == CLASS_MONK;
3261 is_special_class |= creature_ptr->pclass == CLASS_FORCETRAINER;
3262 is_special_class |= creature_ptr->pclass == CLASS_BERSERKER;
3263 if (is_special_class && (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)))
3264 creature_ptr->ryoute = FALSE;
3266 creature_ptr->skill_stl += 1;
3268 if (is_time_limit_stealth(creature_ptr))
3269 creature_ptr->skill_stl += 99;
3271 creature_ptr->skill_dis += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
3272 creature_ptr->skill_dis += adj_int_dis[creature_ptr->stat_ind[A_INT]];
3273 creature_ptr->skill_dev += adj_int_dev[creature_ptr->stat_ind[A_INT]];
3274 creature_ptr->skill_sav += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
3275 creature_ptr->skill_dig += adj_str_dig[creature_ptr->stat_ind[A_STR]];
3276 creature_ptr->skill_dis += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
3277 creature_ptr->skill_dev += ((cp_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
3278 creature_ptr->skill_sav += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
3279 creature_ptr->skill_stl += (cp_ptr->x_stl * creature_ptr->lev / 10);
3280 creature_ptr->skill_srh += (cp_ptr->x_srh * creature_ptr->lev / 10);
3281 creature_ptr->skill_fos += (cp_ptr->x_fos * creature_ptr->lev / 10);
3282 creature_ptr->skill_thn += ((cp_ptr->x_thn * creature_ptr->lev / 10) + (ap_ptr->a_thn * creature_ptr->lev / 50));
3283 creature_ptr->skill_thb += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
3284 creature_ptr->skill_tht += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
3286 if ((PRACE_IS_(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != SEIKAKU_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE))
3288 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
3289 creature_ptr->skill_stl = MIN(creature_ptr->skill_stl - 3, (creature_ptr->skill_stl + 2) / 2);
3292 if (creature_ptr->skill_stl > 30) creature_ptr->skill_stl = 30;
3293 if (creature_ptr->skill_stl < 0) creature_ptr->skill_stl = 0;
3294 if (creature_ptr->skill_dig < 1) creature_ptr->skill_dig = 1;
3295 if (creature_ptr->anti_magic && (creature_ptr->skill_sav < (90 + creature_ptr->lev)))
3296 creature_ptr->skill_sav = 90 + creature_ptr->lev;
3297 if (creature_ptr->tsubureru) creature_ptr->skill_sav = 10;
3298 if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (creature_ptr->skill_sav < (95 + creature_ptr->lev)))
3299 creature_ptr->skill_sav = 95 + creature_ptr->lev;
3301 if (down_saving) creature_ptr->skill_sav /= 2;
3303 if (creature_ptr->immune_acid) creature_ptr->resist_acid = TRUE;
3304 if (creature_ptr->immune_elec) creature_ptr->resist_elec = TRUE;
3305 if (creature_ptr->immune_fire) creature_ptr->resist_fire = TRUE;
3306 if (creature_ptr->immune_cold) creature_ptr->resist_cold = TRUE;
3308 if (current_world_ptr->character_xtra) return;
3310 if (creature_ptr->old_heavy_shoot != creature_ptr->heavy_shoot)
3312 if (creature_ptr->heavy_shoot)
3314 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
3316 else if (creature_ptr->inventory_list[INVEN_BOW].k_idx)
3318 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
3322 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
3325 creature_ptr->old_heavy_shoot = creature_ptr->heavy_shoot;
3328 for (int i = 0; i < 2; i++)
3330 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i])
3332 if (creature_ptr->heavy_wield[i])
3334 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
3336 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3338 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
3340 else if (creature_ptr->heavy_wield[1 - i])
3342 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
3346 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
3349 creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
3352 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i])
3354 if (creature_ptr->riding_wield[i])
3356 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
3358 else if (!creature_ptr->riding)
3360 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
3362 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3364 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
3367 creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
3370 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
3373 if (creature_ptr->icky_wield[i])
3375 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
3376 if (current_world_ptr->is_loading_now)
3378 chg_virtue(creature_ptr, V_FAITH, -1);
3381 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3383 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
3387 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
3390 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
3393 if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute))
3395 if (creature_ptr->riding_ryoute)
3398 msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
3400 msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
3406 msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
3408 msg_print("You began to control the pet you're riding with one hand.");
3412 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
3415 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))
3417 if (heavy_armor(creature_ptr))
3419 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
3420 if (current_world_ptr->is_loading_now)
3422 chg_virtue(creature_ptr, V_HARMONY, -1);
3427 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
3430 creature_ptr->monk_notify_aux = creature_ptr->monk_armour_aux;
3433 for (int i = 0; i < INVEN_PACK; i++)
3435 if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_sw = TRUE;
3436 if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_kabe = TRUE;
3439 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)
3441 o_ptr = &floor_ptr->o_list[this_o_idx];
3442 next_o_idx = o_ptr->next_o_idx;
3444 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
3445 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
3448 if (creature_ptr->pass_wall && !creature_ptr->kill_wall) creature_ptr->no_flowed = TRUE;
3450 if (have_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER)))
3452 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
3453 if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
3456 if (have_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER)))
3458 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_KABE];
3459 if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
3464 static void calc_alignment(player_type *creature_ptr)
3466 creature_ptr->align = 0;
3467 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3468 for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
3470 monster_type *m_ptr;
3471 monster_race *r_ptr;
3472 m_ptr = &floor_ptr->m_list[m_idx];
3473 if (!monster_is_valid(m_ptr)) continue;
3474 r_ptr = &r_info[m_ptr->r_idx];
3476 if (!is_pet(m_ptr)) continue;
3478 if (r_ptr->flags3 & RF3_GOOD) creature_ptr->align += r_ptr->level;
3479 if (r_ptr->flags3 & RF3_EVIL) creature_ptr->align -= r_ptr->level;
3482 if (creature_ptr->mimic_form)
3484 switch (creature_ptr->mimic_form)
3487 creature_ptr->align -= 200;
3489 case MIMIC_DEMON_LORD:
3490 creature_ptr->align -= 200;
3496 switch (creature_ptr->prace)
3499 creature_ptr->align += 200;
3502 creature_ptr->align -= 200;
3507 for (int i = 0; i < 2; i++)
3509 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
3510 if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL) continue;
3511 creature_ptr->align -= 1000;
3516 for (int i = 0; i < 8; i++)
3518 switch (creature_ptr->vir_types[i])
3521 creature_ptr->align += creature_ptr->virtues[i] * 2;
3530 creature_ptr->align -= creature_ptr->virtues[i];
3533 creature_ptr->align += creature_ptr->virtues[i];
3538 for (int i = 0; i < j; i++)
3540 if (creature_ptr->align > 0)
3542 creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
3543 if (creature_ptr->align < 0) creature_ptr->align = 0;
3545 else if (creature_ptr->align < 0)
3547 creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
3548 if (creature_ptr->align > 0) creature_ptr->align = 0;
3555 * @brief プレイヤーの最大HPを計算する /
3556 * Calculate the players (maximal) hit points
3557 * Adjust current hitpoints if necessary
3561 static void calc_hitpoints(player_type *creature_ptr)
3563 int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
3564 int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
3567 if (creature_ptr->mimic_form)
3569 if (creature_ptr->pclass == CLASS_SORCERER)
3570 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
3572 tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3573 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
3576 if (creature_ptr->pclass == CLASS_SORCERER)
3578 if (creature_ptr->lev < 30)
3579 mhp = (mhp * (45 + creature_ptr->lev) / 100);
3581 mhp = (mhp * 75 / 100);
3582 bonus = (bonus * 65 / 100);
3587 if (creature_ptr->pclass == CLASS_BERSERKER)
3589 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
3592 if (mhp < creature_ptr->lev + 1) mhp = creature_ptr->lev + 1;
3593 if (IS_HERO(creature_ptr)) mhp += 10;
3594 if (creature_ptr->shero && (creature_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
3595 if (creature_ptr->tsuyoshi) mhp += 50;
3596 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) mhp += 15;
3597 if (hex_spelling(creature_ptr, HEX_BUILDING)) mhp += 60;
3598 if (creature_ptr->mhp == mhp) return;
3600 if (creature_ptr->chp >= mhp)
3602 creature_ptr->chp = mhp;
3603 creature_ptr->chp_frac = 0;
3607 if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp))
3609 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
3612 creature_ptr->mhp = mhp;
3614 creature_ptr->redraw |= PR_HP;
3615 creature_ptr->window |= PW_PLAYER;
3620 * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
3623 * SWD: Experimental modification: multiple light sources have additive effect.
3625 static void calc_torch(player_type *creature_ptr)
3627 creature_ptr->cur_lite = 0;
3628 for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
3631 o_ptr = &creature_ptr->inventory_list[i];
3632 if (!o_ptr->k_idx) continue;
3634 if (o_ptr->name2 == EGO_LITE_SHINE) creature_ptr->cur_lite++;
3635 if (o_ptr->name2 != EGO_LITE_DARKNESS)
3637 if (o_ptr->tval == TV_LITE)
3639 if ((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
3640 if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
3644 BIT_FLAGS flgs[TR_FLAG_SIZE];
3645 object_flags(o_ptr, flgs);
3648 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 1;
3649 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 2;
3650 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 3;
3651 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
3652 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
3653 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
3654 creature_ptr->cur_lite += rad;
3657 if (d_info[creature_ptr->dungeon_idx].flags1 & DF1_DARKNESS && creature_ptr->cur_lite > 1)
3658 creature_ptr->cur_lite = 1;
3660 if (creature_ptr->cur_lite <= 0 && creature_ptr->lite)
3661 creature_ptr->cur_lite++;
3663 if (creature_ptr->cur_lite > 14)
3664 creature_ptr->cur_lite = 14;
3666 if (creature_ptr->cur_lite < 0)
3667 creature_ptr->cur_lite = 0;
3669 if (creature_ptr->old_lite == creature_ptr->cur_lite)
3672 creature_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
3673 creature_ptr->old_lite = creature_ptr->cur_lite;
3675 if ((creature_ptr->cur_lite > 0) && (creature_ptr->special_defense & NINJA_S_STEALTH))
3676 set_superstealth(creature_ptr, FALSE);
3681 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
3682 * Calculate number of spells player should have, and forget,
3683 * or remember, spells until that number is properly reflected.
3686 * Note that this function induces various "status" messages,
3687 * which must be bypasses until the character is created.
3689 static void calc_spells(player_type *creature_ptr)
3691 if (!mp_ptr->spell_book) return;
3692 if (!current_world_ptr->character_generated) return;
3693 if (current_world_ptr->character_xtra) return;
3694 if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE))
3696 creature_ptr->new_spells = 0;
3700 concptr p = spell_category_name(mp_ptr->spell_book);
3701 int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
3702 if (levels < 0) levels = 0;
3704 int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
3706 if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
3711 if (creature_ptr->pclass == CLASS_SAMURAI)
3715 else if (creature_ptr->realm2 == REALM_NONE)
3717 num_allowed = (num_allowed + 1) / 2;
3718 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
3720 else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST))
3722 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
3726 if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
3729 int num_boukyaku = 0;
3730 for (int j = 0; j < 64; j++)
3733 (creature_ptr->spell_forgotten1 & (1L << j)) :
3734 (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
3740 creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
3741 for (int i = 63; i >= 0; i--)
3743 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
3745 int j = creature_ptr->spell_order[i];
3746 if (j >= 99) continue;
3748 const magic_type *s_ptr;
3749 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
3752 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3754 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
3757 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
3759 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
3761 if (s_ptr->slevel <= creature_ptr->lev) continue;
3763 bool is_spell_learned = (j < 32) ?
3764 (creature_ptr->spell_learned1 & (1L << j)) :
3765 (creature_ptr->spell_learned2 & (1L << (j - 32)));
3766 if (!is_spell_learned) continue;
3771 creature_ptr->spell_forgotten1 |= (1L << j);
3772 which = creature_ptr->realm1;
3776 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
3777 which = creature_ptr->realm2;
3782 creature_ptr->spell_learned1 &= ~(1L << j);
3783 which = creature_ptr->realm1;
3787 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
3788 which = creature_ptr->realm2;
3792 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3794 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3796 creature_ptr->new_spells++;
3799 /* Forget spells if we know too many spells */
3800 for (int i = 63; i >= 0; i--)
3802 if (creature_ptr->new_spells >= 0) break;
3803 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
3805 int j = creature_ptr->spell_order[i];
3806 if (j >= 99) continue;
3808 bool is_spell_learned = (j < 32) ?
3809 (creature_ptr->spell_learned1 & (1L << j)) :
3810 (creature_ptr->spell_learned2 & (1L << (j - 32)));
3811 if (!is_spell_learned) continue;
3816 creature_ptr->spell_forgotten1 |= (1L << j);
3817 which = creature_ptr->realm1;
3821 creature_ptr->spell_forgotten2 |= (1L << (j - 32));
3822 which = creature_ptr->realm2;
3827 creature_ptr->spell_learned1 &= ~(1L << j);
3828 which = creature_ptr->realm1;
3832 creature_ptr->spell_learned2 &= ~(1L << (j - 32));
3833 which = creature_ptr->realm2;
3837 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3839 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3841 creature_ptr->new_spells++;
3844 /* Check for spells to remember */
3845 for (int i = 0; i < 64; i++)
3847 if (creature_ptr->new_spells <= 0) break;
3848 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2) break;
3849 int j = creature_ptr->spell_order[i];
3852 const magic_type *s_ptr;
3853 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
3856 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3858 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
3861 s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
3863 s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
3865 if (s_ptr->slevel > creature_ptr->lev) continue;
3867 bool is_spell_learned = (j < 32) ?
3868 (creature_ptr->spell_forgotten1 & (1L << j)) :
3869 (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
3870 if (!is_spell_learned) continue;
3875 creature_ptr->spell_forgotten1 &= ~(1L << j);
3876 which = creature_ptr->realm1;
3880 creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
3881 which = creature_ptr->realm2;
3886 creature_ptr->spell_learned1 |= (1L << j);
3887 which = creature_ptr->realm1;
3891 creature_ptr->spell_learned2 |= (1L << (j - 32));
3892 which = creature_ptr->realm2;
3896 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3898 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3900 creature_ptr->new_spells--;
3903 if (creature_ptr->realm2 == REALM_NONE)
3906 for (int j = 0; j < 32; j++)
3908 const magic_type *s_ptr;
3909 if (!is_magic(creature_ptr->realm1)) s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3910 else s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
3912 if (s_ptr->slevel > creature_ptr->lev) continue;
3914 if (creature_ptr->spell_learned1 & (1L << j))
3923 if ((creature_ptr->new_spells > k) &&
3924 ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
3926 creature_ptr->new_spells = (s16b)k;
3930 if (creature_ptr->new_spells < 0) creature_ptr->new_spells = 0;
3932 if (creature_ptr->old_spells == creature_ptr->new_spells) return;
3934 if (creature_ptr->new_spells)
3937 if (creature_ptr->new_spells < 10) {
3938 msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
3941 msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
3944 msg_format("You can learn %d more %s%s.",
3945 creature_ptr->new_spells, p,
3946 (creature_ptr->new_spells != 1) ? "s" : "");
3950 creature_ptr->old_spells = creature_ptr->new_spells;
3951 creature_ptr->redraw |= PR_STUDY;
3952 creature_ptr->window |= PW_OBJECT;
3957 * @brief プレイヤーの最大MPを計算する /
3958 * Calculate maximum mana. You do not need to know any spells.
3959 * Note that mana is lowered by heavy (or inappropriate) armor.
3962 * This function induces status messages.
3964 static void calc_mana(player_type *creature_ptr)
3966 if (!mp_ptr->spell_book) return;
3969 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) ||
3970 (creature_ptr->pclass == CLASS_MIRROR_MASTER) ||
3971 (creature_ptr->pclass == CLASS_BLUE_MAGE))
3973 levels = creature_ptr->lev;
3977 if (mp_ptr->spell_first > creature_ptr->lev)
3979 creature_ptr->msp = 0;
3980 creature_ptr->redraw |= (PR_MANA);
3984 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
3988 if (creature_ptr->pclass == CLASS_SAMURAI)
3990 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
3991 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3995 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
3997 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3998 if (msp && (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
3999 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
4000 if (msp && (creature_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + creature_ptr->lev) / 100;
4003 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
4005 BIT_FLAGS flgs[TR_FLAG_SIZE];
4006 creature_ptr->cumber_glove = FALSE;
4008 o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
4009 object_flags(o_ptr, flgs);
4011 !(have_flag(flgs, TR_FREE_ACT)) &&
4012 !(have_flag(flgs, TR_DEC_MANA)) &&
4013 !(have_flag(flgs, TR_EASY_SPELL)) &&
4014 !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
4015 !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
4017 creature_ptr->cumber_glove = TRUE;
4018 msp = (3 * msp) / 4;
4022 creature_ptr->cumber_armor = FALSE;
4025 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4026 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4027 cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
4028 cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
4029 cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
4030 cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
4031 cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
4033 switch (creature_ptr->pclass)
4036 case CLASS_HIGH_MAGE:
4037 case CLASS_BLUE_MAGE:
4039 case CLASS_FORCETRAINER:
4040 case CLASS_SORCERER:
4042 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4043 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4050 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
4051 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
4054 case CLASS_MINDCRAFTER:
4055 case CLASS_BEASTMASTER:
4056 case CLASS_MIRROR_MASTER:
4058 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 2;
4059 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
4064 case CLASS_RED_MAGE:
4065 case CLASS_WARRIOR_MAGE:
4067 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 3;
4068 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
4072 case CLASS_CHAOS_WARRIOR:
4074 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 5;
4075 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
4084 int max_wgt = mp_ptr->spell_weight;
4085 if ((cur_wgt - max_wgt) > 0)
4087 creature_ptr->cumber_armor = TRUE;
4088 switch (creature_ptr->pclass)
4091 case CLASS_HIGH_MAGE:
4092 case CLASS_BLUE_MAGE:
4094 msp -= msp * (cur_wgt - max_wgt) / 600;
4098 case CLASS_MINDCRAFTER:
4099 case CLASS_BEASTMASTER:
4101 case CLASS_FORCETRAINER:
4103 case CLASS_MIRROR_MASTER:
4105 msp -= msp * (cur_wgt - max_wgt) / 800;
4108 case CLASS_SORCERER:
4110 msp -= msp * (cur_wgt - max_wgt) / 900;
4116 case CLASS_RED_MAGE:
4118 msp -= msp * (cur_wgt - max_wgt) / 1000;
4122 case CLASS_CHAOS_WARRIOR:
4123 case CLASS_WARRIOR_MAGE:
4125 msp -= msp * (cur_wgt - max_wgt) / 1200;
4130 creature_ptr->cumber_armor = FALSE;
4135 msp -= msp * (cur_wgt - max_wgt) / 800;
4141 if (msp < 0) msp = 0;
4143 if (creature_ptr->msp != msp)
4145 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI))
4147 creature_ptr->csp = msp;
4148 creature_ptr->csp_frac = 0;
4152 if (creature_ptr->level_up_message && (msp > creature_ptr->msp))
4154 msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
4157 creature_ptr->msp = msp;
4158 creature_ptr->redraw |= (PR_MANA);
4159 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
4162 if (current_world_ptr->character_xtra) return;
4164 if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove)
4166 if (creature_ptr->cumber_glove)
4167 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
4169 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
4171 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
4174 if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor) return;
4176 if (creature_ptr->cumber_armor)
4177 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
4179 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
4181 creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
4186 * @brief 装備中の射撃武器の威力倍率を返す /
4187 * calcurate the fire rate of target object
4188 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
4189 * @return 射撃倍率の値(100で1.00倍)
4191 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
4193 int extra_shots = 0;
4194 BIT_FLAGS flgs[TR_FLAG_SIZE];
4195 for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
4198 q_ptr = &creature_ptr->inventory_list[i];
4199 if (!q_ptr->k_idx) continue;
4201 if (i == INVEN_BOW) continue;
4203 object_flags(q_ptr, flgs);
4204 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
4207 object_flags(o_ptr, flgs);
4208 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
4211 if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
4215 num += (extra_shots * 100);
4217 OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
4218 if ((creature_ptr->pclass == CLASS_RANGER) &&
4219 (tval_ammo == TV_ARROW))
4221 num += (creature_ptr->lev * 4);
4224 if ((creature_ptr->pclass == CLASS_CAVALRY) &&
4225 (tval_ammo == TV_ARROW))
4227 num += (creature_ptr->lev * 3);
4230 if (creature_ptr->pclass == CLASS_ARCHER)
4232 if (tval_ammo == TV_ARROW)
4233 num += ((creature_ptr->lev * 5) + 50);
4234 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
4235 num += (creature_ptr->lev * 4);
4238 if (creature_ptr->pclass == CLASS_WARRIOR &&
4239 (tval_ammo <= TV_BOLT) &&
4240 (tval_ammo >= TV_SHOT))
4242 num += (creature_ptr->lev * 2);
4245 if ((creature_ptr->pclass == CLASS_ROGUE) &&
4246 (tval_ammo == TV_SHOT))
4248 num += (creature_ptr->lev * 4);
4256 * @brief プレイヤーの所持重量制限を計算する /
4257 * Computes current weight limit.
4260 WEIGHT weight_limit(player_type *creature_ptr)
4262 WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
4263 if (creature_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
4269 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
4270 * @param i 判定する手のID(右手:0 左手:1)
4271 * @return 持っているならばTRUE
4273 bool has_melee_weapon(player_type *creature_ptr, int i)
4275 return ((creature_ptr->inventory_list[i].k_idx && object_is_melee_weapon(&creature_ptr->inventory_list[i])) ? TRUE : FALSE);
4280 * @brief プレイヤーの現在開いている手の状態を返す
4281 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
4282 * @return 開いている手のビットフラグ
4284 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
4286 BIT_FLAGS16 status = EMPTY_HAND_NONE;
4287 if (!creature_ptr->inventory_list[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
4288 if (!creature_ptr->inventory_list[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
4290 if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS))
4292 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
4293 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
4301 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
4302 * @return ペナルティが適用されるならばTRUE。
4304 bool heavy_armor(player_type *creature_ptr)
4306 if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
4309 WEIGHT monk_arm_wgt = 0;
4310 if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4311 if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4312 monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
4313 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
4314 monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
4315 monk_arm_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
4316 monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
4318 return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
4323 * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
4325 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
4327 void update_creature(player_type *creature_ptr)
4329 if (!creature_ptr->update) return;
4331 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4332 if (creature_ptr->update & (PU_AUTODESTROY))
4334 creature_ptr->update &= ~(PU_AUTODESTROY);
4335 autopick_delayed_alter(creature_ptr);
4338 if (creature_ptr->update & (PU_COMBINE))
4340 creature_ptr->update &= ~(PU_COMBINE);
4341 combine_pack(creature_ptr);
4344 if (creature_ptr->update & (PU_REORDER))
4346 creature_ptr->update &= ~(PU_REORDER);
4347 reorder_pack(creature_ptr);
4350 if (creature_ptr->update & (PU_BONUS))
4352 creature_ptr->update &= ~(PU_BONUS);
4353 calc_alignment(creature_ptr);
4354 calc_bonuses(creature_ptr);
4357 if (creature_ptr->update & (PU_TORCH))
4359 creature_ptr->update &= ~(PU_TORCH);
4360 calc_torch(creature_ptr);
4363 if (creature_ptr->update & (PU_HP))
4365 creature_ptr->update &= ~(PU_HP);
4366 calc_hitpoints(creature_ptr);
4369 if (creature_ptr->update & (PU_MANA))
4371 creature_ptr->update &= ~(PU_MANA);
4372 calc_mana(creature_ptr);
4375 if (creature_ptr->update & (PU_SPELLS))
4377 creature_ptr->update &= ~(PU_SPELLS);
4378 calc_spells(creature_ptr);
4381 if (!current_world_ptr->character_generated) return;
4382 if (current_world_ptr->character_icky) return;
4383 if (creature_ptr->update & (PU_UN_LITE))
4385 creature_ptr->update &= ~(PU_UN_LITE);
4386 forget_lite(floor_ptr);
4389 if (creature_ptr->update & (PU_UN_VIEW))
4391 creature_ptr->update &= ~(PU_UN_VIEW);
4392 forget_view(floor_ptr);
4395 if (creature_ptr->update & (PU_VIEW))
4397 creature_ptr->update &= ~(PU_VIEW);
4398 update_view(creature_ptr);
4401 if (creature_ptr->update & (PU_LITE))
4403 creature_ptr->update &= ~(PU_LITE);
4404 update_lite(creature_ptr);
4407 if (creature_ptr->update & (PU_FLOW))
4409 creature_ptr->update &= ~(PU_FLOW);
4410 update_flow(creature_ptr);
4413 if (creature_ptr->update & (PU_DISTANCE))
4415 creature_ptr->update &= ~(PU_DISTANCE);
4417 update_monsters(creature_ptr, TRUE);
4420 if (creature_ptr->update & (PU_MON_LITE))
4422 creature_ptr->update &= ~(PU_MON_LITE);
4423 update_mon_lite(creature_ptr);
4426 if (creature_ptr->update & (PU_DELAY_VIS))
4428 creature_ptr->update &= ~(PU_DELAY_VIS);
4429 delayed_visual_update(creature_ptr);
4432 if (creature_ptr->update & (PU_MONSTERS))
4434 creature_ptr->update &= ~(PU_MONSTERS);
4435 update_monsters(creature_ptr, FALSE);
4441 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
4442 * @return 魔道書を一冊も持っていないならTRUEを返す
4444 bool player_has_no_spellbooks(player_type *creature_ptr)
4447 for (int i = 0; i < INVEN_PACK; i++)
4449 o_ptr = &creature_ptr->inventory_list[i];
4450 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
4453 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4454 for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
4456 o_ptr = &floor_ptr->o_list[i];
4457 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
4464 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
4466 creature_ptr->energy_use = (ENERGY)need_cost;
4470 void free_turn(player_type *creature_ptr)
4472 creature_ptr->energy_use = 0;
4477 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4480 * @return 配置に成功したらTRUE
4482 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
4484 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0) return FALSE;
4486 /* Save player location */
4487 creature_ptr->y = y;
4488 creature_ptr->x = x;
4494 * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
4497 void wreck_the_pattern(player_type *creature_ptr)
4499 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4500 int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
4501 if (pattern_type == PATTERN_TILE_WRECKED) return;
4503 msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
4504 msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
4506 if (!IS_INVULN(creature_ptr))
4507 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
4509 int to_ruin = randint1(45) + 35;
4513 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
4515 if (pattern_tile(floor_ptr, r_y, r_x) &&
4516 (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
4518 cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
4522 cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
4527 * @brief エルドリッチホラーの形容詞種別を決める
4528 * @param r_ptr モンスター情報への参照ポインタ
4531 concptr decide_horror_message(monster_race *r_ptr)
4533 int horror_num = randint0(MAX_SAN_HORROR_SUM);
4534 if (horror_num < MAX_SAN_HORROR_COMMON)
4536 return horror_desc_common[horror_num];
4539 if ((r_ptr->flags3 & RF3_EVIL) != 0)
4541 return horror_desc_evil[horror_num - MAX_SAN_HORROR_COMMON];
4544 return horror_desc_neutral[horror_num - MAX_SAN_HORROR_COMMON];
4549 * todo m_nameとdescで何が違うのかは良く分からない
4550 * @brief エルドリッチホラー持ちのモンスターを見た時の反応 (モンスター名版)
4551 * @param m_name モンスター名
4552 * @param r_ptr モンスター情報への参照ポインタ
4555 void see_eldritch_horror(GAME_TEXT *m_name, monster_race *r_ptr)
4557 concptr horror_message = decide_horror_message(r_ptr);
4558 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), horror_message, m_name);
4559 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4564 * @brief エルドリッチホラー持ちのモンスターを見た時の反応 (モンスター名版)
4565 * @param desc モンスター名 (エルドリッチホラー持ちの全モンスターからランダム…のはず)
4566 * @param r_ptr モンスターへの参照ポインタ
4569 void feel_eldritch_horror(concptr desc, monster_race *r_ptr)
4571 concptr horror_message = decide_horror_message(r_ptr);
4572 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), horror_message, desc);
4573 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4578 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
4579 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ。薬・罠・魔法の影響ならNULL
4580 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
4583 void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
4585 if (creature_ptr->phase_out || !current_world_ptr->character_dungeon) return;
4588 if (!necro && m_ptr)
4590 GAME_TEXT m_name[MAX_NLEN];
4591 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
4592 power = r_ptr->level / 2;
4593 monster_desc(creature_ptr, m_name, m_ptr, 0);
4594 if (!(r_ptr->flags1 & RF1_UNIQUE))
4596 if (r_ptr->flags1 & RF1_FRIENDS)
4601 if (!current_world_ptr->is_loading_now)
4607 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
4613 if (randint1(100) > power) return;
4615 if (saving_throw(creature_ptr->skill_sav - power))
4618 if (creature_ptr->image)
4620 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4621 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4625 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4626 creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
4632 see_eldritch_horror(m_name, r_ptr);
4633 if (PRACE_IS_(creature_ptr, RACE_IMP) ||
4634 PRACE_IS_(creature_ptr, RACE_DEMON) ||
4635 (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) ||
4636 current_world_ptr->wizard)
4639 if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_ZOMBIE)
4640 || PRACE_IS_(creature_ptr, RACE_VAMPIRE) || PRACE_IS_(creature_ptr, RACE_SPECTRE) ||
4641 (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
4643 if (saving_throw(25 + creature_ptr->lev)) return;
4648 monster_race *r_ptr;
4649 GAME_TEXT m_name[MAX_NLEN];
4651 get_mon_num_prep(creature_ptr, get_nightmare, NULL);
4652 r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH, 0)];
4653 power = r_ptr->level + 10;
4654 desc = r_name + r_ptr->name;
4655 get_mon_num_prep(creature_ptr, NULL, NULL);
4659 if (!(r_ptr->flags1 & RF1_UNIQUE))
4660 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
4663 sprintf(m_name, "%s", desc);
4665 if (!(r_ptr->flags1 & RF1_UNIQUE))
4667 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
4671 if (saving_throw(creature_ptr->skill_sav * 100 / power))
4673 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
4677 if (creature_ptr->image)
4679 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4680 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4684 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4685 creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
4691 feel_eldritch_horror(desc, r_ptr);
4692 if (!creature_ptr->mimic_form)
4694 switch (creature_ptr->prace)
4698 if (saving_throw(20 + creature_ptr->lev)) return;
4704 if (saving_throw(10 + creature_ptr->lev)) return;
4710 if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
4712 if (saving_throw(20 + creature_ptr->lev)) return;
4714 else if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
4716 if (saving_throw(10 + creature_ptr->lev)) return;
4722 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
4725 /* 過去の効果無効率再現のため5回saving_throw 実行 */
4726 if (saving_throw(creature_ptr->skill_sav - power)
4727 && saving_throw(creature_ptr->skill_sav - power)
4728 && saving_throw(creature_ptr->skill_sav - power)
4729 && saving_throw(creature_ptr->skill_sav - power)
4730 && saving_throw(creature_ptr->skill_sav - power))
4735 switch (randint1(22))
4739 if (!(creature_ptr->muta3 & MUT3_MORONIC))
4741 if ((creature_ptr->stat_use[A_INT] < 4) && (creature_ptr->stat_use[A_WIS] < 4))
4743 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
4747 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
4750 if (creature_ptr->muta3 & MUT3_HYPER_INT)
4752 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
4753 creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
4756 creature_ptr->muta3 |= MUT3_MORONIC;
4763 if (!(creature_ptr->muta2 & MUT2_COWARDICE) && !creature_ptr->resist_fear)
4765 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
4766 if (creature_ptr->muta3 & MUT3_FEARLESS)
4768 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
4769 creature_ptr->muta3 &= ~(MUT3_FEARLESS);
4772 creature_ptr->muta2 |= MUT2_COWARDICE;
4779 if (!(creature_ptr->muta2 & MUT2_HALLU) && !creature_ptr->resist_chaos)
4781 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
4782 creature_ptr->muta2 |= MUT2_HALLU;
4789 if (!(creature_ptr->muta2 & MUT2_BERS_RAGE) && !creature_ptr->resist_conf)
4791 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
4792 creature_ptr->muta2 |= MUT2_BERS_RAGE;
4806 if (!creature_ptr->resist_conf)
4808 (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
4811 if (!creature_ptr->resist_chaos && one_in_(3))
4813 (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
4816 /* todo いつからかは不明だがreturnとbreakが同時に存在している。どちらがデッドコードか不明瞭なので保留 */
4824 if (!creature_ptr->resist_conf)
4826 (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
4828 if (!creature_ptr->free_act)
4830 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + randint0(4) + 4);
4832 if (!creature_ptr->resist_chaos)
4834 (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
4839 (void)do_dec_stat(creature_ptr, A_INT);
4840 } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
4844 (void)do_dec_stat(creature_ptr, A_WIS);
4845 } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
4852 if (lose_all_info(creature_ptr))
4853 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
4862 do_dec_stat(creature_ptr, A_INT);
4863 do_dec_stat(creature_ptr, A_WIS);
4870 creature_ptr->update |= PU_BONUS;
4871 handle_stuff(creature_ptr);
4876 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
4877 * Advance experience levels and print experience
4880 void check_experience(player_type *creature_ptr)
4882 if (creature_ptr->exp < 0) creature_ptr->exp = 0;
4883 if (creature_ptr->max_exp < 0) creature_ptr->max_exp = 0;
4884 if (creature_ptr->max_max_exp < 0) creature_ptr->max_max_exp = 0;
4886 if (creature_ptr->exp > PY_MAX_EXP) creature_ptr->exp = PY_MAX_EXP;
4887 if (creature_ptr->max_exp > PY_MAX_EXP) creature_ptr->max_exp = PY_MAX_EXP;
4888 if (creature_ptr->max_max_exp > PY_MAX_EXP) creature_ptr->max_max_exp = PY_MAX_EXP;
4890 if (creature_ptr->exp > creature_ptr->max_exp) creature_ptr->max_exp = creature_ptr->exp;
4891 if (creature_ptr->max_exp > creature_ptr->max_max_exp) creature_ptr->max_max_exp = creature_ptr->max_exp;
4893 creature_ptr->redraw |= (PR_EXP);
4894 handle_stuff(creature_ptr);
4896 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
4897 PLAYER_LEVEL old_lev = creature_ptr->lev;
4898 while ((creature_ptr->lev > 1) &&
4899 (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L)))
4901 creature_ptr->lev--;
4902 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4903 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
4904 creature_ptr->window |= (PW_PLAYER);
4905 handle_stuff(creature_ptr);
4908 bool level_reward = FALSE;
4909 bool level_mutation = FALSE;
4910 bool level_inc_stat = FALSE;
4911 while ((creature_ptr->lev < PY_MAX_LEVEL) &&
4912 (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L)))
4914 creature_ptr->lev++;
4915 if (creature_ptr->lev > creature_ptr->max_plv)
4917 creature_ptr->max_plv = creature_ptr->lev;
4919 if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
4920 (creature_ptr->muta2 & MUT2_CHAOS_GIFT))
4922 level_reward = TRUE;
4924 if (creature_ptr->prace == RACE_BEASTMAN)
4926 if (one_in_(5)) level_mutation = TRUE;
4928 level_inc_stat = TRUE;
4930 exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
4934 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
4935 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4936 creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
4937 creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
4938 creature_ptr->level_up_message = TRUE;
4939 handle_stuff(creature_ptr);
4941 creature_ptr->level_up_message = FALSE;
4944 if (!(creature_ptr->max_plv % 10))
4953 cnv_stat(creature_ptr->stat_max[0], tmp);
4954 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
4955 cnv_stat(creature_ptr->stat_max[1], tmp);
4956 prt(format(_(" b) 知能 (現在値 %s)", " b) Int (cur %s)"), tmp), 3, 14);
4957 cnv_stat(creature_ptr->stat_max[2], tmp);
4958 prt(format(_(" c) 賢さ (現在値 %s)", " c) Wis (cur %s)"), tmp), 4, 14);
4959 cnv_stat(creature_ptr->stat_max[3], tmp);
4960 prt(format(_(" d) 器用 (現在値 %s)", " d) Dex (cur %s)"), tmp), 5, 14);
4961 cnv_stat(creature_ptr->stat_max[4], tmp);
4962 prt(format(_(" e) 耐久 (現在値 %s)", " e) Con (cur %s)"), tmp), 6, 14);
4963 cnv_stat(creature_ptr->stat_max[5], tmp);
4964 prt(format(_(" f) 魅力 (現在値 %s)", " f) Chr (cur %s)"), tmp), 7, 14);
4967 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
4972 if ((choice >= 'a') && (choice <= 'f')) break;
4974 for (n = 0; n < A_MAX; n++)
4975 if (n != choice - 'a')
4977 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
4979 do_inc_stat(creature_ptr, choice - 'a');
4982 else if (!(creature_ptr->max_plv % 2))
4983 do_inc_stat(creature_ptr, randint0(6));
4988 msg_print(_("あなたは変わった気がする...", "You feel different..."));
4989 (void)gain_mutation(creature_ptr, 0);
4990 level_mutation = FALSE;
4994 * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
4999 gain_level_reward(creature_ptr, 0);
5000 level_reward = FALSE;
5003 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5004 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
5005 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
5006 handle_stuff(creature_ptr);
5009 if (old_lev != creature_ptr->lev)
5010 autopick_load_pref(creature_ptr, FALSE);
5015 * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
5017 * @param out_val 出力先文字列ポインタ
5020 void cnv_stat(int val, char *out_val)
5024 sprintf(out_val, " %2d", val);
5028 int bonus = (val - 18);
5031 sprintf(out_val, "18/%3s", "***");
5033 else if (bonus >= 100)
5035 sprintf(out_val, "18/%03d", bonus);
5039 sprintf(out_val, " 18/%02d", bonus);
5045 * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
5046 * Modify a stat value by a "modifier", return new value
5048 * @param amount 加減算値
5052 * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
5053 * Or even: 18/13, 18/23, 18/33, ..., 18/220
5054 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
5055 * Or even: 18/13, 18/03, 18, 17, ..., 3
5058 s16b modify_stat_value(int value, int amount)
5062 for (int i = 0; i < amount; i++)
5064 if (value < 18) value++;
5068 else if (amount < 0)
5070 for (int i = 0; i < (0 - amount); i++)
5072 if (value >= 18 + 10) value -= 10;
5073 else if (value > 18) value = 18;
5074 else if (value > 3) value--;
5084 * Hack -- Calculates the total number of points earned -JWT-
5088 long calc_score(player_type *creature_ptr)
5090 int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
5093 if (!preserve_mode) mult += 10;
5094 if (!autoroller) mult += 10;
5095 if (!smart_learn) mult -= 20;
5096 if (smart_cheat) mult += 30;
5097 if (ironman_shops) mult += 50;
5098 if (ironman_small_levels) mult += 10;
5099 if (ironman_empty_levels) mult += 20;
5100 if (!powerup_home) mult += 50;
5101 if (ironman_rooms) mult += 100;
5102 if (ironman_nightmare) mult += 100;
5104 if (mult < 5) mult = 5;
5107 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
5108 if (max_dlv[i] > max_dl)
5109 max_dl = max_dlv[i];
5111 u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
5112 u32b point_h = point_l / 0x10000L;
5113 point_l = point_l % 0x10000L;
5116 point_h += point_l / 0x10000L;
5117 point_l %= 0x10000L;
5119 point_l += ((point_h % 100) << 16);
5123 u32b point = (point_h << 16) + (point_l);
5124 if (creature_ptr->arena_number >= 0)
5125 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
5127 if (ironman_downward) point *= 2;
5128 if (creature_ptr->pclass == CLASS_BERSERKER)
5130 if (creature_ptr->prace == RACE_SPECTRE)
5134 if ((creature_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
5137 if (current_world_ptr->total_winner) point = 2;
5140 if (easy_band) point = (0 - point);
5146 void cheat_death(player_type *creature_ptr)
5148 if (creature_ptr->sc)
5149 creature_ptr->sc = creature_ptr->age = 0;
5150 creature_ptr->age++;
5152 current_world_ptr->noscore |= 0x0001;
5153 msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
5156 (void)life_stream(creature_ptr, FALSE, FALSE);
5157 if (creature_ptr->pclass == CLASS_MAGIC_EATER)
5160 for (magic_idx = 0; magic_idx < EATER_EXT * 2; magic_idx++)
5162 creature_ptr->magic_num1[magic_idx] = creature_ptr->magic_num2[magic_idx] * EATER_CHARGE;
5164 for (; magic_idx < EATER_EXT * 3; magic_idx++)
5166 creature_ptr->magic_num1[magic_idx] = 0;
5170 creature_ptr->csp = creature_ptr->msp;
5171 creature_ptr->csp_frac = 0;
5172 if (creature_ptr->word_recall)
5174 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
5176 creature_ptr->word_recall = 0;
5177 creature_ptr->redraw |= (PR_STATUS);
5180 if (creature_ptr->alter_reality)
5182 creature_ptr->alter_reality = 0;
5183 creature_ptr->redraw |= (PR_STATUS);
5186 (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
5187 creature_ptr->is_dead = FALSE;
5188 (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
5190 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
5191 floor_ptr->dun_level = 0;
5192 floor_ptr->inside_arena = FALSE;
5193 creature_ptr->phase_out = FALSE;
5195 floor_ptr->inside_quest = 0;
5196 if (creature_ptr->dungeon_idx) creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
5197 creature_ptr->dungeon_idx = 0;
5198 if (lite_town || vanilla_town)
5200 creature_ptr->wilderness_y = 1;
5201 creature_ptr->wilderness_x = 1;
5204 creature_ptr->oldpy = 10;
5205 creature_ptr->oldpx = 34;
5209 creature_ptr->oldpy = 33;
5210 creature_ptr->oldpx = 131;
5215 creature_ptr->wilderness_y = 48;
5216 creature_ptr->wilderness_x = 5;
5217 creature_ptr->oldpy = 33;
5218 creature_ptr->oldpx = 131;
5221 creature_ptr->wild_mode = FALSE;
5222 creature_ptr->leaving = TRUE;
5224 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1,
5228 leave_floor(creature_ptr);
5229 wipe_monsters_list(creature_ptr);
5234 * @param creature_ptr プレーヤーへの参照ポインタ
5235 * @return 祝福状態ならばTRUE
5237 bool is_blessed(player_type *creature_ptr)
5239 return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
5243 bool is_oppose_acid(player_type *creature_ptr)
5245 return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5249 bool is_oppose_elec(player_type *creature_ptr)
5251 return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5255 bool is_oppose_fire(player_type *creature_ptr)
5257 return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5261 bool is_oppose_cold(player_type *creature_ptr)
5263 return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5267 bool is_oppose_pois(player_type *creature_ptr)
5269 return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5273 bool is_tim_esp(player_type *creature_ptr)
5275 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
5279 bool is_tim_stealth(player_type *creature_ptr)
5281 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
5285 bool is_time_limit_esp(player_type *creature_ptr)
5287 return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
5291 bool is_time_limit_stealth(player_type *creature_ptr)
5293 return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
5297 bool can_two_hands_wielding(player_type *creature_ptr)
5299 return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS);
5305 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
5308 void stop_singing(player_type *creature_ptr)
5310 if (creature_ptr->pclass != CLASS_BARD) return;
5312 /* Are there interupted song? */
5313 if (INTERUPTING_SONG_EFFECT(creature_ptr))
5315 /* Forget interupted song */
5316 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
5320 /* The player is singing? */
5321 if (!SINGING_SONG_EFFECT(creature_ptr)) return;
5323 /* Hack -- if called from set_action(), avoid recursive loop */
5324 if (creature_ptr->action == ACTION_SING) set_action(creature_ptr, ACTION_NONE);
5326 /* Message text of each song or etc. */
5327 exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
5329 SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
5330 SINGING_SONG_ID(creature_ptr) = 0;
5331 creature_ptr->update |= (PU_BONUS);
5332 creature_ptr->redraw |= (PR_STATUS);
5336 * @brief 口を使う継続的な処理を中断する
5337 * @param caster_ptr プレーヤーへの参照ポインタ
5340 void stop_mouth(player_type *caster_ptr)
5342 if (music_singing_any(caster_ptr)) stop_singing(caster_ptr);
5343 if (hex_spelling_any(caster_ptr)) stop_hex_spell_all(caster_ptr);
5348 * @brief ペットの維持コスト計算
5351 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
5354 bool have_a_unique = FALSE;
5355 DEPTH total_friend_levels = 0;
5359 for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
5361 monster_type *m_ptr;
5362 monster_race *r_ptr;
5364 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
5365 if (!monster_is_valid(m_ptr)) continue;
5366 r_ptr = &r_info[m_ptr->r_idx];
5371 if (r_ptr->flags1 & RF1_UNIQUE)
5373 if (creature_ptr->pclass == CLASS_CAVALRY)
5375 if (creature_ptr->riding == m_idx)
5376 total_friend_levels += (r_ptr->level + 5) * 2;
5377 else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
5378 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
5380 total_friend_levels += (r_ptr->level + 5) * 10;
5381 have_a_unique = TRUE;
5384 total_friend_levels += (r_ptr->level + 5) * 10;
5387 total_friend_levels += r_ptr->level;
5395 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
5396 if (upkeep_factor < 0) upkeep_factor = 0;
5397 if (upkeep_factor > 1000) upkeep_factor = 1000;
5398 return upkeep_factor;
5404 bool music_singing(player_type *caster_ptr, int music_songs)
5406 return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);