OSDN Git Service

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