OSDN Git Service

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