4 /* Purpose: misc code */
7 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
9 * This software may be copied and distributed for educational, research, and
10 * not for profit purposes provided that this copyright and statement are
11 * included in all such copies.
20 * Converts stat num into a six-char (right justified) string
22 void cnv_stat(int val, char *out_val)
27 int bonus = (val - 18);
31 sprintf(out_val, "18/%3s", "***");
33 else if (bonus >= 100)
35 sprintf(out_val, "18/%03d", bonus);
39 sprintf(out_val, " 18/%02d", bonus);
46 sprintf(out_val, " %2d", val);
53 * Modify a stat value by a "modifier", return new value
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
58 * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
59 * Or even: 18/13, 18/03, 18, 17, ..., 3
61 s16b modify_stat_value(int value, int amount)
68 /* Apply each point */
69 for (i = 0; i < amount; i++)
71 /* One point at a time */
72 if (value < 18) value++;
74 /* Ten "points" at a time */
82 /* Apply each point */
83 for (i = 0; i < (0 - amount); i++)
85 /* Ten points at a time */
86 if (value >= 18+10) value -= 10;
88 /* Hack -- prevent weirdness */
89 else if (value > 18) value = 18;
91 /* One point at a time */
92 else if (value > 3) value--;
96 /* Return new value */
103 * Print character info at given row, column in a 13 char field
105 static void prt_field(cptr info, int row, int col)
107 /* Dump 13 spaces to clear */
108 c_put_str(TERM_WHITE, " ", row, col);
110 /* Dump the info itself */
111 c_put_str(TERM_L_BLUE, info, row, col);
120 s32b len = 20L * TOWN_DAWN;
121 s32b tick = turn % len + len / 4;
123 /* Dump 13 spaces to clear */
124 c_put_str(TERM_WHITE, " ", ROW_DAY, COL_DAY);
126 /* Dump the info itself */
128 c_put_str(TERM_WHITE, format("%2dÆüÌÜ",
130 c_put_str(TERM_WHITE, format("Day %-2d",
132 ((p_ptr->prace == RACE_VAMPIRE) ||
133 (p_ptr->prace == RACE_SKELETON) ||
134 (p_ptr->prace == RACE_ZOMBIE) ||
135 (p_ptr->prace == RACE_SPECTRE))
136 ? (turn - (15L * TOWN_DAWN)) / len + 1
137 : (turn + (5L * TOWN_DAWN))/ len + 1),
140 c_put_str(TERM_WHITE, format("%2d:%02d",
141 (24 * tick / len) % 24,
142 (1440 * tick / len) % 60),
152 static void prt_dungeon(void)
154 cptr dungeon_name = d_name+d_info[dungeon_type].name;
157 /* Dump 13 spaces to clear */
158 c_put_str(TERM_WHITE, " ", ROW_DUNGEON, COL_DUNGEON);
160 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST) && (quest[p_ptr->inside_quest].flags & QUEST_FLAG_PRESET))
163 dungeon_name = "¥¯¥¨¥¹¥È";
165 dungeon_name = "Quest";
167 else if (p_ptr->wild_mode)
169 dungeon_name = "ÃϾå";
171 dungeon_name = "Surface";
173 else if (p_ptr->inside_arena)
175 dungeon_name = "¥¢¥ê¡¼¥Ê";
177 dungeon_name = "Monster Arena";
179 else if (p_ptr->inside_battle)
181 dungeon_name = "Æ®µ»¾ì";
183 dungeon_name = "Arena";
185 else if (!dun_level && p_ptr->town_num)
186 dungeon_name = town[p_ptr->town_num].name;
187 col = COL_DUNGEON + 6 - strlen(dungeon_name)/2;
188 if (col < 0) col = 0;
190 /* Dump the info itself */
191 c_put_str(TERM_L_UMBER, format("%s",dungeon_name),
199 * Print character stat in given row, column
201 static void prt_stat(int stat)
205 /* Display "injured" stat */
206 if (p_ptr->stat_cur[stat] < p_ptr->stat_max[stat])
208 put_str(stat_names_reduced[stat], ROW_STAT + stat, 0);
209 cnv_stat(p_ptr->stat_use[stat], tmp);
210 c_put_str(TERM_YELLOW, tmp, ROW_STAT + stat, COL_STAT + 6);
213 /* Display "healthy" stat */
216 put_str(stat_names[stat], ROW_STAT + stat, 0);
217 cnv_stat(p_ptr->stat_use[stat], tmp);
218 c_put_str(TERM_L_GREEN, tmp, ROW_STAT + stat, COL_STAT + 6);
221 /* Indicate natural maximum */
222 if (p_ptr->stat_max[stat] == p_ptr->stat_max_max[stat])
225 /* ÆüËܸì¤Ë¤«¤Ö¤é¤Ê¤¤¤è¤¦¤Ëɽ¼¨°ÌÃÖ¤òÊѹ¹ */
226 put_str("!", ROW_STAT + stat, 5);
228 put_str("!", ROW_STAT + stat, 3);
235 /* Show status bar */
237 static void prt_status(void)
243 c_put_str(TERM_YELLOW, "¤Ä", ROW_STATBAR, COL_STATBAR);
245 c_put_str(TERM_YELLOW, "Ts", ROW_STATBAR, COL_STATBAR);
250 else if (p_ptr->image)
253 c_put_str(TERM_VIOLET, "¸¸", ROW_STATBAR, COL_STATBAR);
255 c_put_str(TERM_VIOLET, "Hu", ROW_STATBAR, COL_STATBAR);
260 put_str(" ", ROW_STATBAR, COL_STATBAR);
267 c_put_str(TERM_L_DARK, "ÌÕ", ROW_STATBAR, COL_STATBAR+2);
269 c_put_str(TERM_L_DARK, "Bl", ROW_STATBAR, COL_STATBAR+2);
274 put_str(" ", ROW_STATBAR, COL_STATBAR+2);
278 if (p_ptr->paralyzed)
281 c_put_str(TERM_RED, "áã", ROW_STATBAR, COL_STATBAR+4);
283 c_put_str(TERM_RED, "Pa", ROW_STATBAR, COL_STATBAR+4);
288 put_str(" ", ROW_STATBAR, COL_STATBAR+4);
295 c_put_str(TERM_VIOLET, "Íð", ROW_STATBAR, COL_STATBAR+6);
297 c_put_str(TERM_VIOLET, "Cf", ROW_STATBAR, COL_STATBAR+6);
302 put_str(" ", ROW_STATBAR, COL_STATBAR+6);
309 c_put_str(TERM_GREEN, "ÆÇ", ROW_STATBAR, COL_STATBAR+8);
311 c_put_str(TERM_GREEN, "Po", ROW_STATBAR, COL_STATBAR+8);
316 put_str(" ", ROW_STATBAR, COL_STATBAR+8);
319 /* Times see-invisible */
320 if (p_ptr->tim_invis)
323 c_put_str(TERM_L_BLUE, "ȑ", ROW_STATBAR, COL_STATBAR+10);
325 c_put_str(TERM_L_BLUE, "Se", ROW_STATBAR, COL_STATBAR+10);
330 put_str(" ", ROW_STATBAR, COL_STATBAR+10);
334 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
337 c_put_str(TERM_ORANGE, "¥Æ", ROW_STATBAR, COL_STATBAR+12);
339 c_put_str(TERM_ORANGE, "Te", ROW_STATBAR, COL_STATBAR+12);
344 put_str(" ", ROW_STATBAR, COL_STATBAR+12);
347 /* Timed regenerate */
348 if (p_ptr->tim_regen)
351 c_put_str(TERM_L_BLUE, "²ó", ROW_STATBAR, COL_STATBAR+14);
353 c_put_str(TERM_L_BLUE, "Rg", ROW_STATBAR, COL_STATBAR+14);
358 put_str(" ", ROW_STATBAR, COL_STATBAR+14);
361 /* Timed infra-vision */
362 if (p_ptr->tim_infra)
365 c_put_str(TERM_L_RED, "ÀÖ", ROW_STATBAR, COL_STATBAR+16);
367 c_put_str(TERM_L_RED, "If", ROW_STATBAR, COL_STATBAR+16);
372 put_str(" ", ROW_STATBAR, COL_STATBAR+16);
375 /* Protection from evil */
379 c_put_str(TERM_SLATE, "¼Ù", ROW_STATBAR, COL_STATBAR+18);
381 c_put_str(TERM_SLATE, "Ev", ROW_STATBAR, COL_STATBAR+18);
386 put_str(" ", ROW_STATBAR, COL_STATBAR+18);
389 /* Invulnerability */
390 if (p_ptr->invuln || music_singing(MUSIC_INVULN))
393 c_put_str(TERM_YELLOW, "̵", ROW_STATBAR, COL_STATBAR+20);
395 c_put_str(TERM_YELLOW, "Iv", ROW_STATBAR, COL_STATBAR+20);
400 put_str(" ", ROW_STATBAR, COL_STATBAR+20);
404 if (p_ptr->wraith_form)
407 c_put_str(TERM_L_DARK, "ͩ", ROW_STATBAR, COL_STATBAR+22);
409 c_put_str(TERM_L_DARK, "Gh", ROW_STATBAR, COL_STATBAR+22);
413 else if (p_ptr->kabenuke)
416 c_put_str(TERM_SLATE, "ÊÉ", ROW_STATBAR, COL_STATBAR+22);
418 c_put_str(TERM_SLATE, "Wp", ROW_STATBAR, COL_STATBAR+22);
421 else if (p_ptr->tim_reflect)
424 c_put_str(TERM_SLATE, "ȿ", ROW_STATBAR, COL_STATBAR+22);
426 c_put_str(TERM_SLATE, "Rf", ROW_STATBAR, COL_STATBAR+22);
431 put_str(" ", ROW_STATBAR, COL_STATBAR+22);
435 if (p_ptr->hero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
438 c_put_str(TERM_WHITE, "ͦ", ROW_STATBAR, COL_STATBAR+24);
440 c_put_str(TERM_WHITE, "He", ROW_STATBAR, COL_STATBAR+24);
445 put_str(" ", ROW_STATBAR, COL_STATBAR+24);
448 /* Super Heroism / berserk */
452 c_put_str(TERM_RED, "¶¸", ROW_STATBAR, COL_STATBAR+26);
454 c_put_str(TERM_RED, "Br", ROW_STATBAR, COL_STATBAR+26);
459 put_str(" ", ROW_STATBAR, COL_STATBAR+26);
463 if (p_ptr->blessed || music_singing(MUSIC_BLESS))
466 c_put_str(TERM_WHITE, "½Ë", ROW_STATBAR, COL_STATBAR+28);
468 c_put_str(TERM_WHITE, "Bs", ROW_STATBAR, COL_STATBAR+28);
473 put_str(" ", ROW_STATBAR, COL_STATBAR+28);
480 c_put_str(TERM_YELLOW, "Ëâ", ROW_STATBAR, COL_STATBAR+30);
482 c_put_str(TERM_YELLOW, "Md", ROW_STATBAR, COL_STATBAR+30);
485 else if (p_ptr->tsubureru)
488 c_put_str(TERM_L_UMBER, "¿", ROW_STATBAR, COL_STATBAR+30);
490 c_put_str(TERM_L_UMBER, "Eh", ROW_STATBAR, COL_STATBAR+30);
493 else if (p_ptr->shield)
496 c_put_str(TERM_WHITE, "ÀÐ", ROW_STATBAR, COL_STATBAR+30);
498 c_put_str(TERM_WHITE, "Ss", ROW_STATBAR, COL_STATBAR+30);
501 else if (p_ptr->special_defense & NINJA_KAWARIMI)
504 c_put_str(TERM_VIOLET, "ÊÑ", ROW_STATBAR, COL_STATBAR+30);
506 c_put_str(TERM_VIOLET, "Qa", ROW_STATBAR, COL_STATBAR+30);
511 put_str(" ", ROW_STATBAR, COL_STATBAR+30);
515 if (p_ptr->special_defense & DEFENSE_ACID)
518 c_put_str(TERM_L_GREEN, "»À", ROW_STATBAR, COL_STATBAR+32);
520 c_put_str(TERM_L_GREEN, "Ac", ROW_STATBAR, COL_STATBAR+32);
523 else if (p_ptr->oppose_acid || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
526 c_put_str(TERM_GREEN, "»À", ROW_STATBAR, COL_STATBAR+32);
528 c_put_str(TERM_GREEN, "Ac", ROW_STATBAR, COL_STATBAR+32);
533 put_str(" ", ROW_STATBAR, COL_STATBAR+32);
536 /* Oppose Lightning */
537 if (p_ptr->special_defense & DEFENSE_ELEC)
540 c_put_str(TERM_L_BLUE, "ÅÅ", ROW_STATBAR, COL_STATBAR+34);
542 c_put_str(TERM_L_BLUE, "El", ROW_STATBAR, COL_STATBAR+34);
545 else if (p_ptr->oppose_elec || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
548 c_put_str(TERM_BLUE, "ÅÅ", ROW_STATBAR, COL_STATBAR+34);
550 c_put_str(TERM_BLUE, "El", ROW_STATBAR, COL_STATBAR+34);
555 put_str(" ", ROW_STATBAR, COL_STATBAR+34);
559 if (p_ptr->special_defense & DEFENSE_FIRE)
562 c_put_str(TERM_L_RED, "²Ð", ROW_STATBAR, COL_STATBAR+36);
564 c_put_str(TERM_L_RED, "Fi", ROW_STATBAR, COL_STATBAR+36);
567 else if (p_ptr->oppose_fire || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
570 c_put_str(TERM_RED, "²Ð", ROW_STATBAR, COL_STATBAR+36);
572 c_put_str(TERM_RED, "Fi", ROW_STATBAR, COL_STATBAR+36);
577 put_str(" ", ROW_STATBAR, COL_STATBAR+36);
581 if (p_ptr->special_defense & DEFENSE_COLD)
584 c_put_str(TERM_WHITE, "Îä", ROW_STATBAR, COL_STATBAR+38);
586 c_put_str(TERM_WHITE, "Co", ROW_STATBAR, COL_STATBAR+38);
589 else if (p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
592 c_put_str(TERM_SLATE, "Îä", ROW_STATBAR, COL_STATBAR+38);
594 c_put_str(TERM_SLATE, "Co", ROW_STATBAR, COL_STATBAR+38);
599 put_str(" ", ROW_STATBAR, COL_STATBAR+38);
603 if (p_ptr->oppose_pois || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
606 c_put_str(TERM_GREEN, "ÆÇ", ROW_STATBAR, COL_STATBAR+40);
608 c_put_str(TERM_GREEN, "Po", ROW_STATBAR, COL_STATBAR+40);
613 put_str(" ", ROW_STATBAR, COL_STATBAR+40);
617 if (p_ptr->word_recall)
620 c_put_str(TERM_WHITE, "µ¢", ROW_STATBAR, COL_STATBAR+42);
622 c_put_str(TERM_WHITE, "Wr", ROW_STATBAR, COL_STATBAR+42);
627 put_str(" ", ROW_STATBAR, COL_STATBAR+42);
634 c_put_str(TERM_BLUE, "¶²", ROW_STATBAR, COL_STATBAR+44);
636 c_put_str(TERM_BLUE, "Fe", ROW_STATBAR, COL_STATBAR+44);
641 put_str(" ", ROW_STATBAR, COL_STATBAR+44);
645 if (p_ptr->tim_res_time)
648 c_put_str(TERM_L_BLUE, "»þ", ROW_STATBAR, COL_STATBAR+46);
650 c_put_str(TERM_L_BLUE, "Ti", ROW_STATBAR, COL_STATBAR+46);
653 else if (p_ptr->multishadow)
656 c_put_str(TERM_L_BLUE, "ʬ", ROW_STATBAR, COL_STATBAR+46);
658 c_put_str(TERM_L_BLUE, "Ms", ROW_STATBAR, COL_STATBAR+46);
663 put_str(" ", ROW_STATBAR, COL_STATBAR+46);
666 /* Confusing Hands */
667 if (p_ptr->special_attack & ATTACK_CONFUSE)
670 c_put_str(TERM_RED, "Íð", ROW_STATBAR, COL_STATBAR+48);
672 c_put_str(TERM_RED, "Cf", ROW_STATBAR, COL_STATBAR+48);
677 put_str(" ", ROW_STATBAR, COL_STATBAR+48);
680 if (p_ptr->resist_magic)
683 c_put_str(TERM_SLATE, "ËÉ", ROW_STATBAR, COL_STATBAR+50);
685 c_put_str(TERM_SLATE, "Rm", ROW_STATBAR, COL_STATBAR+50);
690 put_str(" ", ROW_STATBAR, COL_STATBAR+50);
693 /* Ultimate-resistance */
697 c_put_str(TERM_YELLOW, "µæ", ROW_STATBAR, COL_STATBAR+52);
699 c_put_str(TERM_YELLOW, "Ul", ROW_STATBAR, COL_STATBAR+52);
703 else if (p_ptr->tim_ffall)
706 c_put_str(TERM_L_BLUE, "Éâ", ROW_STATBAR, COL_STATBAR+52);
708 c_put_str(TERM_L_BLUE, "Lv", ROW_STATBAR, COL_STATBAR+52);
711 else if (p_ptr->tim_res_nether)
714 c_put_str(TERM_L_DARK, "¹ö", ROW_STATBAR, COL_STATBAR+52);
716 c_put_str(TERM_L_DARK, "Nt", ROW_STATBAR, COL_STATBAR+52);
719 else if (p_ptr->dustrobe)
722 c_put_str(TERM_L_DARK, "¶À", ROW_STATBAR, COL_STATBAR+52);
724 c_put_str(TERM_L_DARK, "Am", ROW_STATBAR, COL_STATBAR+52);
729 put_str(" ", ROW_STATBAR, COL_STATBAR+52);
733 if (p_ptr->special_attack & ATTACK_FIRE)
736 c_put_str(TERM_L_RED, "²Ð", ROW_STATBAR, COL_STATBAR+54);
738 c_put_str(TERM_L_RED, "Fi", ROW_STATBAR, COL_STATBAR+54);
741 else if (p_ptr->special_attack & ATTACK_COLD)
744 c_put_str(TERM_WHITE, "Îä", ROW_STATBAR, COL_STATBAR+54);
746 c_put_str(TERM_WHITE, "Co", ROW_STATBAR, COL_STATBAR+54);
749 else if (p_ptr->special_attack & ATTACK_ELEC)
752 c_put_str(TERM_L_BLUE, "ÅÅ", ROW_STATBAR, COL_STATBAR+54);
754 c_put_str(TERM_L_BLUE, "El", ROW_STATBAR, COL_STATBAR+54);
757 else if (p_ptr->special_attack & ATTACK_ACID)
760 c_put_str(TERM_SLATE, "»À", ROW_STATBAR, COL_STATBAR+54);
762 c_put_str(TERM_SLATE, "Ac", ROW_STATBAR, COL_STATBAR+54);
765 else if (p_ptr->special_attack & ATTACK_POIS)
768 c_put_str(TERM_L_GREEN, "ÆÇ", ROW_STATBAR, COL_STATBAR+54);
770 c_put_str(TERM_L_GREEN, "Po", ROW_STATBAR, COL_STATBAR+54);
773 else if (p_ptr->special_defense & NINJA_S_STEALTH)
776 c_put_str(TERM_YELLOW, "Ķ", ROW_STATBAR, COL_STATBAR+54);
778 c_put_str(TERM_YELLOW, "St", ROW_STATBAR, COL_STATBAR+54);
783 put_str(" ", ROW_STATBAR, COL_STATBAR+54);
787 if (p_ptr->tim_sh_fire)
790 c_put_str(TERM_L_RED, "¥ª", ROW_STATBAR, COL_STATBAR+56);
792 c_put_str(TERM_L_RED, "Sf", ROW_STATBAR, COL_STATBAR+56);
795 else if (p_ptr->tim_stealth || music_singing(MUSIC_STEALTH))
798 c_put_str(TERM_UMBER, "±£", ROW_STATBAR, COL_STATBAR+56);
800 c_put_str(TERM_UMBER, "Sl", ROW_STATBAR, COL_STATBAR+56);
803 else if (p_ptr->special_defense & NINJA_S_STEALTH)
806 c_put_str(TERM_YELLOW, "±£", ROW_STATBAR, COL_STATBAR+56);
808 c_put_str(TERM_YELLOW, "lt", ROW_STATBAR, COL_STATBAR+56);
811 else if (p_ptr->tim_sh_touki)
814 c_put_str(TERM_WHITE, "Ʈ", ROW_STATBAR, COL_STATBAR+56);
816 c_put_str(TERM_WHITE, "Ae", ROW_STATBAR, COL_STATBAR+56);
821 put_str(" ", ROW_STATBAR, COL_STATBAR+56);
828 * Prints "title", including "wizard" or "winner" as needed.
830 static void prt_title(void)
838 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
847 else if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
849 if ((p_ptr->arena_number > MAX_ARENA_MONS+2) && (p_ptr->arena_number < 99))
852 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
862 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
874 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
879 prt_field(p, ROW_TITLE, COL_TITLE);
886 static void prt_level(void)
891 sprintf(tmp, "%5d", p_ptr->lev);
893 sprintf(tmp, "%6d", p_ptr->lev);
897 if (p_ptr->lev >= p_ptr->max_plv)
900 put_str("¥ì¥Ù¥ë ", ROW_LEVEL, 0);
901 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
903 put_str("LEVEL ", ROW_LEVEL, 0);
904 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 6);
911 put_str("x¥ì¥Ù¥ë", ROW_LEVEL, 0);
912 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
914 put_str("Level ", ROW_LEVEL, 0);
915 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 6);
923 * Display the experience
925 static void prt_exp(void)
929 if ((p_ptr->prace == RACE_ANDROID) && !cheat_xtra)
930 (void)strcpy(out_val, "*******");
933 (void)sprintf(out_val, "%7ld", (long)p_ptr->exp);
935 (void)sprintf(out_val, "%8ld", (long)p_ptr->exp);
939 if (p_ptr->exp >= p_ptr->max_exp)
942 put_str("·Ð¸³ ", ROW_EXP, 0);
943 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 5);
945 put_str("EXP ", ROW_EXP, 0);
946 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
953 put_str("x·Ð¸³", ROW_EXP, 0);
954 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 5);
956 put_str("Exp ", ROW_EXP, 0);
957 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
965 * Prints current gold
967 static void prt_gold(void)
972 put_str("¡ð ", ROW_GOLD, COL_GOLD);
974 put_str("AU ", ROW_GOLD, COL_GOLD);
977 sprintf(tmp, "%9ld", (long)p_ptr->au);
978 c_put_str(TERM_L_GREEN, tmp, ROW_GOLD, COL_GOLD + 3);
986 static void prt_ac(void)
991 /* AC ¤Îɽ¼¨Êý¼°¤òÊѹ¹¤·¤Æ¤¤¤ë */
992 put_str(" £Á£Ã( )", ROW_AC, COL_AC);
993 sprintf(tmp, "%5d", p_ptr->dis_ac + p_ptr->dis_to_a);
994 c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 6);
996 put_str("Cur AC ", ROW_AC, COL_AC);
997 sprintf(tmp, "%5d", p_ptr->dis_ac + p_ptr->dis_to_a);
998 c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 7);
1005 * Prints Cur/Max hit points
1007 static void prt_hp(void)
1009 /* ¥Ò¥Ã¥È¥Ý¥¤¥ó¥È¤Îɽ¼¨ÊýË¡¤òÊѹ¹ */
1015 /* put_str(" £È£Ð¡¦£Í£Ð", ROW_HPMP, COL_HPMP); */
1017 put_str("HP", ROW_CURHP, COL_CURHP);
1019 /* ¸½ºß¤Î¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
1020 sprintf(tmp, "%4d", p_ptr->chp);
1022 if (p_ptr->chp >= p_ptr->mhp)
1024 color = TERM_L_GREEN;
1026 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1028 color = TERM_YELLOW;
1035 c_put_str(color, tmp, ROW_CURHP, COL_CURHP+3);
1038 put_str( "/", ROW_CURHP, COL_CURHP + 7 );
1040 /* ºÇÂç¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
1041 sprintf(tmp, "%4d", p_ptr->mhp);
1042 color = TERM_L_GREEN;
1044 c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8 );
1049 * Prints players max/cur spell points
1051 static void prt_sp(void)
1053 /* ¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È¤Îɽ¼¨ÊýË¡¤òÊѹ¹¤·¤Æ¤¤¤ë */
1058 /* Do not show mana unless it matters */
1059 if (!mp_ptr->spell_book) return;
1062 /* put_str(" £Í£Ð / ºÇÂç", ROW_MAXSP, COL_MAXSP); */
1065 put_str("MP", ROW_CURSP, COL_CURSP);
1067 put_str("SP", ROW_CURSP, COL_CURSP);
1070 /* ¸½ºß¤Î¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
1071 sprintf(tmp, "%4d", p_ptr->csp);
1073 if (p_ptr->csp >= p_ptr->msp)
1075 color = TERM_L_GREEN;
1077 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1079 color = TERM_YELLOW;
1086 c_put_str(color, tmp, ROW_CURSP, COL_CURSP+3);
1089 put_str( "/", ROW_CURSP, COL_CURSP + 7 );
1091 /* ºÇÂç¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
1092 sprintf(tmp, "%4d", p_ptr->msp);
1093 color = TERM_L_GREEN;
1095 c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
1100 * Prints depth in stat area
1102 static void prt_depth(void)
1109 strcpy(depths, "ÃϾå");
1111 strcpy(depths, "Surf.");
1114 else if (p_ptr->inside_quest && !dungeon_type)
1117 strcpy(depths, "ÃϾå");
1119 strcpy(depths, "Quest");
1123 else if (depth_in_feet)
1126 (void)sprintf(depths, "%d ft", dun_level * 50);
1128 (void)sprintf(depths, "%d ft", dun_level * 50);
1135 sprintf(depths, "%d ³¬", dun_level);
1137 (void)sprintf(depths, "Lev %d", dun_level);
1142 /* Right-Adjust the "depth", and clear old values */
1143 prt(format("%7s", depths), ROW_DEPTH, COL_DEPTH);
1148 * Prints status of hunger
1150 static void prt_hunger(void)
1152 /* Fainting / Starving */
1153 if (p_ptr->food < PY_FOOD_FAINT)
1156 c_put_str(TERM_RED, "¿ê¼å ", ROW_HUNGRY, COL_HUNGRY);
1158 c_put_str(TERM_RED, "Weak ", ROW_HUNGRY, COL_HUNGRY);
1164 else if (p_ptr->food < PY_FOOD_WEAK)
1167 c_put_str(TERM_ORANGE, "¿ê¼å ", ROW_HUNGRY, COL_HUNGRY);
1169 c_put_str(TERM_ORANGE, "Weak ", ROW_HUNGRY, COL_HUNGRY);
1175 else if (p_ptr->food < PY_FOOD_ALERT)
1178 c_put_str(TERM_YELLOW, "¶õÊ¢ ", ROW_HUNGRY, COL_HUNGRY);
1180 c_put_str(TERM_YELLOW, "Hungry", ROW_HUNGRY, COL_HUNGRY);
1186 else if (p_ptr->food < PY_FOOD_FULL)
1188 c_put_str(TERM_L_GREEN, " ", ROW_HUNGRY, COL_HUNGRY);
1192 else if (p_ptr->food < PY_FOOD_MAX)
1195 c_put_str(TERM_L_GREEN, "ËþÊ¢ ", ROW_HUNGRY, COL_HUNGRY);
1197 c_put_str(TERM_L_GREEN, "Full ", ROW_HUNGRY, COL_HUNGRY);
1206 c_put_str(TERM_GREEN, "¿©²á¤®", ROW_HUNGRY, COL_HUNGRY);
1208 c_put_str(TERM_GREEN, "Gorged", ROW_HUNGRY, COL_HUNGRY);
1216 * Prints Searching, Resting, Paralysis, or 'count' status
1217 * Display is always exactly 10 characters wide (see below)
1219 * This function was a major bottleneck when resting, so a lot of
1220 * the text formatting code was optimized in place below.
1222 static void prt_state(void)
1224 byte attr = TERM_WHITE;
1231 if (command_rep > 999)
1234 sprintf(text, "%2d00", command_rep / 100);
1236 (void)sprintf(text, "%2d00", command_rep / 100);
1243 sprintf(text, " %2d", command_rep);
1245 (void)sprintf(text, " %2d", command_rep);
1254 switch(p_ptr->action)
1259 strcpy(text, "õº÷");
1261 strcpy(text, "Sear");
1269 /* Start with "Rest" */
1277 /* Extensive (timed) rest */
1278 if (resting >= 1000)
1283 text[1] = '0' + (i % 10);
1284 text[0] = '0' + (i / 10);
1287 /* Long (timed) rest */
1288 else if (resting >= 100)
1291 text[3] = '0' + (i % 10);
1293 text[2] = '0' + (i % 10);
1294 text[1] = '0' + (i / 10);
1297 /* Medium (timed) rest */
1298 else if (resting >= 10)
1301 text[3] = '0' + (i % 10);
1302 text[2] = '0' + (i / 10);
1305 /* Short (timed) rest */
1306 else if (resting > 0)
1309 text[3] = '0' + (i);
1312 /* Rest until healed */
1313 else if (resting == -1)
1315 text[0] = text[1] = text[2] = text[3] = '*';
1318 /* Rest until done */
1319 else if (resting == -2)
1321 text[0] = text[1] = text[2] = text[3] = '&';
1328 strcpy(text, "³Ø½¬");
1330 strcpy(text, "lear");
1332 if (new_mane) attr = TERM_L_RED;
1338 strcpy(text, "Äà¤ê");
1340 strcpy(text, "fish");
1347 for (i = 0; i < MAX_KAMAE; i++)
1348 if (p_ptr->special_defense & (KAMAE_GENBU << i)) break;
1351 case 0: attr = TERM_GREEN;break;
1352 case 1: attr = TERM_WHITE;break;
1353 case 2: attr = TERM_L_BLUE;break;
1354 case 3: attr = TERM_L_RED;break;
1356 strcpy(text, kamae_shurui[i].desc);
1362 for (i = 0; i < MAX_KATA; i++)
1363 if (p_ptr->special_defense & (KATA_IAI << i)) break;
1364 strcpy(text, kata_shurui[i].desc);
1370 strcpy(text, "²Î ");
1372 strcpy(text, "Sing");
1376 case ACTION_HAYAGAKE:
1379 strcpy(text, "®¶î");
1381 strcpy(text, "Fast");
1393 /* Display the info (or blanks) */
1394 c_put_str(attr, format("%5.5s",text), ROW_STATE, COL_STATE);
1399 * Prints the speed of a character. -CJS-
1401 static void prt_speed(void)
1403 int i = p_ptr->pspeed;
1404 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1406 byte attr = TERM_WHITE;
1409 /* Hack -- Visually "undo" the Search Mode Slowdown */
1410 if (p_ptr->action == ACTION_SEARCH) i += 10;
1417 if (m_list[p_ptr->riding].fast && !m_list[p_ptr->riding].slow) attr = TERM_L_BLUE;
1418 else if (m_list[p_ptr->riding].slow && !m_list[p_ptr->riding].fast) attr = TERM_VIOLET;
1419 else attr = TERM_GREEN;
1421 else if ((is_fast && !p_ptr->slow) || p_ptr->lightspeed) attr = TERM_YELLOW;
1422 else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
1423 else attr = TERM_L_GREEN;
1425 sprintf(buf, "%s(+%d)", (p_ptr->riding ? "¾èÇÏ" : "²Ã®"), (i - 110));
1427 sprintf(buf, "Fast(+%d)", (i - 110));
1437 if (m_list[p_ptr->riding].fast && !m_list[p_ptr->riding].slow) attr = TERM_L_BLUE;
1438 else if (m_list[p_ptr->riding].slow && !m_list[p_ptr->riding].fast) attr = TERM_VIOLET;
1439 else attr = TERM_RED;
1441 else if (is_fast && !p_ptr->slow) attr = TERM_YELLOW;
1442 else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
1443 else attr = TERM_L_UMBER;
1445 sprintf(buf, "%s(-%d)", (p_ptr->riding ? "¾èÇÏ" : "¸ºÂ®"), (110 - i));
1447 sprintf(buf, "Slow(-%d)", (110 - i));
1450 else if (p_ptr->riding)
1454 strcpy(buf, "¾èÇÏÃæ");
1456 strcpy(buf, "Riding");
1460 /* Display the speed */
1461 c_put_str(attr, format("%-9s", buf), ROW_SPEED, COL_SPEED);
1465 static void prt_study(void)
1467 if (p_ptr->new_spells)
1470 put_str("³Ø½¬", ROW_STUDY, COL_STUDY);
1472 put_str("Stud", ROW_STUDY, COL_STUDY);
1478 put_str(" ", ROW_STUDY, COL_STUDY);
1483 static void prt_mane(void)
1485 if (p_ptr->pclass == CLASS_IMITATOR)
1490 if (new_mane) attr = TERM_L_RED;
1491 else attr = TERM_WHITE;
1493 c_put_str(attr, "¤Þ¤Í", ROW_STUDY, COL_STUDY);
1495 c_put_str(attr, "Mane", ROW_STUDY, COL_STUDY);
1500 put_str(" ", ROW_STUDY, COL_STUDY);
1506 static void prt_cut(void)
1513 c_put_str(TERM_L_RED, "Ã×Ì¿½ý ", ROW_CUT, COL_CUT);
1515 c_put_str(TERM_L_RED, "Mortal wound", ROW_CUT, COL_CUT);
1522 c_put_str(TERM_RED, "¤Ò¤É¤¤¿¼¼ê ", ROW_CUT, COL_CUT);
1524 c_put_str(TERM_RED, "Deep gash ", ROW_CUT, COL_CUT);
1531 c_put_str(TERM_RED, "½Å½ý ", ROW_CUT, COL_CUT);
1533 c_put_str(TERM_RED, "Severe cut ", ROW_CUT, COL_CUT);
1540 c_put_str(TERM_ORANGE, "ÂçÊѤʽý ", ROW_CUT, COL_CUT);
1542 c_put_str(TERM_ORANGE, "Nasty cut ", ROW_CUT, COL_CUT);
1549 c_put_str(TERM_ORANGE, "¤Ò¤É¤¤½ý ", ROW_CUT, COL_CUT);
1551 c_put_str(TERM_ORANGE, "Bad cut ", ROW_CUT, COL_CUT);
1558 c_put_str(TERM_YELLOW, "·Ú½ý ", ROW_CUT, COL_CUT);
1560 c_put_str(TERM_YELLOW, "Light cut ", ROW_CUT, COL_CUT);
1567 c_put_str(TERM_YELLOW, "¤«¤¹¤ê½ý ", ROW_CUT, COL_CUT);
1569 c_put_str(TERM_YELLOW, "Graze ", ROW_CUT, COL_CUT);
1575 put_str(" ", ROW_CUT, COL_CUT);
1581 static void prt_stun(void)
1583 int s = p_ptr->stun;
1588 c_put_str(TERM_RED, "°Õ¼±ÉÔÌÀÎÆ ", ROW_STUN, COL_STUN);
1590 c_put_str(TERM_RED, "Knocked out ", ROW_STUN, COL_STUN);
1597 c_put_str(TERM_ORANGE, "¤Ò¤É¤¯Û¯Û° ", ROW_STUN, COL_STUN);
1599 c_put_str(TERM_ORANGE, "Heavy stun ", ROW_STUN, COL_STUN);
1606 c_put_str(TERM_ORANGE, "ۯ۰ ", ROW_STUN, COL_STUN);
1608 c_put_str(TERM_ORANGE, "Stun ", ROW_STUN, COL_STUN);
1614 put_str(" ", ROW_STUN, COL_STUN);
1621 * Redraw the "monster health bar" -DRS-
1622 * Rather extensive modifications by -BEN-
1624 * The "monster health bar" provides visual feedback on the "health"
1625 * of the monster currently being "tracked". There are several ways
1626 * to "track" a monster, including targetting it, attacking it, and
1627 * affecting it (and nobody else) with a ranged attack.
1629 * Display the monster health bar (affectionately known as the
1630 * "health-o-meter"). Clear health bar if nothing is being tracked.
1631 * Auto-track current target monster when bored. Note that the
1632 * health-bar stops tracking any monster that "disappears".
1634 static void health_redraw(void)
1637 #ifdef DRS_SHOW_HEALTH_BAR
1640 if (!p_ptr->health_who)
1642 /* Erase the health bar */
1643 Term_erase(COL_INFO, ROW_INFO, 12);
1646 /* Tracking an unseen monster */
1647 else if (!m_list[p_ptr->health_who].ml)
1649 /* Indicate that the monster health is "unknown" */
1650 Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
1653 /* Tracking a hallucinatory monster */
1654 else if (p_ptr->image)
1656 /* Indicate that the monster health is "unknown" */
1657 Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
1660 /* Tracking a dead monster (???) */
1661 else if (!m_list[p_ptr->health_who].hp < 0)
1663 /* Indicate that the monster health is "unknown" */
1664 Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
1667 /* Tracking a visible monster */
1672 monster_type *m_ptr = &m_list[p_ptr->health_who];
1674 /* Default to almost dead */
1675 byte attr = TERM_RED;
1677 /* Extract the "percent" of health */
1678 pct = 100L * m_ptr->hp / m_ptr->maxhp;
1679 pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
1682 if (pct >= 10) attr = TERM_L_RED;
1685 if (pct >= 25) attr = TERM_ORANGE;
1687 /* Somewhat Wounded */
1688 if (pct >= 60) attr = TERM_YELLOW;
1691 if (pct >= 100) attr = TERM_L_GREEN;
1694 if (m_ptr->monfear) attr = TERM_VIOLET;
1697 if (m_ptr->csleep) attr = TERM_BLUE;
1700 if (m_ptr->invulner) attr = TERM_WHITE;
1702 /* Convert percent into "health" */
1703 len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
1705 /* Default to "unknown" */
1706 Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
1708 /* Dump the current "health" (use '*' symbols) */
1709 Term_putstr(COL_INFO + 1, ROW_INFO, len, attr, "**********");
1718 static void riding_health_redraw(void)
1721 #ifdef DRS_SHOW_HEALTH_BAR
1726 /* Erase the health bar */
1727 Term_erase(COL_RIDING_INFO, ROW_RIDING_INFO, 12);
1730 /* Tracking a hallucinatory monster */
1731 else if (p_ptr->image)
1733 /* Indicate that the monster health is "unknown" */
1734 Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
1737 /* Tracking a dead monster (???) */
1738 else if (!m_list[p_ptr->health_who].hp < 0)
1740 /* Indicate that the monster health is "unknown" */
1741 Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
1744 /* Tracking a visible monster */
1749 monster_type *m_ptr = &m_list[p_ptr->riding];
1751 /* Default to almost dead */
1752 byte attr = TERM_RED;
1754 /* Extract the "percent" of health */
1755 pct = 100L * m_ptr->hp / m_ptr->maxhp;
1756 pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
1759 if (pct >= 10) attr = TERM_L_RED;
1762 if (pct >= 25) attr = TERM_ORANGE;
1764 /* Somewhat Wounded */
1765 if (pct >= 60) attr = TERM_YELLOW;
1768 if (pct >= 100) attr = TERM_L_GREEN;
1771 if (m_ptr->monfear) attr = TERM_VIOLET;
1774 if (m_ptr->csleep) attr = TERM_BLUE;
1777 if (m_ptr->invulner) attr = TERM_WHITE;
1779 /* Convert percent into "health" */
1780 len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
1782 /* Default to "unknown" */
1783 Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
1785 /* Dump the current "health" (use '*' symbols) */
1786 Term_putstr(COL_RIDING_INFO + 1, ROW_RIDING_INFO, len, attr, "**********");
1796 * Display basic info (mostly left of map)
1798 static void prt_frame_basic(void)
1802 /* Race and Class */
1803 if (p_ptr->mimic_form)
1804 prt_field(mimic_info[p_ptr->mimic_form].title, ROW_RACE, COL_RACE);
1806 prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
1807 /* prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
1808 /* prt_field(ap_ptr->title, ROW_SEIKAKU, COL_SEIKAKU); */
1814 /* Level/Experience */
1819 for (i = 0; i < 6; i++) prt_stat(i);
1838 riding_health_redraw();
1843 * Display extra info (mostly below map)
1845 static void prt_frame_extra(void)
1870 * Hack -- display inventory in sub-windows
1872 static void fix_inven(void)
1877 for (j = 0; j < 8; j++)
1882 if (!angband_term[j]) continue;
1884 /* No relevant flags */
1885 if (!(window_flag[j] & (PW_INVEN))) continue;
1888 Term_activate(angband_term[j]);
1890 /* Display inventory */
1904 * Hack -- display equipment in sub-windows
1906 static void fix_equip(void)
1911 for (j = 0; j < 8; j++)
1916 if (!angband_term[j]) continue;
1918 /* No relevant flags */
1919 if (!(window_flag[j] & (PW_EQUIP))) continue;
1922 Term_activate(angband_term[j]);
1924 /* Display equipment */
1937 * Hack -- display equipment in sub-windows
1939 static void fix_spell(void)
1944 for (j = 0; j < 8; j++)
1949 if (!angband_term[j]) continue;
1951 /* No relevant flags */
1952 if (!(window_flag[j] & (PW_SPELL))) continue;
1955 Term_activate(angband_term[j]);
1957 /* Display spell list */
1958 display_spell_list();
1970 * Hack -- display character in sub-windows
1972 static void fix_player(void)
1977 for (j = 0; j < 8; j++)
1982 if (!angband_term[j]) continue;
1984 /* No relevant flags */
1985 if (!(window_flag[j] & (PW_PLAYER))) continue;
1988 Term_activate(angband_term[j]);
1992 /* Display player */
2006 * Hack -- display recent messages in sub-windows
2008 * XXX XXX XXX Adjust for width and split messages
2010 static void fix_message(void)
2017 for (j = 0; j < 8; j++)
2022 if (!angband_term[j]) continue;
2024 /* No relevant flags */
2025 if (!(window_flag[j] & (PW_MESSAGE))) continue;
2028 Term_activate(angband_term[j]);
2031 Term_get_size(&w, &h);
2034 for (i = 0; i < h; i++)
2036 /* Dump the message on the appropriate line */
2037 Term_putstr(0, (h - 1) - i, -1, (i < now_message) ? TERM_WHITE : TERM_SLATE, message_str((s16b)i));
2040 Term_locate(&x, &y);
2042 /* Clear to end of line */
2043 Term_erase(x, y, 255);
2056 * Hack -- display overhead view in sub-windows
2058 * Note that the "player" symbol does NOT appear on the map.
2060 static void fix_overhead(void)
2067 for (j = 0; j < 8; j++)
2072 if (!angband_term[j]) continue;
2074 /* No relevant flags */
2075 if (!(window_flag[j] & (PW_OVERHEAD))) continue;
2078 Term_activate(angband_term[j]);
2081 display_map(&cy, &cx);
2093 * Hack -- display dungeon view in sub-windows
2095 static void fix_dungeon(void)
2100 for (j = 0; j < 8; j++)
2105 if (!angband_term[j]) continue;
2107 /* No relevant flags */
2108 if (!(window_flag[j] & (PW_DUNGEON))) continue;
2111 Term_activate(angband_term[j]);
2113 /* Redraw dungeon view */
2126 * Hack -- display monster recall in sub-windows
2128 static void fix_monster(void)
2133 for (j = 0; j < 8; j++)
2138 if (!angband_term[j]) continue;
2140 /* No relevant flags */
2141 if (!(window_flag[j] & (PW_MONSTER))) continue;
2144 Term_activate(angband_term[j]);
2146 /* Display monster race info */
2147 if (p_ptr->monster_race_idx) display_roff(p_ptr->monster_race_idx);
2159 * Hack -- display object recall in sub-windows
2161 static void fix_object(void)
2166 for (j = 0; j < 8; j++)
2171 if (!angband_term[j]) continue;
2173 /* No relevant flags */
2174 if (!(window_flag[j] & (PW_OBJECT))) continue;
2177 Term_activate(angband_term[j]);
2179 /* Display monster race info */
2180 if (p_ptr->object_kind_idx) display_koff(p_ptr->object_kind_idx);
2192 * Calculate number of spells player should have, and forget,
2193 * or remember, spells until that number is properly reflected.
2195 * Note that this function induces various "status" messages,
2196 * which must be bypasses until the character is created.
2198 static void calc_spells(void)
2200 int i, j, k, levels;
2202 int num_boukyaku = 0;
2205 int use_realm1 = p_ptr->realm1 - 1;
2206 int use_realm2 = p_ptr->realm2 - 1;
2213 /* Hack -- must be literate */
2214 if (!mp_ptr->spell_book) return;
2216 /* Hack -- wait for creation */
2217 if (!character_generated) return;
2219 /* Hack -- handle "xtra" mode */
2220 if (character_xtra) return;
2222 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
2224 p_ptr->new_spells = 0;
2228 p = spell_categoly_name(mp_ptr->spell_book);
2230 /* Determine the number of spells allowed */
2231 levels = p_ptr->lev - mp_ptr->spell_first + 1;
2233 /* Hack -- no negative spells */
2234 if (levels < 0) levels = 0;
2236 /* Extract total allowed spells */
2237 num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
2239 if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
2243 if (p_ptr->pclass == CLASS_SAMURAI)
2247 else if (p_ptr->realm2 == REALM_NONE)
2249 num_allowed = (num_allowed+1)/2;
2250 if (num_allowed>(32+bonus)) num_allowed = 32+bonus;
2252 else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
2254 if (num_allowed>(96+bonus)) num_allowed = 96+bonus;
2258 if (num_allowed>(80+bonus)) num_allowed = 80+bonus;
2261 /* Count the number of spells we know */
2262 for (j = 0; j < 64; j++)
2264 /* Count known spells */
2266 (spell_forgotten1 & (1L << j)) :
2267 (spell_forgotten2 & (1L << (j - 32))))
2273 /* See how many spells we must forget or may learn */
2274 p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
2276 /* Forget spells which are too hard */
2277 for (i = 63; i >= 0; i--)
2279 /* Efficiency -- all done */
2280 if (!spell_learned1 && !spell_learned2) break;
2282 /* Access the spell */
2285 /* Skip non-spells */
2286 if (j >= 99) continue;
2290 if (!is_magic(((j < 32) ? use_realm1 : use_realm2)+1))
2293 s_ptr = &technic_info[use_realm1 - MIN_TECHNIC][j];
2295 s_ptr = &technic_info[use_realm2 - MIN_TECHNIC][j%32];
2298 s_ptr = &mp_ptr->info[use_realm1][j];
2300 s_ptr = &mp_ptr->info[use_realm2][j%32];
2302 /* Skip spells we are allowed to know */
2303 if (s_ptr->slevel <= p_ptr->lev) continue;
2307 (spell_learned1 & (1L << j)) :
2308 (spell_learned2 & (1L << (j - 32))))
2310 /* Mark as forgotten */
2313 spell_forgotten1 |= (1L << j);
2318 spell_forgotten2 |= (1L << (j - 32));
2322 /* No longer known */
2325 spell_learned1 &= ~(1L << j);
2330 spell_learned2 &= ~(1L << (j - 32));
2336 msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
2337 spell_names[technic2magic(which+1)-1][j%32], p );
2339 msg_format("You have forgotten the %s of %s.", p,
2340 spell_names[technic2magic(which+1)-1][j%32]);
2344 /* One more can be learned */
2345 p_ptr->new_spells++;
2350 /* Forget spells if we know too many spells */
2351 for (i = 63; i >= 0; i--)
2353 /* Stop when possible */
2354 if (p_ptr->new_spells >= 0) break;
2356 /* Efficiency -- all done */
2357 if (!spell_learned1 && !spell_learned2) break;
2359 /* Get the (i+1)th spell learned */
2362 /* Skip unknown spells */
2363 if (j >= 99) continue;
2365 /* Forget it (if learned) */
2367 (spell_learned1 & (1L << j)) :
2368 (spell_learned2 & (1L << (j - 32))))
2370 /* Mark as forgotten */
2373 spell_forgotten1 |= (1L << j);
2378 spell_forgotten2 |= (1L << (j - 32));
2382 /* No longer known */
2385 spell_learned1 &= ~(1L << j);
2390 spell_learned2 &= ~(1L << (j - 32));
2396 msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
2397 spell_names[technic2magic(which+1)-1][j%32], p );
2399 msg_format("You have forgotten the %s of %s.", p,
2400 spell_names[technic2magic(which+1)-1][j%32]);
2404 /* One more can be learned */
2405 p_ptr->new_spells++;
2410 /* Check for spells to remember */
2411 for (i = 0; i < 64; i++)
2413 /* None left to remember */
2414 if (p_ptr->new_spells <= 0) break;
2416 /* Efficiency -- all done */
2417 if (!spell_forgotten1 && !spell_forgotten2) break;
2419 /* Get the next spell we learned */
2422 /* Skip unknown spells */
2425 /* Access the spell */
2426 if (!is_magic(((j < 32) ? use_realm1 : use_realm2)+1))
2429 s_ptr = &technic_info[use_realm1 - MIN_TECHNIC][j];
2431 s_ptr = &technic_info[use_realm2 - MIN_TECHNIC][j%32];
2434 s_ptr = &mp_ptr->info[use_realm1][j];
2436 s_ptr = &mp_ptr->info[use_realm2][j%32];
2438 /* Skip spells we cannot remember */
2439 if (s_ptr->slevel > p_ptr->lev) continue;
2441 /* First set of spells */
2443 (spell_forgotten1 & (1L << j)) :
2444 (spell_forgotten2 & (1L << (j - 32))))
2446 /* No longer forgotten */
2449 spell_forgotten1 &= ~(1L << j);
2454 spell_forgotten2 &= ~(1L << (j - 32));
2458 /* Known once more */
2461 spell_learned1 |= (1L << j);
2466 spell_learned2 |= (1L << (j - 32));
2472 msg_format("%s¤Î%s¤ò»×¤¤½Ð¤·¤¿¡£",
2473 spell_names[technic2magic(which+1)-1][j%32], p );
2475 msg_format("You have remembered the %s of %s.",
2476 p, spell_names[technic2magic(which+1)-1][j%32]);
2480 /* One less can be learned */
2481 p_ptr->new_spells--;
2487 if (p_ptr->realm2 == REALM_NONE)
2489 /* Count spells that can be learned */
2490 for (j = 0; j < 32; j++)
2492 if (!is_magic(use_realm1+1)) s_ptr = &technic_info[use_realm1-MIN_TECHNIC][j];
2493 else s_ptr = &mp_ptr->info[use_realm1][j];
2495 /* Skip spells we cannot remember */
2496 if (s_ptr->slevel > p_ptr->lev) continue;
2498 /* Skip spells we already know */
2499 if (spell_learned1 & (1L << j))
2508 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;
2511 if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
2513 /* Spell count changed */
2514 if (p_ptr->old_spells != p_ptr->new_spells)
2516 /* Message if needed */
2517 if (p_ptr->new_spells)
2521 if( p_ptr->new_spells < 10 ){
2522 msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
2524 msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
2527 msg_format("You can learn %d more %s%s.",
2528 p_ptr->new_spells, p,
2529 (p_ptr->new_spells != 1) ? "s" : "");
2534 /* Save the new_spells value */
2535 p_ptr->old_spells = p_ptr->new_spells;
2537 /* Redraw Study Status */
2538 p_ptr->redraw |= (PR_STUDY);
2544 * Calculate maximum mana. You do not need to know any spells.
2545 * Note that mana is lowered by heavy (or inappropriate) armor.
2547 * This function induces status messages.
2549 static void calc_mana(void)
2551 int msp, levels, cur_wgt, max_wgt;
2556 /* Hack -- Must be literate */
2557 if (!mp_ptr->spell_book) return;
2559 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2560 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2561 (p_ptr->pclass == CLASS_BLUE_MAGE))
2563 levels = p_ptr->lev;
2567 if(mp_ptr->spell_first > p_ptr->lev)
2572 /* Display mana later */
2573 p_ptr->redraw |= (PR_MANA);
2577 /* Extract "effective" player level */
2578 levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
2581 if (p_ptr->pclass == CLASS_SAMURAI)
2583 msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
2584 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
2588 /* Extract total mana */
2589 msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels+3) / 4;
2591 /* Hack -- usually add one mana */
2594 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
2596 if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp/2;
2598 /* Hack: High mages have a 25% mana bonus */
2599 if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
2601 if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp*(25+p_ptr->lev)/100;
2604 /* Only mages are affected */
2605 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
2609 /* Assume player is not encumbered by gloves */
2610 p_ptr->cumber_glove = FALSE;
2612 /* Get the gloves */
2613 o_ptr = &inventory[INVEN_HANDS];
2615 /* Examine the gloves */
2616 object_flags(o_ptr, &f1, &f2, &f3);
2618 /* Normal gloves hurt mage-type spells */
2620 !(f2 & (TR2_FREE_ACT)) &&
2621 !(f1 & (TR1_MAGIC_MASTERY)) &&
2622 !((f1 & (TR1_DEX)) && (o_ptr->pval > 0)))
2625 p_ptr->cumber_glove = TRUE;
2628 msp = (3 * msp) / 4;
2633 /* Assume player not encumbered by armor */
2634 p_ptr->cumber_armor = FALSE;
2636 /* Weigh the armor */
2638 if(inventory[INVEN_RARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
2639 if(inventory[INVEN_LARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
2640 cur_wgt += inventory[INVEN_BODY].weight;
2641 cur_wgt += inventory[INVEN_HEAD].weight;
2642 cur_wgt += inventory[INVEN_OUTER].weight;
2643 cur_wgt += inventory[INVEN_HANDS].weight;
2644 cur_wgt += inventory[INVEN_FEET].weight;
2646 /* Subtract a percentage of maximum mana. */
2647 switch (p_ptr->pclass)
2649 /* For these classes, mana is halved if armour
2650 * is 30 pounds over their weight limit. */
2652 case CLASS_HIGH_MAGE:
2653 case CLASS_BLUE_MAGE:
2655 case CLASS_FORCETRAINER:
2656 case CLASS_SORCERER:
2658 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
2659 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
2663 /* Mana halved if armour is 40 pounds over weight limit. */
2668 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight*2/3;
2669 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight*2/3;
2673 case CLASS_MINDCRAFTER:
2674 case CLASS_BEASTMASTER:
2675 case CLASS_MIRROR_MASTER:
2677 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/2;
2678 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/2;
2682 /* Mana halved if armour is 50 pounds over weight limit. */
2685 case CLASS_RED_MAGE:
2686 case CLASS_WARRIOR_MAGE:
2688 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/3;
2689 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/3;
2693 /* Mana halved if armour is 60 pounds over weight limit. */
2695 case CLASS_CHAOS_WARRIOR:
2697 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/5;
2698 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/5;
2702 /* For new classes created, but not yet added to this formula. */
2709 /* Determine the weight allowance */
2710 max_wgt = mp_ptr->spell_weight;
2712 /* Heavy armor penalizes mana by a percentage. -LM- */
2713 if ((cur_wgt - max_wgt) > 0)
2716 p_ptr->cumber_armor = TRUE;
2718 /* Subtract a percentage of maximum mana. */
2719 switch (p_ptr->pclass)
2721 /* For these classes, mana is halved if armour
2722 * is 30 pounds over their weight limit. */
2724 case CLASS_HIGH_MAGE:
2725 case CLASS_BLUE_MAGE:
2727 msp -= msp * (cur_wgt - max_wgt) / 600;
2731 /* Mana halved if armour is 40 pounds over weight limit. */
2733 case CLASS_MINDCRAFTER:
2734 case CLASS_BEASTMASTER:
2736 case CLASS_FORCETRAINER:
2738 case CLASS_MIRROR_MASTER:
2740 msp -= msp * (cur_wgt - max_wgt) / 800;
2744 case CLASS_SORCERER:
2746 msp -= msp * (cur_wgt - max_wgt) / 900;
2750 /* Mana halved if armour is 50 pounds over weight limit. */
2754 case CLASS_RED_MAGE:
2756 msp -= msp * (cur_wgt - max_wgt) / 1000;
2760 /* Mana halved if armour is 60 pounds over weight limit. */
2762 case CLASS_CHAOS_WARRIOR:
2763 case CLASS_WARRIOR_MAGE:
2765 msp -= msp * (cur_wgt - max_wgt) / 1200;
2771 p_ptr->cumber_armor = FALSE;
2775 /* For new classes created, but not yet added to this formula. */
2778 msp -= msp * (cur_wgt - max_wgt) / 800;
2784 /* Mana can never be negative */
2785 if (msp < 0) msp = 0;
2788 /* Maximum mana has changed */
2789 if (p_ptr->msp != msp)
2791 /* Enforce maximum */
2792 if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
2795 p_ptr->csp_frac = 0;
2799 /* ¥ì¥Ù¥ë¥¢¥Ã¥×¤Î»þ¤Ï¾å¾ºÎ̤òɽ¼¨¤¹¤ë */
2800 if ((level_up == 1) && (msp > p_ptr->msp))
2802 msg_format("ºÇÂç¥Þ¥¸¥Ã¥¯¡¦¥Ý¥¤¥ó¥È¤¬ %d Áý²Ã¤·¤¿¡ª",
2803 (msp - p_ptr->msp));
2809 /* Display mana later */
2810 p_ptr->redraw |= (PR_MANA);
2813 p_ptr->window |= (PW_PLAYER);
2814 p_ptr->window |= (PW_SPELL);
2818 /* Hack -- handle "xtra" mode */
2819 if (character_xtra) return;
2821 /* Take note when "glove state" changes */
2822 if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
2825 if (p_ptr->cumber_glove)
2828 msg_print("¼ê¤¬Ê¤¤ï¤ì¤Æ¼öʸ¤¬¾§¤¨¤Ë¤¯¤¤´¶¤¸¤¬¤¹¤ë¡£");
2830 msg_print("Your covered hands feel unsuitable for spellcasting.");
2837 msg_print("¤³¤Î¼ê¤Î¾õÂ֤ʤ顢¤°¤Ã¤È¼öʸ¤¬¾§¤¨¤ä¤¹¤¤´¶¤¸¤À¡£");
2839 msg_print("Your hands feel more suitable for spellcasting.");
2845 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
2849 /* Take note when "armor state" changes */
2850 if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
2853 if (p_ptr->cumber_armor)
2856 msg_print("ÁõÈ÷¤Î½Å¤µ¤ÇÆ°¤¤¬Æߤ¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
2858 msg_print("The weight of your equipment encumbers your movement.");
2865 msg_print("¤°¤Ã¤È³Ú¤ËÂΤòÆ°¤«¤»¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
2867 msg_print("You feel able to move more freely.");
2873 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
2880 * Calculate the players (maximal) hit points
2881 * Adjust current hitpoints if necessary
2883 static void calc_hitpoints(void)
2888 /* Un-inflate "half-hitpoint bonus per level" value */
2889 bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
2891 /* Calculate hitpoints */
2892 mhp = player_hp[p_ptr->lev - 1];
2894 if (p_ptr->mimic_form)
2896 if (p_ptr->pclass == CLASS_SORCERER)
2897 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
2899 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2900 mhp = mhp * tmp_hitdie / p_ptr->hitdie;
2903 if (p_ptr->pclass == CLASS_SORCERER)
2905 if (p_ptr->lev < 30)
2906 mhp = (mhp * (45+p_ptr->lev) / 100);
2908 mhp = (mhp * 75 / 100);
2909 bonus = (bonus * 65 / 100);
2914 if (p_ptr->pclass == CLASS_BERSERKER)
2916 mhp = mhp*(110+(((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110))/100;
2919 /* Always have at least one hitpoint per level */
2920 if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
2922 /* Factor in the hero / superhero settings */
2923 if (p_ptr->hero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2924 if (p_ptr->shero) mhp += 30;
2925 if (p_ptr->tsuyoshi) mhp += 50;
2927 /* New maximum hitpoints */
2928 if (p_ptr->mhp != mhp)
2930 /* Enforce maximum */
2931 if (p_ptr->chp >= mhp)
2934 p_ptr->chp_frac = 0;
2938 /* ¥ì¥Ù¥ë¥¢¥Ã¥×¤Î»þ¤Ï¾å¾ºÎ̤òɽ¼¨¤¹¤ë */
2939 if ((level_up == 1) && (mhp > p_ptr->mhp))
2941 msg_format("ºÇÂç¥Ò¥Ã¥È¡¦¥Ý¥¤¥ó¥È¤¬ %d Áý²Ã¤·¤¿¡ª",
2942 (mhp - p_ptr->mhp) );
2945 /* Save the new max-hitpoints */
2948 /* Display hitpoints (later) */
2949 p_ptr->redraw |= (PR_HP);
2952 p_ptr->window |= (PW_PLAYER);
2959 * Extract and set the current "lite radius"
2961 * SWD: Experimental modification: multiple light sources have additive effect.
2964 static void calc_torch(void)
2970 /* Assume no light */
2971 p_ptr->cur_lite = 0;
2973 /* Loop through all wielded items */
2974 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2976 o_ptr = &inventory[i];
2978 /* Examine actual lites */
2979 if ((i == INVEN_LITE) && (o_ptr->k_idx) && (o_ptr->tval == TV_LITE))
2981 if (o_ptr->name2 == EGO_LITE_DARKNESS)
2983 if (o_ptr->sval == SV_LITE_TORCH)
2985 p_ptr->cur_lite -= 1;
2988 /* Lanterns (with fuel) provide more lite */
2989 else if (o_ptr->sval == SV_LITE_LANTERN)
2991 p_ptr->cur_lite -= 2;
2994 else if (o_ptr->sval == SV_LITE_FEANOR)
2996 p_ptr->cur_lite -= 3;
2999 /* Torches (with fuel) provide some lite */
3000 else if ((o_ptr->sval == SV_LITE_TORCH) && (o_ptr->xtra4 > 0))
3002 p_ptr->cur_lite += 1;
3005 /* Lanterns (with fuel) provide more lite */
3006 else if ((o_ptr->sval == SV_LITE_LANTERN) && (o_ptr->xtra4 > 0))
3008 p_ptr->cur_lite += 2;
3011 else if (o_ptr->sval == SV_LITE_FEANOR)
3013 p_ptr->cur_lite += 2;
3016 /* Artifact Lites provide permanent, bright, lite */
3017 else if (artifact_p(o_ptr))
3019 p_ptr->cur_lite += 3;
3022 if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
3026 /* Skip empty slots */
3027 if (!o_ptr->k_idx) continue;
3029 /* Extract the flags */
3030 object_flags(o_ptr, &f1, &f2, &f3);
3032 /* does this item glow? */
3035 if ((o_ptr->name2 == EGO_DARK) || (o_ptr->name1 == ART_NIGHT)) p_ptr->cur_lite--;
3036 else p_ptr->cur_lite++;
3042 /* max radius is 5 without rewriting other code -- */
3043 /* see cave.c:update_lite() and defines.h:LITE_MAX */
3044 if (d_info[dungeon_type].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
3045 p_ptr->cur_lite = 1;
3046 if (p_ptr->cur_lite > 5) p_ptr->cur_lite = 5;
3047 if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
3049 /* check if the player doesn't have a lite source, */
3050 /* but does glow as an intrinsic. */
3051 if (p_ptr->cur_lite == 0 && p_ptr->lite) p_ptr->cur_lite = 1;
3053 /* end experimental mods */
3055 /* Reduce lite when running if requested */
3056 if (running && view_reduce_lite)
3058 /* Reduce the lite radius if needed */
3059 if (p_ptr->cur_lite > 1) p_ptr->cur_lite = 1;
3062 /* Notice changes in the "lite radius" */
3063 if (p_ptr->old_lite != p_ptr->cur_lite)
3065 /* Update the lite */
3066 p_ptr->update |= (PU_LITE);
3068 /* Update the monsters */
3069 p_ptr->update |= (PU_MONSTERS);
3071 /* Remember the old lite */
3072 p_ptr->old_lite = p_ptr->cur_lite;
3074 if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
3075 set_superstealth(FALSE);
3082 * Computes current weight limit.
3084 static int weight_limit(void)
3088 /* Weight limit based only on strength */
3089 i = adj_str_wgt[p_ptr->stat_ind[A_STR]] * 100;
3090 if (p_ptr->pclass == CLASS_BERSERKER) i = i*3/2;
3092 /* Return the result */
3097 bool buki_motteruka(int i)
3099 return ((inventory[i].k_idx && inventory[i].tval >= TV_DIGGING && inventory[i].tval <= TV_SWORD) ? TRUE : FALSE);
3103 * Calculate the players current "state", taking into account
3104 * not only race/class intrinsics, but also objects being worn
3105 * and temporary spell effects.
3107 * See also calc_mana() and calc_hitpoints().
3109 * Take note of the new "speed code", in particular, a very strong
3110 * player will start slowing down as soon as he reaches 150 pounds,
3111 * but not until he reaches 450 pounds will he be half as fast as
3112 * a normal kobold. This both hurts and helps the player, hurts
3113 * because in the old days a player could just avoid 300 pounds,
3114 * and helps because now carrying 300 pounds is not very painful.
3116 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
3117 * damage, since that would affect non-combat things. These values
3118 * are actually added in later, at the appropriate place.
3120 * This function induces various "status" messages.
3122 void calc_bonuses(void)
3124 int i, j, hold, neutral[2];
3135 bool yoiyami = FALSE;
3136 bool down_saving = FALSE;
3137 bool have_dd_s, have_dd_t, have_sw, have_kabe;
3138 bool easy_2hand = FALSE;
3139 s16b this_o_idx, next_o_idx = 0;
3140 player_race *tmp_rp_ptr;
3143 /* Save the old speed */
3144 old_speed = p_ptr->pspeed;
3146 /* Save the old vision stuff */
3147 old_telepathy = p_ptr->telepathy;
3148 old_see_inv = p_ptr->see_inv;
3150 /* Save the old armor class */
3151 old_dis_ac = p_ptr->dis_ac;
3152 old_dis_to_a = p_ptr->dis_to_a;
3155 /* Clear extra blows/shots */
3156 extra_blows[0] = extra_blows[1] = extra_shots = 0;
3158 /* Clear the stat modifiers */
3159 for (i = 0; i < 6; i++) p_ptr->stat_add[i] = 0;
3162 /* Clear the Displayed/Real armor class */
3163 p_ptr->dis_ac = p_ptr->ac = 0;
3165 /* Clear the Displayed/Real Bonuses */
3166 p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
3167 p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
3168 p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
3169 p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
3170 p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
3171 p_ptr->dis_to_a = p_ptr->to_a = 0;
3175 /* Start with "normal" speed */
3176 p_ptr->pspeed = 110;
3178 /* Start with a single blow per turn */
3179 p_ptr->num_blow[0] = 1;
3180 p_ptr->num_blow[1] = 1;
3182 /* Start with a single shot per turn */
3183 p_ptr->num_fire = 100;
3185 /* Reset the "xtra" tval */
3186 p_ptr->tval_xtra = 0;
3188 /* Reset the "ammo" tval */
3189 p_ptr->tval_ammo = 0;
3191 /* Clear all the flags */
3192 p_ptr->aggravate = FALSE;
3193 p_ptr->teleport = FALSE;
3194 p_ptr->exp_drain = FALSE;
3195 p_ptr->bless_blade = FALSE;
3196 p_ptr->xtra_might = FALSE;
3197 p_ptr->impact[0] = FALSE;
3198 p_ptr->impact[1] = FALSE;
3199 p_ptr->pass_wall = FALSE;
3200 p_ptr->kill_wall = FALSE;
3201 p_ptr->dec_mana = FALSE;
3202 p_ptr->easy_spell = FALSE;
3203 p_ptr->heavy_spell = FALSE;
3204 p_ptr->see_inv = FALSE;
3205 p_ptr->free_act = FALSE;
3206 p_ptr->slow_digest = FALSE;
3207 p_ptr->regenerate = FALSE;
3208 p_ptr->can_swim = FALSE;
3209 p_ptr->ffall = FALSE;
3210 p_ptr->hold_life = FALSE;
3211 p_ptr->telepathy = FALSE;
3212 p_ptr->lite = FALSE;
3213 p_ptr->sustain_str = FALSE;
3214 p_ptr->sustain_int = FALSE;
3215 p_ptr->sustain_wis = FALSE;
3216 p_ptr->sustain_con = FALSE;
3217 p_ptr->sustain_dex = FALSE;
3218 p_ptr->sustain_chr = FALSE;
3219 p_ptr->resist_acid = FALSE;
3220 p_ptr->resist_elec = FALSE;
3221 p_ptr->resist_fire = FALSE;
3222 p_ptr->resist_cold = FALSE;
3223 p_ptr->resist_pois = FALSE;
3224 p_ptr->resist_conf = FALSE;
3225 p_ptr->resist_sound = FALSE;
3226 p_ptr->resist_lite = FALSE;
3227 p_ptr->resist_dark = FALSE;
3228 p_ptr->resist_chaos = FALSE;
3229 p_ptr->resist_disen = FALSE;
3230 p_ptr->resist_shard = FALSE;
3231 p_ptr->resist_nexus = FALSE;
3232 p_ptr->resist_blind = FALSE;
3233 p_ptr->resist_neth = FALSE;
3234 p_ptr->resist_time = FALSE;
3235 p_ptr->resist_fear = FALSE;
3236 p_ptr->reflect = FALSE;
3237 p_ptr->sh_fire = FALSE;
3238 p_ptr->sh_elec = FALSE;
3239 p_ptr->sh_cold = FALSE;
3240 p_ptr->anti_magic = FALSE;
3241 p_ptr->anti_tele = FALSE;
3242 p_ptr->warning = FALSE;
3243 p_ptr->mighty_throw = FALSE;
3245 p_ptr->immune_acid = FALSE;
3246 p_ptr->immune_elec = FALSE;
3247 p_ptr->immune_fire = FALSE;
3248 p_ptr->immune_cold = FALSE;
3250 p_ptr->ryoute = FALSE;
3251 p_ptr->migite = FALSE;
3252 p_ptr->hidarite = FALSE;
3253 p_ptr->no_flowed = FALSE;
3257 if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
3258 else tmp_rp_ptr = &race_info[p_ptr->prace];
3260 /* Base infravision (purely racial) */
3261 p_ptr->see_infra = tmp_rp_ptr->infra;
3263 /* Base skill -- disarming */
3264 p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
3266 /* Base skill -- magic devices */
3267 p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
3269 /* Base skill -- saving throw */
3270 p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
3272 /* Base skill -- stealth */
3273 p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
3275 /* Base skill -- searching ability */
3276 p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
3278 /* Base skill -- searching frequency */
3279 p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
3281 /* Base skill -- combat (normal) */
3282 p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
3284 /* Base skill -- combat (shooting) */
3285 p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
3287 /* Base skill -- combat (throwing) */
3288 p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
3290 /* Base skill -- digging */
3291 p_ptr->skill_dig = 0;
3293 if (buki_motteruka(INVEN_RARM) && (empty_hands(FALSE) & 0x00000001) && ((inventory[INVEN_RARM].weight > 99) || (inventory[INVEN_RARM].tval == TV_POLEARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE))) p_ptr->ryoute = TRUE;
3294 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) == 3) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE))) p_ptr->ryoute = TRUE;
3295 if (buki_motteruka(INVEN_RARM) || !buki_motteruka(INVEN_LARM)) p_ptr->migite = TRUE;
3296 if (buki_motteruka(INVEN_LARM)) p_ptr->hidarite = TRUE;
3298 if (p_ptr->special_defense & KAMAE_MASK)
3300 if (empty_hands(TRUE) < 2)
3302 set_action(ACTION_NONE);
3308 if (!get_player_flags_callback())
3310 #endif /* USE_SCRIPT */
3313 switch (p_ptr->pclass)
3316 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
3317 if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
3320 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
3322 case CLASS_CHAOS_WARRIOR:
3323 if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
3324 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
3326 case CLASS_MINDCRAFTER:
3327 if (p_ptr->lev > 9) p_ptr->resist_fear = TRUE;
3328 if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
3329 if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
3330 if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
3333 case CLASS_FORCETRAINER:
3334 /* Unencumbered Monks become faster every 10 levels */
3335 if (!(heavy_armor()))
3337 if (!((p_ptr->prace == RACE_KLACKON) ||
3338 (p_ptr->prace == RACE_SPRITE) ||
3339 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
3340 p_ptr->pspeed += (p_ptr->lev) / 10;
3342 /* Free action if unencumbered at level 25 */
3343 if (p_ptr->lev > 24)
3344 p_ptr->free_act = TRUE;
3347 case CLASS_SORCERER:
3349 p_ptr->dis_to_a -= 50;
3352 p_ptr->resist_sound = TRUE;
3355 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
3357 case CLASS_BERSERKER:
3359 p_ptr->sustain_str = TRUE;
3360 p_ptr->sustain_dex = TRUE;
3361 p_ptr->sustain_con = TRUE;
3362 p_ptr->regenerate = TRUE;
3363 p_ptr->free_act = TRUE;
3365 if (p_ptr->lev > 29) p_ptr->pspeed++;
3366 if (p_ptr->lev > 39) p_ptr->pspeed++;
3367 if (p_ptr->lev > 44) p_ptr->pspeed++;
3368 if (p_ptr->lev > 49) p_ptr->pspeed++;
3369 p_ptr->to_a += 10+p_ptr->lev/2;
3370 p_ptr->dis_to_a += 10+p_ptr->lev/2;
3371 p_ptr->skill_dig += (100+p_ptr->lev*8);
3372 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
3373 p_ptr->redraw |= PR_STATUS;
3375 case CLASS_MIRROR_MASTER:
3376 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
3379 /* Unencumbered Monks become faster every 10 levels */
3382 p_ptr->pspeed -= (p_ptr->lev) / 10;
3383 p_ptr->skill_stl -= (p_ptr->lev)/10;
3387 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
3390 if (!((p_ptr->prace == RACE_KLACKON) ||
3391 (p_ptr->prace == RACE_SPRITE) ||
3392 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
3393 p_ptr->pspeed += (p_ptr->lev) / 10;
3395 p_ptr->skill_stl += (p_ptr->lev)/10;
3397 /* Free action if unencumbered at level 25 */
3398 if (p_ptr->lev > 24)
3399 p_ptr->free_act = TRUE;
3402 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
3404 p_ptr->to_a += p_ptr->lev/2+5;
3405 p_ptr->dis_to_a += p_ptr->lev/2+5;
3407 p_ptr->slow_digest = TRUE;
3408 p_ptr->resist_fear = TRUE;
3409 if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
3410 if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
3411 if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
3412 if (p_ptr->lev > 44)
3414 p_ptr->oppose_pois = 1;
3415 p_ptr->redraw |= PR_STATUS;
3422 if (p_ptr->mimic_form)
3424 switch(p_ptr->mimic_form)
3427 p_ptr->hold_life=TRUE;
3428 p_ptr->resist_chaos=TRUE;
3429 p_ptr->resist_neth=TRUE;
3430 p_ptr->resist_fire=TRUE;
3431 p_ptr->oppose_fire = 1;
3432 p_ptr->see_inv=TRUE;
3434 p_ptr->redraw |= PR_STATUS;
3436 p_ptr->dis_to_a += 10;
3438 case MIMIC_DEMON_LORD:
3439 p_ptr->hold_life=TRUE;
3440 p_ptr->resist_chaos=TRUE;
3441 p_ptr->resist_neth=TRUE;
3442 p_ptr->immune_fire=TRUE;
3443 p_ptr->resist_acid = TRUE;
3444 p_ptr->resist_fire=TRUE;
3445 p_ptr->resist_cold = TRUE;
3446 p_ptr->resist_elec = TRUE;
3447 p_ptr->resist_pois = TRUE;
3448 p_ptr->resist_conf = TRUE;
3449 p_ptr->resist_disen = TRUE;
3450 p_ptr->resist_nexus = TRUE;
3451 p_ptr->resist_fear = TRUE;
3452 p_ptr->sh_fire = TRUE;
3453 p_ptr->see_inv = TRUE;
3454 p_ptr->telepathy = TRUE;
3455 p_ptr->ffall = TRUE;
3456 p_ptr->kill_wall = TRUE;
3459 p_ptr->dis_to_a += 20;
3462 p_ptr->resist_dark = TRUE;
3463 p_ptr->hold_life = TRUE;
3464 p_ptr->resist_neth = TRUE;
3465 p_ptr->resist_cold = TRUE;
3466 p_ptr->resist_pois = TRUE;
3467 p_ptr->see_inv = TRUE;
3470 p_ptr->dis_to_a += 10;
3471 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3477 switch (p_ptr->prace)
3480 p_ptr->resist_lite = TRUE;
3483 p_ptr->sustain_dex = TRUE;
3486 p_ptr->free_act = TRUE;
3489 p_ptr->resist_blind = TRUE;
3492 p_ptr->resist_dark = TRUE;
3494 case RACE_HALF_TROLL:
3495 p_ptr->sustain_str = TRUE;
3497 if (p_ptr->lev > 14)
3499 /* High level trolls heal fast... */
3500 p_ptr->regenerate = TRUE;
3502 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
3504 p_ptr->slow_digest = TRUE;
3505 /* Let's not make Regeneration
3506 * a disadvantage for the poor warriors who can
3507 * never learn a spell that satisfies hunger (actually
3508 * neither can rogues, but half-trolls are not
3509 * supposed to play rogues) */
3514 p_ptr->sustain_con = TRUE;
3515 p_ptr->regenerate = TRUE; /* Amberites heal fast... */
3518 p_ptr->resist_lite = TRUE;
3519 p_ptr->see_inv = TRUE;
3521 case RACE_BARBARIAN:
3522 p_ptr->resist_fear = TRUE;
3524 case RACE_HALF_OGRE:
3525 p_ptr->resist_dark = TRUE;
3526 p_ptr->sustain_str = TRUE;
3528 case RACE_HALF_GIANT:
3529 p_ptr->sustain_str = TRUE;
3530 p_ptr->resist_shard = TRUE;
3532 case RACE_HALF_TITAN:
3533 p_ptr->resist_chaos = TRUE;
3536 p_ptr->resist_sound = TRUE;
3539 p_ptr->resist_acid = TRUE;
3540 if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
3543 p_ptr->resist_conf = TRUE;
3544 p_ptr->resist_acid = TRUE;
3546 /* Klackons become faster */
3547 p_ptr->pspeed += (p_ptr->lev) / 10;
3550 p_ptr->resist_pois = TRUE;
3553 p_ptr->resist_disen = TRUE;
3554 p_ptr->resist_dark = TRUE;
3557 p_ptr->resist_dark = TRUE;
3558 if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
3560 case RACE_DRACONIAN:
3561 p_ptr->ffall = TRUE;
3562 if (p_ptr->lev > 4) p_ptr->resist_fire = TRUE;
3563 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
3564 if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
3565 if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
3566 if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
3568 case RACE_MIND_FLAYER:
3569 p_ptr->sustain_int = TRUE;
3570 p_ptr->sustain_wis = TRUE;
3571 if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
3572 if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
3575 p_ptr->resist_fire = TRUE;
3576 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
3579 p_ptr->slow_digest = TRUE;
3580 p_ptr->free_act = TRUE;
3581 p_ptr->see_inv = TRUE;
3582 p_ptr->resist_pois = TRUE;
3583 if (p_ptr->lev > 34) p_ptr->hold_life = TRUE;
3586 p_ptr->resist_shard = TRUE;
3587 p_ptr->hold_life = TRUE;
3588 p_ptr->see_inv = TRUE;
3589 p_ptr->resist_pois = TRUE;
3590 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
3593 p_ptr->resist_neth = TRUE;
3594 p_ptr->hold_life = TRUE;
3595 p_ptr->see_inv = TRUE;
3596 p_ptr->resist_pois = TRUE;
3597 p_ptr->slow_digest = TRUE;
3598 if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
3601 p_ptr->resist_dark = TRUE;
3602 p_ptr->hold_life = TRUE;
3603 p_ptr->resist_neth = TRUE;
3604 p_ptr->resist_cold = TRUE;
3605 p_ptr->resist_pois = TRUE;
3606 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3609 p_ptr->ffall = TRUE;
3610 p_ptr->free_act = TRUE;
3611 p_ptr->resist_neth = TRUE;
3612 p_ptr->hold_life = TRUE;
3613 p_ptr->see_inv = TRUE;
3614 p_ptr->resist_pois = TRUE;
3615 p_ptr->slow_digest = TRUE;
3616 p_ptr->resist_cold = TRUE;
3617 p_ptr->pass_wall = TRUE;
3618 if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
3621 p_ptr->ffall = TRUE;
3622 p_ptr->resist_lite = TRUE;
3624 /* Sprites become faster */
3625 p_ptr->pspeed += (p_ptr->lev) / 10;
3628 p_ptr->resist_conf = TRUE;
3629 p_ptr->resist_sound = TRUE;
3632 /* Ents dig like maniacs, but only with their hands. */
3633 if (!inventory[INVEN_RARM].k_idx)
3634 p_ptr->skill_dig += p_ptr->lev * 10;
3635 /* Ents get tougher and stronger as they age, but lose dexterity. */
3636 if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
3637 if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
3638 if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
3640 if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
3641 if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
3642 if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
3644 if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
3645 if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
3646 if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
3649 p_ptr->ffall = TRUE;
3650 p_ptr->see_inv = TRUE;
3653 p_ptr->resist_fire = TRUE;
3654 p_ptr->resist_neth = TRUE;
3655 p_ptr->hold_life = TRUE;
3657 p_ptr->see_inv = TRUE;
3658 if (p_ptr->lev > 44)
3660 p_ptr->oppose_fire = 1;
3661 p_ptr->redraw |= PR_STATUS;
3665 p_ptr->sustain_con = TRUE;
3668 p_ptr->ffall = TRUE;
3671 p_ptr->resist_conf = TRUE;
3674 p_ptr->slow_digest = TRUE;
3675 p_ptr->free_act = TRUE;
3676 p_ptr->resist_pois = TRUE;
3677 p_ptr->hold_life = TRUE;
3685 if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
3687 p_ptr->see_inv = TRUE;
3688 p_ptr->free_act = TRUE;
3689 p_ptr->slow_digest = TRUE;
3690 p_ptr->regenerate = TRUE;
3691 p_ptr->ffall = TRUE;
3692 p_ptr->hold_life = TRUE;
3693 p_ptr->telepathy = TRUE;
3695 p_ptr->sustain_str = TRUE;
3696 p_ptr->sustain_int = TRUE;
3697 p_ptr->sustain_wis = TRUE;
3698 p_ptr->sustain_con = TRUE;
3699 p_ptr->sustain_dex = TRUE;
3700 p_ptr->sustain_chr = TRUE;
3701 p_ptr->resist_acid = TRUE;
3702 p_ptr->resist_elec = TRUE;
3703 p_ptr->resist_fire = TRUE;
3704 p_ptr->resist_cold = TRUE;
3705 p_ptr->resist_pois = TRUE;
3706 p_ptr->resist_conf = TRUE;
3707 p_ptr->resist_sound = TRUE;
3708 p_ptr->resist_lite = TRUE;
3709 p_ptr->resist_dark = TRUE;
3710 p_ptr->resist_chaos = TRUE;
3711 p_ptr->resist_disen = TRUE;
3712 p_ptr->resist_shard = TRUE;
3713 p_ptr->resist_nexus = TRUE;
3714 p_ptr->resist_blind = TRUE;
3715 p_ptr->resist_neth = TRUE;
3716 p_ptr->resist_fear = TRUE;
3717 p_ptr->reflect = TRUE;
3718 p_ptr->sh_fire = TRUE;
3719 p_ptr->sh_elec = TRUE;
3720 p_ptr->sh_cold = TRUE;
3722 p_ptr->dis_to_a += 100;
3724 if (p_ptr->tim_res_nether)
3726 p_ptr->resist_neth = TRUE;
3728 if (p_ptr->tim_sh_fire)
3730 p_ptr->sh_fire = TRUE;
3732 if (p_ptr->tim_res_time)
3734 p_ptr->resist_time = TRUE;
3738 if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->aggravate = TRUE;
3741 if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
3743 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
3745 p_ptr->resist_blind = TRUE;
3746 p_ptr->resist_conf = TRUE;
3747 p_ptr->hold_life = TRUE;
3748 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3750 if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
3751 /* Munchkin become faster */
3752 p_ptr->pspeed += (p_ptr->lev) / 10 + 5;
3757 if (!(r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_PASS_WALL))
3758 p_ptr->pass_wall = FALSE;
3759 if (r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_KILL_WALL)
3760 p_ptr->pass_wall = TRUE;
3762 if (music_singing(MUSIC_WALL)) p_ptr->kill_wall = TRUE;
3764 if (p_ptr->kill_wall) p_ptr->pass_wall = TRUE;
3766 /* Hack -- apply racial/class stat maxes */
3767 /* Apply the racial modifiers */
3768 for (i = 0; i < 6; i++)
3770 /* Modify the stats for "race" */
3771 p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
3775 /* I'm adding the mutations here for the lack of a better place... */
3778 /* Hyper Strength */
3779 if (p_ptr->muta3 & MUT3_HYPER_STR)
3781 p_ptr->stat_add[A_STR] += 4;
3785 if (p_ptr->muta3 & MUT3_PUNY)
3787 p_ptr->stat_add[A_STR] -= 4;
3790 /* Living computer */
3791 if (p_ptr->muta3 & MUT3_HYPER_INT)
3793 p_ptr->stat_add[A_INT] += 4;
3794 p_ptr->stat_add[A_WIS] += 4;
3798 if (p_ptr->muta3 & MUT3_MORONIC)
3800 p_ptr->stat_add[A_INT] -= 4;
3801 p_ptr->stat_add[A_WIS] -= 4;
3804 if (p_ptr->muta3 & MUT3_RESILIENT)
3806 p_ptr->stat_add[A_CON] += 4;
3809 if (p_ptr->muta3 & MUT3_XTRA_FAT)
3811 p_ptr->stat_add[A_CON] += 2;
3815 if (p_ptr->muta3 & MUT3_ALBINO)
3817 p_ptr->stat_add[A_CON] -= 4;
3820 if (p_ptr->muta3 & MUT3_FLESH_ROT)
3822 p_ptr->stat_add[A_CON] -= 2;
3823 p_ptr->stat_add[A_CHR] -= 1;
3824 p_ptr->regenerate = FALSE;
3825 /* Cancel innate regeneration */
3828 if (p_ptr->muta3 & MUT3_SILLY_VOI)
3830 p_ptr->stat_add[A_CHR] -= 4;
3833 if (p_ptr->muta3 & MUT3_BLANK_FAC)
3835 p_ptr->stat_add[A_CHR] -= 1;
3838 if (p_ptr->muta3 & MUT3_XTRA_EYES)
3840 p_ptr->skill_fos += 15;
3841 p_ptr->skill_srh += 15;
3844 if (p_ptr->muta3 & MUT3_MAGIC_RES)
3846 p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
3849 if (p_ptr->muta3 & MUT3_XTRA_NOIS)
3851 p_ptr->skill_stl -= 3;
3854 if (p_ptr->muta3 & MUT3_INFRAVIS)
3856 p_ptr->see_infra += 3;
3859 if (p_ptr->muta3 & MUT3_XTRA_LEGS)
3864 if (p_ptr->muta3 & MUT3_SHORT_LEG)
3869 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
3871 p_ptr->sh_elec = TRUE;
3874 if (p_ptr->muta3 & MUT3_FIRE_BODY)
3876 p_ptr->sh_fire = TRUE;
3880 if (p_ptr->muta3 & MUT3_WART_SKIN)
3882 p_ptr->stat_add[A_CHR] -= 2;
3884 p_ptr->dis_to_a += 5;
3887 if (p_ptr->muta3 & MUT3_SCALES)
3889 p_ptr->stat_add[A_CHR] -= 1;
3891 p_ptr->dis_to_a += 10;
3894 if (p_ptr->muta3 & MUT3_IRON_SKIN)
3896 p_ptr->stat_add[A_DEX] -= 1;
3898 p_ptr->dis_to_a += 25;
3901 if (p_ptr->muta3 & MUT3_WINGS)
3903 p_ptr->ffall = TRUE;
3906 if (p_ptr->muta3 & MUT3_FEARLESS)
3908 p_ptr->resist_fear = TRUE;
3911 if (p_ptr->muta3 & MUT3_REGEN)
3913 p_ptr->regenerate = TRUE;
3916 if (p_ptr->muta3 & MUT3_ESP)
3918 p_ptr->telepathy = TRUE;
3921 if (p_ptr->muta3 & MUT3_LIMBER)
3923 p_ptr->stat_add[A_DEX] += 3;
3926 if (p_ptr->muta3 & MUT3_ARTHRITIS)
3928 p_ptr->stat_add[A_DEX] -= 3;
3931 if (p_ptr->muta3 & MUT3_MOTION)
3933 p_ptr->free_act = TRUE;
3934 p_ptr->skill_stl += 1;
3937 if (p_ptr->muta3 & MUT3_ILL_NORM)
3939 p_ptr->stat_add[A_CHR] = 0;
3943 if (p_ptr->tsuyoshi)
3945 p_ptr->stat_add[A_STR] += 4;
3946 p_ptr->stat_add[A_CON] += 4;
3949 /* Scan the usable inventory */
3950 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3952 int bonus_to_h, bonus_to_d;
3953 o_ptr = &inventory[i];
3955 /* Skip non-objects */
3956 if (!o_ptr->k_idx) continue;
3957 if (o_ptr->tval == TV_CAPTURE) continue;
3959 /* Extract the item flags */
3960 object_flags(o_ptr, &f1, &f2, &f3);
3962 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_WARNING)) || (o_ptr->name1 == ART_BARAHIR)) p_ptr->warning = TRUE;
3965 if (f1 & (TR1_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
3966 if (f1 & (TR1_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
3967 if (f1 & (TR1_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
3968 if (f1 & (TR1_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
3969 if (f1 & (TR1_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
3970 if (f1 & (TR1_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
3972 if (f1 & (TR1_MAGIC_MASTERY)) p_ptr->skill_dev += 8*o_ptr->pval;
3974 /* Affect stealth */
3975 if (f1 & (TR1_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
3977 /* Affect searching ability (factor of five) */
3978 if (f1 & (TR1_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
3980 /* Affect searching frequency (factor of five) */
3981 if (f1 & (TR1_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
3983 /* Affect infravision */
3984 if (f1 & (TR1_INFRA)) p_ptr->see_infra += o_ptr->pval;
3986 /* Affect digging (factor of 20) */
3987 if (f1 & (TR1_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
3990 if (f1 & (TR1_SPEED)) p_ptr->pspeed += o_ptr->pval;
3993 if (f1 & (TR1_BLOWS))
3995 if((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
3996 else if((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
3997 else {extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval;}
4000 /* Hack -- cause earthquakes */
4001 if (f1 & (TR1_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
4004 if (f3 & (TR3_XTRA_SHOTS)) extra_shots++;
4007 if (f3 & (TR3_DEC_MANA)) p_ptr->dec_mana = TRUE;
4008 if (f3 & (TR3_AGGRAVATE)) p_ptr->aggravate = TRUE;
4009 if (f3 & (TR3_TELEPORT)) p_ptr->teleport = TRUE;
4010 if (f3 & (TR3_DRAIN_EXP)) p_ptr->exp_drain = TRUE;
4011 if (f3 & (TR3_BLESSED)) p_ptr->bless_blade = TRUE;
4012 if (f3 & (TR3_XTRA_MIGHT)) p_ptr->xtra_might = TRUE;
4013 if (f3 & (TR3_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
4014 if (f3 & (TR3_REGEN)) p_ptr->regenerate = TRUE;
4015 if (f3 & (TR3_TELEPATHY)) p_ptr->telepathy = TRUE;
4016 if (f3 & (TR3_SEE_INVIS)) p_ptr->see_inv = TRUE;
4017 if (f3 & (TR3_FEATHER)) p_ptr->ffall = TRUE;
4018 if (f2 & (TR2_FREE_ACT)) p_ptr->free_act = TRUE;
4019 if (f2 & (TR2_HOLD_LIFE)) p_ptr->hold_life = TRUE;
4021 /* Immunity flags */
4022 if (f2 & (TR2_IM_FIRE)) p_ptr->immune_fire = TRUE;
4023 if (f2 & (TR2_IM_ACID)) p_ptr->immune_acid = TRUE;
4024 if (f2 & (TR2_IM_COLD)) p_ptr->immune_cold = TRUE;
4025 if (f2 & (TR2_IM_ELEC)) p_ptr->immune_elec = TRUE;
4027 /* Resistance flags */
4028 if (f2 & (TR2_RES_ACID)) p_ptr->resist_acid = TRUE;
4029 if (f2 & (TR2_RES_ELEC)) p_ptr->resist_elec = TRUE;
4030 if (f2 & (TR2_RES_FIRE)) p_ptr->resist_fire = TRUE;
4031 if (f2 & (TR2_RES_COLD)) p_ptr->resist_cold = TRUE;
4032 if (f2 & (TR2_RES_POIS)) p_ptr->resist_pois = TRUE;
4033 if (f2 & (TR2_RES_FEAR)) p_ptr->resist_fear = TRUE;
4034 if (f2 & (TR2_RES_CONF)) p_ptr->resist_conf = TRUE;
4035 if (f2 & (TR2_RES_SOUND)) p_ptr->resist_sound = TRUE;
4036 if (f2 & (TR2_RES_LITE)) p_ptr->resist_lite = TRUE;
4037 if (f2 & (TR2_RES_DARK)) p_ptr->resist_dark = TRUE;
4038 if (f2 & (TR2_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
4039 if (f2 & (TR2_RES_DISEN)) p_ptr->resist_disen = TRUE;
4040 if (f2 & (TR2_RES_SHARDS)) p_ptr->resist_shard = TRUE;
4041 if (f2 & (TR2_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
4042 if (f2 & (TR2_RES_BLIND)) p_ptr->resist_blind = TRUE;
4043 if (f2 & (TR2_RES_NETHER)) p_ptr->resist_neth = TRUE;
4045 if (f2 & (TR2_REFLECT)) p_ptr->reflect = TRUE;
4046 if (f3 & (TR3_SH_FIRE)) p_ptr->sh_fire = TRUE;
4047 if (f3 & (TR3_SH_ELEC)) p_ptr->sh_elec = TRUE;
4048 if (f3 & (TR3_SH_COLD)) p_ptr->sh_cold = TRUE;
4049 if (f3 & (TR3_NO_MAGIC)) p_ptr->anti_magic = TRUE;
4050 if (f3 & (TR3_NO_TELE)) p_ptr->anti_tele = TRUE;
4053 if (f2 & (TR2_SUST_STR)) p_ptr->sustain_str = TRUE;
4054 if (f2 & (TR2_SUST_INT)) p_ptr->sustain_int = TRUE;
4055 if (f2 & (TR2_SUST_WIS)) p_ptr->sustain_wis = TRUE;
4056 if (f2 & (TR2_SUST_DEX)) p_ptr->sustain_dex = TRUE;
4057 if (f2 & (TR2_SUST_CON)) p_ptr->sustain_con = TRUE;
4058 if (f2 & (TR2_SUST_CHR)) p_ptr->sustain_chr = TRUE;
4060 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
4061 if (o_ptr->name2 == EGO_2HAND) easy_2hand = TRUE;
4062 if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
4063 if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
4064 if (o_ptr->name2 == EGO_RING_WIZARD) p_ptr->easy_spell = TRUE;
4065 if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
4066 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
4068 /* Modify the base armor class */
4069 p_ptr->ac += o_ptr->ac;
4071 /* The base armor class is always known */
4072 p_ptr->dis_ac += o_ptr->ac;
4074 /* Apply the bonuses to armor class */
4075 p_ptr->to_a += o_ptr->to_a;
4077 /* Apply the mental bonuses to armor class, if known */
4078 if (object_known_p(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
4080 /* Hack -- do not apply "weapon" bonuses */
4081 if (i == INVEN_RARM && buki_motteruka(i)) continue;
4082 if (i == INVEN_LARM && buki_motteruka(i)) continue;
4084 /* Hack -- do not apply "bow" bonuses */
4085 if (i == INVEN_BOW) continue;
4087 if (p_ptr->pclass == CLASS_NINJA)
4089 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h+1)/2;
4090 else bonus_to_h = o_ptr->to_h;
4091 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d+1)/2;
4092 else bonus_to_d = o_ptr->to_d;
4096 bonus_to_h = o_ptr->to_h;
4097 bonus_to_d = o_ptr->to_d;
4100 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
4102 p_ptr->to_h[i-INVEN_RIGHT] += bonus_to_h;
4103 p_ptr->to_h_b += bonus_to_h;
4104 p_ptr->to_h_m += bonus_to_h;
4105 p_ptr->to_d[i-INVEN_RIGHT] += bonus_to_d;
4106 p_ptr->to_d_m += bonus_to_d;
4108 if (object_known_p(o_ptr)) p_ptr->dis_to_h[i-INVEN_RIGHT] += bonus_to_h;
4109 if (object_known_p(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
4110 if (object_known_p(o_ptr)) p_ptr->dis_to_d[i-INVEN_RIGHT] += bonus_to_d;
4112 else if (p_ptr->migite && p_ptr->hidarite)
4114 /* Apply the bonuses to hit/damage */
4115 p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
4116 p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
4117 p_ptr->to_h_b += bonus_to_h;
4118 p_ptr->to_h_m += bonus_to_h;
4119 p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
4120 p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
4121 p_ptr->to_d_m += bonus_to_d;
4123 /* Apply the mental bonuses tp hit/damage, if known */
4124 if (object_known_p(o_ptr)) p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
4125 if (object_known_p(o_ptr)) p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
4126 if (object_known_p(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
4127 if (object_known_p(o_ptr)) p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
4128 if (object_known_p(o_ptr)) p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
4132 /* Apply the bonuses to hit/damage */
4133 if(i != INVEN_LEFT || p_ptr->ryoute) p_ptr->to_h[0] += bonus_to_h;
4134 if(i != INVEN_RIGHT) p_ptr->to_h[1] += bonus_to_h;
4135 p_ptr->to_h_b += bonus_to_h;
4136 p_ptr->to_h_m += bonus_to_h;
4137 if(i != INVEN_LEFT || p_ptr->ryoute) p_ptr->to_d[0] += bonus_to_d;
4138 if(i != INVEN_RIGHT) p_ptr->to_d[1] += bonus_to_d;
4139 p_ptr->to_d_m += bonus_to_d;
4141 /* Apply the mental bonuses tp hit/damage, if known */
4142 if ((i != INVEN_LEFT || p_ptr->ryoute) && object_known_p(o_ptr)) p_ptr->dis_to_h[0] += bonus_to_h;
4143 if ((i != INVEN_RIGHT) && object_known_p(o_ptr)) p_ptr->dis_to_h[1] += bonus_to_h;
4144 if (object_known_p(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
4145 if ((i != INVEN_LEFT || p_ptr->ryoute) && object_known_p(o_ptr)) p_ptr->dis_to_d[0] += bonus_to_d;
4146 if ((i != INVEN_RIGHT) && object_known_p(o_ptr)) p_ptr->dis_to_d[1] += bonus_to_d;
4150 /* Monks get extra ac for armour _not worn_ */
4151 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
4153 if (!(inventory[INVEN_BODY].k_idx))
4155 p_ptr->to_a += (p_ptr->lev * 3) / 2;
4156 p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
4158 if (!(inventory[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
4160 p_ptr->to_a += ((p_ptr->lev - 13) / 3);
4161 p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
4163 if (!(inventory[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
4165 p_ptr->to_a += ((p_ptr->lev - 8) / 3);
4166 p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
4168 if (!(inventory[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
4170 p_ptr->to_a += (p_ptr->lev - 2) / 3;
4171 p_ptr->dis_to_a += (p_ptr->lev -2) / 3;
4173 if (!(inventory[INVEN_HANDS].k_idx))
4175 p_ptr->to_a += (p_ptr->lev / 2);
4176 p_ptr->dis_to_a += (p_ptr->lev / 2);
4178 if (!(inventory[INVEN_FEET].k_idx))
4180 p_ptr->to_a += (p_ptr->lev / 3);
4181 p_ptr->dis_to_a += (p_ptr->lev / 3);
4183 if (p_ptr->special_defense & KAMAE_BYAKKO)
4185 p_ptr->stat_add[A_STR] += 2;
4186 p_ptr->stat_add[A_DEX] += 2;
4187 p_ptr->stat_add[A_CON] -= 3;
4189 else if (p_ptr->special_defense & KAMAE_SEIRYU)
4192 else if (p_ptr->special_defense & KAMAE_GENBU)
4194 p_ptr->stat_add[A_INT] -= 1;
4195 p_ptr->stat_add[A_WIS] -= 1;
4196 p_ptr->stat_add[A_DEX] -= 2;
4197 p_ptr->stat_add[A_CON] += 3;
4199 else if (p_ptr->special_defense & KAMAE_SUZAKU)
4201 p_ptr->stat_add[A_STR] -= 2;
4202 p_ptr->stat_add[A_INT] += 1;
4203 p_ptr->stat_add[A_WIS] += 1;
4204 p_ptr->stat_add[A_DEX] += 2;
4205 p_ptr->stat_add[A_CON] -= 2;
4209 if (p_ptr->special_defense & KATA_KOUKIJIN)
4211 for (i = 0; i < 6; i++)
4212 p_ptr->stat_add[i] += 5;
4216 /* Hack -- aura of fire also provides light */
4217 if (p_ptr->sh_fire) p_ptr->lite = TRUE;
4219 /* Golems also get an intrinsic AC bonus */
4220 if ((p_ptr->prace == RACE_GOLEM) || (p_ptr->prace == RACE_ANDROID))
4222 p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
4223 p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
4226 /* Calculate stats */
4227 for (i = 0; i < 6; i++)
4231 /* Extract the new "stat_use" value for the stat */
4232 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
4234 /* Notice changes */
4235 if (p_ptr->stat_top[i] != top)
4237 /* Save the new value */
4238 p_ptr->stat_top[i] = top;
4240 /* Redisplay the stats later */
4241 p_ptr->redraw |= (PR_STATS);
4244 p_ptr->window |= (PW_PLAYER);
4248 /* Extract the new "stat_use" value for the stat */
4249 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
4251 if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
4253 /* 10 to 18/90 charisma, guaranteed, based on level */
4254 if (use < 8 + 2 * p_ptr->lev)
4256 use = 8 + 2 * p_ptr->lev;
4260 /* Notice changes */
4261 if (p_ptr->stat_use[i] != use)
4263 /* Save the new value */
4264 p_ptr->stat_use[i] = use;
4266 /* Redisplay the stats later */
4267 p_ptr->redraw |= (PR_STATS);
4270 p_ptr->window |= (PW_PLAYER);
4274 /* Values: 3, 4, ..., 17 */
4275 if (use <= 18) ind = (use - 3);
4277 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
4278 else if (use <= 18+219) ind = (15 + (use - 18) / 10);
4280 /* Range: 18/220+ */
4283 /* Notice changes */
4284 if (p_ptr->stat_ind[i] != ind)
4286 /* Save the new index */
4287 p_ptr->stat_ind[i] = ind;
4289 /* Change in CON affects Hitpoints */
4292 p_ptr->update |= (PU_HP);
4295 /* Change in INT may affect Mana/Spells */
4296 else if (i == A_INT)
4298 if (mp_ptr->spell_stat == A_INT)
4300 p_ptr->update |= (PU_MANA | PU_SPELLS);
4304 /* Change in WIS may affect Mana/Spells */
4305 else if (i == A_WIS)
4307 if (mp_ptr->spell_stat == A_WIS)
4309 p_ptr->update |= (PU_MANA | PU_SPELLS);
4313 /* Change in WIS may affect Mana/Spells */
4314 else if (i == A_CHR)
4316 if (mp_ptr->spell_stat == A_CHR)
4318 p_ptr->update |= (PU_MANA | PU_SPELLS);
4323 p_ptr->window |= (PW_PLAYER);
4328 /* Apply temporary "stun" */
4329 if (p_ptr->stun > 50)
4331 p_ptr->to_h[0] -= 20;
4332 p_ptr->to_h[1] -= 20;
4333 p_ptr->to_h_b -= 20;
4334 p_ptr->to_h_m -= 20;
4335 p_ptr->dis_to_h[0] -= 20;
4336 p_ptr->dis_to_h[1] -= 20;
4337 p_ptr->dis_to_h_b -= 20;
4338 p_ptr->to_d[0] -= 20;
4339 p_ptr->to_d[1] -= 20;
4340 p_ptr->to_d_m -= 20;
4341 p_ptr->dis_to_d[0] -= 20;
4342 p_ptr->dis_to_d[1] -= 20;
4344 else if (p_ptr->stun)
4346 p_ptr->to_h[0] -= 5;
4347 p_ptr->to_h[1] -= 5;
4350 p_ptr->dis_to_h[0] -= 5;
4351 p_ptr->dis_to_h[1] -= 5;
4352 p_ptr->dis_to_h_b -= 5;
4353 p_ptr->to_d[0] -= 5;
4354 p_ptr->to_d[1] -= 5;
4356 p_ptr->dis_to_d[0] -= 5;
4357 p_ptr->dis_to_d[1] -= 5;
4361 if (p_ptr->wraith_form)
4363 p_ptr->reflect = TRUE;
4366 /* Temporary blessing */
4367 if (p_ptr->blessed || music_singing(MUSIC_BLESS))
4370 p_ptr->dis_to_a += 5;
4371 p_ptr->to_h[0] += 10;
4372 p_ptr->to_h[1] += 10;
4373 p_ptr->to_h_b += 10;
4374 p_ptr->to_h_m += 10;
4375 p_ptr->dis_to_h[0] += 10;
4376 p_ptr->dis_to_h[1] += 10;
4377 p_ptr->dis_to_h_b += 10;
4380 /* Temporary shield */
4381 if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
4384 p_ptr->dis_to_a += 50;
4386 if (p_ptr->magicdef)
4388 p_ptr->resist_blind = TRUE;
4389 p_ptr->resist_conf = TRUE;
4390 p_ptr->reflect = TRUE;
4391 p_ptr->free_act = TRUE;
4392 p_ptr->ffall = TRUE;
4395 /* Temporary "Hero" */
4396 if (p_ptr->hero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
4398 p_ptr->to_h[0] += 12;
4399 p_ptr->to_h[1] += 12;
4400 p_ptr->to_h_b += 12;
4401 p_ptr->to_h_m += 12;
4402 p_ptr->dis_to_h[0] += 12;
4403 p_ptr->dis_to_h[1] += 12;
4404 p_ptr->dis_to_h_b += 12;
4407 /* Temporary "Beserk" */
4410 p_ptr->to_h[0] += 12;
4411 p_ptr->to_h[1] += 12;
4412 p_ptr->to_h_b -= 12;
4413 p_ptr->to_h_m += 12;
4414 p_ptr->to_d[0] += 3+(p_ptr->lev/5);
4415 p_ptr->to_d[1] += 3+(p_ptr->lev/5);
4416 p_ptr->to_d_m += 3+(p_ptr->lev/5);
4417 p_ptr->dis_to_h[0] += 12;
4418 p_ptr->dis_to_h[1] += 12;
4419 p_ptr->dis_to_h_b -= 12;
4420 p_ptr->dis_to_d[0] += 3+(p_ptr->lev/5);
4421 p_ptr->dis_to_d[1] += 3+(p_ptr->lev/5);
4423 p_ptr->dis_to_a -= 10;
4424 p_ptr->skill_stl -= 7;
4425 p_ptr->skill_dev -= 20;
4426 p_ptr->skill_sav -= 30;
4427 p_ptr->skill_srh -= 15;
4428 p_ptr->skill_fos -= 15;
4429 p_ptr->skill_tht -= 20;
4430 p_ptr->skill_dig += 30;
4433 /* Temporary "fast" */
4434 if (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
4436 p_ptr->pspeed += 10;
4439 /* Temporary "slow" */
4442 p_ptr->pspeed -= 10;
4445 /* Temporary "telepathy" */
4446 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
4448 p_ptr->telepathy = TRUE;
4451 if (p_ptr->ele_immune)
4453 if (p_ptr->special_defense & DEFENSE_ACID)
4454 p_ptr->immune_acid = TRUE;
4455 else if (p_ptr->special_defense & DEFENSE_ELEC)
4456 p_ptr->immune_elec = TRUE;
4457 else if (p_ptr->special_defense & DEFENSE_FIRE)
4458 p_ptr->immune_fire = TRUE;
4459 else if (p_ptr->special_defense & DEFENSE_COLD)
4460 p_ptr->immune_cold = TRUE;
4463 /* Temporary see invisible */
4464 if (p_ptr->tim_invis)
4466 p_ptr->see_inv = TRUE;
4469 /* Temporary infravision boost */
4470 if (p_ptr->tim_infra)
4472 p_ptr->see_infra+=3;
4475 /* Temporary regeneration boost */
4476 if (p_ptr->tim_regen)
4478 p_ptr->regenerate = TRUE;
4481 /* Temporary levitation */
4482 if (p_ptr->tim_ffall)
4484 p_ptr->ffall = TRUE;
4487 /* Hack -- Hero/Shero -> Res fear */
4488 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
4490 p_ptr->resist_fear = TRUE;
4494 /* Hack -- Telepathy Change */
4495 if (p_ptr->telepathy != old_telepathy)
4497 p_ptr->update |= (PU_MONSTERS);
4500 /* Hack -- See Invis Change */
4501 if (p_ptr->see_inv != old_see_inv)
4503 p_ptr->update |= (PU_MONSTERS);
4506 /* Bloating slows the player down (a little) */
4507 if (p_ptr->food >= PY_FOOD_MAX) p_ptr->pspeed -= 10;
4509 if (p_ptr->special_defense & KAMAE_SUZAKU) p_ptr->pspeed += 10;
4511 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
4513 p_ptr->to_h[0] += (skill_exp[GINOU_SUDE]-4000)/200;
4514 p_ptr->dis_to_h[0] += (skill_exp[GINOU_SUDE]-4000)/200;
4517 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4519 int penalty1, penalty2;
4520 penalty1 = ((100-skill_exp[GINOU_NITOURYU]/160) - (130-inventory[INVEN_RARM].weight)/8);
4521 penalty2 = ((100-skill_exp[GINOU_NITOURYU]/160) - (130-inventory[INVEN_LARM].weight)/8);
4522 if ((inventory[INVEN_RARM].name1 == ART_QUICKTHORN) && (inventory[INVEN_LARM].name1 == ART_TINYTHORN))
4524 penalty1 = penalty1 / 2 - 5;
4525 penalty2 = penalty2 / 2 - 5;
4528 p_ptr->dis_to_a += 10;
4532 if (penalty1 > 0) penalty1 /= 2;
4533 if (penalty2 > 0) penalty2 /= 2;
4535 else if ((inventory[INVEN_LARM].tval == TV_SWORD) && ((inventory[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (inventory[INVEN_LARM].sval == SV_WAKIZASHI)))
4537 penalty1 = MAX(0, penalty1 - 10);
4538 penalty2 = MAX(0, penalty2 - 10);
4540 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
4542 penalty1 = MIN(0, penalty1);
4543 penalty2 = MIN(0, penalty2);
4545 if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
4546 if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
4547 p_ptr->to_h[0] -= penalty1;
4548 p_ptr->to_h[1] -= penalty2;
4549 p_ptr->dis_to_h[0] -= penalty1;
4550 p_ptr->dis_to_h[1] -= penalty2;
4553 /* Extract the current weight (in tenth pounds) */
4554 j = p_ptr->total_weight;
4556 /* Extract the "weight limit" (in tenth pounds) */
4561 int speed = m_list[p_ptr->riding].mspeed;
4562 if (m_list[p_ptr->riding].mspeed > 110)
4564 p_ptr->pspeed = 110 + ((speed-110)*(skill_exp[GINOU_RIDING]*3 + p_ptr->lev*160L - 10000L)/(22000L));
4565 if (p_ptr->pspeed < 110) p_ptr->pspeed = 110;
4569 p_ptr->pspeed = speed;
4571 if (m_list[p_ptr->riding].fast) p_ptr->pspeed += 10;
4572 if (m_list[p_ptr->riding].slow) p_ptr->pspeed -= 10;
4573 if (r_info[m_list[p_ptr->riding].r_idx].flags7 & RF7_CAN_FLY) p_ptr->ffall = TRUE;
4574 if (r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
4576 if (skill_exp[GINOU_RIDING] < 2000) j += (p_ptr->wt*3*(2000 - skill_exp[GINOU_RIDING]))/2000;
4578 i = 3000 + r_info[m_list[p_ptr->riding].r_idx].level * 50;
4581 /* XXX XXX XXX Apply "encumbrance" from weight */
4582 if (j > i/2) p_ptr->pspeed -= ((j - (i/2)) / (i / 10));
4584 /* Searching slows the player down */
4585 if (p_ptr->action == ACTION_SEARCH) p_ptr->pspeed -= 10;
4587 /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
4588 p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
4589 p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4590 p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4591 p_ptr->to_d_m += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4592 p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4593 p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4594 p_ptr->to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4595 p_ptr->to_h_m += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4596 p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4597 p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4598 p_ptr->to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4599 p_ptr->to_h_m += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4601 /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
4602 p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
4603 p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4604 p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4605 p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4606 p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4607 p_ptr->dis_to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4608 p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4609 p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4610 p_ptr->dis_to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4613 /* Obtain the "hold" value */
4614 hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
4617 /* Examine the "current bow" */
4618 o_ptr = &inventory[INVEN_BOW];
4621 /* Assume not heavy */
4622 p_ptr->heavy_shoot = FALSE;
4624 /* It is hard to carholdry a heavy bow */
4625 if (hold < o_ptr->weight / 10)
4627 /* Hard to wield a heavy bow */
4628 p_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
4629 p_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
4632 p_ptr->heavy_shoot = TRUE;
4636 /* Compute "extra shots" if needed */
4639 /* Analyze the launcher */
4640 switch (o_ptr->sval)
4644 p_ptr->tval_ammo = TV_SHOT;
4652 p_ptr->tval_ammo = TV_ARROW;
4659 p_ptr->tval_ammo = TV_BOLT;
4664 p_ptr->tval_ammo = TV_NO_AMMO;
4669 /* Apply special flags */
4670 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
4673 p_ptr->num_fire += (extra_shots * 100);
4675 /* Hack -- Rangers love Bows */
4676 if ((p_ptr->pclass == CLASS_RANGER) &&
4677 (p_ptr->tval_ammo == TV_ARROW))
4679 p_ptr->num_fire += (p_ptr->lev * 4);
4682 if ((p_ptr->pclass == CLASS_CAVALRY) &&
4683 (p_ptr->tval_ammo == TV_ARROW))
4685 p_ptr->num_fire += (p_ptr->lev * 3);
4688 if (p_ptr->pclass == CLASS_ARCHER)
4690 p_ptr->num_fire += (p_ptr->lev * 6);
4694 * Addendum -- also "Reward" high level warriors,
4695 * with _any_ missile weapon -- TY
4697 if (p_ptr->pclass == CLASS_WARRIOR &&
4698 (p_ptr->tval_ammo <= TV_BOLT) &&
4699 (p_ptr->tval_ammo >= TV_SHOT))
4701 p_ptr->num_fire += (p_ptr->lev * 2);
4703 if ((p_ptr->pclass == CLASS_ROGUE) &&
4704 (p_ptr->tval_ammo == TV_SHOT))
4706 p_ptr->num_fire += (p_ptr->lev * 4);
4714 for(i = 0 ; i < 2 ; i++)
4716 /* Examine the "main weapon" */
4717 o_ptr = &inventory[INVEN_RARM+i];
4719 object_flags(o_ptr, &f1, &f2, &f3);
4721 /* Assume not heavy */
4722 p_ptr->heavy_wield[i] = FALSE;
4723 p_ptr->icky_wield[i] = FALSE;
4724 p_ptr->riding_wield[i] = FALSE;
4726 if (!buki_motteruka(INVEN_RARM+i)) {p_ptr->num_blow[i]=1;continue;}
4727 /* It is hard to hold a heavy weapon */
4728 if (hold < o_ptr->weight / 10)
4730 /* Hard to wield a heavy weapon */
4731 p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
4732 p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
4735 p_ptr->heavy_wield[i] = TRUE;
4737 else if (p_ptr->ryoute && (hold < o_ptr->weight/5)) omoi = TRUE;
4739 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
4742 p_ptr->dis_to_a += 5;
4745 /* Normal weapons */
4746 if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
4748 int str_index, dex_index;
4750 int num = 0, wgt = 0, mul = 0, div = 0;
4752 /* Analyze the class */
4753 switch (p_ptr->pclass)
4757 num = 6; wgt = 70; mul = 5; break;
4760 case CLASS_BERSERKER:
4761 num = 6; wgt = 70; mul = 7; break;
4765 case CLASS_HIGH_MAGE:
4766 case CLASS_BLUE_MAGE:
4767 num = 3; wgt = 100; mul = 2; break;
4769 /* Priest, Mindcrafter */
4771 case CLASS_MAGIC_EATER:
4772 case CLASS_MINDCRAFTER:
4773 num = 5; wgt = 100; mul = 3; break;
4777 num = 5; wgt = 40; mul = 3; break;
4781 num = 5; wgt = 70; mul = 4; break;
4786 num = 5; wgt = 70; mul = 4; break;
4790 num = 5; wgt = 150; mul = 5; break;
4793 case CLASS_WARRIOR_MAGE:
4794 case CLASS_RED_MAGE:
4795 num = 5; wgt = 70; mul = 3; break;
4798 case CLASS_CHAOS_WARRIOR:
4799 num = 5; wgt = 70; mul = 4; break;
4803 num = 5; wgt = 60; mul = 3; break;
4807 num = 4; wgt = 100; mul = 3; break;
4810 case CLASS_IMITATOR:
4811 num = 5; wgt = 70; mul = 4; break;
4814 case CLASS_BEASTMASTER:
4815 num = 5; wgt = 70; mul = 3; break;
4818 if ((p_ptr->riding) && (f2 & TR2_RIDING)) {num = 5; wgt = 70; mul = 4;}
4819 else {num = 5; wgt = 100; mul = 3;}
4823 case CLASS_SORCERER:
4824 num = 1; wgt = 1; mul = 1; break;
4826 /* Archer, Magic eater */
4829 num = 4; wgt = 70; mul = 2; break;
4832 case CLASS_FORCETRAINER:
4833 num = 4; wgt = 60; mul = 2; break;
4836 case CLASS_MIRROR_MASTER:
4837 num = 3; wgt = 100; mul = 3; break;
4841 num = 4; wgt = 20; mul = 1; break;
4844 /* Enforce a minimum "weight" (tenth pounds) */
4845 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
4847 /* Access the strength vs weight */
4848 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
4850 if (p_ptr->ryoute && !omoi) str_index++;
4851 if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index-1);
4854 if (str_index > 11) str_index = 11;
4856 /* Index by dexterity */
4857 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
4860 if (dex_index > 11) dex_index = 11;
4862 /* Use the blows table */
4863 p_ptr->num_blow[i] = blows_table[str_index][dex_index];
4866 if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = num;
4868 /* Add in the "bonus blows" */
4869 p_ptr->num_blow[i] += extra_blows[i];
4872 if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
4873 else if (p_ptr->pclass == CLASS_BERSERKER)
4875 p_ptr->num_blow[i] += (p_ptr->lev / 23);
4877 else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
4879 if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
4881 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
4884 /* Require at least one blow */
4885 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
4887 /* Boost digging skill by weapon weight */
4888 p_ptr->skill_dig += (o_ptr->weight / 10);
4892 /* Priest weapon penalty for non-blessed edged weapons */
4893 if ((p_ptr->pclass == CLASS_PRIEST) && (!(f3 & (TR3_BLESSED))) &&
4894 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
4896 /* Reduce the real bonuses */
4897 p_ptr->to_h[i] -= 2;
4898 p_ptr->to_d[i] -= 2;
4900 /* Reduce the mental bonuses */
4901 p_ptr->dis_to_h[i] -= 2;
4902 p_ptr->dis_to_d[i] -= 2;
4905 p_ptr->icky_wield[i] = TRUE;
4907 else if (p_ptr->pclass == CLASS_BERSERKER)
4909 p_ptr->to_h[i] += p_ptr->lev/5;
4910 p_ptr->to_d[i] += p_ptr->lev/6;
4911 p_ptr->dis_to_h[i] += p_ptr->lev/5;
4912 p_ptr->dis_to_d[i] += p_ptr->lev/6;
4913 if (!p_ptr->hidarite || p_ptr->ryoute)
4915 p_ptr->to_h[i] += p_ptr->lev/5;
4916 p_ptr->to_d[i] += p_ptr->lev/6;
4917 p_ptr->dis_to_h[i] += p_ptr->lev/5;
4918 p_ptr->dis_to_d[i] += p_ptr->lev/6;
4921 else if (p_ptr->pclass == CLASS_SORCERER)
4923 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
4925 /* Reduce the real bonuses */
4926 p_ptr->to_h[i] -= 200;
4927 p_ptr->to_d[i] -= 200;
4929 /* Reduce the mental bonuses */
4930 p_ptr->dis_to_h[i] -= 200;
4931 p_ptr->dis_to_d[i] -= 200;
4934 p_ptr->icky_wield[i] = TRUE;
4938 /* Reduce the real bonuses */
4939 p_ptr->to_h[i] -= 30;
4940 p_ptr->to_d[i] -= 10;
4942 /* Reduce the mental bonuses */
4943 p_ptr->dis_to_h[i] -= 30;
4944 p_ptr->dis_to_d[i] -= 10;
4949 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
4951 p_ptr->to_h[i] +=15;
4952 p_ptr->dis_to_h[i] +=15;
4954 else if (!(f2 & TR2_RIDING))
4957 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
4963 penalty = r_info[m_list[p_ptr->riding].r_idx].level - skill_exp[GINOU_RIDING] / 80;
4965 if (penalty < 30) penalty = 30;
4967 p_ptr->to_h[i] -= penalty;
4968 p_ptr->dis_to_h[i] -= penalty;
4971 p_ptr->riding_wield[i] = TRUE;
4980 p_ptr->riding_ryoute = FALSE;
4981 if (p_ptr->ryoute || !empty_hands(FALSE)) p_ptr->riding_ryoute = TRUE;
4983 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
4985 if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
4989 penalty = r_info[m_list[p_ptr->riding].r_idx].level - skill_exp[GINOU_RIDING] / 80;
4991 if (penalty < 30) penalty = 30;
4993 if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
4994 p_ptr->to_h_b -= penalty;
4995 p_ptr->dis_to_h_b -= penalty;
4998 /* Different calculation for monks with empty hands */
4999 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) > 1))
5001 int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
5002 p_ptr->num_blow[0] = 0;
5004 if (p_ptr->pclass == CLASS_FORCETRAINER)
5006 if (blow_base > 18) p_ptr->num_blow[0]++;
5007 if (blow_base > 31) p_ptr->num_blow[0]++;
5008 if (blow_base > 44) p_ptr->num_blow[0]++;
5009 if (blow_base > 58) p_ptr->num_blow[0]++;
5013 if (blow_base > 12) p_ptr->num_blow[0]++;
5014 if (blow_base > 22) p_ptr->num_blow[0]++;
5015 if (blow_base > 31) p_ptr->num_blow[0]++;
5016 if (blow_base > 39) p_ptr->num_blow[0]++;
5017 if (blow_base > 46) p_ptr->num_blow[0]++;
5018 if (blow_base > 53) p_ptr->num_blow[0]++;
5019 if (blow_base > 59) p_ptr->num_blow[0]++;
5022 if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
5023 p_ptr->num_blow[0] /= 2;
5026 p_ptr->to_h[0] += (p_ptr->lev / 3);
5027 p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
5029 p_ptr->to_d[0] += (p_ptr->lev / 6);
5030 p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
5033 if (p_ptr->special_defense & KAMAE_BYAKKO)
5036 p_ptr->dis_to_a -= 40;
5039 else if (p_ptr->special_defense & KAMAE_SEIRYU)
5042 p_ptr->dis_to_a -= 50;
5043 p_ptr->resist_acid = TRUE;
5044 p_ptr->resist_fire = TRUE;
5045 p_ptr->resist_elec = TRUE;
5046 p_ptr->resist_cold = TRUE;
5047 p_ptr->resist_pois = TRUE;
5048 p_ptr->sh_fire = TRUE;
5049 p_ptr->sh_elec = TRUE;
5050 p_ptr->sh_cold = TRUE;
5051 p_ptr->ffall = TRUE;
5053 else if (p_ptr->special_defense & KAMAE_GENBU)
5055 p_ptr->to_a += (p_ptr->lev*p_ptr->lev)/50;
5056 p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev)/50;
5057 p_ptr->reflect = TRUE;
5058 p_ptr->num_blow[0] -= 2;
5059 if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
5060 if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
5062 else if (p_ptr->special_defense & KAMAE_SUZAKU)
5064 p_ptr->to_h[0] -= (p_ptr->lev / 3);
5065 p_ptr->to_d[0] -= (p_ptr->lev / 6);
5067 p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
5068 p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
5069 p_ptr->num_blow[0] /= 2;
5070 p_ptr->ffall = TRUE;
5073 p_ptr->num_blow[0] += 1+extra_blows[0];
5076 monk_armour_aux = FALSE;
5080 monk_armour_aux = TRUE;
5083 for (i = 0 ; i < 2 ; i++)
5085 if(buki_motteruka(INVEN_RARM+i))
5087 p_ptr->to_h[i] += (weapon_exp[inventory[INVEN_RARM+i].tval-TV_BOW][inventory[INVEN_RARM+i].sval]-4000)/200;
5088 p_ptr->dis_to_h[i] += (weapon_exp[inventory[INVEN_RARM+i].tval-TV_BOW][inventory[INVEN_RARM+i].sval]-4000)/200;
5089 if ((p_ptr->pclass == CLASS_MONK) && !(weapon_exp_settei[CLASS_MONK][inventory[INVEN_RARM+i].tval-TV_BOW][inventory[INVEN_RARM+i].sval][1]))
5091 p_ptr->to_h[i] -= 40;
5092 p_ptr->dis_to_h[i] -= 40;
5093 p_ptr->icky_wield[i] = TRUE;
5095 else if ((p_ptr->pclass == CLASS_FORCETRAINER) && !(weapon_exp_settei[CLASS_FORCETRAINER][inventory[INVEN_RARM+i].tval-TV_BOW][inventory[INVEN_RARM+i].sval][1]))
5097 p_ptr->to_h[i] -= 40;
5098 p_ptr->dis_to_h[i] -= 40;
5099 p_ptr->icky_wield[i] = TRUE;
5101 else if (p_ptr->pclass == CLASS_NINJA)
5103 if ((weapon_exp_settei[CLASS_NINJA][inventory[INVEN_RARM+i].tval-TV_BOW][inventory[INVEN_RARM+i].sval][1] <= 4000) || (inventory[INVEN_LARM-i].tval == TV_SHIELD))
5105 p_ptr->to_h[i] -= 40;
5106 p_ptr->dis_to_h[i] -= 40;
5107 p_ptr->icky_wield[i] = TRUE;
5108 p_ptr->num_blow[i] /= 2;
5109 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
5115 /* Temporary lightspeed */
5116 if ((p_ptr->lightspeed && !p_ptr->riding) || (p_ptr->pspeed > 209))
5118 p_ptr->pspeed = 209;
5120 if (p_ptr->pspeed < 11) p_ptr->pspeed = 11;
5122 /* Display the speed (if needed) */
5123 if (p_ptr->pspeed != old_speed) p_ptr->redraw |= (PR_SPEED);
5127 if (p_ptr->to_a > (0 - p_ptr->ac))
5128 p_ptr->to_a = 0 - p_ptr->ac;
5129 if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
5130 p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
5133 /* Redraw armor (if needed) */
5134 if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
5137 p_ptr->redraw |= (PR_ARMOR);
5140 p_ptr->window |= (PW_PLAYER);
5144 if (p_ptr->ryoute && !omoi)
5146 int bonus_to_h=0, bonus_to_d=0;
5147 bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
5148 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);
5150 p_ptr->to_h[0] += MAX(bonus_to_h,1);
5151 p_ptr->dis_to_h[0] += MAX(bonus_to_h,1);
5152 p_ptr->to_d[0] += MAX(bonus_to_d,1);
5153 p_ptr->dis_to_d[0] += MAX(bonus_to_d,1);
5156 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) == 3)) p_ptr->ryoute = FALSE;
5158 /* Affect Skill -- stealth (bonus one) */
5159 p_ptr->skill_stl += 1;
5161 if (p_ptr->tim_stealth || music_singing(MUSIC_STEALTH))
5162 p_ptr->skill_stl += 99;
5164 /* Affect Skill -- disarming (DEX and INT) */
5165 p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
5166 p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
5168 /* Affect Skill -- magic devices (INT) */
5169 p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
5171 /* Affect Skill -- saving throw (WIS) */
5172 p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
5174 /* Affect Skill -- digging (STR) */
5175 p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
5177 /* Affect Skill -- disarming (Level, by Class) */
5178 p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
5180 /* Affect Skill -- magic devices (Level, by Class) */
5181 p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
5183 /* Affect Skill -- saving throw (Level, by Class) */
5184 p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
5186 /* Affect Skill -- stealth (Level, by Class) */
5187 p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
5189 /* Affect Skill -- search ability (Level, by Class) */
5190 p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
5192 /* Affect Skill -- search frequency (Level, by Class) */
5193 p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
5195 /* Affect Skill -- combat (normal) (Level, by Class) */
5196 p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
5198 /* Affect Skill -- combat (shooting) (Level, by Class) */
5199 p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
5201 /* Affect Skill -- combat (throwing) (Level, by Class) */
5202 p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
5205 if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && p_ptr->aggravate)
5207 p_ptr->aggravate = FALSE;
5208 p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
5211 /* Limit Skill -- stealth from 0 to 30 */
5212 if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
5213 if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
5215 /* Limit Skill -- digging from 1 up */
5216 if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
5218 if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
5220 if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
5222 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;
5224 if (down_saving) p_ptr->skill_sav /= 2;
5226 /* Hack -- handle "xtra" mode */
5227 if (character_xtra) return;
5229 /* Take note when "heavy bow" changes */
5230 if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
5233 if (p_ptr->heavy_shoot)
5236 msg_print("¤³¤ó¤Ê½Å¤¤µÝ¤òÁõÈ÷¤·¤Æ¤¤¤ë¤Î¤ÏÂçÊѤÀ¡£");
5238 msg_print("You have trouble wielding such a heavy bow.");
5242 else if (inventory[INVEN_BOW].k_idx)
5245 msg_print("¤³¤ÎµÝ¤Ê¤éÁõÈ÷¤·¤Æ¤¤¤Æ¤â¿É¤¯¤Ê¤¤¡£");
5247 msg_print("You have no trouble wielding your bow.");
5254 msg_print("½Å¤¤µÝ¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤ÆÂΤ¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5256 msg_print("You feel relieved to put down your heavy bow.");
5262 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
5265 for(i = 0 ; i < 2 ; i++)
5267 /* Take note when "heavy weapon" changes */
5268 if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
5271 if (p_ptr->heavy_wield[i])
5274 msg_print("¤³¤ó¤Ê½Å¤¤Éð´ï¤òÁõÈ÷¤·¤Æ¤¤¤ë¤Î¤ÏÂçÊѤÀ¡£");
5276 msg_print("You have trouble wielding such a heavy weapon.");
5280 else if (buki_motteruka(INVEN_RARM+i))
5283 msg_print("¤³¤ì¤Ê¤éÁõÈ÷¤·¤Æ¤¤¤Æ¤â¿É¤¯¤Ê¤¤¡£");
5285 msg_print("You have no trouble wielding your weapon.");
5289 else if (p_ptr->heavy_wield[1-i])
5292 msg_print("¤Þ¤ÀÉð´ï¤¬½Å¤¤¡£");
5294 msg_print("You have still trouble wielding a heavy weapon.");
5301 msg_print("½Å¤¤Éð´ï¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤ÆÂΤ¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5303 msg_print("You feel relieved to put down your heavy weapon.");
5309 p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
5312 /* Take note when "heavy weapon" changes */
5313 if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
5316 if (p_ptr->riding_wield[i])
5319 msg_print("¤³¤ÎÉð´ï¤Ï¾èÇÏÃæ¤Ë»È¤¦¤Ë¤Ï¤à¤«¤Ê¤¤¤è¤¦¤À¡£");
5321 msg_print("This weapon is not suitable for riding.");
5325 else if (!p_ptr->riding)
5328 msg_print("¤³¤ÎÉð´ï¤ÏÅÌÊâ¤Ç»È¤¤¤ä¤¹¤¤¡£");
5330 msg_print("This weapon was not suitable for riding.");
5334 else if (buki_motteruka(INVEN_RARM+i))
5337 msg_print("¤³¤ì¤Ê¤é¾èÇÏÃæ¤Ë¤Ô¤Ã¤¿¤ê¤À¡£");
5339 msg_print("This weapon is suitable for riding.");
5344 p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
5347 /* Take note when "illegal weapon" changes */
5348 if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
5351 if (p_ptr->icky_wield[i])
5354 msg_print("º£¤ÎÁõÈ÷¤Ï¤É¤¦¤â¼«Ê¬¤Ë¤Õ¤µ¤ï¤·¤¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
5356 msg_print("You do not feel comfortable with your weapon.");
5360 chg_virtue(V_FAITH, -1);
5363 else if (buki_motteruka(INVEN_RARM+i))
5366 msg_print("º£¤ÎÁõÈ÷¤Ï¼«Ê¬¤Ë¤Õ¤µ¤ï¤·¤¤µ¤¤¬¤¹¤ë¡£");
5368 msg_print("You feel comfortable with your weapon.");
5375 msg_print("ÁõÈ÷¤ò¤Ï¤º¤·¤¿¤é¿ïʬ¤Èµ¤¤¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5377 msg_print("You feel more comfortable after removing your weapon.");
5383 p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
5387 if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
5390 if (p_ptr->riding_ryoute)
5393 msg_print("ξ¼ê¤¬¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ÆÇϤòÁà¤ì¤Ê¤¤¡£");
5395 msg_print("You are using both hand for fighting, and you can't control a riding pet.");
5401 msg_print("¼ê¤¬¶õ¤¤¤ÆÇϤòÁà¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
5403 msg_print("You began to control riding pet with one hand.");
5407 p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
5410 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (monk_armour_aux != monk_notify_aux))
5415 msg_print("ÁõÈ÷¤¬½Å¤¯¤Æ¥Ð¥é¥ó¥¹¤ò¼è¤ì¤Ê¤¤¡£");
5417 msg_print("The weight of your armor disrupts your balance.");
5422 chg_virtue(V_HARMONY, -1);
5427 msg_print("¥Ð¥é¥ó¥¹¤¬¤È¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
5429 msg_print("You regain your balance.");
5432 monk_notify_aux = monk_armour_aux;
5436 p_ptr->align = friend_align;
5438 /* Determine player alignment */
5439 for (i = 0; i < 8; i++)
5441 if ((p_ptr->vir_types[i] == V_HARMONY) || (p_ptr->vir_types[i] == V_NATURE))
5446 else if (p_ptr->vir_types[i] == V_UNLIFE) p_ptr->align -= p_ptr->virtues[i];
5447 else if (p_ptr->vir_types[i] == V_JUSTICE) p_ptr->align += (p_ptr->virtues[i]*2);
5448 else if (p_ptr->vir_types[i] != V_CHANCE) p_ptr->align += p_ptr->virtues[i];
5452 if (p_ptr->align > 0)
5454 p_ptr->align -= (p_ptr->virtues[j]/2);
5455 if (p_ptr->align < 0) p_ptr->align = 0;
5457 else if (p_ptr->align < 0)
5459 p_ptr->align += (p_ptr->virtues[j]/2);
5460 if (p_ptr->align > 0) p_ptr->align = 0;
5464 if ((inventory[INVEN_RARM].name1 == ART_IRON_BALL) || (inventory[INVEN_LARM].name1 == ART_IRON_BALL)) p_ptr->align -= 1000;
5465 if (prace_is_(RACE_ANGEL)) p_ptr->align += 200;
5466 if ((prace_is_(RACE_DEMON)) || (p_ptr->mimic_form == MIMIC_DEMON_LORD) || (p_ptr->mimic_form == MIMIC_DEMON)) p_ptr->align -= 200;
5472 for (i = 0; i < INVEN_PACK; i++)
5474 if ((inventory[i].tval == TV_SORCERY_BOOK) && (inventory[i].sval == 3)) have_dd_s = TRUE;
5475 if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
5476 if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
5477 if ((inventory[i].tval == TV_ENCHANT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
5479 for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
5483 /* Acquire object */
5484 o_ptr = &o_list[this_o_idx];
5486 /* Acquire next object */
5487 next_o_idx = o_ptr->next_o_idx;
5489 if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
5490 if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
5491 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
5492 if ((o_ptr->tval == TV_ENCHANT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
5495 if ((p_ptr->pass_wall && !p_ptr->kill_wall) || p_ptr->kabenuke || p_ptr->wraith_form) p_ptr->no_flowed = TRUE;
5497 if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
5499 magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S];
5500 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5503 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)))
5505 magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T];
5506 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5509 if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
5511 magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW];
5512 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5515 if (have_kabe && ((p_ptr->realm1 == REALM_ENCHANT) || (p_ptr->realm2 == REALM_ENCHANT) || (p_ptr->pclass == CLASS_SORCERER)))
5517 magic_type *s_ptr = &mp_ptr->info[REALM_ENCHANT-1][SPELL_KABE];
5518 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5525 * Handle "p_ptr->notice"
5527 void notice_stuff(void)
5530 if (!p_ptr->notice) return;
5533 /* Combine the pack */
5534 if (p_ptr->notice & (PN_COMBINE))
5536 p_ptr->notice &= ~(PN_COMBINE);
5540 /* Reorder the pack */
5541 if (p_ptr->notice & (PN_REORDER))
5543 p_ptr->notice &= ~(PN_REORDER);
5550 * Handle "p_ptr->update"
5552 void update_stuff(void)
5555 if (!p_ptr->update) return;
5558 if (p_ptr->update & (PU_BONUS))
5560 p_ptr->update &= ~(PU_BONUS);
5564 if (p_ptr->update & (PU_TORCH))
5566 p_ptr->update &= ~(PU_TORCH);
5570 if (p_ptr->update & (PU_HP))
5572 p_ptr->update &= ~(PU_HP);
5576 if (p_ptr->update & (PU_MANA))
5578 p_ptr->update &= ~(PU_MANA);
5582 if (p_ptr->update & (PU_SPELLS))
5584 p_ptr->update &= ~(PU_SPELLS);
5589 /* Character is not ready yet, no screen updates */
5590 if (!character_generated) return;
5593 /* Character is in "icky" mode, no screen updates */
5594 if (character_icky) return;
5597 if (p_ptr->update & (PU_UN_LITE))
5599 p_ptr->update &= ~(PU_UN_LITE);
5603 if (p_ptr->update & (PU_UN_VIEW))
5605 p_ptr->update &= ~(PU_UN_VIEW);
5609 if (p_ptr->update & (PU_VIEW))
5611 p_ptr->update &= ~(PU_VIEW);
5615 if (p_ptr->update & (PU_LITE))
5617 p_ptr->update &= ~(PU_LITE);
5622 if (p_ptr->update & (PU_FLOW))
5624 p_ptr->update &= ~(PU_FLOW);
5628 if (p_ptr->update & (PU_MON_LITE))
5630 p_ptr->update &= ~(PU_MON_LITE);
5634 if (p_ptr->update & (PU_DISTANCE))
5636 p_ptr->update &= ~(PU_DISTANCE);
5637 p_ptr->update &= ~(PU_MONSTERS);
5638 update_monsters(TRUE);
5641 if (p_ptr->update & (PU_MONSTERS))
5643 p_ptr->update &= ~(PU_MONSTERS);
5644 update_monsters(FALSE);
5650 * Handle "p_ptr->redraw"
5652 void redraw_stuff(void)
5655 if (!p_ptr->redraw) return;
5658 /* Character is not ready yet, no screen updates */
5659 if (!character_generated) return;
5662 /* Character is in "icky" mode, no screen updates */
5663 if (character_icky) return;
5667 /* Hack -- clear the screen */
5668 if (p_ptr->redraw & (PR_WIPE))
5670 p_ptr->redraw &= ~(PR_WIPE);
5676 if (p_ptr->redraw & (PR_MAP))
5678 p_ptr->redraw &= ~(PR_MAP);
5683 if (p_ptr->redraw & (PR_BASIC))
5685 p_ptr->redraw &= ~(PR_BASIC);
5686 p_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
5687 p_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
5688 p_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
5689 p_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
5695 if (p_ptr->redraw & (PR_DUNGEON))
5697 p_ptr->redraw &= ~(PR_DUNGEON);
5700 if (p_ptr->redraw & (PR_EQUIPPY))
5702 p_ptr->redraw &= ~(PR_EQUIPPY);
5703 print_equippy(); /* To draw / delete equippy chars */
5706 if (p_ptr->redraw & (PR_MISC))
5708 p_ptr->redraw &= ~(PR_MISC);
5709 prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
5710 /* prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
5714 if (p_ptr->redraw & (PR_TITLE))
5716 p_ptr->redraw &= ~(PR_TITLE);
5720 if (p_ptr->redraw & (PR_LEV))
5722 p_ptr->redraw &= ~(PR_LEV);
5726 if (p_ptr->redraw & (PR_EXP))
5728 p_ptr->redraw &= ~(PR_EXP);
5732 if (p_ptr->redraw & (PR_STATS))
5734 p_ptr->redraw &= ~(PR_STATS);
5743 if (p_ptr->redraw & (PR_STATUS))
5745 p_ptr->redraw &= ~(PR_STATUS);
5749 if (p_ptr->redraw & (PR_ARMOR))
5751 p_ptr->redraw &= ~(PR_ARMOR);
5755 if (p_ptr->redraw & (PR_HP))
5757 p_ptr->redraw &= ~(PR_HP);
5761 if (p_ptr->redraw & (PR_MANA))
5763 p_ptr->redraw &= ~(PR_MANA);
5767 if (p_ptr->redraw & (PR_GOLD))
5769 p_ptr->redraw &= ~(PR_GOLD);
5773 if (p_ptr->redraw & (PR_DEPTH))
5775 p_ptr->redraw &= ~(PR_DEPTH);
5779 if (p_ptr->redraw & (PR_HEALTH))
5781 p_ptr->redraw &= ~(PR_HEALTH);
5785 if (p_ptr->redraw & (PR_UHEALTH))
5787 p_ptr->redraw &= ~(PR_UHEALTH);
5788 riding_health_redraw();
5792 if (p_ptr->redraw & (PR_EXTRA))
5794 p_ptr->redraw &= ~(PR_EXTRA);
5795 p_ptr->redraw &= ~(PR_CUT | PR_STUN);
5796 p_ptr->redraw &= ~(PR_HUNGER);
5797 p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_MANE | PR_STATUS);
5801 if (p_ptr->redraw & (PR_CUT))
5803 p_ptr->redraw &= ~(PR_CUT);
5807 if (p_ptr->redraw & (PR_STUN))
5809 p_ptr->redraw &= ~(PR_STUN);
5813 if (p_ptr->redraw & (PR_HUNGER))
5815 p_ptr->redraw &= ~(PR_HUNGER);
5819 if (p_ptr->redraw & (PR_STATE))
5821 p_ptr->redraw &= ~(PR_STATE);
5825 if (p_ptr->redraw & (PR_SPEED))
5827 p_ptr->redraw &= ~(PR_SPEED);
5831 if (p_ptr->pclass == CLASS_IMITATOR)
5833 if (p_ptr->redraw & (PR_MANE))
5835 p_ptr->redraw &= ~(PR_MANE);
5839 else if (p_ptr->redraw & (PR_STUDY))
5841 p_ptr->redraw &= ~(PR_STUDY);
5848 * Handle "p_ptr->window"
5850 void window_stuff(void)
5858 if (!p_ptr->window) return;
5861 for (j = 0; j < 8; j++)
5863 /* Save usable flags */
5864 if (angband_term[j]) mask |= window_flag[j];
5867 /* Apply usable flags */
5868 p_ptr->window &= mask;
5871 if (!p_ptr->window) return;
5874 /* Display inventory */
5875 if (p_ptr->window & (PW_INVEN))
5877 p_ptr->window &= ~(PW_INVEN);
5881 /* Display equipment */
5882 if (p_ptr->window & (PW_EQUIP))
5884 p_ptr->window &= ~(PW_EQUIP);
5888 /* Display spell list */
5889 if (p_ptr->window & (PW_SPELL))
5891 p_ptr->window &= ~(PW_SPELL);
5895 /* Display player */
5896 if (p_ptr->window & (PW_PLAYER))
5898 p_ptr->window &= ~(PW_PLAYER);
5902 /* Display overhead view */
5903 if (p_ptr->window & (PW_MESSAGE))
5905 p_ptr->window &= ~(PW_MESSAGE);
5909 /* Display overhead view */
5910 if (p_ptr->window & (PW_OVERHEAD))
5912 p_ptr->window &= ~(PW_OVERHEAD);
5916 /* Display overhead view */
5917 if (p_ptr->window & (PW_DUNGEON))
5919 p_ptr->window &= ~(PW_DUNGEON);
5923 /* Display monster recall */
5924 if (p_ptr->window & (PW_MONSTER))
5926 p_ptr->window &= ~(PW_MONSTER);
5930 /* Display object recall */
5931 if (p_ptr->window & (PW_OBJECT))
5933 p_ptr->window &= ~(PW_OBJECT);
5940 * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
5942 void handle_stuff(void)
5945 if (p_ptr->update) update_stuff();
5948 if (p_ptr->redraw) redraw_stuff();
5951 if (p_ptr->window) window_stuff();
5955 s16b empty_hands(bool is_monk)
5958 if (is_monk && (p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_BERSERKER)) return FALSE;
5960 if (!(inventory[INVEN_RARM].k_idx)) kaerichi +=2;
5961 if (!(inventory[INVEN_LARM].k_idx)) kaerichi +=1;
5966 bool heavy_armor(void)
5968 u16b monk_arm_wgt = 0;
5970 if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
5972 /* Weight the armor */
5973 if(inventory[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_RARM].weight;
5974 if(inventory[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_LARM].weight;
5975 monk_arm_wgt += inventory[INVEN_BODY].weight;
5976 monk_arm_wgt += inventory[INVEN_HEAD].weight;
5977 monk_arm_wgt += inventory[INVEN_OUTER].weight;
5978 monk_arm_wgt += inventory[INVEN_HANDS].weight;
5979 monk_arm_wgt += inventory[INVEN_FEET].weight;
5981 return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
5984 int number_of_quests(void)
5988 /* Clear the counter */
5991 for (j = MIN_RANDOM_QUEST; j < MAX_RANDOM_QUEST+1; j++)
5993 if (quest[j].status != QUEST_STATUS_UNTAKEN)
5995 /* Increment count of quests taken. */
6000 /* Return the number of quests taken */