OSDN Git Service

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