OSDN Git Service

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