OSDN Git Service

Merge remote-tracking branch 'remotes/origin/For2.2.X-Add-Monster' into For2.2.2...
[hengband/hengband.git] / src / player-status.c
1 #include "angband.h"
2 #include "core.h"
3 #include "util.h"
4
5 #include "bldg.h"
6 #include "quest.h"
7 #include "player-move.h"
8 #include "player-status.h"
9 #include "player-effects.h"
10 #include "player-skill.h"
11 #include "player-race.h"
12 #include "player-class.h"
13 #include "player-personality.h"
14 #include "player-damage.h"
15 #include "floor.h"
16 #include "floor-events.h"
17 #include "feature.h"
18 #include "artifact.h"
19 #include "avatar.h"
20 #include "spells.h"
21 #include "spells-status.h"
22 #include "object.h"
23 #include "object-hook.h"
24 #include "object-ego.h"
25 #include "monster.h"
26 #include "monster-status.h"
27 #include "monsterrace-hook.h"
28 #include "mutation.h"
29 #include "patron.h"
30 #include "realm-hex.h"
31 #include "realm-song.h"
32 #include "cmd-pet.h"
33 #include "cmd-spell.h"
34 #include "dungeon.h"
35 #include "objectkind.h"
36 #include "monsterrace.h"
37 #include "autopick.h"
38 #include "cmd-dump.h"
39 #include "melee.h"
40 #include "world.h"
41 #include "view-mainwindow.h"
42 #include "files.h"
43 #include "cmd-magiceat.h"
44
45 /*!
46  * @brief 能力値テーブル / Abbreviations of healthy stats
47  */
48 const concptr stat_names[6] =
49 {
50 #ifdef JP
51         "腕力 :", "知能 :", "賢さ :", "器用 :", "耐久 :", "魅力 :"
52 #else
53         "STR : ", "INT : ", "WIS : ", "DEX : ", "CON : ", "CHR : "
54 #endif
55 };
56
57 /*!
58  * @brief 能力値テーブル(能力低下時) / Abbreviations of damaged stats
59  */
60 const concptr stat_names_reduced[6] =
61 {
62 #ifdef JP
63         "腕力x:", "知能x:", "賢さx:", "器用x:", "耐久x:", "魅力x:"
64 #else
65         "Str : ", "Int : ", "Wis : ", "Dex : ", "Con : ", "Chr : "
66 #endif
67 };
68
69 /* ELDRITCH_HORRORによるsanity blast処理に関するメッセージの最大数 / Number of entries in the sanity-blast descriptions */
70 #define MAX_SAN_HORROR 20 /*!< 恐ろしい対象の形容数(正常時) */
71 #define MAX_SAN_FUNNY 22  /*!< 恐ろしい対象の形容数(幻覚時) */
72 #define MAX_SAN_COMMENT 5 /*!< 恐ろしい対象を見たときの絶叫メッセージ数(幻覚時) */
73
74 /*!
75  * @var horror_desc
76  * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
77  */
78 static concptr horror_desc[MAX_SAN_HORROR] =
79 {
80 #ifdef JP
81         "忌まわしい",
82         "底知れぬ",
83         "ぞっとする",
84         "破滅的な",
85         "冒涜的な",
86
87         "いやな",
88         "恐ろしい",
89         "不潔な",
90         "容赦のない",
91         "おぞましい",
92
93         "地獄の",
94         "身の毛もよだつ",
95         "地獄の",
96         "忌まわしい",
97         "悪夢のような",
98
99         "嫌悪を感じる",
100         "罰当たりな",
101         "恐い",
102         "不浄な",
103         "言うもおぞましい",
104 #else
105         "abominable",
106         "abysmal",
107         "appalling",
108         "baleful",
109         "blasphemous",
110
111         "disgusting",
112         "dreadful",
113         "filthy",
114         "grisly",
115         "hideous",
116
117         "hellish",
118         "horrible",
119         "infernal",
120         "loathsome",
121         "nightmarish",
122
123         "repulsive",
124         "sacrilegious",
125         "terrible",
126         "unclean",
127         "unspeakable",
128 #endif
129 };
130
131 /*!
132  * @var funny_desc
133  * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
134  */
135 static concptr funny_desc[MAX_SAN_FUNNY] =
136 {
137 #ifdef JP
138         "間抜けな",
139         "滑稽な",
140         "ばからしい",
141         "無味乾燥な",
142         "馬鹿げた",
143
144         "笑える",
145         "ばかばかしい",
146         "ぶっとんだ",
147         "いかした",
148         "ポストモダンな",
149
150         "ファンタスティックな",
151         "ダダイズム的な",
152         "キュビズム的な",
153         "宇宙的な",
154         "卓越した",
155
156         "理解不能な",
157         "ものすごい",
158         "驚くべき",
159         "信じられない",
160         "カオティックな",
161
162         "野性的な",
163         "非常識な",
164 #else
165         "silly",
166         "hilarious",
167         "absurd",
168         "insipid",
169         "ridiculous",
170
171         "laughable",
172         "ludicrous",
173         "far-out",
174         "groovy",
175         "postmodern",
176
177         "fantastic",
178         "dadaistic",
179         "cubistic",
180         "cosmic",
181         "awesome",
182
183         "incomprehensible",
184         "fabulous",
185         "amazing",
186         "incredible",
187         "chaotic",
188
189         "wild",
190         "preposterous",
191 #endif
192 };
193
194 /*!
195  * @var funny_comments
196  * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
197  */
198 static concptr funny_comments[MAX_SAN_COMMENT] =
199 {
200 #ifdef JP
201           "最高だぜ!",
202           "うひょー!",
203           "いかすぜ!",
204           "すんばらしい!",
205           "ぶっとびー!"
206   #else
207           "Wow, cosmic, man!",
208           "Rad!",
209           "Groovy!",
210           "Cool!",
211           "Far out!"
212   #endif
213 };
214
215 /*!
216  * @brief 基本必要経験値テーブル /
217  * Base experience levels, may be adjusted up for race and/or class
218  */
219 const s32b player_exp[PY_MAX_LEVEL] =
220 {
221         10,
222         25,
223         45,
224         70,
225         100,
226         140,
227         200,
228         280,
229         380,/*10*/
230         500,
231         650,
232         850,
233         1100,
234         1400,
235         1800,
236         2300,
237         2900,
238         3600,
239         4400,/*20*/
240         5400,
241         6800,
242         8400,
243         10200,
244         12500,
245         17500,
246         25000,
247         35000L,
248         50000L,
249         75000L,/*30*/
250         100000L,
251         150000L,
252         200000L,
253         275000L,
254         350000L,
255         450000L,
256         550000L,
257         700000L,
258         850000L,
259         1000000L,/*40*/
260         1250000L,
261         1500000L,
262         1800000L,
263         2100000L,
264         2400000L,
265         2700000L,
266         3000000L,
267         3500000L,
268         4000000L,
269         4500000L,/*50*/
270         5000000L
271 };
272
273 /*!
274  * @brief 基本必要強化値テーブル(アンドロイド専用)
275  */
276 const s32b player_exp_a[PY_MAX_LEVEL] =
277 {
278         20,
279         50,
280         100,
281         170,
282         280,
283         430,
284         650,
285         950,
286         1400,/*10*/
287         1850,
288         2300,
289         2900,
290         3600,
291         4400,
292         5400,
293         6800,
294         8400,
295         10400,
296         12500,/*20*/
297         17500,
298         25000,
299         35000,
300         50000L,
301         75000L,
302         100000L,
303         150000L,
304         200000L,
305         275000L,
306         350000L,/*30*/
307         450000L,
308         550000L,
309         650000L,
310         800000L,
311         950000L,
312         1100000L,
313         1250000L,
314         1400000L,
315         1550000L,
316         1700000L,/*40*/
317         1900000L,
318         2100000L,
319         2300000L,
320         2550000L,
321         2800000L,
322         3050000L,
323         3300000L,
324         3700000L,
325         4100000L,
326         4500000L,/*50*/
327         5000000L
328 };
329
330 /*!
331  * 知力/賢さによるレベル毎の習得可能魔法数テーブル
332  * Stat Table (INT/WIS) -- Number of half-spells per level
333  */
334 const byte adj_mag_study[] =
335 {
336         0       /* 3 */,
337         0       /* 4 */,
338         0       /* 5 */,
339         0       /* 6 */,
340         0       /* 7 */,
341         1       /* 8 */,
342         1       /* 9 */,
343         1       /* 10 */,
344         1       /* 11 */,
345         2       /* 12 */,
346         2       /* 13 */,
347         2       /* 14 */,
348         2       /* 15 */,
349         2       /* 16 */,
350         2       /* 17 */,
351         2       /* 18/00-18/09 */,
352         2       /* 18/10-18/19 */,
353         2       /* 18/20-18/29 */,
354         2       /* 18/30-18/39 */,
355         2       /* 18/40-18/49 */,
356         3       /* 18/50-18/59 */,
357         3       /* 18/60-18/69 */,
358         3       /* 18/70-18/79 */,
359         3       /* 18/80-18/89 */,
360         4       /* 18/90-18/99 */,
361         4       /* 18/100-18/109 */,
362         4       /* 18/110-18/119 */,
363         5       /* 18/120-18/129 */,
364         5       /* 18/130-18/139 */,
365         5       /* 18/140-18/149 */,
366         5       /* 18/150-18/159 */,
367         5       /* 18/160-18/169 */,
368         5       /* 18/170-18/179 */,
369         5       /* 18/180-18/189 */,
370         5       /* 18/190-18/199 */,
371         5       /* 18/200-18/209 */,
372         6       /* 18/210-18/219 */,
373         6       /* 18/220+ */
374 };
375
376 /*!
377  * 知力/賢さによるMP修正テーブル
378  * Stat Table (INT/WIS) -- extra 1/4-mana-points per level
379  */
380 const byte adj_mag_mana[] =
381 {
382         0       /* 3 */,
383         0       /* 4 */,
384         0       /* 5 */,
385         0       /* 6 */,
386         0       /* 7 */,
387         1       /* 8 */,
388         2       /* 9 */,
389         3       /* 10 */,
390         4       /* 11 */,
391         5       /* 12 */,
392         5       /* 13 */,
393         6       /* 14 */,
394         7       /* 15 */,
395         8       /* 16 */,
396         9       /* 17 */,
397         10      /* 18/00-18/09 */,
398         11      /* 18/10-18/19 */,
399         11      /* 18/20-18/29 */,
400         12      /* 18/30-18/39 */,
401         12      /* 18/40-18/49 */,
402         13      /* 18/50-18/59 */,
403         14      /* 18/60-18/69 */,
404         15      /* 18/70-18/79 */,
405         16      /* 18/80-18/89 */,
406         17      /* 18/90-18/99 */,
407         18      /* 18/100-18/109 */,
408         19      /* 18/110-18/119 */,
409         20      /* 18/120-18/129 */,
410         21      /* 18/130-18/139 */,
411         22      /* 18/140-18/149 */,
412         23      /* 18/150-18/159 */,
413         24      /* 18/160-18/169 */,
414         25      /* 18/170-18/179 */,
415         26      /* 18/180-18/189 */,
416         27      /* 18/190-18/199 */,
417         28      /* 18/200-18/209 */,
418         29      /* 18/210-18/219 */,
419         30      /* 18/220+ */
420 };
421
422 /*!
423  * 知力/賢さによる最低魔法失敗率テーブル
424  * Stat Table (INT/WIS) -- Minimum failure rate (percentage)
425  */
426 const byte adj_mag_fail[] =
427 {
428         99      /* 3 */,
429         99      /* 4 */,
430         99      /* 5 */,
431         99      /* 6 */,
432         99      /* 7 */,
433         50      /* 8 */,
434         30      /* 9 */,
435         20      /* 10 */,
436         15      /* 11 */,
437         12      /* 12 */,
438         11      /* 13 */,
439         10      /* 14 */,
440         9       /* 15 */,
441         8       /* 16 */,
442         7       /* 17 */,
443         6       /* 18/00-18/09 */,
444         6       /* 18/10-18/19 */,
445         5       /* 18/20-18/29 */,
446         5       /* 18/30-18/39 */,
447         5       /* 18/40-18/49 */,
448         4       /* 18/50-18/59 */,
449         4       /* 18/60-18/69 */,
450         4       /* 18/70-18/79 */,
451         4       /* 18/80-18/89 */,
452         3       /* 18/90-18/99 */,
453         3       /* 18/100-18/109 */,
454         2       /* 18/110-18/119 */,
455         2       /* 18/120-18/129 */,
456         2       /* 18/130-18/139 */,
457         2       /* 18/140-18/149 */,
458         1       /* 18/150-18/159 */,
459         1       /* 18/160-18/169 */,
460         1       /* 18/170-18/179 */,
461         1       /* 18/180-18/189 */,
462         1       /* 18/190-18/199 */,
463         0       /* 18/200-18/209 */,
464         0       /* 18/210-18/219 */,
465         0       /* 18/220+ */
466 };
467
468 /*!
469  * 知力/賢さによる魔法失敗率修正テーブル
470  * Stat Table (INT/WIS) -- Various things
471  */
472 const byte adj_mag_stat[] =
473 {
474         0       /* 3 */,
475         0       /* 4 */,
476         0       /* 5 */,
477         0       /* 6 */,
478         0       /* 7 */,
479         1       /* 8 */,
480         1       /* 9 */,
481         1       /* 10 */,
482         1       /* 11 */,
483         1       /* 12 */,
484         1       /* 13 */,
485         1       /* 14 */,
486         2       /* 15 */,
487         2       /* 16 */,
488         2       /* 17 */,
489         3       /* 18/00-18/09 */,
490         3       /* 18/10-18/19 */,
491         3       /* 18/20-18/29 */,
492         3       /* 18/30-18/39 */,
493         3       /* 18/40-18/49 */,
494         4       /* 18/50-18/59 */,
495         4       /* 18/60-18/69 */,
496         5       /* 18/70-18/79 */,
497         6       /* 18/80-18/89 */,
498         7       /* 18/90-18/99 */,
499         8       /* 18/100-18/109 */,
500         9       /* 18/110-18/119 */,
501         10      /* 18/120-18/129 */,
502         11      /* 18/130-18/139 */,
503         12      /* 18/140-18/149 */,
504         13      /* 18/150-18/159 */,
505         14      /* 18/160-18/169 */,
506         15      /* 18/170-18/179 */,
507         16      /* 18/180-18/189 */,
508         17      /* 18/190-18/199 */,
509         18      /* 18/200-18/209 */,
510         19      /* 18/210-18/219 */,
511         20      /* 18/220+ */
512 };
513
514 /*!
515  * 魅力による店での取引修正テーブル
516  * Stat Table (CHR) -- payment percentages
517  */
518 const byte adj_chr_gold[] =
519 {
520         130     /* 3 */,
521         125     /* 4 */,
522         122     /* 5 */,
523         120     /* 6 */,
524         118     /* 7 */,
525         116     /* 8 */,
526         114     /* 9 */,
527         112     /* 10 */,
528         110     /* 11 */,
529         108     /* 12 */,
530         106     /* 13 */,
531         104     /* 14 */,
532         103     /* 15 */,
533         102     /* 16 */,
534         101     /* 17 */,
535         100     /* 18/00-18/09 */,
536         99      /* 18/10-18/19 */,
537         98      /* 18/20-18/29 */,
538         97      /* 18/30-18/39 */,
539         96      /* 18/40-18/49 */,
540         95      /* 18/50-18/59 */,
541         94      /* 18/60-18/69 */,
542         93      /* 18/70-18/79 */,
543         92      /* 18/80-18/89 */,
544         91      /* 18/90-18/99 */,
545         90      /* 18/100-18/109 */,
546         89      /* 18/110-18/119 */,
547         88      /* 18/120-18/129 */,
548         87      /* 18/130-18/139 */,
549         86      /* 18/140-18/149 */,
550         85      /* 18/150-18/159 */,
551         84      /* 18/160-18/169 */,
552         83      /* 18/170-18/179 */,
553         82      /* 18/180-18/189 */,
554         81      /* 18/190-18/199 */,
555         80      /* 18/200-18/209 */,
556         79      /* 18/210-18/219 */,
557         78      /* 18/220+ */
558 };
559
560 /*!
561  * 知力による魔道具使用修正テーブル
562  * Stat Table (INT) -- Magic devices
563  */
564 const byte adj_int_dev[] =
565 {
566         0       /* 3 */,
567         0       /* 4 */,
568         0       /* 5 */,
569         0       /* 6 */,
570         0       /* 7 */,
571         1       /* 8 */,
572         1       /* 9 */,
573         1       /* 10 */,
574         1       /* 11 */,
575         1       /* 12 */,
576         1       /* 13 */,
577         1       /* 14 */,
578         2       /* 15 */,
579         2       /* 16 */,
580         2       /* 17 */,
581         3       /* 18/00-18/09 */,
582         3       /* 18/10-18/19 */,
583         4       /* 18/20-18/29 */,
584         4       /* 18/30-18/39 */,
585         5       /* 18/40-18/49 */,
586         5       /* 18/50-18/59 */,
587         6       /* 18/60-18/69 */,
588         6       /* 18/70-18/79 */,
589         7       /* 18/80-18/89 */,
590         7       /* 18/90-18/99 */,
591         8       /* 18/100-18/109 */,
592         9       /* 18/110-18/119 */,
593         10      /* 18/120-18/129 */,
594         11      /* 18/130-18/139 */,
595         12      /* 18/140-18/149 */,
596         13      /* 18/150-18/159 */,
597         14      /* 18/160-18/169 */,
598         15      /* 18/170-18/179 */,
599         16      /* 18/180-18/189 */,
600         17      /* 18/190-18/199 */,
601         18      /* 18/200-18/209 */,
602         19      /* 18/210-18/219 */,
603         20      /* 18/220+ */
604 };
605
606 /*!
607  * 賢さによる魔法防御修正テーブル
608  * Stat Table (WIS) -- Saving throw
609  */
610 const byte adj_wis_sav[] =
611 {
612         0       /* 3 */,
613         0       /* 4 */,
614         0       /* 5 */,
615         0       /* 6 */,
616         0       /* 7 */,
617         1       /* 8 */,
618         1       /* 9 */,
619         1       /* 10 */,
620         1       /* 11 */,
621         1       /* 12 */,
622         1       /* 13 */,
623         1       /* 14 */,
624         2       /* 15 */,
625         2       /* 16 */,
626         2       /* 17 */,
627         3       /* 18/00-18/09 */,
628         3       /* 18/10-18/19 */,
629         3       /* 18/20-18/29 */,
630         3       /* 18/30-18/39 */,
631         3       /* 18/40-18/49 */,
632         4       /* 18/50-18/59 */,
633         4       /* 18/60-18/69 */,
634         5       /* 18/70-18/79 */,
635         5       /* 18/80-18/89 */,
636         6       /* 18/90-18/99 */,
637         7       /* 18/100-18/109 */,
638         8       /* 18/110-18/119 */,
639         9       /* 18/120-18/129 */,
640         10      /* 18/130-18/139 */,
641         11      /* 18/140-18/149 */,
642         12      /* 18/150-18/159 */,
643         13      /* 18/160-18/169 */,
644         14      /* 18/170-18/179 */,
645         15      /* 18/180-18/189 */,
646         16      /* 18/190-18/199 */,
647         17      /* 18/200-18/209 */,
648         18      /* 18/210-18/219 */,
649         19      /* 18/220+ */
650 };
651
652 /*!
653  * 器用さによるトラップ解除修正テーブル
654  * Stat Table (DEX) -- disarming
655  */
656 const byte adj_dex_dis[] =
657 {
658         0       /* 3 */,
659         0       /* 4 */,
660         0       /* 5 */,
661         0       /* 6 */,
662         0       /* 7 */,
663         0       /* 8 */,
664         0       /* 9 */,
665         0       /* 10 */,
666         0       /* 11 */,
667         0       /* 12 */,
668         1       /* 13 */,
669         1       /* 14 */,
670         1       /* 15 */,
671         2       /* 16 */,
672         2       /* 17 */,
673         4       /* 18/00-18/09 */,
674         4       /* 18/10-18/19 */,
675         4       /* 18/20-18/29 */,
676         4       /* 18/30-18/39 */,
677         5       /* 18/40-18/49 */,
678         5       /* 18/50-18/59 */,
679         5       /* 18/60-18/69 */,
680         6       /* 18/70-18/79 */,
681         6       /* 18/80-18/89 */,
682         7       /* 18/90-18/99 */,
683         8       /* 18/100-18/109 */,
684         8       /* 18/110-18/119 */,
685         8       /* 18/120-18/129 */,
686         8       /* 18/130-18/139 */,
687         8       /* 18/140-18/149 */,
688         9       /* 18/150-18/159 */,
689         9       /* 18/160-18/169 */,
690         9       /* 18/170-18/179 */,
691         9       /* 18/180-18/189 */,
692         9       /* 18/190-18/199 */,
693         10      /* 18/200-18/209 */,
694         10      /* 18/210-18/219 */,
695         10      /* 18/220+ */
696 };
697
698 /*!
699  * 知力によるトラップ解除修正テーブル
700  * Stat Table (INT) -- disarming
701  */
702 const byte adj_int_dis[] =
703 {
704         0       /* 3 */,
705         0       /* 4 */,
706         0       /* 5 */,
707         0       /* 6 */,
708         0       /* 7 */,
709         1       /* 8 */,
710         1       /* 9 */,
711         1       /* 10 */,
712         1       /* 11 */,
713         1       /* 12 */,
714         1       /* 13 */,
715         1       /* 14 */,
716         2       /* 15 */,
717         2       /* 16 */,
718         2       /* 17 */,
719         3       /* 18/00-18/09 */,
720         3       /* 18/10-18/19 */,
721         3       /* 18/20-18/29 */,
722         4       /* 18/30-18/39 */,
723         4       /* 18/40-18/49 */,
724         5       /* 18/50-18/59 */,
725         6       /* 18/60-18/69 */,
726         7       /* 18/70-18/79 */,
727         8       /* 18/80-18/89 */,
728         9       /* 18/90-18/99 */,
729         10      /* 18/100-18/109 */,
730         10      /* 18/110-18/119 */,
731         11      /* 18/120-18/129 */,
732         12      /* 18/130-18/139 */,
733         13      /* 18/140-18/149 */,
734         14      /* 18/150-18/159 */,
735         15      /* 18/160-18/169 */,
736         16      /* 18/170-18/179 */,
737         17      /* 18/180-18/189 */,
738         18      /* 18/190-18/199 */,
739         19      /* 18/200-18/209 */,
740         19      /* 18/210-18/219 */,
741         20      /* 18/220+ */
742 };
743
744 /*!
745  * 器用さによるAC修正テーブル
746  * Stat Table (DEX) -- bonus to ac (plus 128)
747  */
748 const byte adj_dex_ta[] =
749 {
750         128 + -4    /*  3 */,
751         128 + -3    /*  4 */,
752         128 + -2    /*  5 */,
753         128 + -1    /*  6 */,
754         128 + 0     /*  7 */,
755         128 + 0     /*  8 */,
756         128 + 0     /*  9 */,
757         128 + 0     /* 10 */,
758         128 + 0     /* 11 */,
759         128 + 0     /* 12 */,
760         128 + 0     /* 13 */,
761         128 + 0     /* 14 */,
762         128 + 1     /* 15 */,
763         128 + 1     /* 16 */,
764         128 + 1     /* 17 */,
765         128 + 2     /* 18/00-18/09 */,
766         128 + 2     /* 18/10-18/19 */,
767         128 + 2     /* 18/20-18/29 */,
768         128 + 2     /* 18/30-18/39 */,
769         128 + 2     /* 18/40-18/49 */,
770         128 + 3     /* 18/50-18/59 */,
771         128 + 3     /* 18/60-18/69 */,
772         128 + 3     /* 18/70-18/79 */,
773         128 + 4     /* 18/80-18/89 */,
774         128 + 5     /* 18/90-18/99 */,
775         128 + 6     /* 18/100-18/109 */,
776         128 + 7     /* 18/110-18/119 */,
777         128 + 8     /* 18/120-18/129 */,
778         128 + 9     /* 18/130-18/139 */,
779         128 + 9     /* 18/140-18/149 */,
780         128 + 10    /* 18/150-18/159 */,
781         128 + 11    /* 18/160-18/169 */,
782         128 + 12    /* 18/170-18/179 */,
783         128 + 13    /* 18/180-18/189 */,
784         128 + 14    /* 18/190-18/199 */,
785         128 + 15    /* 18/200-18/209 */,
786         128 + 15    /* 18/210-18/219 */,
787         128 + 16    /* 18/220+ */
788 };
789
790 /*!
791  * 腕力によるダメージ修正テーブル
792  * Stat Table (STR) -- bonus to dam (plus 128)
793  */
794 const byte adj_str_td[] =
795 {
796         128 + -2    /*  3 */,
797         128 + -2    /*  4 */,
798         128 + -1    /*  5 */,
799         128 + -1    /*  6 */,
800         128 + 0     /*  7 */,
801         128 + 0     /*  8 */,
802         128 + 0     /*  9 */,
803         128 + 0     /* 10 */,
804         128 + 0     /* 11 */,
805         128 + 0     /* 12 */,
806         128 + 0     /* 13 */,
807         128 + 0     /* 14 */,
808         128 + 0     /* 15 */,
809         128 + 1     /* 16 */,
810         128 + 2     /* 17 */,
811         128 + 2     /* 18/00-18/09 */,
812         128 + 2     /* 18/10-18/19 */,
813         128 + 3     /* 18/20-18/29 */,
814         128 + 3     /* 18/30-18/39 */,
815         128 + 3     /* 18/40-18/49 */,
816         128 + 3     /* 18/50-18/59 */,
817         128 + 3     /* 18/60-18/69 */,
818         128 + 4     /* 18/70-18/79 */,
819         128 + 5     /* 18/80-18/89 */,
820         128 + 5     /* 18/90-18/99 */,
821         128 + 6     /* 18/100-18/109 */,
822         128 + 7     /* 18/110-18/119 */,
823         128 + 8     /* 18/120-18/129 */,
824         128 + 9     /* 18/130-18/139 */,
825         128 + 10    /* 18/140-18/149 */,
826         128 + 11    /* 18/150-18/159 */,
827         128 + 12    /* 18/160-18/169 */,
828         128 + 13    /* 18/170-18/179 */,
829         128 + 14    /* 18/180-18/189 */,
830         128 + 15    /* 18/190-18/199 */,
831         128 + 16    /* 18/200-18/209 */,
832         128 + 18    /* 18/210-18/219 */,
833         128 + 20    /* 18/220+ */
834 };
835
836 /*!
837  * 器用度による命中修正テーブル
838  * Stat Table (DEX) -- bonus to hit (plus 128)
839  */
840 const byte adj_dex_th[] =
841 {
842         128 + -3        /* 3 */,
843         128 + -2        /* 4 */,
844         128 + -2        /* 5 */,
845         128 + -1        /* 6 */,
846         128 + -1        /* 7 */,
847         128 + 0 /* 8 */,
848         128 + 0 /* 9 */,
849         128 + 0 /* 10 */,
850         128 + 0 /* 11 */,
851         128 + 0 /* 12 */,
852         128 + 0 /* 13 */,
853         128 + 0 /* 14 */,
854         128 + 0 /* 15 */,
855         128 + 1 /* 16 */,
856         128 + 2 /* 17 */,
857         128 + 3 /* 18/00-18/09 */,
858         128 + 3 /* 18/10-18/19 */,
859         128 + 3 /* 18/20-18/29 */,
860         128 + 3 /* 18/30-18/39 */,
861         128 + 3 /* 18/40-18/49 */,
862         128 + 4 /* 18/50-18/59 */,
863         128 + 4 /* 18/60-18/69 */,
864         128 + 4 /* 18/70-18/79 */,
865         128 + 4 /* 18/80-18/89 */,
866         128 + 5 /* 18/90-18/99 */,
867         128 + 6 /* 18/100-18/109 */,
868         128 + 7 /* 18/110-18/119 */,
869         128 + 8 /* 18/120-18/129 */,
870         128 + 9 /* 18/130-18/139 */,
871         128 + 9 /* 18/140-18/149 */,
872         128 + 10        /* 18/150-18/159 */,
873         128 + 11        /* 18/160-18/169 */,
874         128 + 12        /* 18/170-18/179 */,
875         128 + 13        /* 18/180-18/189 */,
876         128 + 14        /* 18/190-18/199 */,
877         128 + 15        /* 18/200-18/209 */,
878         128 + 15        /* 18/210-18/219 */,
879         128 + 16        /* 18/220+ */
880 };
881
882 /*!
883  * 腕力による命中修正テーブル
884  * Stat Table (STR) -- bonus to hit (plus 128)
885  */
886 const byte adj_str_th[] =
887 {
888         128 + -3        /* 3 */,
889         128 + -2        /* 4 */,
890         128 + -1        /* 5 */,
891         128 + -1        /* 6 */,
892         128 + 0 /* 7 */,
893         128 + 0 /* 8 */,
894         128 + 0 /* 9 */,
895         128 + 0 /* 10 */,
896         128 + 0 /* 11 */,
897         128 + 0 /* 12 */,
898         128 + 0 /* 13 */,
899         128 + 0 /* 14 */,
900         128 + 0 /* 15 */,
901         128 + 0 /* 16 */,
902         128 + 0 /* 17 */,
903         128 + 1 /* 18/00-18/09 */,
904         128 + 1 /* 18/10-18/19 */,
905         128 + 1 /* 18/20-18/29 */,
906         128 + 1 /* 18/30-18/39 */,
907         128 + 1 /* 18/40-18/49 */,
908         128 + 1 /* 18/50-18/59 */,
909         128 + 1 /* 18/60-18/69 */,
910         128 + 2 /* 18/70-18/79 */,
911         128 + 3 /* 18/80-18/89 */,
912         128 + 4 /* 18/90-18/99 */,
913         128 + 5 /* 18/100-18/109 */,
914         128 + 6 /* 18/110-18/119 */,
915         128 + 7 /* 18/120-18/129 */,
916         128 + 8 /* 18/130-18/139 */,
917         128 + 9 /* 18/140-18/149 */,
918         128 + 10        /* 18/150-18/159 */,
919         128 + 11        /* 18/160-18/169 */,
920         128 + 12        /* 18/170-18/179 */,
921         128 + 13        /* 18/180-18/189 */,
922         128 + 14        /* 18/190-18/199 */,
923         128 + 15        /* 18/200-18/209 */,
924         128 + 15        /* 18/210-18/219 */,
925         128 + 16        /* 18/220+ */
926 };
927
928 /*!
929  * 腕力による基本所持重量値テーブル
930  * Stat Table (STR) -- weight limit in deca-pounds
931  */
932 const byte adj_str_wgt[] =
933 {
934         10      /* 3 */,
935         11      /* 4 */,
936         12      /* 5 */,
937         13      /* 6 */,
938         14      /* 7 */,
939         15      /* 8 */,
940         16      /* 9 */,
941         17      /* 10 */,
942         18      /* 11 */,
943         19      /* 12 */,
944         20      /* 13 */,
945         21      /* 14 */,
946         22      /* 15 */,
947         23      /* 16 */,
948         24      /* 17 */,
949         25      /* 18/00-18/09 */,
950         26      /* 18/10-18/19 */,
951         27      /* 18/20-18/29 */,
952         28      /* 18/30-18/39 */,
953         29      /* 18/40-18/49 */,
954         30      /* 18/50-18/59 */,
955         31      /* 18/60-18/69 */,
956         31      /* 18/70-18/79 */,
957         32      /* 18/80-18/89 */,
958         32      /* 18/90-18/99 */,
959         33      /* 18/100-18/109 */,
960         33      /* 18/110-18/119 */,
961         34      /* 18/120-18/129 */,
962         34      /* 18/130-18/139 */,
963         35      /* 18/140-18/149 */,
964         35      /* 18/150-18/159 */,
965         36      /* 18/160-18/169 */,
966         36      /* 18/170-18/179 */,
967         37      /* 18/180-18/189 */,
968         37      /* 18/190-18/199 */,
969         38      /* 18/200-18/209 */,
970         38      /* 18/210-18/219 */,
971         39      /* 18/220+ */
972 };
973
974 /*!
975  * 腕力による武器重量限界値テーブル
976  * Stat Table (STR) -- weapon weight limit in pounds
977  */
978 const byte adj_str_hold[] =
979 {
980         4       /* 3 */,
981         5       /* 4 */,
982         6       /* 5 */,
983         7       /* 6 */,
984         8       /* 7 */,
985         9       /* 8 */,
986         10      /* 9 */,
987         11      /* 10 */,
988         12      /* 11 */,
989         13      /* 12 */,
990         14      /* 13 */,
991         15      /* 14 */,
992         16      /* 15 */,
993         17      /* 16 */,
994         18      /* 17 */,
995         19      /* 18/00-18/09 */,
996         20      /* 18/10-18/19 */,
997         21      /* 18/20-18/29 */,
998         22      /* 18/30-18/39 */,
999         23      /* 18/40-18/49 */,
1000         24      /* 18/50-18/59 */,
1001         25      /* 18/60-18/69 */,
1002         26      /* 18/70-18/79 */,
1003         27      /* 18/80-18/89 */,
1004         28      /* 18/90-18/99 */,
1005         30      /* 18/100-18/109 */,
1006         31      /* 18/110-18/119 */,
1007         32      /* 18/120-18/129 */,
1008         33      /* 18/130-18/139 */,
1009         34      /* 18/140-18/149 */,
1010         35      /* 18/150-18/159 */,
1011         37      /* 18/160-18/169 */,
1012         40      /* 18/170-18/179 */,
1013         44      /* 18/180-18/189 */,
1014         48      /* 18/190-18/199 */,
1015         50     /* 18/200-18/209 */,
1016         50     /* 18/210-18/219 */,
1017         50     /* 18/220+ */
1018 };
1019
1020 /*!
1021  * 腕力による採掘能力修正値テーブル
1022  * Stat Table (STR) -- digging value
1023  */
1024 const byte adj_str_dig[] =
1025 {
1026         0       /* 3 */,
1027         0       /* 4 */,
1028         1       /* 5 */,
1029         2       /* 6 */,
1030         3       /* 7 */,
1031         4       /* 8 */,
1032         4       /* 9 */,
1033         5       /* 10 */,
1034         5       /* 11 */,
1035         6       /* 12 */,
1036         6       /* 13 */,
1037         7       /* 14 */,
1038         7       /* 15 */,
1039         8       /* 16 */,
1040         8       /* 17 */,
1041         9       /* 18/00-18/09 */,
1042         10      /* 18/10-18/19 */,
1043         12      /* 18/20-18/29 */,
1044         15      /* 18/30-18/39 */,
1045         20      /* 18/40-18/49 */,
1046         25      /* 18/50-18/59 */,
1047         30      /* 18/60-18/69 */,
1048         35      /* 18/70-18/79 */,
1049         40      /* 18/80-18/89 */,
1050         45      /* 18/90-18/99 */,
1051         50      /* 18/100-18/109 */,
1052         55      /* 18/110-18/119 */,
1053         60      /* 18/120-18/129 */,
1054         65      /* 18/130-18/139 */,
1055         70      /* 18/140-18/149 */,
1056         75      /* 18/150-18/159 */,
1057         80      /* 18/160-18/169 */,
1058         85      /* 18/170-18/179 */,
1059         90      /* 18/180-18/189 */,
1060         95      /* 18/190-18/199 */,
1061         100     /* 18/200-18/209 */,
1062         100     /* 18/210-18/219 */,
1063         100     /* 18/220+ */
1064 };
1065
1066 /*!
1067  * 器用さによる盗難防止&体当たり成功判定修正テーブル
1068  * Stat Table (DEX) -- chance of avoiding "theft" and "falling"
1069  */
1070 const byte adj_dex_safe[] =
1071 {
1072         0       /* 3 */,
1073         1       /* 4 */,
1074         2       /* 5 */,
1075         3       /* 6 */,
1076         4       /* 7 */,
1077         5       /* 8 */,
1078         5       /* 9 */,
1079         6       /* 10 */,
1080         6       /* 11 */,
1081         7       /* 12 */,
1082         7       /* 13 */,
1083         8       /* 14 */,
1084         8       /* 15 */,
1085         9       /* 16 */,
1086         9       /* 17 */,
1087         10      /* 18/00-18/09 */,
1088         10      /* 18/10-18/19 */,
1089         15      /* 18/20-18/29 */,
1090         15      /* 18/30-18/39 */,
1091         20      /* 18/40-18/49 */,
1092         25      /* 18/50-18/59 */,
1093         30      /* 18/60-18/69 */,
1094         35      /* 18/70-18/79 */,
1095         40      /* 18/80-18/89 */,
1096         45      /* 18/90-18/99 */,
1097         50      /* 18/100-18/109 */,
1098         60      /* 18/110-18/119 */,
1099         70      /* 18/120-18/129 */,
1100         80      /* 18/130-18/139 */,
1101         90      /* 18/140-18/149 */,
1102         100     /* 18/150-18/159 */,
1103         100     /* 18/160-18/169 */,
1104         100     /* 18/170-18/179 */,
1105         100     /* 18/180-18/189 */,
1106         100     /* 18/190-18/199 */,
1107         100     /* 18/200-18/209 */,
1108         100     /* 18/210-18/219 */,
1109         100     /* 18/220+ */
1110 };
1111
1112 /*!
1113  * 耐久による基本HP自然治癒値テーブル /
1114  * Stat Table (CON) -- base regeneration rate
1115  */
1116 const byte adj_con_fix[] =
1117 {
1118         0       /* 3 */,
1119         0       /* 4 */,
1120         0       /* 5 */,
1121         0       /* 6 */,
1122         0       /* 7 */,
1123         0       /* 8 */,
1124         0       /* 9 */,
1125         0       /* 10 */,
1126         0       /* 11 */,
1127         0       /* 12 */,
1128         0       /* 13 */,
1129         1       /* 14 */,
1130         1       /* 15 */,
1131         1       /* 16 */,
1132         1       /* 17 */,
1133         2       /* 18/00-18/09 */,
1134         2       /* 18/10-18/19 */,
1135         2       /* 18/20-18/29 */,
1136         2       /* 18/30-18/39 */,
1137         2       /* 18/40-18/49 */,
1138         3       /* 18/50-18/59 */,
1139         3       /* 18/60-18/69 */,
1140         3       /* 18/70-18/79 */,
1141         3       /* 18/80-18/89 */,
1142         3       /* 18/90-18/99 */,
1143         4       /* 18/100-18/109 */,
1144         4       /* 18/110-18/119 */,
1145         5       /* 18/120-18/129 */,
1146         6       /* 18/130-18/139 */,
1147         6       /* 18/140-18/149 */,
1148         7       /* 18/150-18/159 */,
1149         7       /* 18/160-18/169 */,
1150         8       /* 18/170-18/179 */,
1151         8       /* 18/180-18/189 */,
1152         8       /* 18/190-18/199 */,
1153         9       /* 18/200-18/209 */,
1154         9       /* 18/210-18/219 */,
1155         9       /* 18/220+ */
1156 };
1157
1158 /*!
1159  * 耐久による基本HP自然治癒値テーブル /
1160  * Stat Table (CON) -- extra 1/4-hitpoints per level (plus 128)
1161  */
1162 const byte adj_con_mhp[] =
1163 {
1164         128 + -8        /* 3 */,
1165         128 + -6        /* 4 */,
1166         128 + -4        /* 5 */,
1167         128 + -2        /* 6 */,
1168         128 + -1 /* 7 */,
1169         128 + 0 /* 8 */,
1170         128 + 0 /* 9 */,
1171         128 + 0 /* 10 */,
1172         128 + 0 /* 11 */,
1173         128 + 0 /* 12 */,
1174         128 + 0 /* 13 */,
1175         128 + 1 /* 14 */,
1176         128 + 1 /* 15 */,
1177         128 + 2 /* 16 */,
1178         128 + 3 /* 17 */,
1179         128 + 4 /* 18/00-18/09 */,
1180         128 + 5 /* 18/10-18/19 */,
1181         128 + 6 /* 18/20-18/29 */,
1182         128 + 7 /* 18/30-18/39 */,
1183         128 + 8 /* 18/40-18/49 */,
1184         128 + 9 /* 18/50-18/59 */,
1185         128 + 10  /* 18/60-18/69 */,
1186         128 + 11 /* 18/70-18/79 */,
1187         128 + 12 /* 18/80-18/89 */,
1188         128 + 14 /* 18/90-18/99 */,
1189         128 + 17         /* 18/100-18/109 */,
1190         128 + 20        /* 18/110-18/119 */,
1191         128 + 23        /* 18/120-18/129 */,
1192         128 + 26        /* 18/130-18/139 */,
1193         128 + 29        /* 18/140-18/149 */,
1194         128 + 32        /* 18/150-18/159 */,
1195         128 + 35        /* 18/160-18/169 */,
1196         128 + 38        /* 18/170-18/179 */,
1197         128 + 40        /* 18/180-18/189 */,
1198         128 + 42        /* 18/190-18/199 */,
1199         128 + 44        /* 18/200-18/209 */,
1200         128 + 46        /* 18/210-18/219 */,
1201         128 + 48        /* 18/220+ */
1202 };
1203
1204 /*!
1205  * 魅力による魅了能力修正テーブル /
1206  * Stat Table (CHR) -- charm
1207  */
1208 const byte adj_chr_chm[] =
1209 {
1210         0       /* 3 */,
1211         0       /* 4 */,
1212         1       /* 5 */,
1213         2       /* 6 */,
1214         3       /* 7 */,
1215         4       /* 8 */,
1216         4       /* 9 */,
1217         5       /* 10 */,
1218         5       /* 11 */,
1219         6       /* 12 */,
1220         6       /* 13 */,
1221         7       /* 14 */,
1222         7       /* 15 */,
1223         8       /* 16 */,
1224         8       /* 17 */,
1225         9       /* 18/00-18/09 */,
1226         10      /* 18/10-18/19 */,
1227         12      /* 18/20-18/29 */,
1228         15      /* 18/30-18/39 */,
1229         18      /* 18/40-18/49 */,
1230         21      /* 18/50-18/59 */,
1231         24      /* 18/60-18/69 */,
1232         28      /* 18/70-18/79 */,
1233         32      /* 18/80-18/89 */,
1234         36      /* 18/90-18/99 */,
1235         39      /* 18/100-18/109 */,
1236         42      /* 18/110-18/119 */,
1237         45      /* 18/120-18/129 */,
1238         49      /* 18/130-18/139 */,
1239         53      /* 18/140-18/149 */,
1240         57      /* 18/150-18/159 */,
1241         61      /* 18/160-18/169 */,
1242         65      /* 18/170-18/179 */,
1243         69      /* 18/180-18/189 */,
1244         73      /* 18/190-18/199 */,
1245         77      /* 18/200-18/209 */,
1246         81      /* 18/210-18/219 */,
1247         85      /* 18/220+ */
1248 };
1249
1250 /*** Player information ***/
1251
1252 /*
1253  * Static player info record
1254  */
1255 player_type p_body;
1256
1257 /*
1258  * Pointer to the player info
1259  */
1260 player_type *p_ptr = &p_body;
1261
1262 /*
1263  * Return alignment title
1264  */
1265 concptr your_alignment(player_type *creature_ptr)
1266 {
1267         if (creature_ptr->align > 150) return _("大善", "Lawful");
1268         else if (creature_ptr->align > 50) return _("中善", "Good");
1269         else if (creature_ptr->align > 10) return _("小善", "Neutral Good");
1270         else if (creature_ptr->align > -11) return _("中立", "Neutral");
1271         else if (creature_ptr->align > -51) return _("小悪", "Neutral Evil");
1272         else if (creature_ptr->align > -151) return _("中悪", "Evil");
1273         else return _("大悪", "Chaotic");
1274 }
1275
1276
1277 /*
1278  * Return proficiency level of weapons and misc. skills (except riding)
1279  */
1280 int weapon_exp_level(int weapon_exp)
1281 {
1282         if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1283         else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1284         else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1285         else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
1286         else return EXP_LEVEL_MASTER;
1287 }
1288
1289
1290 /*
1291  * Return proficiency level of riding
1292  */
1293 int riding_exp_level(int riding_exp)
1294 {
1295         if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1296         else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1297         else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1298         else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
1299         else return EXP_LEVEL_MASTER;
1300 }
1301
1302
1303 /*
1304  * Return proficiency level of spells
1305  */
1306 int spell_exp_level(int spell_exp)
1307 {
1308         if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
1309         else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
1310         else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
1311         else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
1312         else return EXP_LEVEL_MASTER;
1313 }
1314
1315
1316 /*!
1317  * @brief プレイヤーの全ステータスを更新する /
1318  * Calculate the players current "state", taking into account
1319  * not only race/class intrinsics, but also objects being worn
1320  * and temporary spell effects.
1321  * @return なし
1322  * @details
1323  * <pre>
1324  * See also calc_mana() and calc_hitpoints().
1325  *
1326  * Take note of the new "speed code", in particular, a very strong
1327  * player will start slowing down as soon as he reaches 150 pounds,
1328  * but not until he reaches 450 pounds will he be half as fast as
1329  * a normal kobold.  This both hurts and helps the player, hurts
1330  * because in the old days a player could just avoid 300 pounds,
1331  * and helps because now carrying 300 pounds is not very painful.
1332  *
1333  * The "weapon" and "bow" do *not* add to the bonuses to hit or to
1334  * damage, since that would affect non-combat things.  These values
1335  * are actually added in later, at the appropriate place.
1336  *
1337  * This function induces various "status" messages.
1338  * </pre>
1339  */
1340 void calc_bonuses(player_type *creature_ptr)
1341 {
1342         int hold;
1343         int new_speed;
1344         int default_hand = 0;
1345         int empty_hands_status = empty_hands(creature_ptr, TRUE);
1346         int extra_blows[2];
1347         object_type *o_ptr;
1348         BIT_FLAGS flgs[TR_FLAG_SIZE];
1349         bool omoi = FALSE;
1350         bool yoiyami = FALSE;
1351         bool down_saving = FALSE;
1352
1353         bool have_sw = FALSE, have_kabe = FALSE;
1354         bool easy_2weapon = FALSE;
1355         bool riding_levitation = FALSE;
1356         OBJECT_IDX this_o_idx, next_o_idx = 0;
1357         const player_race *tmp_rp_ptr;
1358
1359         /* Save the old vision stuff */
1360         bool old_telepathy = creature_ptr->telepathy;
1361         bool old_esp_animal = creature_ptr->esp_animal;
1362         bool old_esp_undead = creature_ptr->esp_undead;
1363         bool old_esp_demon = creature_ptr->esp_demon;
1364         bool old_esp_orc = creature_ptr->esp_orc;
1365         bool old_esp_troll = creature_ptr->esp_troll;
1366         bool old_esp_giant = creature_ptr->esp_giant;
1367         bool old_esp_dragon = creature_ptr->esp_dragon;
1368         bool old_esp_human = creature_ptr->esp_human;
1369         bool old_esp_evil = creature_ptr->esp_evil;
1370         bool old_esp_good = creature_ptr->esp_good;
1371         bool old_esp_nonliving = creature_ptr->esp_nonliving;
1372         bool old_esp_unique = creature_ptr->esp_unique;
1373         bool old_see_inv = creature_ptr->see_inv;
1374         bool old_mighty_throw = creature_ptr->mighty_throw;
1375
1376         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
1377         feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
1378
1379         ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
1380         ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
1381
1382         extra_blows[0] = extra_blows[1] = 0;
1383
1384         for (int i = 0; i < A_MAX; i++) creature_ptr->stat_add[i] = 0;
1385
1386         creature_ptr->dis_ac = creature_ptr->ac = 0;
1387         creature_ptr->dis_to_h[0] = creature_ptr->to_h[0] = 0;
1388         creature_ptr->dis_to_h[1] = creature_ptr->to_h[1] = 0;
1389         creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0;
1390         creature_ptr->dis_to_d[1] = creature_ptr->to_d[1] = 0;
1391         creature_ptr->dis_to_h_b = creature_ptr->to_h_b = 0;
1392         creature_ptr->dis_to_a = creature_ptr->to_a = 0;
1393         creature_ptr->to_h_m = 0;
1394         creature_ptr->to_d_m = 0;
1395         creature_ptr->to_m_chance = 0;
1396         creature_ptr->to_dd[0] = creature_ptr->to_ds[0] = 0;
1397         creature_ptr->to_dd[1] = creature_ptr->to_ds[1] = 0;
1398
1399         new_speed = 110;
1400         creature_ptr->num_blow[0] = 1;
1401         creature_ptr->num_blow[1] = 1;
1402         creature_ptr->num_fire = 100;
1403         creature_ptr->tval_xtra = 0;
1404         creature_ptr->tval_ammo = 0;
1405         creature_ptr->cursed = 0L;
1406         creature_ptr->bless_blade = FALSE;
1407         creature_ptr->xtra_might = FALSE;
1408         creature_ptr->impact[0] = FALSE;
1409         creature_ptr->impact[1] = FALSE;
1410         creature_ptr->pass_wall = FALSE;
1411         creature_ptr->kill_wall = FALSE;
1412         creature_ptr->dec_mana = FALSE;
1413         creature_ptr->easy_spell = FALSE;
1414         creature_ptr->heavy_spell = FALSE;
1415         creature_ptr->see_inv = FALSE;
1416         creature_ptr->free_act = FALSE;
1417         creature_ptr->slow_digest = FALSE;
1418         creature_ptr->regenerate = FALSE;
1419         creature_ptr->can_swim = FALSE;
1420         creature_ptr->levitation = FALSE;
1421         creature_ptr->hold_exp = FALSE;
1422         creature_ptr->telepathy = FALSE;
1423         creature_ptr->esp_animal = FALSE;
1424         creature_ptr->esp_undead = FALSE;
1425         creature_ptr->esp_demon = FALSE;
1426         creature_ptr->esp_orc = FALSE;
1427         creature_ptr->esp_troll = FALSE;
1428         creature_ptr->esp_giant = FALSE;
1429         creature_ptr->esp_dragon = FALSE;
1430         creature_ptr->esp_human = FALSE;
1431         creature_ptr->esp_evil = FALSE;
1432         creature_ptr->esp_good = FALSE;
1433         creature_ptr->esp_nonliving = FALSE;
1434         creature_ptr->esp_unique = FALSE;
1435         creature_ptr->lite = FALSE;
1436         creature_ptr->sustain_str = FALSE;
1437         creature_ptr->sustain_int = FALSE;
1438         creature_ptr->sustain_wis = FALSE;
1439         creature_ptr->sustain_con = FALSE;
1440         creature_ptr->sustain_dex = FALSE;
1441         creature_ptr->sustain_chr = FALSE;
1442         creature_ptr->resist_acid = FALSE;
1443         creature_ptr->resist_elec = FALSE;
1444         creature_ptr->resist_fire = FALSE;
1445         creature_ptr->resist_cold = FALSE;
1446         creature_ptr->resist_pois = FALSE;
1447         creature_ptr->resist_conf = FALSE;
1448         creature_ptr->resist_sound = FALSE;
1449         creature_ptr->resist_lite = FALSE;
1450         creature_ptr->resist_dark = FALSE;
1451         creature_ptr->resist_chaos = FALSE;
1452         creature_ptr->resist_disen = FALSE;
1453         creature_ptr->resist_shard = FALSE;
1454         creature_ptr->resist_nexus = FALSE;
1455         creature_ptr->resist_blind = FALSE;
1456         creature_ptr->resist_neth = FALSE;
1457         creature_ptr->resist_time = FALSE;
1458         creature_ptr->resist_water = FALSE;
1459         creature_ptr->resist_fear = FALSE;
1460         creature_ptr->reflect = FALSE;
1461         creature_ptr->sh_fire = FALSE;
1462         creature_ptr->sh_elec = FALSE;
1463         creature_ptr->sh_cold = FALSE;
1464         creature_ptr->anti_magic = FALSE;
1465         creature_ptr->anti_tele = FALSE;
1466         creature_ptr->warning = FALSE;
1467         creature_ptr->mighty_throw = FALSE;
1468         creature_ptr->see_nocto = FALSE;
1469         creature_ptr->immune_acid = FALSE;
1470         creature_ptr->immune_elec = FALSE;
1471         creature_ptr->immune_fire = FALSE;
1472         creature_ptr->immune_cold = FALSE;
1473         creature_ptr->ryoute = FALSE;
1474         creature_ptr->migite = FALSE;
1475         creature_ptr->hidarite = FALSE;
1476         creature_ptr->no_flowed = FALSE;
1477
1478         if (creature_ptr->mimic_form) tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
1479         else tmp_rp_ptr = &race_info[creature_ptr->prace];
1480
1481         creature_ptr->see_infra = tmp_rp_ptr->infra;
1482         creature_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
1483         creature_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
1484         creature_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
1485         creature_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
1486         creature_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
1487         creature_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
1488         creature_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
1489         creature_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
1490         creature_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
1491         creature_ptr->skill_dig = 0;
1492
1493         if (has_melee_weapon(creature_ptr, INVEN_RARM)) creature_ptr->migite = TRUE;
1494         if (has_melee_weapon(creature_ptr, INVEN_LARM))
1495         {
1496                 creature_ptr->hidarite = TRUE;
1497                 if (!creature_ptr->migite) default_hand = 1;
1498         }
1499
1500         if (can_two_hands_wielding(creature_ptr))
1501         {
1502                 if (creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) &&
1503                         object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM]))
1504                 {
1505                         creature_ptr->ryoute = TRUE;
1506                 }
1507                 else if (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) &&
1508                         object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM]))
1509                 {
1510                         creature_ptr->ryoute = TRUE;
1511                 }
1512                 else
1513                 {
1514                         switch (creature_ptr->pclass)
1515                         {
1516                         case CLASS_MONK:
1517                         case CLASS_FORCETRAINER:
1518                         case CLASS_BERSERKER:
1519                                 if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
1520                                 {
1521                                         creature_ptr->migite = TRUE;
1522                                         creature_ptr->ryoute = TRUE;
1523                                 }
1524                                 break;
1525                         }
1526                 }
1527         }
1528
1529         if (!creature_ptr->migite && !creature_ptr->hidarite)
1530         {
1531                 if (empty_hands_status & EMPTY_HAND_RARM) creature_ptr->migite = TRUE;
1532                 else if (empty_hands_status == EMPTY_HAND_LARM)
1533                 {
1534                         creature_ptr->hidarite = TRUE;
1535                         default_hand = 1;
1536                 }
1537         }
1538
1539         if (creature_ptr->special_defense & KAMAE_MASK)
1540         {
1541                 if (!(empty_hands_status & EMPTY_HAND_RARM))
1542                 {
1543                         set_action(creature_ptr, ACTION_NONE);
1544                 }
1545         }
1546
1547         switch (creature_ptr->pclass)
1548         {
1549         case CLASS_WARRIOR:
1550                 if (creature_ptr->lev > 29) creature_ptr->resist_fear = TRUE;
1551                 if (creature_ptr->lev > 44) creature_ptr->regenerate = TRUE;
1552                 break;
1553         case CLASS_PALADIN:
1554                 if (creature_ptr->lev > 39) creature_ptr->resist_fear = TRUE;
1555                 break;
1556         case CLASS_CHAOS_WARRIOR:
1557                 if (creature_ptr->lev > 29) creature_ptr->resist_chaos = TRUE;
1558                 if (creature_ptr->lev > 39) creature_ptr->resist_fear = TRUE;
1559                 break;
1560         case CLASS_MINDCRAFTER:
1561                 if (creature_ptr->lev > 9) creature_ptr->resist_fear = TRUE;
1562                 if (creature_ptr->lev > 19) creature_ptr->sustain_wis = TRUE;
1563                 if (creature_ptr->lev > 29) creature_ptr->resist_conf = TRUE;
1564                 if (creature_ptr->lev > 39) creature_ptr->telepathy = TRUE;
1565                 break;
1566         case CLASS_MONK:
1567         case CLASS_FORCETRAINER:
1568                 if (!(heavy_armor(creature_ptr)))
1569                 {
1570                         if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
1571                                 PRACE_IS_(creature_ptr, RACE_SPRITE) ||
1572                                 (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
1573                                 new_speed += (creature_ptr->lev) / 10;
1574
1575                         if (creature_ptr->lev > 24)
1576                                 creature_ptr->free_act = TRUE;
1577                 }
1578
1579                 break;
1580         case CLASS_SORCERER:
1581                 creature_ptr->to_a -= 50;
1582                 creature_ptr->dis_to_a -= 50;
1583                 break;
1584         case CLASS_BARD:
1585                 creature_ptr->resist_sound = TRUE;
1586                 break;
1587         case CLASS_SAMURAI:
1588                 if (creature_ptr->lev > 29) creature_ptr->resist_fear = TRUE;
1589                 break;
1590         case CLASS_BERSERKER:
1591                 creature_ptr->shero = 1;
1592                 creature_ptr->sustain_str = TRUE;
1593                 creature_ptr->sustain_dex = TRUE;
1594                 creature_ptr->sustain_con = TRUE;
1595                 creature_ptr->regenerate = TRUE;
1596                 creature_ptr->free_act = TRUE;
1597                 new_speed += 2;
1598                 if (creature_ptr->lev > 29) new_speed++;
1599                 if (creature_ptr->lev > 39) new_speed++;
1600                 if (creature_ptr->lev > 44) new_speed++;
1601                 if (creature_ptr->lev > 49) new_speed++;
1602                 creature_ptr->to_a += 10 + creature_ptr->lev / 2;
1603                 creature_ptr->dis_to_a += 10 + creature_ptr->lev / 2;
1604                 creature_ptr->skill_dig += (100 + creature_ptr->lev * 8);
1605                 if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
1606                 creature_ptr->redraw |= PR_STATUS;
1607                 break;
1608         case CLASS_MIRROR_MASTER:
1609                 if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
1610                 break;
1611         case CLASS_NINJA:
1612                 if (heavy_armor(creature_ptr))
1613                 {
1614                         new_speed -= (creature_ptr->lev) / 10;
1615                         creature_ptr->skill_stl -= (creature_ptr->lev) / 10;
1616                 }
1617                 else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
1618                         (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
1619                 {
1620                         new_speed += 3;
1621                         if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
1622                                 PRACE_IS_(creature_ptr, RACE_SPRITE) ||
1623                                 (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
1624                                 new_speed += (creature_ptr->lev) / 10;
1625                         creature_ptr->skill_stl += (creature_ptr->lev) / 10;
1626                         if (creature_ptr->lev > 24)
1627                                 creature_ptr->free_act = TRUE;
1628                 }
1629
1630                 if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
1631                         (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
1632                 {
1633                         creature_ptr->to_a += creature_ptr->lev / 2 + 5;
1634                         creature_ptr->dis_to_a += creature_ptr->lev / 2 + 5;
1635                 }
1636
1637                 creature_ptr->slow_digest = TRUE;
1638                 creature_ptr->resist_fear = TRUE;
1639                 if (creature_ptr->lev > 19) creature_ptr->resist_pois = TRUE;
1640                 if (creature_ptr->lev > 24) creature_ptr->sustain_dex = TRUE;
1641                 if (creature_ptr->lev > 29) creature_ptr->see_inv = TRUE;
1642                 if (creature_ptr->lev > 44)
1643                 {
1644                         creature_ptr->oppose_pois = 1;
1645                         creature_ptr->redraw |= PR_STATUS;
1646                 }
1647
1648                 creature_ptr->see_nocto = TRUE;
1649                 break;
1650         }
1651
1652         if (creature_ptr->mimic_form)
1653         {
1654                 switch (creature_ptr->mimic_form)
1655                 {
1656                 case MIMIC_DEMON:
1657                         creature_ptr->hold_exp = TRUE;
1658                         creature_ptr->resist_chaos = TRUE;
1659                         creature_ptr->resist_neth = TRUE;
1660                         creature_ptr->resist_fire = TRUE;
1661                         creature_ptr->oppose_fire = 1;
1662                         creature_ptr->see_inv = TRUE;
1663                         new_speed += 3;
1664                         creature_ptr->redraw |= PR_STATUS;
1665                         creature_ptr->to_a += 10;
1666                         creature_ptr->dis_to_a += 10;
1667                         break;
1668                 case MIMIC_DEMON_LORD:
1669                         creature_ptr->hold_exp = TRUE;
1670                         creature_ptr->resist_chaos = TRUE;
1671                         creature_ptr->resist_neth = TRUE;
1672                         creature_ptr->immune_fire = TRUE;
1673                         creature_ptr->resist_acid = TRUE;
1674                         creature_ptr->resist_fire = TRUE;
1675                         creature_ptr->resist_cold = TRUE;
1676                         creature_ptr->resist_elec = TRUE;
1677                         creature_ptr->resist_pois = TRUE;
1678                         creature_ptr->resist_conf = TRUE;
1679                         creature_ptr->resist_disen = TRUE;
1680                         creature_ptr->resist_nexus = TRUE;
1681                         creature_ptr->resist_fear = TRUE;
1682                         creature_ptr->sh_fire = TRUE;
1683                         creature_ptr->see_inv = TRUE;
1684                         creature_ptr->telepathy = TRUE;
1685                         creature_ptr->levitation = TRUE;
1686                         creature_ptr->kill_wall = TRUE;
1687                         new_speed += 5;
1688                         creature_ptr->to_a += 20;
1689                         creature_ptr->dis_to_a += 20;
1690                         break;
1691                 case MIMIC_VAMPIRE:
1692                         creature_ptr->resist_dark = TRUE;
1693                         creature_ptr->hold_exp = TRUE;
1694                         creature_ptr->resist_neth = TRUE;
1695                         creature_ptr->resist_cold = TRUE;
1696                         creature_ptr->resist_pois = TRUE;
1697                         creature_ptr->see_inv = TRUE;
1698                         new_speed += 3;
1699                         creature_ptr->to_a += 10;
1700                         creature_ptr->dis_to_a += 10;
1701                         if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1702                         break;
1703                 }
1704         }
1705         else
1706         {
1707                 switch (creature_ptr->prace)
1708                 {
1709                 case RACE_ELF:
1710                         creature_ptr->resist_lite = TRUE;
1711                         break;
1712                 case RACE_HOBBIT:
1713                         creature_ptr->hold_exp = TRUE;
1714                         break;
1715                 case RACE_GNOME:
1716                         creature_ptr->free_act = TRUE;
1717                         break;
1718                 case RACE_DWARF:
1719                         creature_ptr->resist_blind = TRUE;
1720                         break;
1721                 case RACE_HALF_ORC:
1722                         creature_ptr->resist_dark = TRUE;
1723                         break;
1724                 case RACE_HALF_TROLL:
1725                         creature_ptr->sustain_str = TRUE;
1726
1727                         if (creature_ptr->lev > 14)
1728                         {
1729                                 creature_ptr->regenerate = TRUE;
1730                                 if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER)
1731                                 {
1732                                         creature_ptr->slow_digest = TRUE;
1733                                         /* Let's not make Regeneration
1734                                          * a disadvantage for the poor warriors who can
1735                                          * never learn a spell that satisfies hunger (actually
1736                                          * neither can rogues, but half-trolls are not
1737                                          * supposed to play rogues) */
1738                                 }
1739                         }
1740                         break;
1741                 case RACE_AMBERITE:
1742                         creature_ptr->sustain_con = TRUE;
1743                         creature_ptr->regenerate = TRUE;
1744                         break;
1745                 case RACE_HIGH_ELF:
1746                         creature_ptr->resist_lite = TRUE;
1747                         creature_ptr->see_inv = TRUE;
1748                         break;
1749                 case RACE_BARBARIAN:
1750                         creature_ptr->resist_fear = TRUE;
1751                         break;
1752                 case RACE_HALF_OGRE:
1753                         creature_ptr->resist_dark = TRUE;
1754                         creature_ptr->sustain_str = TRUE;
1755                         break;
1756                 case RACE_HALF_GIANT:
1757                         creature_ptr->sustain_str = TRUE;
1758                         creature_ptr->resist_shard = TRUE;
1759                         break;
1760                 case RACE_HALF_TITAN:
1761                         creature_ptr->resist_chaos = TRUE;
1762                         break;
1763                 case RACE_CYCLOPS:
1764                         creature_ptr->resist_sound = TRUE;
1765                         break;
1766                 case RACE_YEEK:
1767                         creature_ptr->resist_acid = TRUE;
1768                         if (creature_ptr->lev > 19) creature_ptr->immune_acid = TRUE;
1769                         break;
1770                 case RACE_KLACKON:
1771                         creature_ptr->resist_conf = TRUE;
1772                         creature_ptr->resist_acid = TRUE;
1773                         new_speed += (creature_ptr->lev) / 10;
1774                         break;
1775                 case RACE_KOBOLD:
1776                         creature_ptr->resist_pois = TRUE;
1777                         break;
1778                 case RACE_NIBELUNG:
1779                         creature_ptr->resist_disen = TRUE;
1780                         creature_ptr->resist_dark = TRUE;
1781                         break;
1782                 case RACE_DARK_ELF:
1783                         creature_ptr->resist_dark = TRUE;
1784                         if (creature_ptr->lev > 19) creature_ptr->see_inv = TRUE;
1785                         break;
1786                 case RACE_DRACONIAN:
1787                         creature_ptr->levitation = TRUE;
1788                         if (creature_ptr->lev > 4) creature_ptr->resist_fire = TRUE;
1789                         if (creature_ptr->lev > 9) creature_ptr->resist_cold = TRUE;
1790                         if (creature_ptr->lev > 14) creature_ptr->resist_acid = TRUE;
1791                         if (creature_ptr->lev > 19) creature_ptr->resist_elec = TRUE;
1792                         if (creature_ptr->lev > 34) creature_ptr->resist_pois = TRUE;
1793                         break;
1794                 case RACE_MIND_FLAYER:
1795                         creature_ptr->sustain_int = TRUE;
1796                         creature_ptr->sustain_wis = TRUE;
1797                         if (creature_ptr->lev > 14) creature_ptr->see_inv = TRUE;
1798                         if (creature_ptr->lev > 29) creature_ptr->telepathy = TRUE;
1799                         break;
1800                 case RACE_IMP:
1801                         creature_ptr->resist_fire = TRUE;
1802                         if (creature_ptr->lev > 9) creature_ptr->see_inv = TRUE;
1803                         break;
1804                 case RACE_GOLEM:
1805                         creature_ptr->slow_digest = TRUE;
1806                         creature_ptr->free_act = TRUE;
1807                         creature_ptr->see_inv = TRUE;
1808                         creature_ptr->resist_pois = TRUE;
1809                         if (creature_ptr->lev > 34) creature_ptr->hold_exp = TRUE;
1810                         break;
1811                 case RACE_SKELETON:
1812                         creature_ptr->resist_shard = TRUE;
1813                         creature_ptr->hold_exp = TRUE;
1814                         creature_ptr->see_inv = TRUE;
1815                         creature_ptr->resist_pois = TRUE;
1816                         if (creature_ptr->lev > 9) creature_ptr->resist_cold = TRUE;
1817                         break;
1818                 case RACE_ZOMBIE:
1819                         creature_ptr->resist_neth = TRUE;
1820                         creature_ptr->hold_exp = TRUE;
1821                         creature_ptr->see_inv = TRUE;
1822                         creature_ptr->resist_pois = TRUE;
1823                         creature_ptr->slow_digest = TRUE;
1824                         if (creature_ptr->lev > 4) creature_ptr->resist_cold = TRUE;
1825                         break;
1826                 case RACE_VAMPIRE:
1827                         creature_ptr->resist_dark = TRUE;
1828                         creature_ptr->hold_exp = TRUE;
1829                         creature_ptr->resist_neth = TRUE;
1830                         creature_ptr->resist_cold = TRUE;
1831                         creature_ptr->resist_pois = TRUE;
1832                         if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1833                         break;
1834                 case RACE_SPECTRE:
1835                         creature_ptr->levitation = TRUE;
1836                         creature_ptr->free_act = TRUE;
1837                         creature_ptr->resist_neth = TRUE;
1838                         creature_ptr->hold_exp = TRUE;
1839                         creature_ptr->see_inv = TRUE;
1840                         creature_ptr->resist_pois = TRUE;
1841                         creature_ptr->slow_digest = TRUE;
1842                         creature_ptr->resist_cold = TRUE;
1843                         creature_ptr->pass_wall = TRUE;
1844                         if (creature_ptr->lev > 34) creature_ptr->telepathy = TRUE;
1845                         break;
1846                 case RACE_SPRITE:
1847                         creature_ptr->levitation = TRUE;
1848                         creature_ptr->resist_lite = TRUE;
1849
1850                         new_speed += (creature_ptr->lev) / 10;
1851                         break;
1852                 case RACE_BEASTMAN:
1853                         creature_ptr->resist_conf = TRUE;
1854                         creature_ptr->resist_sound = TRUE;
1855                         break;
1856                 case RACE_ENT:
1857                         if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
1858                                 creature_ptr->skill_dig += creature_ptr->lev * 10;
1859
1860                         if (creature_ptr->lev > 25) creature_ptr->stat_add[A_STR]++;
1861                         if (creature_ptr->lev > 40) creature_ptr->stat_add[A_STR]++;
1862                         if (creature_ptr->lev > 45) creature_ptr->stat_add[A_STR]++;
1863
1864                         if (creature_ptr->lev > 25) creature_ptr->stat_add[A_DEX]--;
1865                         if (creature_ptr->lev > 40) creature_ptr->stat_add[A_DEX]--;
1866                         if (creature_ptr->lev > 45) creature_ptr->stat_add[A_DEX]--;
1867
1868                         if (creature_ptr->lev > 25) creature_ptr->stat_add[A_CON]++;
1869                         if (creature_ptr->lev > 40) creature_ptr->stat_add[A_CON]++;
1870                         if (creature_ptr->lev > 45) creature_ptr->stat_add[A_CON]++;
1871                         break;
1872                 case RACE_ANGEL:
1873                         creature_ptr->levitation = TRUE;
1874                         creature_ptr->see_inv = TRUE;
1875                         break;
1876                 case RACE_DEMON:
1877                         creature_ptr->resist_fire = TRUE;
1878                         creature_ptr->resist_neth = TRUE;
1879                         creature_ptr->hold_exp = TRUE;
1880                         if (creature_ptr->lev > 9) creature_ptr->see_inv = TRUE;
1881                         if (creature_ptr->lev > 44)
1882                         {
1883                                 creature_ptr->oppose_fire = 1;
1884                                 creature_ptr->redraw |= PR_STATUS;
1885                         }
1886
1887                         break;
1888                 case RACE_DUNADAN:
1889                         creature_ptr->sustain_con = TRUE;
1890                         break;
1891                 case RACE_S_FAIRY:
1892                         creature_ptr->levitation = TRUE;
1893                         break;
1894                 case RACE_KUTAR:
1895                         creature_ptr->resist_conf = TRUE;
1896                         break;
1897                 case RACE_ANDROID:
1898                         creature_ptr->slow_digest = TRUE;
1899                         creature_ptr->free_act = TRUE;
1900                         creature_ptr->resist_pois = TRUE;
1901                         creature_ptr->hold_exp = TRUE;
1902                         break;
1903                 case RACE_MERFOLK:
1904                         creature_ptr->resist_water = TRUE;
1905                         break;
1906                 default:
1907                         break;
1908                 }
1909         }
1910
1911         if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU))
1912         {
1913                 creature_ptr->see_inv = TRUE;
1914                 creature_ptr->free_act = TRUE;
1915                 creature_ptr->slow_digest = TRUE;
1916                 creature_ptr->regenerate = TRUE;
1917                 creature_ptr->levitation = TRUE;
1918                 creature_ptr->hold_exp = TRUE;
1919                 creature_ptr->telepathy = TRUE;
1920                 creature_ptr->lite = TRUE;
1921                 creature_ptr->sustain_str = TRUE;
1922                 creature_ptr->sustain_int = TRUE;
1923                 creature_ptr->sustain_wis = TRUE;
1924                 creature_ptr->sustain_con = TRUE;
1925                 creature_ptr->sustain_dex = TRUE;
1926                 creature_ptr->sustain_chr = TRUE;
1927                 creature_ptr->resist_acid = TRUE;
1928                 creature_ptr->resist_elec = TRUE;
1929                 creature_ptr->resist_fire = TRUE;
1930                 creature_ptr->resist_cold = TRUE;
1931                 creature_ptr->resist_pois = TRUE;
1932                 creature_ptr->resist_conf = TRUE;
1933                 creature_ptr->resist_sound = TRUE;
1934                 creature_ptr->resist_lite = TRUE;
1935                 creature_ptr->resist_dark = TRUE;
1936                 creature_ptr->resist_chaos = TRUE;
1937                 creature_ptr->resist_disen = TRUE;
1938                 creature_ptr->resist_shard = TRUE;
1939                 creature_ptr->resist_nexus = TRUE;
1940                 creature_ptr->resist_blind = TRUE;
1941                 creature_ptr->resist_neth = TRUE;
1942                 creature_ptr->resist_fear = TRUE;
1943                 creature_ptr->reflect = TRUE;
1944                 creature_ptr->sh_fire = TRUE;
1945                 creature_ptr->sh_elec = TRUE;
1946                 creature_ptr->sh_cold = TRUE;
1947                 creature_ptr->to_a += 100;
1948                 creature_ptr->dis_to_a += 100;
1949         }
1950         else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef)
1951         {
1952                 creature_ptr->to_a += 50;
1953                 creature_ptr->dis_to_a += 50;
1954         }
1955
1956         if (creature_ptr->tim_res_nether)
1957         {
1958                 creature_ptr->resist_neth = TRUE;
1959         }
1960
1961         if (creature_ptr->tim_sh_fire)
1962         {
1963                 creature_ptr->sh_fire = TRUE;
1964         }
1965
1966         if (creature_ptr->tim_res_time)
1967         {
1968                 creature_ptr->resist_time = TRUE;
1969         }
1970
1971         if (creature_ptr->pseikaku == SEIKAKU_SEXY) creature_ptr->cursed |= (TRC_AGGRAVATE);
1972         if (creature_ptr->pseikaku == SEIKAKU_NAMAKE) creature_ptr->to_m_chance += 10;
1973         if (creature_ptr->pseikaku == SEIKAKU_KIREMONO) creature_ptr->to_m_chance -= 3;
1974         if ((creature_ptr->pseikaku == SEIKAKU_GAMAN) || (creature_ptr->pseikaku == SEIKAKU_CHIKARA)) creature_ptr->to_m_chance++;
1975         if (creature_ptr->pseikaku == SEIKAKU_CHARGEMAN)
1976         {
1977                 creature_ptr->to_m_chance += 5;
1978                 creature_ptr->resist_conf = TRUE;
1979         }
1980
1981         if (creature_ptr->pseikaku == SEIKAKU_LUCKY) creature_ptr->muta3 |= MUT3_GOOD_LUCK;
1982         if (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)
1983         {
1984                 creature_ptr->resist_blind = TRUE;
1985                 creature_ptr->resist_conf = TRUE;
1986                 creature_ptr->hold_exp = TRUE;
1987                 if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
1988
1989                 if ((creature_ptr->prace != RACE_KLACKON) && (creature_ptr->prace != RACE_SPRITE))
1990                         new_speed += (creature_ptr->lev) / 10 + 5;
1991         }
1992
1993         if (music_singing(creature_ptr, MUSIC_WALL))
1994         {
1995                 creature_ptr->kill_wall = TRUE;
1996         }
1997
1998         for (int i = 0; i < A_MAX; i++)
1999         {
2000                 creature_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
2001         }
2002
2003         if (creature_ptr->muta3)
2004         {
2005                 if (creature_ptr->muta3 & MUT3_HYPER_STR)
2006                 {
2007                         creature_ptr->stat_add[A_STR] += 4;
2008                 }
2009
2010                 if (creature_ptr->muta3 & MUT3_PUNY)
2011                 {
2012                         creature_ptr->stat_add[A_STR] -= 4;
2013                 }
2014
2015                 if (creature_ptr->muta3 & MUT3_HYPER_INT)
2016                 {
2017                         creature_ptr->stat_add[A_INT] += 4;
2018                         creature_ptr->stat_add[A_WIS] += 4;
2019                 }
2020
2021                 if (creature_ptr->muta3 & MUT3_MORONIC)
2022                 {
2023                         creature_ptr->stat_add[A_INT] -= 4;
2024                         creature_ptr->stat_add[A_WIS] -= 4;
2025                 }
2026
2027                 if (creature_ptr->muta3 & MUT3_RESILIENT)
2028                 {
2029                         creature_ptr->stat_add[A_CON] += 4;
2030                 }
2031
2032                 if (creature_ptr->muta3 & MUT3_XTRA_FAT)
2033                 {
2034                         creature_ptr->stat_add[A_CON] += 2;
2035                         new_speed -= 2;
2036                 }
2037
2038                 if (creature_ptr->muta3 & MUT3_ALBINO)
2039                 {
2040                         creature_ptr->stat_add[A_CON] -= 4;
2041                 }
2042
2043                 if (creature_ptr->muta3 & MUT3_FLESH_ROT)
2044                 {
2045                         creature_ptr->stat_add[A_CON] -= 2;
2046                         creature_ptr->stat_add[A_CHR] -= 1;
2047                         creature_ptr->regenerate = FALSE;
2048                 }
2049
2050                 if (creature_ptr->muta3 & MUT3_SILLY_VOI)
2051                 {
2052                         creature_ptr->stat_add[A_CHR] -= 4;
2053                 }
2054
2055                 if (creature_ptr->muta3 & MUT3_BLANK_FAC)
2056                 {
2057                         creature_ptr->stat_add[A_CHR] -= 1;
2058                 }
2059
2060                 if (creature_ptr->muta3 & MUT3_XTRA_EYES)
2061                 {
2062                         creature_ptr->skill_fos += 15;
2063                         creature_ptr->skill_srh += 15;
2064                 }
2065
2066                 if (creature_ptr->muta3 & MUT3_MAGIC_RES)
2067                 {
2068                         creature_ptr->skill_sav += (15 + (creature_ptr->lev / 5));
2069                 }
2070
2071                 if (creature_ptr->muta3 & MUT3_XTRA_NOIS)
2072                 {
2073                         creature_ptr->skill_stl -= 3;
2074                 }
2075
2076                 if (creature_ptr->muta3 & MUT3_INFRAVIS)
2077                 {
2078                         creature_ptr->see_infra += 3;
2079                 }
2080
2081                 if (creature_ptr->muta3 & MUT3_XTRA_LEGS)
2082                 {
2083                         new_speed += 3;
2084                 }
2085
2086                 if (creature_ptr->muta3 & MUT3_SHORT_LEG)
2087                 {
2088                         new_speed -= 3;
2089                 }
2090
2091                 if (creature_ptr->muta3 & MUT3_ELEC_TOUC)
2092                 {
2093                         creature_ptr->sh_elec = TRUE;
2094                 }
2095
2096                 if (creature_ptr->muta3 & MUT3_FIRE_BODY)
2097                 {
2098                         creature_ptr->sh_fire = TRUE;
2099                         creature_ptr->lite = TRUE;
2100                 }
2101
2102                 if (creature_ptr->muta3 & MUT3_WART_SKIN)
2103                 {
2104                         creature_ptr->stat_add[A_CHR] -= 2;
2105                         creature_ptr->to_a += 5;
2106                         creature_ptr->dis_to_a += 5;
2107                 }
2108
2109                 if (creature_ptr->muta3 & MUT3_SCALES)
2110                 {
2111                         creature_ptr->stat_add[A_CHR] -= 1;
2112                         creature_ptr->to_a += 10;
2113                         creature_ptr->dis_to_a += 10;
2114                 }
2115
2116                 if (creature_ptr->muta3 & MUT3_IRON_SKIN)
2117                 {
2118                         creature_ptr->stat_add[A_DEX] -= 1;
2119                         creature_ptr->to_a += 25;
2120                         creature_ptr->dis_to_a += 25;
2121                 }
2122
2123                 if (creature_ptr->muta3 & MUT3_WINGS)
2124                 {
2125                         creature_ptr->levitation = TRUE;
2126                 }
2127
2128                 if (creature_ptr->muta3 & MUT3_FEARLESS)
2129                 {
2130                         creature_ptr->resist_fear = TRUE;
2131                 }
2132
2133                 if (creature_ptr->muta3 & MUT3_REGEN)
2134                 {
2135                         creature_ptr->regenerate = TRUE;
2136                 }
2137
2138                 if (creature_ptr->muta3 & MUT3_ESP)
2139                 {
2140                         creature_ptr->telepathy = TRUE;
2141                 }
2142
2143                 if (creature_ptr->muta3 & MUT3_LIMBER)
2144                 {
2145                         creature_ptr->stat_add[A_DEX] += 3;
2146                 }
2147
2148                 if (creature_ptr->muta3 & MUT3_ARTHRITIS)
2149                 {
2150                         creature_ptr->stat_add[A_DEX] -= 3;
2151                 }
2152
2153                 if (creature_ptr->muta3 & MUT3_MOTION)
2154                 {
2155                         creature_ptr->free_act = TRUE;
2156                         creature_ptr->skill_stl += 1;
2157                 }
2158
2159                 if (creature_ptr->muta3 & MUT3_ILL_NORM)
2160                 {
2161                         creature_ptr->stat_add[A_CHR] = 0;
2162                 }
2163         }
2164
2165         if (creature_ptr->tsuyoshi)
2166         {
2167                 creature_ptr->stat_add[A_STR] += 4;
2168                 creature_ptr->stat_add[A_CON] += 4;
2169         }
2170
2171         for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
2172         {
2173                 int bonus_to_h, bonus_to_d;
2174                 o_ptr = &creature_ptr->inventory_list[i];
2175                 if (!o_ptr->k_idx) continue;
2176
2177                 object_flags(o_ptr, flgs);
2178
2179                 creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
2180                 if (o_ptr->name1 == ART_CHAINSWORD) creature_ptr->cursed |= TRC_CHAINSWORD;
2181
2182                 if (have_flag(flgs, TR_STR)) creature_ptr->stat_add[A_STR] += o_ptr->pval;
2183                 if (have_flag(flgs, TR_INT)) creature_ptr->stat_add[A_INT] += o_ptr->pval;
2184                 if (have_flag(flgs, TR_WIS)) creature_ptr->stat_add[A_WIS] += o_ptr->pval;
2185                 if (have_flag(flgs, TR_DEX)) creature_ptr->stat_add[A_DEX] += o_ptr->pval;
2186                 if (have_flag(flgs, TR_CON)) creature_ptr->stat_add[A_CON] += o_ptr->pval;
2187                 if (have_flag(flgs, TR_CHR)) creature_ptr->stat_add[A_CHR] += o_ptr->pval;
2188                 if (have_flag(flgs, TR_MAGIC_MASTERY)) creature_ptr->skill_dev += 8 * o_ptr->pval;
2189                 if (have_flag(flgs, TR_STEALTH)) creature_ptr->skill_stl += o_ptr->pval;
2190                 if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_srh += (o_ptr->pval * 5);
2191                 if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_fos += (o_ptr->pval * 5);
2192                 if (have_flag(flgs, TR_INFRA)) creature_ptr->see_infra += o_ptr->pval;
2193                 if (have_flag(flgs, TR_TUNNEL)) creature_ptr->skill_dig += (o_ptr->pval * 20);
2194                 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
2195                 if (have_flag(flgs, TR_BLOWS))
2196                 {
2197                         if ((i == INVEN_RARM || i == INVEN_RIGHT) && !creature_ptr->ryoute) extra_blows[0] += o_ptr->pval;
2198                         else if ((i == INVEN_LARM || i == INVEN_LEFT) && !creature_ptr->ryoute) extra_blows[1] += o_ptr->pval;
2199                         else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
2200                 }
2201
2202                 if (have_flag(flgs, TR_IMPACT)) creature_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
2203                 if (have_flag(flgs, TR_AGGRAVATE))   creature_ptr->cursed |= TRC_AGGRAVATE;
2204                 if (have_flag(flgs, TR_DRAIN_EXP))   creature_ptr->cursed |= TRC_DRAIN_EXP;
2205                 if (have_flag(flgs, TR_TY_CURSE))    creature_ptr->cursed |= TRC_TY_CURSE;
2206                 if (have_flag(flgs, TR_ADD_L_CURSE)) creature_ptr->cursed |= TRC_ADD_L_CURSE;
2207                 if (have_flag(flgs, TR_ADD_H_CURSE)) creature_ptr->cursed |= TRC_ADD_H_CURSE;
2208                 if (have_flag(flgs, TR_DRAIN_HP))    creature_ptr->cursed |= TRC_DRAIN_HP;
2209                 if (have_flag(flgs, TR_DRAIN_MANA))  creature_ptr->cursed |= TRC_DRAIN_MANA;
2210                 if (have_flag(flgs, TR_CALL_ANIMAL)) creature_ptr->cursed |= TRC_CALL_ANIMAL;
2211                 if (have_flag(flgs, TR_CALL_DEMON))  creature_ptr->cursed |= TRC_CALL_DEMON;
2212                 if (have_flag(flgs, TR_CALL_DRAGON)) creature_ptr->cursed |= TRC_CALL_DRAGON;
2213                 if (have_flag(flgs, TR_CALL_UNDEAD)) creature_ptr->cursed |= TRC_CALL_UNDEAD;
2214                 if (have_flag(flgs, TR_COWARDICE))   creature_ptr->cursed |= TRC_COWARDICE;
2215                 if (have_flag(flgs, TR_LOW_MELEE))   creature_ptr->cursed |= TRC_LOW_MELEE;
2216                 if (have_flag(flgs, TR_LOW_AC))      creature_ptr->cursed |= TRC_LOW_AC;
2217                 if (have_flag(flgs, TR_LOW_MAGIC))   creature_ptr->cursed |= TRC_LOW_MAGIC;
2218                 if (have_flag(flgs, TR_FAST_DIGEST)) creature_ptr->cursed |= TRC_FAST_DIGEST;
2219                 if (have_flag(flgs, TR_SLOW_REGEN))  creature_ptr->cursed |= TRC_SLOW_REGEN;
2220                 if (have_flag(flgs, TR_DEC_MANA))    creature_ptr->dec_mana = TRUE;
2221                 if (have_flag(flgs, TR_BLESSED))     creature_ptr->bless_blade = TRUE;
2222                 if (have_flag(flgs, TR_XTRA_MIGHT))  creature_ptr->xtra_might = TRUE;
2223                 if (have_flag(flgs, TR_SLOW_DIGEST)) creature_ptr->slow_digest = TRUE;
2224                 if (have_flag(flgs, TR_REGEN))       creature_ptr->regenerate = TRUE;
2225                 if (have_flag(flgs, TR_TELEPATHY))   creature_ptr->telepathy = TRUE;
2226                 if (have_flag(flgs, TR_ESP_ANIMAL))  creature_ptr->esp_animal = TRUE;
2227                 if (have_flag(flgs, TR_ESP_UNDEAD))  creature_ptr->esp_undead = TRUE;
2228                 if (have_flag(flgs, TR_ESP_DEMON))   creature_ptr->esp_demon = TRUE;
2229                 if (have_flag(flgs, TR_ESP_ORC))     creature_ptr->esp_orc = TRUE;
2230                 if (have_flag(flgs, TR_ESP_TROLL))   creature_ptr->esp_troll = TRUE;
2231                 if (have_flag(flgs, TR_ESP_GIANT))   creature_ptr->esp_giant = TRUE;
2232                 if (have_flag(flgs, TR_ESP_DRAGON))  creature_ptr->esp_dragon = TRUE;
2233                 if (have_flag(flgs, TR_ESP_HUMAN))   creature_ptr->esp_human = TRUE;
2234                 if (have_flag(flgs, TR_ESP_EVIL))    creature_ptr->esp_evil = TRUE;
2235                 if (have_flag(flgs, TR_ESP_GOOD))    creature_ptr->esp_good = TRUE;
2236                 if (have_flag(flgs, TR_ESP_NONLIVING)) creature_ptr->esp_nonliving = TRUE;
2237                 if (have_flag(flgs, TR_ESP_UNIQUE))  creature_ptr->esp_unique = TRUE;
2238
2239                 if (have_flag(flgs, TR_SEE_INVIS))   creature_ptr->see_inv = TRUE;
2240                 if (have_flag(flgs, TR_LEVITATION))     creature_ptr->levitation = TRUE;
2241                 if (have_flag(flgs, TR_FREE_ACT))    creature_ptr->free_act = TRUE;
2242                 if (have_flag(flgs, TR_HOLD_EXP))   creature_ptr->hold_exp = TRUE;
2243                 if (have_flag(flgs, TR_WARNING)) {
2244                         if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription), '$')))
2245                                 creature_ptr->warning = TRUE;
2246                 }
2247
2248                 if (have_flag(flgs, TR_TELEPORT))
2249                 {
2250                         if (object_is_cursed(o_ptr)) creature_ptr->cursed |= TRC_TELEPORT;
2251                         else
2252                         {
2253                                 concptr insc = quark_str(o_ptr->inscription);
2254
2255                                 /* {.} will stop random teleportation. */
2256                                 if (o_ptr->inscription && my_strchr(insc, '.'))
2257                                 {
2258                                 }
2259                                 else
2260                                 {
2261                                         creature_ptr->cursed |= TRC_TELEPORT_SELF;
2262                                 }
2263                         }
2264                 }
2265
2266                 if (have_flag(flgs, TR_IM_FIRE)) creature_ptr->immune_fire = TRUE;
2267                 if (have_flag(flgs, TR_IM_ACID)) creature_ptr->immune_acid = TRUE;
2268                 if (have_flag(flgs, TR_IM_COLD)) creature_ptr->immune_cold = TRUE;
2269                 if (have_flag(flgs, TR_IM_ELEC)) creature_ptr->immune_elec = TRUE;
2270
2271                 if (have_flag(flgs, TR_RES_ACID))   creature_ptr->resist_acid = TRUE;
2272                 if (have_flag(flgs, TR_RES_ELEC))   creature_ptr->resist_elec = TRUE;
2273                 if (have_flag(flgs, TR_RES_FIRE))   creature_ptr->resist_fire = TRUE;
2274                 if (have_flag(flgs, TR_RES_COLD))   creature_ptr->resist_cold = TRUE;
2275                 if (have_flag(flgs, TR_RES_POIS))   creature_ptr->resist_pois = TRUE;
2276                 if (have_flag(flgs, TR_RES_FEAR))   creature_ptr->resist_fear = TRUE;
2277                 if (have_flag(flgs, TR_RES_CONF))   creature_ptr->resist_conf = TRUE;
2278                 if (have_flag(flgs, TR_RES_SOUND))  creature_ptr->resist_sound = TRUE;
2279                 if (have_flag(flgs, TR_RES_LITE))   creature_ptr->resist_lite = TRUE;
2280                 if (have_flag(flgs, TR_RES_DARK))   creature_ptr->resist_dark = TRUE;
2281                 if (have_flag(flgs, TR_RES_CHAOS))  creature_ptr->resist_chaos = TRUE;
2282                 if (have_flag(flgs, TR_RES_DISEN))  creature_ptr->resist_disen = TRUE;
2283                 if (have_flag(flgs, TR_RES_SHARDS)) creature_ptr->resist_shard = TRUE;
2284                 if (have_flag(flgs, TR_RES_NEXUS))  creature_ptr->resist_nexus = TRUE;
2285                 if (have_flag(flgs, TR_RES_BLIND))  creature_ptr->resist_blind = TRUE;
2286                 if (have_flag(flgs, TR_RES_NETHER)) creature_ptr->resist_neth = TRUE;
2287
2288                 if (have_flag(flgs, TR_REFLECT))  creature_ptr->reflect = TRUE;
2289                 if (have_flag(flgs, TR_SH_FIRE))  creature_ptr->sh_fire = TRUE;
2290                 if (have_flag(flgs, TR_SH_ELEC))  creature_ptr->sh_elec = TRUE;
2291                 if (have_flag(flgs, TR_SH_COLD))  creature_ptr->sh_cold = TRUE;
2292                 if (have_flag(flgs, TR_NO_MAGIC)) creature_ptr->anti_magic = TRUE;
2293                 if (have_flag(flgs, TR_NO_TELE))  creature_ptr->anti_tele = TRUE;
2294
2295                 if (have_flag(flgs, TR_SUST_STR)) creature_ptr->sustain_str = TRUE;
2296                 if (have_flag(flgs, TR_SUST_INT)) creature_ptr->sustain_int = TRUE;
2297                 if (have_flag(flgs, TR_SUST_WIS)) creature_ptr->sustain_wis = TRUE;
2298                 if (have_flag(flgs, TR_SUST_DEX)) creature_ptr->sustain_dex = TRUE;
2299                 if (have_flag(flgs, TR_SUST_CON)) creature_ptr->sustain_con = TRUE;
2300                 if (have_flag(flgs, TR_SUST_CHR)) creature_ptr->sustain_chr = TRUE;
2301
2302                 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
2303                 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
2304                 if (o_ptr->name2 == EGO_RING_RES_TIME) creature_ptr->resist_time = TRUE;
2305                 if (o_ptr->name2 == EGO_RING_THROW) creature_ptr->mighty_throw = TRUE;
2306                 if (have_flag(flgs, TR_EASY_SPELL)) creature_ptr->easy_spell = TRUE;
2307                 if (o_ptr->name2 == EGO_AMU_FOOL) creature_ptr->heavy_spell = TRUE;
2308                 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
2309
2310                 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
2311                 {
2312                         if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2313                         {
2314                                 creature_ptr->to_m_chance += 10;
2315                         }
2316                         else
2317                         {
2318                                 creature_ptr->to_m_chance += 3;
2319                         }
2320                 }
2321
2322                 if (o_ptr->tval == TV_CAPTURE) continue;
2323
2324                 creature_ptr->ac += o_ptr->ac;
2325                 creature_ptr->dis_ac += o_ptr->ac;
2326                 creature_ptr->to_a += o_ptr->to_a;
2327                 if (object_is_known(o_ptr)) creature_ptr->dis_to_a += o_ptr->to_a;
2328
2329                 if (o_ptr->curse_flags & TRC_LOW_MELEE)
2330                 {
2331                         int slot = i - INVEN_RARM;
2332                         if (slot < 2)
2333                         {
2334                                 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2335                                 {
2336                                         creature_ptr->to_h[slot] -= 15;
2337                                         if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h[slot] -= 15;
2338                                 }
2339                                 else
2340                                 {
2341                                         creature_ptr->to_h[slot] -= 5;
2342                                         if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h[slot] -= 5;
2343                                 }
2344                         }
2345                         else
2346                         {
2347                                 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2348                                 {
2349                                         creature_ptr->to_h_b -= 15;
2350                                         if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h_b -= 15;
2351                                 }
2352                                 else
2353                                 {
2354                                         creature_ptr->to_h_b -= 5;
2355                                         if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h_b -= 5;
2356                                 }
2357                         }
2358                 }
2359
2360                 if (o_ptr->curse_flags & TRC_LOW_AC)
2361                 {
2362                         if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
2363                         {
2364                                 creature_ptr->to_a -= 30;
2365                                 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_a -= 30;
2366                         }
2367                         else
2368                         {
2369                                 creature_ptr->to_a -= 10;
2370                                 if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_a -= 10;
2371                         }
2372                 }
2373
2374                 if (i == INVEN_RARM && has_melee_weapon(creature_ptr, i)) continue;
2375                 if (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) continue;
2376                 if (i == INVEN_BOW) continue;
2377
2378                 bonus_to_h = o_ptr->to_h;
2379                 bonus_to_d = o_ptr->to_d;
2380
2381                 if (creature_ptr->pclass == CLASS_NINJA)
2382                 {
2383                         if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h + 1) / 2;
2384                         if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
2385                 }
2386
2387                 creature_ptr->to_h_b += (s16b)bonus_to_h;
2388                 creature_ptr->to_h_m += (s16b)bonus_to_h;
2389                 creature_ptr->to_d_m += (s16b)bonus_to_d;
2390
2391                 if (object_is_known(o_ptr)) creature_ptr->dis_to_h_b += (s16b)bonus_to_h;
2392
2393                 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !creature_ptr->ryoute)
2394                 {
2395                         creature_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
2396                         creature_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
2397                         if (object_is_known(o_ptr))
2398                         {
2399                                 creature_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
2400                                 creature_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
2401                         }
2402
2403                         continue;
2404                 }
2405
2406                 if (creature_ptr->migite && creature_ptr->hidarite)
2407                 {
2408                         creature_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2409                         creature_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2410                         creature_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2411                         creature_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2412                         if (!object_is_known(o_ptr)) continue;
2413
2414                         creature_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
2415                         creature_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
2416                         creature_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
2417                         creature_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
2418                         continue;
2419                 }
2420
2421                 creature_ptr->to_h[default_hand] += (s16b)bonus_to_h;
2422                 creature_ptr->to_d[default_hand] += (s16b)bonus_to_d;
2423
2424                 if (!object_is_known(o_ptr)) continue;
2425
2426                 creature_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
2427                 creature_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
2428         }
2429
2430         if (object_is_armour(&creature_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&creature_ptr->inventory_list[INVEN_LARM]))
2431         {
2432                 creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2433                 creature_ptr->dis_ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
2434         }
2435
2436         if (old_mighty_throw != creature_ptr->mighty_throw)
2437         {
2438                 creature_ptr->window |= PW_INVEN;
2439         }
2440
2441         if (creature_ptr->cursed & TRC_TELEPORT) creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
2442
2443         if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr))
2444         {
2445                 if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx))
2446                 {
2447                         creature_ptr->to_a += (creature_ptr->lev * 3) / 2;
2448                         creature_ptr->dis_to_a += (creature_ptr->lev * 3) / 2;
2449                 }
2450                 if (!(creature_ptr->inventory_list[INVEN_OUTER].k_idx) && (creature_ptr->lev > 15))
2451                 {
2452                         creature_ptr->to_a += ((creature_ptr->lev - 13) / 3);
2453                         creature_ptr->dis_to_a += ((creature_ptr->lev - 13) / 3);
2454                 }
2455                 if (!(creature_ptr->inventory_list[INVEN_LARM].k_idx) && (creature_ptr->lev > 10))
2456                 {
2457                         creature_ptr->to_a += ((creature_ptr->lev - 8) / 3);
2458                         creature_ptr->dis_to_a += ((creature_ptr->lev - 8) / 3);
2459                 }
2460                 if (!(creature_ptr->inventory_list[INVEN_HEAD].k_idx) && (creature_ptr->lev > 4))
2461                 {
2462                         creature_ptr->to_a += (creature_ptr->lev - 2) / 3;
2463                         creature_ptr->dis_to_a += (creature_ptr->lev - 2) / 3;
2464                 }
2465                 if (!(creature_ptr->inventory_list[INVEN_HANDS].k_idx))
2466                 {
2467                         creature_ptr->to_a += (creature_ptr->lev / 2);
2468                         creature_ptr->dis_to_a += (creature_ptr->lev / 2);
2469                 }
2470                 if (!(creature_ptr->inventory_list[INVEN_FEET].k_idx))
2471                 {
2472                         creature_ptr->to_a += (creature_ptr->lev / 3);
2473                         creature_ptr->dis_to_a += (creature_ptr->lev / 3);
2474                 }
2475                 if (creature_ptr->special_defense & KAMAE_BYAKKO)
2476                 {
2477                         creature_ptr->stat_add[A_STR] += 2;
2478                         creature_ptr->stat_add[A_DEX] += 2;
2479                         creature_ptr->stat_add[A_CON] -= 3;
2480                 }
2481                 else if (creature_ptr->special_defense & KAMAE_SEIRYU)
2482                 {
2483                 }
2484                 else if (creature_ptr->special_defense & KAMAE_GENBU)
2485                 {
2486                         creature_ptr->stat_add[A_INT] -= 1;
2487                         creature_ptr->stat_add[A_WIS] -= 1;
2488                         creature_ptr->stat_add[A_DEX] -= 2;
2489                         creature_ptr->stat_add[A_CON] += 3;
2490                 }
2491                 else if (creature_ptr->special_defense & KAMAE_SUZAKU)
2492                 {
2493                         creature_ptr->stat_add[A_STR] -= 2;
2494                         creature_ptr->stat_add[A_INT] += 1;
2495                         creature_ptr->stat_add[A_WIS] += 1;
2496                         creature_ptr->stat_add[A_DEX] += 2;
2497                         creature_ptr->stat_add[A_CON] -= 2;
2498                 }
2499         }
2500
2501         if (creature_ptr->special_defense & KATA_KOUKIJIN)
2502         {
2503                 for (int i = 0; i < A_MAX; i++)
2504                         creature_ptr->stat_add[i] += 5;
2505                 creature_ptr->to_a -= 50;
2506                 creature_ptr->dis_to_a -= 50;
2507         }
2508
2509         if (creature_ptr->sh_fire) creature_ptr->lite = TRUE;
2510
2511         if (PRACE_IS_(creature_ptr, RACE_GOLEM) || PRACE_IS_(creature_ptr, RACE_ANDROID))
2512         {
2513                 creature_ptr->to_a += 10 + (creature_ptr->lev * 2 / 5);
2514                 creature_ptr->dis_to_a += 10 + (creature_ptr->lev * 2 / 5);
2515         }
2516
2517         if (creature_ptr->realm1 == REALM_HEX)
2518         {
2519                 if (hex_spelling_any(creature_ptr)) creature_ptr->skill_stl -= (1 + CASTING_HEX_NUM(creature_ptr));
2520                 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
2521                 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
2522                 if (hex_spelling(creature_ptr, HEX_BUILDING))
2523                 {
2524                         creature_ptr->stat_add[A_STR] += 4;
2525                         creature_ptr->stat_add[A_DEX] += 4;
2526                         creature_ptr->stat_add[A_CON] += 4;
2527                 }
2528
2529                 if (hex_spelling(creature_ptr, HEX_DEMON_AURA))
2530                 {
2531                         creature_ptr->sh_fire = TRUE;
2532                         creature_ptr->regenerate = TRUE;
2533                 }
2534
2535                 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR))
2536                 {
2537                         creature_ptr->sh_cold = TRUE;
2538                         creature_ptr->to_a += 30;
2539                         creature_ptr->dis_to_a += 30;
2540                 }
2541
2542                 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK))
2543                 {
2544                         creature_ptr->sh_elec = TRUE;
2545                         new_speed += 3;
2546                 }
2547
2548                 for (int i = INVEN_RARM; i <= INVEN_FEET; i++)
2549                 {
2550                         ARMOUR_CLASS ac = 0;
2551                         o_ptr = &creature_ptr->inventory_list[i];
2552                         if (!o_ptr->k_idx) continue;
2553                         if (!object_is_armour(o_ptr)) continue;
2554                         if (!object_is_cursed(o_ptr)) continue;
2555                         ac += 5;
2556                         if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
2557                         if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
2558                         creature_ptr->to_a += (s16b)ac;
2559                         creature_ptr->dis_to_a += (s16b)ac;
2560                 }
2561         }
2562
2563         int count = 0;
2564         for (int i = 0; i < A_MAX; i++)
2565         {
2566                 int ind;
2567                 int top = modify_stat_value(creature_ptr->stat_max[i], creature_ptr->stat_add[i]);
2568
2569                 if (creature_ptr->stat_top[i] != top)
2570                 {
2571                         creature_ptr->stat_top[i] = (s16b)top;
2572                         creature_ptr->redraw |= (PR_STATS);
2573                         creature_ptr->window |= (PW_PLAYER);
2574                 }
2575
2576                 int use = modify_stat_value(creature_ptr->stat_cur[i], creature_ptr->stat_add[i]);
2577
2578                 if ((i == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM))
2579                 {
2580                         /* 10 to 18/90 charisma, guaranteed, based on level */
2581                         if (use < 8 + 2 * creature_ptr->lev)
2582                         {
2583                                 use = 8 + 2 * creature_ptr->lev;
2584                         }
2585                 }
2586
2587                 if (creature_ptr->stat_use[i] != use)
2588                 {
2589                         creature_ptr->stat_use[i] = (s16b)use;
2590                         creature_ptr->redraw |= (PR_STATS);
2591                         creature_ptr->window |= (PW_PLAYER);
2592                 }
2593
2594                 if (use <= 18) ind = (use - 3);
2595                 else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
2596                 else ind = (37);
2597
2598                 if (creature_ptr->stat_ind[i] == ind) continue;
2599                 creature_ptr->stat_ind[i] = (s16b)ind;
2600                 if (i == A_CON)
2601                 {
2602                         creature_ptr->update |= (PU_HP);
2603                 }
2604                 else if (i == A_INT)
2605                 {
2606                         if (mp_ptr->spell_stat == A_INT)
2607                         {
2608                                 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2609                         }
2610                 }
2611                 else if (i == A_WIS)
2612                 {
2613                         if (mp_ptr->spell_stat == A_WIS)
2614                         {
2615                                 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2616                         }
2617                 }
2618                 else if (i == A_CHR)
2619                 {
2620                         if (mp_ptr->spell_stat == A_CHR)
2621                         {
2622                                 creature_ptr->update |= (PU_MANA | PU_SPELLS);
2623                         }
2624                 }
2625
2626                 creature_ptr->window |= (PW_PLAYER);
2627                 count++;
2628         }
2629
2630         if (creature_ptr->stun > 50)
2631         {
2632                 creature_ptr->to_h[0] -= 20;
2633                 creature_ptr->to_h[1] -= 20;
2634                 creature_ptr->to_h_b -= 20;
2635                 creature_ptr->to_h_m -= 20;
2636                 creature_ptr->dis_to_h[0] -= 20;
2637                 creature_ptr->dis_to_h[1] -= 20;
2638                 creature_ptr->dis_to_h_b -= 20;
2639                 creature_ptr->to_d[0] -= 20;
2640                 creature_ptr->to_d[1] -= 20;
2641                 creature_ptr->to_d_m -= 20;
2642                 creature_ptr->dis_to_d[0] -= 20;
2643                 creature_ptr->dis_to_d[1] -= 20;
2644         }
2645         else if (creature_ptr->stun)
2646         {
2647                 creature_ptr->to_h[0] -= 5;
2648                 creature_ptr->to_h[1] -= 5;
2649                 creature_ptr->to_h_b -= 5;
2650                 creature_ptr->to_h_m -= 5;
2651                 creature_ptr->dis_to_h[0] -= 5;
2652                 creature_ptr->dis_to_h[1] -= 5;
2653                 creature_ptr->dis_to_h_b -= 5;
2654                 creature_ptr->to_d[0] -= 5;
2655                 creature_ptr->to_d[1] -= 5;
2656                 creature_ptr->to_d_m -= 5;
2657                 creature_ptr->dis_to_d[0] -= 5;
2658                 creature_ptr->dis_to_d[1] -= 5;
2659         }
2660
2661         if (creature_ptr->wraith_form)
2662         {
2663                 creature_ptr->reflect = TRUE;
2664                 creature_ptr->pass_wall = TRUE;
2665         }
2666
2667         if (creature_ptr->kabenuke)
2668         {
2669                 creature_ptr->pass_wall = TRUE;
2670         }
2671
2672         if (is_blessed(creature_ptr))
2673         {
2674                 creature_ptr->to_a += 5;
2675                 creature_ptr->dis_to_a += 5;
2676                 creature_ptr->to_h[0] += 10;
2677                 creature_ptr->to_h[1] += 10;
2678                 creature_ptr->to_h_b += 10;
2679                 creature_ptr->to_h_m += 10;
2680                 creature_ptr->dis_to_h[0] += 10;
2681                 creature_ptr->dis_to_h[1] += 10;
2682                 creature_ptr->dis_to_h_b += 10;
2683         }
2684
2685         if (creature_ptr->magicdef)
2686         {
2687                 creature_ptr->resist_blind = TRUE;
2688                 creature_ptr->resist_conf = TRUE;
2689                 creature_ptr->reflect = TRUE;
2690                 creature_ptr->free_act = TRUE;
2691                 creature_ptr->levitation = TRUE;
2692         }
2693
2694         if (IS_HERO(creature_ptr))
2695         {
2696                 creature_ptr->to_h[0] += 12;
2697                 creature_ptr->to_h[1] += 12;
2698                 creature_ptr->to_h_b += 12;
2699                 creature_ptr->to_h_m += 12;
2700                 creature_ptr->dis_to_h[0] += 12;
2701                 creature_ptr->dis_to_h[1] += 12;
2702                 creature_ptr->dis_to_h_b += 12;
2703         }
2704
2705         if (creature_ptr->shero)
2706         {
2707                 creature_ptr->to_h[0] += 12;
2708                 creature_ptr->to_h[1] += 12;
2709                 creature_ptr->to_h_b -= 12;
2710                 creature_ptr->to_h_m += 12;
2711                 creature_ptr->to_d[0] += 3 + (creature_ptr->lev / 5);
2712                 creature_ptr->to_d[1] += 3 + (creature_ptr->lev / 5);
2713                 creature_ptr->to_d_m += 3 + (creature_ptr->lev / 5);
2714                 creature_ptr->dis_to_h[0] += 12;
2715                 creature_ptr->dis_to_h[1] += 12;
2716                 creature_ptr->dis_to_h_b -= 12;
2717                 creature_ptr->dis_to_d[0] += 3 + (creature_ptr->lev / 5);
2718                 creature_ptr->dis_to_d[1] += 3 + (creature_ptr->lev / 5);
2719                 creature_ptr->to_a -= 10;
2720                 creature_ptr->dis_to_a -= 10;
2721                 creature_ptr->skill_stl -= 7;
2722                 creature_ptr->skill_dev -= 20;
2723                 creature_ptr->skill_sav -= 30;
2724                 creature_ptr->skill_srh -= 15;
2725                 creature_ptr->skill_fos -= 15;
2726                 creature_ptr->skill_tht -= 20;
2727                 creature_ptr->skill_dig += 30;
2728         }
2729
2730         if (IS_FAST(creature_ptr))
2731         {
2732                 new_speed += 10;
2733         }
2734
2735         if (creature_ptr->slow)
2736         {
2737                 new_speed -= 10;
2738         }
2739
2740         if (is_time_limit_esp(creature_ptr))
2741         {
2742                 creature_ptr->telepathy = TRUE;
2743         }
2744
2745         if (creature_ptr->ele_immune)
2746         {
2747                 if (creature_ptr->special_defense & DEFENSE_ACID)
2748                         creature_ptr->immune_acid = TRUE;
2749                 else if (creature_ptr->special_defense & DEFENSE_ELEC)
2750                         creature_ptr->immune_elec = TRUE;
2751                 else if (creature_ptr->special_defense & DEFENSE_FIRE)
2752                         creature_ptr->immune_fire = TRUE;
2753                 else if (creature_ptr->special_defense & DEFENSE_COLD)
2754                         creature_ptr->immune_cold = TRUE;
2755         }
2756
2757         if (creature_ptr->tim_invis)
2758         {
2759                 creature_ptr->see_inv = TRUE;
2760         }
2761
2762         if (creature_ptr->tim_infra)
2763         {
2764                 creature_ptr->see_infra += 3;
2765         }
2766
2767         if (creature_ptr->tim_regen)
2768         {
2769                 creature_ptr->regenerate = TRUE;
2770         }
2771
2772         if (creature_ptr->tim_levitation)
2773         {
2774                 creature_ptr->levitation = TRUE;
2775         }
2776
2777         if (creature_ptr->tim_reflect)
2778         {
2779                 creature_ptr->reflect = TRUE;
2780         }
2781
2782         if (IS_HERO(creature_ptr) || creature_ptr->shero)
2783         {
2784                 creature_ptr->resist_fear = TRUE;
2785         }
2786
2787         if (creature_ptr->telepathy != old_telepathy)
2788         {
2789                 creature_ptr->update |= (PU_MONSTERS);
2790         }
2791
2792         if ((creature_ptr->esp_animal != old_esp_animal) ||
2793                 (creature_ptr->esp_undead != old_esp_undead) ||
2794                 (creature_ptr->esp_demon != old_esp_demon) ||
2795                 (creature_ptr->esp_orc != old_esp_orc) ||
2796                 (creature_ptr->esp_troll != old_esp_troll) ||
2797                 (creature_ptr->esp_giant != old_esp_giant) ||
2798                 (creature_ptr->esp_dragon != old_esp_dragon) ||
2799                 (creature_ptr->esp_human != old_esp_human) ||
2800                 (creature_ptr->esp_evil != old_esp_evil) ||
2801                 (creature_ptr->esp_good != old_esp_good) ||
2802                 (creature_ptr->esp_nonliving != old_esp_nonliving) ||
2803                 (creature_ptr->esp_unique != old_esp_unique))
2804         {
2805                 creature_ptr->update |= (PU_MONSTERS);
2806         }
2807
2808         if (creature_ptr->see_inv != old_see_inv)
2809         {
2810                 creature_ptr->update |= (PU_MONSTERS);
2811         }
2812
2813         if (creature_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
2814
2815         if (creature_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
2816
2817         if ((creature_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
2818                 (creature_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
2819         {
2820                 creature_ptr->to_h[default_hand] += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2821                 creature_ptr->dis_to_h[default_hand] += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
2822         }
2823
2824         if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2825         {
2826                 int penalty1, penalty2;
2827                 penalty1 = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[INVEN_RARM].weight) / 8);
2828                 penalty2 = ((100 - creature_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - creature_ptr->inventory_list[INVEN_LARM].weight) / 8);
2829                 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_QUICKTHORN) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_TINYTHORN))
2830                 {
2831                         penalty1 = penalty1 / 2 - 5;
2832                         penalty2 = penalty2 / 2 - 5;
2833                         new_speed += 7;
2834                         creature_ptr->to_a += 10;
2835                         creature_ptr->dis_to_a += 10;
2836                 }
2837                 if (easy_2weapon)
2838                 {
2839                         if (penalty1 > 0) penalty1 /= 2;
2840                         if (penalty2 > 0) penalty2 /= 2;
2841                 }
2842                 else if ((creature_ptr->inventory_list[INVEN_LARM].tval == TV_SWORD) && ((creature_ptr->inventory_list[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (creature_ptr->inventory_list[INVEN_LARM].sval == SV_WAKIZASHI)))
2843                 {
2844                         penalty1 = MAX(0, penalty1 - 10);
2845                         penalty2 = MAX(0, penalty2 - 10);
2846                 }
2847                 if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
2848                 {
2849                         penalty1 = MIN(0, penalty1);
2850                         penalty2 = MIN(0, penalty2);
2851                         creature_ptr->to_a += 10;
2852                         creature_ptr->dis_to_a += 10;
2853                 }
2854                 else
2855                 {
2856                         if ((creature_ptr->inventory_list[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
2857                                 penalty1 /= 2;
2858                         if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
2859                                 penalty2 /= 2;
2860                 }
2861
2862                 if (creature_ptr->inventory_list[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
2863                 if (creature_ptr->inventory_list[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
2864                 creature_ptr->to_h[0] -= (s16b)penalty1;
2865                 creature_ptr->to_h[1] -= (s16b)penalty2;
2866                 creature_ptr->dis_to_h[0] -= (s16b)penalty1;
2867                 creature_ptr->dis_to_h[1] -= (s16b)penalty2;
2868         }
2869
2870         int j = creature_ptr->total_weight;
2871         if (!creature_ptr->riding)
2872         {
2873                 count = (int)weight_limit(creature_ptr);
2874         }
2875         else
2876         {
2877                 monster_type *riding_m_ptr = &floor_ptr->m_list[creature_ptr->riding];
2878                 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
2879                 SPEED speed = riding_m_ptr->mspeed;
2880
2881                 if (riding_m_ptr->mspeed > 110)
2882                 {
2883                         new_speed = 110 + (s16b)((speed - 110) * (creature_ptr->skill_exp[GINOU_RIDING] * 3 + creature_ptr->lev * 160L - 10000L) / (22000L));
2884                         if (new_speed < 110) new_speed = 110;
2885                 }
2886                 else
2887                 {
2888                         new_speed = speed;
2889                 }
2890
2891                 new_speed += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
2892                 if (MON_FAST(riding_m_ptr)) new_speed += 10;
2893                 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
2894                 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
2895                 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) creature_ptr->can_swim = TRUE;
2896
2897                 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) creature_ptr->pass_wall = FALSE;
2898                 if (riding_r_ptr->flags2 & RF2_KILL_WALL) creature_ptr->kill_wall = TRUE;
2899
2900                 if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED)
2901                         j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
2902
2903                 count = 1500 + riding_r_ptr->level * 25;
2904         }
2905
2906         if (j > count) new_speed -= ((j - count) / (count / 5));
2907         if (creature_ptr->action == ACTION_SEARCH) new_speed -= 10;
2908         if (creature_ptr->prace == RACE_MERFOLK)
2909         {
2910                 if (have_flag(f_ptr->flags, FF_WATER))
2911                 {
2912                         new_speed += (2 + creature_ptr->lev / 10);
2913                 }
2914                 else if (!creature_ptr->levitation)
2915                 {
2916                         new_speed -= 2;
2917                 }
2918         }
2919
2920         creature_ptr->to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2921         creature_ptr->to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2922         creature_ptr->to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2923         creature_ptr->to_d_m += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2924         creature_ptr->to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2925         creature_ptr->to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2926         creature_ptr->to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2927         creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2928         creature_ptr->to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2929         creature_ptr->to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2930         creature_ptr->to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2931         creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2932         creature_ptr->dis_to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
2933         creature_ptr->dis_to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2934         creature_ptr->dis_to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
2935         creature_ptr->dis_to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2936         creature_ptr->dis_to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2937         creature_ptr->dis_to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2938         creature_ptr->dis_to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2939         creature_ptr->dis_to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2940         creature_ptr->dis_to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
2941
2942         hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
2943         o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2944         creature_ptr->heavy_shoot = is_heavy_shoot(creature_ptr, o_ptr);
2945         if (creature_ptr->heavy_shoot)
2946         {
2947                 creature_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
2948                 creature_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
2949         }
2950
2951         if (o_ptr->k_idx)
2952         {
2953                 creature_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
2954                 if (o_ptr->k_idx && !creature_ptr->heavy_shoot)
2955                 {
2956                         creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
2957                         if ((creature_ptr->pclass == CLASS_SNIPER) &&
2958                                 (creature_ptr->tval_ammo == TV_BOLT))
2959                         {
2960                                 creature_ptr->to_h_b += (10 + (creature_ptr->lev / 5));
2961                                 creature_ptr->dis_to_h_b += (10 + (creature_ptr->lev / 5));
2962                         }
2963                 }
2964         }
2965
2966         if (creature_ptr->ryoute) hold *= 2;
2967         for (int i = 0; i < 2; i++)
2968         {
2969                 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
2970                 object_flags(o_ptr, flgs);
2971                 creature_ptr->heavy_wield[i] = FALSE;
2972                 creature_ptr->icky_wield[i] = FALSE;
2973                 creature_ptr->riding_wield[i] = FALSE;
2974                 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
2975                 {
2976                         creature_ptr->num_blow[i] = 1;
2977                         continue;
2978                 }
2979
2980                 if (hold < o_ptr->weight / 10)
2981                 {
2982                         creature_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
2983                         creature_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
2984                         creature_ptr->heavy_wield[i] = TRUE;
2985                 }
2986                 else if (creature_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
2987
2988                 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
2989                 {
2990                         creature_ptr->to_a += 5;
2991                         creature_ptr->dis_to_a += 5;
2992                 }
2993
2994                 if (o_ptr->k_idx && !creature_ptr->heavy_wield[i])
2995                 {
2996                         int str_index, dex_index;
2997                         int num = 0, wgt = 0, mul = 0, div = 0;
2998                         switch (creature_ptr->pclass)
2999                         {
3000                         case CLASS_WARRIOR:
3001                                 num = 6; wgt = 70; mul = 5; break;
3002
3003                         case CLASS_BERSERKER:
3004                                 num = 6; wgt = 70; mul = 7; break;
3005
3006                         case CLASS_MAGE:
3007                         case CLASS_HIGH_MAGE:
3008                         case CLASS_BLUE_MAGE:
3009                                 num = 3; wgt = 100; mul = 2; break;
3010
3011                         case CLASS_PRIEST:
3012                         case CLASS_MAGIC_EATER:
3013                         case CLASS_MINDCRAFTER:
3014                                 num = 5; wgt = 100; mul = 3; break;
3015
3016                         case CLASS_ROGUE:
3017                                 num = 5; wgt = 40; mul = 3; break;
3018
3019                         case CLASS_RANGER:
3020                                 num = 5; wgt = 70; mul = 4; break;
3021
3022                         case CLASS_PALADIN:
3023                         case CLASS_SAMURAI:
3024                                 num = 5; wgt = 70; mul = 4; break;
3025
3026                         case CLASS_SMITH:
3027                                 num = 5; wgt = 150; mul = 5; break;
3028
3029                         case CLASS_WARRIOR_MAGE:
3030                         case CLASS_RED_MAGE:
3031                                 num = 5; wgt = 70; mul = 3; break;
3032
3033                         case CLASS_CHAOS_WARRIOR:
3034                                 num = 5; wgt = 70; mul = 4; break;
3035
3036                         case CLASS_MONK:
3037                                 num = 5; wgt = 60; mul = 3; break;
3038
3039                         case CLASS_TOURIST:
3040                                 num = 4; wgt = 100; mul = 3; break;
3041
3042                         case CLASS_IMITATOR:
3043                                 num = 5; wgt = 70; mul = 4; break;
3044
3045                         case CLASS_BEASTMASTER:
3046                                 num = 5; wgt = 70; mul = 3; break;
3047
3048                         case CLASS_CAVALRY:
3049                                 if ((creature_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
3050                                 else { num = 5; wgt = 100; mul = 3; }
3051                                 break;
3052
3053                         case CLASS_SORCERER:
3054                                 num = 1; wgt = 1; mul = 1; break;
3055
3056                         case CLASS_ARCHER:
3057                         case CLASS_BARD:
3058                         case CLASS_SNIPER:
3059                                 num = 4; wgt = 70; mul = 2; break;
3060
3061                         case CLASS_FORCETRAINER:
3062                                 num = 4; wgt = 60; mul = 2; break;
3063
3064                         case CLASS_MIRROR_MASTER:
3065                                 num = 3; wgt = 100; mul = 3; break;
3066
3067                         case CLASS_NINJA:
3068                                 num = 4; wgt = 20; mul = 1; break;
3069                         }
3070
3071                         if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING))
3072                         {
3073                                 num++;
3074                                 wgt /= 2;
3075                                 mul += 2;
3076                         }
3077
3078                         div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
3079                         str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
3080
3081                         if (creature_ptr->ryoute && !omoi) str_index++;
3082                         if (creature_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
3083                         if (str_index > 11) str_index = 11;
3084
3085                         dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
3086                         if (dex_index > 11) dex_index = 11;
3087
3088                         creature_ptr->num_blow[i] = blows_table[str_index][dex_index];
3089                         if (creature_ptr->num_blow[i] > num) creature_ptr->num_blow[i] = (s16b)num;
3090
3091                         creature_ptr->num_blow[i] += (s16b)extra_blows[i];
3092                         if (creature_ptr->pclass == CLASS_WARRIOR) creature_ptr->num_blow[i] += (creature_ptr->lev / 40);
3093                         else if (creature_ptr->pclass == CLASS_BERSERKER)
3094                                 creature_ptr->num_blow[i] += (creature_ptr->lev / 23);
3095                         else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
3096                                 creature_ptr->num_blow[i] ++;
3097
3098                         if (creature_ptr->special_defense & KATA_FUUJIN)
3099                                 creature_ptr->num_blow[i] -= 1;
3100
3101                         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
3102                                 creature_ptr->num_blow[i] = 1;
3103
3104                         if (creature_ptr->num_blow[i] < 1)
3105                                 creature_ptr->num_blow[i] = 1;
3106
3107                         creature_ptr->skill_dig += (o_ptr->weight / 10);
3108                 }
3109
3110                 if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
3111                         ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
3112                 {
3113                         creature_ptr->to_h[i] -= 2;
3114                         creature_ptr->to_d[i] -= 2;
3115                         creature_ptr->dis_to_h[i] -= 2;
3116                         creature_ptr->dis_to_d[i] -= 2;
3117                         creature_ptr->icky_wield[i] = TRUE;
3118                 }
3119                 else if (creature_ptr->pclass == CLASS_BERSERKER)
3120                 {
3121                         creature_ptr->to_h[i] += creature_ptr->lev / 5;
3122                         creature_ptr->to_d[i] += creature_ptr->lev / 6;
3123                         creature_ptr->dis_to_h[i] += creature_ptr->lev / 5;
3124                         creature_ptr->dis_to_d[i] += creature_ptr->lev / 6;
3125                         if (((i == 0) && !creature_ptr->hidarite) || creature_ptr->ryoute)
3126                         {
3127                                 creature_ptr->to_h[i] += creature_ptr->lev / 5;
3128                                 creature_ptr->to_d[i] += creature_ptr->lev / 6;
3129                                 creature_ptr->dis_to_h[i] += creature_ptr->lev / 5;
3130                                 creature_ptr->dis_to_d[i] += creature_ptr->lev / 6;
3131                         }
3132                 }
3133                 else if (creature_ptr->pclass == CLASS_SORCERER)
3134                 {
3135                         if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
3136                         {
3137                                 creature_ptr->to_h[i] -= 200;
3138                                 creature_ptr->to_d[i] -= 200;
3139                                 creature_ptr->dis_to_h[i] -= 200;
3140                                 creature_ptr->dis_to_d[i] -= 200;
3141                                 creature_ptr->icky_wield[i] = TRUE;
3142                         }
3143                         else
3144                         {
3145                                 creature_ptr->to_h[i] -= 30;
3146                                 creature_ptr->to_d[i] -= 10;
3147                                 creature_ptr->dis_to_h[i] -= 30;
3148                                 creature_ptr->dis_to_d[i] -= 10;
3149                         }
3150                 }
3151
3152                 if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr))
3153                 {
3154                         if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
3155                         if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_h[i] += 7; creature_ptr->dis_to_h[i] += 7; }
3156                         if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_h[i] += 13; creature_ptr->dis_to_h[i] += 13; }
3157                         if (o_ptr->curse_flags & (TRC_TY_CURSE)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
3158                         if (hex_spelling(creature_ptr, HEX_RUNESWORD))
3159                         {
3160                                 if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_d[i] += 5; creature_ptr->dis_to_d[i] += 5; }
3161                                 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_d[i] += 7; creature_ptr->dis_to_d[i] += 7; }
3162                                 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_d[i] += 13; creature_ptr->dis_to_d[i] += 13; }
3163                         }
3164                 }
3165
3166                 if (creature_ptr->riding == 0) continue;
3167
3168                 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
3169                 {
3170                         creature_ptr->to_h[i] += 15;
3171                         creature_ptr->dis_to_h[i] += 15;
3172                         creature_ptr->to_dd[i] += 2;
3173                         continue;
3174                 }
3175
3176                 if (have_flag(flgs, TR_RIDING)) continue;
3177
3178                 int penalty;
3179                 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
3180                 {
3181                         penalty = 5;
3182                 }
3183                 else
3184                 {
3185                         penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3186                         penalty += 30;
3187                         if (penalty < 30) penalty = 30;
3188                 }
3189
3190                 creature_ptr->to_h[i] -= (s16b)penalty;
3191                 creature_ptr->dis_to_h[i] -= (s16b)penalty;
3192                 creature_ptr->riding_wield[i] = TRUE;
3193         }
3194
3195         if (creature_ptr->riding)
3196         {
3197                 int penalty = 0;
3198
3199                 creature_ptr->riding_ryoute = FALSE;
3200
3201                 if (creature_ptr->ryoute || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE)) creature_ptr->riding_ryoute = TRUE;
3202                 else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
3203                 {
3204                         switch (creature_ptr->pclass)
3205                         {
3206                         case CLASS_MONK:
3207                         case CLASS_FORCETRAINER:
3208                         case CLASS_BERSERKER:
3209                                 if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
3210                                         creature_ptr->riding_ryoute = TRUE;
3211                                 break;
3212                         }
3213                 }
3214
3215                 if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
3216                 {
3217                         if (creature_ptr->tval_ammo != TV_ARROW) penalty = 5;
3218                 }
3219                 else
3220                 {
3221                         penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
3222                         penalty += 30;
3223                         if (penalty < 30) penalty = 30;
3224                 }
3225
3226                 if (creature_ptr->tval_ammo == TV_BOLT) penalty *= 2;
3227                 creature_ptr->to_h_b -= (s16b)penalty;
3228                 creature_ptr->dis_to_h_b -= (s16b)penalty;
3229         }
3230
3231         /* Different calculation for monks with empty hands */
3232         if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER)) &&
3233                 (empty_hands_status & EMPTY_HAND_RARM) && !creature_ptr->hidarite)
3234         {
3235                 int blow_base = creature_ptr->lev + adj_dex_blow[creature_ptr->stat_ind[A_DEX]];
3236                 creature_ptr->num_blow[0] = 0;
3237
3238                 if (creature_ptr->pclass == CLASS_FORCETRAINER)
3239                 {
3240                         if (blow_base > 18) creature_ptr->num_blow[0]++;
3241                         if (blow_base > 31) creature_ptr->num_blow[0]++;
3242                         if (blow_base > 44) creature_ptr->num_blow[0]++;
3243                         if (blow_base > 58) creature_ptr->num_blow[0]++;
3244                         if (P_PTR_KI)
3245                         {
3246                                 creature_ptr->to_d[0] += P_PTR_KI / 5;
3247                                 creature_ptr->dis_to_d[0] += P_PTR_KI / 5;
3248                         }
3249                 }
3250                 else
3251                 {
3252                         if (blow_base > 12) creature_ptr->num_blow[0]++;
3253                         if (blow_base > 22) creature_ptr->num_blow[0]++;
3254                         if (blow_base > 31) creature_ptr->num_blow[0]++;
3255                         if (blow_base > 39) creature_ptr->num_blow[0]++;
3256                         if (blow_base > 46) creature_ptr->num_blow[0]++;
3257                         if (blow_base > 53) creature_ptr->num_blow[0]++;
3258                         if (blow_base > 59) creature_ptr->num_blow[0]++;
3259                 }
3260
3261                 if (heavy_armor(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER))
3262                         creature_ptr->num_blow[0] /= 2;
3263                 else
3264                 {
3265                         creature_ptr->to_h[0] += (creature_ptr->lev / 3);
3266                         creature_ptr->dis_to_h[0] += (creature_ptr->lev / 3);
3267
3268                         creature_ptr->to_d[0] += (creature_ptr->lev / 6);
3269                         creature_ptr->dis_to_d[0] += (creature_ptr->lev / 6);
3270                 }
3271
3272                 if (creature_ptr->special_defense & KAMAE_BYAKKO)
3273                 {
3274                         creature_ptr->to_a -= 40;
3275                         creature_ptr->dis_to_a -= 40;
3276
3277                 }
3278                 else if (creature_ptr->special_defense & KAMAE_SEIRYU)
3279                 {
3280                         creature_ptr->to_a -= 50;
3281                         creature_ptr->dis_to_a -= 50;
3282                         creature_ptr->resist_acid = TRUE;
3283                         creature_ptr->resist_fire = TRUE;
3284                         creature_ptr->resist_elec = TRUE;
3285                         creature_ptr->resist_cold = TRUE;
3286                         creature_ptr->resist_pois = TRUE;
3287                         creature_ptr->sh_fire = TRUE;
3288                         creature_ptr->sh_elec = TRUE;
3289                         creature_ptr->sh_cold = TRUE;
3290                         creature_ptr->levitation = TRUE;
3291                 }
3292                 else if (creature_ptr->special_defense & KAMAE_GENBU)
3293                 {
3294                         creature_ptr->to_a += (creature_ptr->lev*creature_ptr->lev) / 50;
3295                         creature_ptr->dis_to_a += (creature_ptr->lev*creature_ptr->lev) / 50;
3296                         creature_ptr->reflect = TRUE;
3297                         creature_ptr->num_blow[0] -= 2;
3298                         if ((creature_ptr->pclass == CLASS_MONK) && (creature_ptr->lev > 42)) creature_ptr->num_blow[0]--;
3299                         if (creature_ptr->num_blow[0] < 0) creature_ptr->num_blow[0] = 0;
3300                 }
3301                 else if (creature_ptr->special_defense & KAMAE_SUZAKU)
3302                 {
3303                         creature_ptr->to_h[0] -= (creature_ptr->lev / 3);
3304                         creature_ptr->to_d[0] -= (creature_ptr->lev / 6);
3305
3306                         creature_ptr->dis_to_h[0] -= (creature_ptr->lev / 3);
3307                         creature_ptr->dis_to_d[0] -= (creature_ptr->lev / 6);
3308                         creature_ptr->num_blow[0] /= 2;
3309                         creature_ptr->levitation = TRUE;
3310                 }
3311
3312                 creature_ptr->num_blow[0] += 1 + extra_blows[0];
3313         }
3314
3315         if (creature_ptr->riding) creature_ptr->levitation = riding_levitation;
3316
3317         creature_ptr->monk_armour_aux = FALSE;
3318
3319         if (heavy_armor(creature_ptr))
3320         {
3321                 creature_ptr->monk_armour_aux = TRUE;
3322         }
3323
3324         for (int i = 0; i < 2; i++)
3325         {
3326                 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
3327
3328                 OBJECT_TYPE_VALUE tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
3329                 OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
3330
3331                 creature_ptr->to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3332                 creature_ptr->dis_to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
3333                 if ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER))
3334                 {
3335                         if (!s_info[creature_ptr->pclass].w_max[tval][sval])
3336                         {
3337                                 creature_ptr->to_h[i] -= 40;
3338                                 creature_ptr->dis_to_h[i] -= 40;
3339                                 creature_ptr->icky_wield[i] = TRUE;
3340                         }
3341
3342                         continue;
3343                 }
3344
3345                 if (creature_ptr->pclass != CLASS_NINJA) continue;
3346
3347                 if ((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD))
3348                         continue;
3349
3350                 creature_ptr->to_h[i] -= 40;
3351                 creature_ptr->dis_to_h[i] -= 40;
3352                 creature_ptr->icky_wield[i] = TRUE;
3353                 creature_ptr->num_blow[i] /= 2;
3354                 if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1;
3355         }
3356
3357         /* Maximum speed is (+99). (internally it's 110 + 99) */
3358         /* Temporary lightspeed forces to be maximum speed */
3359         if ((creature_ptr->lightspeed && !creature_ptr->riding) || (new_speed > 209))
3360         {
3361                 new_speed = 209;
3362         }
3363
3364         /* Minimum speed is (-99). (internally it's 110 - 99) */
3365         if (new_speed < 11) new_speed = 11;
3366
3367         if (creature_ptr->pspeed != (byte)new_speed)
3368         {
3369                 creature_ptr->pspeed = (byte)new_speed;
3370                 creature_ptr->redraw |= (PR_SPEED);
3371         }
3372
3373         if (yoiyami)
3374         {
3375                 if (creature_ptr->to_a > (0 - creature_ptr->ac))
3376                         creature_ptr->to_a = 0 - creature_ptr->ac;
3377                 if (creature_ptr->dis_to_a > (0 - creature_ptr->dis_ac))
3378                         creature_ptr->dis_to_a = 0 - creature_ptr->dis_ac;
3379         }
3380
3381         if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a))
3382         {
3383                 creature_ptr->redraw |= (PR_ARMOR);
3384                 creature_ptr->window |= (PW_PLAYER);
3385         }
3386
3387         if (creature_ptr->ryoute && !omoi)
3388         {
3389                 int bonus_to_h = 0, bonus_to_d = 0;
3390                 bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
3391                 bonus_to_h = ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
3392
3393                 creature_ptr->to_h[default_hand] += MAX(bonus_to_h, 1);
3394                 creature_ptr->dis_to_h[default_hand] += MAX(bonus_to_h, 1);
3395                 creature_ptr->to_d[default_hand] += MAX(bonus_to_d, 1);
3396                 creature_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
3397         }
3398
3399         bool is_special_class = creature_ptr->pclass == CLASS_MONK;
3400         is_special_class |= creature_ptr->pclass == CLASS_FORCETRAINER;
3401         is_special_class |= creature_ptr->pclass == CLASS_BERSERKER;
3402         if (is_special_class && (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)))
3403                 creature_ptr->ryoute = FALSE;
3404
3405         creature_ptr->skill_stl += 1;
3406
3407         if (is_time_limit_stealth(creature_ptr))
3408                 creature_ptr->skill_stl += 99;
3409
3410         creature_ptr->skill_dis += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
3411         creature_ptr->skill_dis += adj_int_dis[creature_ptr->stat_ind[A_INT]];
3412         creature_ptr->skill_dev += adj_int_dev[creature_ptr->stat_ind[A_INT]];
3413         creature_ptr->skill_sav += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
3414         creature_ptr->skill_dig += adj_str_dig[creature_ptr->stat_ind[A_STR]];
3415         creature_ptr->skill_dis += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
3416         creature_ptr->skill_dev += ((cp_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
3417         creature_ptr->skill_sav += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
3418         creature_ptr->skill_stl += (cp_ptr->x_stl * creature_ptr->lev / 10);
3419         creature_ptr->skill_srh += (cp_ptr->x_srh * creature_ptr->lev / 10);
3420         creature_ptr->skill_fos += (cp_ptr->x_fos * creature_ptr->lev / 10);
3421         creature_ptr->skill_thn += ((cp_ptr->x_thn * creature_ptr->lev / 10) + (ap_ptr->a_thn * creature_ptr->lev / 50));
3422         creature_ptr->skill_thb += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
3423         creature_ptr->skill_tht += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
3424
3425         if ((PRACE_IS_(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != SEIKAKU_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE))
3426         {
3427                 creature_ptr->cursed &= ~(TRC_AGGRAVATE);
3428                 creature_ptr->skill_stl = MIN(creature_ptr->skill_stl - 3, (creature_ptr->skill_stl + 2) / 2);
3429         }
3430
3431         if (creature_ptr->skill_stl > 30) creature_ptr->skill_stl = 30;
3432         if (creature_ptr->skill_stl < 0) creature_ptr->skill_stl = 0;
3433         if (creature_ptr->skill_dig < 1) creature_ptr->skill_dig = 1;
3434         if (creature_ptr->anti_magic && (creature_ptr->skill_sav < (90 + creature_ptr->lev)))
3435                 creature_ptr->skill_sav = 90 + creature_ptr->lev;
3436         if (creature_ptr->tsubureru) creature_ptr->skill_sav = 10;
3437         if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (creature_ptr->skill_sav < (95 + creature_ptr->lev)))
3438                 creature_ptr->skill_sav = 95 + creature_ptr->lev;
3439
3440         if (down_saving) creature_ptr->skill_sav /= 2;
3441
3442         if (creature_ptr->immune_acid) creature_ptr->resist_acid = TRUE;
3443         if (creature_ptr->immune_elec) creature_ptr->resist_elec = TRUE;
3444         if (creature_ptr->immune_fire) creature_ptr->resist_fire = TRUE;
3445         if (creature_ptr->immune_cold) creature_ptr->resist_cold = TRUE;
3446
3447         if (current_world_ptr->character_xtra) return;
3448
3449         if (creature_ptr->old_heavy_shoot != creature_ptr->heavy_shoot)
3450         {
3451                 if (creature_ptr->heavy_shoot)
3452                 {
3453                         msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
3454                 }
3455                 else if (creature_ptr->inventory_list[INVEN_BOW].k_idx)
3456                 {
3457                         msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
3458                 }
3459                 else
3460                 {
3461                         msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
3462                 }
3463
3464                 creature_ptr->old_heavy_shoot = creature_ptr->heavy_shoot;
3465         }
3466
3467         for (int i = 0; i < 2; i++)
3468         {
3469                 if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i])
3470                 {
3471                         if (creature_ptr->heavy_wield[i])
3472                         {
3473                                 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
3474                         }
3475                         else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3476                         {
3477                                 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
3478                         }
3479                         else if (creature_ptr->heavy_wield[1 - i])
3480                         {
3481                                 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
3482                         }
3483                         else
3484                         {
3485                                 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
3486                         }
3487
3488                         creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
3489                 }
3490
3491                 if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i])
3492                 {
3493                         if (creature_ptr->riding_wield[i])
3494                         {
3495                                 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
3496                         }
3497                         else if (!creature_ptr->riding)
3498                         {
3499                                 msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
3500                         }
3501                         else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3502                         {
3503                                 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
3504                         }
3505
3506                         creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
3507                 }
3508
3509                 if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i])
3510                         continue;
3511
3512                 if (creature_ptr->icky_wield[i])
3513                 {
3514                         msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
3515                         if (current_world_ptr->is_loading_now)
3516                         {
3517                                 chg_virtue(creature_ptr, V_FAITH, -1);
3518                         }
3519                 }
3520                 else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
3521                 {
3522                         msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
3523                 }
3524                 else
3525                 {
3526                         msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
3527                 }
3528
3529                 creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
3530         }
3531
3532         if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute))
3533         {
3534                 if (creature_ptr->riding_ryoute)
3535                 {
3536 #ifdef JP
3537                         msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
3538 #else
3539                         msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
3540 #endif
3541                 }
3542                 else
3543                 {
3544 #ifdef JP
3545                         msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
3546 #else
3547                         msg_print("You began to control the pet you're riding with one hand.");
3548 #endif
3549                 }
3550
3551                 creature_ptr->old_riding_ryoute = creature_ptr->riding_ryoute;
3552         }
3553
3554         if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_NINJA)) && (creature_ptr->monk_armour_aux != creature_ptr->monk_notify_aux))
3555         {
3556                 if (heavy_armor(creature_ptr))
3557                 {
3558                         msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
3559                         if (current_world_ptr->is_loading_now)
3560                         {
3561                                 chg_virtue(creature_ptr, V_HARMONY, -1);
3562                         }
3563                 }
3564                 else
3565                 {
3566                         msg_print(_("バランスがとれるようになった。", "You regain your balance."));
3567                 }
3568
3569                 creature_ptr->monk_notify_aux = creature_ptr->monk_armour_aux;
3570         }
3571
3572         for (int i = 0; i < INVEN_PACK; i++)
3573         {
3574                 if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_sw = TRUE;
3575                 if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_kabe = TRUE;
3576         }
3577
3578         for (this_o_idx = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3579         {
3580                 o_ptr = &floor_ptr->o_list[this_o_idx];
3581                 next_o_idx = o_ptr->next_o_idx;
3582
3583                 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
3584                 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
3585         }
3586
3587         if (creature_ptr->pass_wall && !creature_ptr->kill_wall) creature_ptr->no_flowed = TRUE;
3588
3589         if (have_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER)))
3590         {
3591                 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
3592                 if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
3593         }
3594
3595         if (have_kabe && ((creature_ptr->realm1 == REALM_CRAFT) || (creature_ptr->realm2 == REALM_CRAFT) || (creature_ptr->pclass == CLASS_SORCERER)))
3596         {
3597                 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_KABE];
3598                 if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
3599         }
3600 }
3601
3602
3603 static void calc_alignment(player_type *creature_ptr)
3604 {
3605         creature_ptr->align = 0;
3606         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
3607         for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
3608         {
3609                 monster_type *m_ptr;
3610                 monster_race *r_ptr;
3611                 m_ptr = &floor_ptr->m_list[m_idx];
3612                 if (!monster_is_valid(m_ptr)) continue;
3613                 r_ptr = &r_info[m_ptr->r_idx];
3614
3615                 if (!is_pet(m_ptr)) continue;
3616
3617                 if (r_ptr->flags3 & RF3_GOOD) creature_ptr->align += r_ptr->level;
3618                 if (r_ptr->flags3 & RF3_EVIL) creature_ptr->align -= r_ptr->level;
3619         }
3620
3621         if (creature_ptr->mimic_form)
3622         {
3623                 switch (creature_ptr->mimic_form)
3624                 {
3625                 case MIMIC_DEMON:
3626                         creature_ptr->align -= 200;
3627                         break;
3628                 case MIMIC_DEMON_LORD:
3629                         creature_ptr->align -= 200;
3630                         break;
3631                 }
3632         }
3633         else
3634         {
3635                 switch (creature_ptr->prace)
3636                 {
3637                 case RACE_ANGEL:
3638                         creature_ptr->align += 200;
3639                         break;
3640                 case RACE_DEMON:
3641                         creature_ptr->align -= 200;
3642                         break;
3643                 }
3644         }
3645
3646         for (int i = 0; i < 2; i++)
3647         {
3648                 if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
3649                 if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL) continue;
3650                 creature_ptr->align -= 1000;
3651         }
3652
3653         int j = 0;
3654         int neutral[2];
3655         for (int i = 0; i < 8; i++)
3656         {
3657                 switch (creature_ptr->vir_types[i])
3658                 {
3659                 case V_JUSTICE:
3660                         creature_ptr->align += creature_ptr->virtues[i] * 2;
3661                         break;
3662                 case V_CHANCE:
3663                         break;
3664                 case V_NATURE:
3665                 case V_HARMONY:
3666                         neutral[j++] = i;
3667                         break;
3668                 case V_UNLIFE:
3669                         creature_ptr->align -= creature_ptr->virtues[i];
3670                         break;
3671                 default:
3672                         creature_ptr->align += creature_ptr->virtues[i];
3673                         break;
3674                 }
3675         }
3676
3677         for (int i = 0; i < j; i++)
3678         {
3679                 if (creature_ptr->align > 0)
3680                 {
3681                         creature_ptr->align -= creature_ptr->virtues[neutral[i]] / 2;
3682                         if (creature_ptr->align < 0) creature_ptr->align = 0;
3683                 }
3684                 else if (creature_ptr->align < 0)
3685                 {
3686                         creature_ptr->align += creature_ptr->virtues[neutral[i]] / 2;
3687                         if (creature_ptr->align > 0) creature_ptr->align = 0;
3688                 }
3689         }
3690 }
3691
3692
3693 /*!
3694  * @brief プレイヤーの最大HPを計算する /
3695  * Calculate the players (maximal) hit points
3696  * Adjust current hitpoints if necessary
3697  * @return なし
3698  * @details
3699  */
3700 static void calc_hitpoints(player_type *creature_ptr)
3701 {
3702         int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
3703         int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
3704
3705         byte tmp_hitdie;
3706         if (creature_ptr->mimic_form)
3707         {
3708                 if (creature_ptr->pclass == CLASS_SORCERER)
3709                         tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
3710                 else
3711                         tmp_hitdie = mimic_info[creature_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3712                 mhp = mhp * tmp_hitdie / creature_ptr->hitdie;
3713         }
3714
3715         if (creature_ptr->pclass == CLASS_SORCERER)
3716         {
3717                 if (creature_ptr->lev < 30)
3718                         mhp = (mhp * (45 + creature_ptr->lev) / 100);
3719                 else
3720                         mhp = (mhp * 75 / 100);
3721                 bonus = (bonus * 65 / 100);
3722         }
3723
3724         mhp += bonus;
3725
3726         if (creature_ptr->pclass == CLASS_BERSERKER)
3727         {
3728                 mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
3729         }
3730
3731         if (mhp < creature_ptr->lev + 1) mhp = creature_ptr->lev + 1;
3732         if (IS_HERO(creature_ptr)) mhp += 10;
3733         if (creature_ptr->shero && (creature_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
3734         if (creature_ptr->tsuyoshi) mhp += 50;
3735         if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) mhp += 15;
3736         if (hex_spelling(creature_ptr, HEX_BUILDING)) mhp += 60;
3737         if (creature_ptr->mhp == mhp) return;
3738
3739         if (creature_ptr->chp >= mhp)
3740         {
3741                 creature_ptr->chp = mhp;
3742                 creature_ptr->chp_frac = 0;
3743         }
3744
3745 #ifdef JP
3746         if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp))
3747         {
3748                 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
3749         }
3750 #endif
3751         creature_ptr->mhp = mhp;
3752
3753         creature_ptr->redraw |= PR_HP;
3754         creature_ptr->window |= PW_PLAYER;
3755 }
3756
3757
3758 /*!
3759  * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
3760  * @return なし
3761  * @details
3762  * SWD: Experimental modification: multiple light sources have additive effect.
3763  */
3764 static void calc_torch(player_type *creature_ptr)
3765 {
3766         creature_ptr->cur_lite = 0;
3767         for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
3768         {
3769                 object_type *o_ptr;
3770                 o_ptr = &creature_ptr->inventory_list[i];
3771                 if (!o_ptr->k_idx) continue;
3772
3773                 if (o_ptr->name2 == EGO_LITE_SHINE) creature_ptr->cur_lite++;
3774                 if (o_ptr->name2 != EGO_LITE_DARKNESS)
3775                 {
3776                         if (o_ptr->tval == TV_LITE)
3777                         {
3778                                 if ((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
3779                                 if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
3780                         }
3781                 }
3782
3783                 BIT_FLAGS flgs[TR_FLAG_SIZE];
3784                 object_flags(o_ptr, flgs);
3785
3786                 POSITION rad = 0;
3787                 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
3788                 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
3789                 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
3790                 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
3791                 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
3792                 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
3793                 creature_ptr->cur_lite += rad;
3794         }
3795
3796         if (d_info[creature_ptr->dungeon_idx].flags1 & DF1_DARKNESS && creature_ptr->cur_lite > 1)
3797                 creature_ptr->cur_lite = 1;
3798
3799         if (creature_ptr->cur_lite <= 0 && creature_ptr->lite)
3800                 creature_ptr->cur_lite++;
3801
3802         if (creature_ptr->cur_lite > 14)
3803                 creature_ptr->cur_lite = 14;
3804
3805         if (creature_ptr->cur_lite < 0)
3806                 creature_ptr->cur_lite = 0;
3807
3808         if (creature_ptr->old_lite == creature_ptr->cur_lite)
3809                 return;
3810
3811         creature_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
3812         creature_ptr->old_lite = creature_ptr->cur_lite;
3813
3814         if ((creature_ptr->cur_lite > 0) && (creature_ptr->special_defense & NINJA_S_STEALTH))
3815                 set_superstealth(creature_ptr, FALSE);
3816 }
3817
3818
3819 /*!
3820  * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
3821  * Calculate number of spells player should have, and forget,
3822  * or remember, spells until that number is properly reflected.
3823  * @return なし
3824  * @details
3825  * Note that this function induces various "status" messages,
3826  * which must be bypasses until the character is created.
3827  */
3828 static void calc_spells(player_type *creature_ptr)
3829 {
3830         if (!mp_ptr->spell_book) return;
3831         if (!current_world_ptr->character_generated) return;
3832         if (current_world_ptr->character_xtra) return;
3833         if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE))
3834         {
3835                 creature_ptr->new_spells = 0;
3836                 return;
3837         }
3838
3839         concptr p = spell_category_name(mp_ptr->spell_book);
3840         int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
3841         if (levels < 0) levels = 0;
3842
3843         int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
3844         int bonus = 0;
3845         if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
3846         {
3847                 bonus = 4;
3848         }
3849
3850         if (creature_ptr->pclass == CLASS_SAMURAI)
3851         {
3852                 num_allowed = 32;
3853         }
3854         else if (creature_ptr->realm2 == REALM_NONE)
3855         {
3856                 num_allowed = (num_allowed + 1) / 2;
3857                 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
3858         }
3859         else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST))
3860         {
3861                 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
3862         }
3863         else
3864         {
3865                 if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
3866         }
3867
3868         int num_boukyaku = 0;
3869         for (int j = 0; j < 64; j++)
3870         {
3871                 if ((j < 32) ?
3872                         (creature_ptr->spell_forgotten1 & (1L << j)) :
3873                         (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
3874                 {
3875                         num_boukyaku++;
3876                 }
3877         }
3878
3879         creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
3880         for (int i = 63; i >= 0; i--)
3881         {
3882                 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
3883
3884                 int j = creature_ptr->spell_order[i];
3885                 if (j >= 99) continue;
3886
3887                 const magic_type *s_ptr;
3888                 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
3889                 {
3890                         if (j < 32)
3891                                 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3892                         else
3893                                 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
3894                 }
3895                 else if (j < 32)
3896                         s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
3897                 else
3898                         s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
3899
3900                 if (s_ptr->slevel <= creature_ptr->lev) continue;
3901
3902                 bool is_spell_learned = (j < 32) ?
3903                         (creature_ptr->spell_learned1 & (1L << j)) :
3904                         (creature_ptr->spell_learned2 & (1L << (j - 32)));
3905                 if (!is_spell_learned) continue;
3906
3907                 REALM_IDX which;
3908                 if (j < 32)
3909                 {
3910                         creature_ptr->spell_forgotten1 |= (1L << j);
3911                         which = creature_ptr->realm1;
3912                 }
3913                 else
3914                 {
3915                         creature_ptr->spell_forgotten2 |= (1L << (j - 32));
3916                         which = creature_ptr->realm2;
3917                 }
3918
3919                 if (j < 32)
3920                 {
3921                         creature_ptr->spell_learned1 &= ~(1L << j);
3922                         which = creature_ptr->realm1;
3923                 }
3924                 else
3925                 {
3926                         creature_ptr->spell_learned2 &= ~(1L << (j - 32));
3927                         which = creature_ptr->realm2;
3928                 }
3929
3930 #ifdef JP
3931                 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3932 #else
3933                 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3934 #endif
3935                 creature_ptr->new_spells++;
3936         }
3937
3938         /* Forget spells if we know too many spells */
3939         for (int i = 63; i >= 0; i--)
3940         {
3941                 if (creature_ptr->new_spells >= 0) break;
3942                 if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
3943
3944                 int j = creature_ptr->spell_order[i];
3945                 if (j >= 99) continue;
3946
3947                 bool is_spell_learned = (j < 32) ?
3948                         (creature_ptr->spell_learned1 & (1L << j)) :
3949                         (creature_ptr->spell_learned2 & (1L << (j - 32)));
3950                 if (!is_spell_learned) continue;
3951
3952                 REALM_IDX which;
3953                 if (j < 32)
3954                 {
3955                         creature_ptr->spell_forgotten1 |= (1L << j);
3956                         which = creature_ptr->realm1;
3957                 }
3958                 else
3959                 {
3960                         creature_ptr->spell_forgotten2 |= (1L << (j - 32));
3961                         which = creature_ptr->realm2;
3962                 }
3963
3964                 if (j < 32)
3965                 {
3966                         creature_ptr->spell_learned1 &= ~(1L << j);
3967                         which = creature_ptr->realm1;
3968                 }
3969                 else
3970                 {
3971                         creature_ptr->spell_learned2 &= ~(1L << (j - 32));
3972                         which = creature_ptr->realm2;
3973                 }
3974
3975 #ifdef JP
3976                 msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
3977 #else
3978                 msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
3979 #endif
3980                 creature_ptr->new_spells++;
3981         }
3982
3983         /* Check for spells to remember */
3984         for (int i = 0; i < 64; i++)
3985         {
3986                 if (creature_ptr->new_spells <= 0) break;
3987                 if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2) break;
3988                 int j = creature_ptr->spell_order[i];
3989                 if (j >= 99) break;
3990
3991                 const magic_type *s_ptr;
3992                 if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
3993                 {
3994                         if (j < 32)
3995                                 s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
3996                         else
3997                                 s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
3998                 }
3999                 else if (j < 32)
4000                         s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
4001                 else
4002                         s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
4003
4004                 if (s_ptr->slevel > creature_ptr->lev) continue;
4005
4006                 bool is_spell_learned = (j < 32) ?
4007                         (creature_ptr->spell_forgotten1 & (1L << j)) :
4008                         (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
4009                 if (!is_spell_learned) continue;
4010
4011                 REALM_IDX which;
4012                 if (j < 32)
4013                 {
4014                         creature_ptr->spell_forgotten1 &= ~(1L << j);
4015                         which = creature_ptr->realm1;
4016                 }
4017                 else
4018                 {
4019                         creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
4020                         which = creature_ptr->realm2;
4021                 }
4022
4023                 if (j < 32)
4024                 {
4025                         creature_ptr->spell_learned1 |= (1L << j);
4026                         which = creature_ptr->realm1;
4027                 }
4028                 else
4029                 {
4030                         creature_ptr->spell_learned2 |= (1L << (j - 32));
4031                         which = creature_ptr->realm2;
4032                 }
4033
4034 #ifdef JP
4035                 msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
4036 #else
4037                 msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
4038 #endif
4039                 creature_ptr->new_spells--;
4040         }
4041
4042         if (creature_ptr->realm2 == REALM_NONE)
4043         {
4044                 int k = 0;
4045                 for (int j = 0; j < 32; j++)
4046                 {
4047                         const magic_type *s_ptr;
4048                         if (!is_magic(creature_ptr->realm1)) s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
4049                         else s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
4050
4051                         if (s_ptr->slevel > creature_ptr->lev) continue;
4052
4053                         if (creature_ptr->spell_learned1 & (1L << j))
4054                         {
4055                                 continue;
4056                         }
4057
4058                         k++;
4059                 }
4060
4061                 if (k > 32) k = 32;
4062                 if ((creature_ptr->new_spells > k) &&
4063                         ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
4064                 {
4065                         creature_ptr->new_spells = (s16b)k;
4066                 }
4067         }
4068
4069         if (creature_ptr->new_spells < 0) creature_ptr->new_spells = 0;
4070
4071         if (creature_ptr->old_spells == creature_ptr->new_spells) return;
4072
4073         if (creature_ptr->new_spells)
4074         {
4075 #ifdef JP
4076                 if (creature_ptr->new_spells < 10) {
4077                         msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
4078                 }
4079                 else {
4080                         msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
4081                 }
4082 #else
4083                 msg_format("You can learn %d more %s%s.",
4084                         creature_ptr->new_spells, p,
4085                         (creature_ptr->new_spells != 1) ? "s" : "");
4086 #endif
4087         }
4088
4089         creature_ptr->old_spells = creature_ptr->new_spells;
4090         creature_ptr->redraw |= PR_STUDY;
4091         creature_ptr->window |= PW_OBJECT;
4092 }
4093
4094
4095 /*!
4096  * @brief プレイヤーの最大MPを計算する /
4097  * Calculate maximum mana.  You do not need to know any spells.
4098  * Note that mana is lowered by heavy (or inappropriate) armor.
4099  * @return なし
4100  * @details
4101  * This function induces status messages.
4102  */
4103 static void calc_mana(player_type *creature_ptr)
4104 {
4105         if (!mp_ptr->spell_book) return;
4106
4107         int levels;
4108         if ((creature_ptr->pclass == CLASS_MINDCRAFTER) ||
4109                 (creature_ptr->pclass == CLASS_MIRROR_MASTER) ||
4110                 (creature_ptr->pclass == CLASS_BLUE_MAGE))
4111         {
4112                 levels = creature_ptr->lev;
4113         }
4114         else
4115         {
4116                 if (mp_ptr->spell_first > creature_ptr->lev)
4117                 {
4118                         creature_ptr->msp = 0;
4119                         creature_ptr->redraw |= (PR_MANA);
4120                         return;
4121                 }
4122
4123                 levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
4124         }
4125
4126         int msp;
4127         if (creature_ptr->pclass == CLASS_SAMURAI)
4128         {
4129                 msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
4130                 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
4131         }
4132         else
4133         {
4134                 msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
4135                 if (msp) msp++;
4136                 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
4137                 if (msp && (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
4138                 if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
4139                 if (msp && (creature_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + creature_ptr->lev) / 100;
4140         }
4141
4142         if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
4143         {
4144                 BIT_FLAGS flgs[TR_FLAG_SIZE];
4145                 creature_ptr->cumber_glove = FALSE;
4146                 object_type *o_ptr;
4147                 o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
4148                 object_flags(o_ptr, flgs);
4149                 if (o_ptr->k_idx &&
4150                         !(have_flag(flgs, TR_FREE_ACT)) &&
4151                         !(have_flag(flgs, TR_DEC_MANA)) &&
4152                         !(have_flag(flgs, TR_EASY_SPELL)) &&
4153                         !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
4154                         !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
4155                 {
4156                         creature_ptr->cumber_glove = TRUE;
4157                         msp = (3 * msp) / 4;
4158                 }
4159         }
4160
4161         creature_ptr->cumber_armor = FALSE;
4162
4163         int cur_wgt = 0;
4164         if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4165         if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4166         cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
4167         cur_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
4168         cur_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
4169         cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
4170         cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
4171
4172         switch (creature_ptr->pclass)
4173         {
4174         case CLASS_MAGE:
4175         case CLASS_HIGH_MAGE:
4176         case CLASS_BLUE_MAGE:
4177         case CLASS_MONK:
4178         case CLASS_FORCETRAINER:
4179         case CLASS_SORCERER:
4180         {
4181                 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4182                 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4183                 break;
4184         }
4185         case CLASS_PRIEST:
4186         case CLASS_BARD:
4187         case CLASS_TOURIST:
4188         {
4189                 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight * 2 / 3;
4190                 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
4191                 break;
4192         }
4193         case CLASS_MINDCRAFTER:
4194         case CLASS_BEASTMASTER:
4195         case CLASS_MIRROR_MASTER:
4196         {
4197                 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 2;
4198                 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
4199                 break;
4200         }
4201         case CLASS_ROGUE:
4202         case CLASS_RANGER:
4203         case CLASS_RED_MAGE:
4204         case CLASS_WARRIOR_MAGE:
4205         {
4206                 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 3;
4207                 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
4208                 break;
4209         }
4210         case CLASS_PALADIN:
4211         case CLASS_CHAOS_WARRIOR:
4212         {
4213                 if (creature_ptr->inventory_list[INVEN_RARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight / 5;
4214                 if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
4215                 break;
4216         }
4217         default:
4218         {
4219                 break;
4220         }
4221         }
4222
4223         int max_wgt = mp_ptr->spell_weight;
4224         if ((cur_wgt - max_wgt) > 0)
4225         {
4226                 creature_ptr->cumber_armor = TRUE;
4227                 switch (creature_ptr->pclass)
4228                 {
4229                 case CLASS_MAGE:
4230                 case CLASS_HIGH_MAGE:
4231                 case CLASS_BLUE_MAGE:
4232                 {
4233                         msp -= msp * (cur_wgt - max_wgt) / 600;
4234                         break;
4235                 }
4236                 case CLASS_PRIEST:
4237                 case CLASS_MINDCRAFTER:
4238                 case CLASS_BEASTMASTER:
4239                 case CLASS_BARD:
4240                 case CLASS_FORCETRAINER:
4241                 case CLASS_TOURIST:
4242                 case CLASS_MIRROR_MASTER:
4243                 {
4244                         msp -= msp * (cur_wgt - max_wgt) / 800;
4245                         break;
4246                 }
4247                 case CLASS_SORCERER:
4248                 {
4249                         msp -= msp * (cur_wgt - max_wgt) / 900;
4250                         break;
4251                 }
4252                 case CLASS_ROGUE:
4253                 case CLASS_RANGER:
4254                 case CLASS_MONK:
4255                 case CLASS_RED_MAGE:
4256                 {
4257                         msp -= msp * (cur_wgt - max_wgt) / 1000;
4258                         break;
4259                 }
4260                 case CLASS_PALADIN:
4261                 case CLASS_CHAOS_WARRIOR:
4262                 case CLASS_WARRIOR_MAGE:
4263                 {
4264                         msp -= msp * (cur_wgt - max_wgt) / 1200;
4265                         break;
4266                 }
4267                 case CLASS_SAMURAI:
4268                 {
4269                         creature_ptr->cumber_armor = FALSE;
4270                         break;
4271                 }
4272                 default:
4273                 {
4274                         msp -= msp * (cur_wgt - max_wgt) / 800;
4275                         break;
4276                 }
4277                 }
4278         }
4279
4280         if (msp < 0) msp = 0;
4281
4282         if (creature_ptr->msp != msp)
4283         {
4284                 if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI))
4285                 {
4286                         creature_ptr->csp = msp;
4287                         creature_ptr->csp_frac = 0;
4288                 }
4289
4290 #ifdef JP
4291                 if (creature_ptr->level_up_message && (msp > creature_ptr->msp))
4292                 {
4293                         msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
4294                 }
4295 #endif
4296                 creature_ptr->msp = msp;
4297                 creature_ptr->redraw |= (PR_MANA);
4298                 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
4299         }
4300
4301         if (current_world_ptr->character_xtra) return;
4302
4303         if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove)
4304         {
4305                 if (creature_ptr->cumber_glove)
4306                         msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
4307                 else
4308                         msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
4309
4310                 creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
4311         }
4312
4313         if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor) return;
4314
4315         if (creature_ptr->cumber_armor)
4316                 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
4317         else
4318                 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
4319
4320         creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
4321 }
4322
4323
4324 /*!
4325  * @brief 装備中の射撃武器の威力倍率を返す /
4326  * calcurate the fire rate of target object
4327  * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
4328  * @return 射撃倍率の値(100で1.00倍)
4329  */
4330 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
4331 {
4332         int extra_shots = 0;
4333         BIT_FLAGS flgs[TR_FLAG_SIZE];
4334         for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
4335         {
4336                 object_type *q_ptr;
4337                 q_ptr = &creature_ptr->inventory_list[i];
4338                 if (!q_ptr->k_idx) continue;
4339
4340                 if (i == INVEN_BOW) continue;
4341
4342                 object_flags(q_ptr, flgs);
4343                 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
4344         }
4345
4346         object_flags(o_ptr, flgs);
4347         if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
4348
4349         int num = 0;
4350         if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
4351                 return (s16b)num;
4352
4353         num = 100;
4354         num += (extra_shots * 100);
4355
4356         OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
4357         if ((creature_ptr->pclass == CLASS_RANGER) &&
4358                 (tval_ammo == TV_ARROW))
4359         {
4360                 num += (creature_ptr->lev * 4);
4361         }
4362
4363         if ((creature_ptr->pclass == CLASS_CAVALRY) &&
4364                 (tval_ammo == TV_ARROW))
4365         {
4366                 num += (creature_ptr->lev * 3);
4367         }
4368
4369         if (creature_ptr->pclass == CLASS_ARCHER)
4370         {
4371                 if (tval_ammo == TV_ARROW)
4372                         num += ((creature_ptr->lev * 5) + 50);
4373                 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
4374                         num += (creature_ptr->lev * 4);
4375         }
4376
4377         if (creature_ptr->pclass == CLASS_WARRIOR &&
4378                 (tval_ammo <= TV_BOLT) &&
4379                 (tval_ammo >= TV_SHOT))
4380         {
4381                 num += (creature_ptr->lev * 2);
4382         }
4383
4384         if ((creature_ptr->pclass == CLASS_ROGUE) &&
4385                 (tval_ammo == TV_SHOT))
4386         {
4387                 num += (creature_ptr->lev * 4);
4388         }
4389
4390         return (s16b)num;
4391 }
4392
4393
4394 /*!
4395  * @brief プレイヤーの所持重量制限を計算する /
4396  * Computes current weight limit.
4397  * @return 制限重量(ポンド)
4398  */
4399 WEIGHT weight_limit(player_type *creature_ptr)
4400 {
4401         WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50;
4402         if (creature_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
4403         return i;
4404 }
4405
4406
4407 /*!
4408  * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
4409  * @param i 判定する手のID(右手:0 左手:1)
4410  * @return 持っているならばTRUE
4411  */
4412 bool has_melee_weapon(player_type *creature_ptr, int i)
4413 {
4414         return ((creature_ptr->inventory_list[i].k_idx && object_is_melee_weapon(&creature_ptr->inventory_list[i])) ? TRUE : FALSE);
4415 }
4416
4417
4418 /*!
4419  * @brief プレイヤーの現在開いている手の状態を返す
4420  * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
4421  * @return 開いている手のビットフラグ
4422  */
4423 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
4424 {
4425         BIT_FLAGS16 status = EMPTY_HAND_NONE;
4426         if (!creature_ptr->inventory_list[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
4427         if (!creature_ptr->inventory_list[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
4428
4429         if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS))
4430         {
4431                 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
4432                 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
4433         }
4434
4435         return status;
4436 }
4437
4438
4439 /*!
4440  * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
4441  * @return ペナルティが適用されるならばTRUE。
4442  */
4443 bool heavy_armor(player_type *creature_ptr)
4444 {
4445         if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA))
4446                 return FALSE;
4447
4448         WEIGHT monk_arm_wgt = 0;
4449         if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
4450         if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
4451         monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
4452         monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight;
4453         monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight;
4454         monk_arm_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
4455         monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
4456
4457         return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
4458 }
4459
4460
4461 /*!
4462  * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
4463  * @return なし
4464  * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
4465  */
4466 void update_creature(player_type *creature_ptr)
4467 {
4468         if (!creature_ptr->update) return;
4469
4470         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4471         if (creature_ptr->update & (PU_AUTODESTROY))
4472         {
4473                 creature_ptr->update &= ~(PU_AUTODESTROY);
4474                 autopick_delayed_alter(creature_ptr);
4475         }
4476
4477         if (creature_ptr->update & (PU_COMBINE))
4478         {
4479                 creature_ptr->update &= ~(PU_COMBINE);
4480                 combine_pack(creature_ptr);
4481         }
4482
4483         if (creature_ptr->update & (PU_REORDER))
4484         {
4485                 creature_ptr->update &= ~(PU_REORDER);
4486                 reorder_pack(creature_ptr);
4487         }
4488
4489         if (creature_ptr->update & (PU_BONUS))
4490         {
4491                 creature_ptr->update &= ~(PU_BONUS);
4492                 calc_alignment(creature_ptr);
4493                 calc_bonuses(creature_ptr);
4494         }
4495
4496         if (creature_ptr->update & (PU_TORCH))
4497         {
4498                 creature_ptr->update &= ~(PU_TORCH);
4499                 calc_torch(creature_ptr);
4500         }
4501
4502         if (creature_ptr->update & (PU_HP))
4503         {
4504                 creature_ptr->update &= ~(PU_HP);
4505                 calc_hitpoints(creature_ptr);
4506         }
4507
4508         if (creature_ptr->update & (PU_MANA))
4509         {
4510                 creature_ptr->update &= ~(PU_MANA);
4511                 calc_mana(creature_ptr);
4512         }
4513
4514         if (creature_ptr->update & (PU_SPELLS))
4515         {
4516                 creature_ptr->update &= ~(PU_SPELLS);
4517                 calc_spells(creature_ptr);
4518         }
4519
4520         if (!current_world_ptr->character_generated) return;
4521         if (current_world_ptr->character_icky) return;
4522         if (creature_ptr->update & (PU_UN_LITE))
4523         {
4524                 creature_ptr->update &= ~(PU_UN_LITE);
4525                 forget_lite(floor_ptr);
4526         }
4527
4528         if (creature_ptr->update & (PU_UN_VIEW))
4529         {
4530                 creature_ptr->update &= ~(PU_UN_VIEW);
4531                 forget_view(floor_ptr);
4532         }
4533
4534         if (creature_ptr->update & (PU_VIEW))
4535         {
4536                 creature_ptr->update &= ~(PU_VIEW);
4537                 update_view(creature_ptr);
4538         }
4539
4540         if (creature_ptr->update & (PU_LITE))
4541         {
4542                 creature_ptr->update &= ~(PU_LITE);
4543                 update_lite(creature_ptr);
4544         }
4545
4546         if (creature_ptr->update & (PU_FLOW))
4547         {
4548                 creature_ptr->update &= ~(PU_FLOW);
4549                 update_flow(creature_ptr);
4550         }
4551
4552         if (creature_ptr->update & (PU_DISTANCE))
4553         {
4554                 creature_ptr->update &= ~(PU_DISTANCE);
4555
4556                 update_monsters(creature_ptr, TRUE);
4557         }
4558
4559         if (creature_ptr->update & (PU_MON_LITE))
4560         {
4561                 creature_ptr->update &= ~(PU_MON_LITE);
4562                 update_mon_lite(creature_ptr);
4563         }
4564
4565         if (creature_ptr->update & (PU_DELAY_VIS))
4566         {
4567                 creature_ptr->update &= ~(PU_DELAY_VIS);
4568                 delayed_visual_update(creature_ptr);
4569         }
4570
4571         if (creature_ptr->update & (PU_MONSTERS))
4572         {
4573                 creature_ptr->update &= ~(PU_MONSTERS);
4574                 update_monsters(creature_ptr, FALSE);
4575         }
4576 }
4577
4578
4579 /*!
4580  * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
4581  * @return 魔道書を一冊も持っていないならTRUEを返す
4582  */
4583 bool player_has_no_spellbooks(player_type *creature_ptr)
4584 {
4585         object_type *o_ptr;
4586         for (int i = 0; i < INVEN_PACK; i++)
4587         {
4588                 o_ptr = &creature_ptr->inventory_list[i];
4589                 if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
4590         }
4591
4592         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4593         for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
4594         {
4595                 o_ptr = &floor_ptr->o_list[i];
4596                 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
4597         }
4598
4599         return TRUE;
4600 }
4601
4602
4603 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
4604 {
4605         creature_ptr->energy_use = (ENERGY)need_cost;
4606 }
4607
4608
4609 void free_turn(player_type *creature_ptr)
4610 {
4611         creature_ptr->energy_use = 0;
4612 }
4613
4614
4615 /*!
4616  * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4617  * @param x 配置先X座標
4618  * @param y 配置先Y座標
4619  * @return 配置に成功したらTRUE
4620  */
4621 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
4622 {
4623         if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0) return FALSE;
4624
4625         /* Save player location */
4626         creature_ptr->y = y;
4627         creature_ptr->x = x;
4628         return TRUE;
4629 }
4630
4631
4632 /*!
4633  * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
4634  * @return なし
4635  */
4636 void wreck_the_pattern(player_type *creature_ptr)
4637 {
4638         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
4639         int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
4640         if (pattern_type == PATTERN_TILE_WRECKED) return;
4641
4642         msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
4643         msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
4644
4645         if (!IS_INVULN(creature_ptr))
4646                 take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
4647
4648         int to_ruin = randint1(45) + 35;
4649         while (to_ruin--)
4650         {
4651                 POSITION r_y, r_x;
4652                 scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
4653
4654                 if (pattern_tile(floor_ptr, r_y, r_x) &&
4655                         (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
4656                 {
4657                         cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
4658                 }
4659         }
4660
4661         cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
4662 }
4663
4664
4665 /*!
4666  * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
4667  * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
4668  * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
4669  * @return なし
4670  */
4671 void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
4672 {
4673         if (creature_ptr->phase_out || !current_world_ptr->character_dungeon) return;
4674
4675         int power = 100;
4676         if (!necro && m_ptr)
4677         {
4678                 GAME_TEXT m_name[MAX_NLEN];
4679                 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
4680                 power = r_ptr->level / 2;
4681                 monster_desc(creature_ptr, m_name, m_ptr, 0);
4682                 if (!(r_ptr->flags1 & RF1_UNIQUE))
4683                 {
4684                         if (r_ptr->flags1 & RF1_FRIENDS)
4685                                 power /= 2;
4686                 }
4687                 else power *= 2;
4688
4689                 if (!current_world_ptr->is_loading_now)
4690                         return;
4691
4692                 if (!m_ptr->ml)
4693                         return;
4694
4695                 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
4696                         return;
4697
4698                 if (is_pet(m_ptr))
4699                         return;
4700
4701                 if (randint1(100) > power) return;
4702
4703                 if (saving_throw(creature_ptr->skill_sav - power))
4704                         return;
4705
4706                 if (creature_ptr->image)
4707                 {
4708                         msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4709                                 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4710
4711                         if (one_in_(3))
4712                         {
4713                                 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4714                                 creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
4715                         }
4716
4717                         return;
4718                 }
4719
4720                 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4721                         horror_desc[randint0(MAX_SAN_HORROR)], m_name);
4722                 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4723                 if (PRACE_IS_(creature_ptr, RACE_IMP) ||
4724                         PRACE_IS_(creature_ptr, RACE_DEMON) ||
4725                         (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) ||
4726                         current_world_ptr->wizard)
4727                         return;
4728
4729                 if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_ZOMBIE)
4730                         || PRACE_IS_(creature_ptr, RACE_VAMPIRE) || PRACE_IS_(creature_ptr, RACE_SPECTRE) ||
4731                         (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
4732                 {
4733                         if (saving_throw(25 + creature_ptr->lev)) return;
4734                 }
4735         }
4736         else if (!necro)
4737         {
4738                 monster_race *r_ptr;
4739                 GAME_TEXT m_name[MAX_NLEN];
4740                 concptr desc;
4741                 get_mon_num_prep(creature_ptr, get_nightmare, NULL);
4742                 r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH)];
4743                 power = r_ptr->level + 10;
4744                 desc = r_name + r_ptr->name;
4745                 get_mon_num_prep(creature_ptr, NULL, NULL);
4746 #ifdef JP
4747 #else
4748
4749                 if (!(r_ptr->flags1 & RF1_UNIQUE))
4750                         sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
4751                 else
4752 #endif
4753                         sprintf(m_name, "%s", desc);
4754
4755                 if (!(r_ptr->flags1 & RF1_UNIQUE))
4756                 {
4757                         if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
4758                 }
4759                 else power *= 2;
4760
4761                 if (saving_throw(creature_ptr->skill_sav * 100 / power))
4762                 {
4763                         msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
4764                         return;
4765                 }
4766
4767                 if (creature_ptr->image)
4768                 {
4769                         msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4770                                 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
4771
4772                         if (one_in_(3))
4773                         {
4774                                 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
4775                                 creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
4776                         }
4777
4778                         return;
4779                 }
4780
4781                 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
4782                         horror_desc[randint0(MAX_SAN_HORROR)], desc);
4783
4784                 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
4785
4786                 if (!creature_ptr->mimic_form)
4787                 {
4788                         switch (creature_ptr->prace)
4789                         {
4790                         case RACE_IMP:
4791                         case RACE_DEMON:
4792                                 if (saving_throw(20 + creature_ptr->lev)) return;
4793                                 break;
4794                         case RACE_SKELETON:
4795                         case RACE_ZOMBIE:
4796                         case RACE_SPECTRE:
4797                         case RACE_VAMPIRE:
4798                                 if (saving_throw(10 + creature_ptr->lev)) return;
4799                                 break;
4800                         }
4801                 }
4802                 else
4803                 {
4804                         if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
4805                         {
4806                                 if (saving_throw(20 + creature_ptr->lev)) return;
4807                         }
4808                         else if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
4809                         {
4810                                 if (saving_throw(10 + creature_ptr->lev)) return;
4811                         }
4812                 }
4813         }
4814         else
4815         {
4816                 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
4817         }
4818
4819         /* 過去の効果無効率再現のため5回saving_throw 実行 */
4820         if (saving_throw(creature_ptr->skill_sav - power)
4821                 && saving_throw(creature_ptr->skill_sav - power)
4822                 && saving_throw(creature_ptr->skill_sav - power)
4823                 && saving_throw(creature_ptr->skill_sav - power)
4824                 && saving_throw(creature_ptr->skill_sav - power)
4825                 )
4826         {
4827                 return;
4828         }
4829
4830         switch (randint1(22))
4831         {
4832         case 1:
4833                 if (!(creature_ptr->muta3 & MUT3_MORONIC))
4834                 {
4835                         if ((creature_ptr->stat_use[A_INT] < 4) && (creature_ptr->stat_use[A_WIS] < 4))
4836                         {
4837                                 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
4838                         }
4839                         else
4840                         {
4841                                 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
4842                         }
4843
4844                         if (creature_ptr->muta3 & MUT3_HYPER_INT)
4845                         {
4846                                 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
4847                                 creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
4848                         }
4849                         creature_ptr->muta3 |= MUT3_MORONIC;
4850                 }
4851                 break;
4852         case 2:
4853                 if (!(creature_ptr->muta2 & MUT2_COWARDICE) && !creature_ptr->resist_fear)
4854                 {
4855                         msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
4856                         if (creature_ptr->muta3 & MUT3_FEARLESS)
4857                         {
4858                                 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
4859                                 creature_ptr->muta3 &= ~(MUT3_FEARLESS);
4860                         }
4861
4862                         creature_ptr->muta2 |= MUT2_COWARDICE;
4863                 }
4864                 break;
4865         case 3:
4866                 if (!(creature_ptr->muta2 & MUT2_HALLU) && !creature_ptr->resist_chaos)
4867                 {
4868                         msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
4869                         creature_ptr->muta2 |= MUT2_HALLU;
4870                 }
4871                 break;
4872         case 4:
4873                 if (!(creature_ptr->muta2 & MUT2_BERS_RAGE) && !creature_ptr->resist_conf)
4874                 {
4875                         msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
4876                         creature_ptr->muta2 |= MUT2_BERS_RAGE;
4877                 }
4878                 break;
4879         case 5:
4880         case 6:
4881         case 7:
4882         case 8:
4883         case 9:
4884         case 10:
4885         case 11:
4886         case 12:
4887                 if (!creature_ptr->resist_conf)
4888                 {
4889                         (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
4890                 }
4891
4892                 if (!creature_ptr->resist_chaos && one_in_(3))
4893                 {
4894                         (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
4895                 }
4896
4897                 /* todo いつからかは不明だがreturnとbreakが同時に存在している。どちらがデッドコードか不明瞭なので保留 */
4898                 return;
4899                 break;
4900         case 13:
4901         case 14:
4902         case 15:
4903                 if (!creature_ptr->resist_conf)
4904                 {
4905                         (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
4906                 }
4907                 if (!creature_ptr->free_act)
4908                 {
4909                         (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + randint0(4) + 4);
4910                 }
4911                 if (!creature_ptr->resist_chaos)
4912                 {
4913                         (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
4914                 }
4915
4916                 do
4917                 {
4918                         (void)do_dec_stat(creature_ptr, A_INT);
4919                 } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
4920
4921                 do
4922                 {
4923                         (void)do_dec_stat(creature_ptr, A_WIS);
4924                 } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
4925
4926                 break;
4927         case 16:
4928         case 17:
4929                 if (lose_all_info(creature_ptr))
4930                         msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
4931                 break;
4932         case 18:
4933         case 19:
4934         case 20:
4935         case 21:
4936         case 22:
4937                 do_dec_stat(creature_ptr, A_INT);
4938                 do_dec_stat(creature_ptr, A_WIS);
4939                 break;
4940         default:
4941                 break;
4942         }
4943
4944         creature_ptr->update |= PU_BONUS;
4945         handle_stuff(creature_ptr);
4946 }
4947
4948
4949 /*!
4950  * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
4951  * Advance experience levels and print experience
4952  * @return なし
4953  */
4954 void check_experience(player_type *creature_ptr)
4955 {
4956         if (creature_ptr->exp < 0) creature_ptr->exp = 0;
4957         if (creature_ptr->max_exp < 0) creature_ptr->max_exp = 0;
4958         if (creature_ptr->max_max_exp < 0) creature_ptr->max_max_exp = 0;
4959
4960         if (creature_ptr->exp > PY_MAX_EXP) creature_ptr->exp = PY_MAX_EXP;
4961         if (creature_ptr->max_exp > PY_MAX_EXP) creature_ptr->max_exp = PY_MAX_EXP;
4962         if (creature_ptr->max_max_exp > PY_MAX_EXP) creature_ptr->max_max_exp = PY_MAX_EXP;
4963
4964         if (creature_ptr->exp > creature_ptr->max_exp) creature_ptr->max_exp = creature_ptr->exp;
4965         if (creature_ptr->max_exp > creature_ptr->max_max_exp) creature_ptr->max_max_exp = creature_ptr->max_exp;
4966
4967         creature_ptr->redraw |= (PR_EXP);
4968         handle_stuff(creature_ptr);
4969
4970         bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
4971         PLAYER_LEVEL old_lev = creature_ptr->lev;
4972         while ((creature_ptr->lev > 1) &&
4973                 (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L)))
4974         {
4975                 creature_ptr->lev--;
4976                 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
4977                 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
4978                 creature_ptr->window |= (PW_PLAYER);
4979                 handle_stuff(creature_ptr);
4980         }
4981
4982         bool level_reward = FALSE;
4983         bool level_mutation = FALSE;
4984         bool level_inc_stat = FALSE;
4985         while ((creature_ptr->lev < PY_MAX_LEVEL) &&
4986                 (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L)))
4987         {
4988                 creature_ptr->lev++;
4989                 if (creature_ptr->lev > creature_ptr->max_plv)
4990                 {
4991                         creature_ptr->max_plv = creature_ptr->lev;
4992
4993                         if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
4994                                 (creature_ptr->muta2 & MUT2_CHAOS_GIFT))
4995                         {
4996                                 level_reward = TRUE;
4997                         }
4998                         if (creature_ptr->prace == RACE_BEASTMAN)
4999                         {
5000                                 if (one_in_(5)) level_mutation = TRUE;
5001                         }
5002                         level_inc_stat = TRUE;
5003
5004                         exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
5005                 }
5006
5007                 sound(SOUND_LEVEL);
5008                 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
5009                 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5010                 creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
5011                 creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
5012                 creature_ptr->level_up_message = TRUE;
5013                 handle_stuff(creature_ptr);
5014
5015                 creature_ptr->level_up_message = FALSE;
5016                 if (level_inc_stat)
5017                 {
5018                         if (!(creature_ptr->max_plv % 10))
5019                         {
5020                                 int choice;
5021                                 screen_save();
5022                                 while (TRUE)
5023                                 {
5024                                         int n;
5025                                         char tmp[32];
5026
5027                                         cnv_stat(creature_ptr->stat_max[0], tmp);
5028                                         prt(format(_("        a) 腕力 (現在値 %s)", "        a) Str (cur %s)"), tmp), 2, 14);
5029                                         cnv_stat(creature_ptr->stat_max[1], tmp);
5030                                         prt(format(_("        b) 知能 (現在値 %s)", "        b) Int (cur %s)"), tmp), 3, 14);
5031                                         cnv_stat(creature_ptr->stat_max[2], tmp);
5032                                         prt(format(_("        c) 賢さ (現在値 %s)", "        c) Wis (cur %s)"), tmp), 4, 14);
5033                                         cnv_stat(creature_ptr->stat_max[3], tmp);
5034                                         prt(format(_("        d) 器用 (現在値 %s)", "        d) Dex (cur %s)"), tmp), 5, 14);
5035                                         cnv_stat(creature_ptr->stat_max[4], tmp);
5036                                         prt(format(_("        e) 耐久 (現在値 %s)", "        e) Con (cur %s)"), tmp), 6, 14);
5037                                         cnv_stat(creature_ptr->stat_max[5], tmp);
5038                                         prt(format(_("        f) 魅力 (現在値 %s)", "        f) Chr (cur %s)"), tmp), 7, 14);
5039
5040                                         prt("", 8, 14);
5041                                         prt(_("        どの能力値を上げますか?", "        Which stat do you want to raise?"), 1, 14);
5042
5043                                         while (TRUE)
5044                                         {
5045                                                 choice = inkey();
5046                                                 if ((choice >= 'a') && (choice <= 'f')) break;
5047                                         }
5048                                         for (n = 0; n < A_MAX; n++)
5049                                                 if (n != choice - 'a')
5050                                                         prt("", n + 2, 14);
5051                                         if (get_check(_("よろしいですか?", "Are you sure? "))) break;
5052                                 }
5053                                 do_inc_stat(creature_ptr, choice - 'a');
5054                                 screen_load();
5055                         }
5056                         else if (!(creature_ptr->max_plv % 2))
5057                                 do_inc_stat(creature_ptr, randint0(6));
5058                 }
5059
5060                 if (level_mutation)
5061                 {
5062                         msg_print(_("あなたは変わった気がする...", "You feel different..."));
5063                         (void)gain_mutation(creature_ptr, 0);
5064                         level_mutation = FALSE;
5065                 }
5066
5067                 /*
5068                  * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が
5069                  * 呼ばれるので順番を最後にする。
5070                  */
5071                 if (level_reward)
5072                 {
5073                         gain_level_reward(creature_ptr, 0);
5074                         level_reward = FALSE;
5075                 }
5076
5077                 creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
5078                 creature_ptr->redraw |= (PR_LEV | PR_TITLE);
5079                 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
5080                 handle_stuff(creature_ptr);
5081         }
5082
5083         if (old_lev != creature_ptr->lev)
5084                 autopick_load_pref(creature_ptr, FALSE);
5085 }
5086
5087
5088 /*!
5089  * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
5090  * @param val 能力値
5091  * @param out_val 出力先文字列ポインタ
5092  * @return なし
5093  */
5094 void cnv_stat(int val, char *out_val)
5095 {
5096         if (val <= 18)
5097         {
5098                 sprintf(out_val, "    %2d", val);
5099                 return;
5100         }
5101
5102         int bonus = (val - 18);
5103         if (bonus >= 220)
5104         {
5105                 sprintf(out_val, "18/%3s", "***");
5106         }
5107         else if (bonus >= 100)
5108         {
5109                 sprintf(out_val, "18/%03d", bonus);
5110         }
5111         else
5112         {
5113                 sprintf(out_val, " 18/%02d", bonus);
5114         }
5115 }
5116
5117
5118 /*!
5119  * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
5120  * Modify a stat value by a "modifier", return new value
5121  * @param value 現在値
5122  * @param amount 加減算値
5123  * @return 加減算後の値
5124  * @details
5125  * <pre>
5126  * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
5127  * Or even: 18/13, 18/23, 18/33, ..., 18/220
5128  * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
5129  * Or even: 18/13, 18/03, 18, 17, ..., 3
5130  * </pre>
5131  */
5132 s16b modify_stat_value(int value, int amount)
5133 {
5134         if (amount > 0)
5135         {
5136                 for (int i = 0; i < amount; i++)
5137                 {
5138                         if (value < 18) value++;
5139                         else value += 10;
5140                 }
5141         }
5142         else if (amount < 0)
5143         {
5144                 for (int i = 0; i < (0 - amount); i++)
5145                 {
5146                         if (value >= 18 + 10) value -= 10;
5147                         else if (value > 18) value = 18;
5148                         else if (value > 3) value--;
5149                 }
5150         }
5151
5152         return (s16b)value;
5153 }
5154
5155
5156 /*!
5157  * @brief スコアを計算する /
5158  * Hack -- Calculates the total number of points earned         -JWT-
5159  * @return なし
5160  * @details
5161  */
5162 long calc_score(player_type *creature_ptr)
5163 {
5164         int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
5165
5166         int mult = 100;
5167         if (!preserve_mode) mult += 10;
5168         if (!autoroller) mult += 10;
5169         if (!smart_learn) mult -= 20;
5170         if (smart_cheat) mult += 30;
5171         if (ironman_shops) mult += 50;
5172         if (ironman_small_levels) mult += 10;
5173         if (ironman_empty_levels) mult += 20;
5174         if (!powerup_home) mult += 50;
5175         if (ironman_rooms) mult += 100;
5176         if (ironman_nightmare) mult += 100;
5177
5178         if (mult < 5) mult = 5;
5179
5180         DEPTH max_dl = 0;
5181         for (int i = 0; i < current_world_ptr->max_d_idx; i++)
5182                 if (max_dlv[i] > max_dl)
5183                         max_dl = max_dlv[i];
5184
5185         u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
5186         u32b point_h = point_l / 0x10000L;
5187         point_l = point_l % 0x10000L;
5188         point_h *= mult;
5189         point_l *= mult;
5190         point_h += point_l / 0x10000L;
5191         point_l %= 0x10000L;
5192
5193         point_l += ((point_h % 100) << 16);
5194         point_h /= 100;
5195         point_l /= 100;
5196
5197         u32b point = (point_h << 16) + (point_l);
5198         if (creature_ptr->arena_number >= 0)
5199                 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
5200
5201         if (ironman_downward) point *= 2;
5202         if (creature_ptr->pclass == CLASS_BERSERKER)
5203         {
5204                 if (creature_ptr->prace == RACE_SPECTRE)
5205                         point = point / 5;
5206         }
5207
5208         if ((creature_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
5209         {
5210                 point = 1;
5211                 if (current_world_ptr->total_winner) point = 2;
5212         }
5213
5214         if (easy_band) point = (0 - point);
5215
5216         return point;
5217 }
5218
5219
5220 void cheat_death(player_type *creature_ptr)
5221 {
5222         if (creature_ptr->sc)
5223                 creature_ptr->sc = creature_ptr->age = 0;
5224         creature_ptr->age++;
5225
5226         current_world_ptr->noscore |= 0x0001;
5227         msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
5228         msg_print(NULL);
5229
5230         (void)life_stream(creature_ptr, FALSE, FALSE);
5231         if (creature_ptr->pclass == CLASS_MAGIC_EATER)
5232         {
5233                 int magic_idx;
5234                 for (magic_idx = 0; magic_idx < EATER_EXT * 2; magic_idx++)
5235                 {
5236                         creature_ptr->magic_num1[magic_idx] = creature_ptr->magic_num2[magic_idx] * EATER_CHARGE;
5237                 }
5238                 for (; magic_idx < EATER_EXT * 3; magic_idx++)
5239                 {
5240                         creature_ptr->magic_num1[magic_idx] = 0;
5241                 }
5242         }
5243
5244         creature_ptr->csp = creature_ptr->msp;
5245         creature_ptr->csp_frac = 0;
5246         if (creature_ptr->word_recall)
5247         {
5248                 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
5249                 msg_print(NULL);
5250                 creature_ptr->word_recall = 0;
5251                 creature_ptr->redraw |= (PR_STATUS);
5252         }
5253
5254         if (creature_ptr->alter_reality)
5255         {
5256                 creature_ptr->alter_reality = 0;
5257                 creature_ptr->redraw |= (PR_STATUS);
5258         }
5259
5260         (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
5261         creature_ptr->is_dead = FALSE;
5262         (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
5263
5264         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
5265         floor_ptr->dun_level = 0;
5266         floor_ptr->inside_arena = FALSE;
5267         creature_ptr->phase_out = FALSE;
5268         leaving_quest = 0;
5269         floor_ptr->inside_quest = 0;
5270         if (creature_ptr->dungeon_idx) creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
5271         creature_ptr->dungeon_idx = 0;
5272         if (lite_town || vanilla_town)
5273         {
5274                 creature_ptr->wilderness_y = 1;
5275                 creature_ptr->wilderness_x = 1;
5276                 if (vanilla_town)
5277                 {
5278                         creature_ptr->oldpy = 10;
5279                         creature_ptr->oldpx = 34;
5280                 }
5281                 else
5282                 {
5283                         creature_ptr->oldpy = 33;
5284                         creature_ptr->oldpx = 131;
5285                 }
5286         }
5287         else
5288         {
5289                 creature_ptr->wilderness_y = 48;
5290                 creature_ptr->wilderness_x = 5;
5291                 creature_ptr->oldpy = 33;
5292                 creature_ptr->oldpx = 131;
5293         }
5294
5295         creature_ptr->wild_mode = FALSE;
5296         creature_ptr->leaving = TRUE;
5297
5298         exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1,
5299                 _("                            しかし、生き返った。",
5300                         "                            but revived."));
5301
5302         leave_floor(creature_ptr);
5303         wipe_monsters_list(creature_ptr);
5304 }
5305
5306
5307 /*!
5308  * @param creature_ptr プレーヤーへの参照ポインタ
5309  * @return 祝福状態ならばTRUE
5310  */
5311 bool is_blessed(player_type *creature_ptr)
5312 {
5313         return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
5314 }
5315
5316
5317 bool is_oppose_acid(player_type *creature_ptr)
5318 {
5319         return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5320 }
5321
5322
5323 bool is_oppose_elec(player_type *creature_ptr)
5324 {
5325         return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5326 }
5327
5328
5329 bool is_oppose_fire(player_type *creature_ptr)
5330 {
5331         return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5332 }
5333
5334
5335 bool is_oppose_cold(player_type *creature_ptr)
5336 {
5337         return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5338 }
5339
5340
5341 bool is_oppose_pois(player_type *creature_ptr)
5342 {
5343         return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
5344 }
5345
5346
5347 bool is_tim_esp(player_type *creature_ptr)
5348 {
5349         return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
5350 }
5351
5352
5353 bool is_tim_stealth(player_type *creature_ptr)
5354 {
5355         return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
5356 }
5357
5358
5359 bool is_time_limit_esp(player_type *creature_ptr)
5360 {
5361         return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
5362 }
5363
5364
5365 bool is_time_limit_stealth(player_type *creature_ptr)
5366 {
5367         return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
5368 }
5369
5370
5371 bool can_two_hands_wielding(player_type *creature_ptr)
5372 {
5373         return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS);
5374 }
5375
5376
5377
5378 /*!
5379 * @brief 歌の停止を処理する / Stop singing if the player is a Bard
5380 * @return なし
5381 */
5382 void stop_singing(player_type *creature_ptr)
5383 {
5384         if (creature_ptr->pclass != CLASS_BARD) return;
5385
5386         /* Are there interupted song? */
5387         if (INTERUPTING_SONG_EFFECT(creature_ptr))
5388         {
5389                 /* Forget interupted song */
5390                 INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
5391                 return;
5392         }
5393
5394         /* The player is singing? */
5395         if (!SINGING_SONG_EFFECT(creature_ptr)) return;
5396
5397         /* Hack -- if called from set_action(), avoid recursive loop */
5398         if (creature_ptr->action == ACTION_SING) set_action(creature_ptr, ACTION_NONE);
5399
5400         /* Message text of each song or etc. */
5401         exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
5402
5403         SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
5404         SINGING_SONG_ID(creature_ptr) = 0;
5405         creature_ptr->update |= (PU_BONUS);
5406         creature_ptr->redraw |= (PR_STATUS);
5407 }
5408
5409 /*!
5410  * @brief 口を使う継続的な処理を中断する
5411  * @param caster_ptr プレーヤーへの参照ポインタ
5412  * @return なし
5413  */
5414 void stop_mouth(player_type *caster_ptr)
5415 {
5416         if (music_singing_any(caster_ptr)) stop_singing(caster_ptr);
5417         if (hex_spelling_any(caster_ptr)) stop_hex_spell_all(caster_ptr);
5418 }
5419
5420
5421 /*!
5422 * @brief ペットの維持コスト計算
5423 * @return 維持コスト(%)
5424 */
5425 PERCENTAGE calculate_upkeep(player_type *creature_ptr)
5426 {
5427         MONSTER_IDX m_idx;
5428         bool have_a_unique = FALSE;
5429         DEPTH total_friend_levels = 0;
5430
5431         total_friends = 0;
5432
5433         for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
5434         {
5435                 monster_type *m_ptr;
5436                 monster_race *r_ptr;
5437
5438                 m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
5439                 if (!monster_is_valid(m_ptr)) continue;
5440                 r_ptr = &r_info[m_ptr->r_idx];
5441
5442                 if (is_pet(m_ptr))
5443                 {
5444                         total_friends++;
5445                         if (r_ptr->flags1 & RF1_UNIQUE)
5446                         {
5447                                 if (creature_ptr->pclass == CLASS_CAVALRY)
5448                                 {
5449                                         if (creature_ptr->riding == m_idx)
5450                                                 total_friend_levels += (r_ptr->level + 5) * 2;
5451                                         else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
5452                                                 total_friend_levels += (r_ptr->level + 5) * 7 / 2;
5453                                         else
5454                                                 total_friend_levels += (r_ptr->level + 5) * 10;
5455                                         have_a_unique = TRUE;
5456                                 }
5457                                 else
5458                                         total_friend_levels += (r_ptr->level + 5) * 10;
5459                         }
5460                         else
5461                                 total_friend_levels += r_ptr->level;
5462
5463                 }
5464         }
5465
5466         if (total_friends)
5467         {
5468                 int upkeep_factor;
5469                 upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
5470                 if (upkeep_factor < 0) upkeep_factor = 0;
5471                 if (upkeep_factor > 1000) upkeep_factor = 1000;
5472                 return upkeep_factor;
5473         }
5474         else
5475                 return 0;
5476 }
5477
5478 bool music_singing(player_type *caster_ptr, int music_songs)
5479 {
5480         return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);
5481 }