OSDN Git Service

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