OSDN Git Service

新職業スナイパーといくつかの新or移植アーティファクトをマージ。
[hengband/hengband.git] / src / xtra1.c
1
2 /* File: misc.c */
3
4 /*
5  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6  *
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  */
11
12 /* Purpose: misc code */
13
14 #include "angband.h"
15
16
17
18
19 /*
20  * Converts stat num into a six-char (right justified) string
21  */
22 void cnv_stat(int val, char *out_val)
23 {
24         /* Above 18 */
25         if (val > 18)
26         {
27                 int bonus = (val - 18);
28
29                 if (bonus >= 220)
30                 {
31                         sprintf(out_val, "18/%3s", "***");
32                 }
33                 else if (bonus >= 100)
34                 {
35                         sprintf(out_val, "18/%03d", bonus);
36                 }
37                 else
38                 {
39                         sprintf(out_val, " 18/%02d", bonus);
40                 }
41         }
42
43         /* From 3 to 18 */
44         else
45         {
46                 sprintf(out_val, "    %2d", val);
47         }
48 }
49
50
51
52 /*
53  * Modify a stat value by a "modifier", return new value
54  *
55  * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
56  * Or even: 18/13, 18/23, 18/33, ..., 18/220
57  *
58  * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
59  * Or even: 18/13, 18/03, 18, 17, ..., 3
60  */
61 s16b modify_stat_value(int value, int amount)
62 {
63         int    i;
64
65         /* Reward */
66         if (amount > 0)
67         {
68                 /* Apply each point */
69                 for (i = 0; i < amount; i++)
70                 {
71                         /* One point at a time */
72                         if (value < 18) value++;
73
74                         /* Ten "points" at a time */
75                         else value += 10;
76                 }
77         }
78
79         /* Penalty */
80         else if (amount < 0)
81         {
82                 /* Apply each point */
83                 for (i = 0; i < (0 - amount); i++)
84                 {
85                         /* Ten points at a time */
86                         if (value >= 18+10) value -= 10;
87
88                         /* Hack -- prevent weirdness */
89                         else if (value > 18) value = 18;
90
91                         /* One point at a time */
92                         else if (value > 3) value--;
93                 }
94         }
95
96         /* Return new value */
97         return (value);
98 }
99
100
101
102 /*
103  * Print character info at given row, column in a 13 char field
104  */
105 static void prt_field(cptr info, int row, int col)
106 {
107         /* Dump 13 spaces to clear */
108         c_put_str(TERM_WHITE, "             ", row, col);
109
110         /* Dump the info itself */
111         c_put_str(TERM_L_BLUE, info, row, col);
112 }
113
114
115 /*
116  *  Whether daytime or not
117  */
118 bool is_daytime(void)
119 {
120         s32b len = TURNS_PER_TICK * TOWN_DAWN;
121         if ((turn % len) < (len / 2))
122                 return TRUE;
123         else
124                 return FALSE;
125 }
126
127 /*
128  * Extract day, hour, min
129  */
130 void extract_day_hour_min(int *day, int *hour, int *min)
131 {
132         const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
133         s32b turn_in_today = (turn + A_DAY / 4) % A_DAY;
134
135         switch (p_ptr->start_race)
136         {
137         case RACE_VAMPIRE:
138         case RACE_SKELETON:
139         case RACE_ZOMBIE:
140         case RACE_SPECTRE:
141                 *day = (turn - A_DAY * 3 / 4) / A_DAY + 1;
142                 break;
143         default:
144                 *day = (turn + A_DAY / 4) / A_DAY + 1;
145                 break;
146         }
147         *hour = (24 * turn_in_today / A_DAY) % 24;
148         *min = (1440 * turn_in_today / A_DAY) % 60;
149 }
150
151 /*
152  * Print time
153  */
154 void prt_time(void)
155 {
156         int day, hour, min;
157
158         /* Dump 13 spaces to clear */
159         c_put_str(TERM_WHITE, "             ", ROW_DAY, COL_DAY);
160
161         extract_day_hour_min(&day, &hour, &min);
162
163         /* Dump the info itself */
164 #ifdef JP
165         if (day < 1000) c_put_str(TERM_WHITE, format("%2dÆüÌÜ", day), ROW_DAY, COL_DAY);
166         else c_put_str(TERM_WHITE, "***ÆüÌÜ", ROW_DAY, COL_DAY);
167 #else
168         if (day < 1000) c_put_str(TERM_WHITE, format("Day%3d", day), ROW_DAY, COL_DAY);
169         else c_put_str(TERM_WHITE, "Day***", ROW_DAY, COL_DAY);
170 #endif
171
172         c_put_str(TERM_WHITE, format("%2d:%02d", hour, min), ROW_DAY, COL_DAY+7);
173 }
174
175
176 cptr map_name(void)
177 {
178         if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)
179             && (quest[p_ptr->inside_quest].flags & QUEST_FLAG_PRESET))
180 #ifdef JP
181                 return "¥¯¥¨¥¹¥È";
182 #else
183                 return "Quest";
184 #endif
185         else if (p_ptr->wild_mode)
186 #ifdef JP
187                 return "ÃϾå";
188 #else
189                 return "Surface";
190 #endif
191         else if (p_ptr->inside_arena)
192 #ifdef JP
193                 return "¥¢¥ê¡¼¥Ê";
194 #else
195                 return "Arena";
196 #endif
197         else if (p_ptr->inside_battle)
198 #ifdef JP
199                 return "Æ®µ»¾ì";
200 #else
201                 return "Monster Arena";
202 #endif
203         else if (!dun_level && p_ptr->town_num)
204                 return town[p_ptr->town_num].name;
205         else
206                 return d_name+d_info[dungeon_type].name;
207 }
208
209 /*
210  * Print dungeon
211  */
212 static void prt_dungeon(void)
213 {
214         cptr dungeon_name;
215         int col;
216
217         /* Dump 13 spaces to clear */
218         c_put_str(TERM_WHITE, "             ", ROW_DUNGEON, COL_DUNGEON);
219
220         dungeon_name = map_name();
221
222         col = COL_DUNGEON + 6 - strlen(dungeon_name)/2;
223         if (col < 0) col = 0;
224
225         /* Dump the info itself */
226         c_put_str(TERM_L_UMBER, format("%s",dungeon_name),
227                   ROW_DUNGEON, col);
228 }
229
230
231
232
233 /*
234  * Print character stat in given row, column
235  */
236 static void prt_stat(int stat)
237 {
238         char tmp[32];
239
240         /* Display "injured" stat */
241         if (p_ptr->stat_cur[stat] < p_ptr->stat_max[stat])
242         {
243                 put_str(stat_names_reduced[stat], ROW_STAT + stat, 0);
244                 cnv_stat(p_ptr->stat_use[stat], tmp);
245                 c_put_str(TERM_YELLOW, tmp, ROW_STAT + stat, COL_STAT + 6);
246         }
247
248         /* Display "healthy" stat */
249         else
250         {
251                 put_str(stat_names[stat], ROW_STAT + stat, 0);
252                 cnv_stat(p_ptr->stat_use[stat], tmp);
253                 c_put_str(TERM_L_GREEN, tmp, ROW_STAT + stat, COL_STAT + 6);
254         }
255
256         /* Indicate natural maximum */
257         if (p_ptr->stat_max[stat] == p_ptr->stat_max_max[stat])
258         {
259 #ifdef JP
260                 /* ÆüËܸì¤Ë¤«¤Ö¤é¤Ê¤¤¤è¤¦¤Ëɽ¼¨°ÌÃÖ¤òÊѹ¹ */
261                 put_str("!", ROW_STAT + stat, 5);
262 #else
263                 put_str("!", ROW_STAT + stat, 3);
264 #endif
265
266         }
267 }
268
269
270 /*
271  *  Data structure for status bar
272  */
273 #define BAR_TSUYOSHI 0
274 #define BAR_HALLUCINATION 1
275 #define BAR_BLINDNESS 2
276 #define BAR_PARALYZE 3
277 #define BAR_CONFUSE 4
278 #define BAR_POISONED 5
279 #define BAR_AFRAID 6
280 #define BAR_LEVITATE 7
281 #define BAR_REFLECTION 8
282 #define BAR_PASSWALL 9
283 #define BAR_WRAITH 10
284 #define BAR_PROTEVIL 11
285 #define BAR_KAWARIMI 12
286 #define BAR_MAGICDEFENSE 13
287 #define BAR_EXPAND 14
288 #define BAR_STONESKIN 15
289 #define BAR_MULTISHADOW 16
290 #define BAR_REGMAGIC 17
291 #define BAR_ULTIMATE 18
292 #define BAR_INVULN 19
293 #define BAR_IMMACID 20
294 #define BAR_RESACID 21
295 #define BAR_IMMELEC 22
296 #define BAR_RESELEC 23
297 #define BAR_IMMFIRE 24
298 #define BAR_RESFIRE 25
299 #define BAR_IMMCOLD 26
300 #define BAR_RESCOLD 27
301 #define BAR_RESPOIS 28
302 #define BAR_RESNETH 29
303 #define BAR_RESTIME 30
304 #define BAR_DUSTROBE 31
305 #define BAR_SHFIRE 32
306 #define BAR_TOUKI 33
307 #define BAR_SHHOLY 34
308 #define BAR_EYEEYE 35
309 #define BAR_BLESSED 36
310 #define BAR_HEROISM 37
311 #define BAR_BERSERK 38
312 #define BAR_ATTKFIRE 39
313 #define BAR_ATTKCOLD 40
314 #define BAR_ATTKELEC 41
315 #define BAR_ATTKACID 42
316 #define BAR_ATTKPOIS 43
317 #define BAR_ATTKCONF 44
318 #define BAR_SENSEUNSEEN 45
319 #define BAR_TELEPATHY 46
320 #define BAR_REGENERATION 47
321 #define BAR_INFRAVISION 48
322 #define BAR_STEALTH 49
323 #define BAR_SUPERSTEALTH 50
324 #define BAR_RECALL 51
325 #define BAR_ALTER 52
326
327
328 static struct {
329         byte attr;
330         cptr sstr;
331         cptr lstr;
332 } bar[]
333 #ifdef JP
334 = {
335         {TERM_YELLOW, "¤Ä", "¤Ä¤è¤·"},
336         {TERM_VIOLET, "¸¸", "¸¸³Ð"},
337         {TERM_L_DARK, "ÌÕ", "ÌÕÌÜ"},
338         {TERM_RED, "áã", "Ëãáã"},
339         {TERM_VIOLET, "Íð", "º®Íð"},
340         {TERM_GREEN, "ÆÇ", "ÆÇ"},
341         {TERM_BLUE, "¶²", "¶²ÉÝ"},
342         {TERM_L_BLUE, "Éâ", "ÉâÍ·"},
343         {TERM_SLATE, "È¿", "È¿¼Í"},
344         {TERM_SLATE, "ÊÉ", "ÊÉÈ´¤±"},
345         {TERM_L_DARK, "Í©", "Í©ÂÎ"},
346         {TERM_SLATE, "¼Ù", "ËɼÙ"},
347         {TERM_VIOLET, "ÊÑ", "ÊѤï¤ê¿È"},
348         {TERM_YELLOW, "Ëâ", "ËâË¡³»"},
349         {TERM_L_UMBER, "¿­", "¿­¤Ó"},
350         {TERM_WHITE, "ÀÐ", "ÀÐÈ©"},
351         {TERM_L_BLUE, "ʬ", "ʬ¿È"},
352         {TERM_SLATE, "ËÉ", "ËâË¡Ëɸæ"},
353         {TERM_YELLOW, "µæ", "µæ¶Ë"},
354         {TERM_YELLOW, "̵", "̵Ũ"},
355         {TERM_L_GREEN, "»À", "»ÀÌȱÖ"},
356         {TERM_GREEN, "»À", "ÂÑ»À"},
357         {TERM_L_BLUE, "ÅÅ", "ÅÅÌȱÖ"},
358         {TERM_BLUE, "ÅÅ", "ÂÑÅÅ"},
359         {TERM_L_RED, "²Ð", "²ÐÌȱÖ"},
360         {TERM_RED, "²Ð", "ÂѲÐ"},
361         {TERM_WHITE, "Îä", "ÎäÌȱÖ"},
362         {TERM_SLATE, "Îä", "ÂÑÎä"},
363         {TERM_GREEN, "ÆÇ", "ÂÑÆÇ"},
364         {TERM_L_DARK, "¹ö", "ÂÑÃϹö"},
365         {TERM_L_BLUE, "»þ", "ÂÑ»þ´Ö"},
366         {TERM_L_DARK, "¶À", "¶À¥ª¡¼¥é"},
367         {TERM_L_RED, "¥ª", "²Ð¥ª¡¼¥é"},
368         {TERM_WHITE, "Æ®", "Æ®µ¤"},
369         {TERM_WHITE, "À»", "À»¥ª¡¼¥é"},
370         {TERM_VIOLET, "ÌÜ", "ÌܤˤÏÌÜ"},
371         {TERM_WHITE, "½Ë", "½ËÊ¡"},
372         {TERM_WHITE, "ͦ", "ͦ"},
373         {TERM_RED, "¶¸", "¶¸Íð"},
374         {TERM_L_RED, "²Ð", "Ëâ·õ²Ð"},
375         {TERM_WHITE, "Îä", "Ëâ·õÎä"},
376         {TERM_L_BLUE, "ÅÅ", "Ëâ·õÅÅ"},
377         {TERM_SLATE, "»À", "Ëâ·õ»À"},
378         {TERM_L_GREEN, "ÆÇ", "Ëâ·õÆÇ"},
379         {TERM_RED, "Íð", "º®ÍðÂÇ·â"},
380         {TERM_L_BLUE, "»ë", "Æ©ÌÀ»ë"},
381         {TERM_ORANGE, "¥Æ", "¥Æ¥ì¥Ñ¥·"},
382         {TERM_L_BLUE, "²ó", "²óÉü"},
383         {TERM_L_RED, "ÀÖ", "ÀÖ³°"},
384         {TERM_UMBER, "±£", "±£Ì©"},
385         {TERM_YELLOW, "±£", "Ķ±£Ì©"},
386         {TERM_WHITE, "µ¢", "µ¢´Ô"},
387         {TERM_WHITE, "¸½", "¸½¼ÂÊÑÍÆ"},
388         {0, NULL, NULL}
389 };
390 #else
391 = {
392         {TERM_YELLOW, "Ts", "Tsuyoshi"},
393         {TERM_VIOLET, "Ha", "Halluc"},
394         {TERM_L_DARK, "Bl", "Blind"},
395         {TERM_RED, "Pa", "Paralyzed"},
396         {TERM_VIOLET, "Cf", "Confused"},
397         {TERM_GREEN, "Po", "Poisoned"},
398         {TERM_BLUE, "Af", "Afraid"},
399         {TERM_L_BLUE, "Lv", "Levit"},
400         {TERM_SLATE, "Rf", "Reflect"},
401         {TERM_SLATE, "Pw", "PassWall"},
402         {TERM_L_DARK, "Wr", "Wraith"},
403         {TERM_SLATE, "Ev", "PrtEvl"},
404         {TERM_VIOLET, "Kw", "Kawarimi"},
405         {TERM_YELLOW, "Md", "MgcArm"},
406         {TERM_L_UMBER, "Eh", "Expand"},
407         {TERM_WHITE, "Ss", "StnSkn"},
408         {TERM_L_BLUE, "Ms", "MltShdw"},
409         {TERM_SLATE, "Rm", "ResMag"},
410         {TERM_YELLOW, "Ul", "Ultima"},
411         {TERM_YELLOW, "Iv", "Invuln"},
412         {TERM_L_GREEN, "IAc", "ImmAcid"},
413         {TERM_GREEN, "Ac", "Acid"},
414         {TERM_L_BLUE, "IEl", "ImmElec"},
415         {TERM_BLUE, "El", "Elec"},
416         {TERM_L_RED, "IFi", "ImmFire"},
417         {TERM_RED, "Fi", "Fire"},
418         {TERM_WHITE, "ICo", "ImmCold"},
419         {TERM_SLATE, "Co", "Cold"},
420         {TERM_GREEN, "Po", "Pois"},
421         {TERM_L_DARK, "Nt", "Nthr"},
422         {TERM_L_BLUE, "Ti", "Time"},
423         {TERM_L_DARK, "Mr", "Mirr"},
424         {TERM_L_RED, "SFi", "SFire"},
425         {TERM_WHITE, "Fo", "Force"},
426         {TERM_WHITE, "Ho", "Holy"},
427         {TERM_VIOLET, "Ee", "EyeEye"},
428         {TERM_WHITE, "Bs", "Bless"},
429         {TERM_WHITE, "He", "Hero"},
430         {TERM_RED, "Br", "Berserk"},
431         {TERM_L_RED, "BFi", "BFire"},
432         {TERM_WHITE, "BCo", "BCold"},
433         {TERM_L_BLUE, "BEl", "BElec"},
434         {TERM_SLATE, "BAc", "BAcid"},
435         {TERM_L_GREEN, "BPo", "BPois"},
436         {TERM_RED, "TCf", "TchCnf"},
437         {TERM_L_BLUE, "Se", "SInv"},
438         {TERM_ORANGE, "Te", "Telepa"},
439         {TERM_L_BLUE, "Rg", "Regen"},
440         {TERM_L_RED, "If", "Infr"},
441         {TERM_UMBER, "Sl", "Stealth"},
442         {TERM_YELLOW, "Stlt", "Stealth"},
443         {TERM_WHITE, "Rc", "Recall"},
444         {TERM_WHITE, "Al", "Alter"},
445         {0, NULL, NULL}
446 };
447 #endif
448
449 #define ADD_FLG(FLG) (bar_flags[FLG / 32] |= (1L << (FLG % 32)))
450 #define IS_FLG(FLG) (bar_flags[FLG / 32] & (1L << (FLG % 32)))
451
452
453 /*
454  *  Show status bar
455  */
456 static void prt_status(void)
457 {
458         u32b bar_flags[2];
459         int wid, hgt, row_statbar, max_col_statbar;
460         int i, col = 0, num = 0;
461         int space = 2;
462
463         Term_get_size(&wid, &hgt);
464         row_statbar = hgt + ROW_STATBAR;
465         max_col_statbar = wid + MAX_COL_STATBAR;
466
467         Term_erase(0, row_statbar, max_col_statbar);
468
469         bar_flags[0] = bar_flags[1] = 0L;
470
471         /* Tsuyoshi  */
472         if (p_ptr->tsuyoshi) ADD_FLG(BAR_TSUYOSHI);
473
474         /* Hallucinating */
475         if (p_ptr->image) ADD_FLG(BAR_HALLUCINATION);
476
477         /* Blindness */
478         if (p_ptr->blind) ADD_FLG(BAR_BLINDNESS);
479
480         /* Paralysis */
481         if (p_ptr->paralyzed) ADD_FLG(BAR_PARALYZE);
482
483         /* Confusion */
484         if (p_ptr->confused) ADD_FLG(BAR_CONFUSE);
485
486         /* Posioned */
487         if (p_ptr->poisoned) ADD_FLG(BAR_POISONED);
488
489         /* Times see-invisible */
490         if (p_ptr->tim_invis) ADD_FLG(BAR_SENSEUNSEEN);
491
492         /* Timed esp */
493         if (IS_TIM_ESP() ||
494                 (p_ptr->concent >= CONCENT_TELE_THRESHOLD)) ADD_FLG(BAR_TELEPATHY);
495
496         /* Timed regenerate */
497         if (p_ptr->tim_regen) ADD_FLG(BAR_REGENERATION);
498
499         /* Timed infra-vision */
500         if (p_ptr->tim_infra) ADD_FLG(BAR_INFRAVISION);
501
502         /* Protection from evil */
503         if (p_ptr->protevil) ADD_FLG(BAR_PROTEVIL);
504
505         /* Invulnerability */
506         if (IS_INVULN()) ADD_FLG(BAR_INVULN);
507
508         /* Wraith form */
509         if (p_ptr->wraith_form) ADD_FLG(BAR_WRAITH);
510
511         /* Kabenuke */
512         if (p_ptr->kabenuke) ADD_FLG(BAR_PASSWALL);
513
514         if (p_ptr->tim_reflect) ADD_FLG(BAR_REFLECTION);
515
516         /* Heroism */
517         if (IS_HERO()) ADD_FLG(BAR_HEROISM);
518
519         /* Super Heroism / berserk */
520         if (p_ptr->shero) ADD_FLG(BAR_BERSERK);
521
522         /* Blessed */
523         if (IS_BLESSED()) ADD_FLG(BAR_BLESSED);
524
525         /* Shield */
526         if (p_ptr->magicdef) ADD_FLG(BAR_MAGICDEFENSE);
527
528         if (p_ptr->tsubureru) ADD_FLG(BAR_EXPAND);
529
530         if (p_ptr->shield) ADD_FLG(BAR_STONESKIN);
531         
532         if (p_ptr->special_defense & NINJA_KAWARIMI) ADD_FLG(BAR_KAWARIMI);
533
534         /* Oppose Acid */
535         if (p_ptr->special_defense & DEFENSE_ACID) ADD_FLG(BAR_IMMACID);
536         if (IS_OPPOSE_ACID()) ADD_FLG(BAR_RESACID);
537
538         /* Oppose Lightning */
539         if (p_ptr->special_defense & DEFENSE_ELEC) ADD_FLG(BAR_IMMELEC);
540         if (IS_OPPOSE_ELEC()) ADD_FLG(BAR_RESELEC);
541
542         /* Oppose Fire */
543         if (p_ptr->special_defense & DEFENSE_FIRE) ADD_FLG(BAR_IMMFIRE);
544         if (IS_OPPOSE_FIRE()) ADD_FLG(BAR_RESFIRE);
545
546         /* Oppose Cold */
547         if (p_ptr->special_defense & DEFENSE_COLD) ADD_FLG(BAR_IMMCOLD);
548         if (IS_OPPOSE_COLD()) ADD_FLG(BAR_RESCOLD);
549
550         /* Oppose Poison */
551         if (IS_OPPOSE_POIS()) ADD_FLG(BAR_RESPOIS);
552
553         /* Word of Recall */
554         if (p_ptr->word_recall) ADD_FLG(BAR_RECALL);
555
556         /* Alter realiry */
557         if (p_ptr->alter_reality) ADD_FLG(BAR_ALTER);
558
559         /* Afraid */
560         if (p_ptr->afraid) ADD_FLG(BAR_AFRAID);
561
562         /* Resist time */
563         if (p_ptr->tim_res_time) ADD_FLG(BAR_RESTIME);
564
565         if (p_ptr->multishadow) ADD_FLG(BAR_MULTISHADOW);
566
567         /* Confusing Hands */
568         if (p_ptr->special_attack & ATTACK_CONFUSE) ADD_FLG(BAR_ATTKCONF);
569
570         if (p_ptr->resist_magic) ADD_FLG(BAR_REGMAGIC);
571
572         /* Ultimate-resistance */
573         if (p_ptr->ult_res) ADD_FLG(BAR_ULTIMATE);
574
575         /* tim levitation */
576         if (p_ptr->tim_levitation) ADD_FLG(BAR_LEVITATE);
577
578         if (p_ptr->tim_res_nether) ADD_FLG(BAR_RESNETH);
579
580         if (p_ptr->dustrobe) ADD_FLG(BAR_DUSTROBE);
581
582         /* Mahouken */
583         if (p_ptr->special_attack & ATTACK_FIRE) ADD_FLG(BAR_ATTKFIRE);
584         if (p_ptr->special_attack & ATTACK_COLD) ADD_FLG(BAR_ATTKCOLD);
585         if (p_ptr->special_attack & ATTACK_ELEC) ADD_FLG(BAR_ATTKELEC);
586         if (p_ptr->special_attack & ATTACK_ACID) ADD_FLG(BAR_ATTKACID);
587         if (p_ptr->special_attack & ATTACK_POIS) ADD_FLG(BAR_ATTKPOIS);
588         if (p_ptr->special_defense & NINJA_S_STEALTH) ADD_FLG(BAR_SUPERSTEALTH);
589
590         if (p_ptr->tim_sh_fire) ADD_FLG(BAR_SHFIRE);
591
592         /* tim stealth */
593         if (IS_TIM_STEALTH()) ADD_FLG(BAR_STEALTH);
594
595         if (p_ptr->tim_sh_touki) ADD_FLG(BAR_TOUKI);
596
597         /* Holy aura */
598         if (p_ptr->tim_sh_holy) ADD_FLG(BAR_SHHOLY);
599
600         /* An Eye for an Eye */
601         if (p_ptr->tim_eyeeye) ADD_FLG(BAR_EYEEYE);
602
603         /* Calcurate length */
604         for (i = 0; bar[i].sstr; i++)
605         {
606                 if (IS_FLG(i))
607                 {
608                         col += strlen(bar[i].lstr) + 1;
609                         num++;
610                 }
611         }
612
613         /* If there are not excess spaces for long strings, use short one */
614         if (col - 1 > max_col_statbar)
615         {
616                 space = 0;
617                 col = 0;
618
619                 for (i = 0; bar[i].sstr; i++)
620                 {
621                         if (IS_FLG(i))
622                         {
623                                 col += strlen(bar[i].sstr);
624                         }
625                 }
626
627                 /* If there are excess spaces for short string, use more */
628                 if (col - 1 <= max_col_statbar - (num-1))
629                 {
630                         space = 1;
631                         col += num - 1;
632                 }
633         }
634
635
636         /* Centering display column */
637         col = (max_col_statbar - col) / 2;
638
639         /* Display status bar */
640         for (i = 0; bar[i].sstr; i++)
641         {
642                 if (IS_FLG(i))
643                 {
644                         cptr str;
645                         if (space == 2) str = bar[i].lstr;
646                         else str = bar[i].sstr;
647
648                         c_put_str(bar[i].attr, str, row_statbar, col);
649                         col += strlen(str);
650                         if (space > 0) col++;
651                         if (col > max_col_statbar) break;
652                 }
653         }
654 }
655
656
657
658 /*
659  * Prints "title", including "wizard" or "winner" as needed.
660  */
661 static void prt_title(void)
662 {
663         cptr p = "";
664         char str[14];
665
666         /* Wizard */
667         if (p_ptr->wizard)
668         {
669 #ifdef JP
670                 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
671                 p = "[¥¦¥£¥¶¡¼¥É]";
672 #else
673                 p = "[=-WIZARD-=]";
674 #endif
675
676         }
677
678         /* Winner */
679         else if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
680         {
681                 if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
682                 {
683 #ifdef JP
684                         /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
685                         p = "*¿¿¡¦¾¡Íø¼Ô*";
686 #else
687                         p = "*TRUEWINNER*";
688 #endif
689                 }
690                 else
691                 {
692 #ifdef JP
693                         /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
694                         p = "***¾¡Íø¼Ô***";
695 #else
696                         p = "***WINNER***";
697 #endif
698                 }
699         }
700
701         /* Normal */
702         else
703         {
704                 my_strcpy(str, player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5], sizeof(str));
705                 p = str;
706         }
707
708         prt_field(p, ROW_TITLE, COL_TITLE);
709 }
710
711
712 /*
713  * Prints level
714  */
715 static void prt_level(void)
716 {
717         char tmp[32];
718
719 #ifdef JP
720         sprintf(tmp, "%5d", p_ptr->lev);
721 #else
722         sprintf(tmp, "%6d", p_ptr->lev);
723 #endif
724
725
726         if (p_ptr->lev >= p_ptr->max_plv)
727         {
728 #ifdef JP
729                 put_str("¥ì¥Ù¥ë ", ROW_LEVEL, 0);
730                 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
731 #else
732                 put_str("LEVEL ", ROW_LEVEL, 0);
733                 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 6);
734 #endif
735
736         }
737         else
738         {
739 #ifdef JP
740                 put_str("x¥ì¥Ù¥ë", ROW_LEVEL, 0);
741                 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
742 #else
743                 put_str("Level ", ROW_LEVEL, 0);
744                 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 6);
745 #endif
746
747         }
748 }
749
750
751 /*
752  * Display the experience
753  */
754 static void prt_exp(void)
755 {
756         char out_val[32];
757
758         if ((!exp_need)||(p_ptr->prace == RACE_ANDROID))
759         {
760 #ifdef JP
761         (void)sprintf(out_val, "%7ld", (long)p_ptr->exp);
762 #else
763         (void)sprintf(out_val, "%8ld", (long)p_ptr->exp);
764 #endif
765         }
766         else
767         {
768                 if (p_ptr->lev >= PY_MAX_LEVEL)
769                 {
770                         (void)sprintf(out_val, "********");
771                 }
772                 else
773                 {
774 #ifdef JP
775                         (void)sprintf(out_val, "%7ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
776 #else      
777                         (void)sprintf(out_val, "%8ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
778 #endif
779                 }
780         }
781
782         if (p_ptr->exp >= p_ptr->max_exp)
783         {
784 #ifdef JP
785                 if (p_ptr->prace == RACE_ANDROID) put_str("¶¯²½ ", ROW_EXP, 0);
786                 else put_str("·Ð¸³ ", ROW_EXP, 0);
787                 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 5);
788 #else
789                 if (p_ptr->prace == RACE_ANDROID) put_str("Cst ", ROW_EXP, 0);
790                 else put_str("EXP ", ROW_EXP, 0);
791                 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
792 #endif
793
794         }
795         else
796         {
797 #ifdef JP
798                 put_str("x·Ð¸³", ROW_EXP, 0);
799                 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 5);
800 #else
801                 put_str("Exp ", ROW_EXP, 0);
802                 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
803 #endif
804
805         }
806 }
807
808 /*
809  * Prints current gold
810  */
811 static void prt_gold(void)
812 {
813         char tmp[32];
814
815 #ifdef JP
816         put_str("¡ð ", ROW_GOLD, COL_GOLD);
817 #else
818         put_str("AU ", ROW_GOLD, COL_GOLD);
819 #endif
820
821         sprintf(tmp, "%9ld", (long)p_ptr->au);
822         c_put_str(TERM_L_GREEN, tmp, ROW_GOLD, COL_GOLD + 3);
823 }
824
825
826
827 /*
828  * Prints current AC
829  */
830 static void prt_ac(void)
831 {
832         char tmp[32];
833
834 #ifdef JP
835 /* AC ¤Îɽ¼¨Êý¼°¤òÊѹ¹¤·¤Æ¤¤¤ë */
836         put_str(" £Á£Ã(     )", ROW_AC, COL_AC);
837         sprintf(tmp, "%5d", p_ptr->dis_ac + p_ptr->dis_to_a);
838         c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 6);
839 #else
840         put_str("Cur AC ", ROW_AC, COL_AC);
841         sprintf(tmp, "%5d", p_ptr->dis_ac + p_ptr->dis_to_a);
842         c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 7);
843 #endif
844
845 }
846
847
848 /*
849  * Prints Cur/Max hit points
850  */
851 static void prt_hp(void)
852 {
853 /* ¥Ò¥Ã¥È¥Ý¥¤¥ó¥È¤Îɽ¼¨ÊýË¡¤òÊѹ¹ */
854         char tmp[32];
855   
856         byte color;
857   
858         /* ¥¿¥¤¥È¥ë */
859 /*      put_str(" £È£Ð¡¦£Í£Ð", ROW_HPMP, COL_HPMP); */
860
861         put_str("HP", ROW_CURHP, COL_CURHP);
862
863         /* ¸½ºß¤Î¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
864         sprintf(tmp, "%4ld", p_ptr->chp);
865
866         if (p_ptr->chp >= p_ptr->mhp)
867         {
868                 color = TERM_L_GREEN;
869         }
870         else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
871         {
872                 color = TERM_YELLOW;
873         }
874         else
875         {
876                 color = TERM_RED;
877         }
878
879         c_put_str(color, tmp, ROW_CURHP, COL_CURHP+3);
880
881         /* ¶èÀÚ¤ê */
882         put_str( "/", ROW_CURHP, COL_CURHP + 7 );
883
884         /* ºÇÂç¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
885         sprintf(tmp, "%4ld", p_ptr->mhp);
886         color = TERM_L_GREEN;
887
888         c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8 );
889 }
890
891
892 /*
893  * Prints players max/cur spell points
894  */
895 static void prt_sp(void)
896 {
897 /* ¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È¤Îɽ¼¨ÊýË¡¤òÊѹ¹¤·¤Æ¤¤¤ë */
898         char tmp[32];
899         byte color;
900
901
902         /* Do not show mana unless it matters */
903         if (!mp_ptr->spell_book) return;
904
905         /* ¥¿¥¤¥È¥ë */
906 /*      put_str(" £Í£Ð / ºÇÂç", ROW_MAXSP, COL_MAXSP); */
907
908 #ifdef JP
909         put_str("MP", ROW_CURSP, COL_CURSP);
910 #else
911         put_str("SP", ROW_CURSP, COL_CURSP);
912 #endif
913
914         /* ¸½ºß¤Î¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
915         sprintf(tmp, "%4ld", p_ptr->csp);
916
917         if (p_ptr->csp >= p_ptr->msp)
918         {
919                 color = TERM_L_GREEN;
920         }
921         else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
922         {
923                 color = TERM_YELLOW;
924         }
925         else
926         {
927                 color = TERM_RED;
928         }
929
930         c_put_str(color, tmp, ROW_CURSP, COL_CURSP+3);
931
932         /* ¶èÀÚ¤ê */
933         put_str( "/", ROW_CURSP, COL_CURSP + 7 );
934
935         /* ºÇÂç¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
936         sprintf(tmp, "%4ld", p_ptr->msp);
937         color = TERM_L_GREEN;
938
939         c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
940 }
941
942
943 /*
944  * Prints depth in stat area
945  */
946 static void prt_depth(void)
947 {
948         char depths[32];
949         int wid, hgt, row_depth, col_depth;
950         byte attr = TERM_WHITE;
951
952         Term_get_size(&wid, &hgt);
953         col_depth = wid + COL_DEPTH;
954         row_depth = hgt + ROW_DEPTH;
955
956         if (!dun_level)
957         {
958 #ifdef JP
959                 strcpy(depths, "ÃϾå");
960 #else
961                 strcpy(depths, "Surf.");
962 #endif
963         }
964         else if (p_ptr->inside_quest && !dungeon_type)
965         {
966 #ifdef JP
967                 strcpy(depths, "ÃϾå");
968 #else
969                 strcpy(depths, "Quest");
970 #endif
971         }
972         else
973         {
974 #ifdef JP
975                 if (depth_in_feet) (void)sprintf(depths, "%d ft", dun_level * 50);
976                 else (void)sprintf(depths, "%d ³¬", dun_level);
977 #else
978                 if (depth_in_feet) (void)sprintf(depths, "%d ft", dun_level * 50);
979                 else (void)sprintf(depths, "Lev %d", dun_level);
980 #endif
981
982
983                 /* Get color of level based on feeling  -JSV- */
984                 switch (p_ptr->feeling)
985                 {
986                 case  0: attr = TERM_SLATE;   break; /* Unknown */
987                 case  1: attr = TERM_L_BLUE;  break; /* Special */
988                 case  2: attr = TERM_VIOLET;  break; /* Horrible visions */
989                 case  3: attr = TERM_RED;     break; /* Very dangerous */
990                 case  4: attr = TERM_L_RED;   break; /* Very bad feeling */
991                 case  5: attr = TERM_ORANGE;  break; /* Bad feeling */
992                 case  6: attr = TERM_YELLOW;  break; /* Nervous */
993                 case  7: attr = TERM_L_UMBER; break; /* Luck is turning */
994                 case  8: attr = TERM_L_WHITE; break; /* Don't like */
995                 case  9: attr = TERM_WHITE;   break; /* Reasonably safe */
996                 case 10: attr = TERM_WHITE;   break; /* Boring place */
997                 }
998         }
999
1000         /* Right-Adjust the "depth", and clear old values */
1001         c_prt(attr, format("%7s", depths), row_depth, col_depth);
1002 }
1003
1004
1005 /*
1006  * Prints status of hunger
1007  */
1008 static void prt_hunger(void)
1009 {
1010         /* Fainting / Starving */
1011         if (p_ptr->food < PY_FOOD_FAINT)
1012         {
1013 #ifdef JP
1014                 c_put_str(TERM_RED, "¿ê¼å  ", ROW_HUNGRY, COL_HUNGRY);
1015 #else
1016                 c_put_str(TERM_RED, "Weak  ", ROW_HUNGRY, COL_HUNGRY);
1017 #endif
1018
1019         }
1020
1021         /* Weak */
1022         else if (p_ptr->food < PY_FOOD_WEAK)
1023         {
1024 #ifdef JP
1025                 c_put_str(TERM_ORANGE, "¿ê¼å  ", ROW_HUNGRY, COL_HUNGRY);
1026 #else
1027                 c_put_str(TERM_ORANGE, "Weak  ", ROW_HUNGRY, COL_HUNGRY);
1028 #endif
1029
1030         }
1031
1032         /* Hungry */
1033         else if (p_ptr->food < PY_FOOD_ALERT)
1034         {
1035 #ifdef JP
1036                 c_put_str(TERM_YELLOW, "¶õÊ¢  ", ROW_HUNGRY, COL_HUNGRY);
1037 #else
1038                 c_put_str(TERM_YELLOW, "Hungry", ROW_HUNGRY, COL_HUNGRY);
1039 #endif
1040
1041         }
1042
1043         /* Normal */
1044         else if (p_ptr->food < PY_FOOD_FULL)
1045         {
1046                 c_put_str(TERM_L_GREEN, "      ", ROW_HUNGRY, COL_HUNGRY);
1047         }
1048
1049         /* Full */
1050         else if (p_ptr->food < PY_FOOD_MAX)
1051         {
1052 #ifdef JP
1053                 c_put_str(TERM_L_GREEN, "ËþÊ¢  ", ROW_HUNGRY, COL_HUNGRY);
1054 #else
1055                 c_put_str(TERM_L_GREEN, "Full  ", ROW_HUNGRY, COL_HUNGRY);
1056 #endif
1057
1058         }
1059
1060         /* Gorged */
1061         else
1062         {
1063 #ifdef JP
1064                 c_put_str(TERM_GREEN, "¿©²á¤®", ROW_HUNGRY, COL_HUNGRY);
1065 #else
1066                 c_put_str(TERM_GREEN, "Gorged", ROW_HUNGRY, COL_HUNGRY);
1067 #endif
1068
1069         }
1070 }
1071
1072
1073 /*
1074  * Prints Searching, Resting, Paralysis, or 'count' status
1075  * Display is always exactly 10 characters wide (see below)
1076  *
1077  * This function was a major bottleneck when resting, so a lot of
1078  * the text formatting code was optimized in place below.
1079  */
1080 static void prt_state(void)
1081 {
1082         byte attr = TERM_WHITE;
1083
1084         char text[5];
1085
1086         /* Repeating */
1087         if (command_rep)
1088         {
1089                 if (command_rep > 999)
1090                 {
1091 #ifdef JP
1092 sprintf(text, "%2d00", command_rep / 100);
1093 #else
1094                         (void)sprintf(text, "%2d00", command_rep / 100);
1095 #endif
1096
1097                 }
1098                 else
1099                 {
1100 #ifdef JP
1101 sprintf(text, "  %2d", command_rep);
1102 #else
1103                         (void)sprintf(text, "  %2d", command_rep);
1104 #endif
1105
1106                 }
1107         }
1108
1109         /* Action */
1110         else
1111         {
1112                 switch(p_ptr->action)
1113                 {
1114                         case ACTION_SEARCH:
1115                         {
1116 #ifdef JP
1117                                 strcpy(text, "õº÷");
1118 #else
1119                                 strcpy(text, "Sear");
1120 #endif
1121                                 break;
1122                         }
1123                         case ACTION_REST:
1124                         {
1125                                 int i;
1126
1127                                 /* Start with "Rest" */
1128 #ifdef JP
1129                                 strcpy(text, "    ");
1130 #else
1131                                 strcpy(text, "    ");
1132 #endif
1133
1134
1135                                 /* Extensive (timed) rest */
1136                                 if (resting >= 1000)
1137                                 {
1138                                         i = resting / 100;
1139                                         text[3] = '0';
1140                                         text[2] = '0';
1141                                         text[1] = '0' + (i % 10);
1142                                         text[0] = '0' + (i / 10);
1143                                 }
1144
1145                                 /* Long (timed) rest */
1146                                 else if (resting >= 100)
1147                                 {
1148                                         i = resting;
1149                                         text[3] = '0' + (i % 10);
1150                                         i = i / 10;
1151                                         text[2] = '0' + (i % 10);
1152                                         text[1] = '0' + (i / 10);
1153                                 }
1154
1155                                 /* Medium (timed) rest */
1156                                 else if (resting >= 10)
1157                                 {
1158                                         i = resting;
1159                                         text[3] = '0' + (i % 10);
1160                                         text[2] = '0' + (i / 10);
1161                                 }
1162
1163                                 /* Short (timed) rest */
1164                                 else if (resting > 0)
1165                                 {
1166                                         i = resting;
1167                                         text[3] = '0' + (i);
1168                                 }
1169
1170                                 /* Rest until healed */
1171                                 else if (resting == -1)
1172                                 {
1173                                         text[0] = text[1] = text[2] = text[3] = '*';
1174                                 }
1175
1176                                 /* Rest until done */
1177                                 else if (resting == -2)
1178                                 {
1179                                         text[0] = text[1] = text[2] = text[3] = '&';
1180                                 }
1181                                 break;
1182                         }
1183                         case ACTION_LEARN:
1184                         {
1185 #ifdef JP
1186                                 strcpy(text, "³Ø½¬");
1187 #else
1188                                 strcpy(text, "lear");
1189 #endif
1190                                 if (new_mane) attr = TERM_L_RED;
1191                                 break;
1192                         }
1193                         case ACTION_FISH:
1194                         {
1195 #ifdef JP
1196                                 strcpy(text, "Äà¤ê");
1197 #else
1198                                 strcpy(text, "fish");
1199 #endif
1200                                 break;
1201                         }
1202                         case ACTION_KAMAE:
1203                         {
1204                                 int i;
1205                                 for (i = 0; i < MAX_KAMAE; i++)
1206                                         if (p_ptr->special_defense & (KAMAE_GENBU << i)) break;
1207                                 switch (i)
1208                                 {
1209                                         case 0: attr = TERM_GREEN;break;
1210                                         case 1: attr = TERM_WHITE;break;
1211                                         case 2: attr = TERM_L_BLUE;break;
1212                                         case 3: attr = TERM_L_RED;break;
1213                                 }
1214                                 strcpy(text, kamae_shurui[i].desc);
1215                                 break;
1216                         }
1217                         case ACTION_KATA:
1218                         {
1219                                 int i;
1220                                 for (i = 0; i < MAX_KATA; i++)
1221                                         if (p_ptr->special_defense & (KATA_IAI << i)) break;
1222                                 strcpy(text, kata_shurui[i].desc);
1223                                 break;
1224                         }
1225                         case ACTION_SING:
1226                         {
1227 #ifdef JP
1228                                 strcpy(text, "²Î  ");
1229 #else
1230                                 strcpy(text, "Sing");
1231 #endif
1232                                 break;
1233                         }
1234                         case ACTION_HAYAGAKE:
1235                         {
1236 #ifdef JP
1237                                 strcpy(text, "®¶î");
1238 #else
1239                                 strcpy(text, "Fast");
1240 #endif
1241                                 break;
1242                         }
1243                         default:
1244                         {
1245                                 strcpy(text, "    ");
1246                                 break;
1247                         }
1248                 }
1249         }
1250
1251         /* Display the info (or blanks) */
1252         c_put_str(attr, format("%5.5s",text), ROW_STATE, COL_STATE);
1253 }
1254
1255
1256 /*
1257  * Prints the speed of a character.                     -CJS-
1258  */
1259 static void prt_speed(void)
1260 {
1261         int i = p_ptr->pspeed;
1262         bool is_fast = IS_FAST();
1263
1264         byte attr = TERM_WHITE;
1265         char buf[32] = "";
1266         int wid, hgt, row_speed, col_speed;
1267
1268         Term_get_size(&wid, &hgt);
1269         col_speed = wid + COL_SPEED;
1270         row_speed = hgt + ROW_SPEED;
1271
1272         /* Hack -- Visually "undo" the Search Mode Slowdown */
1273         if (p_ptr->action == ACTION_SEARCH) i += 10;
1274
1275         /* Fast */
1276         if (i > 110)
1277         {
1278                 if (p_ptr->riding)
1279                 {
1280                         monster_type *m_ptr = &m_list[p_ptr->riding];
1281                         if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
1282                         else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
1283                         else attr = TERM_GREEN;
1284                 }
1285                 else if ((is_fast && !p_ptr->slow) || p_ptr->lightspeed) attr = TERM_YELLOW;
1286                 else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
1287                 else attr = TERM_L_GREEN;
1288 #ifdef JP
1289                 sprintf(buf, "%s(+%d)", (p_ptr->riding ? "¾èÇÏ" : "²Ã®"), (i - 110));
1290 #else
1291                 sprintf(buf, "Fast(+%d)", (i - 110));
1292 #endif
1293
1294         }
1295
1296         /* Slow */
1297         else if (i < 110)
1298         {
1299                 if (p_ptr->riding)
1300                 {
1301                         monster_type *m_ptr = &m_list[p_ptr->riding];
1302                         if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
1303                         else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
1304                         else attr = TERM_RED;
1305                 }
1306                 else if (is_fast && !p_ptr->slow) attr = TERM_YELLOW;
1307                 else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
1308                 else attr = TERM_L_UMBER;
1309 #ifdef JP
1310                 sprintf(buf, "%s(-%d)", (p_ptr->riding ? "¾èÇÏ" : "¸ºÂ®"), (110 - i));
1311 #else
1312                 sprintf(buf, "Slow(-%d)", (110 - i));
1313 #endif
1314         }
1315         else if (p_ptr->riding)
1316         {
1317                 attr = TERM_GREEN;
1318 #ifdef JP
1319                 strcpy(buf, "¾èÇÏÃæ");
1320 #else
1321                 strcpy(buf, "Riding");
1322 #endif
1323         }
1324
1325         /* Display the speed */
1326         c_put_str(attr, format("%-9s", buf), row_speed, col_speed);
1327 }
1328
1329
1330 static void prt_study(void)
1331 {
1332         int wid, hgt, row_study, col_study;
1333
1334         Term_get_size(&wid, &hgt);
1335         col_study = wid + COL_STUDY;
1336         row_study = hgt + ROW_STUDY;
1337
1338         if (p_ptr->new_spells)
1339         {
1340 #ifdef JP
1341                 put_str("³Ø½¬", row_study, col_study);
1342 #else
1343                 put_str("Stud", row_study, col_study);
1344 #endif
1345
1346         }
1347         else
1348         {
1349                 put_str("    ", row_study, col_study);
1350         }
1351 }
1352
1353
1354 static void prt_imitation(void)
1355 {
1356         int wid, hgt, row_study, col_study;
1357
1358         Term_get_size(&wid, &hgt);
1359         col_study = wid + COL_STUDY;
1360         row_study = hgt + ROW_STUDY;
1361
1362         if (p_ptr->pclass == CLASS_IMITATOR)
1363         {
1364                 if (p_ptr->mane_num)
1365                 {
1366                         byte attr;
1367                         if (new_mane) attr = TERM_L_RED;
1368                         else attr = TERM_WHITE;
1369 #ifdef JP
1370                         c_put_str(attr, "¤Þ¤Í", row_study, col_study);
1371 #else
1372                         c_put_str(attr, "Imit", row_study, col_study);
1373 #endif
1374                 }
1375                 else
1376                 {
1377                         put_str("    ", row_study, col_study);
1378                 }
1379         }
1380 }
1381
1382
1383 static void prt_cut(void)
1384 {
1385         int c = p_ptr->cut;
1386
1387         if (c > 1000)
1388         {
1389 #ifdef JP
1390                 c_put_str(TERM_L_RED, "Ã×Ì¿½ý      ", ROW_CUT, COL_CUT);
1391 #else
1392                 c_put_str(TERM_L_RED, "Mortal wound", ROW_CUT, COL_CUT);
1393 #endif
1394
1395         }
1396         else if (c > 200)
1397         {
1398 #ifdef JP
1399                 c_put_str(TERM_RED, "¤Ò¤É¤¤¿¼¼ê  ", ROW_CUT, COL_CUT);
1400 #else
1401                 c_put_str(TERM_RED, "Deep gash   ", ROW_CUT, COL_CUT);
1402 #endif
1403
1404         }
1405         else if (c > 100)
1406         {
1407 #ifdef JP
1408                 c_put_str(TERM_RED, "½Å½ý        ", ROW_CUT, COL_CUT);
1409 #else
1410                 c_put_str(TERM_RED, "Severe cut  ", ROW_CUT, COL_CUT);
1411 #endif
1412
1413         }
1414         else if (c > 50)
1415         {
1416 #ifdef JP
1417                 c_put_str(TERM_ORANGE, "ÂçÊѤʽý    ", ROW_CUT, COL_CUT);
1418 #else
1419                 c_put_str(TERM_ORANGE, "Nasty cut   ", ROW_CUT, COL_CUT);
1420 #endif
1421
1422         }
1423         else if (c > 25)
1424         {
1425 #ifdef JP
1426                 c_put_str(TERM_ORANGE, "¤Ò¤É¤¤½ý    ", ROW_CUT, COL_CUT);
1427 #else
1428                 c_put_str(TERM_ORANGE, "Bad cut     ", ROW_CUT, COL_CUT);
1429 #endif
1430
1431         }
1432         else if (c > 10)
1433         {
1434 #ifdef JP
1435                 c_put_str(TERM_YELLOW, "·Ú½ý        ", ROW_CUT, COL_CUT);
1436 #else
1437                 c_put_str(TERM_YELLOW, "Light cut   ", ROW_CUT, COL_CUT);
1438 #endif
1439
1440         }
1441         else if (c)
1442         {
1443 #ifdef JP
1444                 c_put_str(TERM_YELLOW, "¤«¤¹¤ê½ý    ", ROW_CUT, COL_CUT);
1445 #else
1446                 c_put_str(TERM_YELLOW, "Graze       ", ROW_CUT, COL_CUT);
1447 #endif
1448
1449         }
1450         else
1451         {
1452                 put_str("            ", ROW_CUT, COL_CUT);
1453         }
1454 }
1455
1456
1457
1458 static void prt_stun(void)
1459 {
1460         int s = p_ptr->stun;
1461
1462         if (s > 100)
1463         {
1464 #ifdef JP
1465                 c_put_str(TERM_RED, "°Õ¼±ÉÔÌÀÎÆ  ", ROW_STUN, COL_STUN);
1466 #else
1467                 c_put_str(TERM_RED, "Knocked out ", ROW_STUN, COL_STUN);
1468 #endif
1469
1470         }
1471         else if (s > 50)
1472         {
1473 #ifdef JP
1474                 c_put_str(TERM_ORANGE, "¤Ò¤É¤¯Û¯Û°  ", ROW_STUN, COL_STUN);
1475 #else
1476                 c_put_str(TERM_ORANGE, "Heavy stun  ", ROW_STUN, COL_STUN);
1477 #endif
1478
1479         }
1480         else if (s)
1481         {
1482 #ifdef JP
1483                 c_put_str(TERM_ORANGE, "ۯ۰        ", ROW_STUN, COL_STUN);
1484 #else
1485                 c_put_str(TERM_ORANGE, "Stun        ", ROW_STUN, COL_STUN);
1486 #endif
1487
1488         }
1489         else
1490         {
1491                 put_str("            ", ROW_STUN, COL_STUN);
1492         }
1493 }
1494
1495
1496
1497 /*
1498  * Redraw the "monster health bar"      -DRS-
1499  * Rather extensive modifications by    -BEN-
1500  *
1501  * The "monster health bar" provides visual feedback on the "health"
1502  * of the monster currently being "tracked".  There are several ways
1503  * to "track" a monster, including targetting it, attacking it, and
1504  * affecting it (and nobody else) with a ranged attack.
1505  *
1506  * Display the monster health bar (affectionately known as the
1507  * "health-o-meter").  Clear health bar if nothing is being tracked.
1508  * Auto-track current target monster when bored.  Note that the
1509  * health-bar stops tracking any monster that "disappears".
1510  */
1511 static void health_redraw(bool riding)
1512 {
1513         s16b health_who;
1514         int row, col;
1515         monster_type *m_ptr;
1516
1517         if (riding)
1518         {
1519                 health_who = p_ptr->riding;
1520                 row = ROW_RIDING_INFO;
1521                 col = COL_RIDING_INFO;
1522         }
1523         else
1524         {
1525                 health_who = p_ptr->health_who;
1526                 row = ROW_INFO;
1527                 col = COL_INFO;
1528         }
1529
1530         m_ptr = &m_list[health_who];
1531
1532         /* Not tracking */
1533         if (!health_who)
1534         {
1535                 /* Erase the health bar */
1536                 Term_erase(col, row, 12);
1537         }
1538
1539         /* Tracking an unseen monster */
1540         else if (!m_ptr->ml)
1541         {
1542                 /* Indicate that the monster health is "unknown" */
1543                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1544         }
1545
1546         /* Tracking a hallucinatory monster */
1547         else if (p_ptr->image)
1548         {
1549                 /* Indicate that the monster health is "unknown" */
1550                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1551         }
1552
1553         /* Tracking a dead monster (???) */
1554         else if (m_ptr->hp < 0)
1555         {
1556                 /* Indicate that the monster health is "unknown" */
1557                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1558         }
1559
1560         /* Tracking a visible monster */
1561         else
1562         {
1563                 /* Extract the "percent" of health */
1564                 int pct = 100L * m_ptr->hp / m_ptr->maxhp;
1565                 int pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
1566
1567                 /* Convert percent into "health" */
1568                 int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
1569
1570                 /* Default to almost dead */
1571                 byte attr = TERM_RED;
1572
1573                 /* Invulnerable */
1574                 if (MON_INVULNER(m_ptr)) attr = TERM_WHITE;
1575
1576                 /* Asleep */
1577                 else if (MON_CSLEEP(m_ptr)) attr = TERM_BLUE;
1578
1579                 /* Afraid */
1580                 else if (MON_MONFEAR(m_ptr)) attr = TERM_VIOLET;
1581
1582                 /* Healthy */
1583                 else if (pct >= 100) attr = TERM_L_GREEN;
1584
1585                 /* Somewhat Wounded */
1586                 else if (pct >= 60) attr = TERM_YELLOW;
1587
1588                 /* Wounded */
1589                 else if (pct >= 25) attr = TERM_ORANGE;
1590
1591                 /* Badly wounded */
1592                 else if (pct >= 10) attr = TERM_L_RED;
1593
1594                 /* Default to "unknown" */
1595                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1596
1597                 /* Dump the current "health" (use '*' symbols) */
1598                 Term_putstr(col + 1, row, len, attr, "**********");
1599         }
1600 }
1601
1602
1603
1604 /*
1605  * Display basic info (mostly left of map)
1606  */
1607 static void prt_frame_basic(void)
1608 {
1609         int i;
1610
1611         /* Race and Class */
1612         if (p_ptr->mimic_form)
1613                 prt_field(mimic_info[p_ptr->mimic_form].title, ROW_RACE, COL_RACE);
1614         else
1615         {
1616                 char str[14];
1617                 my_strcpy(str, rp_ptr->title, sizeof(str));
1618                 prt_field(str, ROW_RACE, COL_RACE);
1619         }
1620 /*      prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
1621 /*      prt_field(ap_ptr->title, ROW_SEIKAKU, COL_SEIKAKU); */
1622
1623
1624         /* Title */
1625         prt_title();
1626
1627         /* Level/Experience */
1628         prt_level();
1629         prt_exp();
1630
1631         /* All Stats */
1632         for (i = 0; i < 6; i++) prt_stat(i);
1633
1634         /* Armor */
1635         prt_ac();
1636
1637         /* Hitpoints */
1638         prt_hp();
1639
1640         /* Spellpoints */
1641         prt_sp();
1642
1643         /* Gold */
1644         prt_gold();
1645
1646         /* Current depth */
1647         prt_depth();
1648
1649         /* Special */
1650         health_redraw(FALSE);
1651         health_redraw(TRUE);
1652 }
1653
1654
1655 /*
1656  * Display extra info (mostly below map)
1657  */
1658 static void prt_frame_extra(void)
1659 {
1660         /* Cut/Stun */
1661         prt_cut();
1662         prt_stun();
1663
1664         /* Food */
1665         prt_hunger();
1666
1667         /* State */
1668         prt_state();
1669
1670         /* Speed */
1671         prt_speed();
1672
1673         /* Study spells */
1674         prt_study();
1675
1676         prt_imitation();
1677
1678         prt_status();
1679 }
1680
1681
1682 /*
1683  * Hack -- display inventory in sub-windows
1684  */
1685 static void fix_inven(void)
1686 {
1687         int j;
1688
1689         /* Scan windows */
1690         for (j = 0; j < 8; j++)
1691         {
1692                 term *old = Term;
1693
1694                 /* No window */
1695                 if (!angband_term[j]) continue;
1696
1697                 /* No relevant flags */
1698                 if (!(window_flag[j] & (PW_INVEN))) continue;
1699
1700                 /* Activate */
1701                 Term_activate(angband_term[j]);
1702
1703                 /* Display inventory */
1704                 display_inven();
1705
1706                 /* Fresh */
1707                 Term_fresh();
1708
1709                 /* Restore */
1710                 Term_activate(old);
1711         }
1712 }
1713
1714
1715
1716 /*
1717  * Hack -- display equipment in sub-windows
1718  */
1719 static void fix_equip(void)
1720 {
1721         int j;
1722
1723         /* Scan windows */
1724         for (j = 0; j < 8; j++)
1725         {
1726                 term *old = Term;
1727
1728                 /* No window */
1729                 if (!angband_term[j]) continue;
1730
1731                 /* No relevant flags */
1732                 if (!(window_flag[j] & (PW_EQUIP))) continue;
1733
1734                 /* Activate */
1735                 Term_activate(angband_term[j]);
1736
1737                 /* Display equipment */
1738                 display_equip();
1739
1740                 /* Fresh */
1741                 Term_fresh();
1742
1743                 /* Restore */
1744                 Term_activate(old);
1745         }
1746 }
1747
1748
1749 /*
1750  * Hack -- display equipment in sub-windows
1751  */
1752 static void fix_spell(void)
1753 {
1754         int j;
1755
1756         /* Scan windows */
1757         for (j = 0; j < 8; j++)
1758         {
1759                 term *old = Term;
1760
1761                 /* No window */
1762                 if (!angband_term[j]) continue;
1763
1764                 /* No relevant flags */
1765                 if (!(window_flag[j] & (PW_SPELL))) continue;
1766
1767                 /* Activate */
1768                 Term_activate(angband_term[j]);
1769
1770                 /* Display spell list */
1771                 display_spell_list();
1772
1773                 /* Fresh */
1774                 Term_fresh();
1775
1776                 /* Restore */
1777                 Term_activate(old);
1778         }
1779 }
1780
1781
1782 /*
1783  * Hack -- display character in sub-windows
1784  */
1785 static void fix_player(void)
1786 {
1787         int j;
1788
1789         /* Scan windows */
1790         for (j = 0; j < 8; j++)
1791         {
1792                 term *old = Term;
1793
1794                 /* No window */
1795                 if (!angband_term[j]) continue;
1796
1797                 /* No relevant flags */
1798                 if (!(window_flag[j] & (PW_PLAYER))) continue;
1799
1800                 /* Activate */
1801                 Term_activate(angband_term[j]);
1802
1803                 update_playtime();
1804
1805                 /* Display player */
1806                 display_player(0);
1807
1808                 /* Fresh */
1809                 Term_fresh();
1810
1811                 /* Restore */
1812                 Term_activate(old);
1813         }
1814 }
1815
1816
1817
1818 /*
1819  * Hack -- display recent messages in sub-windows
1820  *
1821  * XXX XXX XXX Adjust for width and split messages
1822  */
1823 static void fix_message(void)
1824 {
1825         int j, i;
1826         int w, h;
1827         int x, y;
1828
1829         /* Scan windows */
1830         for (j = 0; j < 8; j++)
1831         {
1832                 term *old = Term;
1833
1834                 /* No window */
1835                 if (!angband_term[j]) continue;
1836
1837                 /* No relevant flags */
1838                 if (!(window_flag[j] & (PW_MESSAGE))) continue;
1839
1840                 /* Activate */
1841                 Term_activate(angband_term[j]);
1842
1843                 /* Get size */
1844                 Term_get_size(&w, &h);
1845
1846                 /* Dump messages */
1847                 for (i = 0; i < h; i++)
1848                 {
1849                         /* Dump the message on the appropriate line */
1850                         Term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
1851
1852                         /* Cursor */
1853                         Term_locate(&x, &y);
1854
1855                         /* Clear to end of line */
1856                         Term_erase(x, y, 255);
1857                 }
1858
1859                 /* Fresh */
1860                 Term_fresh();
1861
1862                 /* Restore */
1863                 Term_activate(old);
1864         }
1865 }
1866
1867
1868 /*
1869  * Hack -- display overhead view in sub-windows
1870  *
1871  * Note that the "player" symbol does NOT appear on the map.
1872  */
1873 static void fix_overhead(void)
1874 {
1875         int j;
1876
1877         int cy, cx;
1878
1879         /* Scan windows */
1880         for (j = 0; j < 8; j++)
1881         {
1882                 term *old = Term;
1883                 int wid, hgt;
1884
1885                 /* No window */
1886                 if (!angband_term[j]) continue;
1887
1888                 /* No relevant flags */
1889                 if (!(window_flag[j] & (PW_OVERHEAD))) continue;
1890
1891                 /* Activate */
1892                 Term_activate(angband_term[j]);
1893
1894                 /* Full map in too small window is useless  */
1895                 Term_get_size(&wid, &hgt);
1896                 if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2)
1897                 {
1898                         /* Redraw map */
1899                         display_map(&cy, &cx);
1900
1901                         /* Fresh */
1902                         Term_fresh();
1903                 }
1904
1905                 /* Restore */
1906                 Term_activate(old);
1907         }
1908 }
1909
1910
1911 /*
1912  * Hack -- display dungeon view in sub-windows
1913  */
1914 static void fix_dungeon(void)
1915 {
1916         int j;
1917
1918         /* Scan windows */
1919         for (j = 0; j < 8; j++)
1920         {
1921                 term *old = Term;
1922
1923                 /* No window */
1924                 if (!angband_term[j]) continue;
1925
1926                 /* No relevant flags */
1927                 if (!(window_flag[j] & (PW_DUNGEON))) continue;
1928
1929                 /* Activate */
1930                 Term_activate(angband_term[j]);
1931
1932                 /* Redraw dungeon view */
1933                 display_dungeon();
1934
1935                 /* Fresh */
1936                 Term_fresh();
1937
1938                 /* Restore */
1939                 Term_activate(old);
1940         }
1941 }
1942
1943
1944 /*
1945  * Hack -- display monster recall in sub-windows
1946  */
1947 static void fix_monster(void)
1948 {
1949         int j;
1950
1951         /* Scan windows */
1952         for (j = 0; j < 8; j++)
1953         {
1954                 term *old = Term;
1955
1956                 /* No window */
1957                 if (!angband_term[j]) continue;
1958
1959                 /* No relevant flags */
1960                 if (!(window_flag[j] & (PW_MONSTER))) continue;
1961
1962                 /* Activate */
1963                 Term_activate(angband_term[j]);
1964
1965                 /* Display monster race info */
1966                 if (p_ptr->monster_race_idx) display_roff(p_ptr->monster_race_idx);
1967
1968                 /* Fresh */
1969                 Term_fresh();
1970
1971                 /* Restore */
1972                 Term_activate(old);
1973         }
1974 }
1975
1976
1977 /*
1978  * Hack -- display object recall in sub-windows
1979  */
1980 static void fix_object(void)
1981 {
1982         int j;
1983
1984         /* Scan windows */
1985         for (j = 0; j < 8; j++)
1986         {
1987                 term *old = Term;
1988
1989                 /* No window */
1990                 if (!angband_term[j]) continue;
1991
1992                 /* No relevant flags */
1993                 if (!(window_flag[j] & (PW_OBJECT))) continue;
1994
1995                 /* Activate */
1996                 Term_activate(angband_term[j]);
1997
1998                 /* Display monster race info */
1999                 if (p_ptr->object_kind_idx) display_koff(p_ptr->object_kind_idx);
2000
2001                 /* Fresh */
2002                 Term_fresh();
2003
2004                 /* Restore */
2005                 Term_activate(old);
2006         }
2007 }
2008
2009
2010 /*
2011  * Calculate number of spells player should have, and forget,
2012  * or remember, spells until that number is properly reflected.
2013  *
2014  * Note that this function induces various "status" messages,
2015  * which must be bypasses until the character is created.
2016  */
2017 static void calc_spells(void)
2018 {
2019         int                     i, j, k, levels;
2020         int                     num_allowed;
2021         int                     num_boukyaku = 0;
2022
2023         magic_type              *s_ptr;
2024         int which;
2025         int bonus = 0;
2026
2027
2028         cptr p;
2029
2030         /* Hack -- must be literate */
2031         if (!mp_ptr->spell_book) return;
2032
2033         /* Hack -- wait for creation */
2034         if (!character_generated) return;
2035
2036         /* Hack -- handle "xtra" mode */
2037         if (character_xtra) return;
2038
2039         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
2040         {
2041                 p_ptr->new_spells = 0;
2042                 return;
2043         }
2044
2045         p = spell_category_name(mp_ptr->spell_book);
2046
2047         /* Determine the number of spells allowed */
2048         levels = p_ptr->lev - mp_ptr->spell_first + 1;
2049
2050         /* Hack -- no negative spells */
2051         if (levels < 0) levels = 0;
2052
2053         /* Extract total allowed spells */
2054         num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
2055
2056         if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
2057         {
2058                 bonus = 4;
2059         }
2060         if (p_ptr->pclass == CLASS_SAMURAI)
2061         {
2062                 num_allowed = 32;
2063         }
2064         else if (p_ptr->realm2 == REALM_NONE)
2065         {
2066                 num_allowed = (num_allowed+1)/2;
2067                 if (num_allowed>(32+bonus)) num_allowed = 32+bonus;
2068         }
2069         else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
2070         {
2071                 if (num_allowed>(96+bonus)) num_allowed = 96+bonus;
2072         }
2073         else
2074         {
2075                 if (num_allowed>(80+bonus)) num_allowed = 80+bonus;
2076         }
2077
2078         /* Count the number of spells we know */
2079         for (j = 0; j < 64; j++)
2080         {
2081                 /* Count known spells */
2082                 if ((j < 32) ?
2083                     (p_ptr->spell_forgotten1 & (1L << j)) :
2084                     (p_ptr->spell_forgotten2 & (1L << (j - 32))))
2085                 {
2086                         num_boukyaku++;
2087                 }
2088         }
2089
2090         /* See how many spells we must forget or may learn */
2091         p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
2092
2093         /* Forget spells which are too hard */
2094         for (i = 63; i >= 0; i--)
2095         {
2096                 /* Efficiency -- all done */
2097                 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
2098
2099                 /* Access the spell */
2100                 j = p_ptr->spell_order[i];
2101
2102                 /* Skip non-spells */
2103                 if (j >= 99) continue;
2104
2105
2106                 /* Get the spell */
2107                 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
2108                 {
2109                         if (j < 32)
2110                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
2111                         else
2112                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
2113                 }
2114                 else if (j < 32)
2115                         s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
2116                 else
2117                         s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
2118
2119                 /* Skip spells we are allowed to know */
2120                 if (s_ptr->slevel <= p_ptr->lev) continue;
2121
2122                 /* Is it known? */
2123                 if ((j < 32) ?
2124                     (p_ptr->spell_learned1 & (1L << j)) :
2125                     (p_ptr->spell_learned2 & (1L << (j - 32))))
2126                 {
2127                         /* Mark as forgotten */
2128                         if (j < 32)
2129                         {
2130                                 p_ptr->spell_forgotten1 |= (1L << j);
2131                                 which = p_ptr->realm1;
2132                         }
2133                         else
2134                         {
2135                                 p_ptr->spell_forgotten2 |= (1L << (j - 32));
2136                                 which = p_ptr->realm2;
2137                         }
2138
2139                         /* No longer known */
2140                         if (j < 32)
2141                         {
2142                                 p_ptr->spell_learned1 &= ~(1L << j);
2143                                 which = p_ptr->realm1;
2144                         }
2145                         else
2146                         {
2147                                 p_ptr->spell_learned2 &= ~(1L << (j - 32));
2148                                 which = p_ptr->realm2;
2149                         }
2150
2151                         /* Message */
2152 #ifdef JP
2153                         msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
2154                                    do_spell(which, j%32, SPELL_NAME), p );
2155 #else
2156                         msg_format("You have forgotten the %s of %s.", p,
2157                         do_spell(which, j%32, SPELL_NAME));
2158 #endif
2159
2160
2161                         /* One more can be learned */
2162                         p_ptr->new_spells++;
2163                 }
2164         }
2165
2166
2167         /* Forget spells if we know too many spells */
2168         for (i = 63; i >= 0; i--)
2169         {
2170                 /* Stop when possible */
2171                 if (p_ptr->new_spells >= 0) break;
2172
2173                 /* Efficiency -- all done */
2174                 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
2175
2176                 /* Get the (i+1)th spell learned */
2177                 j = p_ptr->spell_order[i];
2178
2179                 /* Skip unknown spells */
2180                 if (j >= 99) continue;
2181
2182                 /* Forget it (if learned) */
2183                 if ((j < 32) ?
2184                     (p_ptr->spell_learned1 & (1L << j)) :
2185                     (p_ptr->spell_learned2 & (1L << (j - 32))))
2186                 {
2187                         /* Mark as forgotten */
2188                         if (j < 32)
2189                         {
2190                                 p_ptr->spell_forgotten1 |= (1L << j);
2191                                 which = p_ptr->realm1;
2192                         }
2193                         else
2194                         {
2195                                 p_ptr->spell_forgotten2 |= (1L << (j - 32));
2196                                 which = p_ptr->realm2;
2197                         }
2198
2199                         /* No longer known */
2200                         if (j < 32)
2201                         {
2202                                 p_ptr->spell_learned1 &= ~(1L << j);
2203                                 which = p_ptr->realm1;
2204                         }
2205                         else
2206                         {
2207                                 p_ptr->spell_learned2 &= ~(1L << (j - 32));
2208                                 which = p_ptr->realm2;
2209                         }
2210
2211                         /* Message */
2212 #ifdef JP
2213                         msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
2214                                    do_spell(which, j%32, SPELL_NAME), p );
2215 #else
2216                         msg_format("You have forgotten the %s of %s.", p,
2217                                    do_spell(which, j%32, SPELL_NAME));
2218 #endif
2219
2220
2221                         /* One more can be learned */
2222                         p_ptr->new_spells++;
2223                 }
2224         }
2225
2226
2227         /* Check for spells to remember */
2228         for (i = 0; i < 64; i++)
2229         {
2230                 /* None left to remember */
2231                 if (p_ptr->new_spells <= 0) break;
2232
2233                 /* Efficiency -- all done */
2234                 if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
2235
2236                 /* Get the next spell we learned */
2237                 j = p_ptr->spell_order[i];
2238
2239                 /* Skip unknown spells */
2240                 if (j >= 99) break;
2241
2242                 /* Access the spell */
2243                 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
2244                 {
2245                         if (j < 32)
2246                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
2247                         else
2248                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
2249                 }
2250                 else if (j<32)
2251                         s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
2252                 else
2253                         s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
2254
2255                 /* Skip spells we cannot remember */
2256                 if (s_ptr->slevel > p_ptr->lev) continue;
2257
2258                 /* First set of spells */
2259                 if ((j < 32) ?
2260                     (p_ptr->spell_forgotten1 & (1L << j)) :
2261                     (p_ptr->spell_forgotten2 & (1L << (j - 32))))
2262                 {
2263                         /* No longer forgotten */
2264                         if (j < 32)
2265                         {
2266                                 p_ptr->spell_forgotten1 &= ~(1L << j);
2267                                 which = p_ptr->realm1;
2268                         }
2269                         else
2270                         {
2271                                 p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
2272                                 which = p_ptr->realm2;
2273                         }
2274
2275                         /* Known once more */
2276                         if (j < 32)
2277                         {
2278                                 p_ptr->spell_learned1 |= (1L << j);
2279                                 which = p_ptr->realm1;
2280                         }
2281                         else
2282                         {
2283                                 p_ptr->spell_learned2 |= (1L << (j - 32));
2284                                 which = p_ptr->realm2;
2285                         }
2286
2287                         /* Message */
2288 #ifdef JP
2289                         msg_format("%s¤Î%s¤ò»×¤¤½Ð¤·¤¿¡£",
2290                                    do_spell(which, j%32, SPELL_NAME), p );
2291 #else
2292                         msg_format("You have remembered the %s of %s.",
2293                                    p, do_spell(which, j%32, SPELL_NAME));
2294 #endif
2295
2296
2297                         /* One less can be learned */
2298                         p_ptr->new_spells--;
2299                 }
2300         }
2301
2302         k = 0;
2303
2304         if (p_ptr->realm2 == REALM_NONE)
2305         {
2306                 /* Count spells that can be learned */
2307                 for (j = 0; j < 32; j++)
2308                 {
2309                         if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1-MIN_TECHNIC][j];
2310                         else s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
2311
2312                         /* Skip spells we cannot remember */
2313                         if (s_ptr->slevel > p_ptr->lev) continue;
2314
2315                         /* Skip spells we already know */
2316                         if (p_ptr->spell_learned1 & (1L << j))
2317                         {
2318                                 continue;
2319                         }
2320
2321                         /* Count it */
2322                         k++;
2323                 }
2324                 if (k>32) k = 32;
2325                 if ((p_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) p_ptr->new_spells = k;
2326         }
2327
2328         if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
2329
2330         /* Spell count changed */
2331         if (p_ptr->old_spells != p_ptr->new_spells)
2332         {
2333                 /* Message if needed */
2334                 if (p_ptr->new_spells)
2335                 {
2336                         /* Message */
2337 #ifdef JP
2338                         if( p_ptr->new_spells < 10 ){
2339                                 msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
2340                         }else{
2341                                 msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
2342                         }
2343 #else
2344                         msg_format("You can learn %d more %s%s.",
2345                                    p_ptr->new_spells, p,
2346                                    (p_ptr->new_spells != 1) ? "s" : "");
2347 #endif
2348
2349                 }
2350
2351                 /* Save the new_spells value */
2352                 p_ptr->old_spells = p_ptr->new_spells;
2353
2354                 /* Redraw Study Status */
2355                 p_ptr->redraw |= (PR_STUDY);
2356
2357                 /* Redraw object recall */
2358                 p_ptr->window |= (PW_OBJECT);
2359         }
2360 }
2361
2362
2363 /*
2364  * Calculate maximum mana.  You do not need to know any spells.
2365  * Note that mana is lowered by heavy (or inappropriate) armor.
2366  *
2367  * This function induces status messages.
2368  */
2369 static void calc_mana(void)
2370 {
2371         int             msp, levels, cur_wgt, max_wgt;
2372
2373         object_type     *o_ptr;
2374
2375
2376         /* Hack -- Must be literate */
2377         if (!mp_ptr->spell_book) return;
2378
2379         if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2380             (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2381             (p_ptr->pclass == CLASS_BLUE_MAGE))
2382         {
2383                 levels = p_ptr->lev;
2384         }
2385         else
2386         {
2387                 if(mp_ptr->spell_first > p_ptr->lev)
2388                 {
2389                         /* Save new mana */
2390                         p_ptr->msp = 0;
2391
2392                         /* Display mana later */
2393                         p_ptr->redraw |= (PR_MANA);
2394                         return;
2395                 }
2396
2397                 /* Extract "effective" player level */
2398                 levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
2399         }
2400
2401         if (p_ptr->pclass == CLASS_SAMURAI)
2402         {
2403                 msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
2404                 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
2405         }
2406         else
2407         {
2408                 /* Extract total mana */
2409                 msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels+3) / 4;
2410
2411                 /* Hack -- usually add one mana */
2412                 if (msp) msp++;
2413
2414                 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
2415
2416                 if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp/2;
2417
2418                 /* Hack: High mages have a 25% mana bonus */
2419                 if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
2420
2421                 if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp*(25+p_ptr->lev)/100;
2422         }
2423
2424         /* Only mages are affected */
2425         if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
2426         {
2427                 u32b flgs[TR_FLAG_SIZE];
2428
2429                 /* Assume player is not encumbered by gloves */
2430                 p_ptr->cumber_glove = FALSE;
2431
2432                 /* Get the gloves */
2433                 o_ptr = &inventory[INVEN_HANDS];
2434
2435                 /* Examine the gloves */
2436                 object_flags(o_ptr, flgs);
2437
2438                 /* Normal gloves hurt mage-type spells */
2439                 if (o_ptr->k_idx &&
2440                     !(have_flag(flgs, TR_FREE_ACT)) &&
2441                     !(have_flag(flgs, TR_MAGIC_MASTERY)) &&
2442                     !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
2443                 {
2444                         /* Encumbered */
2445                         p_ptr->cumber_glove = TRUE;
2446
2447                         /* Reduce mana */
2448                         msp = (3 * msp) / 4;
2449                 }
2450         }
2451
2452
2453         /* Assume player not encumbered by armor */
2454         p_ptr->cumber_armor = FALSE;
2455
2456         /* Weigh the armor */
2457         cur_wgt = 0;
2458         if(inventory[INVEN_RARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
2459         if(inventory[INVEN_LARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
2460         cur_wgt += inventory[INVEN_BODY].weight;
2461         cur_wgt += inventory[INVEN_HEAD].weight;
2462         cur_wgt += inventory[INVEN_OUTER].weight;
2463         cur_wgt += inventory[INVEN_HANDS].weight;
2464         cur_wgt += inventory[INVEN_FEET].weight;
2465
2466         /* Subtract a percentage of maximum mana. */
2467         switch (p_ptr->pclass)
2468         {
2469                 /* For these classes, mana is halved if armour 
2470                  * is 30 pounds over their weight limit. */
2471                 case CLASS_MAGE:
2472                 case CLASS_HIGH_MAGE:
2473                 case CLASS_BLUE_MAGE:
2474                 case CLASS_MONK:
2475                 case CLASS_FORCETRAINER:
2476                 case CLASS_SORCERER:
2477                 {
2478                         if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
2479                         if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
2480                         break;
2481                 }
2482
2483                 /* Mana halved if armour is 40 pounds over weight limit. */
2484                 case CLASS_PRIEST:
2485                 case CLASS_BARD:
2486                 case CLASS_TOURIST:
2487                 {
2488                         if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight*2/3;
2489                         if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight*2/3;
2490                         break;
2491                 }
2492
2493                 case CLASS_MINDCRAFTER:
2494                 case CLASS_BEASTMASTER:
2495                 case CLASS_MIRROR_MASTER:
2496                 {
2497                         if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/2;
2498                         if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/2;
2499                         break;
2500                 }
2501
2502                 /* Mana halved if armour is 50 pounds over weight limit. */
2503                 case CLASS_ROGUE:
2504                 case CLASS_RANGER:
2505                 case CLASS_RED_MAGE:
2506                 case CLASS_WARRIOR_MAGE:
2507                 {
2508                         if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/3;
2509                         if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/3;
2510                         break;
2511                 }
2512
2513                 /* Mana halved if armour is 60 pounds over weight limit. */
2514                 case CLASS_PALADIN:
2515                 case CLASS_CHAOS_WARRIOR:
2516                 {
2517                         if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/5;
2518                         if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/5;
2519                         break;
2520                 }
2521
2522                 /* For new classes created, but not yet added to this formula. */
2523                 default:
2524                 {
2525                         break;
2526                 }
2527         }
2528
2529         /* Determine the weight allowance */
2530         max_wgt = mp_ptr->spell_weight;
2531
2532         /* Heavy armor penalizes mana by a percentage.  -LM- */
2533         if ((cur_wgt - max_wgt) > 0)
2534         {
2535                 /* Encumbered */
2536                 p_ptr->cumber_armor = TRUE;
2537
2538                 /* Subtract a percentage of maximum mana. */
2539                 switch (p_ptr->pclass)
2540                 {
2541                         /* For these classes, mana is halved if armour 
2542                          * is 30 pounds over their weight limit. */
2543                         case CLASS_MAGE:
2544                         case CLASS_HIGH_MAGE:
2545                         case CLASS_BLUE_MAGE:
2546                         {
2547                                 msp -= msp * (cur_wgt - max_wgt) / 600;
2548                                 break;
2549                         }
2550
2551                         /* Mana halved if armour is 40 pounds over weight limit. */
2552                         case CLASS_PRIEST:
2553                         case CLASS_MINDCRAFTER:
2554                         case CLASS_BEASTMASTER:
2555                         case CLASS_BARD:
2556                         case CLASS_FORCETRAINER:
2557                         case CLASS_TOURIST:
2558                         case CLASS_MIRROR_MASTER:
2559                         {
2560                                 msp -= msp * (cur_wgt - max_wgt) / 800;
2561                                 break;
2562                         }
2563
2564                         case CLASS_SORCERER:
2565                         {
2566                                 msp -= msp * (cur_wgt - max_wgt) / 900;
2567                                 break;
2568                         }
2569
2570                         /* Mana halved if armour is 50 pounds over weight limit. */
2571                         case CLASS_ROGUE:
2572                         case CLASS_RANGER:
2573                         case CLASS_MONK:
2574                         case CLASS_RED_MAGE:
2575                         {
2576                                 msp -= msp * (cur_wgt - max_wgt) / 1000;
2577                                 break;
2578                         }
2579
2580                         /* Mana halved if armour is 60 pounds over weight limit. */
2581                         case CLASS_PALADIN:
2582                         case CLASS_CHAOS_WARRIOR:
2583                         case CLASS_WARRIOR_MAGE:
2584                         {
2585                                 msp -= msp * (cur_wgt - max_wgt) / 1200;
2586                                 break;
2587                         }
2588
2589                         case CLASS_SAMURAI:
2590                         {
2591                                 p_ptr->cumber_armor = FALSE;
2592                                 break;
2593                         }
2594
2595                         /* For new classes created, but not yet added to this formula. */
2596                         default:
2597                         {
2598                                 msp -= msp * (cur_wgt - max_wgt) / 800;
2599                                 break;
2600                         }
2601                 }
2602         }
2603
2604         /* Mana can never be negative */
2605         if (msp < 0) msp = 0;
2606
2607
2608         /* Maximum mana has changed */
2609         if (p_ptr->msp != msp)
2610         {
2611                 /* Enforce maximum */
2612                 if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
2613                 {
2614                         p_ptr->csp = msp;
2615                         p_ptr->csp_frac = 0;
2616                 }
2617
2618 #ifdef JP
2619                 /* ¥ì¥Ù¥ë¥¢¥Ã¥×¤Î»þ¤Ï¾å¾ºÎ̤òɽ¼¨¤¹¤ë */
2620                 if ((level_up == 1) && (msp > p_ptr->msp))
2621                 {
2622                         msg_format("ºÇÂç¥Þ¥¸¥Ã¥¯¡¦¥Ý¥¤¥ó¥È¤¬ %d Áý²Ã¤·¤¿¡ª",
2623                                    (msp - p_ptr->msp));
2624                 }
2625 #endif
2626                 /* Save new mana */
2627                 p_ptr->msp = msp;
2628
2629                 /* Display mana later */
2630                 p_ptr->redraw |= (PR_MANA);
2631
2632                 /* Window stuff */
2633                 p_ptr->window |= (PW_PLAYER);
2634                 p_ptr->window |= (PW_SPELL);
2635         }
2636
2637
2638         /* Hack -- handle "xtra" mode */
2639         if (character_xtra) return;
2640
2641         /* Take note when "glove state" changes */
2642         if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
2643         {
2644                 /* Message */
2645                 if (p_ptr->cumber_glove)
2646                 {
2647 #ifdef JP
2648                         msg_print("¼ê¤¬Ê¤¤ï¤ì¤Æ¼öʸ¤¬¾§¤¨¤Ë¤¯¤¤´¶¤¸¤¬¤¹¤ë¡£");
2649 #else
2650                         msg_print("Your covered hands feel unsuitable for spellcasting.");
2651 #endif
2652
2653                 }
2654                 else
2655                 {
2656 #ifdef JP
2657                         msg_print("¤³¤Î¼ê¤Î¾õÂ֤ʤ顢¤°¤Ã¤È¼öʸ¤¬¾§¤¨¤ä¤¹¤¤´¶¤¸¤À¡£");
2658 #else
2659                         msg_print("Your hands feel more suitable for spellcasting.");
2660 #endif
2661
2662                 }
2663
2664                 /* Save it */
2665                 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
2666         }
2667
2668
2669         /* Take note when "armor state" changes */
2670         if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
2671         {
2672                 /* Message */
2673                 if (p_ptr->cumber_armor)
2674                 {
2675 #ifdef JP
2676                         msg_print("ÁõÈ÷¤Î½Å¤µ¤ÇÆ°¤­¤¬Æߤ¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
2677 #else
2678                         msg_print("The weight of your equipment encumbers your movement.");
2679 #endif
2680
2681                 }
2682                 else
2683                 {
2684 #ifdef JP
2685                         msg_print("¤°¤Ã¤È³Ú¤ËÂΤòÆ°¤«¤»¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
2686 #else
2687                         msg_print("You feel able to move more freely.");
2688 #endif
2689
2690                 }
2691
2692                 /* Save it */
2693                 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
2694         }
2695 }
2696
2697
2698
2699 /*
2700  * Calculate the players (maximal) hit points
2701  * Adjust current hitpoints if necessary
2702  */
2703 static void calc_hitpoints(void)
2704 {
2705         int bonus, mhp;
2706         byte tmp_hitdie;
2707
2708         /* Un-inflate "half-hitpoint bonus per level" value */
2709         bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
2710
2711         /* Calculate hitpoints */
2712         mhp = p_ptr->player_hp[p_ptr->lev - 1];
2713
2714         if (p_ptr->mimic_form)
2715         {
2716                 if (p_ptr->pclass == CLASS_SORCERER)
2717                         tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
2718                 else
2719                         tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2720                 mhp = mhp * tmp_hitdie / p_ptr->hitdie;
2721         }
2722
2723         if (p_ptr->pclass == CLASS_SORCERER)
2724         {
2725                 if (p_ptr->lev < 30)
2726                         mhp = (mhp * (45+p_ptr->lev) / 100);
2727                 else
2728                         mhp = (mhp * 75 / 100);
2729                 bonus = (bonus * 65 / 100);
2730         }
2731
2732         mhp += bonus;
2733
2734         if (p_ptr->pclass == CLASS_BERSERKER)
2735         {
2736                 mhp = mhp*(110+(((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110))/100;
2737         }
2738
2739         /* Always have at least one hitpoint per level */
2740         if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
2741
2742         /* Factor in the hero / superhero settings */
2743         if (IS_HERO()) mhp += 10;
2744         if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
2745         if (p_ptr->tsuyoshi) mhp += 50;
2746
2747         /* New maximum hitpoints */
2748         if (p_ptr->mhp != mhp)
2749         {
2750                 /* Enforce maximum */
2751                 if (p_ptr->chp >= mhp)
2752                 {
2753                         p_ptr->chp = mhp;
2754                         p_ptr->chp_frac = 0;
2755                 }
2756
2757 #ifdef JP
2758                 /* ¥ì¥Ù¥ë¥¢¥Ã¥×¤Î»þ¤Ï¾å¾ºÎ̤òɽ¼¨¤¹¤ë */
2759                 if ((level_up == 1) && (mhp > p_ptr->mhp))
2760                 {
2761                         msg_format("ºÇÂç¥Ò¥Ã¥È¡¦¥Ý¥¤¥ó¥È¤¬ %d Áý²Ã¤·¤¿¡ª",
2762                                    (mhp - p_ptr->mhp) );
2763                 }
2764 #endif
2765                 /* Save the new max-hitpoints */
2766                 p_ptr->mhp = mhp;
2767
2768                 /* Display hitpoints (later) */
2769                 p_ptr->redraw |= (PR_HP);
2770
2771                 /* Window stuff */
2772                 p_ptr->window |= (PW_PLAYER);
2773         }
2774 }
2775
2776
2777
2778 /*
2779  * Extract and set the current "lite radius"
2780  *
2781  * SWD: Experimental modification: multiple light sources have additive effect.
2782  *
2783  */
2784 static void calc_torch(void)
2785 {
2786         int i;
2787         object_type *o_ptr;
2788         u32b flgs[TR_FLAG_SIZE];
2789
2790         /* Assume no light */
2791         p_ptr->cur_lite = 0;
2792
2793         /* Loop through all wielded items */
2794         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2795         {
2796                 o_ptr = &inventory[i];
2797
2798                 /* Examine actual lites */
2799                 if ((i == INVEN_LITE) && (o_ptr->k_idx) && (o_ptr->tval == TV_LITE))
2800                 {
2801                         if (o_ptr->name2 == EGO_LITE_DARKNESS)
2802                         {
2803                                 if (o_ptr->sval == SV_LITE_TORCH)
2804                                 {
2805                                         p_ptr->cur_lite -= 1;
2806                                 }
2807
2808                                 /* Lanterns (with fuel) provide more lite */
2809                                 else if (o_ptr->sval == SV_LITE_LANTERN)
2810                                 {
2811                                         p_ptr->cur_lite -= 2;
2812                                 }
2813
2814                                 else if (o_ptr->sval == SV_LITE_FEANOR)
2815                                 {
2816                                         p_ptr->cur_lite -= 3;
2817                                 }
2818                         }
2819                         /* Torches (with fuel) provide some lite */
2820                         else if ((o_ptr->sval == SV_LITE_TORCH) && (o_ptr->xtra4 > 0))
2821                         {
2822                                 p_ptr->cur_lite += 1;
2823                         }
2824
2825                         /* Lanterns (with fuel) provide more lite */
2826                         else if ((o_ptr->sval == SV_LITE_LANTERN) && (o_ptr->xtra4 > 0))
2827                         {
2828                                 p_ptr->cur_lite += 2;
2829                         }
2830
2831                         else if (o_ptr->sval == SV_LITE_FEANOR)
2832                         {
2833                                 p_ptr->cur_lite += 2;
2834                         }
2835
2836                         /* Artifact Lites provide permanent, bright, lite */
2837                         else if (object_is_fixed_artifact(o_ptr))
2838                         {
2839                                 p_ptr->cur_lite += 3;
2840                         }
2841
2842                         if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
2843                 }
2844                 else
2845                 {
2846                         /* Skip empty slots */
2847                         if (!o_ptr->k_idx) continue;
2848
2849                         /* Extract the flags */
2850                         object_flags(o_ptr, flgs);
2851
2852                         /* does this item glow? */
2853                         if (have_flag(flgs, TR_LITE))
2854                         {
2855                                 if ((o_ptr->name2 == EGO_DARK) || (o_ptr->name1 == ART_NIGHT)) p_ptr->cur_lite--;
2856                                 else p_ptr->cur_lite++;
2857                         }
2858                 }
2859
2860         }
2861
2862         /* max radius is 14 (was 5) without rewriting other code -- */
2863         /* see cave.c:update_lite() and defines.h:LITE_MAX */
2864         if (d_info[dungeon_type].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
2865                 p_ptr->cur_lite = 1;
2866
2867         /*
2868          * check if the player doesn't have light radius, 
2869          * but does weakly glow as an intrinsic.
2870          */
2871         if (p_ptr->cur_lite <= 0 && p_ptr->lite) p_ptr->cur_lite++;
2872
2873         if (p_ptr->cur_lite > 14) p_ptr->cur_lite = 14;
2874         if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
2875
2876         /* end experimental mods */
2877
2878         /* Notice changes in the "lite radius" */
2879         if (p_ptr->old_lite != p_ptr->cur_lite)
2880         {
2881                 /* Update stuff */
2882                 /* Hack -- PU_MON_LITE for monsters' darkness */
2883                 p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
2884
2885                 /* Remember the old lite */
2886                 p_ptr->old_lite = p_ptr->cur_lite;
2887
2888                 if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
2889                         set_superstealth(FALSE);
2890         }
2891 }
2892
2893
2894
2895 /*
2896  * Computes current weight limit.
2897  */
2898 u32b weight_limit(void)
2899 {
2900         u32b i;
2901
2902         /* Weight limit based only on strength */
2903         i = (u32b)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
2904         if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
2905
2906         /* Return the result */
2907         return i;
2908 }
2909
2910
2911 bool buki_motteruka(int i)
2912 {
2913         return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
2914 }
2915
2916
2917 /*
2918  * Calculate the players current "state", taking into account
2919  * not only race/class intrinsics, but also objects being worn
2920  * and temporary spell effects.
2921  *
2922  * See also calc_mana() and calc_hitpoints().
2923  *
2924  * Take note of the new "speed code", in particular, a very strong
2925  * player will start slowing down as soon as he reaches 150 pounds,
2926  * but not until he reaches 450 pounds will he be half as fast as
2927  * a normal kobold.  This both hurts and helps the player, hurts
2928  * because in the old days a player could just avoid 300 pounds,
2929  * and helps because now carrying 300 pounds is not very painful.
2930  *
2931  * The "weapon" and "bow" do *not* add to the bonuses to hit or to
2932  * damage, since that would affect non-combat things.  These values
2933  * are actually added in later, at the appropriate place.
2934  *
2935  * This function induces various "status" messages.
2936  */
2937 void calc_bonuses(void)
2938 {
2939         int             i, j, hold, neutral[2];
2940         int             new_speed;
2941         int             default_hand = 0;
2942         int             empty_hands_status = empty_hands(TRUE);
2943         int             extra_blows[2];
2944         int             extra_shots;
2945         object_type     *o_ptr;
2946         u32b flgs[TR_FLAG_SIZE];
2947         bool            omoi = FALSE;
2948         bool            yoiyami = FALSE;
2949         bool            down_saving = FALSE;
2950 #if 0
2951         bool            have_dd_s = FALSE, have_dd_t = FALSE;
2952 #endif
2953         bool            have_sw = FALSE, have_kabe = FALSE;
2954         bool            easy_2weapon = FALSE;
2955         bool            riding_levitation = FALSE;
2956         s16b this_o_idx, next_o_idx = 0;
2957         player_race *tmp_rp_ptr;
2958
2959         /* Save the old vision stuff */
2960         bool old_telepathy = p_ptr->telepathy;
2961         bool old_esp_animal = p_ptr->esp_animal;
2962         bool old_esp_undead = p_ptr->esp_undead;
2963         bool old_esp_demon = p_ptr->esp_demon;
2964         bool old_esp_orc = p_ptr->esp_orc;
2965         bool old_esp_troll = p_ptr->esp_troll;
2966         bool old_esp_giant = p_ptr->esp_giant;
2967         bool old_esp_dragon = p_ptr->esp_dragon;
2968         bool old_esp_human = p_ptr->esp_human;
2969         bool old_esp_evil = p_ptr->esp_evil;
2970         bool old_esp_good = p_ptr->esp_good;
2971         bool old_esp_nonliving = p_ptr->esp_nonliving;
2972         bool old_esp_unique = p_ptr->esp_unique;
2973         bool old_see_inv = p_ptr->see_inv;
2974         bool old_mighty_throw = p_ptr->mighty_throw;
2975
2976         /* Save the old armor class */
2977         bool old_dis_ac = p_ptr->dis_ac;
2978         bool old_dis_to_a = p_ptr->dis_to_a;
2979
2980
2981         /* Clear extra blows/shots */
2982         extra_blows[0] = extra_blows[1] = extra_shots = 0;
2983
2984         /* Clear the stat modifiers */
2985         for (i = 0; i < 6; i++) p_ptr->stat_add[i] = 0;
2986
2987
2988         /* Clear the Displayed/Real armor class */
2989         p_ptr->dis_ac = p_ptr->ac = 0;
2990
2991         /* Clear the Displayed/Real Bonuses */
2992         p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
2993         p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
2994         p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
2995         p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
2996         p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
2997         p_ptr->dis_to_a = p_ptr->to_a = 0;
2998         p_ptr->to_h_m = 0;
2999         p_ptr->to_d_m = 0;
3000
3001         p_ptr->to_m_chance = 0;
3002
3003         /* Clear the Extra Dice Bonuses */
3004         p_ptr->to_dd[0] = p_ptr->to_ds[0] = 0;
3005         p_ptr->to_dd[1] = p_ptr->to_ds[1] = 0;
3006
3007         /* Start with "normal" speed */
3008         new_speed = 110;
3009
3010         /* Start with a single blow per turn */
3011         p_ptr->num_blow[0] = 1;
3012         p_ptr->num_blow[1] = 1;
3013
3014         /* Start with a single shot per turn */
3015         p_ptr->num_fire = 100;
3016
3017         /* Reset the "xtra" tval */
3018         p_ptr->tval_xtra = 0;
3019
3020         /* Reset the "ammo" tval */
3021         p_ptr->tval_ammo = 0;
3022
3023         /* Clear all the flags */
3024         p_ptr->cursed = 0L;
3025         p_ptr->bless_blade = FALSE;
3026         p_ptr->xtra_might = FALSE;
3027         p_ptr->impact[0] = FALSE;
3028         p_ptr->impact[1] = FALSE;
3029         p_ptr->pass_wall = FALSE;
3030         p_ptr->kill_wall = FALSE;
3031         p_ptr->dec_mana = FALSE;
3032         p_ptr->easy_spell = FALSE;
3033         p_ptr->heavy_spell = FALSE;
3034         p_ptr->see_inv = FALSE;
3035         p_ptr->free_act = FALSE;
3036         p_ptr->slow_digest = FALSE;
3037         p_ptr->regenerate = FALSE;
3038         p_ptr->can_swim = FALSE;
3039         p_ptr->levitation = FALSE;
3040         p_ptr->hold_life = FALSE;
3041         p_ptr->telepathy = FALSE;
3042         p_ptr->esp_animal = FALSE;
3043         p_ptr->esp_undead = FALSE;
3044         p_ptr->esp_demon = FALSE;
3045         p_ptr->esp_orc = FALSE;
3046         p_ptr->esp_troll = FALSE;
3047         p_ptr->esp_giant = FALSE;
3048         p_ptr->esp_dragon = FALSE;
3049         p_ptr->esp_human = FALSE;
3050         p_ptr->esp_evil = FALSE;
3051         p_ptr->esp_good = FALSE;
3052         p_ptr->esp_nonliving = FALSE;
3053         p_ptr->esp_unique = FALSE;
3054         p_ptr->lite = FALSE;
3055         p_ptr->sustain_str = FALSE;
3056         p_ptr->sustain_int = FALSE;
3057         p_ptr->sustain_wis = FALSE;
3058         p_ptr->sustain_con = FALSE;
3059         p_ptr->sustain_dex = FALSE;
3060         p_ptr->sustain_chr = FALSE;
3061         p_ptr->resist_acid = FALSE;
3062         p_ptr->resist_elec = FALSE;
3063         p_ptr->resist_fire = FALSE;
3064         p_ptr->resist_cold = FALSE;
3065         p_ptr->resist_pois = FALSE;
3066         p_ptr->resist_conf = FALSE;
3067         p_ptr->resist_sound = FALSE;
3068         p_ptr->resist_lite = FALSE;
3069         p_ptr->resist_dark = FALSE;
3070         p_ptr->resist_chaos = FALSE;
3071         p_ptr->resist_disen = FALSE;
3072         p_ptr->resist_shard = FALSE;
3073         p_ptr->resist_nexus = FALSE;
3074         p_ptr->resist_blind = FALSE;
3075         p_ptr->resist_neth = FALSE;
3076         p_ptr->resist_time = FALSE;
3077         p_ptr->resist_fear = FALSE;
3078         p_ptr->reflect = FALSE;
3079         p_ptr->sh_fire = FALSE;
3080         p_ptr->sh_elec = FALSE;
3081         p_ptr->sh_cold = FALSE;
3082         p_ptr->anti_magic = FALSE;
3083         p_ptr->anti_tele = FALSE;
3084         p_ptr->warning = FALSE;
3085         p_ptr->mighty_throw = FALSE;
3086         p_ptr->see_nocto = FALSE;
3087
3088         p_ptr->immune_acid = FALSE;
3089         p_ptr->immune_elec = FALSE;
3090         p_ptr->immune_fire = FALSE;
3091         p_ptr->immune_cold = FALSE;
3092
3093         p_ptr->ryoute = FALSE;
3094         p_ptr->migite = FALSE;
3095         p_ptr->hidarite = FALSE;
3096         p_ptr->no_flowed = FALSE;
3097
3098         p_ptr->align = friend_align;
3099
3100         if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
3101         else tmp_rp_ptr = &race_info[p_ptr->prace];
3102
3103         /* Base infravision (purely racial) */
3104         p_ptr->see_infra = tmp_rp_ptr->infra;
3105
3106         /* Base skill -- disarming */
3107         p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
3108
3109         /* Base skill -- magic devices */
3110         p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
3111
3112         /* Base skill -- saving throw */
3113         p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
3114
3115         /* Base skill -- stealth */
3116         p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
3117
3118         /* Base skill -- searching ability */
3119         p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
3120
3121         /* Base skill -- searching frequency */
3122         p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
3123
3124         /* Base skill -- combat (normal) */
3125         p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
3126
3127         /* Base skill -- combat (shooting) */
3128         p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
3129
3130         /* Base skill -- combat (throwing) */
3131         p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
3132
3133         /* Base skill -- digging */
3134         p_ptr->skill_dig = 0;
3135
3136         if (buki_motteruka(INVEN_RARM)) p_ptr->migite = TRUE;
3137         if (buki_motteruka(INVEN_LARM))
3138         {
3139                 p_ptr->hidarite = TRUE;
3140                 if (!p_ptr->migite) default_hand = 1;
3141         }
3142
3143         if (CAN_TWO_HANDS_WIELDING())
3144         {
3145                 if (p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
3146                         object_allow_two_hands_wielding(&inventory[INVEN_RARM]))
3147                 {
3148                         p_ptr->ryoute = TRUE;
3149                 }
3150                 else if (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
3151                         object_allow_two_hands_wielding(&inventory[INVEN_LARM]))
3152                 {
3153                         p_ptr->ryoute = TRUE;
3154                 }
3155                 else
3156                 {
3157                         switch (p_ptr->pclass)
3158                         {
3159                         case CLASS_MONK:
3160                         case CLASS_FORCETRAINER:
3161                         case CLASS_BERSERKER:
3162                                 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
3163                                 {
3164                                         p_ptr->migite = TRUE;
3165                                         p_ptr->ryoute = TRUE;
3166                                 }
3167                                 break;
3168                         }
3169                 }
3170         }
3171
3172         if (!p_ptr->migite && !p_ptr->hidarite)
3173         {
3174                 if (empty_hands_status & EMPTY_HAND_RARM) p_ptr->migite = TRUE;
3175                 else if (empty_hands_status == EMPTY_HAND_LARM)
3176                 {
3177                         p_ptr->hidarite = TRUE;
3178                         default_hand = 1;
3179                 }
3180         }
3181
3182         if (p_ptr->special_defense & KAMAE_MASK)
3183         {
3184                 if (!(empty_hands_status & EMPTY_HAND_RARM))
3185                 {
3186                         set_action(ACTION_NONE);
3187                 }
3188         }
3189
3190         switch (p_ptr->pclass)
3191         {
3192                 case CLASS_WARRIOR:
3193                         if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
3194                         if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
3195                         break;
3196                 case CLASS_PALADIN:
3197                         if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
3198                         break;
3199                 case CLASS_CHAOS_WARRIOR:
3200                         if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
3201                         if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
3202                         break;
3203                 case CLASS_MINDCRAFTER:
3204                         if (p_ptr->lev >  9) p_ptr->resist_fear = TRUE;
3205                         if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
3206                         if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
3207                         if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
3208                         break;
3209                 case CLASS_MONK:
3210                 case CLASS_FORCETRAINER:
3211                         /* Unencumbered Monks become faster every 10 levels */
3212                         if (!(heavy_armor()))
3213                         {
3214                                 if (!(prace_is_(RACE_KLACKON) ||
3215                                       prace_is_(RACE_SPRITE) ||
3216                                       (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
3217                                         new_speed += (p_ptr->lev) / 10;
3218
3219                                 /* Free action if unencumbered at level 25 */
3220                                 if  (p_ptr->lev > 24)
3221                                         p_ptr->free_act = TRUE;
3222                         }
3223                         break;
3224                 case CLASS_SORCERER:
3225                         p_ptr->to_a -= 50;
3226                         p_ptr->dis_to_a -= 50;
3227                         break;
3228                 case CLASS_BARD:
3229                         p_ptr->resist_sound = TRUE;
3230                         break;
3231                 case CLASS_SAMURAI:
3232                         if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
3233                         break;
3234                 case CLASS_BERSERKER:
3235                         p_ptr->shero = 1;
3236                         p_ptr->sustain_str = TRUE;
3237                         p_ptr->sustain_dex = TRUE;
3238                         p_ptr->sustain_con = TRUE;
3239                         p_ptr->regenerate = TRUE;
3240                         p_ptr->free_act = TRUE;
3241                         new_speed += 2;
3242                         if (p_ptr->lev > 29) new_speed++;
3243                         if (p_ptr->lev > 39) new_speed++;
3244                         if (p_ptr->lev > 44) new_speed++;
3245                         if (p_ptr->lev > 49) new_speed++;
3246                         p_ptr->to_a += 10+p_ptr->lev/2;
3247                         p_ptr->dis_to_a += 10+p_ptr->lev/2;
3248                         p_ptr->skill_dig += (100+p_ptr->lev*8);
3249                         if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
3250                         p_ptr->redraw |= PR_STATUS;
3251                         break;
3252                 case CLASS_MIRROR_MASTER:
3253                         if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
3254                         break;
3255                 case CLASS_NINJA:
3256                         /* Unencumbered Ninjas become faster every 10 levels */
3257                         if (heavy_armor())
3258                         {
3259                                 new_speed -= (p_ptr->lev) / 10;
3260                                 p_ptr->skill_stl -= (p_ptr->lev)/10;
3261                         }
3262                         else if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
3263                                  (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
3264                         {
3265                                 new_speed += 3;
3266                                 if (!(prace_is_(RACE_KLACKON) ||
3267                                       prace_is_(RACE_SPRITE) ||
3268                                       (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
3269                                         new_speed += (p_ptr->lev) / 10;
3270                                 p_ptr->skill_stl += (p_ptr->lev)/10;
3271
3272                                 /* Free action if unencumbered at level 25 */
3273                                 if  (p_ptr->lev > 24)
3274                                         p_ptr->free_act = TRUE;
3275                         }
3276                         if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
3277                             (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
3278                         {
3279                                 p_ptr->to_a += p_ptr->lev/2+5;
3280                                 p_ptr->dis_to_a += p_ptr->lev/2+5;
3281                         }
3282                         p_ptr->slow_digest = TRUE;
3283                         p_ptr->resist_fear = TRUE;
3284                         if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
3285                         if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
3286                         if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
3287                         if (p_ptr->lev > 44)
3288                         {
3289                                 p_ptr->oppose_pois = 1;
3290                                 p_ptr->redraw |= PR_STATUS;
3291                         }
3292                         p_ptr->see_nocto = TRUE;
3293                         break;
3294         }
3295
3296         /***** Races ****/
3297         if (p_ptr->mimic_form)
3298         {
3299                 switch (p_ptr->mimic_form)
3300                 {
3301                 case MIMIC_DEMON:
3302                         p_ptr->hold_life = TRUE;
3303                         p_ptr->resist_chaos = TRUE;
3304                         p_ptr->resist_neth = TRUE;
3305                         p_ptr->resist_fire = TRUE;
3306                         p_ptr->oppose_fire = 1;
3307                         p_ptr->see_inv=TRUE;
3308                         new_speed += 3;
3309                         p_ptr->redraw |= PR_STATUS;
3310                         p_ptr->to_a += 10;
3311                         p_ptr->dis_to_a += 10;
3312                         p_ptr->align -= 200;
3313                         break;
3314                 case MIMIC_DEMON_LORD:
3315                         p_ptr->hold_life = TRUE;
3316                         p_ptr->resist_chaos = TRUE;
3317                         p_ptr->resist_neth = TRUE;
3318                         p_ptr->immune_fire = TRUE;
3319                         p_ptr->resist_acid = TRUE;
3320                         p_ptr->resist_fire = TRUE;
3321                         p_ptr->resist_cold = TRUE;
3322                         p_ptr->resist_elec = TRUE;
3323                         p_ptr->resist_pois = TRUE;
3324                         p_ptr->resist_conf = TRUE;
3325                         p_ptr->resist_disen = TRUE;
3326                         p_ptr->resist_nexus = TRUE;
3327                         p_ptr->resist_fear = TRUE;
3328                         p_ptr->sh_fire = TRUE;
3329                         p_ptr->see_inv = TRUE;
3330                         p_ptr->telepathy = TRUE;
3331                         p_ptr->levitation = TRUE;
3332                         p_ptr->kill_wall = TRUE;
3333                         new_speed += 5;
3334                         p_ptr->to_a += 20;
3335                         p_ptr->dis_to_a += 20;
3336                         p_ptr->align -= 200;
3337                         break;
3338                 case MIMIC_VAMPIRE:
3339                         p_ptr->resist_dark = TRUE;
3340                         p_ptr->hold_life = TRUE;
3341                         p_ptr->resist_neth = TRUE;
3342                         p_ptr->resist_cold = TRUE;
3343                         p_ptr->resist_pois = TRUE;
3344                         p_ptr->see_inv = TRUE;
3345                         new_speed += 3;
3346                         p_ptr->to_a += 10;
3347                         p_ptr->dis_to_a += 10;
3348                         if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3349                         break;
3350                 }
3351         }
3352         else
3353         {
3354                 switch (p_ptr->prace)
3355                 {
3356                 case RACE_ELF:
3357                         p_ptr->resist_lite = TRUE;
3358                         break;
3359                 case RACE_HOBBIT:
3360                         p_ptr->hold_life = TRUE;
3361                         break;
3362                 case RACE_GNOME:
3363                         p_ptr->free_act = TRUE;
3364                         break;
3365                 case RACE_DWARF:
3366                         p_ptr->resist_blind = TRUE;
3367                         break;
3368                 case RACE_HALF_ORC:
3369                         p_ptr->resist_dark = TRUE;
3370                         break;
3371                 case RACE_HALF_TROLL:
3372                         p_ptr->sustain_str = TRUE;
3373
3374                         if (p_ptr->lev > 14)
3375                         {
3376                                 /* High level trolls heal fast... */
3377                                 p_ptr->regenerate = TRUE;
3378
3379                                 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
3380                                 {
3381                                         p_ptr->slow_digest = TRUE;
3382                                         /* Let's not make Regeneration
3383                                          * a disadvantage for the poor warriors who can
3384                                          * never learn a spell that satisfies hunger (actually
3385                                          * neither can rogues, but half-trolls are not
3386                                          * supposed to play rogues) */
3387                                 }
3388                         }
3389                         break;
3390                 case RACE_AMBERITE:
3391                         p_ptr->sustain_con = TRUE;
3392                         p_ptr->regenerate = TRUE;  /* Amberites heal fast... */
3393                         break;
3394                 case RACE_HIGH_ELF:
3395                         p_ptr->resist_lite = TRUE;
3396                         p_ptr->see_inv = TRUE;
3397                         break;
3398                 case RACE_BARBARIAN:
3399                         p_ptr->resist_fear = TRUE;
3400                         break;
3401                 case RACE_HALF_OGRE:
3402                         p_ptr->resist_dark = TRUE;
3403                         p_ptr->sustain_str = TRUE;
3404                         break;
3405                 case RACE_HALF_GIANT:
3406                         p_ptr->sustain_str = TRUE;
3407                         p_ptr->resist_shard = TRUE;
3408                         break;
3409                 case RACE_HALF_TITAN:
3410                         p_ptr->resist_chaos = TRUE;
3411                         break;
3412                 case RACE_CYCLOPS:
3413                         p_ptr->resist_sound = TRUE;
3414                         break;
3415                 case RACE_YEEK:
3416                         p_ptr->resist_acid = TRUE;
3417                         if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
3418                         break;
3419                 case RACE_KLACKON:
3420                         p_ptr->resist_conf = TRUE;
3421                         p_ptr->resist_acid = TRUE;
3422
3423                         /* Klackons become faster */
3424                         new_speed += (p_ptr->lev) / 10;
3425                         break;
3426                 case RACE_KOBOLD:
3427                         p_ptr->resist_pois = TRUE;
3428                         break;
3429                 case RACE_NIBELUNG:
3430                         p_ptr->resist_disen = TRUE;
3431                         p_ptr->resist_dark = TRUE;
3432                         break;
3433                 case RACE_DARK_ELF:
3434                         p_ptr->resist_dark = TRUE;
3435                         if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
3436                         break;
3437                 case RACE_DRACONIAN:
3438                         p_ptr->levitation = TRUE;
3439                         if (p_ptr->lev >  4) p_ptr->resist_fire = TRUE;
3440                         if (p_ptr->lev >  9) p_ptr->resist_cold = TRUE;
3441                         if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
3442                         if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
3443                         if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
3444                         break;
3445                 case RACE_MIND_FLAYER:
3446                         p_ptr->sustain_int = TRUE;
3447                         p_ptr->sustain_wis = TRUE;
3448                         if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
3449                         if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
3450                         break;
3451                 case RACE_IMP:
3452                         p_ptr->resist_fire = TRUE;
3453                         if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
3454                         break;
3455                 case RACE_GOLEM:
3456                         p_ptr->slow_digest = TRUE;
3457                         p_ptr->free_act = TRUE;
3458                         p_ptr->see_inv = TRUE;
3459                         p_ptr->resist_pois = TRUE;
3460                         if (p_ptr->lev > 34) p_ptr->hold_life = TRUE;
3461                         break;
3462                 case RACE_SKELETON:
3463                         p_ptr->resist_shard = TRUE;
3464                         p_ptr->hold_life = TRUE;
3465                         p_ptr->see_inv = TRUE;
3466                         p_ptr->resist_pois = TRUE;
3467                         if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
3468                         break;
3469                 case RACE_ZOMBIE:
3470                         p_ptr->resist_neth = TRUE;
3471                         p_ptr->hold_life = TRUE;
3472                         p_ptr->see_inv = TRUE;
3473                         p_ptr->resist_pois = TRUE;
3474                         p_ptr->slow_digest = TRUE;
3475                         if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
3476                         break;
3477                 case RACE_VAMPIRE:
3478                         p_ptr->resist_dark = TRUE;
3479                         p_ptr->hold_life = TRUE;
3480                         p_ptr->resist_neth = TRUE;
3481                         p_ptr->resist_cold = TRUE;
3482                         p_ptr->resist_pois = TRUE;
3483                         if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3484                         break;
3485                 case RACE_SPECTRE:
3486                         p_ptr->levitation = TRUE;
3487                         p_ptr->free_act = TRUE;
3488                         p_ptr->resist_neth = TRUE;
3489                         p_ptr->hold_life = TRUE;
3490                         p_ptr->see_inv = TRUE;
3491                         p_ptr->resist_pois = TRUE;
3492                         p_ptr->slow_digest = TRUE;
3493                         p_ptr->resist_cold = TRUE;
3494                         p_ptr->pass_wall = TRUE;
3495                         if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
3496                         break;
3497                 case RACE_SPRITE:
3498                         p_ptr->levitation = TRUE;
3499                         p_ptr->resist_lite = TRUE;
3500
3501                         /* Sprites become faster */
3502                         new_speed += (p_ptr->lev) / 10;
3503                         break;
3504                 case RACE_BEASTMAN:
3505                         p_ptr->resist_conf  = TRUE;
3506                         p_ptr->resist_sound = TRUE;
3507                         break;
3508                 case RACE_ENT:
3509                         /* Ents dig like maniacs, but only with their hands. */
3510                         if (!inventory[INVEN_RARM].k_idx) 
3511                                 p_ptr->skill_dig += p_ptr->lev * 10;
3512                         /* Ents get tougher and stronger as they age, but lose dexterity. */
3513                         if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
3514                         if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
3515                         if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
3516
3517                         if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
3518                         if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
3519                         if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
3520
3521                         if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
3522                         if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
3523                         if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
3524                         break;
3525                 case RACE_ANGEL:
3526                         p_ptr->levitation = TRUE;
3527                         p_ptr->see_inv = TRUE;
3528                         p_ptr->align += 200;
3529                         break;
3530                 case RACE_DEMON:
3531                         p_ptr->resist_fire  = TRUE;
3532                         p_ptr->resist_neth  = TRUE;
3533                         p_ptr->hold_life = TRUE;
3534                         if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
3535                         if (p_ptr->lev > 44)
3536                         {
3537                                 p_ptr->oppose_fire = 1;
3538                                 p_ptr->redraw |= PR_STATUS;
3539                         }
3540                         p_ptr->align -= 200;
3541                         break;
3542                 case RACE_DUNADAN:
3543                         p_ptr->sustain_con = TRUE;
3544                         break;
3545                 case RACE_S_FAIRY:
3546                         p_ptr->levitation = TRUE;
3547                         break;
3548                 case RACE_KUTA:
3549                         p_ptr->resist_conf = TRUE;
3550                         break;
3551                 case RACE_ANDROID:
3552                         p_ptr->slow_digest = TRUE;
3553                         p_ptr->free_act = TRUE;
3554                         p_ptr->resist_pois = TRUE;
3555                         p_ptr->hold_life = TRUE;
3556                         break;
3557                 default:
3558                         /* Do nothing */
3559                         ;
3560                 }
3561         }
3562
3563         if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
3564         {
3565                 p_ptr->see_inv = TRUE;
3566                 p_ptr->free_act = TRUE;
3567                 p_ptr->slow_digest = TRUE;
3568                 p_ptr->regenerate = TRUE;
3569                 p_ptr->levitation = TRUE;
3570                 p_ptr->hold_life = TRUE;
3571                 p_ptr->telepathy = TRUE;
3572                 p_ptr->lite = TRUE;
3573                 p_ptr->sustain_str = TRUE;
3574                 p_ptr->sustain_int = TRUE;
3575                 p_ptr->sustain_wis = TRUE;
3576                 p_ptr->sustain_con = TRUE;
3577                 p_ptr->sustain_dex = TRUE;
3578                 p_ptr->sustain_chr = TRUE;
3579                 p_ptr->resist_acid = TRUE;
3580                 p_ptr->resist_elec = TRUE;
3581                 p_ptr->resist_fire = TRUE;
3582                 p_ptr->resist_cold = TRUE;
3583                 p_ptr->resist_pois = TRUE;
3584                 p_ptr->resist_conf = TRUE;
3585                 p_ptr->resist_sound = TRUE;
3586                 p_ptr->resist_lite = TRUE;
3587                 p_ptr->resist_dark = TRUE;
3588                 p_ptr->resist_chaos = TRUE;
3589                 p_ptr->resist_disen = TRUE;
3590                 p_ptr->resist_shard = TRUE;
3591                 p_ptr->resist_nexus = TRUE;
3592                 p_ptr->resist_blind = TRUE;
3593                 p_ptr->resist_neth = TRUE;
3594                 p_ptr->resist_fear = TRUE;
3595                 p_ptr->reflect = TRUE;
3596                 p_ptr->sh_fire = TRUE;
3597                 p_ptr->sh_elec = TRUE;
3598                 p_ptr->sh_cold = TRUE;
3599                 p_ptr->to_a += 100;
3600                 p_ptr->dis_to_a += 100;
3601         }
3602         /* Temporary shield */
3603         else if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
3604         {
3605                 p_ptr->to_a += 50;
3606                 p_ptr->dis_to_a += 50;
3607         }
3608
3609         if (p_ptr->tim_res_nether)
3610         {
3611                 p_ptr->resist_neth = TRUE;
3612         }
3613         if (p_ptr->tim_sh_fire)
3614         {
3615                 p_ptr->sh_fire = TRUE;
3616         }
3617         if (p_ptr->tim_res_time)
3618         {
3619                 p_ptr->resist_time = TRUE;
3620         }
3621
3622         /* Sexy Gal */
3623         if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
3624         if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
3625         if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
3626         if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
3627
3628         /* Lucky man */
3629         if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
3630
3631         if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
3632         {
3633                 p_ptr->resist_blind = TRUE;
3634                 p_ptr->resist_conf  = TRUE;
3635                 p_ptr->hold_life = TRUE;
3636                 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3637
3638                 if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
3639                         /* Munchkin become faster */
3640                         new_speed += (p_ptr->lev) / 10 + 5;
3641         }
3642
3643         if (music_singing(MUSIC_WALL))
3644         {
3645                 p_ptr->kill_wall = TRUE;
3646         }
3647
3648         /* Hack -- apply racial/class stat maxes */
3649         /* Apply the racial modifiers */
3650         for (i = 0; i < 6; i++)
3651         {
3652                 /* Modify the stats for "race" */
3653                 p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
3654         }
3655
3656
3657         /* I'm adding the mutations here for the lack of a better place... */
3658         if (p_ptr->muta3)
3659         {
3660                 /* Hyper Strength */
3661                 if (p_ptr->muta3 & MUT3_HYPER_STR)
3662                 {
3663                         p_ptr->stat_add[A_STR] += 4;
3664                 }
3665
3666                 /* Puny */
3667                 if (p_ptr->muta3 & MUT3_PUNY)
3668                 {
3669                         p_ptr->stat_add[A_STR] -= 4;
3670                 }
3671
3672                 /* Living computer */
3673                 if (p_ptr->muta3 & MUT3_HYPER_INT)
3674                 {
3675                         p_ptr->stat_add[A_INT] += 4;
3676                         p_ptr->stat_add[A_WIS] += 4;
3677                 }
3678
3679                 /* Moronic */
3680                 if (p_ptr->muta3 & MUT3_MORONIC)
3681                 {
3682                         p_ptr->stat_add[A_INT] -= 4;
3683                         p_ptr->stat_add[A_WIS] -= 4;
3684                 }
3685
3686                 if (p_ptr->muta3 & MUT3_RESILIENT)
3687                 {
3688                         p_ptr->stat_add[A_CON] += 4;
3689                 }
3690
3691                 if (p_ptr->muta3 & MUT3_XTRA_FAT)
3692                 {
3693                         p_ptr->stat_add[A_CON] += 2;
3694                         new_speed -= 2;
3695                 }
3696
3697                 if (p_ptr->muta3 & MUT3_ALBINO)
3698                 {
3699                         p_ptr->stat_add[A_CON] -= 4;
3700                 }
3701
3702                 if (p_ptr->muta3 & MUT3_FLESH_ROT)
3703                 {
3704                         p_ptr->stat_add[A_CON] -= 2;
3705                         p_ptr->stat_add[A_CHR] -= 1;
3706                         p_ptr->regenerate = FALSE;
3707                         /* Cancel innate regeneration */
3708                 }
3709
3710                 if (p_ptr->muta3 & MUT3_SILLY_VOI)
3711                 {
3712                         p_ptr->stat_add[A_CHR] -= 4;
3713                 }
3714
3715                 if (p_ptr->muta3 & MUT3_BLANK_FAC)
3716                 {
3717                         p_ptr->stat_add[A_CHR] -= 1;
3718                 }
3719
3720                 if (p_ptr->muta3 & MUT3_XTRA_EYES)
3721                 {
3722                         p_ptr->skill_fos += 15;
3723                         p_ptr->skill_srh += 15;
3724                 }
3725
3726                 if (p_ptr->muta3 & MUT3_MAGIC_RES)
3727                 {
3728                         p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
3729                 }
3730
3731                 if (p_ptr->muta3 & MUT3_XTRA_NOIS)
3732                 {
3733                         p_ptr->skill_stl -= 3;
3734                 }
3735
3736                 if (p_ptr->muta3 & MUT3_INFRAVIS)
3737                 {
3738                         p_ptr->see_infra += 3;
3739                 }
3740
3741                 if (p_ptr->muta3 & MUT3_XTRA_LEGS)
3742                 {
3743                         new_speed += 3;
3744                 }
3745
3746                 if (p_ptr->muta3 & MUT3_SHORT_LEG)
3747                 {
3748                         new_speed -= 3;
3749                 }
3750
3751                 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
3752                 {
3753                         p_ptr->sh_elec = TRUE;
3754                 }
3755
3756                 if (p_ptr->muta3 & MUT3_FIRE_BODY)
3757                 {
3758                         p_ptr->sh_fire = TRUE;
3759                         p_ptr->lite = TRUE;
3760                 }
3761
3762                 if (p_ptr->muta3 & MUT3_WART_SKIN)
3763                 {
3764                         p_ptr->stat_add[A_CHR] -= 2;
3765                         p_ptr->to_a += 5;
3766                         p_ptr->dis_to_a += 5;
3767                 }
3768
3769                 if (p_ptr->muta3 & MUT3_SCALES)
3770                 {
3771                         p_ptr->stat_add[A_CHR] -= 1;
3772                         p_ptr->to_a += 10;
3773                         p_ptr->dis_to_a += 10;
3774                 }
3775
3776                 if (p_ptr->muta3 & MUT3_IRON_SKIN)
3777                 {
3778                         p_ptr->stat_add[A_DEX] -= 1;
3779                         p_ptr->to_a += 25;
3780                         p_ptr->dis_to_a += 25;
3781                 }
3782
3783                 if (p_ptr->muta3 & MUT3_WINGS)
3784                 {
3785                         p_ptr->levitation = TRUE;
3786                 }
3787
3788                 if (p_ptr->muta3 & MUT3_FEARLESS)
3789                 {
3790                         p_ptr->resist_fear = TRUE;
3791                 }
3792
3793                 if (p_ptr->muta3 & MUT3_REGEN)
3794                 {
3795                         p_ptr->regenerate = TRUE;
3796                 }
3797
3798                 if (p_ptr->muta3 & MUT3_ESP)
3799                 {
3800                         p_ptr->telepathy = TRUE;
3801                 }
3802
3803                 if (p_ptr->muta3 & MUT3_LIMBER)
3804                 {
3805                         p_ptr->stat_add[A_DEX] += 3;
3806                 }
3807
3808                 if (p_ptr->muta3 & MUT3_ARTHRITIS)
3809                 {
3810                         p_ptr->stat_add[A_DEX] -= 3;
3811                 }
3812
3813                 if (p_ptr->muta3 & MUT3_MOTION)
3814                 {
3815                         p_ptr->free_act = TRUE;
3816                         p_ptr->skill_stl += 1;
3817                 }
3818
3819                 if (p_ptr->muta3 & MUT3_ILL_NORM)
3820                 {
3821                         p_ptr->stat_add[A_CHR] = 0;
3822                 }
3823         }
3824
3825         if (p_ptr->tsuyoshi)
3826         {
3827                 p_ptr->stat_add[A_STR] += 4;
3828                 p_ptr->stat_add[A_CON] += 4;
3829         }
3830
3831         /* Scan the usable inventory */
3832         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3833         {
3834                 int bonus_to_h, bonus_to_d;
3835                 o_ptr = &inventory[i];
3836
3837                 /* Skip non-objects */
3838                 if (!o_ptr->k_idx) continue;
3839
3840                 /* Extract the item flags */
3841                 object_flags(o_ptr, flgs);
3842
3843                 p_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
3844                 if (o_ptr->name1 == ART_CHAINSWORD) p_ptr->cursed |= TRC_CHAINSWORD;
3845
3846                 /* Affect stats */
3847                 if (have_flag(flgs, TR_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
3848                 if (have_flag(flgs, TR_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
3849                 if (have_flag(flgs, TR_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
3850                 if (have_flag(flgs, TR_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
3851                 if (have_flag(flgs, TR_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
3852                 if (have_flag(flgs, TR_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
3853
3854                 if (have_flag(flgs, TR_MAGIC_MASTERY))    p_ptr->skill_dev += 8*o_ptr->pval;
3855
3856                 /* Affect stealth */
3857                 if (have_flag(flgs, TR_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
3858
3859                 /* Affect searching ability (factor of five) */
3860                 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
3861
3862                 /* Affect searching frequency (factor of five) */
3863                 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
3864
3865                 /* Affect infravision */
3866                 if (have_flag(flgs, TR_INFRA)) p_ptr->see_infra += o_ptr->pval;
3867
3868                 /* Affect digging (factor of 20) */
3869                 if (have_flag(flgs, TR_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
3870
3871                 /* Affect speed */
3872                 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
3873
3874                 /* Affect blows */
3875                 if (have_flag(flgs, TR_BLOWS))
3876                 {
3877                         if((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
3878                         else if((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
3879                         else {extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval;}
3880                 }
3881
3882                 /* Hack -- cause earthquakes */
3883                 if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
3884
3885                 /* Boost shots */
3886                 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3887
3888                 /* Various flags */
3889                 if (have_flag(flgs, TR_AGGRAVATE))   p_ptr->cursed |= TRC_AGGRAVATE;
3890                 if (have_flag(flgs, TR_DRAIN_EXP))   p_ptr->cursed |= TRC_DRAIN_EXP;
3891                 if (have_flag(flgs, TR_TY_CURSE))    p_ptr->cursed |= TRC_TY_CURSE;
3892                 if (have_flag(flgs, TR_DEC_MANA))    p_ptr->dec_mana = TRUE;
3893                 if (have_flag(flgs, TR_BLESSED))     p_ptr->bless_blade = TRUE;
3894                 if (have_flag(flgs, TR_XTRA_MIGHT))  p_ptr->xtra_might = TRUE;
3895                 if (have_flag(flgs, TR_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
3896                 if (have_flag(flgs, TR_REGEN))       p_ptr->regenerate = TRUE;
3897                 if (have_flag(flgs, TR_TELEPATHY))   p_ptr->telepathy = TRUE;
3898                 if (have_flag(flgs, TR_ESP_ANIMAL))  p_ptr->esp_animal = TRUE;
3899                 if (have_flag(flgs, TR_ESP_UNDEAD))  p_ptr->esp_undead = TRUE;
3900                 if (have_flag(flgs, TR_ESP_DEMON))   p_ptr->esp_demon = TRUE;
3901                 if (have_flag(flgs, TR_ESP_ORC))     p_ptr->esp_orc = TRUE;
3902                 if (have_flag(flgs, TR_ESP_TROLL))   p_ptr->esp_troll = TRUE;
3903                 if (have_flag(flgs, TR_ESP_GIANT))   p_ptr->esp_giant = TRUE;
3904                 if (have_flag(flgs, TR_ESP_DRAGON))  p_ptr->esp_dragon = TRUE;
3905                 if (have_flag(flgs, TR_ESP_HUMAN))   p_ptr->esp_human = TRUE;
3906                 if (have_flag(flgs, TR_ESP_EVIL))    p_ptr->esp_evil = TRUE;
3907                 if (have_flag(flgs, TR_ESP_GOOD))    p_ptr->esp_good = TRUE;
3908                 if (have_flag(flgs, TR_ESP_NONLIVING)) p_ptr->esp_nonliving = TRUE;
3909                 if (have_flag(flgs, TR_ESP_UNIQUE))  p_ptr->esp_unique = TRUE;
3910
3911                 if (have_flag(flgs, TR_SEE_INVIS))   p_ptr->see_inv = TRUE;
3912                 if (have_flag(flgs, TR_LEVITATION))     p_ptr->levitation = TRUE;
3913                 if (have_flag(flgs, TR_FREE_ACT))    p_ptr->free_act = TRUE;
3914                 if (have_flag(flgs, TR_HOLD_LIFE))   p_ptr->hold_life = TRUE;
3915                 if (have_flag(flgs, TR_WARNING)){
3916                         if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription),'$')))
3917                           p_ptr->warning = TRUE;
3918                 }
3919
3920                 if (have_flag(flgs, TR_TELEPORT))
3921                 {
3922                         if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
3923                         else
3924                         {
3925                                 cptr insc = quark_str(o_ptr->inscription);
3926
3927                                 if (o_ptr->inscription && my_strchr(insc, '.'))
3928                                 {
3929                                         /*
3930                                          * {.} will stop random teleportation.
3931                                          */
3932                                 }
3933                                 else
3934                                 {
3935                                         /* Controlled random teleportation */
3936                                         p_ptr->cursed |= TRC_TELEPORT_SELF;
3937                                 }
3938                         }
3939                 }
3940
3941                 /* Immunity flags */
3942                 if (have_flag(flgs, TR_IM_FIRE)) p_ptr->immune_fire = TRUE;
3943                 if (have_flag(flgs, TR_IM_ACID)) p_ptr->immune_acid = TRUE;
3944                 if (have_flag(flgs, TR_IM_COLD)) p_ptr->immune_cold = TRUE;
3945                 if (have_flag(flgs, TR_IM_ELEC)) p_ptr->immune_elec = TRUE;
3946
3947                 /* Resistance flags */
3948                 if (have_flag(flgs, TR_RES_ACID))   p_ptr->resist_acid = TRUE;
3949                 if (have_flag(flgs, TR_RES_ELEC))   p_ptr->resist_elec = TRUE;
3950                 if (have_flag(flgs, TR_RES_FIRE))   p_ptr->resist_fire = TRUE;
3951                 if (have_flag(flgs, TR_RES_COLD))   p_ptr->resist_cold = TRUE;
3952                 if (have_flag(flgs, TR_RES_POIS))   p_ptr->resist_pois = TRUE;
3953                 if (have_flag(flgs, TR_RES_FEAR))   p_ptr->resist_fear = TRUE;
3954                 if (have_flag(flgs, TR_RES_CONF))   p_ptr->resist_conf = TRUE;
3955                 if (have_flag(flgs, TR_RES_SOUND))  p_ptr->resist_sound = TRUE;
3956                 if (have_flag(flgs, TR_RES_LITE))   p_ptr->resist_lite = TRUE;
3957                 if (have_flag(flgs, TR_RES_DARK))   p_ptr->resist_dark = TRUE;
3958                 if (have_flag(flgs, TR_RES_CHAOS))  p_ptr->resist_chaos = TRUE;
3959                 if (have_flag(flgs, TR_RES_DISEN))  p_ptr->resist_disen = TRUE;
3960                 if (have_flag(flgs, TR_RES_SHARDS)) p_ptr->resist_shard = TRUE;
3961                 if (have_flag(flgs, TR_RES_NEXUS))  p_ptr->resist_nexus = TRUE;
3962                 if (have_flag(flgs, TR_RES_BLIND))  p_ptr->resist_blind = TRUE;
3963                 if (have_flag(flgs, TR_RES_NETHER)) p_ptr->resist_neth = TRUE;
3964
3965                 if (have_flag(flgs, TR_REFLECT))  p_ptr->reflect = TRUE;
3966                 if (have_flag(flgs, TR_SH_FIRE))  p_ptr->sh_fire = TRUE;
3967                 if (have_flag(flgs, TR_SH_ELEC))  p_ptr->sh_elec = TRUE;
3968                 if (have_flag(flgs, TR_SH_COLD))  p_ptr->sh_cold = TRUE;
3969                 if (have_flag(flgs, TR_NO_MAGIC)) p_ptr->anti_magic = TRUE;
3970                 if (have_flag(flgs, TR_NO_TELE))  p_ptr->anti_tele = TRUE;
3971
3972                 /* Sustain flags */
3973                 if (have_flag(flgs, TR_SUST_STR)) p_ptr->sustain_str = TRUE;
3974                 if (have_flag(flgs, TR_SUST_INT)) p_ptr->sustain_int = TRUE;
3975                 if (have_flag(flgs, TR_SUST_WIS)) p_ptr->sustain_wis = TRUE;
3976                 if (have_flag(flgs, TR_SUST_DEX)) p_ptr->sustain_dex = TRUE;
3977                 if (have_flag(flgs, TR_SUST_CON)) p_ptr->sustain_con = TRUE;
3978                 if (have_flag(flgs, TR_SUST_CHR)) p_ptr->sustain_chr = TRUE;
3979
3980                 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
3981                 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
3982                 if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
3983                 if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
3984                 if (have_flag(flgs, TR_EASY_SPELL)) p_ptr->easy_spell = TRUE;
3985                 if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
3986                 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
3987
3988                 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
3989                 {
3990                         if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
3991                         {
3992                                 p_ptr->to_m_chance += 10;
3993                         }
3994                         else
3995                         {
3996                                 p_ptr->to_m_chance += 3;
3997                         }
3998                 }
3999
4000                 if (o_ptr->tval == TV_CAPTURE) continue;
4001
4002                 /* Modify the base armor class */
4003                 p_ptr->ac += o_ptr->ac;
4004
4005                 /* The base armor class is always known */
4006                 p_ptr->dis_ac += o_ptr->ac;
4007
4008                 /* Apply the bonuses to armor class */
4009                 p_ptr->to_a += o_ptr->to_a;
4010
4011                 /* Apply the mental bonuses to armor class, if known */
4012                 if (object_is_known(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
4013
4014                 if (o_ptr->curse_flags & TRC_LOW_MELEE)
4015                 {
4016                         int slot = i - INVEN_RARM;
4017                         if (slot < 2)
4018                         {
4019                                 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
4020                                 {
4021                                         p_ptr->to_h[slot] -= 15;
4022                                         if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 15;
4023                                 }
4024                                 else
4025                                 {
4026                                         p_ptr->to_h[slot] -= 5;
4027                                         if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 5;
4028                                 }
4029                         }
4030                         else
4031                         {
4032                                 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
4033                                 {
4034                                         p_ptr->to_h_b -= 15;
4035                                         if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 15;
4036                                 }
4037                                 else
4038                                 {
4039                                         p_ptr->to_h_b -= 5;
4040                                         if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 5;
4041                                 }
4042                         }
4043                 }
4044
4045                 if (o_ptr->curse_flags & TRC_LOW_AC)
4046                 {
4047                         if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
4048                         {
4049                                 p_ptr->to_a -= 30;
4050                                 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 30;
4051                         }
4052                         else
4053                         {
4054                                 p_ptr->to_a -= 10;
4055                                 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 10;
4056                         }
4057                 }
4058
4059                 /* Hack -- do not apply "weapon" bonuses */
4060                 if (i == INVEN_RARM && buki_motteruka(i)) continue;
4061                 if (i == INVEN_LARM && buki_motteruka(i)) continue;
4062
4063                 /* Hack -- do not apply "bow" bonuses */
4064                 if (i == INVEN_BOW) continue;
4065
4066                 bonus_to_h = o_ptr->to_h;
4067                 bonus_to_d = o_ptr->to_d;
4068
4069                 if (p_ptr->pclass == CLASS_NINJA)
4070                 {
4071                         if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h+1)/2;
4072                         if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d+1)/2;
4073                 }
4074
4075                 /* To Bow and Natural attack */
4076
4077                 /* Apply the bonuses to hit/damage */
4078                 p_ptr->to_h_b += bonus_to_h;
4079                 p_ptr->to_h_m += bonus_to_h;
4080                 p_ptr->to_d_m += bonus_to_d;
4081
4082                 /* Apply the mental bonuses tp hit/damage, if known */
4083                 if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
4084
4085                 /* To Melee */
4086                 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
4087                 {
4088                         /* Apply the bonuses to hit/damage */
4089                         p_ptr->to_h[i-INVEN_RIGHT] += bonus_to_h;
4090                         p_ptr->to_d[i-INVEN_RIGHT] += bonus_to_d;
4091
4092                         /* Apply the mental bonuses tp hit/damage, if known */
4093                         if (object_is_known(o_ptr))
4094                         {
4095                                 p_ptr->dis_to_h[i-INVEN_RIGHT] += bonus_to_h;
4096                                 p_ptr->dis_to_d[i-INVEN_RIGHT] += bonus_to_d;
4097                         }
4098                 }
4099                 else if (p_ptr->migite && p_ptr->hidarite)
4100                 {
4101                         /* Apply the bonuses to hit/damage */
4102                         p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
4103                         p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
4104                         p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
4105                         p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
4106
4107                         /* Apply the mental bonuses tp hit/damage, if known */
4108                         if (object_is_known(o_ptr))
4109                         {
4110                                 p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
4111                                 p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
4112                                 p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
4113                                 p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
4114                         }
4115                 }
4116                 else
4117                 {
4118                         /* Apply the bonuses to hit/damage */
4119                         p_ptr->to_h[default_hand] += bonus_to_h;
4120                         p_ptr->to_d[default_hand] += bonus_to_d;
4121
4122                         /* Apply the mental bonuses to hit/damage, if known */
4123                         if (object_is_known(o_ptr))
4124                         {
4125                                 p_ptr->dis_to_h[default_hand] += bonus_to_h;
4126                                 p_ptr->dis_to_d[default_hand] += bonus_to_d;
4127                         }
4128                 }
4129         }
4130
4131         if (old_mighty_throw != p_ptr->mighty_throw)
4132         {
4133                 /* Redraw average damege display of Shuriken */
4134                 p_ptr->window |= PW_INVEN;
4135         }
4136
4137         if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
4138
4139         /* Monks get extra ac for armour _not worn_ */
4140         if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
4141         {
4142                 if (!(inventory[INVEN_BODY].k_idx))
4143                 {
4144                         p_ptr->to_a += (p_ptr->lev * 3) / 2;
4145                         p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
4146                 }
4147                 if (!(inventory[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
4148                 {
4149                         p_ptr->to_a += ((p_ptr->lev - 13) / 3);
4150                         p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
4151                 }
4152                 if (!(inventory[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
4153                 {
4154                         p_ptr->to_a += ((p_ptr->lev - 8) / 3);
4155                         p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
4156                 }
4157                 if (!(inventory[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
4158                 {
4159                         p_ptr->to_a += (p_ptr->lev - 2) / 3;
4160                         p_ptr->dis_to_a += (p_ptr->lev -2) / 3;
4161                 }
4162                 if (!(inventory[INVEN_HANDS].k_idx))
4163                 {
4164                         p_ptr->to_a += (p_ptr->lev / 2);
4165                         p_ptr->dis_to_a += (p_ptr->lev / 2);
4166                 }
4167                 if (!(inventory[INVEN_FEET].k_idx))
4168                 {
4169                         p_ptr->to_a += (p_ptr->lev / 3);
4170                         p_ptr->dis_to_a += (p_ptr->lev / 3);
4171                 }
4172                 if (p_ptr->special_defense & KAMAE_BYAKKO)
4173                 {
4174                         p_ptr->stat_add[A_STR] += 2;
4175                         p_ptr->stat_add[A_DEX] += 2;
4176                         p_ptr->stat_add[A_CON] -= 3;
4177                 }
4178                 else if (p_ptr->special_defense & KAMAE_SEIRYU)
4179                 {
4180                 }
4181                 else if (p_ptr->special_defense & KAMAE_GENBU)
4182                 {
4183                         p_ptr->stat_add[A_INT] -= 1;
4184                         p_ptr->stat_add[A_WIS] -= 1;
4185                         p_ptr->stat_add[A_DEX] -= 2;
4186                         p_ptr->stat_add[A_CON] += 3;
4187                 }
4188                 else if (p_ptr->special_defense & KAMAE_SUZAKU)
4189                 {
4190                         p_ptr->stat_add[A_STR] -= 2;
4191                         p_ptr->stat_add[A_INT] += 1;
4192                         p_ptr->stat_add[A_WIS] += 1;
4193                         p_ptr->stat_add[A_DEX] += 2;
4194                         p_ptr->stat_add[A_CON] -= 2;
4195                 }
4196         }
4197
4198         if (p_ptr->special_defense & KATA_KOUKIJIN)
4199         {
4200                 for (i = 0; i < 6; i++)
4201                         p_ptr->stat_add[i] += 5;
4202                 p_ptr->to_a -= 50;
4203                 p_ptr->dis_to_a -= 50;
4204         }
4205
4206         /* Hack -- aura of fire also provides light */
4207         if (p_ptr->sh_fire) p_ptr->lite = TRUE;
4208
4209         /* Golems also get an intrinsic AC bonus */
4210         if (prace_is_(RACE_GOLEM) || prace_is_(RACE_ANDROID))
4211         {
4212                 p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
4213                 p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
4214         }
4215
4216         /* Calculate stats */
4217         for (i = 0; i < 6; i++)
4218         {
4219                 int top, use, ind;
4220
4221                 /* Extract the new "stat_use" value for the stat */
4222                 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
4223
4224                 /* Notice changes */
4225                 if (p_ptr->stat_top[i] != top)
4226                 {
4227                         /* Save the new value */
4228                         p_ptr->stat_top[i] = top;
4229
4230                         /* Redisplay the stats later */
4231                         p_ptr->redraw |= (PR_STATS);
4232
4233                         /* Window stuff */
4234                         p_ptr->window |= (PW_PLAYER);
4235                 }
4236
4237
4238                 /* Extract the new "stat_use" value for the stat */
4239                 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
4240
4241                 if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
4242                 {
4243                         /* 10 to 18/90 charisma, guaranteed, based on level */
4244                         if (use < 8 + 2 * p_ptr->lev)
4245                         {
4246                                 use = 8 + 2 * p_ptr->lev;
4247                         }
4248                 }
4249
4250                 /* Notice changes */
4251                 if (p_ptr->stat_use[i] != use)
4252                 {
4253                         /* Save the new value */
4254                         p_ptr->stat_use[i] = use;
4255
4256                         /* Redisplay the stats later */
4257                         p_ptr->redraw |= (PR_STATS);
4258
4259                         /* Window stuff */
4260                         p_ptr->window |= (PW_PLAYER);
4261                 }
4262
4263
4264                 /* Values: 3, 4, ..., 17 */
4265                 if (use <= 18) ind = (use - 3);
4266
4267                 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
4268                 else if (use <= 18+219) ind = (15 + (use - 18) / 10);
4269
4270                 /* Range: 18/220+ */
4271                 else ind = (37);
4272
4273                 /* Notice changes */
4274                 if (p_ptr->stat_ind[i] != ind)
4275                 {
4276                         /* Save the new index */
4277                         p_ptr->stat_ind[i] = ind;
4278
4279                         /* Change in CON affects Hitpoints */
4280                         if (i == A_CON)
4281                         {
4282                                 p_ptr->update |= (PU_HP);
4283                         }
4284
4285                         /* Change in INT may affect Mana/Spells */
4286                         else if (i == A_INT)
4287                         {
4288                                 if (mp_ptr->spell_stat == A_INT)
4289                                 {
4290                                         p_ptr->update |= (PU_MANA | PU_SPELLS);
4291                                 }
4292                         }
4293
4294                         /* Change in WIS may affect Mana/Spells */
4295                         else if (i == A_WIS)
4296                         {
4297                                 if (mp_ptr->spell_stat == A_WIS)
4298                                 {
4299                                         p_ptr->update |= (PU_MANA | PU_SPELLS);
4300                                 }
4301                         }
4302
4303                         /* Change in WIS may affect Mana/Spells */
4304                         else if (i == A_CHR)
4305                         {
4306                                 if (mp_ptr->spell_stat == A_CHR)
4307                                 {
4308                                         p_ptr->update |= (PU_MANA | PU_SPELLS);
4309                                 }
4310                         }
4311
4312                         /* Window stuff */
4313                         p_ptr->window |= (PW_PLAYER);
4314                 }
4315         }
4316
4317
4318         /* Apply temporary "stun" */
4319         if (p_ptr->stun > 50)
4320         {
4321                 p_ptr->to_h[0] -= 20;
4322                 p_ptr->to_h[1] -= 20;
4323                 p_ptr->to_h_b  -= 20;
4324                 p_ptr->to_h_m  -= 20;
4325                 p_ptr->dis_to_h[0] -= 20;
4326                 p_ptr->dis_to_h[1] -= 20;
4327                 p_ptr->dis_to_h_b  -= 20;
4328                 p_ptr->to_d[0] -= 20;
4329                 p_ptr->to_d[1] -= 20;
4330                 p_ptr->to_d_m -= 20;
4331                 p_ptr->dis_to_d[0] -= 20;
4332                 p_ptr->dis_to_d[1] -= 20;
4333         }
4334         else if (p_ptr->stun)
4335         {
4336                 p_ptr->to_h[0] -= 5;
4337                 p_ptr->to_h[1] -= 5;
4338                 p_ptr->to_h_b -= 5;
4339                 p_ptr->to_h_m -= 5;
4340                 p_ptr->dis_to_h[0] -= 5;
4341                 p_ptr->dis_to_h[1] -= 5;
4342                 p_ptr->dis_to_h_b -= 5;
4343                 p_ptr->to_d[0] -= 5;
4344                 p_ptr->to_d[1] -= 5;
4345                 p_ptr->to_d_m -= 5;
4346                 p_ptr->dis_to_d[0] -= 5;
4347                 p_ptr->dis_to_d[1] -= 5;
4348         }
4349
4350         /* Wraith form */
4351         if (p_ptr->wraith_form)
4352         {
4353                 p_ptr->reflect = TRUE;
4354                 p_ptr->pass_wall = TRUE;
4355         }
4356
4357         if (p_ptr->kabenuke)
4358         {
4359                 p_ptr->pass_wall = TRUE;
4360         }
4361
4362         /* Temporary blessing */
4363         if (IS_BLESSED())
4364         {
4365                 p_ptr->to_a += 5;
4366                 p_ptr->dis_to_a += 5;
4367                 p_ptr->to_h[0] += 10;
4368                 p_ptr->to_h[1] += 10;
4369                 p_ptr->to_h_b  += 10;
4370                 p_ptr->to_h_m  += 10;
4371                 p_ptr->dis_to_h[0] += 10;
4372                 p_ptr->dis_to_h[1] += 10;
4373                 p_ptr->dis_to_h_b += 10;
4374         }
4375
4376         if (p_ptr->magicdef)
4377         {
4378                 p_ptr->resist_blind = TRUE;
4379                 p_ptr->resist_conf = TRUE;
4380                 p_ptr->reflect = TRUE;
4381                 p_ptr->free_act = TRUE;
4382                 p_ptr->levitation = TRUE;
4383         }
4384
4385         /* Temporary "Hero" */
4386         if (IS_HERO())
4387         {
4388                 p_ptr->to_h[0] += 12;
4389                 p_ptr->to_h[1] += 12;
4390                 p_ptr->to_h_b  += 12;
4391                 p_ptr->to_h_m  += 12;
4392                 p_ptr->dis_to_h[0] += 12;
4393                 p_ptr->dis_to_h[1] += 12;
4394                 p_ptr->dis_to_h_b  += 12;
4395         }
4396
4397         /* Temporary "Beserk" */
4398         if (p_ptr->shero)
4399         {
4400                 p_ptr->to_h[0] += 12;
4401                 p_ptr->to_h[1] += 12;
4402                 p_ptr->to_h_b  -= 12;
4403                 p_ptr->to_h_m  += 12;
4404                 p_ptr->to_d[0] += 3+(p_ptr->lev/5);
4405                 p_ptr->to_d[1] += 3+(p_ptr->lev/5);
4406                 p_ptr->to_d_m  += 3+(p_ptr->lev/5);
4407                 p_ptr->dis_to_h[0] += 12;
4408                 p_ptr->dis_to_h[1] += 12;
4409                 p_ptr->dis_to_h_b  -= 12;
4410                 p_ptr->dis_to_d[0] += 3+(p_ptr->lev/5);
4411                 p_ptr->dis_to_d[1] += 3+(p_ptr->lev/5);
4412                 p_ptr->to_a -= 10;
4413                 p_ptr->dis_to_a -= 10;
4414                 p_ptr->skill_stl -= 7;
4415                 p_ptr->skill_dev -= 20;
4416                 p_ptr->skill_sav -= 30;
4417                 p_ptr->skill_srh -= 15;
4418                 p_ptr->skill_fos -= 15;
4419                 p_ptr->skill_tht -= 20;
4420                 p_ptr->skill_dig += 30;
4421         }
4422
4423         /* Temporary "fast" */
4424         if (IS_FAST())
4425         {
4426                 new_speed += 10;
4427         }
4428
4429         /* Temporary "slow" */
4430         if (p_ptr->slow)
4431         {
4432                 new_speed -= 10;
4433         }
4434
4435         /* Temporary "telepathy" */
4436         if (IS_TIM_ESP())
4437         {
4438                 p_ptr->telepathy = TRUE;
4439         }
4440
4441         if (p_ptr->ele_immune)
4442         {
4443                 if (p_ptr->special_defense & DEFENSE_ACID)
4444                         p_ptr->immune_acid = TRUE;
4445                 else if (p_ptr->special_defense & DEFENSE_ELEC)
4446                         p_ptr->immune_elec = TRUE;
4447                 else if (p_ptr->special_defense & DEFENSE_FIRE)
4448                         p_ptr->immune_fire = TRUE;
4449                 else if (p_ptr->special_defense & DEFENSE_COLD)
4450                         p_ptr->immune_cold = TRUE;
4451         }
4452
4453         /* Temporary see invisible */
4454         if (p_ptr->tim_invis)
4455         {
4456                 p_ptr->see_inv = TRUE;
4457         }
4458
4459         /* Temporary infravision boost */
4460         if (p_ptr->tim_infra)
4461         {
4462                 p_ptr->see_infra+=3;
4463         }
4464
4465         /* Temporary regeneration boost */
4466         if (p_ptr->tim_regen)
4467         {
4468                 p_ptr->regenerate = TRUE;
4469         }
4470
4471         /* Temporary levitation */
4472         if (p_ptr->tim_levitation)
4473         {
4474                 p_ptr->levitation = TRUE;
4475         }
4476
4477         /* Temporary reflection */
4478         if (p_ptr->tim_reflect)
4479         {
4480                 p_ptr->reflect = TRUE;
4481         }
4482
4483         /* Hack -- Hero/Shero -> Res fear */
4484         if (IS_HERO() || p_ptr->shero)
4485         {
4486                 p_ptr->resist_fear = TRUE;
4487         }
4488
4489
4490         /* Hack -- Telepathy Change */
4491         if (p_ptr->telepathy != old_telepathy)
4492         {
4493                 p_ptr->update |= (PU_MONSTERS);
4494         }
4495
4496         if ((p_ptr->esp_animal != old_esp_animal) ||
4497             (p_ptr->esp_undead != old_esp_undead) ||
4498             (p_ptr->esp_demon != old_esp_demon) ||
4499             (p_ptr->esp_orc != old_esp_orc) ||
4500             (p_ptr->esp_troll != old_esp_troll) ||
4501             (p_ptr->esp_giant != old_esp_giant) ||
4502             (p_ptr->esp_dragon != old_esp_dragon) ||
4503             (p_ptr->esp_human != old_esp_human) ||
4504             (p_ptr->esp_evil != old_esp_evil) ||
4505             (p_ptr->esp_good != old_esp_good) ||
4506             (p_ptr->esp_nonliving != old_esp_nonliving) ||
4507             (p_ptr->esp_unique != old_esp_unique))
4508         {
4509                 p_ptr->update |= (PU_MONSTERS);
4510         }
4511
4512         /* Hack -- See Invis Change */
4513         if (p_ptr->see_inv != old_see_inv)
4514         {
4515                 p_ptr->update |= (PU_MONSTERS);
4516         }
4517
4518         /* Bloating slows the player down (a little) */
4519         if (p_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
4520
4521         if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
4522
4523         if ((p_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
4524             (p_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
4525         {
4526                 p_ptr->to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
4527                 p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
4528         }
4529
4530         if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4531         {
4532                 int penalty1, penalty2;
4533                 penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_RARM].weight) / 8);
4534                 penalty2 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_LARM].weight) / 8);
4535                 if ((inventory[INVEN_RARM].name1 == ART_QUICKTHORN) && (inventory[INVEN_LARM].name1 == ART_TINYTHORN))
4536                 {
4537                         penalty1 = penalty1 / 2 - 5;
4538                         penalty2 = penalty2 / 2 - 5;
4539                         new_speed += 7;
4540                         p_ptr->to_a += 10;
4541                         p_ptr->dis_to_a += 10;
4542                 }
4543                 if (easy_2weapon)
4544                 {
4545                         if (penalty1 > 0) penalty1 /= 2;
4546                         if (penalty2 > 0) penalty2 /= 2;
4547                 }
4548                 else if ((inventory[INVEN_LARM].tval == TV_SWORD) && ((inventory[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (inventory[INVEN_LARM].sval == SV_WAKIZASHI)))
4549                 {
4550                         penalty1 = MAX(0, penalty1 - 10);
4551                         penalty2 = MAX(0, penalty2 - 10);
4552                 }
4553                 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
4554                 {
4555                         penalty1 = MIN(0, penalty1);
4556                         penalty2 = MIN(0, penalty2);
4557                         p_ptr->to_a += 10;
4558                         p_ptr->dis_to_a += 10;
4559                 }
4560                 else
4561                 {
4562                         if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
4563                                 penalty1 /= 2;
4564                         if ((inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
4565                                 penalty2 /= 2;
4566                 }
4567                 if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
4568                 if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
4569                 p_ptr->to_h[0] -= penalty1;
4570                 p_ptr->to_h[1] -= penalty2;
4571                 p_ptr->dis_to_h[0] -= penalty1;
4572                 p_ptr->dis_to_h[1] -= penalty2;
4573         }
4574
4575         /* Extract the current weight (in tenth pounds) */
4576         j = p_ptr->total_weight;
4577
4578         if (!p_ptr->riding)
4579         {
4580                 /* Extract the "weight limit" (in tenth pounds) */
4581                 i = (int)weight_limit();
4582         }
4583         else
4584         {
4585                 monster_type *riding_m_ptr = &m_list[p_ptr->riding];
4586                 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
4587                 int speed = riding_m_ptr->mspeed;
4588
4589                 if (riding_m_ptr->mspeed > 110)
4590                 {
4591                         new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
4592                         if (new_speed < 110) new_speed = 110;
4593                 }
4594                 else
4595                 {
4596                         new_speed = speed;
4597                 }
4598                 new_speed += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev *160L)/3200;
4599                 if (MON_FAST(riding_m_ptr)) new_speed += 10;
4600                 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
4601                 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
4602                 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
4603
4604                 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) p_ptr->pass_wall = FALSE;
4605                 if (riding_r_ptr->flags2 & RF2_KILL_WALL) p_ptr->kill_wall = TRUE;
4606
4607                 if (p_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) j += (p_ptr->wt * 3 * (RIDING_EXP_SKILLED - p_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
4608
4609                 /* Extract the "weight limit" */
4610                 i = 1500 + riding_r_ptr->level * 25;
4611         }
4612
4613         /* XXX XXX XXX Apply "encumbrance" from weight */
4614         if (j > i) new_speed -= ((j - i) / (i / 5));
4615
4616         /* Searching slows the player down */
4617         if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
4618
4619         /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
4620         p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
4621         p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4622         p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4623         p_ptr->to_d_m  += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4624         p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4625         p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4626         p_ptr->to_h_b  += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4627         p_ptr->to_h_m  += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4628         p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4629         p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4630         p_ptr->to_h_b  += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4631         p_ptr->to_h_m  += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4632
4633         /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
4634         p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
4635         p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4636         p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4637         p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4638         p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4639         p_ptr->dis_to_h_b  += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4640         p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4641         p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4642         p_ptr->dis_to_h_b  += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4643
4644
4645         /* Obtain the "hold" value */
4646         hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
4647
4648
4649         /* Examine the "current bow" */
4650         o_ptr = &inventory[INVEN_BOW];
4651
4652
4653         /* Assume not heavy */
4654         p_ptr->heavy_shoot = FALSE;
4655
4656         /* It is hard to carholdry a heavy bow */
4657         if (hold < o_ptr->weight / 10)
4658         {
4659                 /* Hard to wield a heavy bow */
4660                 p_ptr->to_h_b  += 2 * (hold - o_ptr->weight / 10);
4661                 p_ptr->dis_to_h_b  += 2 * (hold - o_ptr->weight / 10);
4662
4663                 /* Heavy Bow */
4664                 p_ptr->heavy_shoot = TRUE;
4665         }
4666
4667
4668         /* Compute "extra shots" if needed */
4669         if (o_ptr->k_idx)
4670         {
4671                 /* Analyze the launcher */
4672                 switch (o_ptr->sval)
4673                 {
4674                         case SV_SLING:
4675                         {
4676                                 p_ptr->tval_ammo = TV_SHOT;
4677                                 break;
4678                         }
4679
4680                         case SV_SHORT_BOW:
4681                         case SV_LONG_BOW:
4682                         case SV_NAMAKE_BOW:
4683                         {
4684                                 p_ptr->tval_ammo = TV_ARROW;
4685                                 break;
4686                         }
4687
4688                         case SV_LIGHT_XBOW:
4689                         case SV_HEAVY_XBOW:
4690                         {
4691                                 p_ptr->tval_ammo = TV_BOLT;
4692                                 break;
4693                         }
4694                         case SV_CRIMSON:
4695                         {
4696                                 p_ptr->tval_ammo = TV_NO_AMMO;
4697                                 break;
4698                         }
4699                 }
4700
4701                 /* Apply special flags */
4702                 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
4703                 {
4704                         /* Extra shots */
4705                         p_ptr->num_fire += (extra_shots * 100);
4706
4707                         /* Hack -- Rangers love Bows */
4708                         if ((p_ptr->pclass == CLASS_RANGER) &&
4709                             (p_ptr->tval_ammo == TV_ARROW))
4710                         {
4711                                 p_ptr->num_fire += (p_ptr->lev * 4);
4712                         }
4713
4714                         if ((p_ptr->pclass == CLASS_CAVALRY) &&
4715                             (p_ptr->tval_ammo == TV_ARROW))
4716                         {
4717                                 p_ptr->num_fire += (p_ptr->lev * 3);
4718                         }
4719
4720                         if (p_ptr->pclass == CLASS_ARCHER)
4721                         {
4722                                 if (p_ptr->tval_ammo == TV_ARROW)
4723                                         p_ptr->num_fire += ((p_ptr->lev * 5)+50);
4724                                 else if ((p_ptr->tval_ammo == TV_BOLT) || (p_ptr->tval_ammo == TV_SHOT))
4725                                         p_ptr->num_fire += (p_ptr->lev * 4);
4726                         }
4727
4728                         /*
4729                          * Addendum -- also "Reward" high level warriors,
4730                          * with _any_ missile weapon -- TY
4731                          */
4732                         if (p_ptr->pclass == CLASS_WARRIOR &&
4733                            (p_ptr->tval_ammo <= TV_BOLT) &&
4734                            (p_ptr->tval_ammo >= TV_SHOT))
4735                         {
4736                                 p_ptr->num_fire += (p_ptr->lev * 2);
4737                         }
4738                         if ((p_ptr->pclass == CLASS_ROGUE) &&
4739                             (p_ptr->tval_ammo == TV_SHOT))
4740                         {
4741                                 p_ptr->num_fire += (p_ptr->lev * 4);
4742                         }
4743
4744                         /* Snipers love Cross bows */
4745                         if ((p_ptr->pclass == CLASS_SNIPER) &&
4746                                 (p_ptr->tval_ammo == TV_BOLT))
4747                         {
4748                                 p_ptr->to_h_b += (10 + (p_ptr->lev / 5));
4749                                 p_ptr->dis_to_h_b += (10 + (p_ptr->lev / 5));
4750                         }
4751                 }
4752         }
4753
4754         if (p_ptr->ryoute)
4755                 hold *= 2;
4756
4757         for(i = 0 ; i < 2 ; i++)
4758         {
4759                 /* Examine the "main weapon" */
4760                 o_ptr = &inventory[INVEN_RARM+i];
4761
4762                 object_flags(o_ptr, flgs);
4763
4764                 /* Assume not heavy */
4765                 p_ptr->heavy_wield[i] = FALSE;
4766                 p_ptr->icky_wield[i] = FALSE;
4767                 p_ptr->riding_wield[i] = FALSE;
4768
4769                 if (!buki_motteruka(INVEN_RARM+i)) {p_ptr->num_blow[i]=1;continue;}
4770                 /* It is hard to hold a heavy weapon */
4771                 if (hold < o_ptr->weight / 10)
4772                 {
4773                         /* Hard to wield a heavy weapon */
4774                         p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
4775                         p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
4776
4777                         /* Heavy weapon */
4778                         p_ptr->heavy_wield[i] = TRUE;
4779                 }
4780                 else if (p_ptr->ryoute && (hold < o_ptr->weight/5)) omoi = TRUE;
4781
4782                 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
4783                 {
4784                         p_ptr->to_a += 5;
4785                         p_ptr->dis_to_a += 5;
4786                 }
4787
4788                 /* Normal weapons */
4789                 if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
4790                 {
4791                         int str_index, dex_index;
4792
4793                         int num = 0, wgt = 0, mul = 0, div = 0;
4794
4795                         /* Analyze the class */
4796                         switch (p_ptr->pclass)
4797                         {
4798                                 /* Warrior */
4799                                 case CLASS_WARRIOR:
4800                                         num = 6; wgt = 70; mul = 5; break;
4801
4802                                 /* Berserker */
4803                                 case CLASS_BERSERKER:
4804                                         num = 6; wgt = 70; mul = 7; break;
4805
4806                                 /* Mage */
4807                                 case CLASS_MAGE:
4808                                 case CLASS_HIGH_MAGE:
4809                                 case CLASS_BLUE_MAGE:
4810                                         num = 3; wgt = 100; mul = 2; break;
4811
4812                                 /* Priest, Mindcrafter, Magic-Eater */
4813                                 case CLASS_PRIEST:
4814                                 case CLASS_MAGIC_EATER:
4815                                 case CLASS_MINDCRAFTER:
4816                                         num = 5; wgt = 100; mul = 3; break;
4817
4818                                 /* Rogue */
4819                                 case CLASS_ROGUE:
4820                                         num = 5; wgt = 40; mul = 3; break;
4821
4822                                 /* Ranger */
4823                                 case CLASS_RANGER:
4824                                         num = 5; wgt = 70; mul = 4; break;
4825
4826                                 /* Paladin */
4827                                 case CLASS_PALADIN:
4828                                 case CLASS_SAMURAI:
4829                                         num = 5; wgt = 70; mul = 4; break;
4830
4831                                 /* Weaponsmith */
4832                                 case CLASS_SMITH:
4833                                         num = 5; wgt = 150; mul = 5; break;
4834
4835                                 /* Warrior-Mage */
4836                                 case CLASS_WARRIOR_MAGE:
4837                                 case CLASS_RED_MAGE:
4838                                         num = 5; wgt = 70; mul = 3; break;
4839
4840                                 /* Chaos Warrior */
4841                                 case CLASS_CHAOS_WARRIOR:
4842                                         num = 5; wgt = 70; mul = 4; break;
4843
4844                                 /* Monk */
4845                                 case CLASS_MONK:
4846                                         num = 5; wgt = 60; mul = 3; break;
4847
4848                                 /* Tourist */
4849                                 case CLASS_TOURIST:
4850                                         num = 4; wgt = 100; mul = 3; break;
4851
4852                                 /* Imitator */
4853                                 case CLASS_IMITATOR:
4854                                         num = 5; wgt = 70; mul = 4; break;
4855
4856                                 /* Beastmaster */
4857                                 case CLASS_BEASTMASTER:
4858                                         num = 5; wgt = 70; mul = 3; break;
4859
4860                                 /* Cavalry */
4861                                 case CLASS_CAVALRY:
4862                                         if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) {num = 5; wgt = 70; mul = 4;}
4863                                         else {num = 5; wgt = 100; mul = 3;}
4864                                         break;
4865
4866                                 /* Sorcerer */
4867                                 case CLASS_SORCERER:
4868                                         num = 1; wgt = 1; mul = 1; break;
4869
4870                                 /* Archer, Bard */
4871                                 case CLASS_ARCHER:
4872                                 case CLASS_BARD:
4873                                         num = 4; wgt = 70; mul = 2; break;
4874
4875                                 /* ForceTrainer */
4876                                 case CLASS_FORCETRAINER:
4877                                         num = 4; wgt = 60; mul = 2; break;
4878
4879                                 /* Mirror Master, Sniper */
4880                                 case CLASS_MIRROR_MASTER:
4881                                 case CLASS_SNIPER:
4882                                         num = 3; wgt = 100; mul = 3; break;
4883
4884                                 /* Ninja */
4885                                 case CLASS_NINJA:
4886                                         num = 4; wgt = 20; mul = 1; break;
4887                         }
4888
4889                         /* Enforce a minimum "weight" (tenth pounds) */
4890                         div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
4891
4892                         /* Access the strength vs weight */
4893                         str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
4894
4895                         if (p_ptr->ryoute && !omoi) str_index++;
4896                         if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index-1);
4897
4898                         /* Maximal value */
4899                         if (str_index > 11) str_index = 11;
4900
4901                         /* Index by dexterity */
4902                         dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
4903
4904                         /* Maximal value */
4905                         if (dex_index > 11) dex_index = 11;
4906
4907                         /* Use the blows table */
4908                         p_ptr->num_blow[i] = blows_table[str_index][dex_index];
4909
4910                         /* Maximal value */
4911                         if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = num;
4912
4913                         /* Add in the "bonus blows" */
4914                         p_ptr->num_blow[i] += extra_blows[i];
4915
4916
4917                         if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
4918                         else if (p_ptr->pclass == CLASS_BERSERKER)
4919                         {
4920                                 p_ptr->num_blow[i] += (p_ptr->lev / 23);
4921                         }
4922                         else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
4923
4924                         if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
4925
4926                         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
4927
4928
4929                         /* Require at least one blow */
4930                         if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
4931
4932                         /* Boost digging skill by weapon weight */
4933                         p_ptr->skill_dig += (o_ptr->weight / 10);
4934                 }
4935
4936                 /* Assume okay */
4937                 /* Priest weapon penalty for non-blessed edged weapons */
4938                 if ((p_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
4939                     ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
4940                 {
4941                         /* Reduce the real bonuses */
4942                         p_ptr->to_h[i] -= 2;
4943                         p_ptr->to_d[i] -= 2;
4944
4945                         /* Reduce the mental bonuses */
4946                         p_ptr->dis_to_h[i] -= 2;
4947                         p_ptr->dis_to_d[i] -= 2;
4948
4949                         /* Icky weapon */
4950                         p_ptr->icky_wield[i] = TRUE;
4951                 }
4952                 else if (p_ptr->pclass == CLASS_BERSERKER)
4953                 {
4954                         p_ptr->to_h[i] += p_ptr->lev/5;
4955                         p_ptr->to_d[i] += p_ptr->lev/6;
4956                         p_ptr->dis_to_h[i] += p_ptr->lev/5;
4957                         p_ptr->dis_to_d[i] += p_ptr->lev/6;
4958                         if (((i == 0) && !p_ptr->hidarite) || p_ptr->ryoute)
4959                         {
4960                                 p_ptr->to_h[i] += p_ptr->lev/5;
4961                                 p_ptr->to_d[i] += p_ptr->lev/6;
4962                                 p_ptr->dis_to_h[i] += p_ptr->lev/5;
4963                                 p_ptr->dis_to_d[i] += p_ptr->lev/6;
4964                         }
4965                 }
4966                 else if (p_ptr->pclass == CLASS_SORCERER)
4967                 {
4968                         if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
4969                         {
4970                                 /* Reduce the real bonuses */
4971                                 p_ptr->to_h[i] -= 200;
4972                                 p_ptr->to_d[i] -= 200;
4973
4974                                 /* Reduce the mental bonuses */
4975                                 p_ptr->dis_to_h[i] -= 200;
4976                                 p_ptr->dis_to_d[i] -= 200;
4977
4978                                 /* Icky weapon */
4979                                 p_ptr->icky_wield[i] = TRUE;
4980                         }
4981                         else
4982                         {
4983                                 /* Reduce the real bonuses */
4984                                 p_ptr->to_h[i] -= 30;
4985                                 p_ptr->to_d[i] -= 10;
4986
4987                                 /* Reduce the mental bonuses */
4988                                 p_ptr->dis_to_h[i] -= 30;
4989                                 p_ptr->dis_to_d[i] -= 10;
4990                         }
4991                 }
4992                 if (p_ptr->riding)
4993                 {
4994                         if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
4995                         {
4996                                 p_ptr->to_h[i] +=15;
4997                                 p_ptr->dis_to_h[i] +=15;
4998                                 p_ptr->to_dd[i] += 2;
4999                         }
5000                         else if (!(have_flag(flgs, TR_RIDING)))
5001                         {
5002                                 int penalty;
5003                                 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
5004                                 {
5005                                         penalty = 5;
5006                                 }
5007                                 else
5008                                 {
5009                                         penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
5010                                         penalty += 30;
5011                                         if (penalty < 30) penalty = 30;
5012                                 }
5013                                 p_ptr->to_h[i] -= penalty;
5014                                 p_ptr->dis_to_h[i] -= penalty;
5015
5016                                 /* Riding weapon */
5017                                 p_ptr->riding_wield[i] = TRUE;
5018                         }
5019                 }
5020         }
5021
5022         if (p_ptr->riding)
5023         {
5024                 int penalty = 0;
5025
5026                 p_ptr->riding_ryoute = FALSE;
5027
5028                 if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
5029                 else if (p_ptr->pet_extra_flags & PF_RYOUTE)
5030                 {
5031                         switch (p_ptr->pclass)
5032                         {
5033                         case CLASS_MONK:
5034                         case CLASS_FORCETRAINER:
5035                         case CLASS_BERSERKER:
5036                                 if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
5037                                         p_ptr->riding_ryoute = TRUE;
5038                                 break;
5039                         }
5040                 }
5041
5042                 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
5043                 {
5044                         if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
5045                 }
5046                 else
5047                 {
5048                         penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
5049                         penalty += 30;
5050                         if (penalty < 30) penalty = 30;
5051                 }
5052                 if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
5053                 p_ptr->to_h_b -= penalty;
5054                 p_ptr->dis_to_h_b -= penalty;
5055         }
5056
5057         /* Different calculation for monks with empty hands */
5058         if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) &&
5059                 (empty_hands_status & EMPTY_HAND_RARM) && !p_ptr->hidarite)
5060         {
5061                 int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
5062                 p_ptr->num_blow[0] = 0;
5063
5064                 if (p_ptr->pclass == CLASS_FORCETRAINER)
5065                 {
5066                         if (blow_base > 18) p_ptr->num_blow[0]++;
5067                         if (blow_base > 31) p_ptr->num_blow[0]++;
5068                         if (blow_base > 44) p_ptr->num_blow[0]++;
5069                         if (blow_base > 58) p_ptr->num_blow[0]++;
5070                         if (p_ptr->magic_num1[0])
5071                         {
5072                                 p_ptr->to_d[0] += (p_ptr->magic_num1[0]/5);
5073                                 p_ptr->dis_to_d[0] += (p_ptr->magic_num1[0]/5);
5074                         }
5075                 }
5076                 else
5077                 {
5078                         if (blow_base > 12) p_ptr->num_blow[0]++;
5079                         if (blow_base > 22) p_ptr->num_blow[0]++;
5080                         if (blow_base > 31) p_ptr->num_blow[0]++;
5081                         if (blow_base > 39) p_ptr->num_blow[0]++;
5082                         if (blow_base > 46) p_ptr->num_blow[0]++;
5083                         if (blow_base > 53) p_ptr->num_blow[0]++;
5084                         if (blow_base > 59) p_ptr->num_blow[0]++;
5085                 }
5086
5087                 if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
5088                         p_ptr->num_blow[0] /= 2;
5089                 else
5090                 {
5091                         p_ptr->to_h[0] += (p_ptr->lev / 3);
5092                         p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
5093
5094                         p_ptr->to_d[0] += (p_ptr->lev / 6);
5095                         p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
5096                 }
5097
5098                 if (p_ptr->special_defense & KAMAE_BYAKKO)
5099                 {
5100                         p_ptr->to_a -= 40;
5101                         p_ptr->dis_to_a -= 40;
5102                         
5103                 }
5104                 else if (p_ptr->special_defense & KAMAE_SEIRYU)
5105                 {
5106                         p_ptr->to_a -= 50;
5107                         p_ptr->dis_to_a -= 50;
5108                         p_ptr->resist_acid = TRUE;
5109                         p_ptr->resist_fire = TRUE;
5110                         p_ptr->resist_elec = TRUE;
5111                         p_ptr->resist_cold = TRUE;
5112                         p_ptr->resist_pois = TRUE;
5113                         p_ptr->sh_fire = TRUE;
5114                         p_ptr->sh_elec = TRUE;
5115                         p_ptr->sh_cold = TRUE;
5116                         p_ptr->levitation = TRUE;
5117                 }
5118                 else if (p_ptr->special_defense & KAMAE_GENBU)
5119                 {
5120                         p_ptr->to_a += (p_ptr->lev*p_ptr->lev)/50;
5121                         p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev)/50;
5122                         p_ptr->reflect = TRUE;
5123                         p_ptr->num_blow[0] -= 2;
5124                         if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
5125                         if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
5126                 }
5127                 else if (p_ptr->special_defense & KAMAE_SUZAKU)
5128                 {
5129                         p_ptr->to_h[0] -= (p_ptr->lev / 3);
5130                         p_ptr->to_d[0] -= (p_ptr->lev / 6);
5131
5132                         p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
5133                         p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
5134                         p_ptr->num_blow[0] /= 2;
5135                         p_ptr->levitation = TRUE;
5136                 }
5137
5138                 p_ptr->num_blow[0] += 1+extra_blows[0];
5139         }
5140
5141         if (p_ptr->riding) p_ptr->levitation = riding_levitation;
5142
5143         monk_armour_aux = FALSE;
5144
5145         if (heavy_armor())
5146         {
5147                 monk_armour_aux = TRUE;
5148         }
5149
5150         for (i = 0; i < 2; i++)
5151         {
5152                 if (buki_motteruka(INVEN_RARM+i))
5153                 {
5154                         int tval = inventory[INVEN_RARM+i].tval - TV_WEAPON_BEGIN;
5155                         int sval = inventory[INVEN_RARM+i].sval;
5156
5157                         p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
5158                         p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
5159                         if ((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER))
5160                         {
5161                                 if (!s_info[p_ptr->pclass].w_max[tval][sval])
5162                                 {
5163                                         p_ptr->to_h[i] -= 40;
5164                                         p_ptr->dis_to_h[i] -= 40;
5165                                         p_ptr->icky_wield[i] = TRUE;
5166                                 }
5167                         }
5168                         else if (p_ptr->pclass == CLASS_NINJA)
5169                         {
5170                                 if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (inventory[INVEN_LARM-i].tval == TV_SHIELD))
5171                                 {
5172                                         p_ptr->to_h[i] -= 40;
5173                                         p_ptr->dis_to_h[i] -= 40;
5174                                         p_ptr->icky_wield[i] = TRUE;
5175                                         p_ptr->num_blow[i] /= 2;
5176                                         if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
5177                                 }
5178                         }
5179
5180                         if (inventory[INVEN_RARM + i].name1 == ART_IRON_BALL) p_ptr->align -= 1000;
5181                 }
5182         }
5183
5184         /* Maximum speed is (+99). (internally it's 110 + 99) */
5185         /* Temporary lightspeed forces to be maximum speed */
5186         if ((p_ptr->lightspeed && !p_ptr->riding) || (new_speed > 209))
5187         {
5188                 new_speed = 209;
5189         }
5190
5191         /* Minimum speed is (-99). (internally it's 110 - 99) */
5192         if (new_speed < 11) new_speed = 11;
5193
5194         /* Display the speed (if needed) */
5195         if (p_ptr->pspeed != (byte)new_speed)
5196         {
5197                 p_ptr->pspeed = (byte)new_speed;
5198                 p_ptr->redraw |= (PR_SPEED);
5199         }
5200
5201         if (yoiyami)
5202         {
5203                 if (p_ptr->to_a > (0 - p_ptr->ac))
5204                         p_ptr->to_a = 0 - p_ptr->ac;
5205                 if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
5206                         p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
5207         }
5208
5209         /* Redraw armor (if needed) */
5210         if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
5211         {
5212                 /* Redraw */
5213                 p_ptr->redraw |= (PR_ARMOR);
5214
5215                 /* Window stuff */
5216                 p_ptr->window |= (PW_PLAYER);
5217         }
5218
5219
5220         if (p_ptr->ryoute && !omoi)
5221         {
5222                 int bonus_to_h=0, bonus_to_d=0;
5223                 bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128)/2;
5224                 bonus_to_h = ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
5225
5226                 p_ptr->to_h[default_hand] += MAX(bonus_to_h,1);
5227                 p_ptr->dis_to_h[default_hand] += MAX(bonus_to_h,1);
5228                 p_ptr->to_d[default_hand] += MAX(bonus_to_d,1);
5229                 p_ptr->dis_to_d[default_hand] += MAX(bonus_to_d,1);
5230         }
5231
5232         if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) p_ptr->ryoute = FALSE;
5233
5234         /* Affect Skill -- stealth (bonus one) */
5235         p_ptr->skill_stl += 1;
5236
5237         if (IS_TIM_STEALTH()) p_ptr->skill_stl += 99;
5238
5239         /* Affect Skill -- disarming (DEX and INT) */
5240         p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
5241         p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
5242
5243         /* Affect Skill -- magic devices (INT) */
5244         p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
5245
5246         /* Affect Skill -- saving throw (WIS) */
5247         p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
5248
5249         /* Affect Skill -- digging (STR) */
5250         p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
5251
5252         /* Affect Skill -- disarming (Level, by Class) */
5253         p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
5254
5255         /* Affect Skill -- magic devices (Level, by Class) */
5256         p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
5257
5258         /* Affect Skill -- saving throw (Level, by Class) */
5259         p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
5260
5261         /* Affect Skill -- stealth (Level, by Class) */
5262         p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
5263
5264         /* Affect Skill -- search ability (Level, by Class) */
5265         p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
5266
5267         /* Affect Skill -- search frequency (Level, by Class) */
5268         p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
5269
5270         /* Affect Skill -- combat (normal) (Level, by Class) */
5271         p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
5272
5273         /* Affect Skill -- combat (shooting) (Level, by Class) */
5274         p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
5275
5276         /* Affect Skill -- combat (throwing) (Level, by Class) */
5277         p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
5278
5279
5280         if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && (p_ptr->cursed & TRC_AGGRAVATE))
5281         {
5282                 p_ptr->cursed &= ~(TRC_AGGRAVATE);
5283                 p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
5284         }
5285
5286         /* Limit Skill -- stealth from 0 to 30 */
5287         if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
5288         if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
5289
5290         /* Limit Skill -- digging from 1 up */
5291         if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
5292
5293         if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
5294
5295         if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
5296
5297         if ((p_ptr->ult_res || p_ptr->resist_magic || p_ptr->magicdef) && (p_ptr->skill_sav < (95 + p_ptr->lev))) p_ptr->skill_sav = 95 + p_ptr->lev;
5298
5299         if (down_saving) p_ptr->skill_sav /= 2;
5300
5301         /* Hack -- Each elemental immunity includes resistance */
5302         if (p_ptr->immune_acid) p_ptr->resist_acid = TRUE;
5303         if (p_ptr->immune_elec) p_ptr->resist_elec = TRUE;
5304         if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
5305         if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
5306
5307         /* Determine player alignment */
5308         for (i = 0, j = 0; i < 8; i++)
5309         {
5310                 switch (p_ptr->vir_types[i])
5311                 {
5312                 case V_JUSTICE:
5313                         p_ptr->align += p_ptr->virtues[i] * 2;
5314                         break;
5315                 case V_CHANCE:
5316                         /* Do nothing */
5317                         break;
5318                 case V_NATURE:
5319                 case V_HARMONY:
5320                         neutral[j++] = i;
5321                         break;
5322                 case V_UNLIFE:
5323                         p_ptr->align -= p_ptr->virtues[i];
5324                         break;
5325                 default:
5326                         p_ptr->align += p_ptr->virtues[i];
5327                         break;
5328                 }
5329         }
5330
5331         for (i = 0; i < j; i++)
5332         {
5333                 if (p_ptr->align > 0)
5334                 {
5335                         p_ptr->align -= p_ptr->virtues[neutral[i]] / 2;
5336                         if (p_ptr->align < 0) p_ptr->align = 0;
5337                 }
5338                 else if (p_ptr->align < 0)
5339                 {
5340                         p_ptr->align += p_ptr->virtues[neutral[i]] / 2;
5341                         if (p_ptr->align > 0) p_ptr->align = 0;
5342                 }
5343         }
5344
5345         /* Hack -- handle "xtra" mode */
5346         if (character_xtra) return;
5347
5348         /* Take note when "heavy bow" changes */
5349         if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
5350         {
5351                 /* Message */
5352                 if (p_ptr->heavy_shoot)
5353                 {
5354 #ifdef JP
5355                         msg_print("¤³¤ó¤Ê½Å¤¤µÝ¤òÁõÈ÷¤·¤Æ¤¤¤ë¤Î¤ÏÂçÊѤÀ¡£");
5356 #else
5357                         msg_print("You have trouble wielding such a heavy bow.");
5358 #endif
5359
5360                 }
5361                 else if (inventory[INVEN_BOW].k_idx)
5362                 {
5363 #ifdef JP
5364                         msg_print("¤³¤ÎµÝ¤Ê¤éÁõÈ÷¤·¤Æ¤¤¤Æ¤â¿É¤¯¤Ê¤¤¡£");
5365 #else
5366                         msg_print("You have no trouble wielding your bow.");
5367 #endif
5368
5369                 }
5370                 else
5371                 {
5372 #ifdef JP
5373                         msg_print("½Å¤¤µÝ¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤ÆÂΤ¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5374 #else
5375                         msg_print("You feel relieved to put down your heavy bow.");
5376 #endif
5377
5378                 }
5379
5380                 /* Save it */
5381                 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
5382         }
5383
5384         for (i = 0 ; i < 2 ; i++)
5385         {
5386                 /* Take note when "heavy weapon" changes */
5387                 if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
5388                 {
5389                         /* Message */
5390                         if (p_ptr->heavy_wield[i])
5391                         {
5392 #ifdef JP
5393                                 msg_print("¤³¤ó¤Ê½Å¤¤Éð´ï¤òÁõÈ÷¤·¤Æ¤¤¤ë¤Î¤ÏÂçÊѤÀ¡£");
5394 #else
5395                                 msg_print("You have trouble wielding such a heavy weapon.");
5396 #endif
5397
5398                         }
5399                         else if (buki_motteruka(INVEN_RARM+i))
5400                         {
5401 #ifdef JP
5402                                 msg_print("¤³¤ì¤Ê¤éÁõÈ÷¤·¤Æ¤¤¤Æ¤â¿É¤¯¤Ê¤¤¡£");
5403 #else
5404                                 msg_print("You have no trouble wielding your weapon.");
5405 #endif
5406
5407                         }
5408                         else if (p_ptr->heavy_wield[1-i])
5409                         {
5410 #ifdef JP
5411                                 msg_print("¤Þ¤ÀÉð´ï¤¬½Å¤¤¡£");
5412 #else
5413                                 msg_print("You have still trouble wielding a heavy weapon.");
5414 #endif
5415
5416                         }
5417                         else
5418                         {
5419 #ifdef JP
5420                                 msg_print("½Å¤¤Éð´ï¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤ÆÂΤ¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5421 #else
5422                                 msg_print("You feel relieved to put down your heavy weapon.");
5423 #endif
5424
5425                         }
5426
5427                         /* Save it */
5428                         p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
5429                 }
5430
5431                 /* Take note when "heavy weapon" changes */
5432                 if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
5433                 {
5434                         /* Message */
5435                         if (p_ptr->riding_wield[i])
5436                         {
5437 #ifdef JP
5438                                 msg_print("¤³¤ÎÉð´ï¤Ï¾èÇÏÃæ¤Ë»È¤¦¤Ë¤Ï¤à¤«¤Ê¤¤¤è¤¦¤À¡£");
5439 #else
5440                                 msg_print("This weapon is not suitable for use while riding.");
5441 #endif
5442
5443                         }
5444                         else if (!p_ptr->riding)
5445                         {
5446 #ifdef JP
5447                                 msg_print("¤³¤ÎÉð´ï¤ÏÅÌÊâ¤Ç»È¤¤¤ä¤¹¤¤¡£");
5448 #else
5449                                 msg_print("This weapon was not suitable for use while riding.");
5450 #endif
5451
5452                         }
5453                         else if (buki_motteruka(INVEN_RARM+i))
5454                         {
5455 #ifdef JP
5456                                 msg_print("¤³¤ì¤Ê¤é¾èÇÏÃæ¤Ë¤Ô¤Ã¤¿¤ê¤À¡£");
5457 #else
5458                                 msg_print("This weapon is suitable for use while riding.");
5459 #endif
5460
5461                         }
5462                         /* Save it */
5463                         p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
5464                 }
5465
5466                 /* Take note when "illegal weapon" changes */
5467                 if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
5468                 {
5469                         /* Message */
5470                         if (p_ptr->icky_wield[i])
5471                         {
5472 #ifdef JP
5473                                 msg_print("º£¤ÎÁõÈ÷¤Ï¤É¤¦¤â¼«Ê¬¤Ë¤Õ¤µ¤ï¤·¤¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
5474 #else
5475                                 msg_print("You do not feel comfortable with your weapon.");
5476 #endif
5477                                 if (hack_mind)
5478                                 {
5479                                         chg_virtue(V_FAITH, -1);
5480                                 }
5481                         }
5482                         else if (buki_motteruka(INVEN_RARM+i))
5483                         {
5484 #ifdef JP
5485                                 msg_print("º£¤ÎÁõÈ÷¤Ï¼«Ê¬¤Ë¤Õ¤µ¤ï¤·¤¤µ¤¤¬¤¹¤ë¡£");
5486 #else
5487                                 msg_print("You feel comfortable with your weapon.");
5488 #endif
5489
5490                         }
5491                         else
5492                         {
5493 #ifdef JP
5494                                 msg_print("ÁõÈ÷¤ò¤Ï¤º¤·¤¿¤é¿ïʬ¤Èµ¤¤¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5495 #else
5496                                 msg_print("You feel more comfortable after removing your weapon.");
5497 #endif
5498
5499                         }
5500
5501                         /* Save it */
5502                         p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
5503                 }
5504         }
5505
5506         if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
5507         {
5508                 /* Message */
5509                 if (p_ptr->riding_ryoute)
5510                 {
5511 #ifdef JP
5512                         msg_format("%sÇϤòÁà¤ì¤Ê¤¤¡£", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "ξ¼ê¤¬¤Õ¤µ¤¬¤Ã¤Æ¤¤¤Æ" : "");
5513 #else
5514                         msg_print("You are using both hand for fighting, and you can't control a riding pet.");
5515 #endif
5516                 }
5517                 else
5518                 {
5519 #ifdef JP
5520                         msg_format("%sÇϤòÁà¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "¼ê¤¬¶õ¤¤¤Æ" : "");
5521 #else
5522                         msg_print("You began to control riding pet with one hand.");
5523 #endif
5524                 }
5525
5526                 p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
5527         }
5528
5529         if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (monk_armour_aux != monk_notify_aux))
5530         {
5531                 if (heavy_armor())
5532                 {
5533 #ifdef JP
5534 msg_print("ÁõÈ÷¤¬½Å¤¯¤Æ¥Ð¥é¥ó¥¹¤ò¼è¤ì¤Ê¤¤¡£");
5535 #else
5536                         msg_print("The weight of your armor disrupts your balance.");
5537 #endif
5538
5539                         if (hack_mind)
5540                         {
5541                                 chg_virtue(V_HARMONY, -1);
5542                         }
5543                 }
5544                 else
5545 #ifdef JP
5546 msg_print("¥Ð¥é¥ó¥¹¤¬¤È¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
5547 #else
5548                         msg_print("You regain your balance.");
5549 #endif
5550
5551                 monk_notify_aux = monk_armour_aux;
5552         }
5553
5554         for (i = 0; i < INVEN_PACK; i++)
5555         {
5556 #if 0
5557                 if ((inventory[i].tval == TV_SORCERY_BOOK) && (inventory[i].sval == 2)) have_dd_s = TRUE;
5558                 if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
5559 #endif
5560                 if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
5561                 if ((inventory[i].tval == TV_CRAFT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
5562         }
5563         for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
5564         {
5565                 object_type *o_ptr;
5566
5567                 /* Acquire object */
5568                 o_ptr = &o_list[this_o_idx];
5569
5570                 /* Acquire next object */
5571                 next_o_idx = o_ptr->next_o_idx;
5572
5573 #if 0
5574                 if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
5575                 if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
5576 #endif
5577                 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
5578                 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
5579         }
5580
5581         if (p_ptr->pass_wall && !p_ptr->kill_wall) p_ptr->no_flowed = TRUE;
5582 #if 0
5583         if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
5584         {
5585                 magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S];
5586                 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5587         }
5588
5589         if (have_dd_t && ((p_ptr->realm1 == REALM_TRUMP) || (p_ptr->realm2 == REALM_TRUMP) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)))
5590         {
5591                 magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T];
5592                 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5593         }
5594 #endif
5595         if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
5596         {
5597                 magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW];
5598                 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5599         }
5600
5601         if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER)))
5602         {
5603                 magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT-1][SPELL_KABE];
5604                 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5605         }
5606 }
5607
5608
5609
5610 /*
5611  * Handle "p_ptr->notice"
5612  */
5613 void notice_stuff(void)
5614 {
5615         /* Notice stuff */
5616         if (!p_ptr->notice) return;
5617
5618
5619         /* Actually do auto-destroy */
5620         if (p_ptr->notice & (PN_AUTODESTROY))
5621         {
5622                 p_ptr->notice &= ~(PN_AUTODESTROY);
5623                 autopick_delayed_alter();
5624         }
5625
5626         /* Combine the pack */
5627         if (p_ptr->notice & (PN_COMBINE))
5628         {
5629                 p_ptr->notice &= ~(PN_COMBINE);
5630                 combine_pack();
5631         }
5632
5633         /* Reorder the pack */
5634         if (p_ptr->notice & (PN_REORDER))
5635         {
5636                 p_ptr->notice &= ~(PN_REORDER);
5637                 reorder_pack();
5638         }
5639 }
5640
5641
5642 /*
5643  * Handle "p_ptr->update"
5644  */
5645 void update_stuff(void)
5646 {
5647         /* Update stuff */
5648         if (!p_ptr->update) return;
5649
5650
5651         if (p_ptr->update & (PU_BONUS))
5652         {
5653                 p_ptr->update &= ~(PU_BONUS);
5654                 calc_bonuses();
5655         }
5656
5657         if (p_ptr->update & (PU_TORCH))
5658         {
5659                 p_ptr->update &= ~(PU_TORCH);
5660                 calc_torch();
5661         }
5662
5663         if (p_ptr->update & (PU_HP))
5664         {
5665                 p_ptr->update &= ~(PU_HP);
5666                 calc_hitpoints();
5667         }
5668
5669         if (p_ptr->update & (PU_MANA))
5670         {
5671                 p_ptr->update &= ~(PU_MANA);
5672                 calc_mana();
5673         }
5674
5675         if (p_ptr->update & (PU_SPELLS))
5676         {
5677                 p_ptr->update &= ~(PU_SPELLS);
5678                 calc_spells();
5679         }
5680
5681
5682         /* Character is not ready yet, no screen updates */
5683         if (!character_generated) return;
5684
5685
5686         /* Character is in "icky" mode, no screen updates */
5687         if (character_icky) return;
5688
5689
5690         if (p_ptr->update & (PU_UN_LITE))
5691         {
5692                 p_ptr->update &= ~(PU_UN_LITE);
5693                 forget_lite();
5694         }
5695
5696         if (p_ptr->update & (PU_UN_VIEW))
5697         {
5698                 p_ptr->update &= ~(PU_UN_VIEW);
5699                 forget_view();
5700         }
5701
5702         if (p_ptr->update & (PU_VIEW))
5703         {
5704                 p_ptr->update &= ~(PU_VIEW);
5705                 update_view();
5706         }
5707
5708         if (p_ptr->update & (PU_LITE))
5709         {
5710                 p_ptr->update &= ~(PU_LITE);
5711                 update_lite();
5712         }
5713
5714
5715         if (p_ptr->update & (PU_FLOW))
5716         {
5717                 p_ptr->update &= ~(PU_FLOW);
5718                 update_flow();
5719         }
5720
5721         if (p_ptr->update & (PU_DISTANCE))
5722         {
5723                 p_ptr->update &= ~(PU_DISTANCE);
5724
5725                 /* Still need to call update_monsters(FALSE) after update_mon_lite() */ 
5726                 /* p_ptr->update &= ~(PU_MONSTERS); */
5727
5728                 update_monsters(TRUE);
5729         }
5730
5731         if (p_ptr->update & (PU_MON_LITE))
5732         {
5733                 p_ptr->update &= ~(PU_MON_LITE);
5734                 update_mon_lite();
5735         }
5736
5737         /*
5738          * Mega-Hack -- Delayed visual update
5739          * Only used if update_view(), update_lite() or update_mon_lite() was called
5740          */
5741         if (p_ptr->update & (PU_DELAY_VIS))
5742         {
5743                 p_ptr->update &= ~(PU_DELAY_VIS);
5744                 delayed_visual_update();
5745         }
5746
5747         if (p_ptr->update & (PU_MONSTERS))
5748         {
5749                 p_ptr->update &= ~(PU_MONSTERS);
5750                 update_monsters(FALSE);
5751         }
5752 }
5753
5754
5755 /*
5756  * Handle "p_ptr->redraw"
5757  */
5758 void redraw_stuff(void)
5759 {
5760         /* Redraw stuff */
5761         if (!p_ptr->redraw) return;
5762
5763
5764         /* Character is not ready yet, no screen updates */
5765         if (!character_generated) return;
5766
5767
5768         /* Character is in "icky" mode, no screen updates */
5769         if (character_icky) return;
5770
5771
5772
5773         /* Hack -- clear the screen */
5774         if (p_ptr->redraw & (PR_WIPE))
5775         {
5776                 p_ptr->redraw &= ~(PR_WIPE);
5777                 msg_print(NULL);
5778                 Term_clear();
5779         }
5780
5781
5782         if (p_ptr->redraw & (PR_MAP))
5783         {
5784                 p_ptr->redraw &= ~(PR_MAP);
5785                 prt_map();
5786         }
5787
5788
5789         if (p_ptr->redraw & (PR_BASIC))
5790         {
5791                 p_ptr->redraw &= ~(PR_BASIC);
5792                 p_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
5793                 p_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
5794                 p_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
5795                 p_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
5796                 prt_frame_basic();
5797                 prt_time();
5798                 prt_dungeon();
5799         }
5800
5801         if (p_ptr->redraw & (PR_EQUIPPY))
5802         {
5803                 p_ptr->redraw &= ~(PR_EQUIPPY);
5804                 print_equippy(); /* To draw / delete equippy chars */
5805         }
5806
5807         if (p_ptr->redraw & (PR_MISC))
5808         {
5809                 p_ptr->redraw &= ~(PR_MISC);
5810                 prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
5811 /*              prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
5812
5813         }
5814
5815         if (p_ptr->redraw & (PR_TITLE))
5816         {
5817                 p_ptr->redraw &= ~(PR_TITLE);
5818                 prt_title();
5819         }
5820
5821         if (p_ptr->redraw & (PR_LEV))
5822         {
5823                 p_ptr->redraw &= ~(PR_LEV);
5824                 prt_level();
5825         }
5826
5827         if (p_ptr->redraw & (PR_EXP))
5828         {
5829                 p_ptr->redraw &= ~(PR_EXP);
5830                 prt_exp();
5831         }
5832
5833         if (p_ptr->redraw & (PR_STATS))
5834         {
5835                 p_ptr->redraw &= ~(PR_STATS);
5836                 prt_stat(A_STR);
5837                 prt_stat(A_INT);
5838                 prt_stat(A_WIS);
5839                 prt_stat(A_DEX);
5840                 prt_stat(A_CON);
5841                 prt_stat(A_CHR);
5842         }
5843
5844         if (p_ptr->redraw & (PR_STATUS))
5845         {
5846                 p_ptr->redraw &= ~(PR_STATUS);
5847                 prt_status();
5848         }
5849
5850         if (p_ptr->redraw & (PR_ARMOR))
5851         {
5852                 p_ptr->redraw &= ~(PR_ARMOR);
5853                 prt_ac();
5854         }
5855
5856         if (p_ptr->redraw & (PR_HP))
5857         {
5858                 p_ptr->redraw &= ~(PR_HP);
5859                 prt_hp();
5860         }
5861
5862         if (p_ptr->redraw & (PR_MANA))
5863         {
5864                 p_ptr->redraw &= ~(PR_MANA);
5865                 prt_sp();
5866         }
5867
5868         if (p_ptr->redraw & (PR_GOLD))
5869         {
5870                 p_ptr->redraw &= ~(PR_GOLD);
5871                 prt_gold();
5872         }
5873
5874         if (p_ptr->redraw & (PR_DEPTH))
5875         {
5876                 p_ptr->redraw &= ~(PR_DEPTH);
5877                 prt_depth();
5878         }
5879
5880         if (p_ptr->redraw & (PR_HEALTH))
5881         {
5882                 p_ptr->redraw &= ~(PR_HEALTH);
5883                 health_redraw(FALSE);
5884         }
5885
5886         if (p_ptr->redraw & (PR_UHEALTH))
5887         {
5888                 p_ptr->redraw &= ~(PR_UHEALTH);
5889                 health_redraw(TRUE);
5890         }
5891
5892
5893         if (p_ptr->redraw & (PR_EXTRA))
5894         {
5895                 p_ptr->redraw &= ~(PR_EXTRA);
5896                 p_ptr->redraw &= ~(PR_CUT | PR_STUN);
5897                 p_ptr->redraw &= ~(PR_HUNGER);
5898                 p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
5899                 prt_frame_extra();
5900         }
5901
5902         if (p_ptr->redraw & (PR_CUT))
5903         {
5904                 p_ptr->redraw &= ~(PR_CUT);
5905                 prt_cut();
5906         }
5907
5908         if (p_ptr->redraw & (PR_STUN))
5909         {
5910                 p_ptr->redraw &= ~(PR_STUN);
5911                 prt_stun();
5912         }
5913
5914         if (p_ptr->redraw & (PR_HUNGER))
5915         {
5916                 p_ptr->redraw &= ~(PR_HUNGER);
5917                 prt_hunger();
5918         }
5919
5920         if (p_ptr->redraw & (PR_STATE))
5921         {
5922                 p_ptr->redraw &= ~(PR_STATE);
5923                 prt_state();
5924         }
5925
5926         if (p_ptr->redraw & (PR_SPEED))
5927         {
5928                 p_ptr->redraw &= ~(PR_SPEED);
5929                 prt_speed();
5930         }
5931
5932         if (p_ptr->pclass == CLASS_IMITATOR)
5933         {
5934                 if (p_ptr->redraw & (PR_IMITATION))
5935                 {
5936                         p_ptr->redraw &= ~(PR_IMITATION);
5937                         prt_imitation();
5938                 }
5939         }
5940         else if (p_ptr->redraw & (PR_STUDY))
5941         {
5942                 p_ptr->redraw &= ~(PR_STUDY);
5943                 prt_study();
5944         }
5945 }
5946
5947
5948 /*
5949  * Handle "p_ptr->window"
5950  */
5951 void window_stuff(void)
5952 {
5953         int j;
5954
5955         u32b mask = 0L;
5956
5957
5958         /* Nothing to do */
5959         if (!p_ptr->window) return;
5960
5961         /* Scan windows */
5962         for (j = 0; j < 8; j++)
5963         {
5964                 /* Save usable flags */
5965                 if (angband_term[j]) mask |= window_flag[j];
5966         }
5967
5968         /* Apply usable flags */
5969         p_ptr->window &= mask;
5970
5971         /* Nothing to do */
5972         if (!p_ptr->window) return;
5973
5974
5975         /* Display inventory */
5976         if (p_ptr->window & (PW_INVEN))
5977         {
5978                 p_ptr->window &= ~(PW_INVEN);
5979                 fix_inven();
5980         }
5981
5982         /* Display equipment */
5983         if (p_ptr->window & (PW_EQUIP))
5984         {
5985                 p_ptr->window &= ~(PW_EQUIP);
5986                 fix_equip();
5987         }
5988
5989         /* Display spell list */
5990         if (p_ptr->window & (PW_SPELL))
5991         {
5992                 p_ptr->window &= ~(PW_SPELL);
5993                 fix_spell();
5994         }
5995
5996         /* Display player */
5997         if (p_ptr->window & (PW_PLAYER))
5998         {
5999                 p_ptr->window &= ~(PW_PLAYER);
6000                 fix_player();
6001         }
6002
6003         /* Display overhead view */
6004         if (p_ptr->window & (PW_MESSAGE))
6005         {
6006                 p_ptr->window &= ~(PW_MESSAGE);
6007                 fix_message();
6008         }
6009
6010         /* Display overhead view */
6011         if (p_ptr->window & (PW_OVERHEAD))
6012         {
6013                 p_ptr->window &= ~(PW_OVERHEAD);
6014                 fix_overhead();
6015         }
6016
6017         /* Display overhead view */
6018         if (p_ptr->window & (PW_DUNGEON))
6019         {
6020                 p_ptr->window &= ~(PW_DUNGEON);
6021                 fix_dungeon();
6022         }
6023
6024         /* Display monster recall */
6025         if (p_ptr->window & (PW_MONSTER))
6026         {
6027                 p_ptr->window &= ~(PW_MONSTER);
6028                 fix_monster();
6029         }
6030
6031         /* Display object recall */
6032         if (p_ptr->window & (PW_OBJECT))
6033         {
6034                 p_ptr->window &= ~(PW_OBJECT);
6035                 fix_object();
6036         }
6037 }
6038
6039
6040 /*
6041  * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
6042  */
6043 void handle_stuff(void)
6044 {
6045         /* Update stuff */
6046         if (p_ptr->update) update_stuff();
6047
6048         /* Redraw stuff */
6049         if (p_ptr->redraw) redraw_stuff();
6050
6051         /* Window stuff */
6052         if (p_ptr->window) window_stuff();
6053 }
6054
6055
6056 s16b empty_hands(bool riding_control)
6057 {
6058         s16b status = EMPTY_HAND_NONE;
6059
6060         if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
6061         if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
6062
6063         if (riding_control && (status != EMPTY_HAND_NONE) && p_ptr->riding && !(p_ptr->pet_extra_flags & PF_RYOUTE))
6064         {
6065                 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
6066                 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
6067         }
6068
6069         return status;
6070 }
6071
6072
6073 bool heavy_armor(void)
6074 {
6075         u16b monk_arm_wgt = 0;
6076
6077         if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
6078
6079         /* Weight the armor */
6080         if(inventory[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_RARM].weight;
6081         if(inventory[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_LARM].weight;
6082         monk_arm_wgt += inventory[INVEN_BODY].weight;
6083         monk_arm_wgt += inventory[INVEN_HEAD].weight;
6084         monk_arm_wgt += inventory[INVEN_OUTER].weight;
6085         monk_arm_wgt += inventory[INVEN_HANDS].weight;
6086         monk_arm_wgt += inventory[INVEN_FEET].weight;
6087
6088         return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
6089 }